From 5198dd42ef4ccf839e7d4450f6ce14d73d492a6c Mon Sep 17 00:00:00 2001 From: Yeming Liu <Yeming.Liu@microsoft.com> Date: Tue, 1 Sep 2020 14:32:45 +0800 Subject: [PATCH] [KeyVault] Support new resource: managed HSM (#14569) * mhsm * mhsm2 * exclude from test * mhsm3 * bump up version * all new api versions * generate from merged spec * include tests --- .../keyvault_resource-manager.txt | 10 +- .../AzSdk.RP.props | 2 +- .../Generated/IKeyVaultManagementClient.cs | 10 +- .../src/Generated/IManagedHsmsOperations.cs | 305 +++ .../src/Generated/KeyVaultManagementClient.cs | 12 +- .../src/Generated/ManagedHsmsOperations.cs | 1650 +++++++++++++++++ .../ManagedHsmsOperationsExtensions.cs | 473 +++++ .../src/Generated/Models/Error.cs | 68 + .../src/Generated/Models/ManagedHsm.cs | 73 + .../src/Generated/Models/ManagedHsmError.cs | 51 + .../Models/ManagedHsmErrorException.cs | 62 + .../Generated/Models/ManagedHsmProperties.cs | 155 ++ .../Generated/Models/ManagedHsmResource.cs | 113 ++ .../src/Generated/Models/ManagedHsmSku.cs | 75 + .../src/Generated/Models/ManagedHsmSkuName.cs | 60 + .../src/Generated/Models/ProvisioningState.cs | 53 + .../src/Generated/Models/VaultProperties.cs | 8 +- .../src/Generated/Operations.cs | 16 +- .../PrivateEndpointConnectionsOperations.cs | 30 +- .../PrivateLinkResourcesOperations.cs | 10 +- .../SdkInfo_KeyVaultManagementClient.cs | 7 +- .../src/Generated/VaultsOperations.cs | 110 +- ...Microsoft.Azure.Management.KeyVault.csproj | 6 +- .../src/Properties/AssemblyInfo.cs | 2 +- ...oft.Azure.Management.KeyVault.Tests.csproj | 4 +- 25 files changed, 3233 insertions(+), 132 deletions(-) create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IManagedHsmsOperations.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperations.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperationsExtensions.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/Error.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsm.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmError.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmErrorException.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmProperties.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmResource.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSku.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSkuName.cs create mode 100644 sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ProvisioningState.cs diff --git a/eng/mgmt/mgmtmetadata/keyvault_resource-manager.txt b/eng/mgmt/mgmtmetadata/keyvault_resource-manager.txt index 417f9ba83d67..ffba64259597 100644 --- a/eng/mgmt/mgmtmetadata/keyvault_resource-manager.txt +++ b/eng/mgmt/mgmtmetadata/keyvault_resource-manager.txt @@ -1,14 +1,14 @@ -Installing AutoRest version: 2.0.4413 +Installing AutoRest version: v2 AutoRest installed successfully. Commencing code generation Generating CSharp code Executing AutoRest command -cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/resource-manager/readme.md --csharp --version=2.0.4413 --reflect-api-versions --csharp.output-folder=C:\Users\yeliu\isra-fel\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.Management.KeyVault\src\Generated -2020-03-24 07:45:59 UTC +cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp.output-folder=C:\Users\yeliu\isra-fel\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.Management.KeyVault\src\Generated +2020-08-25 07:58:48 UTC Azure-rest-api-specs repository information GitHub fork: Azure Branch: master -Commit: c9a1ed48c35572cf59cb5030e678a9d614684a7f +Commit: 122829cebe6e4177e9eb6ff349071d3e2034b0e7 AutoRest information -Requested version: 2.0.4413 +Requested version: v2 Bootstrapper version: autorest@2.0.4413 diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/AzSdk.RP.props b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/AzSdk.RP.props index 54bffcb3f9f6..e6952d50565d 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/AzSdk.RP.props +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/AzSdk.RP.props @@ -1,7 +1,7 @@ <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file--> <PropertyGroup> - <AzureApiTag>KeyVault_2019-09-01;KeyVaultManagementClient_2019-09-01;</AzureApiTag> + <AzureApiTag>KeyVault_2019-09-01;KeyVault_2020-04-01-preview;KeyVaultManagementClient_2019-09-01;</AzureApiTag> <PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags> </PropertyGroup> </Project> \ No newline at end of file diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IKeyVaultManagementClient.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IKeyVaultManagementClient.cs index c52d34e300bc..f3de174aee62 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IKeyVaultManagementClient.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IKeyVaultManagementClient.cs @@ -48,11 +48,6 @@ public partial interface IKeyVaultManagementClient : System.IDisposable /// </summary> string SubscriptionId { get; set; } - /// <summary> - /// Client Api Version. - /// </summary> - string ApiVersion { get; } - /// <summary> /// The preferred language for the response. /// </summary> @@ -92,5 +87,10 @@ public partial interface IKeyVaultManagementClient : System.IDisposable /// </summary> IOperations Operations { get; } + /// <summary> + /// Gets the IManagedHsmsOperations. + /// </summary> + IManagedHsmsOperations ManagedHsms { get; } + } } diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IManagedHsmsOperations.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IManagedHsmsOperations.cs new file mode 100644 index 000000000000..0d326629baf7 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/IManagedHsmsOperations.cs @@ -0,0 +1,305 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// <summary> + /// ManagedHsmsOperations operations. + /// </summary> + public partial interface IManagedHsmsOperations + { + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<ManagedHsm>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<ManagedHsm>> UpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// Gets the specified managed HSM Pool. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool. + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<ManagedHsm>> GetWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// The List operation gets information about the managed HSM Pools + /// associated with the subscription and within the specified resource + /// group. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<IPage<ManagedHsm>>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, int? top = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// The List operation gets information about the managed HSM Pools + /// associated with the subscription. + /// </summary> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<IPage<ManagedHsm>>> ListBySubscriptionWithHttpMessagesAsync(int? top = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<ManagedHsm>> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<ManagedHsm>> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// The List operation gets information about the managed HSM Pools + /// associated with the subscription and within the specified resource + /// group. + /// </summary> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<IPage<ManagedHsm>>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// The List operation gets information about the managed HSM Pools + /// associated with the subscription. + /// </summary> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="Microsoft.Rest.SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="Microsoft.Rest.ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + Task<AzureOperationResponse<IPage<ManagedHsm>>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/KeyVaultManagementClient.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/KeyVaultManagementClient.cs index 6939f9756371..5445b99956e7 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/KeyVaultManagementClient.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/KeyVaultManagementClient.cs @@ -54,11 +54,6 @@ public partial class KeyVaultManagementClient : ServiceClient<KeyVaultManagement /// </summary> public string SubscriptionId { get; set; } - /// <summary> - /// Client Api Version. - /// </summary> - public string ApiVersion { get; private set; } - /// <summary> /// The preferred language for the response. /// </summary> @@ -97,6 +92,11 @@ public partial class KeyVaultManagementClient : ServiceClient<KeyVaultManagement /// </summary> public virtual IOperations Operations { get; private set; } + /// <summary> + /// Gets the IManagedHsmsOperations. + /// </summary> + public virtual IManagedHsmsOperations ManagedHsms { get; private set; } + /// <summary> /// Initializes a new instance of the KeyVaultManagementClient class. /// </summary> @@ -342,8 +342,8 @@ private void Initialize() PrivateEndpointConnections = new PrivateEndpointConnectionsOperations(this); PrivateLinkResources = new PrivateLinkResourcesOperations(this); Operations = new Operations(this); + ManagedHsms = new ManagedHsmsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2019-09-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperations.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperations.cs new file mode 100644 index 000000000000..77d3d9ac9e81 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperations.cs @@ -0,0 +1,1650 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault +{ + 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; + + /// <summary> + /// ManagedHsmsOperations operations. + /// </summary> + internal partial class ManagedHsmsOperations : IServiceOperations<KeyVaultManagementClient>, IManagedHsmsOperations + { + /// <summary> + /// Initializes a new instance of the ManagedHsmsOperations class. + /// </summary> + /// <param name='client'> + /// Reference to the service client. + /// </param> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + internal ManagedHsmsOperations(KeyVaultManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// <summary> + /// Gets a reference to the KeyVaultManagementClient + /// </summary> + public KeyVaultManagementClient Client { get; private set; } + + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public async Task<AzureOperationResponse<ManagedHsm>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse<ManagedHsm> _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public async Task<AzureOperationResponse<ManagedHsm>> UpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse<ManagedHsm> _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, name, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + /// <param name='customHeaders'> + /// The headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, name, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// <summary> + /// Gets the specified managed HSM Pool. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool. + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<ManagedHsm>> GetWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2020-04-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List<string> _queryParameters = new List<string>(); + 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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<ManagedHsm>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsm>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription and within the specified resource group. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<IPage<ManagedHsm>>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, int? top = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2020-04-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("top", top); + tracingParameters.Add("apiVersion", apiVersion); + 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.KeyVault/managedHSMs").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List<string> _queryParameters = new List<string>(); + 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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<IPage<ManagedHsm>>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ManagedHsm>>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription. + /// </summary> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<IPage<ManagedHsm>>> ListBySubscriptionWithHttpMessagesAsync(int? top = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2020-04-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("top", top); + tracingParameters.Add("apiVersion", apiVersion); + 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.KeyVault/managedHSMs").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List<string> _queryParameters = new List<string>(); + 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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<IPage<ManagedHsm>>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ManagedHsm>>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<ManagedHsm>> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (name != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(name, "^[a-zA-Z0-9]{3,24}$")) + { + throw new ValidationException(ValidationRules.Pattern, "name", "^[a-zA-Z0-9]{3,24}$"); + } + } + 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 = "2020-04-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + 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/Microsoft.KeyVault/managedHSMs/{name}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List<string> _queryParameters = new List<string>(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<ManagedHsm>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsm>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsm>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<ManagedHsm>> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string name, ManagedHsm parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (name != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(name, "^[a-zA-Z0-9]{3,24}$")) + { + throw new ValidationException(ValidationRules.Pattern, "name", "^[a-zA-Z0-9]{3,24}$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2020-04-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + 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/Microsoft.KeyVault/managedHSMs/{name}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List<string> _queryParameters = new List<string>(); + 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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<ManagedHsm>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsm>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsm>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2020-04-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List<string> _queryParameters = new List<string>(); + 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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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; + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription and within the specified resource group. + /// </summary> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<IPage<ManagedHsm>>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>(); + 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<string> _queryParameters = new List<string>(); + if (_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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<IPage<ManagedHsm>>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ManagedHsm>>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription. + /// </summary> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + /// <param name='customHeaders'> + /// Headers that will be added to request. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + /// <exception cref="ManagedHsmErrorException"> + /// Thrown when the operation returned an invalid status code + /// </exception> + /// <exception cref="SerializationException"> + /// Thrown when unable to deserialize the response + /// </exception> + /// <exception cref="ValidationException"> + /// Thrown when a required parameter is null + /// </exception> + /// <exception cref="System.ArgumentNullException"> + /// Thrown when a required parameter is null + /// </exception> + /// <return> + /// A response object containing the response body and response headers. + /// </return> + public async Task<AzureOperationResponse<IPage<ManagedHsm>>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> 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<string, object> tracingParameters = new Dictionary<string, object>(); + 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<string> _queryParameters = new List<string>(); + if (_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 ManagedHsmErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ManagedHsmError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ManagedHsmError>(_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<IPage<ManagedHsm>>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ManagedHsm>>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.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/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperationsExtensions.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperationsExtensions.cs new file mode 100644 index 000000000000..b58e3160edf3 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/ManagedHsmsOperationsExtensions.cs @@ -0,0 +1,473 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// <summary> + /// Extension methods for ManagedHsmsOperations. + /// </summary> + public static partial class ManagedHsmsOperationsExtensions + { + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + public static ManagedHsm CreateOrUpdate(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, name, parameters).GetAwaiter().GetResult(); + } + + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<ManagedHsm> CreateOrUpdateAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + public static ManagedHsm Update(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters) + { + return operations.UpdateAsync(resourceGroupName, name, parameters).GetAwaiter().GetResult(); + } + + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<ManagedHsm> UpdateAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, name, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + public static void Delete(this IManagedHsmsOperations operations, string resourceGroupName, string name) + { + operations.DeleteAsync(resourceGroupName, name).GetAwaiter().GetResult(); + } + + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task DeleteAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// <summary> + /// Gets the specified managed HSM Pool. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool. + /// </param> + public static ManagedHsm Get(this IManagedHsmsOperations operations, string resourceGroupName, string name) + { + return operations.GetAsync(resourceGroupName, name).GetAwaiter().GetResult(); + } + + /// <summary> + /// Gets the specified managed HSM Pool. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<ManagedHsm> GetAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription and within the specified resource group. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + public static IPage<ManagedHsm> ListByResourceGroup(this IManagedHsmsOperations operations, string resourceGroupName, int? top = default(int?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, top).GetAwaiter().GetResult(); + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription and within the specified resource group. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<IPage<ManagedHsm>> ListByResourceGroupAsync(this IManagedHsmsOperations operations, string resourceGroupName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + public static IPage<ManagedHsm> ListBySubscription(this IManagedHsmsOperations operations, int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(top).GetAwaiter().GetResult(); + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='top'> + /// Maximum number of results to return. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<IPage<ManagedHsm>> ListBySubscriptionAsync(this IManagedHsmsOperations operations, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + public static ManagedHsm BeginCreateOrUpdate(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, name, parameters).GetAwaiter().GetResult(); + } + + /// <summary> + /// Create or update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to create or update the managed HSM Pool + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<ManagedHsm> BeginCreateOrUpdateAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + public static ManagedHsm BeginUpdate(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters) + { + return operations.BeginUpdateAsync(resourceGroupName, name, parameters).GetAwaiter().GetResult(); + } + + /// <summary> + /// Update a managed HSM Pool in the specified subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// Name of the managed HSM Pool + /// </param> + /// <param name='parameters'> + /// Parameters to patch the managed HSM Pool + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<ManagedHsm> BeginUpdateAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, ManagedHsm parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, name, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + public static void BeginDelete(this IManagedHsmsOperations operations, string resourceGroupName, string name) + { + operations.BeginDeleteAsync(resourceGroupName, name).GetAwaiter().GetResult(); + } + + /// <summary> + /// Deletes the specified managed HSM Pool. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='resourceGroupName'> + /// Name of the resource group that contains the managed HSM pool. + /// </param> + /// <param name='name'> + /// The name of the managed HSM Pool to delete + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task BeginDeleteAsync(this IManagedHsmsOperations operations, string resourceGroupName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription and within the specified resource group. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + public static IPage<ManagedHsm> ListByResourceGroupNext(this IManagedHsmsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription and within the specified resource group. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<IPage<ManagedHsm>> ListByResourceGroupNextAsync(this IManagedHsmsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + public static IPage<ManagedHsm> ListBySubscriptionNext(this IManagedHsmsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// <summary> + /// The List operation gets information about the managed HSM Pools associated + /// with the subscription. + /// </summary> + /// <param name='operations'> + /// The operations group for this extension method. + /// </param> + /// <param name='nextPageLink'> + /// The NextLink from the previous successful call to List operation. + /// </param> + /// <param name='cancellationToken'> + /// The cancellation token. + /// </param> + public static async Task<IPage<ManagedHsm>> ListBySubscriptionNextAsync(this IManagedHsmsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/Error.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/Error.cs new file mode 100644 index 000000000000..77ae9e8bbe92 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/Error.cs @@ -0,0 +1,68 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// <summary> + /// The server error. + /// </summary> + public partial class Error + { + /// <summary> + /// Initializes a new instance of the Error class. + /// </summary> + public Error() + { + CustomInit(); + } + + /// <summary> + /// Initializes a new instance of the Error class. + /// </summary> + /// <param name="code">The error code.</param> + /// <param name="message">The error message.</param> + /// <param name="innerError">The inner error, contains a more specific + /// error code.</param> + public Error(string code = default(string), string message = default(string), Error innerError = default(Error)) + { + Code = code; + Message = message; + InnerError = innerError; + CustomInit(); + } + + /// <summary> + /// An initialization method that performs custom operations like setting defaults + /// </summary> + partial void CustomInit(); + + /// <summary> + /// Gets the error code. + /// </summary> + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// <summary> + /// Gets the error message. + /// </summary> + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// <summary> + /// Gets the inner error, contains a more specific error code. + /// </summary> + [JsonProperty(PropertyName = "innererror")] + public Error InnerError { get; private set; } + + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsm.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsm.cs new file mode 100644 index 000000000000..2c8d405f635e --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsm.cs @@ -0,0 +1,73 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// <summary> + /// Resource information with extended details. + /// </summary> + public partial class ManagedHsm : ManagedHsmResource + { + /// <summary> + /// Initializes a new instance of the ManagedHsm class. + /// </summary> + public ManagedHsm() + { + CustomInit(); + } + + /// <summary> + /// Initializes a new instance of the ManagedHsm class. + /// </summary> + /// <param name="id">The Azure Resource Manager resource ID for the + /// managed HSM Pool.</param> + /// <param name="name">The name of the managed HSM Pool.</param> + /// <param name="type">The resource type of the managed HSM + /// Pool.</param> + /// <param name="location">The supported Azure location where the + /// managed HSM Pool should be created.</param> + /// <param name="sku">SKU details</param> + /// <param name="tags">Resource tags</param> + /// <param name="properties">Properties of the managed HSM</param> + public ManagedHsm(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), IDictionary<string, string> tags = default(IDictionary<string, string>), ManagedHsmProperties properties = default(ManagedHsmProperties)) + : base(id, name, type, location, sku, tags) + { + Properties = properties; + CustomInit(); + } + + /// <summary> + /// An initialization method that performs custom operations like setting defaults + /// </summary> + partial void CustomInit(); + + /// <summary> + /// Gets or sets properties of the managed HSM + /// </summary> + [JsonProperty(PropertyName = "properties")] + public ManagedHsmProperties Properties { get; set; } + + /// <summary> + /// Validate the object. + /// </summary> + /// <exception cref="Rest.ValidationException"> + /// Thrown if validation fails + /// </exception> + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmError.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmError.cs new file mode 100644 index 000000000000..bcaf15f1b9cb --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmError.cs @@ -0,0 +1,51 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// <summary> + /// The error exception. + /// </summary> + public partial class ManagedHsmError + { + /// <summary> + /// Initializes a new instance of the ManagedHsmError class. + /// </summary> + public ManagedHsmError() + { + CustomInit(); + } + + /// <summary> + /// Initializes a new instance of the ManagedHsmError class. + /// </summary> + /// <param name="error">The server error.</param> + public ManagedHsmError(Error error = default(Error)) + { + Error = error; + CustomInit(); + } + + /// <summary> + /// An initialization method that performs custom operations like setting defaults + /// </summary> + partial void CustomInit(); + + /// <summary> + /// Gets the server error. + /// </summary> + [JsonProperty(PropertyName = "error")] + public Error Error { get; private set; } + + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmErrorException.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmErrorException.cs new file mode 100644 index 000000000000..69094783a2cb --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmErrorException.cs @@ -0,0 +1,62 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Microsoft.Rest; + + /// <summary> + /// Exception thrown for an invalid response with ManagedHsmError + /// information. + /// </summary> + public partial class ManagedHsmErrorException : RestException + { + /// <summary> + /// Gets information about the associated HTTP request. + /// </summary> + public HttpRequestMessageWrapper Request { get; set; } + + /// <summary> + /// Gets information about the associated HTTP response. + /// </summary> + public HttpResponseMessageWrapper Response { get; set; } + + /// <summary> + /// Gets or sets the body object. + /// </summary> + public ManagedHsmError Body { get; set; } + + /// <summary> + /// Initializes a new instance of the ManagedHsmErrorException class. + /// </summary> + public ManagedHsmErrorException() + { + } + + /// <summary> + /// Initializes a new instance of the ManagedHsmErrorException class. + /// </summary> + /// <param name="message">The exception message.</param> + public ManagedHsmErrorException(string message) + : this(message, null) + { + } + + /// <summary> + /// Initializes a new instance of the ManagedHsmErrorException class. + /// </summary> + /// <param name="message">The exception message.</param> + /// <param name="innerException">Inner exception.</param> + public ManagedHsmErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmProperties.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmProperties.cs new file mode 100644 index 000000000000..f3a0a3092e83 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmProperties.cs @@ -0,0 +1,155 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// <summary> + /// Properties of the managed HSM Pool + /// </summary> + public partial class ManagedHsmProperties + { + /// <summary> + /// Initializes a new instance of the ManagedHsmProperties class. + /// </summary> + public ManagedHsmProperties() + { + CustomInit(); + } + + /// <summary> + /// Initializes a new instance of the ManagedHsmProperties class. + /// </summary> + /// <param name="tenantId">The Azure Active Directory tenant ID that + /// should be used for authenticating requests to the managed HSM + /// pool.</param> + /// <param name="initialAdminObjectIds">Array of initial administrators + /// object ids for this managed hsm pool.</param> + /// <param name="hsmPoolUri">The URI of the managed hsm pool for + /// performing operations on keys.</param> + /// <param name="enableSoftDelete">Property to specify whether the + /// 'soft delete' functionality is enabled for this managed HSM pool. + /// If it's not set to any value(true or false) when creating new + /// managed HSM pool, it will be set to true by default. Once set to + /// true, it cannot be reverted to false.</param> + /// <param name="softDeleteRetentionInDays">softDelete data retention + /// days. It accepts >=7 and <=90.</param> + /// <param name="enablePurgeProtection">Property specifying whether + /// protection against purge is enabled for this managed HSM pool. + /// Setting this property to true activates protection against purge + /// for this managed HSM pool and its content - only the Managed HSM + /// service may initiate a hard, irrecoverable deletion. The setting is + /// effective only if soft delete is also enabled. Enabling this + /// functionality is irreversible.</param> + /// <param name="createMode">The create mode to indicate whether the + /// resource is being created or is being recovered from a deleted + /// resource. Possible values include: 'recover', 'default'</param> + /// <param name="statusMessage">Resource Status Message.</param> + /// <param name="provisioningState">Provisioning state. Possible values + /// include: 'Succeeded', 'Provisioning', 'Failed', 'Updating', + /// 'Deleting', 'Activated', 'SecurityDomainRestore', + /// 'Restoring'</param> + public ManagedHsmProperties(System.Guid? tenantId = default(System.Guid?), IList<string> initialAdminObjectIds = default(IList<string>), string hsmPoolUri = default(string), bool? enableSoftDelete = default(bool?), int? softDeleteRetentionInDays = default(int?), bool? enablePurgeProtection = default(bool?), CreateMode? createMode = default(CreateMode?), string statusMessage = default(string), string provisioningState = default(string)) + { + TenantId = tenantId; + InitialAdminObjectIds = initialAdminObjectIds; + HsmPoolUri = hsmPoolUri; + EnableSoftDelete = enableSoftDelete; + SoftDeleteRetentionInDays = softDeleteRetentionInDays; + EnablePurgeProtection = enablePurgeProtection; + CreateMode = createMode; + StatusMessage = statusMessage; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// <summary> + /// An initialization method that performs custom operations like setting defaults + /// </summary> + partial void CustomInit(); + + /// <summary> + /// Gets or sets the Azure Active Directory tenant ID that should be + /// used for authenticating requests to the managed HSM pool. + /// </summary> + [JsonProperty(PropertyName = "tenantId")] + public System.Guid? TenantId { get; set; } + + /// <summary> + /// Gets or sets array of initial administrators object ids for this + /// managed hsm pool. + /// </summary> + [JsonProperty(PropertyName = "initialAdminObjectIds")] + public IList<string> InitialAdminObjectIds { get; set; } + + /// <summary> + /// Gets or sets the URI of the managed hsm pool for performing + /// operations on keys. + /// </summary> + [JsonProperty(PropertyName = "hsmPoolUri")] + public string HsmPoolUri { get; set; } + + /// <summary> + /// Gets or sets property to specify whether the 'soft delete' + /// functionality is enabled for this managed HSM pool. If it's not set + /// to any value(true or false) when creating new managed HSM pool, it + /// will be set to true by default. Once set to true, it cannot be + /// reverted to false. + /// </summary> + [JsonProperty(PropertyName = "enableSoftDelete")] + public bool? EnableSoftDelete { get; set; } + + /// <summary> + /// Gets or sets softDelete data retention days. It accepts &gt;=7 + /// and &lt;=90. + /// </summary> + [JsonProperty(PropertyName = "softDeleteRetentionInDays")] + public int? SoftDeleteRetentionInDays { get; set; } + + /// <summary> + /// Gets or sets property specifying whether protection against purge + /// is enabled for this managed HSM pool. Setting this property to true + /// activates protection against purge for this managed HSM pool and + /// its content - only the Managed HSM service may initiate a hard, + /// irrecoverable deletion. The setting is effective only if soft + /// delete is also enabled. Enabling this functionality is + /// irreversible. + /// </summary> + [JsonProperty(PropertyName = "enablePurgeProtection")] + public bool? EnablePurgeProtection { get; set; } + + /// <summary> + /// Gets or sets the create mode to indicate whether the resource is + /// being created or is being recovered from a deleted resource. + /// Possible values include: 'recover', 'default' + /// </summary> + [JsonProperty(PropertyName = "createMode")] + public CreateMode? CreateMode { get; set; } + + /// <summary> + /// Gets resource Status Message. + /// </summary> + [JsonProperty(PropertyName = "statusMessage")] + public string StatusMessage { get; private set; } + + /// <summary> + /// Gets provisioning state. Possible values include: 'Succeeded', + /// 'Provisioning', 'Failed', 'Updating', 'Deleting', 'Activated', + /// 'SecurityDomainRestore', 'Restoring' + /// </summary> + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmResource.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmResource.cs new file mode 100644 index 000000000000..5d65eecafb53 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmResource.cs @@ -0,0 +1,113 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// <summary> + /// Managed HSM resource + /// </summary> + public partial class ManagedHsmResource : IResource + { + /// <summary> + /// Initializes a new instance of the ManagedHsmResource class. + /// </summary> + public ManagedHsmResource() + { + CustomInit(); + } + + /// <summary> + /// Initializes a new instance of the ManagedHsmResource class. + /// </summary> + /// <param name="id">The Azure Resource Manager resource ID for the + /// managed HSM Pool.</param> + /// <param name="name">The name of the managed HSM Pool.</param> + /// <param name="type">The resource type of the managed HSM + /// Pool.</param> + /// <param name="location">The supported Azure location where the + /// managed HSM Pool should be created.</param> + /// <param name="sku">SKU details</param> + /// <param name="tags">Resource tags</param> + public ManagedHsmResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), IDictionary<string, string> tags = default(IDictionary<string, string>)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Sku = sku; + Tags = tags; + CustomInit(); + } + + /// <summary> + /// An initialization method that performs custom operations like setting defaults + /// </summary> + partial void CustomInit(); + + /// <summary> + /// Gets the Azure Resource Manager resource ID for the managed HSM + /// Pool. + /// </summary> + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// <summary> + /// Gets the name of the managed HSM Pool. + /// </summary> + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// <summary> + /// Gets the resource type of the managed HSM Pool. + /// </summary> + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// <summary> + /// Gets or sets the supported Azure location where the managed HSM + /// Pool should be created. + /// </summary> + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// <summary> + /// Gets or sets SKU details + /// </summary> + [JsonProperty(PropertyName = "sku")] + public ManagedHsmSku Sku { get; set; } + + /// <summary> + /// Gets or sets resource tags + /// </summary> + [JsonProperty(PropertyName = "tags")] + public IDictionary<string, string> Tags { get; set; } + + /// <summary> + /// Validate the object. + /// </summary> + /// <exception cref="ValidationException"> + /// Thrown if validation fails + /// </exception> + public virtual void Validate() + { + if (Sku != null) + { + Sku.Validate(); + } + } + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSku.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSku.cs new file mode 100644 index 000000000000..ee026d520adb --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSku.cs @@ -0,0 +1,75 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// <summary> + /// SKU details + /// </summary> + public partial class ManagedHsmSku + { + /// <summary> + /// Initializes a new instance of the ManagedHsmSku class. + /// </summary> + public ManagedHsmSku() + { + CustomInit(); + } + + /// <summary> + /// Initializes a new instance of the ManagedHsmSku class. + /// </summary> + /// <param name="name">SKU of the managed HSM Pool. Possible values + /// include: 'Standard_B1', 'Custom_B32'</param> + public ManagedHsmSku(ManagedHsmSkuName name) + { + Name = name; + CustomInit(); + } + /// <summary> + /// Static constructor for ManagedHsmSku class. + /// </summary> + static ManagedHsmSku() + { + Family = "B"; + } + + /// <summary> + /// An initialization method that performs custom operations like setting defaults + /// </summary> + partial void CustomInit(); + + /// <summary> + /// Gets or sets SKU of the managed HSM Pool. Possible values include: + /// 'Standard_B1', 'Custom_B32' + /// </summary> + [JsonProperty(PropertyName = "name")] + public ManagedHsmSkuName Name { get; set; } + + /// <summary> + /// SKU Family of the managed HSM Pool + /// </summary> + [JsonProperty(PropertyName = "family")] + public static string Family { get; private set; } + + /// <summary> + /// Validate the object. + /// </summary> + /// <exception cref="Rest.ValidationException"> + /// Thrown if validation fails + /// </exception> + public virtual void Validate() + { + } + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSkuName.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSkuName.cs new file mode 100644 index 000000000000..a7443c2cebf8 --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ManagedHsmSkuName.cs @@ -0,0 +1,60 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// <summary> + /// Defines values for ManagedHsmSkuName. + /// </summary> + [JsonConverter(typeof(StringEnumConverter))] + public enum ManagedHsmSkuName + { + [EnumMember(Value = "Standard_B1")] + StandardB1, + [EnumMember(Value = "Custom_B32")] + CustomB32 + } + internal static class ManagedHsmSkuNameEnumExtension + { + internal static string ToSerializedValue(this ManagedHsmSkuName? value) + { + return value == null ? null : ((ManagedHsmSkuName)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ManagedHsmSkuName value) + { + switch( value ) + { + case ManagedHsmSkuName.StandardB1: + return "Standard_B1"; + case ManagedHsmSkuName.CustomB32: + return "Custom_B32"; + } + return null; + } + + internal static ManagedHsmSkuName? ParseManagedHsmSkuName(this string value) + { + switch( value ) + { + case "Standard_B1": + return ManagedHsmSkuName.StandardB1; + case "Custom_B32": + return ManagedHsmSkuName.CustomB32; + } + return null; + } + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ProvisioningState.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..9bbe9c85523d --- /dev/null +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,53 @@ +// <auto-generated> +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// </auto-generated> + +namespace Microsoft.Azure.Management.KeyVault.Models +{ + + /// <summary> + /// Defines values for ProvisioningState. + /// </summary> + public static class ProvisioningState + { + /// <summary> + /// The managed HSM Pool has been full provisioned. + /// </summary> + public const string Succeeded = "Succeeded"; + /// <summary> + /// The managed HSM Pool is currently being provisioned. + /// </summary> + public const string Provisioning = "Provisioning"; + /// <summary> + /// Provisioning of the managed HSM Pool has failed. + /// </summary> + public const string Failed = "Failed"; + /// <summary> + /// The managed HSM Pool is currently being updated. + /// </summary> + public const string Updating = "Updating"; + /// <summary> + /// The managed HSM Pool is currently being deleted. + /// </summary> + public const string Deleting = "Deleting"; + /// <summary> + /// The managed HSM pool is ready for normal use. + /// </summary> + public const string Activated = "Activated"; + /// <summary> + /// The managed HSM pool is waiting for a security domain restore + /// action. + /// </summary> + public const string SecurityDomainRestore = "SecurityDomainRestore"; + /// <summary> + /// The managed HSM pool is being restored from full HSM backup. + /// </summary> + public const string Restoring = "Restoring"; + } +} diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/VaultProperties.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/VaultProperties.cs index 976ca743b9bc..9f580d1ae2b6 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/VaultProperties.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Models/VaultProperties.cs @@ -37,7 +37,7 @@ public VaultProperties() /// should be used for authenticating requests to the key /// vault.</param> /// <param name="sku">SKU details</param> - /// <param name="accessPolicies">An array of 0 to 16 identities that + /// <param name="accessPolicies">An array of 0 to 1024 identities that /// have access to the key vault. All identities in the array must use /// the same tenant ID as the key vault's tenant ID. When `createMode` /// is set to `recover`, access policies are not required. Otherwise, @@ -122,9 +122,9 @@ public VaultProperties() public Sku Sku { get; set; } /// <summary> - /// Gets or sets an array of 0 to 16 identities that have access to the - /// key vault. All identities in the array must use the same tenant ID - /// as the key vault's tenant ID. When `createMode` is set to + /// Gets or sets an array of 0 to 1024 identities that have access to + /// the key vault. All identities in the array must use the same tenant + /// ID as the key vault's tenant ID. When `createMode` is set to /// `recover`, access policies are not required. Otherwise, access /// policies are required. /// </summary> diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Operations.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Operations.cs index c7f6e2a12097..e6a9bb02727c 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Operations.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/Operations.cs @@ -65,21 +65,12 @@ internal Operations(KeyVaultManagementClient client) /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> - /// <exception cref="ValidationException"> - /// Thrown when a required parameter is null - /// </exception> - /// <exception cref="System.ArgumentNullException"> - /// Thrown when a required parameter is null - /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task<AzureOperationResponse<IPage<Operation>>> ListWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -87,6 +78,7 @@ internal Operations(KeyVaultManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } @@ -94,9 +86,9 @@ internal Operations(KeyVaultManagementClient client) var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.KeyVault/operations").ToString(); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateEndpointConnectionsOperations.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateEndpointConnectionsOperations.cs index e064090a5b66..970a8e9528b0 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateEndpointConnectionsOperations.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateEndpointConnectionsOperations.cs @@ -109,10 +109,7 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -123,6 +120,7 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); } @@ -134,9 +132,9 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -325,14 +323,11 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (properties == null) { throw new ValidationException(ValidationRules.CannotBeNull, "properties"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -343,6 +338,7 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("properties", properties); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Put", tracingParameters); @@ -355,9 +351,9 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -588,10 +584,7 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -602,6 +595,7 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); } @@ -613,9 +607,9 @@ internal PrivateEndpointConnectionsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateLinkResourcesOperations.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateLinkResourcesOperations.cs index b1bde0a13752..fea7442aebbf 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateLinkResourcesOperations.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/PrivateLinkResourcesOperations.cs @@ -101,10 +101,7 @@ internal PrivateLinkResourcesOperations(KeyVaultManagementClient client) throw new ValidationException(ValidationRules.Pattern, "vaultName", "^[a-zA-Z0-9-]{3,24}$"); } } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -114,6 +111,7 @@ internal PrivateLinkResourcesOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListByVault", tracingParameters); } @@ -124,9 +122,9 @@ internal PrivateLinkResourcesOperations(KeyVaultManagementClient client) _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/SdkInfo_KeyVaultManagementClient.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/SdkInfo_KeyVaultManagementClient.cs index 2ec2c146cb46..0af6c64bbca4 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/SdkInfo_KeyVaultManagementClient.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/SdkInfo_KeyVaultManagementClient.cs @@ -19,6 +19,7 @@ public static IEnumerable<Tuple<string, string, string>> ApiInfo_KeyVaultManagem { return new Tuple<string, string, string>[] { + new Tuple<string, string, string>("KeyVault", "ManagedHsms", "2020-04-01-preview"), new Tuple<string, string, string>("KeyVault", "Operations", "2019-09-01"), new Tuple<string, string, string>("KeyVault", "PrivateEndpointConnections", "2019-09-01"), new Tuple<string, string, string>("KeyVault", "PrivateLinkResources", "2019-09-01"), @@ -28,12 +29,12 @@ public static IEnumerable<Tuple<string, string, string>> ApiInfo_KeyVaultManagem } } // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "2.0.4413"; + public static readonly String AutoRestVersion = "v2"; public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/resource-manager/readme.md --csharp --version=2.0.4413 --reflect-api-versions --csharp.output-folder=C:\\Users\\yeliu\\isra-fel\\azure-sdk-for-net\\sdk\\keyvault\\Microsoft.Azure.Management.KeyVault\\src\\Generated"; + public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp.output-folder=C:\\Users\\yeliu\\isra-fel\\azure-sdk-for-net\\sdk\\keyvault\\Microsoft.Azure.Management.KeyVault\\src\\Generated"; public static readonly String GithubForkName = "Azure"; public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "c9a1ed48c35572cf59cb5030e678a9d614684a7f"; + public static readonly String GithubCommidId = "122829cebe6e4177e9eb6ff349071d3e2034b0e7"; public static readonly String CodeGenerationErrors = ""; public static readonly String GithubRepoName = "azure-rest-api-specs"; // END: Code Generation Metadata Section diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/VaultsOperations.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/VaultsOperations.cs index 175587fccdb5..bdbf8d307169 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/VaultsOperations.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Generated/VaultsOperations.cs @@ -125,10 +125,6 @@ internal VaultsOperations(KeyVaultManagementClient client) throw new ValidationException(ValidationRules.Pattern, "vaultName", "^[a-zA-Z0-9-]{3,24}$"); } } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (parameters == null) { throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); @@ -137,6 +133,7 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -146,6 +143,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); @@ -157,9 +155,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -347,14 +345,11 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "vaultName"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -364,6 +359,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); } @@ -374,9 +370,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -525,14 +521,11 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "vaultName"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -542,6 +535,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); } @@ -552,9 +546,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -734,10 +728,6 @@ internal VaultsOperations(KeyVaultManagementClient client) throw new ValidationException(ValidationRules.Pattern, "vaultName", "^[a-zA-Z0-9-]{3,24}$"); } } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (parameters == null) { throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); @@ -750,6 +740,7 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -760,6 +751,7 @@ internal VaultsOperations(KeyVaultManagementClient client) tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); tracingParameters.Add("operationKind", operationKind); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "UpdateAccessPolicy", tracingParameters); @@ -772,9 +764,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{operationKind}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(operationKind, Client.SerializationSettings).Trim('"'))); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -962,14 +954,11 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -979,6 +968,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("top", top); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); } @@ -992,9 +982,9 @@ internal VaultsOperations(KeyVaultManagementClient client) { _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1151,14 +1141,11 @@ internal VaultsOperations(KeyVaultManagementClient client) /// </return> public async Task<AzureOperationResponse<IPage<Vault>>> ListBySubscriptionWithHttpMessagesAsync(int? top = default(int?), Dictionary<string, List<string>> 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"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1167,6 +1154,7 @@ internal VaultsOperations(KeyVaultManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("top", top); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); } @@ -1179,9 +1167,9 @@ internal VaultsOperations(KeyVaultManagementClient client) { _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); } - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1334,14 +1322,11 @@ internal VaultsOperations(KeyVaultManagementClient client) /// </return> public async Task<AzureOperationResponse<IPage<DeletedVault>>> ListDeletedWithHttpMessagesAsync(Dictionary<string, List<string>> 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"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1349,6 +1334,7 @@ internal VaultsOperations(KeyVaultManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "ListDeleted", tracingParameters); } @@ -1357,9 +1343,9 @@ internal VaultsOperations(KeyVaultManagementClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1526,14 +1512,11 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "location"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1543,6 +1526,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("vaultName", vaultName); tracingParameters.Add("location", location); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetDeleted", tracingParameters); } @@ -1553,9 +1537,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -1933,14 +1917,11 @@ internal VaultsOperations(KeyVaultManagementClient client) { vaultName.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"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1949,6 +1930,7 @@ internal VaultsOperations(KeyVaultManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("vaultName", vaultName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); } @@ -1957,9 +1939,9 @@ internal VaultsOperations(KeyVaultManagementClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkNameAvailability").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -2142,10 +2124,6 @@ internal VaultsOperations(KeyVaultManagementClient client) throw new ValidationException(ValidationRules.Pattern, "vaultName", "^[a-zA-Z0-9-]{3,24}$"); } } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (parameters == null) { throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); @@ -2158,6 +2136,7 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2167,6 +2146,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("vaultName", vaultName); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); @@ -2178,9 +2158,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { @@ -2369,14 +2349,11 @@ internal VaultsOperations(KeyVaultManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "location"); } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } + string apiVersion = "2019-09-01"; // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2386,6 +2363,7 @@ internal VaultsOperations(KeyVaultManagementClient client) Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); tracingParameters.Add("vaultName", vaultName); tracingParameters.Add("location", location); + tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "BeginPurgeDeleted", tracingParameters); } @@ -2396,9 +2374,9 @@ internal VaultsOperations(KeyVaultManagementClient client) _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List<string> _queryParameters = new List<string>(); - if (Client.ApiVersion != null) + if (apiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Microsoft.Azure.Management.KeyVault.csproj b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Microsoft.Azure.Management.KeyVault.csproj index 9f3259e2bdf7..443a69399132 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Microsoft.Azure.Management.KeyVault.csproj +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Microsoft.Azure.Management.KeyVault.csproj @@ -11,11 +11,11 @@ </Description> <AssemblyTitle>Microsoft Azure Key Vault Management</AssemblyTitle> <AssemblyName>Microsoft.Azure.Management.KeyVault</AssemblyName> - <Version>3.0.1</Version> + <Version>3.1.0</Version> <PackageTags>Microsoft Azure key vault management;Key Vault;</PackageTags> - <PackageReleaseNotes> + <PackageReleaseNotes> <![CDATA[ - - Enabled soft delete and purge protection by default during key vault creation + - Support CRUD operations to managed HSM ]]> </PackageReleaseNotes> </PropertyGroup> diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Properties/AssemblyInfo.cs b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Properties/AssemblyInfo.cs index a43aeaf836d1..3d19fed1e9f6 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Properties/AssemblyInfo.cs +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/src/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyDescription("Provides key vault management capabilities for Microsoft Azure.")] [assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.1.0")] +[assembly: AssemblyFileVersion("3.1.0.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Azure .NET SDK")] diff --git a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/tests/Microsoft.Azure.Management.KeyVault.Tests.csproj b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/tests/Microsoft.Azure.Management.KeyVault.Tests.csproj index 20c7490dca96..605face22904 100644 --- a/sdk/keyvault/Microsoft.Azure.Management.KeyVault/tests/Microsoft.Azure.Management.KeyVault.Tests.csproj +++ b/sdk/keyvault/Microsoft.Azure.Management.KeyVault/tests/Microsoft.Azure.Management.KeyVault.Tests.csproj @@ -5,7 +5,7 @@ <Description>KeyVault.Tests Class Library</Description> <Version>1.0.0</Version> <Authors>Microsoft Corporation</Authors> - <AssemblyName>KeyVaultManagement.Tests</AssemblyName> + <AssemblyName>KeyVaultManagement.Tests</AssemblyName> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\src\Microsoft.Azure.Management.KeyVault.csproj" /> @@ -13,7 +13,7 @@ <PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.1.3-preview" /> <PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="2.2.2-preview" /> </ItemGroup> - + <ItemGroup> <None Update="SessionRecords\**\*.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>