From b33eeadc837c9347f8f41848e015f5e4a0a853e6 Mon Sep 17 00:00:00 2001 From: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:58:40 +0800 Subject: [PATCH 1/8] Rough Regen --- .../Sample_DeletedKeyVaultCollection.cs | 6 +- .../Samples/Sample_DeletedKeyVaultResource.cs | 4 +- .../Sample_DeletedManagedHsmCollection.cs | 6 +- .../Sample_DeletedManagedHsmResource.cs | 4 +- .../Samples/Sample_KeyVaultCollection.cs | 12 +- ...aultPrivateEndpointConnectionCollection.cs | 10 +- ...yVaultPrivateEndpointConnectionResource.cs | 6 +- .../Samples/Sample_KeyVaultResource.cs | 14 +- .../Sample_KeyVaultSecretCollection.cs | 10 +- .../Samples/Sample_KeyVaultSecretResource.cs | 4 +- .../Samples/Sample_ManagedHSMKeyCollection.cs | 204 +++++ .../Samples/Sample_ManagedHSMKeyResource.cs | 87 +++ .../Sample_ManagedHSMKeyVersionCollection.cs | 167 ++++ .../Sample_ManagedHSMKeyVersionResource.cs | 50 ++ .../Samples/Sample_ManagedHsmCollection.cs | 10 +- ...dHsmPrivateEndpointConnectionCollection.cs | 10 +- ...gedHsmPrivateEndpointConnectionResource.cs | 6 +- .../Samples/Sample_ManagedHsmResource.cs | 14 +- .../Sample_SubscriptionResourceExtensions.cs | 4 +- .../Samples/Sample_VaultKeyCollection.cs | 204 +++++ .../Samples/Sample_VaultKeyResource.cs | 87 +++ .../Sample_VaultKeyVersionCollection.cs | 167 ++++ .../Samples/Sample_VaultKeyVersionResource.cs | 50 ++ .../src/Generated/ArmKeyVaultModelFactory.cs | 288 ++++++- .../Generated/DeletedKeyVaultCollection.cs | 12 +- .../src/Generated/DeletedKeyVaultResource.cs | 8 +- .../Generated/DeletedManagedHsmCollection.cs | 12 +- .../Generated/DeletedManagedHsmResource.cs | 8 +- .../Extensions/KeyVaultExtensions.cs | 116 ++- .../Extensions/MockableKeyVaultArmClient.cs | 48 ++ .../MockableKeyVaultResourceGroupResource.cs | 8 +- .../MockableKeyVaultSubscriptionResource.cs | 32 +- .../src/Generated/KeyData.Serialization.cs | 652 ++++++++++++++++ .../src/Generated/KeyData.cs | 128 +++ .../src/Generated/KeyVaultCollection.cs | 20 +- ...aultPrivateEndpointConnectionCollection.cs | 20 +- ...yVaultPrivateEndpointConnectionResource.cs | 12 +- .../src/Generated/KeyVaultResource.cs | 109 ++- .../src/Generated/KeyVaultSecretCollection.cs | 20 +- .../src/Generated/KeyVaultSecretResource.cs | 8 +- .../src/Generated/ManagedHSMKeyCollection.cs | 498 ++++++++++++ .../ManagedHSMKeyResource.Serialization.cs | 26 + .../src/Generated/ManagedHSMKeyResource.cs | 696 +++++++++++++++++ .../ManagedHSMKeyVersionCollection.cs | 395 ++++++++++ ...agedHSMKeyVersionResource.Serialization.cs | 26 + .../Generated/ManagedHSMKeyVersionResource.cs | 172 +++++ .../src/Generated/ManagedHsmCollection.cs | 20 +- .../Generated/ManagedHsmData.Serialization.cs | 33 + .../src/Generated/ManagedHsmData.cs | 7 +- .../ManagedHsmKeyData.Serialization.cs | 621 +++++++++++++++ .../src/Generated/ManagedHsmKeyData.cs | 123 +++ ...dHsmPrivateEndpointConnectionCollection.cs | 20 +- ...ateEndpointConnectionData.Serialization.cs | 33 + ...ManagedHsmPrivateEndpointConnectionData.cs | 7 +- ...gedHsmPrivateEndpointConnectionResource.cs | 24 +- .../src/Generated/ManagedHsmResource.cs | 105 ++- .../Generated/Models/Action.Serialization.cs | 159 ++++ .../src/Generated/Models/Action.cs | 66 ++ .../Generated/Models/DeletionRecoveryLevel.cs | 57 ++ .../Generated/Models/JsonWebKeyCurveName.cs | 57 ++ .../Generated/Models/JsonWebKeyOperation.cs | 69 ++ .../src/Generated/Models/JsonWebKeyType.cs | 57 ++ .../Models/KeyAttributes.Serialization.cs | 349 +++++++++ .../src/Generated/Models/KeyAttributes.cs | 96 +++ .../Models/KeyListResult.Serialization.cs | 212 +++++ .../src/Generated/Models/KeyListResult.cs | 70 ++ .../Models/KeyProperties.Serialization.cs | 262 +++++++ .../src/Generated/Models/KeyProperties.cs | 107 +++ .../Models/KeyReleasePolicy.Serialization.cs | 193 +++++ .../src/Generated/Models/KeyReleasePolicy.cs | 71 ++ ...yRotationPolicyActionType.Serialization.cs | 28 + .../Models/KeyRotationPolicyActionType.cs | 18 + ...yRotationPolicyAttributes.Serialization.cs | 223 ++++++ .../Models/KeyRotationPolicyAttributes.cs | 76 ++ .../Models/LifetimeAction.Serialization.cs | 192 +++++ .../src/Generated/Models/LifetimeAction.cs | 82 ++ ...MKeyCreateOrUpdateContent.Serialization.cs | 145 ++++ .../ManagedHSMKeyCreateOrUpdateContent.cs | 82 ++ .../Models/ManagedHsmAction.Serialization.cs | 159 ++++ .../src/Generated/Models/ManagedHsmAction.cs | 66 ++ .../ManagedHsmKeyAttributes.Serialization.cs | 349 +++++++++ .../Models/ManagedHsmKeyAttributes.cs | 96 +++ .../ManagedHsmKeyListResult.Serialization.cs | 212 +++++ .../Models/ManagedHsmKeyListResult.cs | 70 ++ .../ManagedHsmKeyProperties.Serialization.cs | 262 +++++++ .../Models/ManagedHsmKeyProperties.cs | 107 +++ ...anagedHsmKeyReleasePolicy.Serialization.cs | 193 +++++ .../Models/ManagedHsmKeyReleasePolicy.cs | 71 ++ ...yRotationPolicyAttributes.Serialization.cs | 223 ++++++ .../ManagedHsmKeyRotationPolicyAttributes.cs | 76 ++ .../ManagedHsmLifetimeAction.Serialization.cs | 192 +++++ .../Models/ManagedHsmLifetimeAction.cs | 82 ++ ...smPrivateLinkResourceData.Serialization.cs | 33 + .../ManagedHsmPrivateLinkResourceData.cs | 7 +- .../ManagedHsmRotationPolicy.Serialization.cs | 208 +++++ .../Models/ManagedHsmRotationPolicy.cs | 72 ++ .../Models/ManagedHsmTrigger.Serialization.cs | 197 +++++ .../src/Generated/Models/ManagedHsmTrigger.cs | 71 ++ .../Models/RotationPolicy.Serialization.cs | 208 +++++ .../src/Generated/Models/RotationPolicy.cs | 72 ++ .../Generated/Models/Trigger.Serialization.cs | 197 +++++ .../src/Generated/Models/Trigger.cs | 71 ++ ...tKeyCreateOrUpdateContent.Serialization.cs | 145 ++++ .../Models/VaultKeyCreateOrUpdateContent.cs | 82 ++ .../RestOperations/KeysRestOperations.cs | 731 ++++++++++++++++++ .../ManagedHsmKeysRestOperations.cs | 731 ++++++++++++++++++ .../ManagedHsmsRestOperations.cs | 2 +- ...rivateEndpointConnectionsRestOperations.cs | 2 +- .../MhsmPrivateLinkResourcesRestOperations.cs | 2 +- .../MhsmRegionsRestOperations.cs | 2 +- ...rivateEndpointConnectionsRestOperations.cs | 2 +- .../PrivateLinkResourcesRestOperations.cs | 2 +- .../RestOperations/SecretsRestOperations.cs | 2 +- .../RestOperations/VaultsRestOperations.cs | 2 +- .../src/Generated/VaultKeyCollection.cs | 498 ++++++++++++ .../VaultKeyResource.Serialization.cs | 26 + .../src/Generated/VaultKeyResource.cs | 337 ++++++++ .../Generated/VaultKeyVersionCollection.cs | 395 ++++++++++ .../VaultKeyVersionResource.Serialization.cs | 26 + .../src/Generated/VaultKeyVersionResource.cs | 172 +++++ .../src/autorest.md | 5 +- 121 files changed, 14327 insertions(+), 245 deletions(-) create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs create mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultCollection.cs index 80909fcfda99a..47d78329805b1 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_DeletedKeyVaultCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveADeletedVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getDeletedVault.json // this example is just showing the usage of "Vaults_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -54,7 +54,7 @@ public async Task Get_RetrieveADeletedVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_RetrieveADeletedVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getDeletedVault.json // this example is just showing the usage of "Vaults_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -84,7 +84,7 @@ public async Task Exists_RetrieveADeletedVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_RetrieveADeletedVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getDeletedVault.json // this example is just showing the usage of "Vaults_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultResource.cs index 40b38eb7bd017..adeb0bdf97253 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedKeyVaultResource.cs @@ -19,7 +19,7 @@ public partial class Sample_DeletedKeyVaultResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveADeletedVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getDeletedVault.json // this example is just showing the usage of "Vaults_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -50,7 +50,7 @@ public async Task Get_RetrieveADeletedVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task PurgeDeleted_PurgeADeletedVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/purgeDeletedVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/purgeDeletedVault.json // this example is just showing the usage of "Vaults_PurgeDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmCollection.cs index f8a8b655eb4ae..34a9048662d1b 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_DeletedManagedHsmCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveADeletedManagedHSM() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/DeletedManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -54,7 +54,7 @@ public async Task Get_RetrieveADeletedManagedHSM() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_RetrieveADeletedManagedHSM() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/DeletedManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -84,7 +84,7 @@ public async Task Exists_RetrieveADeletedManagedHSM() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_RetrieveADeletedManagedHSM() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/DeletedManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmResource.cs index a25ea6027324a..b3cb2944a109c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_DeletedManagedHsmResource.cs @@ -19,7 +19,7 @@ public partial class Sample_DeletedManagedHsmResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveADeletedManagedHSM() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/DeletedManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -50,7 +50,7 @@ public async Task Get_RetrieveADeletedManagedHSM() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task PurgeDeleted_PurgeAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Purge.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/DeletedManagedHsm_Purge.json // this example is just showing the usage of "ManagedHsms_PurgeDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs index 56b3b03957bc6..60864d7f2a859 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs @@ -21,7 +21,7 @@ public partial class Sample_KeyVaultCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateANewVaultOrUpdateAnExistingVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createVault.json // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -81,7 +81,7 @@ public async Task CreateOrUpdate_CreateANewVaultOrUpdateAnExistingVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateOrUpdateAVaultWithNetworkAcls() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVaultWithNetworkAcls.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createVaultWithNetworkAcls.json // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -135,7 +135,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAVaultWithNetworkAcls() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -169,7 +169,7 @@ public async Task Get_RetrieveAVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_RetrieveAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -199,7 +199,7 @@ public async Task Exists_RetrieveAVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_RetrieveAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -241,7 +241,7 @@ public async Task GetIfExists_RetrieveAVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListVaultsInTheSpecifiedResourceGroup() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultByResourceGroup.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listVaultByResourceGroup.json // this example is just showing the usage of "Vaults_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs index d46e54fdc0d4c..503fab6a922c7 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_KeyVaultPrivateEndpointConnectionCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_KeyVaultGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -55,7 +55,7 @@ public async Task Get_KeyVaultGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_KeyVaultGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -86,7 +86,7 @@ public async Task Exists_KeyVaultGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_KeyVaultGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -129,7 +129,7 @@ public async Task GetIfExists_KeyVaultGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_KeyVaultPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/putPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -174,7 +174,7 @@ public async Task CreateOrUpdate_KeyVaultPutPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_KeyVaultListPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs index aebe9a7d8c6af..8b4387e65090e 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs @@ -20,7 +20,7 @@ public partial class Sample_KeyVaultPrivateEndpointConnectionResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_KeyVaultGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -52,7 +52,7 @@ public async Task Get_KeyVaultGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_KeyVaultPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/putPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -94,7 +94,7 @@ public async Task Update_KeyVaultPutPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_KeyVaultDeletePrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deletePrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/deletePrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs index e90a5570d0c39..8bd62c0e408a0 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs @@ -21,7 +21,7 @@ public partial class Sample_KeyVaultResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_UpdateAnExistingVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateVault.json // this example is just showing the usage of "Vaults_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -82,7 +82,7 @@ public async Task Update_UpdateAnExistingVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deleteVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/deleteVault.json // this example is just showing the usage of "Vaults_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -109,7 +109,7 @@ public async Task Delete_DeleteAVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,7 +140,7 @@ public async Task Get_RetrieveAVault() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task UpdateAccessPolicy_AddAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateAccessPoliciesAdd.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateAccessPoliciesAdd.json // this example is just showing the usage of "Vaults_UpdateAccessPolicy" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -186,7 +186,7 @@ public async Task UpdateAccessPolicy_AddAnAccessPolicyOrUpdateAnAccessPolicyWith [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetKeyVaults_ListVaultsInTheSpecifiedSubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultBySubscription.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listVaultBySubscription.json // this example is just showing the usage of "Vaults_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -219,7 +219,7 @@ public async Task GetKeyVaults_ListVaultsInTheSpecifiedSubscription() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CheckKeyVaultNameAvailability_ValidateAVaultName() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/checkVaultNameAvailability.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/checkVaultNameAvailability.json // this example is just showing the usage of "Vaults_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -245,7 +245,7 @@ public async Task CheckKeyVaultNameAvailability_ValidateAVaultName() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetPrivateLinkResources_KeyVaultListPrivateLinkResources() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateLinkResources.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listPrivateLinkResources.json // this example is just showing the usage of "PrivateLinkResources_ListByVault" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs index d8425f768e42a..21803f35c95b2 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_KeyVaultSecretCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createSecret.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createSecret.json // this example is just showing the usage of "Secrets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -60,7 +60,7 @@ public async Task CreateOrUpdate_CreateASecret() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -95,7 +95,7 @@ public async Task Get_GetASecret() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -126,7 +126,7 @@ public async Task Exists_GetASecret() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -169,7 +169,7 @@ public async Task GetIfExists_GetASecret() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListSecretsInTheVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listSecrets.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listSecrets.json // this example is just showing the usage of "Secrets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs index b94a17f90e3bc..7c0bf11383e31 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs @@ -20,7 +20,7 @@ public partial class Sample_KeyVaultSecretResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_UpdateASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateSecret.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateSecret.json // this example is just showing the usage of "Secrets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -59,7 +59,7 @@ public async Task Update_UpdateASecret() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs new file mode 100644 index 0000000000000..45f00152a2635 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_ManagedHSMKeyCollection + { + // Create a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmCreateKey.json + // this example is just showing the usage of "ManagedHsmKeys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHsmResource created on azure + // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); + + // get the collection of this ManagedHSMKeyResource + ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + ManagedHSMKeyCreateOrUpdateContent content = new ManagedHSMKeyCreateOrUpdateContent(new ManagedHsmKeyProperties() + { + Kty = JsonWebKeyType.RSA, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, content); + ManagedHSMKeyResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json + // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHsmResource created on azure + // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); + + // get the collection of this ManagedHSMKeyResource + ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + ManagedHSMKeyResource result = await collection.GetAsync(keyName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json + // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHsmResource created on azure + // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); + + // get the collection of this ManagedHSMKeyResource + ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + bool result = await collection.ExistsAsync(keyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json + // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHsmResource created on azure + // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); + + // get the collection of this ManagedHSMKeyResource + ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + ManagedHSMKeyResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // List keys in the managed HSM + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListKeysInTheManagedHSM() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmListKeys.json + // this example is just showing the usage of "ManagedHsmKeys_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHsmResource created on azure + // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); + + // get the collection of this ManagedHSMKeyResource + ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); + + // invoke the operation and iterate over the result + await foreach (ManagedHSMKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs new file mode 100644 index 0000000000000..4be0549e3c5ef --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_ManagedHSMKeyResource + { + // Create a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmCreateKey.json + // this example is just showing the usage of "ManagedHsmKeys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyResource created on azure + // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); + ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); + + // invoke the operation + ManagedHSMKeyCreateOrUpdateContent content = new ManagedHSMKeyCreateOrUpdateContent(new ManagedHsmKeyProperties() + { + Kty = JsonWebKeyType.RSA, + }); + ArmOperation lro = await managedHSMKey.UpdateAsync(WaitUntil.Completed, content); + ManagedHSMKeyResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json + // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyResource created on azure + // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); + ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); + + // invoke the operation + ManagedHSMKeyResource result = await managedHSMKey.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs new file mode 100644 index 0000000000000..0670642abbb1a --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_ManagedHSMKeyVersionCollection + { + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json + // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyResource created on azure + // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); + ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); + + // get the collection of this ManagedHSMKeyVersionResource + ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); + + // invoke the operation + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + ManagedHSMKeyVersionResource result = await collection.GetAsync(keyVersion); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json + // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyResource created on azure + // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); + ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); + + // get the collection of this ManagedHSMKeyVersionResource + ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); + + // invoke the operation + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + bool result = await collection.ExistsAsync(keyVersion); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json + // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyResource created on azure + // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); + ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); + + // get the collection of this ManagedHSMKeyVersionResource + ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); + + // invoke the operation + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + NullableResponse response = await collection.GetIfExistsAsync(keyVersion); + ManagedHSMKeyVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // List key versions in the managed HSM + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListKeyVersionsInTheManagedHSM() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmListKeyVersions.json + // this example is just showing the usage of "ManagedHsmKeys_ListVersions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyResource created on azure + // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); + ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); + + // get the collection of this ManagedHSMKeyVersionResource + ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); + + // invoke the operation and iterate over the result + await foreach (ManagedHSMKeyVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs new file mode 100644 index 0000000000000..e3263f9e22ae9 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_ManagedHSMKeyVersionResource + { + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json + // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedHSMKeyVersionResource created on azure + // for more information of creating ManagedHSMKeyVersionResource, please refer to the document of ManagedHSMKeyVersionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string name = "sample-managedhsm-name"; + string keyName = "sample-key-name"; + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + ResourceIdentifier managedHSMKeyVersionResourceId = ManagedHSMKeyVersionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName, keyVersion); + ManagedHSMKeyVersionResource managedHSMKeyVersion = client.GetManagedHSMKeyVersionResource(managedHSMKeyVersionResourceId); + + // invoke the operation + ManagedHSMKeyVersionResource result = await managedHSMKeyVersion.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs index 717b927dca85d..c93002c50c556 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs @@ -21,7 +21,7 @@ public partial class Sample_ManagedHsmCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateANewManagedHSMPoolOrUpdateAnExistingManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_CreateOrUpdate.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_CreateOrUpdate.json // this example is just showing the usage of "ManagedHsms_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,7 +76,7 @@ public async Task CreateOrUpdate_CreateANewManagedHSMPoolOrUpdateAnExistingManag [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -110,7 +110,7 @@ public async Task Get_RetrieveAManagedHSMPool() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_RetrieveAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,7 +140,7 @@ public async Task Exists_RetrieveAManagedHSMPool() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_RetrieveAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -182,7 +182,7 @@ public async Task GetIfExists_RetrieveAManagedHSMPool() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListManagedHSMPoolsInAResourceGroup() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListByResourceGroup.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListByResourceGroup.json // this example is just showing the usage of "ManagedHsms_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs index 73ea7f30ba698..e6164c9ed374f 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_ManagedHsmPrivateEndpointConnectionCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListManagedHSMPoolsInASubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -57,7 +57,7 @@ public async Task GetAll_ListManagedHSMPoolsInASubscription() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_ManagedHsmGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -92,7 +92,7 @@ public async Task Get_ManagedHsmGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_ManagedHsmGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -123,7 +123,7 @@ public async Task Exists_ManagedHsmGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_ManagedHsmGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -166,7 +166,7 @@ public async Task GetIfExists_ManagedHsmGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_ManagedHsmPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_putPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs index 318f38995beed..43edf63714033 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs @@ -20,7 +20,7 @@ public partial class Sample_ManagedHsmPrivateEndpointConnectionResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_ManagedHsmGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -52,7 +52,7 @@ public async Task Get_ManagedHsmGetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_ManagedHsmPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_putPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -93,7 +93,7 @@ public async Task Update_ManagedHsmPutPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_ManagedHsmDeletePrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_deletePrivateEndpointConnection.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_deletePrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs index 1f315579c789b..0a294376790d0 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs @@ -21,7 +21,7 @@ public partial class Sample_ManagedHsmResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_UpdateAnExistingManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Update.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Update.json // this example is just showing the usage of "ManagedHsms_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -62,7 +62,7 @@ public async Task Update_UpdateAnExistingManagedHSMPool() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Delete.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Delete.json // this example is just showing the usage of "ManagedHsms_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -89,7 +89,7 @@ public async Task Delete_DeleteAManagedHSMPool() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_RetrieveAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -120,7 +120,7 @@ public async Task Get_RetrieveAManagedHSMPool() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetManagedHsms_ListManagedHSMPoolsInASubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListBySubscription.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListBySubscription.json // this example is just showing the usage of "ManagedHsms_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -152,7 +152,7 @@ public async Task GetManagedHsms_ListManagedHSMPoolsInASubscription() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CheckManagedHsmNameAvailability_ValidateAManagedHsmName() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_checkMhsmNameAvailability.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_checkMhsmNameAvailability.json // this example is just showing the usage of "ManagedHsms_CheckManagedHsmNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -178,7 +178,7 @@ public async Task CheckManagedHsmNameAvailability_ValidateAManagedHsmName() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetMHSMPrivateLinkResourcesByManagedHsmResource_KeyVaultListPrivateLinkResources() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_listPrivateLinkResources.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_listPrivateLinkResources.json // this example is just showing the usage of "MHSMPrivateLinkResources_ListByManagedHsmResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -208,7 +208,7 @@ public async Task GetMHSMPrivateLinkResourcesByManagedHsmResource_KeyVaultListPr [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetMHSMRegionsByResource_ListManagedHSMPoolsInASubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListRegionsByResource.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListRegionsByResource.json // this example is just showing the usage of "MHSMRegions_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 6eee45c18d418..435f81d3e9795 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -20,7 +20,7 @@ public partial class Sample_SubscriptionResourceExtensions [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetDeletedKeyVaults_ListDeletedVaultsInTheSpecifiedSubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listDeletedVaults.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listDeletedVaults.json // this example is just showing the usage of "Vaults_ListDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -52,7 +52,7 @@ public async Task GetDeletedKeyVaults_ListDeletedVaultsInTheSpecifiedSubscriptio [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetDeletedManagedHsms_ListDeletedManagedHSMsInTheSpecifiedSubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_List.json + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/DeletedManagedHsm_List.json // this example is just showing the usage of "ManagedHsms_ListDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs new file mode 100644 index 0000000000000..ec4e8a88be62c --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_VaultKeyCollection + { + // Create a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_CreateAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createKey.json + // this example is just showing the usage of "Keys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KeyVaultResource created on azure + // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); + + // get the collection of this VaultKeyResource + VaultKeyCollection collection = keyVault.GetVaultKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + VaultKeyCreateOrUpdateContent content = new VaultKeyCreateOrUpdateContent(new KeyProperties() + { + Kty = JsonWebKeyType.RSA, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, content); + VaultKeyResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json + // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KeyVaultResource created on azure + // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); + + // get the collection of this VaultKeyResource + VaultKeyCollection collection = keyVault.GetVaultKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + VaultKeyResource result = await collection.GetAsync(keyName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json + // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KeyVaultResource created on azure + // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); + + // get the collection of this VaultKeyResource + VaultKeyCollection collection = keyVault.GetVaultKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + bool result = await collection.ExistsAsync(keyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json + // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KeyVaultResource created on azure + // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); + + // get the collection of this VaultKeyResource + VaultKeyCollection collection = keyVault.GetVaultKeys(); + + // invoke the operation + string keyName = "sample-key-name"; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + VaultKeyResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // List keys in the vault + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListKeysInTheVault() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listKeys.json + // this example is just showing the usage of "Keys_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KeyVaultResource created on azure + // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); + + // get the collection of this VaultKeyResource + VaultKeyCollection collection = keyVault.GetVaultKeys(); + + // invoke the operation and iterate over the result + await foreach (VaultKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs new file mode 100644 index 0000000000000..088244b70235e --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_VaultKeyResource + { + // Create a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_CreateAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createKey.json + // this example is just showing the usage of "Keys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyResource created on azure + // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); + VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); + + // invoke the operation + VaultKeyCreateOrUpdateContent content = new VaultKeyCreateOrUpdateContent(new KeyProperties() + { + Kty = JsonWebKeyType.RSA, + }); + ArmOperation lro = await vaultKey.UpdateAsync(WaitUntil.Completed, content); + VaultKeyResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKey() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json + // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyResource created on azure + // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); + VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); + + // invoke the operation + VaultKeyResource result = await vaultKey.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs new file mode 100644 index 0000000000000..e2755edb1fbde --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_VaultKeyVersionCollection + { + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json + // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyResource created on azure + // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); + VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); + + // get the collection of this VaultKeyVersionResource + VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); + + // invoke the operation + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + VaultKeyVersionResource result = await collection.GetAsync(keyVersion); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json + // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyResource created on azure + // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); + VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); + + // get the collection of this VaultKeyVersionResource + VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); + + // invoke the operation + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + bool result = await collection.ExistsAsync(keyVersion); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json + // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyResource created on azure + // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); + VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); + + // get the collection of this VaultKeyVersionResource + VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); + + // invoke the operation + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + NullableResponse response = await collection.GetIfExistsAsync(keyVersion); + VaultKeyVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // List key versions in the vault + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListKeyVersionsInTheVault() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listKeyVersions.json + // this example is just showing the usage of "Keys_ListVersions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyResource created on azure + // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); + VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); + + // get the collection of this VaultKeyVersionResource + VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); + + // invoke the operation and iterate over the result + await foreach (VaultKeyVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs new file mode 100644 index 0000000000000..51ffb78dceb2e --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; + +namespace Azure.ResourceManager.KeyVault.Samples +{ + public partial class Sample_VaultKeyVersionResource + { + // Get a key version + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetAKeyVersion() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json + // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VaultKeyVersionResource created on azure + // for more information of creating VaultKeyVersionResource, please refer to the document of VaultKeyVersionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "sample-group"; + string vaultName = "sample-vault-name"; + string keyName = "sample-key-name"; + string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + ResourceIdentifier vaultKeyVersionResourceId = VaultKeyVersionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName, keyVersion); + VaultKeyVersionResource vaultKeyVersion = client.GetVaultKeyVersionResource(vaultKeyVersionResourceId); + + // invoke the operation + VaultKeyVersionResource result = await vaultKeyVersion.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs index c078290f6dcca..cd5db8df693e3 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using Azure.Core; using Azure.ResourceManager.Models; @@ -16,6 +17,228 @@ namespace Azure.ResourceManager.KeyVault.Models /// Model factory for models. public static partial class ArmKeyVaultModelFactory { + /// Initializes a new instance of . + /// The tags that will be assigned to the key. + /// The properties of the key to be created. + /// A new instance for mocking. + public static VaultKeyCreateOrUpdateContent VaultKeyCreateOrUpdateContent(IDictionary tags = null, KeyProperties properties = null) + { + tags ??= new Dictionary(); + + return new VaultKeyCreateOrUpdateContent(tags, properties, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// A new instance for mocking. + public static KeyProperties KeyProperties(KeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null) + { + keyOps ??= new List(); + + return new KeyProperties( + attributes, + kty, + keyOps?.ToList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Determines whether or not the object is enabled. + /// Not before date in seconds since 1970-01-01T00:00:00Z. + /// Expiry date in seconds since 1970-01-01T00:00:00Z. + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + /// Indicates if the private key can be exported. + /// A new instance for mocking. + public static KeyAttributes KeyAttributes(bool? enabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? exportable = null) + { + return new KeyAttributes( + enabled, + notBefore, + expires, + created, + updated, + recoveryLevel, + exportable, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. + /// A new instance for mocking. + public static KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? created = null, long? updated = null, string expiryTime = null) + { + return new KeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// Azure location of the key vault resource. + /// Tags assigned to the key vault resource. + /// A new instance for mocking. + public static KeyData KeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, KeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null, AzureLocation? location = null, IReadOnlyDictionary tags = null) + { + keyOps ??= new List(); + tags ??= new Dictionary(); + + return new KeyData( + id, + name, + resourceType, + systemData, + attributes, + kty, + keyOps?.ToList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + location, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The tags that will be assigned to the key. + /// The properties of the key to be created. + /// A new instance for mocking. + public static ManagedHSMKeyCreateOrUpdateContent ManagedHSMKeyCreateOrUpdateContent(IDictionary tags = null, ManagedHsmKeyProperties properties = null) + { + tags ??= new Dictionary(); + + return new ManagedHSMKeyCreateOrUpdateContent(tags, properties, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// A new instance for mocking. + public static ManagedHsmKeyProperties ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, ManagedHsmRotationPolicy rotationPolicy = null, ManagedHsmKeyReleasePolicy releasePolicy = null) + { + keyOps ??= new List(); + + return new ManagedHsmKeyProperties( + attributes, + kty, + keyOps?.ToList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Determines whether or not the object is enabled. + /// Not before date in seconds since 1970-01-01T00:00:00Z. + /// Expiry date in seconds since 1970-01-01T00:00:00Z. + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + /// Indicates if the private key can be exported. + /// A new instance for mocking. + public static ManagedHsmKeyAttributes ManagedHsmKeyAttributes(bool? enabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? exportable = null) + { + return new ManagedHsmKeyAttributes( + enabled, + notBefore, + expires, + created, + updated, + recoveryLevel, + exportable, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. + /// A new instance for mocking. + public static ManagedHsmKeyRotationPolicyAttributes ManagedHsmKeyRotationPolicyAttributes(long? created = null, long? updated = null, string expiryTime = null) + { + return new ManagedHsmKeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// Resource tags. + /// A new instance for mocking. + public static ManagedHsmKeyData ManagedHsmKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ManagedHsmKeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, ManagedHsmRotationPolicy rotationPolicy = null, ManagedHsmKeyReleasePolicy releasePolicy = null, IReadOnlyDictionary tags = null) + { + keyOps ??= new List(); + tags ??= new Dictionary(); + + return new ManagedHsmKeyData( + id, + name, + resourceType, + systemData, + attributes, + kty, + keyOps?.ToList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + tags, + serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The supported Azure location where the key vault should be created. /// The tags that will be assigned to the key vault. @@ -265,8 +488,9 @@ public static KeyVaultPrivateLinkResourceData KeyVaultPrivateLinkResourceData(Re /// The location. /// Properties of the managed HSM. /// SKU details. + /// Managed service identity (system assigned and/or user assigned identities). /// A new instance for mocking. - public static ManagedHsmData ManagedHsmData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ManagedHsmProperties properties = null, ManagedHsmSku sku = null) + public static ManagedHsmData ManagedHsmData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ManagedHsmProperties properties = null, ManagedHsmSku sku = null, ManagedServiceIdentity identity = null) { tags ??= new Dictionary(); @@ -279,6 +503,7 @@ public static ManagedHsmData ManagedHsmData(ResourceIdentifier id = null, string location, properties, sku, + identity, serializedAdditionalRawData: null); } @@ -373,8 +598,9 @@ public static ManagedHSMSecurityDomainProperties ManagedHSMSecurityDomainPropert /// Approval state of the private link connection. /// Provisioning state of the private endpoint connection. /// SKU details. + /// Managed service identity (system assigned and/or user assigned identities). /// A new instance for mocking. - public static ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ETag? etag = null, ResourceIdentifier privateEndpointId = null, ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState = null, ManagedHsmSku sku = null) + public static ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ETag? etag = null, ResourceIdentifier privateEndpointId = null, ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState = null, ManagedHsmSku sku = null, ManagedServiceIdentity identity = null) { tags ??= new Dictionary(); @@ -390,6 +616,7 @@ public static ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointC privateLinkServiceConnectionState, provisioningState, sku, + identity, serializedAdditionalRawData: null); } @@ -444,8 +671,9 @@ public static DeletedManagedHsmProperties DeletedManagedHsmProperties(ResourceId /// Required member names of private link resource. /// Required DNS zone names of the the private link resource. /// SKU details. + /// Managed service identity (system assigned and/or user assigned identities). /// A new instance for mocking. - public static ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, string groupId = null, IEnumerable requiredMembers = null, IEnumerable requiredZoneNames = null, ManagedHsmSku sku = null) + public static ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, string groupId = null, IEnumerable requiredMembers = null, IEnumerable requiredZoneNames = null, ManagedHsmSku sku = null, ManagedServiceIdentity identity = null) { tags ??= new Dictionary(); requiredMembers ??= new List(); @@ -462,6 +690,7 @@ public static ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceDat requiredMembers?.ToList(), requiredZoneNames?.ToList(), sku, + identity, serializedAdditionalRawData: null); } @@ -563,5 +792,58 @@ public static KeyVaultSecretData KeyVaultSecretData(ResourceIdentifier id = null tags, serializedAdditionalRawData: null); } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Properties of the managed HSM. + /// SKU details. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static ManagedHsmData ManagedHsmData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ManagedHsmProperties properties, ManagedHsmSku sku) + { + return ManagedHsmData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, properties: properties, sku: sku, identity: default); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Modified whenever there is a change in the state of private endpoint connection. + /// Properties of the private endpoint object. + /// Approval state of the private link connection. + /// Provisioning state of the private endpoint connection. + /// SKU details. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ETag? etag, ResourceIdentifier privateEndpointId, ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState, ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState, ManagedHsmSku sku) + { + return ManagedHsmPrivateEndpointConnectionData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, etag: etag, privateEndpointId: privateEndpointId, privateLinkServiceConnectionState: privateLinkServiceConnectionState, provisioningState: provisioningState, sku: sku, identity: default); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Group identifier of private link resource. + /// Required member names of private link resource. + /// Required DNS zone names of the the private link resource. + /// SKU details. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string groupId, IEnumerable requiredMembers, IEnumerable requiredZoneNames, ManagedHsmSku sku) + { + return ManagedHsmPrivateLinkResourceData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, groupId: groupId, requiredMembers: requiredMembers, requiredZoneNames: requiredZoneNames, sku: sku, identity: default); + } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultCollection.cs index f91e8817484d4..9fedaa2a1957a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultCollection.cs @@ -62,7 +62,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -108,7 +108,7 @@ public virtual async Task> GetAsync(AzureLocat /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -154,7 +154,7 @@ public virtual Response Get(AzureLocation location, str /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -198,7 +198,7 @@ public virtual async Task> ExistsAsync(AzureLocation location, st /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -242,7 +242,7 @@ public virtual Response Exists(AzureLocation location, string vaultName, C /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -288,7 +288,7 @@ public virtual async Task> GetIfExists /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultResource.cs index 5165ade3a0887..70a11589f76fb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedKeyVaultResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -141,7 +141,7 @@ public virtual async Task> GetAsync(Cancellati /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -181,7 +181,7 @@ public virtual Response Get(CancellationToken cancellat /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -223,7 +223,7 @@ public virtual async Task PurgeDeletedAsync(WaitUntil waitUntil, C /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmCollection.cs index 02491e344f7cf..bc09ba33d5f5a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmCollection.cs @@ -62,7 +62,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -108,7 +108,7 @@ public virtual async Task> GetAsync(AzureLoc /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -154,7 +154,7 @@ public virtual Response Get(AzureLocation location, s /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -198,7 +198,7 @@ public virtual async Task> ExistsAsync(AzureLocation location, st /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -242,7 +242,7 @@ public virtual Response Exists(AzureLocation location, string name, Cancel /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -288,7 +288,7 @@ public virtual async Task> GetIfExis /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmResource.cs index 30aeed42b163d..10fccc7a35ee6 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/DeletedManagedHsmResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -141,7 +141,7 @@ public virtual async Task> GetAsync(Cancella /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -181,7 +181,7 @@ public virtual Response Get(CancellationToken cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -223,7 +223,7 @@ public virtual async Task PurgeDeletedAsync(WaitUntil waitUntil, C /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs index 117edbd2b3352..dc0c50c6340c6 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs @@ -33,6 +33,82 @@ private static MockableKeyVaultSubscriptionResource GetMockableKeyVaultSubscript return resource.GetCachedClient(client => new MockableKeyVaultSubscriptionResource(client, resource.Id)); } + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static VaultKeyResource GetVaultKeyResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableKeyVaultArmClient(client).GetVaultKeyResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static VaultKeyVersionResource GetVaultKeyVersionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableKeyVaultArmClient(client).GetVaultKeyVersionResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ManagedHSMKeyResource GetManagedHSMKeyResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableKeyVaultArmClient(client).GetManagedHSMKeyResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableKeyVaultArmClient(client).GetManagedHSMKeyVersionResource(id); + } + /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// You can use to create a from its components. @@ -196,7 +272,7 @@ public static KeyVaultCollection GetKeyVaults(this ResourceGroupResource resourc /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -234,7 +310,7 @@ public static async Task> GetKeyVaultAsync(this Resou /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -289,7 +365,7 @@ public static ManagedHsmCollection GetManagedHsms(this ResourceGroupResource res /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -327,7 +403,7 @@ public static async Task> GetManagedHsmAsync(this R /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -382,7 +458,7 @@ public static DeletedKeyVaultCollection GetDeletedKeyVaults(this SubscriptionRes /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -421,7 +497,7 @@ public static async Task> GetDeletedKeyVaultAs /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -477,7 +553,7 @@ public static DeletedManagedHsmCollection GetDeletedManagedHsms(this Subscriptio /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -516,7 +592,7 @@ public static async Task> GetDeletedManagedH /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -555,7 +631,7 @@ public static Response GetDeletedManagedHsm(this Subs /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -592,7 +668,7 @@ public static AsyncPageable GetKeyVaultsAsync(this Subscriptio /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -629,7 +705,7 @@ public static Pageable GetKeyVaults(this SubscriptionResource /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -661,7 +737,7 @@ public static AsyncPageable GetDeletedKeyVaultsAsync(th /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -693,7 +769,7 @@ public static Pageable GetDeletedKeyVaults(this Subscri /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -729,7 +805,7 @@ public static async Task> CheckKeyVault /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -765,7 +841,7 @@ public static Response CheckKeyVaultNameAvailabi /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -802,7 +878,7 @@ public static AsyncPageable GetManagedHsmsAsync(this Subscri /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -839,7 +915,7 @@ public static Pageable GetManagedHsms(this SubscriptionResou /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -871,7 +947,7 @@ public static AsyncPageable GetDeletedManagedHsmsAsyn /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -903,7 +979,7 @@ public static Pageable GetDeletedManagedHsms(this Sub /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -939,7 +1015,7 @@ public static async Task> CheckManage /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs index 7e34193bd5fad..b2b1c4b68f926 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs @@ -34,6 +34,54 @@ private string GetApiVersionOrNull(ResourceType resourceType) return apiVersion; } + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual VaultKeyResource GetVaultKeyResource(ResourceIdentifier id) + { + VaultKeyResource.ValidateResourceId(id); + return new VaultKeyResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual VaultKeyVersionResource GetVaultKeyVersionResource(ResourceIdentifier id) + { + VaultKeyVersionResource.ValidateResourceId(id); + return new VaultKeyVersionResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ManagedHSMKeyResource GetManagedHSMKeyResource(ResourceIdentifier id) + { + ManagedHSMKeyResource.ValidateResourceId(id); + return new ManagedHSMKeyResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(ResourceIdentifier id) + { + ManagedHSMKeyVersionResource.ValidateResourceId(id); + return new ManagedHSMKeyVersionResource(Client, id); + } + /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// You can use to create a from its components. diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultResourceGroupResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultResourceGroupResource.cs index b3a04a42126c1..cddb41101444c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultResourceGroupResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultResourceGroupResource.cs @@ -53,7 +53,7 @@ public virtual KeyVaultCollection GetKeyVaults() /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -84,7 +84,7 @@ public virtual async Task> GetKeyVaultAsync(string va /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -122,7 +122,7 @@ public virtual ManagedHsmCollection GetManagedHsms() /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -153,7 +153,7 @@ public virtual async Task> GetManagedHsmAsync(strin /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultSubscriptionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultSubscriptionResource.cs index 8a96019efc24b..09d7573c8c386 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultSubscriptionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultSubscriptionResource.cs @@ -74,7 +74,7 @@ public virtual DeletedKeyVaultCollection GetDeletedKeyVaults() /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -106,7 +106,7 @@ public virtual async Task> GetDeletedKeyVaultA /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -145,7 +145,7 @@ public virtual DeletedManagedHsmCollection GetDeletedManagedHsms() /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -177,7 +177,7 @@ public virtual async Task> GetDeletedManaged /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -209,7 +209,7 @@ public virtual Response GetDeletedManagedHsm(AzureLoc /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -240,7 +240,7 @@ public virtual AsyncPageable GetKeyVaultsAsync(int? top = null /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -271,7 +271,7 @@ public virtual Pageable GetKeyVaults(int? top = null, Cancella /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -297,7 +297,7 @@ public virtual AsyncPageable GetDeletedKeyVaultsAsync(C /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -323,7 +323,7 @@ public virtual Pageable GetDeletedKeyVaults(Cancellatio /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -365,7 +365,7 @@ public virtual async Task> CheckKeyVaul /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -407,7 +407,7 @@ public virtual Response CheckKeyVaultNameAvailab /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -438,7 +438,7 @@ public virtual AsyncPageable GetManagedHsmsAsync(int? top = /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -469,7 +469,7 @@ public virtual Pageable GetManagedHsms(int? top = null, Canc /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -495,7 +495,7 @@ public virtual AsyncPageable GetDeletedManagedHsmsAsy /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -521,7 +521,7 @@ public virtual Pageable GetDeletedManagedHsms(Cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -563,7 +563,7 @@ public virtual async Task> CheckManag /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs new file mode 100644 index 0000000000000..064256eb74172 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs @@ -0,0 +1,652 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.KeyVault.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.KeyVault +{ + public partial class KeyData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsDefined(Kty)) + { + writer.WritePropertyName("kty"u8); + writer.WriteStringValue(Kty.Value.ToString()); + } + if (Optional.IsCollectionDefined(KeyOps)) + { + writer.WritePropertyName("keyOps"u8); + writer.WriteStartArray(); + foreach (var item in KeyOps) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(KeySize)) + { + writer.WritePropertyName("keySize"u8); + writer.WriteNumberValue(KeySize.Value); + } + if (Optional.IsDefined(CurveName)) + { + writer.WritePropertyName("curveName"u8); + writer.WriteStringValue(CurveName.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(KeyUri)) + { + writer.WritePropertyName("keyUri"u8); + writer.WriteStringValue(KeyUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) + { + writer.WritePropertyName("keyUriWithVersion"u8); + writer.WriteStringValue(KeyUriWithVersion); + } + if (Optional.IsDefined(RotationPolicy)) + { + writer.WritePropertyName("rotationPolicy"u8); + writer.WriteObjectValue(RotationPolicy, options); + } + if (Optional.IsDefined(ReleasePolicy)) + { + writer.WritePropertyName("release_policy"u8); + writer.WriteObjectValue(ReleasePolicy, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyData(document.RootElement, options); + } + + internal static KeyData DeserializeKeyData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureLocation? location = default; + IReadOnlyDictionary tags = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + KeyAttributes attributes = default; + JsonWebKeyType? kty = default; + IList keyOps = default; + int? keySize = default; + JsonWebKeyCurveName? curveName = default; + Uri keyUri = default; + string keyUriWithVersion = default; + RotationPolicy rotationPolicy = default; + KeyReleasePolicy releasePolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("attributes"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = KeyAttributes.DeserializeKeyAttributes(property0.Value, options); + continue; + } + if (property0.NameEquals("kty"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kty = new JsonWebKeyType(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("keyOps"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(new JsonWebKeyOperation(item.GetString())); + } + keyOps = array; + continue; + } + if (property0.NameEquals("keySize"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keySize = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("curveName"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + curveName = new JsonWebKeyCurveName(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("keyUri"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyUri = new Uri(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("keyUriWithVersion"u8)) + { + keyUriWithVersion = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("rotationPolicy"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rotationPolicy = RotationPolicy.DeserializeRotationPolicy(property0.Value, options); + continue; + } + if (property0.NameEquals("release_policy"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + releasePolicy = KeyReleasePolicy.DeserializeKeyReleasePolicy(property0.Value, options); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyData( + id, + name, + type, + systemData, + attributes, + kty, + keyOps ?? new ChangeTrackingList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + location, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" location: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Location)) + { + builder.Append(" location: "); + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" attributes: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Attributes)) + { + builder.Append(" attributes: "); + BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 4, false, " attributes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kty), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" kty: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Kty)) + { + builder.Append(" kty: "); + builder.AppendLine($"'{Kty.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyOps), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyOps: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(KeyOps)) + { + if (KeyOps.Any()) + { + builder.Append(" keyOps: "); + builder.AppendLine("["); + foreach (var item in KeyOps) + { + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keySize: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeySize)) + { + builder.Append(" keySize: "); + builder.AppendLine($"{KeySize.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurveName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" curveName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(CurveName)) + { + builder.Append(" curveName: "); + builder.AppendLine($"'{CurveName.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyUri: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyUri)) + { + builder.Append(" keyUri: "); + builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUriWithVersion), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyUriWithVersion: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyUriWithVersion)) + { + builder.Append(" keyUriWithVersion: "); + if (KeyUriWithVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{KeyUriWithVersion}'''"); + } + else + { + builder.AppendLine($"'{KeyUriWithVersion}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RotationPolicy), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" rotationPolicy: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(RotationPolicy)) + { + builder.Append(" rotationPolicy: "); + BicepSerializationHelpers.AppendChildObject(builder, RotationPolicy, options, 4, false, " rotationPolicy: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReleasePolicy), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" release_policy: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ReleasePolicy)) + { + builder.Append(" release_policy: "); + BicepSerializationHelpers.AppendChildObject(builder, ReleasePolicy, options, 4, false, " release_policy: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(KeyData)} does not support writing '{options.Format}' format."); + } + } + + KeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs new file mode 100644 index 0000000000000..9d2c370211aad --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.KeyVault.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A class representing the Key data model. + /// The key resource. + /// + public partial class KeyData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public KeyData() + { + KeyOps = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// Azure location of the key vault resource. + /// Tags assigned to the key vault resource. + /// Keeps track of any properties unknown to the library. + internal KeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, KeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, AzureLocation? location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Attributes = attributes; + Kty = kty; + KeyOps = keyOps; + KeySize = keySize; + CurveName = curveName; + KeyUri = keyUri; + KeyUriWithVersion = keyUriWithVersion; + RotationPolicy = rotationPolicy; + ReleasePolicy = releasePolicy; + Location = location; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The attributes of the key. + [WirePath("properties.attributes")] + public KeyAttributes Attributes { get; set; } + /// The type of the key. For valid values, see JsonWebKeyType. + [WirePath("properties.kty")] + public JsonWebKeyType? Kty { get; set; } + /// Gets the key ops. + [WirePath("properties.keyOps")] + public IList KeyOps { get; } + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + [WirePath("properties.keySize")] + public int? KeySize { get; set; } + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + [WirePath("properties.curveName")] + public JsonWebKeyCurveName? CurveName { get; set; } + /// The URI to retrieve the current version of the key. + [WirePath("properties.keyUri")] + public Uri KeyUri { get; } + /// The URI to retrieve the specific version of the key. + [WirePath("properties.keyUriWithVersion")] + public string KeyUriWithVersion { get; } + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("properties.rotationPolicy")] + public RotationPolicy RotationPolicy { get; set; } + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("properties.release_policy")] + public KeyReleasePolicy ReleasePolicy { get; set; } + /// Azure location of the key vault resource. + [WirePath("location")] + public AzureLocation? Location { get; } + /// Tags assigned to the key vault resource. + [WirePath("tags")] + public IReadOnlyDictionary Tags { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultCollection.cs index 420811bf3ea62..efd240b0a5659 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultCollection.cs @@ -66,7 +66,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -115,7 +115,7 @@ public virtual async Task> CreateOrUpdateAsync(Wa /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -164,7 +164,7 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -209,7 +209,7 @@ public virtual async Task> GetAsync(string vaultName, /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -254,7 +254,7 @@ public virtual Response Get(string vaultName, CancellationToke /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -285,7 +285,7 @@ public virtual AsyncPageable GetAllAsync(int? top = null, Canc /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -316,7 +316,7 @@ public virtual Pageable GetAll(int? top = null, CancellationTo /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -359,7 +359,7 @@ public virtual async Task> ExistsAsync(string vaultName, Cancella /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -402,7 +402,7 @@ public virtual Response Exists(string vaultName, CancellationToken cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -447,7 +447,7 @@ public virtual async Task> GetIfExistsAsync(s /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionCollection.cs index 6f09aa285a470..cbab25128bd13 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionCollection.cs @@ -64,7 +64,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -115,7 +115,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -166,7 +166,7 @@ public virtual ArmOperation CreateOrU /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -211,7 +211,7 @@ public virtual async Task> G /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -256,7 +256,7 @@ public virtual Response Get(string pr /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -286,7 +286,7 @@ public virtual AsyncPageable GetAllAs /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -316,7 +316,7 @@ public virtual Pageable GetAll(Cancel /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -359,7 +359,7 @@ public virtual async Task> ExistsAsync(string privateEndpointConn /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -402,7 +402,7 @@ public virtual Response Exists(string privateEndpointConnectionName, Cance /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -447,7 +447,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionResource.cs index 4d07c1b80db44..03cf5de486c0e 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultPrivateEndpointConnectionResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -141,7 +141,7 @@ public virtual async Task> G /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -181,7 +181,7 @@ public virtual Response Get(Cancellat /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -223,7 +223,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -265,7 +265,7 @@ public virtual ArmOperation Delete(Wa /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -313,7 +313,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs index e87bd39d8d610..329feabb5bc41 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs @@ -95,6 +95,75 @@ internal static void ValidateResourceId(ResourceIdentifier id) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); } + /// Gets a collection of VaultKeyResources in the KeyVault. + /// An object representing collection of VaultKeyResources and their operations over a VaultKeyResource. + public virtual VaultKeyCollection GetVaultKeys() + { + return GetCachedClient(client => new VaultKeyCollection(client, Id)); + } + + /// + /// Gets the current version of the specified key from the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVaultKeyAsync(string keyName, CancellationToken cancellationToken = default) + { + return await GetVaultKeys().GetAsync(keyName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the current version of the specified key from the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVaultKey(string keyName, CancellationToken cancellationToken = default) + { + return GetVaultKeys().Get(keyName, cancellationToken); + } + /// Gets a collection of KeyVaultPrivateEndpointConnectionResources in the KeyVault. /// An object representing collection of KeyVaultPrivateEndpointConnectionResources and their operations over a KeyVaultPrivateEndpointConnectionResource. public virtual KeyVaultPrivateEndpointConnectionCollection GetKeyVaultPrivateEndpointConnections() @@ -115,7 +184,7 @@ public virtual KeyVaultPrivateEndpointConnectionCollection GetKeyVaultPrivateEnd /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -146,7 +215,7 @@ public virtual async Task> G /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -184,7 +253,7 @@ public virtual KeyVaultSecretCollection GetKeyVaultSecrets() /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -215,7 +284,7 @@ public virtual async Task> GetKeyVaultSecretAsy /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -246,7 +315,7 @@ public virtual Response GetKeyVaultSecret(string secretN /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -286,7 +355,7 @@ public virtual async Task> GetAsync(CancellationToken /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -326,7 +395,7 @@ public virtual Response Get(CancellationToken cancellationToke /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -370,7 +439,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -414,7 +483,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -456,7 +525,7 @@ public virtual async Task> UpdateAsync(KeyVaultPatch /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -498,7 +567,7 @@ public virtual Response Update(KeyVaultPatch patch, Cancellati /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -537,7 +606,7 @@ public virtual async Task> UpdateAccess /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -576,7 +645,7 @@ public virtual Response UpdateAccessPolicy(Acces /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -601,7 +670,7 @@ public virtual AsyncPageable GetPrivateLinkReso /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -626,7 +695,7 @@ public virtual Pageable GetPrivateLinkResources /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -688,7 +757,7 @@ public virtual async Task> AddTagAsync(string key, st /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -750,7 +819,7 @@ public virtual Response AddTag(string key, string value, Cance /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -807,7 +876,7 @@ public virtual async Task> SetTagsAsync(IDictionary /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -864,7 +933,7 @@ public virtual Response SetTags(IDictionary ta /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -924,7 +993,7 @@ public virtual async Task> RemoveTagAsync(string key, /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretCollection.cs index 92b282356f335..c70fc0fe01563 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretCollection.cs @@ -65,7 +65,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -116,7 +116,7 @@ public virtual async Task> CreateOrUpdateAs /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -167,7 +167,7 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil wai /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -212,7 +212,7 @@ public virtual async Task> GetAsync(string secr /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -257,7 +257,7 @@ public virtual Response Get(string secretName, Cancellat /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -288,7 +288,7 @@ public virtual AsyncPageable GetAllAsync(int? top = null /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -319,7 +319,7 @@ public virtual Pageable GetAll(int? top = null, Cancella /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -362,7 +362,7 @@ public virtual async Task> ExistsAsync(string secretName, Cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -405,7 +405,7 @@ public virtual Response Exists(string secretName, CancellationToken cancel /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -450,7 +450,7 @@ public virtual async Task> GetIfExistsA /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretResource.cs index f10347663969e..f5f7f3916b4f1 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultSecretResource.cs @@ -102,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -142,7 +142,7 @@ public virtual async Task> GetAsync(Cancellatio /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -182,7 +182,7 @@ public virtual Response Get(CancellationToken cancellati /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -224,7 +224,7 @@ public virtual async Task> UpdateAsync(KeyVault /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs new file mode 100644 index 0000000000000..516ae88e0e833 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs @@ -0,0 +1,498 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetManagedHSMKeys method from an instance of . + /// + public partial class ManagedHSMKeyCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _managedHSMKeyManagedHsmKeysClientDiagnostics; + private readonly ManagedHsmKeysRestOperations _managedHSMKeyManagedHsmKeysRestClient; + + /// Initializes a new instance of the class for mocking. + protected ManagedHSMKeyCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ManagedHSMKeyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _managedHSMKeyManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ManagedHSMKeyResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ManagedHSMKeyResource.ResourceType, out string managedHSMKeyManagedHsmKeysApiVersion); + _managedHSMKeyManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyManagedHsmKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagedHsmResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedHsmResource.ResourceType), nameof(id)); + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken).ConfigureAwait(false); + var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken); + var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the current version of the specified key from the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Get"); + scope.Start(); + try + { + var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the current version of the specified key from the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Get"); + scope.Start(); + try + { + var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the keys in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys + /// + /// + /// Operation Id + /// ManagedHsmKeys_List + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyManagedHsmKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyManagedHsmKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the keys in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys + /// + /// + /// Operation Id + /// ManagedHsmKeys_List + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyManagedHsmKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyManagedHsmKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Exists"); + scope.Start(); + try + { + var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Exists"); + scope.Start(); + try + { + var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.GetIfExists"); + scope.Start(); + try + { + var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs new file mode 100644 index 0000000000000..7ba0bbc02f664 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.KeyVault +{ + public partial class ManagedHSMKeyResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ManagedHsmKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ManagedHsmKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs new file mode 100644 index 0000000000000..334f85ceef200 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs @@ -0,0 +1,696 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A Class representing a ManagedHSMKey along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetManagedHSMKeyResource method. + /// Otherwise you can get one from its parent resource using the GetManagedHSMKey method. + /// + public partial class ManagedHSMKeyResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The name. + /// The keyName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _managedHSMKeyManagedHsmKeysClientDiagnostics; + private readonly ManagedHsmKeysRestOperations _managedHSMKeyManagedHsmKeysRestClient; + private readonly ManagedHsmKeyData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KeyVault/managedHSMs/keys"; + + /// Initializes a new instance of the class for mocking. + protected ManagedHSMKeyResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ManagedHSMKeyResource(ArmClient client, ManagedHsmKeyData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ManagedHSMKeyResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _managedHSMKeyManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string managedHSMKeyManagedHsmKeysApiVersion); + _managedHSMKeyManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyManagedHsmKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ManagedHsmKeyData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of ManagedHSMKeyVersionResources in the ManagedHSMKey. + /// An object representing collection of ManagedHSMKeyVersionResources and their operations over a ManagedHSMKeyVersionResource. + public virtual ManagedHSMKeyVersionCollection GetManagedHSMKeyVersions() + { + return GetCachedClient(client => new ManagedHSMKeyVersionCollection(client, Id)); + } + + /// + /// Gets the specified version of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetManagedHSMKeyVersionAsync(string keyVersion, CancellationToken cancellationToken = default) + { + return await GetManagedHSMKeyVersions().GetAsync(keyVersion, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified version of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetManagedHSMKeyVersion(string keyVersion, CancellationToken cancellationToken = default) + { + return GetManagedHSMKeyVersions().Get(keyVersion, cancellationToken); + } + + /// + /// Gets the current version of the specified key from the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Get"); + scope.Start(); + try + { + var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the current version of the specified key from the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Get"); + scope.Start(); + try + { + var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Update"); + scope.Start(); + try + { + var response = await _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Update"); + scope.Start(); + try + { + var response = _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs new file mode 100644 index 0000000000000..a80834affaf4c --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs @@ -0,0 +1,395 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetManagedHSMKeyVersions method from an instance of . + /// + public partial class ManagedHSMKeyVersionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _managedHSMKeyVersionManagedHsmKeysClientDiagnostics; + private readonly ManagedHsmKeysRestOperations _managedHSMKeyVersionManagedHsmKeysRestClient; + + /// Initializes a new instance of the class for mocking. + protected ManagedHSMKeyVersionCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ManagedHSMKeyVersionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _managedHSMKeyVersionManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ManagedHSMKeyVersionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ManagedHSMKeyVersionResource.ResourceType, out string managedHSMKeyVersionManagedHsmKeysApiVersion); + _managedHSMKeyVersionManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyVersionManagedHsmKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagedHSMKeyResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedHSMKeyResource.ResourceType), nameof(id)); + } + + /// + /// Gets the specified version of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Get"); + scope.Start(); + try + { + var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified version of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Get"); + scope.Start(); + try + { + var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the versions of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions + /// + /// + /// Operation Id + /// ManagedHsmKeys_ListVersions + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyVersionResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyVersionManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the versions of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions + /// + /// + /// Operation Id + /// ManagedHsmKeys_ListVersions + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyVersionResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyVersionManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Exists"); + scope.Start(); + try + { + var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Exists"); + scope.Start(); + try + { + var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.GetIfExists"); + scope.Start(); + try + { + var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs new file mode 100644 index 0000000000000..db9ef782ca1fe --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.KeyVault +{ + public partial class ManagedHSMKeyVersionResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ManagedHsmKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ManagedHsmKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs new file mode 100644 index 0000000000000..1d50d506ee863 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A Class representing a ManagedHSMKeyVersion along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetManagedHSMKeyVersionResource method. + /// Otherwise you can get one from its parent resource using the GetManagedHSMKeyVersion method. + /// + public partial class ManagedHSMKeyVersionResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The name. + /// The keyName. + /// The keyVersion. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _managedHSMKeyVersionManagedHsmKeysClientDiagnostics; + private readonly ManagedHsmKeysRestOperations _managedHSMKeyVersionManagedHsmKeysRestClient; + private readonly ManagedHsmKeyData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KeyVault/managedHSMs/keys/versions"; + + /// Initializes a new instance of the class for mocking. + protected ManagedHSMKeyVersionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ManagedHSMKeyVersionResource(ArmClient client, ManagedHsmKeyData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ManagedHSMKeyVersionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _managedHSMKeyVersionManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string managedHSMKeyVersionManagedHsmKeysApiVersion); + _managedHSMKeyVersionManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyVersionManagedHsmKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ManagedHsmKeyData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Gets the specified version of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionResource.Get"); + scope.Start(); + try + { + var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified version of the specified key in the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// ManagedHsmKeys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionResource.Get"); + scope.Start(); + try + { + var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmCollection.cs index 74e345e9c64e4..36eb798d4b1e0 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmCollection.cs @@ -65,7 +65,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -114,7 +114,7 @@ public virtual async Task> CreateOrUpdateAsync( /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -163,7 +163,7 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUnt /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -208,7 +208,7 @@ public virtual async Task> GetAsync(string name, Ca /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -253,7 +253,7 @@ public virtual Response Get(string name, CancellationToken c /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -284,7 +284,7 @@ public virtual AsyncPageable GetAllAsync(int? top = null, Ca /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -315,7 +315,7 @@ public virtual Pageable GetAll(int? top = null, Cancellation /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -358,7 +358,7 @@ public virtual async Task> ExistsAsync(string name, CancellationT /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -401,7 +401,7 @@ public virtual Response Exists(string name, CancellationToken cancellation /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -446,7 +446,7 @@ public virtual async Task> GetIfExistsAsync /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs index c6fa57ae14be0..9cc54e4052d1c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.Serialization.cs @@ -40,6 +40,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -113,6 +119,7 @@ internal static ManagedHsmData DeserializeManagedHsmData(JsonElement element, Mo } ManagedHsmProperties properties = default; ManagedHsmSku sku = default; + ManagedServiceIdentity identity = default; IDictionary tags = default; AzureLocation location = default; ResourceIdentifier id = default; @@ -141,6 +148,16 @@ internal static ManagedHsmData DeserializeManagedHsmData(JsonElement element, Mo sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value, options); continue; } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -199,6 +216,7 @@ internal static ManagedHsmData DeserializeManagedHsmData(JsonElement element, Mo location, properties, sku, + identity, serializedAdditionalRawData); } @@ -315,6 +333,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" identity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Identity)) + { + builder.Append(" identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (hasPropertyOverride) { diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.cs index 0b649360401ef..f1a5cd0fe4d8a 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmData.cs @@ -66,11 +66,13 @@ public ManagedHsmData(AzureLocation location) : base(location) /// The location. /// Properties of the managed HSM. /// SKU details. + /// Managed service identity (system assigned and/or user assigned identities). /// Keeps track of any properties unknown to the library. - internal ManagedHsmData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ManagedHsmProperties properties, ManagedHsmSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal ManagedHsmData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ManagedHsmProperties properties, ManagedHsmSku sku, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) { Properties = properties; Sku = sku; + Identity = identity; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -85,5 +87,8 @@ internal ManagedHsmData() /// SKU details. [WirePath("sku")] public ManagedHsmSku Sku { get; set; } + /// Managed service identity (system assigned and/or user assigned identities). + [WirePath("identity")] + public ManagedServiceIdentity Identity { get; set; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs new file mode 100644 index 0000000000000..932c49aac90ab --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs @@ -0,0 +1,621 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.KeyVault.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.KeyVault +{ + public partial class ManagedHsmKeyData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsDefined(Kty)) + { + writer.WritePropertyName("kty"u8); + writer.WriteStringValue(Kty.Value.ToString()); + } + if (Optional.IsCollectionDefined(KeyOps)) + { + writer.WritePropertyName("keyOps"u8); + writer.WriteStartArray(); + foreach (var item in KeyOps) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(KeySize)) + { + writer.WritePropertyName("keySize"u8); + writer.WriteNumberValue(KeySize.Value); + } + if (Optional.IsDefined(CurveName)) + { + writer.WritePropertyName("curveName"u8); + writer.WriteStringValue(CurveName.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(KeyUri)) + { + writer.WritePropertyName("keyUri"u8); + writer.WriteStringValue(KeyUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) + { + writer.WritePropertyName("keyUriWithVersion"u8); + writer.WriteStringValue(KeyUriWithVersion); + } + if (Optional.IsDefined(RotationPolicy)) + { + writer.WritePropertyName("rotationPolicy"u8); + writer.WriteObjectValue(RotationPolicy, options); + } + if (Optional.IsDefined(ReleasePolicy)) + { + writer.WritePropertyName("release_policy"u8); + writer.WriteObjectValue(ReleasePolicy, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmKeyData(document.RootElement, options); + } + + internal static ManagedHsmKeyData DeserializeManagedHsmKeyData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary tags = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + ManagedHsmKeyAttributes attributes = default; + JsonWebKeyType? kty = default; + IReadOnlyList keyOps = default; + int? keySize = default; + JsonWebKeyCurveName? curveName = default; + Uri keyUri = default; + string keyUriWithVersion = default; + ManagedHsmRotationPolicy rotationPolicy = default; + ManagedHsmKeyReleasePolicy releasePolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("attributes"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = ManagedHsmKeyAttributes.DeserializeManagedHsmKeyAttributes(property0.Value, options); + continue; + } + if (property0.NameEquals("kty"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kty = new JsonWebKeyType(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("keyOps"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(new JsonWebKeyOperation(item.GetString())); + } + keyOps = array; + continue; + } + if (property0.NameEquals("keySize"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keySize = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("curveName"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + curveName = new JsonWebKeyCurveName(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("keyUri"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyUri = new Uri(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("keyUriWithVersion"u8)) + { + keyUriWithVersion = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("rotationPolicy"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rotationPolicy = ManagedHsmRotationPolicy.DeserializeManagedHsmRotationPolicy(property0.Value, options); + continue; + } + if (property0.NameEquals("release_policy"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + releasePolicy = ManagedHsmKeyReleasePolicy.DeserializeManagedHsmKeyReleasePolicy(property0.Value, options); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmKeyData( + id, + name, + type, + systemData, + attributes, + kty, + keyOps ?? new ChangeTrackingList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" attributes: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Attributes)) + { + builder.Append(" attributes: "); + BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 4, false, " attributes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kty), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" kty: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Kty)) + { + builder.Append(" kty: "); + builder.AppendLine($"'{Kty.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyOps), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyOps: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(KeyOps)) + { + if (KeyOps.Any()) + { + builder.Append(" keyOps: "); + builder.AppendLine("["); + foreach (var item in KeyOps) + { + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keySize: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeySize)) + { + builder.Append(" keySize: "); + builder.AppendLine($"{KeySize.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurveName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" curveName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(CurveName)) + { + builder.Append(" curveName: "); + builder.AppendLine($"'{CurveName.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyUri: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyUri)) + { + builder.Append(" keyUri: "); + builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUriWithVersion), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyUriWithVersion: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyUriWithVersion)) + { + builder.Append(" keyUriWithVersion: "); + if (KeyUriWithVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{KeyUriWithVersion}'''"); + } + else + { + builder.AppendLine($"'{KeyUriWithVersion}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RotationPolicy), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" rotationPolicy: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(RotationPolicy)) + { + builder.Append(" rotationPolicy: "); + BicepSerializationHelpers.AppendChildObject(builder, RotationPolicy, options, 4, false, " rotationPolicy: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReleasePolicy), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" release_policy: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ReleasePolicy)) + { + builder.Append(" release_policy: "); + BicepSerializationHelpers.AppendChildObject(builder, ReleasePolicy, options, 4, false, " release_policy: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmKeyData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs new file mode 100644 index 0000000000000..5df91ed639f14 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.KeyVault.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A class representing the ManagedHsmKey data model. + /// The key resource. + /// + public partial class ManagedHsmKeyData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ManagedHsmKeyData() + { + KeyOps = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagedHsmKeyAttributes attributes, JsonWebKeyType? kty, IReadOnlyList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, ManagedHsmRotationPolicy rotationPolicy, ManagedHsmKeyReleasePolicy releasePolicy, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Attributes = attributes; + Kty = kty; + KeyOps = keyOps; + KeySize = keySize; + CurveName = curveName; + KeyUri = keyUri; + KeyUriWithVersion = keyUriWithVersion; + RotationPolicy = rotationPolicy; + ReleasePolicy = releasePolicy; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The attributes of the key. + [WirePath("properties.attributes")] + public ManagedHsmKeyAttributes Attributes { get; } + /// The type of the key. For valid values, see JsonWebKeyType. + [WirePath("properties.kty")] + public JsonWebKeyType? Kty { get; } + /// Gets the key ops. + [WirePath("properties.keyOps")] + public IReadOnlyList KeyOps { get; } + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + [WirePath("properties.keySize")] + public int? KeySize { get; } + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + [WirePath("properties.curveName")] + public JsonWebKeyCurveName? CurveName { get; } + /// The URI to retrieve the current version of the key. + [WirePath("properties.keyUri")] + public Uri KeyUri { get; } + /// The URI to retrieve the specific version of the key. + [WirePath("properties.keyUriWithVersion")] + public string KeyUriWithVersion { get; } + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("properties.rotationPolicy")] + public ManagedHsmRotationPolicy RotationPolicy { get; } + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("properties.release_policy")] + public ManagedHsmKeyReleasePolicy ReleasePolicy { get; } + /// Resource tags. + [WirePath("tags")] + public IReadOnlyDictionary Tags { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionCollection.cs index aac153dc143c1..7b08672fe9a0c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionCollection.cs @@ -64,7 +64,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -115,7 +115,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -166,7 +166,7 @@ public virtual ArmOperation CreateO /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -211,7 +211,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -256,7 +256,7 @@ public virtual Response Get(string /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -286,7 +286,7 @@ public virtual AsyncPageable GetAll /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -316,7 +316,7 @@ public virtual Pageable GetAll(Canc /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -359,7 +359,7 @@ public virtual async Task> ExistsAsync(string privateEndpointConn /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -402,7 +402,7 @@ public virtual Response Exists(string privateEndpointConnectionName, Cance /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -447,7 +447,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs index 9b3d9931cb76e..fb0bd0836de87 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.Serialization.cs @@ -41,6 +41,12 @@ void IJsonModel.Write(Utf8JsonWriter wr writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -132,6 +138,7 @@ internal static ManagedHsmPrivateEndpointConnectionData DeserializeManagedHsmPri } ETag? etag = default; ManagedHsmSku sku = default; + ManagedServiceIdentity identity = default; IDictionary tags = default; AzureLocation location = default; ResourceIdentifier id = default; @@ -163,6 +170,16 @@ internal static ManagedHsmPrivateEndpointConnectionData DeserializeManagedHsmPri sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value, options); continue; } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -263,6 +280,7 @@ internal static ManagedHsmPrivateEndpointConnectionData DeserializeManagedHsmPri privateLinkServiceConnectionState, provisioningState, sku, + identity, serializedAdditionalRawData); } @@ -379,6 +397,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" identity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Identity)) + { + builder.Append(" identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (hasPropertyOverride) { diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.cs index 6c18975f19b59..1d0e205b73dc9 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionData.cs @@ -70,14 +70,16 @@ public ManagedHsmPrivateEndpointConnectionData(AzureLocation location) : base(lo /// Approval state of the private link connection. /// Provisioning state of the private endpoint connection. /// SKU details. + /// Managed service identity (system assigned and/or user assigned identities). /// Keeps track of any properties unknown to the library. - internal ManagedHsmPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ETag? etag, SubResource privateEndpoint, ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState, ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState, ManagedHsmSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal ManagedHsmPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ETag? etag, SubResource privateEndpoint, ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState, ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState, ManagedHsmSku sku, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) { ETag = etag; PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; ProvisioningState = provisioningState; Sku = sku; + Identity = identity; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -107,5 +109,8 @@ public ResourceIdentifier PrivateEndpointId /// SKU details. [WirePath("sku")] public ManagedHsmSku Sku { get; set; } + /// Managed service identity (system assigned and/or user assigned identities). + [WirePath("identity")] + public ManagedServiceIdentity Identity { get; set; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionResource.cs index 3cfbcc2e60b6d..33e51ea61b256 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmPrivateEndpointConnectionResource.cs @@ -102,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -142,7 +142,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -182,7 +182,7 @@ public virtual Response Get(Cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -224,7 +224,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -266,7 +266,7 @@ public virtual ArmOperation Delete( /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -314,7 +314,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -362,7 +362,7 @@ public virtual ArmOperation Update( /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -419,7 +419,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -476,7 +476,7 @@ public virtual Response AddTag(stri /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -532,7 +532,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -588,7 +588,7 @@ public virtual Response SetTags(IDi /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -643,7 +643,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs index 5efc606a706df..c9edaf601f30d 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs @@ -99,6 +99,75 @@ internal static void ValidateResourceId(ResourceIdentifier id) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); } + /// Gets a collection of ManagedHSMKeyResources in the ManagedHsm. + /// An object representing collection of ManagedHSMKeyResources and their operations over a ManagedHSMKeyResource. + public virtual ManagedHSMKeyCollection GetManagedHSMKeys() + { + return GetCachedClient(client => new ManagedHSMKeyCollection(client, Id)); + } + + /// + /// Gets the current version of the specified key from the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetManagedHSMKeyAsync(string keyName, CancellationToken cancellationToken = default) + { + return await GetManagedHSMKeys().GetAsync(keyName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the current version of the specified key from the specified managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} + /// + /// + /// Operation Id + /// ManagedHsmKeys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetManagedHSMKey(string keyName, CancellationToken cancellationToken = default) + { + return GetManagedHSMKeys().Get(keyName, cancellationToken); + } + /// Gets a collection of ManagedHsmPrivateEndpointConnectionResources in the ManagedHsm. /// An object representing collection of ManagedHsmPrivateEndpointConnectionResources and their operations over a ManagedHsmPrivateEndpointConnectionResource. public virtual ManagedHsmPrivateEndpointConnectionCollection GetManagedHsmPrivateEndpointConnections() @@ -119,7 +188,7 @@ public virtual ManagedHsmPrivateEndpointConnectionCollection GetManagedHsmPrivat /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -150,7 +219,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -181,7 +250,7 @@ public virtual Response GetManagedH /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -221,7 +290,7 @@ public virtual async Task> GetAsync(CancellationTok /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -261,7 +330,7 @@ public virtual Response Get(CancellationToken cancellationTo /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -303,7 +372,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -345,7 +414,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -391,7 +460,7 @@ public virtual async Task> UpdateAsync(WaitUnti /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -437,7 +506,7 @@ public virtual ArmOperation Update(WaitUntil waitUntil, Mana /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -462,7 +531,7 @@ public virtual AsyncPageable GetMHSMPrivateLi /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -487,7 +556,7 @@ public virtual Pageable GetMHSMPrivateLinkRes /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -513,7 +582,7 @@ public virtual AsyncPageable GetMHSMRegionsByReso /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// @@ -539,7 +608,7 @@ public virtual Pageable GetMHSMRegionsByResource( /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -601,7 +670,7 @@ public virtual async Task> AddTagAsync(string key, /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -663,7 +732,7 @@ public virtual Response AddTag(string key, string value, Can /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -720,7 +789,7 @@ public virtual async Task> SetTagsAsync(IDictionary /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -777,7 +846,7 @@ public virtual Response SetTags(IDictionary /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource @@ -837,7 +906,7 @@ public virtual async Task> RemoveTagAsync(string ke /// /// /// Default Api Version - /// 2023-02-01 + /// 2023-07-01 /// /// /// Resource diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs new file mode 100644 index 0000000000000..0830e8d9f6c21 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + internal partial class Action : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Action)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(KeyRotationPolicyActionType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(KeyRotationPolicyActionType.Value.ToSerialString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Action IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Action)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAction(document.RootElement, options); + } + + internal static Action DeserializeAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + KeyRotationPolicyActionType? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = property.Value.GetString().ToKeyRotationPolicyActionType(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Action(type, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyRotationPolicyActionType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" type: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyRotationPolicyActionType)) + { + builder.Append(" type: "); + builder.AppendLine($"'{KeyRotationPolicyActionType.Value.ToSerialString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(Action)} does not support writing '{options.Format}' format."); + } + } + + Action IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Action)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs new file mode 100644 index 0000000000000..033b56749c373 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The Action. + internal partial class Action + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Action() + { + } + + /// Initializes a new instance of . + /// The type of action. + /// Keeps track of any properties unknown to the library. + internal Action(KeyRotationPolicyActionType? keyRotationPolicyActionType, IDictionary serializedAdditionalRawData) + { + KeyRotationPolicyActionType = keyRotationPolicyActionType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The type of action. + [WirePath("type")] + public KeyRotationPolicyActionType? KeyRotationPolicyActionType { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs new file mode 100644 index 0000000000000..b8633c7a1cba3 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + public readonly partial struct DeletionRecoveryLevel : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DeletionRecoveryLevel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PurgeableValue = "Purgeable"; + private const string RecoverablePurgeableValue = "Recoverable+Purgeable"; + private const string RecoverableValue = "Recoverable"; + private const string RecoverableProtectedSubscriptionValue = "Recoverable+ProtectedSubscription"; + + /// Purgeable. + public static DeletionRecoveryLevel Purgeable { get; } = new DeletionRecoveryLevel(PurgeableValue); + /// Recoverable+Purgeable. + public static DeletionRecoveryLevel RecoverablePurgeable { get; } = new DeletionRecoveryLevel(RecoverablePurgeableValue); + /// Recoverable. + public static DeletionRecoveryLevel Recoverable { get; } = new DeletionRecoveryLevel(RecoverableValue); + /// Recoverable+ProtectedSubscription. + public static DeletionRecoveryLevel RecoverableProtectedSubscription { get; } = new DeletionRecoveryLevel(RecoverableProtectedSubscriptionValue); + /// Determines if two values are the same. + public static bool operator ==(DeletionRecoveryLevel left, DeletionRecoveryLevel right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DeletionRecoveryLevel left, DeletionRecoveryLevel right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DeletionRecoveryLevel(string value) => new DeletionRecoveryLevel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DeletionRecoveryLevel other && Equals(other); + /// + public bool Equals(DeletionRecoveryLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs new file mode 100644 index 0000000000000..931c9aef9361f --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + public readonly partial struct JsonWebKeyCurveName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public JsonWebKeyCurveName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string P256Value = "P-256"; + private const string P384Value = "P-384"; + private const string P521Value = "P-521"; + private const string P256KValue = "P-256K"; + + /// P-256. + public static JsonWebKeyCurveName P256 { get; } = new JsonWebKeyCurveName(P256Value); + /// P-384. + public static JsonWebKeyCurveName P384 { get; } = new JsonWebKeyCurveName(P384Value); + /// P-521. + public static JsonWebKeyCurveName P521 { get; } = new JsonWebKeyCurveName(P521Value); + /// P-256K. + public static JsonWebKeyCurveName P256K { get; } = new JsonWebKeyCurveName(P256KValue); + /// Determines if two values are the same. + public static bool operator ==(JsonWebKeyCurveName left, JsonWebKeyCurveName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(JsonWebKeyCurveName left, JsonWebKeyCurveName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator JsonWebKeyCurveName(string value) => new JsonWebKeyCurveName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is JsonWebKeyCurveName other && Equals(other); + /// + public bool Equals(JsonWebKeyCurveName other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs new file mode 100644 index 0000000000000..6ad565cdcc8fe --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The permitted JSON web key operations of the key. For more information, see JsonWebKeyOperation. + public readonly partial struct JsonWebKeyOperation : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public JsonWebKeyOperation(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EncryptValue = "encrypt"; + private const string DecryptValue = "decrypt"; + private const string SignValue = "sign"; + private const string VerifyValue = "verify"; + private const string WrapKeyValue = "wrapKey"; + private const string UnwrapKeyValue = "unwrapKey"; + private const string ImportValue = "import"; + private const string ReleaseValue = "release"; + + /// encrypt. + public static JsonWebKeyOperation Encrypt { get; } = new JsonWebKeyOperation(EncryptValue); + /// decrypt. + public static JsonWebKeyOperation Decrypt { get; } = new JsonWebKeyOperation(DecryptValue); + /// sign. + public static JsonWebKeyOperation Sign { get; } = new JsonWebKeyOperation(SignValue); + /// verify. + public static JsonWebKeyOperation Verify { get; } = new JsonWebKeyOperation(VerifyValue); + /// wrapKey. + public static JsonWebKeyOperation WrapKey { get; } = new JsonWebKeyOperation(WrapKeyValue); + /// unwrapKey. + public static JsonWebKeyOperation UnwrapKey { get; } = new JsonWebKeyOperation(UnwrapKeyValue); + /// import. + public static JsonWebKeyOperation Import { get; } = new JsonWebKeyOperation(ImportValue); + /// release. + public static JsonWebKeyOperation Release { get; } = new JsonWebKeyOperation(ReleaseValue); + /// Determines if two values are the same. + public static bool operator ==(JsonWebKeyOperation left, JsonWebKeyOperation right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(JsonWebKeyOperation left, JsonWebKeyOperation right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator JsonWebKeyOperation(string value) => new JsonWebKeyOperation(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is JsonWebKeyOperation other && Equals(other); + /// + public bool Equals(JsonWebKeyOperation other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs new file mode 100644 index 0000000000000..4a24c59b92ced --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The type of the key. For valid values, see JsonWebKeyType. + public readonly partial struct JsonWebKeyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public JsonWebKeyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ECValue = "EC"; + private const string ECHSMValue = "EC-HSM"; + private const string RSAValue = "RSA"; + private const string RSAHSMValue = "RSA-HSM"; + + /// EC. + public static JsonWebKeyType EC { get; } = new JsonWebKeyType(ECValue); + /// EC-HSM. + public static JsonWebKeyType ECHSM { get; } = new JsonWebKeyType(ECHSMValue); + /// RSA. + public static JsonWebKeyType RSA { get; } = new JsonWebKeyType(RSAValue); + /// RSA-HSM. + public static JsonWebKeyType RSAHSM { get; } = new JsonWebKeyType(RSAHSMValue); + /// Determines if two values are the same. + public static bool operator ==(JsonWebKeyType left, JsonWebKeyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(JsonWebKeyType left, JsonWebKeyType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator JsonWebKeyType(string value) => new JsonWebKeyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is JsonWebKeyType other && Equals(other); + /// + public bool Equals(JsonWebKeyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs new file mode 100644 index 0000000000000..a264a8812e927 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class KeyAttributes : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyAttributes)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(NotBefore)) + { + writer.WritePropertyName("nbf"u8); + writer.WriteNumberValue(NotBefore.Value); + } + if (Optional.IsDefined(Expires)) + { + writer.WritePropertyName("exp"u8); + writer.WriteNumberValue(Expires.Value); + } + if (options.Format != "W" && Optional.IsDefined(Created)) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created.Value); + } + if (options.Format != "W" && Optional.IsDefined(Updated)) + { + writer.WritePropertyName("updated"u8); + writer.WriteNumberValue(Updated.Value); + } + if (options.Format != "W" && Optional.IsDefined(RecoveryLevel)) + { + writer.WritePropertyName("recoveryLevel"u8); + writer.WriteStringValue(RecoveryLevel.Value.ToString()); + } + if (Optional.IsDefined(Exportable)) + { + writer.WritePropertyName("exportable"u8); + writer.WriteBooleanValue(Exportable.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyAttributes)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyAttributes(document.RootElement, options); + } + + internal static KeyAttributes DeserializeKeyAttributes(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? enabled = default; + long? nbf = default; + long? exp = default; + long? created = default; + long? updated = default; + DeletionRecoveryLevel? recoveryLevel = default; + bool? exportable = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("nbf"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nbf = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("exp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + exp = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("created"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + created = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("updated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updated = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("recoveryLevel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recoveryLevel = new DeletionRecoveryLevel(property.Value.GetString()); + continue; + } + if (property.NameEquals("exportable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + exportable = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyAttributes( + enabled, + nbf, + exp, + created, + updated, + recoveryLevel, + exportable, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" enabled: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Enabled)) + { + builder.Append(" enabled: "); + var boolValue = Enabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nbf: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NotBefore)) + { + builder.Append(" nbf: "); + builder.AppendLine($"'{NotBefore.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Expires), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" exp: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Expires)) + { + builder.Append(" exp: "); + builder.AppendLine($"'{Expires.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" created: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Created)) + { + builder.Append(" created: "); + builder.AppendLine($"'{Created.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" updated: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Updated)) + { + builder.Append(" updated: "); + builder.AppendLine($"'{Updated.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoveryLevel), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" recoveryLevel: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(RecoveryLevel)) + { + builder.Append(" recoveryLevel: "); + builder.AppendLine($"'{RecoveryLevel.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Exportable), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" exportable: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Exportable)) + { + builder.Append(" exportable: "); + var boolValue = Exportable.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(KeyAttributes)} does not support writing '{options.Format}' format."); + } + } + + KeyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyAttributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyAttributes)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs new file mode 100644 index 0000000000000..c70bfbafd90f4 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The object attributes managed by the Azure Key Vault service. + public partial class KeyAttributes + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public KeyAttributes() + { + } + + /// Initializes a new instance of . + /// Determines whether or not the object is enabled. + /// Not before date in seconds since 1970-01-01T00:00:00Z. + /// Expiry date in seconds since 1970-01-01T00:00:00Z. + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + /// Indicates if the private key can be exported. + /// Keeps track of any properties unknown to the library. + internal KeyAttributes(bool? enabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? exportable, IDictionary serializedAdditionalRawData) + { + Enabled = enabled; + NotBefore = notBefore; + Expires = expires; + Created = created; + Updated = updated; + RecoveryLevel = recoveryLevel; + Exportable = exportable; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Determines whether or not the object is enabled. + [WirePath("enabled")] + public bool? Enabled { get; set; } + /// Not before date in seconds since 1970-01-01T00:00:00Z. + [WirePath("nbf")] + public long? NotBefore { get; set; } + /// Expiry date in seconds since 1970-01-01T00:00:00Z. + [WirePath("exp")] + public long? Expires { get; set; } + /// Creation time in seconds since 1970-01-01T00:00:00Z. + [WirePath("created")] + public long? Created { get; } + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + [WirePath("updated")] + public long? Updated { get; } + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + [WirePath("recoveryLevel")] + public DeletionRecoveryLevel? RecoveryLevel { get; } + /// Indicates if the private key can be exported. + [WirePath("exportable")] + public bool? Exportable { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs new file mode 100644 index 0000000000000..18e6aa8e4ef40 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + internal partial class KeyListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyListResult(document.RootElement, options); + } + + internal static KeyListResult DeserializeKeyListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyData.DeserializeKeyData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(KeyListResult)} does not support writing '{options.Format}' format."); + } + } + + KeyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs new file mode 100644 index 0000000000000..c882d391234ef --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The page of keys. + internal partial class KeyListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal KeyListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The key resources. + /// The URL to get the next page of keys. + /// Keeps track of any properties unknown to the library. + internal KeyListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The key resources. + public IReadOnlyList Value { get; } + /// The URL to get the next page of keys. + public string NextLink { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs new file mode 100644 index 0000000000000..3760ff44ea8d4 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class KeyProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsDefined(Kty)) + { + writer.WritePropertyName("kty"u8); + writer.WriteStringValue(Kty.Value.ToString()); + } + if (Optional.IsCollectionDefined(KeyOps)) + { + writer.WritePropertyName("keyOps"u8); + writer.WriteStartArray(); + foreach (var item in KeyOps) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(KeySize)) + { + writer.WritePropertyName("keySize"u8); + writer.WriteNumberValue(KeySize.Value); + } + if (Optional.IsDefined(CurveName)) + { + writer.WritePropertyName("curveName"u8); + writer.WriteStringValue(CurveName.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(KeyUri)) + { + writer.WritePropertyName("keyUri"u8); + writer.WriteStringValue(KeyUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) + { + writer.WritePropertyName("keyUriWithVersion"u8); + writer.WriteStringValue(KeyUriWithVersion); + } + if (Optional.IsDefined(RotationPolicy)) + { + writer.WritePropertyName("rotationPolicy"u8); + writer.WriteObjectValue(RotationPolicy, options); + } + if (Optional.IsDefined(ReleasePolicy)) + { + writer.WritePropertyName("release_policy"u8); + writer.WriteObjectValue(ReleasePolicy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyProperties(document.RootElement, options); + } + + internal static KeyProperties DeserializeKeyProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + KeyAttributes attributes = default; + JsonWebKeyType? kty = default; + IList keyOps = default; + int? keySize = default; + JsonWebKeyCurveName? curveName = default; + Uri keyUri = default; + string keyUriWithVersion = default; + RotationPolicy rotationPolicy = default; + KeyReleasePolicy releasePolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("attributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = KeyAttributes.DeserializeKeyAttributes(property.Value, options); + continue; + } + if (property.NameEquals("kty"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kty = new JsonWebKeyType(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyOps"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new JsonWebKeyOperation(item.GetString())); + } + keyOps = array; + continue; + } + if (property.NameEquals("keySize"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keySize = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("curveName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + curveName = new JsonWebKeyCurveName(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyUriWithVersion"u8)) + { + keyUriWithVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("rotationPolicy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rotationPolicy = RotationPolicy.DeserializeRotationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("release_policy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + releasePolicy = KeyReleasePolicy.DeserializeKeyReleasePolicy(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyProperties( + attributes, + kty, + keyOps ?? new ChangeTrackingList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KeyProperties)} does not support writing '{options.Format}' format."); + } + } + + KeyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs new file mode 100644 index 0000000000000..13e0080367eea --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The properties of the key. + public partial class KeyProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public KeyProperties() + { + KeyOps = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// Keeps track of any properties unknown to the library. + internal KeyProperties(KeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) + { + Attributes = attributes; + Kty = kty; + KeyOps = keyOps; + KeySize = keySize; + CurveName = curveName; + KeyUri = keyUri; + KeyUriWithVersion = keyUriWithVersion; + RotationPolicy = rotationPolicy; + ReleasePolicy = releasePolicy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The attributes of the key. + [WirePath("attributes")] + public KeyAttributes Attributes { get; set; } + /// The type of the key. For valid values, see JsonWebKeyType. + [WirePath("kty")] + public JsonWebKeyType? Kty { get; set; } + /// Gets the key ops. + [WirePath("keyOps")] + public IList KeyOps { get; } + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + [WirePath("keySize")] + public int? KeySize { get; set; } + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + [WirePath("curveName")] + public JsonWebKeyCurveName? CurveName { get; set; } + /// The URI to retrieve the current version of the key. + [WirePath("keyUri")] + public Uri KeyUri { get; } + /// The URI to retrieve the specific version of the key. + [WirePath("keyUriWithVersion")] + public string KeyUriWithVersion { get; } + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("rotationPolicy")] + public RotationPolicy RotationPolicy { get; set; } + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("release_policy")] + public KeyReleasePolicy ReleasePolicy { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs new file mode 100644 index 0000000000000..818bc23c7934e --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class KeyReleasePolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ContentType)) + { + writer.WritePropertyName("contentType"u8); + writer.WriteStringValue(ContentType); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data, "U"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyReleasePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyReleasePolicy(document.RootElement, options); + } + + internal static KeyReleasePolicy DeserializeKeyReleasePolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string contentType = default; + byte[] data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("contentType"u8)) + { + contentType = property.Value.GetString(); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = property.Value.GetBytesFromBase64("U"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyReleasePolicy(contentType, data, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" contentType: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ContentType)) + { + builder.Append(" contentType: "); + if (ContentType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContentType}'''"); + } + else + { + builder.AppendLine($"'{ContentType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Data), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" data: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Data)) + { + builder.Append(" data: "); + builder.AppendLine($"'{Data.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support writing '{options.Format}' format."); + } + } + + KeyReleasePolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyReleasePolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs new file mode 100644 index 0000000000000..1074b9653e7c2 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The KeyReleasePolicy. + public partial class KeyReleasePolicy + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public KeyReleasePolicy() + { + } + + /// Initializes a new instance of . + /// Content type and version of key release policy. + /// Blob encoding the policy rules under which the key can be released. + /// Keeps track of any properties unknown to the library. + internal KeyReleasePolicy(string contentType, byte[] data, IDictionary serializedAdditionalRawData) + { + ContentType = contentType; + Data = data; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Content type and version of key release policy. + [WirePath("contentType")] + public string ContentType { get; set; } + /// Blob encoding the policy rules under which the key can be released. + [WirePath("data")] + public byte[] Data { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs new file mode 100644 index 0000000000000..2f6a46a5dea2e --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.KeyVault.Models +{ + internal static partial class KeyRotationPolicyActionTypeExtensions + { + public static string ToSerialString(this KeyRotationPolicyActionType value) => value switch + { + KeyRotationPolicyActionType.Rotate => "rotate", + KeyRotationPolicyActionType.Notify => "notify", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown KeyRotationPolicyActionType value.") + }; + + public static KeyRotationPolicyActionType ToKeyRotationPolicyActionType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "rotate")) return KeyRotationPolicyActionType.Rotate; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "notify")) return KeyRotationPolicyActionType.Notify; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown KeyRotationPolicyActionType value."); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs new file mode 100644 index 0000000000000..1b13ec69f697d --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The type of action. + public enum KeyRotationPolicyActionType + { + /// rotate. + Rotate, + /// notify. + Notify + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs new file mode 100644 index 0000000000000..28d61fa1720fa --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class KeyRotationPolicyAttributes : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Created)) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created.Value); + } + if (options.Format != "W" && Optional.IsDefined(Updated)) + { + writer.WritePropertyName("updated"u8); + writer.WriteNumberValue(Updated.Value); + } + if (Optional.IsDefined(ExpiryTime)) + { + writer.WritePropertyName("expiryTime"u8); + writer.WriteStringValue(ExpiryTime); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyRotationPolicyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyRotationPolicyAttributes(document.RootElement, options); + } + + internal static KeyRotationPolicyAttributes DeserializeKeyRotationPolicyAttributes(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long? created = default; + long? updated = default; + string expiryTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("created"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + created = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("updated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updated = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("expiryTime"u8)) + { + expiryTime = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" created: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Created)) + { + builder.Append(" created: "); + builder.AppendLine($"'{Created.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" updated: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Updated)) + { + builder.Append(" updated: "); + builder.AppendLine($"'{Updated.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpiryTime), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" expiryTime: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ExpiryTime)) + { + builder.Append(" expiryTime: "); + if (ExpiryTime.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ExpiryTime}'''"); + } + else + { + builder.AppendLine($"'{ExpiryTime}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support writing '{options.Format}' format."); + } + } + + KeyRotationPolicyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyRotationPolicyAttributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs new file mode 100644 index 0000000000000..106a305064a2b --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The KeyRotationPolicyAttributes. + public partial class KeyRotationPolicyAttributes + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public KeyRotationPolicyAttributes() + { + } + + /// Initializes a new instance of . + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. + /// Keeps track of any properties unknown to the library. + internal KeyRotationPolicyAttributes(long? created, long? updated, string expiryTime, IDictionary serializedAdditionalRawData) + { + Created = created; + Updated = updated; + ExpiryTime = expiryTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Creation time in seconds since 1970-01-01T00:00:00Z. + [WirePath("created")] + public long? Created { get; } + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + [WirePath("updated")] + public long? Updated { get; } + /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. + [WirePath("expiryTime")] + public string ExpiryTime { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs new file mode 100644 index 0000000000000..0f2649c6d9567 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class LifetimeAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LifetimeAction)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Trigger)) + { + writer.WritePropertyName("trigger"u8); + writer.WriteObjectValue(Trigger, options); + } + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + LifetimeAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LifetimeAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLifetimeAction(document.RootElement, options); + } + + internal static LifetimeAction DeserializeLifetimeAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Trigger trigger = default; + Action action = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("trigger"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trigger = Trigger.DeserializeTrigger(property.Value, options); + continue; + } + if (property.NameEquals("action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = Action.DeserializeAction(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LifetimeAction(trigger, action, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Trigger), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" trigger: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Trigger)) + { + builder.Append(" trigger: "); + BicepSerializationHelpers.AppendChildObject(builder, Trigger, options, 2, false, " trigger: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("KeyRotationPolicyActionType", out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" action: "); + builder.AppendLine("{"); + builder.Append(" type: "); + builder.AppendLine(propertyOverride); + builder.AppendLine(" }"); + } + else + { + if (Optional.IsDefined(Action)) + { + builder.Append(" action: "); + BicepSerializationHelpers.AppendChildObject(builder, Action, options, 2, false, " action: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(LifetimeAction)} does not support writing '{options.Format}' format."); + } + } + + LifetimeAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLifetimeAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LifetimeAction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs new file mode 100644 index 0000000000000..27350f296acd7 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The LifetimeAction. + public partial class LifetimeAction + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public LifetimeAction() + { + } + + /// Initializes a new instance of . + /// The trigger of key rotation policy lifetimeAction. + /// The action of key rotation policy lifetimeAction. + /// Keeps track of any properties unknown to the library. + internal LifetimeAction(Trigger trigger, Action action, IDictionary serializedAdditionalRawData) + { + Trigger = trigger; + Action = action; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The trigger of key rotation policy lifetimeAction. + [WirePath("trigger")] + public Trigger Trigger { get; set; } + /// The action of key rotation policy lifetimeAction. + internal Action Action { get; set; } + /// The type of action. + [WirePath("action.type")] + public KeyRotationPolicyActionType? KeyRotationPolicyActionType + { + get => Action is null ? default : Action.KeyRotationPolicyActionType; + set + { + if (Action is null) + Action = new Action(); + Action.KeyRotationPolicyActionType = value; + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs new file mode 100644 index 0000000000000..115b6bd71bf50 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHSMKeyCreateOrUpdateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHSMKeyCreateOrUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHSMKeyCreateOrUpdateContent(document.RootElement, options); + } + + internal static ManagedHSMKeyCreateOrUpdateContent DeserializeManagedHSMKeyCreateOrUpdateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + ManagedHsmKeyProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties"u8)) + { + properties = ManagedHsmKeyProperties.DeserializeManagedHsmKeyProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHSMKeyCreateOrUpdateContent(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + ManagedHSMKeyCreateOrUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHSMKeyCreateOrUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs new file mode 100644 index 0000000000000..9bb011b0ffe6a --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The parameters used to create a key. + public partial class ManagedHSMKeyCreateOrUpdateContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The properties of the key to be created. + /// is null. + public ManagedHSMKeyCreateOrUpdateContent(ManagedHsmKeyProperties properties) + { + Argument.AssertNotNull(properties, nameof(properties)); + + Tags = new ChangeTrackingDictionary(); + Properties = properties; + } + + /// Initializes a new instance of . + /// The tags that will be assigned to the key. + /// The properties of the key to be created. + /// Keeps track of any properties unknown to the library. + internal ManagedHSMKeyCreateOrUpdateContent(IDictionary tags, ManagedHsmKeyProperties properties, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ManagedHSMKeyCreateOrUpdateContent() + { + } + + /// The tags that will be assigned to the key. + [WirePath("tags")] + public IDictionary Tags { get; } + /// The properties of the key to be created. + [WirePath("properties")] + public ManagedHsmKeyProperties Properties { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs new file mode 100644 index 0000000000000..e9857d553e782 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + internal partial class ManagedHsmAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(KeyRotationPolicyActionType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(KeyRotationPolicyActionType.Value.ToSerialString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmAction(document.RootElement, options); + } + + internal static ManagedHsmAction DeserializeManagedHsmAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + KeyRotationPolicyActionType? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = property.Value.GetString().ToKeyRotationPolicyActionType(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmAction(type, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyRotationPolicyActionType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" type: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyRotationPolicyActionType)) + { + builder.Append(" type: "); + builder.AppendLine($"'{KeyRotationPolicyActionType.Value.ToSerialString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs new file mode 100644 index 0000000000000..55c59972391ea --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The ManagedHsmAction. + internal partial class ManagedHsmAction + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmAction() + { + } + + /// Initializes a new instance of . + /// The type of action. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmAction(KeyRotationPolicyActionType? keyRotationPolicyActionType, IDictionary serializedAdditionalRawData) + { + KeyRotationPolicyActionType = keyRotationPolicyActionType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The type of action. + [WirePath("type")] + public KeyRotationPolicyActionType? KeyRotationPolicyActionType { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs new file mode 100644 index 0000000000000..635e7e4257b79 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmKeyAttributes : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(NotBefore)) + { + writer.WritePropertyName("nbf"u8); + writer.WriteNumberValue(NotBefore.Value); + } + if (Optional.IsDefined(Expires)) + { + writer.WritePropertyName("exp"u8); + writer.WriteNumberValue(Expires.Value); + } + if (options.Format != "W" && Optional.IsDefined(Created)) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created.Value); + } + if (options.Format != "W" && Optional.IsDefined(Updated)) + { + writer.WritePropertyName("updated"u8); + writer.WriteNumberValue(Updated.Value); + } + if (options.Format != "W" && Optional.IsDefined(RecoveryLevel)) + { + writer.WritePropertyName("recoveryLevel"u8); + writer.WriteStringValue(RecoveryLevel.Value.ToString()); + } + if (Optional.IsDefined(Exportable)) + { + writer.WritePropertyName("exportable"u8); + writer.WriteBooleanValue(Exportable.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmKeyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmKeyAttributes(document.RootElement, options); + } + + internal static ManagedHsmKeyAttributes DeserializeManagedHsmKeyAttributes(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? enabled = default; + long? nbf = default; + long? exp = default; + long? created = default; + long? updated = default; + DeletionRecoveryLevel? recoveryLevel = default; + bool? exportable = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("nbf"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nbf = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("exp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + exp = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("created"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + created = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("updated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updated = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("recoveryLevel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recoveryLevel = new DeletionRecoveryLevel(property.Value.GetString()); + continue; + } + if (property.NameEquals("exportable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + exportable = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmKeyAttributes( + enabled, + nbf, + exp, + created, + updated, + recoveryLevel, + exportable, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" enabled: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Enabled)) + { + builder.Append(" enabled: "); + var boolValue = Enabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nbf: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NotBefore)) + { + builder.Append(" nbf: "); + builder.AppendLine($"'{NotBefore.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Expires), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" exp: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Expires)) + { + builder.Append(" exp: "); + builder.AppendLine($"'{Expires.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" created: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Created)) + { + builder.Append(" created: "); + builder.AppendLine($"'{Created.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" updated: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Updated)) + { + builder.Append(" updated: "); + builder.AppendLine($"'{Updated.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoveryLevel), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" recoveryLevel: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(RecoveryLevel)) + { + builder.Append(" recoveryLevel: "); + builder.AppendLine($"'{RecoveryLevel.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Exportable), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" exportable: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Exportable)) + { + builder.Append(" exportable: "); + var boolValue = Exportable.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmKeyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmKeyAttributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs new file mode 100644 index 0000000000000..7d7294121f75a --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The object attributes managed by the Azure Key Vault service. + public partial class ManagedHsmKeyAttributes + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmKeyAttributes() + { + } + + /// Initializes a new instance of . + /// Determines whether or not the object is enabled. + /// Not before date in seconds since 1970-01-01T00:00:00Z. + /// Expiry date in seconds since 1970-01-01T00:00:00Z. + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + /// Indicates if the private key can be exported. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmKeyAttributes(bool? enabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? exportable, IDictionary serializedAdditionalRawData) + { + Enabled = enabled; + NotBefore = notBefore; + Expires = expires; + Created = created; + Updated = updated; + RecoveryLevel = recoveryLevel; + Exportable = exportable; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Determines whether or not the object is enabled. + [WirePath("enabled")] + public bool? Enabled { get; set; } + /// Not before date in seconds since 1970-01-01T00:00:00Z. + [WirePath("nbf")] + public long? NotBefore { get; set; } + /// Expiry date in seconds since 1970-01-01T00:00:00Z. + [WirePath("exp")] + public long? Expires { get; set; } + /// Creation time in seconds since 1970-01-01T00:00:00Z. + [WirePath("created")] + public long? Created { get; } + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + [WirePath("updated")] + public long? Updated { get; } + /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. + [WirePath("recoveryLevel")] + public DeletionRecoveryLevel? RecoveryLevel { get; } + /// Indicates if the private key can be exported. + [WirePath("exportable")] + public bool? Exportable { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs new file mode 100644 index 0000000000000..dba0296c27479 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + internal partial class ManagedHsmKeyListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmKeyListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmKeyListResult(document.RootElement, options); + } + + internal static ManagedHsmKeyListResult DeserializeManagedHsmKeyListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ManagedHsmKeyData.DeserializeManagedHsmKeyData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmKeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmKeyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmKeyListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs new file mode 100644 index 0000000000000..5cd48f9b6d32b --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The page of keys. + internal partial class ManagedHsmKeyListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ManagedHsmKeyListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The key resources. + /// The URL to get the next page of keys. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmKeyListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The key resources. + public IReadOnlyList Value { get; } + /// The URL to get the next page of keys. + public string NextLink { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs new file mode 100644 index 0000000000000..2958799e7dcea --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmKeyProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsDefined(Kty)) + { + writer.WritePropertyName("kty"u8); + writer.WriteStringValue(Kty.Value.ToString()); + } + if (Optional.IsCollectionDefined(KeyOps)) + { + writer.WritePropertyName("keyOps"u8); + writer.WriteStartArray(); + foreach (var item in KeyOps) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(KeySize)) + { + writer.WritePropertyName("keySize"u8); + writer.WriteNumberValue(KeySize.Value); + } + if (Optional.IsDefined(CurveName)) + { + writer.WritePropertyName("curveName"u8); + writer.WriteStringValue(CurveName.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(KeyUri)) + { + writer.WritePropertyName("keyUri"u8); + writer.WriteStringValue(KeyUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) + { + writer.WritePropertyName("keyUriWithVersion"u8); + writer.WriteStringValue(KeyUriWithVersion); + } + if (Optional.IsDefined(RotationPolicy)) + { + writer.WritePropertyName("rotationPolicy"u8); + writer.WriteObjectValue(RotationPolicy, options); + } + if (Optional.IsDefined(ReleasePolicy)) + { + writer.WritePropertyName("release_policy"u8); + writer.WriteObjectValue(ReleasePolicy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmKeyProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmKeyProperties(document.RootElement, options); + } + + internal static ManagedHsmKeyProperties DeserializeManagedHsmKeyProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ManagedHsmKeyAttributes attributes = default; + JsonWebKeyType? kty = default; + IList keyOps = default; + int? keySize = default; + JsonWebKeyCurveName? curveName = default; + Uri keyUri = default; + string keyUriWithVersion = default; + ManagedHsmRotationPolicy rotationPolicy = default; + ManagedHsmKeyReleasePolicy releasePolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("attributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = ManagedHsmKeyAttributes.DeserializeManagedHsmKeyAttributes(property.Value, options); + continue; + } + if (property.NameEquals("kty"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kty = new JsonWebKeyType(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyOps"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new JsonWebKeyOperation(item.GetString())); + } + keyOps = array; + continue; + } + if (property.NameEquals("keySize"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keySize = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("curveName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + curveName = new JsonWebKeyCurveName(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyUriWithVersion"u8)) + { + keyUriWithVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("rotationPolicy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rotationPolicy = ManagedHsmRotationPolicy.DeserializeManagedHsmRotationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("release_policy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + releasePolicy = ManagedHsmKeyReleasePolicy.DeserializeManagedHsmKeyReleasePolicy(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmKeyProperties( + attributes, + kty, + keyOps ?? new ChangeTrackingList(), + keySize, + curveName, + keyUri, + keyUriWithVersion, + rotationPolicy, + releasePolicy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmKeyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmKeyProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs new file mode 100644 index 0000000000000..9a5f3b83e8655 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The properties of the key. + public partial class ManagedHsmKeyProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmKeyProperties() + { + KeyOps = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The attributes of the key. + /// The type of the key. For valid values, see JsonWebKeyType. + /// + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// The URI to retrieve the current version of the key. + /// The URI to retrieve the specific version of the key. + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, ManagedHsmRotationPolicy rotationPolicy, ManagedHsmKeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) + { + Attributes = attributes; + Kty = kty; + KeyOps = keyOps; + KeySize = keySize; + CurveName = curveName; + KeyUri = keyUri; + KeyUriWithVersion = keyUriWithVersion; + RotationPolicy = rotationPolicy; + ReleasePolicy = releasePolicy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The attributes of the key. + [WirePath("attributes")] + public ManagedHsmKeyAttributes Attributes { get; set; } + /// The type of the key. For valid values, see JsonWebKeyType. + [WirePath("kty")] + public JsonWebKeyType? Kty { get; set; } + /// Gets the key ops. + [WirePath("keyOps")] + public IList KeyOps { get; } + /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. + [WirePath("keySize")] + public int? KeySize { get; set; } + /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. + [WirePath("curveName")] + public JsonWebKeyCurveName? CurveName { get; set; } + /// The URI to retrieve the current version of the key. + [WirePath("keyUri")] + public Uri KeyUri { get; } + /// The URI to retrieve the specific version of the key. + [WirePath("keyUriWithVersion")] + public string KeyUriWithVersion { get; } + /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("rotationPolicy")] + public ManagedHsmRotationPolicy RotationPolicy { get; set; } + /// Key release policy in response. It will be used for both output and input. Omitted if empty. + [WirePath("release_policy")] + public ManagedHsmKeyReleasePolicy ReleasePolicy { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs new file mode 100644 index 0000000000000..ea74b060a6562 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmKeyReleasePolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ContentType)) + { + writer.WritePropertyName("contentType"u8); + writer.WriteStringValue(ContentType); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data, "U"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmKeyReleasePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmKeyReleasePolicy(document.RootElement, options); + } + + internal static ManagedHsmKeyReleasePolicy DeserializeManagedHsmKeyReleasePolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string contentType = default; + byte[] data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("contentType"u8)) + { + contentType = property.Value.GetString(); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = property.Value.GetBytesFromBase64("U"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmKeyReleasePolicy(contentType, data, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" contentType: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ContentType)) + { + builder.Append(" contentType: "); + if (ContentType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContentType}'''"); + } + else + { + builder.AppendLine($"'{ContentType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Data), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" data: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Data)) + { + builder.Append(" data: "); + builder.AppendLine($"'{Data.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmKeyReleasePolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmKeyReleasePolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs new file mode 100644 index 0000000000000..627f59b4ecc82 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The ManagedHsmKeyReleasePolicy. + public partial class ManagedHsmKeyReleasePolicy + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmKeyReleasePolicy() + { + } + + /// Initializes a new instance of . + /// Content type and version of key release policy. + /// Blob encoding the policy rules under which the key can be released. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmKeyReleasePolicy(string contentType, byte[] data, IDictionary serializedAdditionalRawData) + { + ContentType = contentType; + Data = data; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Content type and version of key release policy. + [WirePath("contentType")] + public string ContentType { get; set; } + /// Blob encoding the policy rules under which the key can be released. + [WirePath("data")] + public byte[] Data { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs new file mode 100644 index 0000000000000..00486526c6232 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmKeyRotationPolicyAttributes : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Created)) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created.Value); + } + if (options.Format != "W" && Optional.IsDefined(Updated)) + { + writer.WritePropertyName("updated"u8); + writer.WriteNumberValue(Updated.Value); + } + if (Optional.IsDefined(ExpiryTime)) + { + writer.WritePropertyName("expiryTime"u8); + writer.WriteStringValue(ExpiryTime); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmKeyRotationPolicyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmKeyRotationPolicyAttributes(document.RootElement, options); + } + + internal static ManagedHsmKeyRotationPolicyAttributes DeserializeManagedHsmKeyRotationPolicyAttributes(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long? created = default; + long? updated = default; + string expiryTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("created"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + created = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("updated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updated = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("expiryTime"u8)) + { + expiryTime = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmKeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" created: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Created)) + { + builder.Append(" created: "); + builder.AppendLine($"'{Created.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" updated: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Updated)) + { + builder.Append(" updated: "); + builder.AppendLine($"'{Updated.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpiryTime), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" expiryTime: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ExpiryTime)) + { + builder.Append(" expiryTime: "); + if (ExpiryTime.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ExpiryTime}'''"); + } + else + { + builder.AppendLine($"'{ExpiryTime}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmKeyRotationPolicyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmKeyRotationPolicyAttributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs new file mode 100644 index 0000000000000..ec6ef95cff4f1 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The ManagedHsmKeyRotationPolicyAttributes. + public partial class ManagedHsmKeyRotationPolicyAttributes + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmKeyRotationPolicyAttributes() + { + } + + /// Initializes a new instance of . + /// Creation time in seconds since 1970-01-01T00:00:00Z. + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmKeyRotationPolicyAttributes(long? created, long? updated, string expiryTime, IDictionary serializedAdditionalRawData) + { + Created = created; + Updated = updated; + ExpiryTime = expiryTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Creation time in seconds since 1970-01-01T00:00:00Z. + [WirePath("created")] + public long? Created { get; } + /// Last updated time in seconds since 1970-01-01T00:00:00Z. + [WirePath("updated")] + public long? Updated { get; } + /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. + [WirePath("expiryTime")] + public string ExpiryTime { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs new file mode 100644 index 0000000000000..0f43c6083348e --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmLifetimeAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Trigger)) + { + writer.WritePropertyName("trigger"u8); + writer.WriteObjectValue(Trigger, options); + } + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmLifetimeAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmLifetimeAction(document.RootElement, options); + } + + internal static ManagedHsmLifetimeAction DeserializeManagedHsmLifetimeAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ManagedHsmTrigger trigger = default; + ManagedHsmAction action = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("trigger"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trigger = ManagedHsmTrigger.DeserializeManagedHsmTrigger(property.Value, options); + continue; + } + if (property.NameEquals("action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = ManagedHsmAction.DeserializeManagedHsmAction(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmLifetimeAction(trigger, action, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Trigger), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" trigger: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Trigger)) + { + builder.Append(" trigger: "); + BicepSerializationHelpers.AppendChildObject(builder, Trigger, options, 2, false, " trigger: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("KeyRotationPolicyActionType", out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" action: "); + builder.AppendLine("{"); + builder.Append(" type: "); + builder.AppendLine(propertyOverride); + builder.AppendLine(" }"); + } + else + { + if (Optional.IsDefined(Action)) + { + builder.Append(" action: "); + BicepSerializationHelpers.AppendChildObject(builder, Action, options, 2, false, " action: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmLifetimeAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmLifetimeAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs new file mode 100644 index 0000000000000..6165098284c61 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The ManagedHsmLifetimeAction. + public partial class ManagedHsmLifetimeAction + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmLifetimeAction() + { + } + + /// Initializes a new instance of . + /// The trigger of key rotation policy lifetimeAction. + /// The action of key rotation policy lifetimeAction. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmLifetimeAction(ManagedHsmTrigger trigger, ManagedHsmAction action, IDictionary serializedAdditionalRawData) + { + Trigger = trigger; + Action = action; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The trigger of key rotation policy lifetimeAction. + [WirePath("trigger")] + public ManagedHsmTrigger Trigger { get; set; } + /// The action of key rotation policy lifetimeAction. + internal ManagedHsmAction Action { get; set; } + /// The type of action. + [WirePath("action.type")] + public KeyRotationPolicyActionType? KeyRotationPolicyActionType + { + get => Action is null ? default : Action.KeyRotationPolicyActionType; + set + { + if (Action is null) + Action = new ManagedHsmAction(); + Action.KeyRotationPolicyActionType = value; + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs index 309d75cef7bee..e941c9dc5440d 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.Serialization.cs @@ -34,6 +34,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -134,6 +140,7 @@ internal static ManagedHsmPrivateLinkResourceData DeserializeManagedHsmPrivateLi return null; } ManagedHsmSku sku = default; + ManagedServiceIdentity identity = default; IDictionary tags = default; AzureLocation location = default; ResourceIdentifier id = default; @@ -156,6 +163,16 @@ internal static ManagedHsmPrivateLinkResourceData DeserializeManagedHsmPrivateLi sku = ManagedHsmSku.DeserializeManagedHsmSku(property.Value, options); continue; } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -261,6 +278,7 @@ internal static ManagedHsmPrivateLinkResourceData DeserializeManagedHsmPrivateLi requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), sku, + identity, serializedAdditionalRawData); } @@ -362,6 +380,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" identity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Identity)) + { + builder.Append(" identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (hasPropertyOverride) { diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.cs index 9ca2c6eea3a85..dedb7a19193bb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmPrivateLinkResourceData.cs @@ -66,13 +66,15 @@ public ManagedHsmPrivateLinkResourceData(AzureLocation location) : base(location /// Required member names of private link resource. /// Required DNS zone names of the the private link resource. /// SKU details. + /// Managed service identity (system assigned and/or user assigned identities). /// Keeps track of any properties unknown to the library. - internal ManagedHsmPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string groupId, IReadOnlyList requiredMembers, IList requiredZoneNames, ManagedHsmSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal ManagedHsmPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string groupId, IReadOnlyList requiredMembers, IList requiredZoneNames, ManagedHsmSku sku, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) { GroupId = groupId; RequiredMembers = requiredMembers; RequiredZoneNames = requiredZoneNames; Sku = sku; + Identity = identity; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -93,5 +95,8 @@ internal ManagedHsmPrivateLinkResourceData() /// SKU details. [WirePath("sku")] public ManagedHsmSku Sku { get; set; } + /// Managed service identity (system assigned and/or user assigned identities). + [WirePath("identity")] + public ManagedServiceIdentity Identity { get; set; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs new file mode 100644 index 0000000000000..a30f50e0a39ec --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmRotationPolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsCollectionDefined(LifetimeActions)) + { + writer.WritePropertyName("lifetimeActions"u8); + writer.WriteStartArray(); + foreach (var item in LifetimeActions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmRotationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmRotationPolicy(document.RootElement, options); + } + + internal static ManagedHsmRotationPolicy DeserializeManagedHsmRotationPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ManagedHsmKeyRotationPolicyAttributes attributes = default; + IList lifetimeActions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("attributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = ManagedHsmKeyRotationPolicyAttributes.DeserializeManagedHsmKeyRotationPolicyAttributes(property.Value, options); + continue; + } + if (property.NameEquals("lifetimeActions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ManagedHsmLifetimeAction.DeserializeManagedHsmLifetimeAction(item, options)); + } + lifetimeActions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmRotationPolicy(attributes, lifetimeActions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" attributes: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Attributes)) + { + builder.Append(" attributes: "); + BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LifetimeActions), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" lifetimeActions: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(LifetimeActions)) + { + if (LifetimeActions.Any()) + { + builder.Append(" lifetimeActions: "); + builder.AppendLine("["); + foreach (var item in LifetimeActions) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " lifetimeActions: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmRotationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmRotationPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs new file mode 100644 index 0000000000000..5ed549348ac4f --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The ManagedHsmRotationPolicy. + public partial class ManagedHsmRotationPolicy + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmRotationPolicy() + { + LifetimeActions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The attributes of key rotation policy. + /// The lifetimeActions for key rotation action. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmRotationPolicy(ManagedHsmKeyRotationPolicyAttributes attributes, IList lifetimeActions, IDictionary serializedAdditionalRawData) + { + Attributes = attributes; + LifetimeActions = lifetimeActions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The attributes of key rotation policy. + [WirePath("attributes")] + public ManagedHsmKeyRotationPolicyAttributes Attributes { get; set; } + /// The lifetimeActions for key rotation action. + [WirePath("lifetimeActions")] + public IList LifetimeActions { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs new file mode 100644 index 0000000000000..db04428691550 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class ManagedHsmTrigger : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(TimeAfterCreate)) + { + writer.WritePropertyName("timeAfterCreate"u8); + writer.WriteStringValue(TimeAfterCreate); + } + if (Optional.IsDefined(TimeBeforeExpiry)) + { + writer.WritePropertyName("timeBeforeExpiry"u8); + writer.WriteStringValue(TimeBeforeExpiry); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedHsmTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedHsmTrigger(document.RootElement, options); + } + + internal static ManagedHsmTrigger DeserializeManagedHsmTrigger(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string timeAfterCreate = default; + string timeBeforeExpiry = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeAfterCreate"u8)) + { + timeAfterCreate = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeBeforeExpiry"u8)) + { + timeBeforeExpiry = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedHsmTrigger(timeAfterCreate, timeBeforeExpiry, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeAfterCreate), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" timeAfterCreate: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(TimeAfterCreate)) + { + builder.Append(" timeAfterCreate: "); + if (TimeAfterCreate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TimeAfterCreate}'''"); + } + else + { + builder.AppendLine($"'{TimeAfterCreate}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeBeforeExpiry), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" timeBeforeExpiry: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(TimeBeforeExpiry)) + { + builder.Append(" timeBeforeExpiry: "); + if (TimeBeforeExpiry.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TimeBeforeExpiry}'''"); + } + else + { + builder.AppendLine($"'{TimeBeforeExpiry}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support writing '{options.Format}' format."); + } + } + + ManagedHsmTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedHsmTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs new file mode 100644 index 0000000000000..7099a9da7eed7 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The ManagedHsmTrigger. + public partial class ManagedHsmTrigger + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ManagedHsmTrigger() + { + } + + /// Initializes a new instance of . + /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + /// Keeps track of any properties unknown to the library. + internal ManagedHsmTrigger(string timeAfterCreate, string timeBeforeExpiry, IDictionary serializedAdditionalRawData) + { + TimeAfterCreate = timeAfterCreate; + TimeBeforeExpiry = timeBeforeExpiry; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + [WirePath("timeAfterCreate")] + public string TimeAfterCreate { get; set; } + /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + [WirePath("timeBeforeExpiry")] + public string TimeBeforeExpiry { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs new file mode 100644 index 0000000000000..d7754d2f19adb --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class RotationPolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RotationPolicy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsCollectionDefined(LifetimeActions)) + { + writer.WritePropertyName("lifetimeActions"u8); + writer.WriteStartArray(); + foreach (var item in LifetimeActions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RotationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RotationPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRotationPolicy(document.RootElement, options); + } + + internal static RotationPolicy DeserializeRotationPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + KeyRotationPolicyAttributes attributes = default; + IList lifetimeActions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("attributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = KeyRotationPolicyAttributes.DeserializeKeyRotationPolicyAttributes(property.Value, options); + continue; + } + if (property.NameEquals("lifetimeActions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LifetimeAction.DeserializeLifetimeAction(item, options)); + } + lifetimeActions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RotationPolicy(attributes, lifetimeActions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" attributes: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Attributes)) + { + builder.Append(" attributes: "); + BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LifetimeActions), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" lifetimeActions: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(LifetimeActions)) + { + if (LifetimeActions.Any()) + { + builder.Append(" lifetimeActions: "); + builder.AppendLine("["); + foreach (var item in LifetimeActions) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " lifetimeActions: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RotationPolicy)} does not support writing '{options.Format}' format."); + } + } + + RotationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRotationPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RotationPolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs new file mode 100644 index 0000000000000..467ef8d13f342 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The RotationPolicy. + public partial class RotationPolicy + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RotationPolicy() + { + LifetimeActions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The attributes of key rotation policy. + /// The lifetimeActions for key rotation action. + /// Keeps track of any properties unknown to the library. + internal RotationPolicy(KeyRotationPolicyAttributes attributes, IList lifetimeActions, IDictionary serializedAdditionalRawData) + { + Attributes = attributes; + LifetimeActions = lifetimeActions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The attributes of key rotation policy. + [WirePath("attributes")] + public KeyRotationPolicyAttributes Attributes { get; set; } + /// The lifetimeActions for key rotation action. + [WirePath("lifetimeActions")] + public IList LifetimeActions { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs new file mode 100644 index 0000000000000..bdcb6db2e5e30 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class Trigger : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trigger)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(TimeAfterCreate)) + { + writer.WritePropertyName("timeAfterCreate"u8); + writer.WriteStringValue(TimeAfterCreate); + } + if (Optional.IsDefined(TimeBeforeExpiry)) + { + writer.WritePropertyName("timeBeforeExpiry"u8); + writer.WriteStringValue(TimeBeforeExpiry); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Trigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trigger)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrigger(document.RootElement, options); + } + + internal static Trigger DeserializeTrigger(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string timeAfterCreate = default; + string timeBeforeExpiry = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeAfterCreate"u8)) + { + timeAfterCreate = property.Value.GetString(); + continue; + } + if (property.NameEquals("timeBeforeExpiry"u8)) + { + timeBeforeExpiry = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Trigger(timeAfterCreate, timeBeforeExpiry, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeAfterCreate), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" timeAfterCreate: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(TimeAfterCreate)) + { + builder.Append(" timeAfterCreate: "); + if (TimeAfterCreate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TimeAfterCreate}'''"); + } + else + { + builder.AppendLine($"'{TimeAfterCreate}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeBeforeExpiry), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" timeBeforeExpiry: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(TimeBeforeExpiry)) + { + builder.Append(" timeBeforeExpiry: "); + if (TimeBeforeExpiry.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TimeBeforeExpiry}'''"); + } + else + { + builder.AppendLine($"'{TimeBeforeExpiry}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(Trigger)} does not support writing '{options.Format}' format."); + } + } + + Trigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Trigger)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs new file mode 100644 index 0000000000000..0e84486b206cd --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The Trigger. + public partial class Trigger + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Trigger() + { + } + + /// Initializes a new instance of . + /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + /// Keeps track of any properties unknown to the library. + internal Trigger(string timeAfterCreate, string timeBeforeExpiry, IDictionary serializedAdditionalRawData) + { + TimeAfterCreate = timeAfterCreate; + TimeBeforeExpiry = timeBeforeExpiry; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + [WirePath("timeAfterCreate")] + public string TimeAfterCreate { get; set; } + /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + [WirePath("timeBeforeExpiry")] + public string TimeBeforeExpiry { get; set; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs new file mode 100644 index 0000000000000..a31017356476d --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.KeyVault.Models +{ + public partial class VaultKeyCreateOrUpdateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VaultKeyCreateOrUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVaultKeyCreateOrUpdateContent(document.RootElement, options); + } + + internal static VaultKeyCreateOrUpdateContent DeserializeVaultKeyCreateOrUpdateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + KeyProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties"u8)) + { + properties = KeyProperties.DeserializeKeyProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VaultKeyCreateOrUpdateContent(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support writing '{options.Format}' format."); + } + } + + VaultKeyCreateOrUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVaultKeyCreateOrUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs new file mode 100644 index 0000000000000..21b3018178dc7 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.KeyVault.Models +{ + /// The parameters used to create a key. + public partial class VaultKeyCreateOrUpdateContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The properties of the key to be created. + /// is null. + public VaultKeyCreateOrUpdateContent(KeyProperties properties) + { + Argument.AssertNotNull(properties, nameof(properties)); + + Tags = new ChangeTrackingDictionary(); + Properties = properties; + } + + /// Initializes a new instance of . + /// The tags that will be assigned to the key. + /// The properties of the key to be created. + /// Keeps track of any properties unknown to the library. + internal VaultKeyCreateOrUpdateContent(IDictionary tags, KeyProperties properties, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VaultKeyCreateOrUpdateContent() + { + } + + /// The tags that will be assigned to the key. + [WirePath("tags")] + public IDictionary Tags { get; } + /// The properties of the key to be created. + [WirePath("properties")] + public KeyProperties Properties { get; } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs new file mode 100644 index 0000000000000..3391b595652d0 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs @@ -0,0 +1,731 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault +{ + internal partial class KeysRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of KeysRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public KeysRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2023-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateCreateIfNotExistRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateIfNotExistRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the key vault which contains the key to be created. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CreateIfNotExistAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, vaultName, keyName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyData.DeserializeKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the key vault which contains the key to be created. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateIfNotExist(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, vaultName, keyName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyData.DeserializeKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the current version of the specified key from the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key to be retrieved. + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, vaultName, keyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyData.DeserializeKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((KeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the current version of the specified key from the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key to be retrieved. + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, vaultName, keyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyData.DeserializeKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((KeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string vaultName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string vaultName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the keys in the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the keys to be retrieved. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, vaultName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the keys in the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the keys to be retrieved. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, vaultName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetVersionRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(keyVersion, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetVersionRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(keyVersion, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified version of the specified key in the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key version to be retrieved. + /// The name of the key version to be retrieved. + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetVersionAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, vaultName, keyName, keyVersion); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyData.DeserializeKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((KeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified version of the specified key in the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key version to be retrieved. + /// The name of the key version to be retrieved. + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response GetVersion(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, vaultName, keyName, keyVersion); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyData.DeserializeKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((KeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListVersionsRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListVersionsRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the versions of the specified key in the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key versions to be retrieved. + /// The name of the key versions to be retrieved. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListVersionsAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, vaultName, keyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the versions of the specified key in the specified key vault. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key versions to be retrieved. + /// The name of the key versions to be retrieved. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListVersions(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, vaultName, keyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string vaultName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string vaultName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the keys in the specified key vault. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the keys to be retrieved. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the keys in the specified key vault. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the keys to be retrieved. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListVersionsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListVersionsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the versions of the specified key in the specified key vault. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key versions to be retrieved. + /// The name of the key versions to be retrieved. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListVersionsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName, keyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the versions of the specified key in the specified key vault. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group which contains the specified key vault. + /// The name of the vault which contains the key versions to be retrieved. + /// The name of the key versions to be retrieved. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListVersionsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName, keyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + KeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = KeyListResult.DeserializeKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs new file mode 100644 index 0000000000000..81877c2718ec0 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs @@ -0,0 +1,731 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault +{ + internal partial class ManagedHsmKeysRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ManagedHsmKeysRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public ManagedHsmKeysRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2023-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateCreateIfNotExistRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateIfNotExistRequest(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CreateIfNotExistAsync(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, name, keyName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateIfNotExist(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, name, keyName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string name, string keyName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the current version of the specified key from the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, name, keyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ManagedHsmKeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the current version of the specified key from the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, name, keyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ManagedHsmKeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the keys in the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the keys in the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetVersionRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(keyVersion, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetVersionRequest(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(keyVersion, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified version of the specified key in the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetVersionAsync(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, name, keyName, keyVersion); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ManagedHsmKeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified version of the specified key in the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response GetVersion(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, name, keyName, keyVersion); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ManagedHsmKeyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListVersionsRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListVersionsRequest(string subscriptionId, string resourceGroupName, string name, string keyName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/keys/", false); + uri.AppendPath(keyName, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the versions of the specified key in the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListVersionsAsync(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, name, keyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the versions of the specified key in the specified managed HSM. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListVersions(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, name, keyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the keys in the specified managed HSM. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the keys in the specified managed HSM. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListVersionsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListVersionsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the versions of the specified key in the specified managed HSM. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListVersionsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name, keyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the versions of the specified key in the specified managed HSM. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. The name is case insensitive. + /// The name of the Managed HSM Pool within the specified resource group. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListVersionsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name, keyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ManagedHsmKeyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmsRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmsRestOperations.cs index 1061454b9253e..bad956922d771 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmsRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmsRestOperations.cs @@ -32,7 +32,7 @@ public ManagedHsmsRestOperations(HttpPipeline pipeline, string applicationId, Ur { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateEndpointConnectionsRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateEndpointConnectionsRestOperations.cs index a1189737ddac4..78789cdbe3e26 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateEndpointConnectionsRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateEndpointConnectionsRestOperations.cs @@ -32,7 +32,7 @@ public MhsmPrivateEndpointConnectionsRestOperations(HttpPipeline pipeline, strin { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateLinkResourcesRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateLinkResourcesRestOperations.cs index 297e0d05da55a..0306c0e006d51 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateLinkResourcesRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmPrivateLinkResourcesRestOperations.cs @@ -32,7 +32,7 @@ public MhsmPrivateLinkResourcesRestOperations(HttpPipeline pipeline, string appl { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmRegionsRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmRegionsRestOperations.cs index 43bda757afcb7..14882073b945c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmRegionsRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/MhsmRegionsRestOperations.cs @@ -32,7 +32,7 @@ public MhsmRegionsRestOperations(HttpPipeline pipeline, string applicationId, Ur { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs index dbfe4780334b8..f8d9c49e75847 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs @@ -32,7 +32,7 @@ public PrivateEndpointConnectionsRestOperations(HttpPipeline pipeline, string ap { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs index f699c64a163cd..6078116a5f5e6 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs @@ -32,7 +32,7 @@ public PrivateLinkResourcesRestOperations(HttpPipeline pipeline, string applicat { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/SecretsRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/SecretsRestOperations.cs index d851c50971c7c..f1bb76b1259e8 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/SecretsRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/SecretsRestOperations.cs @@ -32,7 +32,7 @@ public SecretsRestOperations(HttpPipeline pipeline, string applicationId, Uri en { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/VaultsRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/VaultsRestOperations.cs index 2aa72bee7a349..a0a47004dcc5c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/VaultsRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/VaultsRestOperations.cs @@ -32,7 +32,7 @@ public VaultsRestOperations(HttpPipeline pipeline, string applicationId, Uri end { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-02-01"; + _apiVersion = apiVersion ?? "2023-07-01"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs new file mode 100644 index 0000000000000..68f3e39516ad9 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs @@ -0,0 +1,498 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetVaultKeys method from an instance of . + /// + public partial class VaultKeyCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _vaultKeyKeysClientDiagnostics; + private readonly KeysRestOperations _vaultKeyKeysRestClient; + + /// Initializes a new instance of the class for mocking. + protected VaultKeyCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal VaultKeyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _vaultKeyKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", VaultKeyResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(VaultKeyResource.ResourceType, out string vaultKeyKeysApiVersion); + _vaultKeyKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != KeyVaultResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, KeyVaultResource.ResourceType), nameof(id)); + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _vaultKeyKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken).ConfigureAwait(false); + var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _vaultKeyKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken); + var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the current version of the specified key from the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Get"); + scope.Start(); + try + { + var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the current version of the specified key from the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Get"); + scope.Start(); + try + { + var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the keys in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys + /// + /// + /// Operation Id + /// Keys_List + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the keys in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys + /// + /// + /// Operation Id + /// Keys_List + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Exists"); + scope.Start(); + try + { + var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Exists"); + scope.Start(); + try + { + var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string keyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.GetIfExists"); + scope.Start(); + try + { + var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs new file mode 100644 index 0000000000000..c322128e55e4e --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.KeyVault +{ + public partial class VaultKeyResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + KeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + KeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs new file mode 100644 index 0000000000000..7d661296147ae --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs @@ -0,0 +1,337 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.KeyVault.Models; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A Class representing a VaultKey along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetVaultKeyResource method. + /// Otherwise you can get one from its parent resource using the GetVaultKey method. + /// + public partial class VaultKeyResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The vaultName. + /// The keyName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _vaultKeyKeysClientDiagnostics; + private readonly KeysRestOperations _vaultKeyKeysRestClient; + private readonly KeyData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KeyVault/vaults/keys"; + + /// Initializes a new instance of the class for mocking. + protected VaultKeyResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal VaultKeyResource(ArmClient client, KeyData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal VaultKeyResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _vaultKeyKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string vaultKeyKeysApiVersion); + _vaultKeyKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual KeyData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of VaultKeyVersionResources in the VaultKey. + /// An object representing collection of VaultKeyVersionResources and their operations over a VaultKeyVersionResource. + public virtual VaultKeyVersionCollection GetVaultKeyVersions() + { + return GetCachedClient(client => new VaultKeyVersionCollection(client, Id)); + } + + /// + /// Gets the specified version of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVaultKeyVersionAsync(string keyVersion, CancellationToken cancellationToken = default) + { + return await GetVaultKeyVersions().GetAsync(keyVersion, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified version of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVaultKeyVersion(string keyVersion, CancellationToken cancellationToken = default) + { + return GetVaultKeyVersions().Get(keyVersion, cancellationToken); + } + + /// + /// Gets the current version of the specified key from the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Get"); + scope.Start(); + try + { + var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the current version of the specified key from the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_Get + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Get"); + scope.Start(); + try + { + var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Update"); + scope.Start(); + try + { + var response = await _vaultKeyKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} + /// + /// + /// Operation Id + /// Keys_CreateIfNotExist + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters used to create the specified key. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Update"); + scope.Start(); + try + { + var response = _vaultKeyKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs new file mode 100644 index 0000000000000..81e7f1853a756 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs @@ -0,0 +1,395 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetVaultKeyVersions method from an instance of . + /// + public partial class VaultKeyVersionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _vaultKeyVersionKeysClientDiagnostics; + private readonly KeysRestOperations _vaultKeyVersionKeysRestClient; + + /// Initializes a new instance of the class for mocking. + protected VaultKeyVersionCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal VaultKeyVersionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _vaultKeyVersionKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", VaultKeyVersionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(VaultKeyVersionResource.ResourceType, out string vaultKeyVersionKeysApiVersion); + _vaultKeyVersionKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyVersionKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != VaultKeyResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, VaultKeyResource.ResourceType), nameof(id)); + } + + /// + /// Gets the specified version of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Get"); + scope.Start(); + try + { + var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified version of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Get"); + scope.Start(); + try + { + var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the versions of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions + /// + /// + /// Operation Id + /// Keys_ListVersions + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyVersionKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyVersionKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the versions of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions + /// + /// + /// Operation Id + /// Keys_ListVersions + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyVersionKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyVersionKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Exists"); + scope.Start(); + try + { + var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Exists"); + scope.Start(); + try + { + var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The version of the key to be retrieved. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string keyVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); + + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.GetIfExists"); + scope.Start(); + try + { + var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs new file mode 100644 index 0000000000000..2e934cedc0573 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.KeyVault +{ + public partial class VaultKeyVersionResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + KeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + KeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs new file mode 100644 index 0000000000000..b9cbc8e78a2e2 --- /dev/null +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.KeyVault +{ + /// + /// A Class representing a VaultKeyVersion along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetVaultKeyVersionResource method. + /// Otherwise you can get one from its parent resource using the GetVaultKeyVersion method. + /// + public partial class VaultKeyVersionResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The vaultName. + /// The keyName. + /// The keyVersion. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _vaultKeyVersionKeysClientDiagnostics; + private readonly KeysRestOperations _vaultKeyVersionKeysRestClient; + private readonly KeyData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KeyVault/vaults/keys/versions"; + + /// Initializes a new instance of the class for mocking. + protected VaultKeyVersionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal VaultKeyVersionResource(ArmClient client, KeyData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal VaultKeyVersionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _vaultKeyVersionKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string vaultKeyVersionKeysApiVersion); + _vaultKeyVersionKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyVersionKeysApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual KeyData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Gets the specified version of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionResource.Get"); + scope.Start(); + try + { + var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified version of the specified key in the specified key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} + /// + /// + /// Operation Id + /// Keys_GetVersion + /// + /// + /// Default Api Version + /// 2023-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionResource.Get"); + scope.Start(); + try + { + var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index 0f11720925da6..38682bc75c8eb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -7,7 +7,8 @@ azure-arm: true csharp: true library-name: KeyVault namespace: Azure.ResourceManager.KeyVault -tag: package-2023-02 +require: https://github.com/Azure/azure-rest-api-specs/blob/d1296700aa6cd650970e9891dd58eef5698327fd/specification/keyvault/resource-manager/readme.md +#tag: package-2023-02 output-folder: $(this-folder)/Generated clear-output-folder: true sample-gen: @@ -120,6 +121,8 @@ rename-mapping: CertificatePermissions: IdentityAccessCertificatePermission IPRule.value: AddressRange CheckNameAvailabilityResult: KeyVaultNameAvailabilityResult + Trigger: ValutTrigger + Action: ValutAction prompted-enum-values: Default From 2630bc31c6940af7e9d483701935f108297c7fee Mon Sep 17 00:00:00 2001 From: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:03:49 +0800 Subject: [PATCH 2/8] rename --- ....cs => KeyRotationAction.Serialization.cs} | 48 +++++++++---------- .../{Action.cs => KeyRotationAction.cs} | 18 +++---- ...cs => KeyRotationTrigger.Serialization.cs} | 38 +++++++-------- .../{Trigger.cs => KeyRotationTrigger.cs} | 12 ++--- .../Models/LifetimeAction.Serialization.cs | 10 ++-- .../src/Generated/Models/LifetimeAction.cs | 14 +++--- .../src/autorest.md | 4 +- 7 files changed, 72 insertions(+), 72 deletions(-) rename sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/{Action.Serialization.cs => KeyRotationAction.Serialization.cs} (67%) rename sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/{Action.cs => KeyRotationAction.cs} (74%) rename sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/{Trigger.Serialization.cs => KeyRotationTrigger.Serialization.cs} (76%) rename sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/{Trigger.cs => KeyRotationTrigger.cs} (85%) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs similarity index 67% rename from sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs rename to sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs index 0830e8d9f6c21..65385074f5ecf 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs @@ -14,23 +14,23 @@ namespace Azure.ResourceManager.KeyVault.Models { - internal partial class Action : IUtf8JsonSerializable, IJsonModel + internal partial class KeyRotationAction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(Action)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(KeyRotationAction)} does not support writing '{format}' format."); } writer.WriteStartObject(); - if (Optional.IsDefined(KeyRotationPolicyActionType)) + if (Optional.IsDefined(ActionType)) { writer.WritePropertyName("type"u8); - writer.WriteStringValue(KeyRotationPolicyActionType.Value.ToSerialString()); + writer.WriteStringValue(ActionType.Value.ToSerialString()); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -50,19 +50,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions op writer.WriteEndObject(); } - Action IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + KeyRotationAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(Action)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(KeyRotationAction)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAction(document.RootElement, options); + return DeserializeKeyRotationAction(document.RootElement, options); } - internal static Action DeserializeAction(JsonElement element, ModelReaderWriterOptions options = null) + internal static KeyRotationAction DeserializeKeyRotationAction(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -90,7 +90,7 @@ internal static Action DeserializeAction(JsonElement element, ModelReaderWriterO } } serializedAdditionalRawData = rawDataDictionary; - return new Action(type, serializedAdditionalRawData); + return new KeyRotationAction(type, serializedAdditionalRawData); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) @@ -104,7 +104,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyRotationPolicyActionType), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionType), out propertyOverride); if (hasPropertyOverride) { builder.Append(" type: "); @@ -112,10 +112,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(KeyRotationPolicyActionType)) + if (Optional.IsDefined(ActionType)) { builder.Append(" type: "); - builder.AppendLine($"'{KeyRotationPolicyActionType.Value.ToSerialString()}'"); + builder.AppendLine($"'{ActionType.Value.ToSerialString()}'"); } } @@ -123,9 +123,9 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { @@ -134,26 +134,26 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) case "bicep": return SerializeBicep(options); default: - throw new FormatException($"The model {nameof(Action)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(KeyRotationAction)} does not support writing '{options.Format}' format."); } } - Action IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + KeyRotationAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAction(document.RootElement, options); + return DeserializeKeyRotationAction(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(Action)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(KeyRotationAction)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs similarity index 74% rename from sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs rename to sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs index 033b56749c373..b72cbb9c25f41 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Action.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs @@ -10,8 +10,8 @@ namespace Azure.ResourceManager.KeyVault.Models { - /// The Action. - internal partial class Action + /// The KeyRotationAction. + internal partial class KeyRotationAction { /// /// Keeps track of any properties unknown to the library. @@ -45,22 +45,22 @@ internal partial class Action /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - public Action() + /// Initializes a new instance of . + public KeyRotationAction() { } - /// Initializes a new instance of . - /// The type of action. + /// Initializes a new instance of . + /// The type of action. /// Keeps track of any properties unknown to the library. - internal Action(KeyRotationPolicyActionType? keyRotationPolicyActionType, IDictionary serializedAdditionalRawData) + internal KeyRotationAction(KeyRotationPolicyActionType? actionType, IDictionary serializedAdditionalRawData) { - KeyRotationPolicyActionType = keyRotationPolicyActionType; + ActionType = actionType; _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of action. [WirePath("type")] - public KeyRotationPolicyActionType? KeyRotationPolicyActionType { get; set; } + public KeyRotationPolicyActionType? ActionType { get; set; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs similarity index 76% rename from sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs rename to sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs index bdcb6db2e5e30..ac11fb15f13e6 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs @@ -14,16 +14,16 @@ namespace Azure.ResourceManager.KeyVault.Models { - public partial class Trigger : IUtf8JsonSerializable, IJsonModel + public partial class KeyRotationTrigger : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(Trigger)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -55,19 +55,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions o writer.WriteEndObject(); } - Trigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + KeyRotationTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(Trigger)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTrigger(document.RootElement, options); + return DeserializeKeyRotationTrigger(document.RootElement, options); } - internal static Trigger DeserializeTrigger(JsonElement element, ModelReaderWriterOptions options = null) + internal static KeyRotationTrigger DeserializeKeyRotationTrigger(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -97,7 +97,7 @@ internal static Trigger DeserializeTrigger(JsonElement element, ModelReaderWrite } } serializedAdditionalRawData = rawDataDictionary; - return new Trigger(timeAfterCreate, timeBeforeExpiry, serializedAdditionalRawData); + return new KeyRotationTrigger(timeAfterCreate, timeBeforeExpiry, serializedAdditionalRawData); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) @@ -161,9 +161,9 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { @@ -172,26 +172,26 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) case "bicep": return SerializeBicep(options); default: - throw new FormatException($"The model {nameof(Trigger)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support writing '{options.Format}' format."); } } - Trigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + KeyRotationTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeTrigger(document.RootElement, options); + return DeserializeKeyRotationTrigger(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(Trigger)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs similarity index 85% rename from sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs rename to sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs index 0e84486b206cd..03244e2c23145 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/Trigger.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs @@ -10,8 +10,8 @@ namespace Azure.ResourceManager.KeyVault.Models { - /// The Trigger. - public partial class Trigger + /// The KeyRotationTrigger. + public partial class KeyRotationTrigger { /// /// Keeps track of any properties unknown to the library. @@ -45,16 +45,16 @@ public partial class Trigger /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - public Trigger() + /// Initializes a new instance of . + public KeyRotationTrigger() { } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. /// Keeps track of any properties unknown to the library. - internal Trigger(string timeAfterCreate, string timeBeforeExpiry, IDictionary serializedAdditionalRawData) + internal KeyRotationTrigger(string timeAfterCreate, string timeBeforeExpiry, IDictionary serializedAdditionalRawData) { TimeAfterCreate = timeAfterCreate; TimeBeforeExpiry = timeBeforeExpiry; diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs index 0f2649c6d9567..2cedba0792e4c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs @@ -75,8 +75,8 @@ internal static LifetimeAction DeserializeLifetimeAction(JsonElement element, Mo { return null; } - Trigger trigger = default; - Action action = default; + KeyRotationTrigger trigger = default; + KeyRotationAction action = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -87,7 +87,7 @@ internal static LifetimeAction DeserializeLifetimeAction(JsonElement element, Mo { continue; } - trigger = Trigger.DeserializeTrigger(property.Value, options); + trigger = KeyRotationTrigger.DeserializeKeyRotationTrigger(property.Value, options); continue; } if (property.NameEquals("action"u8)) @@ -96,7 +96,7 @@ internal static LifetimeAction DeserializeLifetimeAction(JsonElement element, Mo { continue; } - action = Action.DeserializeAction(property.Value, options); + action = KeyRotationAction.DeserializeKeyRotationAction(property.Value, options); continue; } if (options.Format != "W") @@ -134,7 +134,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("KeyRotationPolicyActionType", out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("ActionType", out propertyOverride); if (hasPropertyOverride) { builder.Append(" action: "); diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs index 27350f296acd7..458d6777e4f5c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs @@ -54,7 +54,7 @@ public LifetimeAction() /// The trigger of key rotation policy lifetimeAction. /// The action of key rotation policy lifetimeAction. /// Keeps track of any properties unknown to the library. - internal LifetimeAction(Trigger trigger, Action action, IDictionary serializedAdditionalRawData) + internal LifetimeAction(KeyRotationTrigger trigger, KeyRotationAction action, IDictionary serializedAdditionalRawData) { Trigger = trigger; Action = action; @@ -63,19 +63,19 @@ internal LifetimeAction(Trigger trigger, Action action, IDictionary The trigger of key rotation policy lifetimeAction. [WirePath("trigger")] - public Trigger Trigger { get; set; } + public KeyRotationTrigger Trigger { get; set; } /// The action of key rotation policy lifetimeAction. - internal Action Action { get; set; } + internal KeyRotationAction Action { get; set; } /// The type of action. [WirePath("action.type")] - public KeyRotationPolicyActionType? KeyRotationPolicyActionType + public KeyRotationPolicyActionType? ActionType { - get => Action is null ? default : Action.KeyRotationPolicyActionType; + get => Action is null ? default : Action.ActionType; set { if (Action is null) - Action = new Action(); - Action.KeyRotationPolicyActionType = value; + Action = new KeyRotationAction(); + Action.ActionType = value; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index 38682bc75c8eb..df5348df8a45c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -121,8 +121,8 @@ rename-mapping: CertificatePermissions: IdentityAccessCertificatePermission IPRule.value: AddressRange CheckNameAvailabilityResult: KeyVaultNameAvailabilityResult - Trigger: ValutTrigger - Action: ValutAction + Trigger: KeyRotationTrigger + Action: KeyRotationAction prompted-enum-values: Default From 57c514ad39c92c7089b67ba48f8328a1518edabb Mon Sep 17 00:00:00 2001 From: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:31:23 +0800 Subject: [PATCH 3/8] Flatten --- .../src/Generated/ArmKeyVaultModelFactory.cs | 23 +- .../ManagedHsmKeyData.Serialization.cs | 343 ++---------------- .../src/Generated/ManagedHsmKeyData.cs | 65 +--- .../ManagedHsmKeyProperties.Serialization.cs | 170 +++++++++ .../src/autorest.md | 4 + 5 files changed, 218 insertions(+), 387 deletions(-) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs index cd5db8df693e3..85e5fe6fe72a9 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs @@ -205,20 +205,11 @@ public static ManagedHsmKeyRotationPolicyAttributes ManagedHsmKeyRotationPolicyA /// The name. /// The resourceType. /// The systemData. - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// The properties of the key. /// Resource tags. /// A new instance for mocking. - public static ManagedHsmKeyData ManagedHsmKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ManagedHsmKeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, ManagedHsmRotationPolicy rotationPolicy = null, ManagedHsmKeyReleasePolicy releasePolicy = null, IReadOnlyDictionary tags = null) + public static ManagedHsmKeyData ManagedHsmKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ManagedHsmKeyProperties properties = null, IReadOnlyDictionary tags = null) { - keyOps ??= new List(); tags ??= new Dictionary(); return new ManagedHsmKeyData( @@ -226,15 +217,7 @@ public static ManagedHsmKeyData ManagedHsmKeyData(ResourceIdentifier id = null, name, resourceType, systemData, - attributes, - kty, - keyOps?.ToList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, + properties, tags, serializedAdditionalRawData: null); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs index 932c49aac90ab..38f493f118cd3 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs @@ -30,6 +30,8 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite } writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -61,59 +63,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite writer.WritePropertyName("systemData"u8); JsonSerializer.Serialize(writer, SystemData); } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(Attributes)) - { - writer.WritePropertyName("attributes"u8); - writer.WriteObjectValue(Attributes, options); - } - if (Optional.IsDefined(Kty)) - { - writer.WritePropertyName("kty"u8); - writer.WriteStringValue(Kty.Value.ToString()); - } - if (Optional.IsCollectionDefined(KeyOps)) - { - writer.WritePropertyName("keyOps"u8); - writer.WriteStartArray(); - foreach (var item in KeyOps) - { - writer.WriteStringValue(item.ToString()); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(KeySize)) - { - writer.WritePropertyName("keySize"u8); - writer.WriteNumberValue(KeySize.Value); - } - if (Optional.IsDefined(CurveName)) - { - writer.WritePropertyName("curveName"u8); - writer.WriteStringValue(CurveName.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(KeyUri)) - { - writer.WritePropertyName("keyUri"u8); - writer.WriteStringValue(KeyUri.AbsoluteUri); - } - if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) - { - writer.WritePropertyName("keyUriWithVersion"u8); - writer.WriteStringValue(KeyUriWithVersion); - } - if (Optional.IsDefined(RotationPolicy)) - { - writer.WritePropertyName("rotationPolicy"u8); - writer.WriteObjectValue(RotationPolicy, options); - } - if (Optional.IsDefined(ReleasePolicy)) - { - writer.WritePropertyName("release_policy"u8); - writer.WriteObjectValue(ReleasePolicy, options); - } - writer.WriteEndObject(); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -152,24 +101,21 @@ internal static ManagedHsmKeyData DeserializeManagedHsmKeyData(JsonElement eleme { return null; } + ManagedHsmKeyProperties properties = default; IReadOnlyDictionary tags = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; - ManagedHsmKeyAttributes attributes = default; - JsonWebKeyType? kty = default; - IReadOnlyList keyOps = default; - int? keySize = default; - JsonWebKeyCurveName? curveName = default; - Uri keyUri = default; - string keyUriWithVersion = default; - ManagedHsmRotationPolicy rotationPolicy = default; - ManagedHsmKeyReleasePolicy releasePolicy = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("properties"u8)) + { + properties = ManagedHsmKeyProperties.DeserializeManagedHsmKeyProperties(property.Value, options); + continue; + } if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -208,100 +154,6 @@ internal static ManagedHsmKeyData DeserializeManagedHsmKeyData(JsonElement eleme systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } - if (property.NameEquals("properties"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("attributes"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - attributes = ManagedHsmKeyAttributes.DeserializeManagedHsmKeyAttributes(property0.Value, options); - continue; - } - if (property0.NameEquals("kty"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - kty = new JsonWebKeyType(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("keyOps"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(new JsonWebKeyOperation(item.GetString())); - } - keyOps = array; - continue; - } - if (property0.NameEquals("keySize"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keySize = property0.Value.GetInt32(); - continue; - } - if (property0.NameEquals("curveName"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - curveName = new JsonWebKeyCurveName(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("keyUri"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keyUri = new Uri(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("keyUriWithVersion"u8)) - { - keyUriWithVersion = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("rotationPolicy"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rotationPolicy = ManagedHsmRotationPolicy.DeserializeManagedHsmRotationPolicy(property0.Value, options); - continue; - } - if (property0.NameEquals("release_policy"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - releasePolicy = ManagedHsmKeyReleasePolicy.DeserializeManagedHsmKeyReleasePolicy(property0.Value, options); - continue; - } - } - continue; - } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -313,15 +165,7 @@ internal static ManagedHsmKeyData DeserializeManagedHsmKeyData(JsonElement eleme name, type, systemData, - attributes, - kty, - keyOps ?? new ChangeTrackingList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, + properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } @@ -397,190 +241,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); if (hasPropertyOverride) { - builder.Append(" id: "); + builder.Append(" properties: "); builder.AppendLine(propertyOverride); } else { - if (Optional.IsDefined(Id)) + if (Optional.IsDefined(Properties)) { - builder.Append(" id: "); - builder.AppendLine($"'{Id.ToString()}'"); + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" systemData: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(SystemData)) - { - builder.Append(" systemData: "); - builder.AppendLine($"'{SystemData.ToString()}'"); - } - } - - builder.Append(" properties:"); - builder.AppendLine(" {"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" attributes: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Attributes)) - { - builder.Append(" attributes: "); - BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 4, false, " attributes: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kty), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" kty: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Kty)) - { - builder.Append(" kty: "); - builder.AppendLine($"'{Kty.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyOps), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyOps: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(KeyOps)) - { - if (KeyOps.Any()) - { - builder.Append(" keyOps: "); - builder.AppendLine("["); - foreach (var item in KeyOps) - { - builder.AppendLine($" '{item.ToString()}'"); - } - builder.AppendLine(" ]"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keySize: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeySize)) - { - builder.Append(" keySize: "); - builder.AppendLine($"{KeySize.Value}"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurveName), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" curveName: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(CurveName)) - { - builder.Append(" curveName: "); - builder.AppendLine($"'{CurveName.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyUri: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyUri)) - { - builder.Append(" keyUri: "); - builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUriWithVersion), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyUriWithVersion: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyUriWithVersion)) - { - builder.Append(" keyUriWithVersion: "); - if (KeyUriWithVersion.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{KeyUriWithVersion}'''"); - } - else - { - builder.AppendLine($"'{KeyUriWithVersion}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RotationPolicy), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (hasPropertyOverride) { - builder.Append(" rotationPolicy: "); + builder.Append(" id: "); builder.AppendLine(propertyOverride); } else { - if (Optional.IsDefined(RotationPolicy)) + if (Optional.IsDefined(Id)) { - builder.Append(" rotationPolicy: "); - BicepSerializationHelpers.AppendChildObject(builder, RotationPolicy, options, 4, false, " rotationPolicy: "); + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReleasePolicy), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); if (hasPropertyOverride) { - builder.Append(" release_policy: "); + builder.Append(" systemData: "); builder.AppendLine(propertyOverride); } else { - if (Optional.IsDefined(ReleasePolicy)) + if (Optional.IsDefined(SystemData)) { - builder.Append(" release_policy: "); - BicepSerializationHelpers.AppendChildObject(builder, ReleasePolicy, options, 4, false, " release_policy: "); + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); } } - builder.AppendLine(" }"); builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs index 5df91ed639f14..178ab6672b7d8 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs @@ -52,9 +52,13 @@ public partial class ManagedHsmKeyData : ResourceData private IDictionary _serializedAdditionalRawData; /// Initializes a new instance of . - internal ManagedHsmKeyData() + /// The properties of the key. + /// is null. + internal ManagedHsmKeyData(ManagedHsmKeyProperties properties) { - KeyOps = new ChangeTrackingList(); + Argument.AssertNotNull(properties, nameof(properties)); + + Properties = properties; Tags = new ChangeTrackingDictionary(); } @@ -63,59 +67,24 @@ internal ManagedHsmKeyData() /// The name. /// The resourceType. /// The systemData. - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. + /// The properties of the key. /// Resource tags. /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagedHsmKeyAttributes attributes, JsonWebKeyType? kty, IReadOnlyList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, ManagedHsmRotationPolicy rotationPolicy, ManagedHsmKeyReleasePolicy releasePolicy, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal ManagedHsmKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagedHsmKeyProperties properties, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { - Attributes = attributes; - Kty = kty; - KeyOps = keyOps; - KeySize = keySize; - CurveName = curveName; - KeyUri = keyUri; - KeyUriWithVersion = keyUriWithVersion; - RotationPolicy = rotationPolicy; - ReleasePolicy = releasePolicy; + Properties = properties; Tags = tags; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The attributes of the key. - [WirePath("properties.attributes")] - public ManagedHsmKeyAttributes Attributes { get; } - /// The type of the key. For valid values, see JsonWebKeyType. - [WirePath("properties.kty")] - public JsonWebKeyType? Kty { get; } - /// Gets the key ops. - [WirePath("properties.keyOps")] - public IReadOnlyList KeyOps { get; } - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - [WirePath("properties.keySize")] - public int? KeySize { get; } - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - [WirePath("properties.curveName")] - public JsonWebKeyCurveName? CurveName { get; } - /// The URI to retrieve the current version of the key. - [WirePath("properties.keyUri")] - public Uri KeyUri { get; } - /// The URI to retrieve the specific version of the key. - [WirePath("properties.keyUriWithVersion")] - public string KeyUriWithVersion { get; } - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("properties.rotationPolicy")] - public ManagedHsmRotationPolicy RotationPolicy { get; } - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("properties.release_policy")] - public ManagedHsmKeyReleasePolicy ReleasePolicy { get; } + /// Initializes a new instance of for deserialization. + internal ManagedHsmKeyData() + { + } + + /// The properties of the key. + [WirePath("properties")] + public ManagedHsmKeyProperties Properties { get; } /// Resource tags. [WirePath("tags")] public IReadOnlyDictionary Tags { get; } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs index 2958799e7dcea..4b989666dce7d 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; @@ -228,6 +230,172 @@ internal static ManagedHsmKeyProperties DeserializeManagedHsmKeyProperties(JsonE serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" attributes: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Attributes)) + { + builder.Append(" attributes: "); + BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kty), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" kty: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Kty)) + { + builder.Append(" kty: "); + builder.AppendLine($"'{Kty.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyOps), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyOps: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(KeyOps)) + { + if (KeyOps.Any()) + { + builder.Append(" keyOps: "); + builder.AppendLine("["); + foreach (var item in KeyOps) + { + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keySize: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeySize)) + { + builder.Append(" keySize: "); + builder.AppendLine($"{KeySize.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurveName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" curveName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(CurveName)) + { + builder.Append(" curveName: "); + builder.AppendLine($"'{CurveName.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyUri: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyUri)) + { + builder.Append(" keyUri: "); + builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUriWithVersion), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyUriWithVersion: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyUriWithVersion)) + { + builder.Append(" keyUriWithVersion: "); + if (KeyUriWithVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{KeyUriWithVersion}'''"); + } + else + { + builder.AppendLine($"'{KeyUriWithVersion}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RotationPolicy), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" rotationPolicy: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(RotationPolicy)) + { + builder.Append(" rotationPolicy: "); + BicepSerializationHelpers.AppendChildObject(builder, RotationPolicy, options, 2, false, " rotationPolicy: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReleasePolicy), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" release_policy: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ReleasePolicy)) + { + builder.Append(" release_policy: "); + BicepSerializationHelpers.AppendChildObject(builder, ReleasePolicy, options, 2, false, " release_policy: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -236,6 +404,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support writing '{options.Format}' format."); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index df5348df8a45c..83d35fae8abe7 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -154,6 +154,10 @@ directive: $.VaultProperties.properties.provisioningState['x-ms-enum']['name'] = 'KeyVaultProvisioningState'; $.Vault['x-csharp-usage'] = 'model,input,output'; $.CheckNameAvailabilityResult.properties.reason['x-ms-enum']['name'] = 'KeyVaultNameUnavailableReason'; + - from: keysManagedHsm.json + where: $.definitions + transform: > + $.ManagedHsmKey.properties.properties['x-ms-client-flatten'] = false; ``` ### Tag: package-2023-02 From 8e735877a9a08a7c10510fc75d4bb6a91ff13459 Mon Sep 17 00:00:00 2001 From: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:55:04 +0800 Subject: [PATCH 4/8] Gen Api --- ...ResourceManager.KeyVault.netstandard2.0.cs | 501 +++++++++++++++++- .../src/autorest.md | 3 +- 2 files changed, 500 insertions(+), 4 deletions(-) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs index 0d06dd8162925..58e5c2c63bb59 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs @@ -74,6 +74,26 @@ protected DeletedManagedHsmResource() { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class KeyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyData() { } + public Azure.ResourceManager.KeyVault.Models.KeyAttributes Attributes { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } + public System.Collections.Generic.IList KeyOps { get { throw null; } } + public int? KeySize { get { throw null; } set { } } + public System.Uri KeyUri { get { throw null; } } + public string KeyUriWithVersion { get { throw null; } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } + public Azure.Core.AzureLocation? Location { get { throw null; } } + public Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy ReleasePolicy { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.RotationPolicy RotationPolicy { get { throw null; } set { } } + public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } + Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class KeyVaultCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected KeyVaultCollection() { } @@ -129,11 +149,15 @@ public static partial class KeyVaultExtensions public static Azure.ResourceManager.KeyVault.KeyVaultSecretResource GetKeyVaultSecretResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Response GetManagedHsm(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> GetManagedHsmAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.KeyVault.ManagedHSMKeyResource GetManagedHSMKeyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.KeyVault.ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionResource GetManagedHsmPrivateEndpointConnectionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmResource GetManagedHsmResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmCollection GetManagedHsms(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetManagedHsms(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetManagedHsmsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.KeyVault.VaultKeyResource GetVaultKeyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.KeyVault.VaultKeyVersionResource GetVaultKeyVersionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } } public partial class KeyVaultPrivateEndpointConnectionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -225,6 +249,9 @@ protected KeyVaultResource() { } public virtual Azure.ResourceManager.KeyVault.KeyVaultSecretCollection GetKeyVaultSecrets() { throw null; } public virtual Azure.Pageable GetPrivateLinkResources(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetPrivateLinkResourcesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetVaultKey(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetVaultKeyAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.KeyVault.VaultKeyCollection GetVaultKeys() { throw null; } public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -305,6 +332,7 @@ protected ManagedHsmCollection() { } public partial class ManagedHsmData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagedHsmData(Azure.Core.AzureLocation location) { } + public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.KeyVault.Models.ManagedHsmSku Sku { get { throw null; } set { } } Azure.ResourceManager.KeyVault.ManagedHsmData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -313,6 +341,90 @@ public ManagedHsmData(Azure.Core.AzureLocation location) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class ManagedHSMKeyCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ManagedHSMKeyCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ManagedHsmKeyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ManagedHsmKeyData() { } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties Properties { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } + Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ManagedHSMKeyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ManagedHSMKeyResource() { } + public virtual Azure.ResourceManager.KeyVault.ManagedHsmKeyData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetManagedHSMKeyVersion(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetManagedHSMKeyVersionAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyVersionCollection GetManagedHSMKeyVersions() { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ManagedHSMKeyVersionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ManagedHSMKeyVersionCollection() { } + public virtual Azure.Response Exists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ManagedHSMKeyVersionResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ManagedHSMKeyVersionResource() { } + public virtual Azure.ResourceManager.KeyVault.ManagedHsmKeyData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class ManagedHsmPrivateEndpointConnectionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected ManagedHsmPrivateEndpointConnectionCollection() { } @@ -334,6 +446,7 @@ public partial class ManagedHsmPrivateEndpointConnectionData : Azure.ResourceMan { public ManagedHsmPrivateEndpointConnectionData(Azure.Core.AzureLocation location) { } public Azure.ETag? ETag { get { throw null; } set { } } + public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.Core.ResourceIdentifier PrivateEndpointId { get { throw null; } } public Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get { throw null; } set { } } public Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState? ProvisioningState { get { throw null; } } @@ -382,6 +495,9 @@ protected ManagedHsmResource() { } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetManagedHSMKey(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetManagedHSMKeyAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyCollection GetManagedHSMKeys() { throw null; } public virtual Azure.Response GetManagedHsmPrivateEndpointConnection(string privateEndpointConnectionName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetManagedHsmPrivateEndpointConnectionAsync(string privateEndpointConnectionName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionCollection GetManagedHsmPrivateEndpointConnections() { throw null; } @@ -401,6 +517,73 @@ protected ManagedHsmResource() { } public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.ManagedHsmData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.ManagedHsmData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + public partial class VaultKeyCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected VaultKeyCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class VaultKeyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected VaultKeyResource() { } + public virtual Azure.ResourceManager.KeyVault.KeyData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetVaultKeyVersion(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetVaultKeyVersionAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.KeyVault.VaultKeyVersionCollection GetVaultKeyVersions() { throw null; } + Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class VaultKeyVersionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected VaultKeyVersionCollection() { } + public virtual Azure.Response Exists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class VaultKeyVersionResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected VaultKeyVersionResource() { } + public virtual Azure.ResourceManager.KeyVault.KeyData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } } namespace Azure.ResourceManager.KeyVault.Mocking { @@ -412,8 +595,12 @@ protected MockableKeyVaultArmClient() { } public virtual Azure.ResourceManager.KeyVault.KeyVaultPrivateEndpointConnectionResource GetKeyVaultPrivateEndpointConnectionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.KeyVaultResource GetKeyVaultResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.KeyVaultSecretResource GetKeyVaultSecretResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyResource GetManagedHSMKeyResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionResource GetManagedHsmPrivateEndpointConnectionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.ManagedHsmResource GetManagedHsmResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.KeyVault.VaultKeyResource GetVaultKeyResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.KeyVault.VaultKeyVersionResource GetVaultKeyVersionResource(Azure.Core.ResourceIdentifier id) { throw null; } } public partial class MockableKeyVaultResourceGroupResource : Azure.ResourceManager.ArmResource { @@ -462,6 +649,10 @@ public static partial class ArmKeyVaultModelFactory public static Azure.ResourceManager.KeyVault.Models.DeletedKeyVaultProperties DeletedKeyVaultProperties(Azure.Core.ResourceIdentifier vaultId = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledPurgeOn = default(System.DateTimeOffset?), System.Collections.Generic.IReadOnlyDictionary tags = null, bool? purgeProtectionEnabled = default(bool?)) { throw null; } public static Azure.ResourceManager.KeyVault.DeletedManagedHsmData DeletedManagedHsmData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.DeletedManagedHsmProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.DeletedManagedHsmProperties DeletedManagedHsmProperties(Azure.Core.ResourceIdentifier managedHsmId = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledPurgeOn = default(System.DateTimeOffset?), bool? purgeProtectionEnabled = default(bool?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.KeyAttributes KeyAttributes(bool? enabled = default(bool?), long? notBefore = default(long?), long? expires = default(long?), long? created = default(long?), long? updated = default(long?), Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? recoveryLevel = default(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel?), bool? exportable = default(bool?)) { throw null; } + public static Azure.ResourceManager.KeyVault.KeyData KeyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.KeyProperties KeyProperties(Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? created = default(long?), long? updated = default(long?), string expiryTime = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultAccessPolicyParameters KeyVaultAccessPolicyParameters(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IEnumerable accessPolicies = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultCreateOrUpdateContent KeyVaultCreateOrUpdateContent(Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.KeyVaultProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.KeyVaultData KeyVaultData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.KeyVault.Models.KeyVaultProperties properties = null) { throw null; } @@ -473,17 +664,29 @@ public static partial class ArmKeyVaultModelFactory public static Azure.ResourceManager.KeyVault.Models.KeyVaultProperties KeyVaultProperties(System.Guid tenantId = default(System.Guid), Azure.ResourceManager.KeyVault.Models.KeyVaultSku sku = null, System.Collections.Generic.IEnumerable accessPolicies = null, System.Uri vaultUri = null, string hsmPoolResourceId = null, bool? enabledForDeployment = default(bool?), bool? enabledForDiskEncryption = default(bool?), bool? enabledForTemplateDeployment = default(bool?), bool? enableSoftDelete = default(bool?), int? softDeleteRetentionInDays = default(int?), bool? enableRbacAuthorization = default(bool?), Azure.ResourceManager.KeyVault.Models.KeyVaultCreateMode? createMode = default(Azure.ResourceManager.KeyVault.Models.KeyVaultCreateMode?), bool? enablePurgeProtection = default(bool?), Azure.ResourceManager.KeyVault.Models.KeyVaultNetworkRuleSet networkRuleSet = null, Azure.ResourceManager.KeyVault.Models.KeyVaultProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.KeyVaultProvisioningState?), System.Collections.Generic.IEnumerable privateEndpointConnections = null, string publicNetworkAccess = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultSecretCreateOrUpdateContent KeyVaultSecretCreateOrUpdateContent(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.SecretProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.KeyVaultSecretData KeyVaultSecretData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.SecretProperties properties = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } - public static Azure.ResourceManager.KeyVault.ManagedHsmData ManagedHsmData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties properties = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.KeyVault.ManagedHsmData ManagedHsmData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties properties, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku) { throw null; } + public static Azure.ResourceManager.KeyVault.ManagedHsmData ManagedHsmData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties properties = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null, Azure.ResourceManager.Models.ManagedServiceIdentity identity = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHsmGeoReplicatedRegion ManagedHsmGeoReplicatedRegion(string name = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmGeoReplicatedRegionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmGeoReplicatedRegionProvisioningState?), bool? isPrimary = default(bool?)) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes ManagedHsmKeyAttributes(bool? enabled = default(bool?), long? notBefore = default(long?), long? expires = default(long?), long? created = default(long?), long? updated = default(long?), Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? recoveryLevel = default(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel?), bool? exportable = default(bool?)) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent ManagedHSMKeyCreateOrUpdateContent(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties properties = null) { throw null; } + public static Azure.ResourceManager.KeyVault.ManagedHsmKeyData ManagedHsmKeyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties properties = null, System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties ManagedHsmKeyProperties(Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy releasePolicy = null) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes ManagedHsmKeyRotationPolicyAttributes(long? created = default(long?), long? updated = default(long?), string expiryTime = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHsmNameAvailabilityResult ManagedHsmNameAvailabilityResult(bool? isNameAvailable = default(bool?), Azure.ResourceManager.KeyVault.Models.ManagedHsmNameUnavailableReason? reason = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmNameUnavailableReason?), string message = null) { throw null; } - public static Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ETag? etag = default(Azure.ETag?), Azure.Core.ResourceIdentifier privateEndpointId = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState?), Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ETag? etag, Azure.Core.ResourceIdentifier privateEndpointId, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku) { throw null; } + public static Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ETag? etag = default(Azure.ETag?), Azure.Core.ResourceIdentifier privateEndpointId = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState?), Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null, Azure.ResourceManager.Models.ManagedServiceIdentity identity = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionItemData ManagedHsmPrivateEndpointConnectionItemData(Azure.Core.ResourceIdentifier id = null, Azure.ETag? etag = default(Azure.ETag?), Azure.Core.ResourceIdentifier privateEndpointId = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState?)) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string groupId = null, System.Collections.Generic.IEnumerable requiredMembers = null, System.Collections.Generic.IEnumerable requiredZoneNames = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string groupId, System.Collections.Generic.IEnumerable requiredMembers, System.Collections.Generic.IEnumerable requiredZoneNames, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkResourceData ManagedHsmPrivateLinkResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string groupId = null, System.Collections.Generic.IEnumerable requiredMembers = null, System.Collections.Generic.IEnumerable requiredZoneNames = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null, Azure.ResourceManager.Models.ManagedServiceIdentity identity = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties ManagedHsmProperties(System.Guid? tenantId = default(System.Guid?), System.Collections.Generic.IEnumerable initialAdminObjectIds = null, System.Uri hsmUri = null, bool? enableSoftDelete = default(bool?), int? softDeleteRetentionInDays = default(int?), bool? enablePurgeProtection = default(bool?), Azure.ResourceManager.KeyVault.Models.ManagedHsmCreateMode? createMode = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmCreateMode?), string statusMessage = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmProvisioningState?), Azure.ResourceManager.KeyVault.Models.ManagedHsmNetworkRuleSet networkRuleSet = null, System.Collections.Generic.IEnumerable regions = null, System.Collections.Generic.IEnumerable privateEndpointConnections = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmPublicNetworkAccess? publicNetworkAccess = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmPublicNetworkAccess?), System.DateTimeOffset? scheduledPurgeOn = default(System.DateTimeOffset?), Azure.ResourceManager.KeyVault.Models.ManagedHSMSecurityDomainProperties securityDomainProperties = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHSMSecurityDomainProperties ManagedHSMSecurityDomainProperties(Azure.ResourceManager.KeyVault.Models.ManagedHSMSecurityDomainActivationStatus? activationStatus = default(Azure.ResourceManager.KeyVault.Models.ManagedHSMSecurityDomainActivationStatus?), string activationStatusMessage = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.SecretAttributes SecretAttributes(bool? enabled = default(bool?), System.DateTimeOffset? notBefore = default(System.DateTimeOffset?), System.DateTimeOffset? expires = default(System.DateTimeOffset?), System.DateTimeOffset? created = default(System.DateTimeOffset?), System.DateTimeOffset? updated = default(System.DateTimeOffset?)) { throw null; } public static Azure.ResourceManager.KeyVault.Models.SecretBaseAttributes SecretBaseAttributes(bool? enabled = default(bool?), System.DateTimeOffset? notBefore = default(System.DateTimeOffset?), System.DateTimeOffset? expires = default(System.DateTimeOffset?), System.DateTimeOffset? created = default(System.DateTimeOffset?), System.DateTimeOffset? updated = default(System.DateTimeOffset?)) { throw null; } public static Azure.ResourceManager.KeyVault.Models.SecretProperties SecretProperties(string value = null, string contentType = null, Azure.ResourceManager.KeyVault.Models.SecretAttributes attributes = null, System.Uri secretUri = null, string secretUriWithVersion = null) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent VaultKeyCreateOrUpdateContent(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.KeyProperties properties = null) { throw null; } } public partial class DeletedKeyVaultProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -522,6 +725,26 @@ internal DeletedManagedHsmProperties() { } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct DeletionRecoveryLevel : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public DeletionRecoveryLevel(string value) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel Purgeable { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel Recoverable { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel RecoverableProtectedSubscription { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel RecoverablePurgeable { get { throw null; } } + public bool Equals(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel left, Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel right) { throw null; } + public static implicit operator Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel left, Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct IdentityAccessCertificatePermission : System.IEquatable { private readonly object _dummy; @@ -660,6 +883,143 @@ public IdentityAccessPermissions() { } public static bool operator !=(Azure.ResourceManager.KeyVault.Models.IdentityAccessStoragePermission left, Azure.ResourceManager.KeyVault.Models.IdentityAccessStoragePermission right) { throw null; } public override string ToString() { throw null; } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct JsonWebKeyCurveName : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public JsonWebKeyCurveName(string value) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P256 { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P256K { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P384 { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P521 { get { throw null; } } + public bool Equals(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName right) { throw null; } + public static implicit operator Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct JsonWebKeyOperation : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public JsonWebKeyOperation(string value) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Decrypt { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Encrypt { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Import { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Release { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Sign { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation UnwrapKey { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Verify { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation WrapKey { get { throw null; } } + public bool Equals(Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation right) { throw null; } + public static implicit operator Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct JsonWebKeyType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public JsonWebKeyType(string value) { throw null; } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType EC { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType ECHSM { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType RSA { get { throw null; } } + public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType RSAHSM { get { throw null; } } + public bool Equals(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType right) { throw null; } + public static implicit operator Azure.ResourceManager.KeyVault.Models.JsonWebKeyType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class KeyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyAttributes() { } + public long? Created { get { throw null; } } + public bool? Enabled { get { throw null; } set { } } + public long? Expires { get { throw null; } set { } } + public bool? Exportable { get { throw null; } set { } } + public long? NotBefore { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? RecoveryLevel { get { throw null; } } + public long? Updated { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.KeyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.KeyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class KeyProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyProperties() { } + public Azure.ResourceManager.KeyVault.Models.KeyAttributes Attributes { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } + public System.Collections.Generic.IList KeyOps { get { throw null; } } + public int? KeySize { get { throw null; } set { } } + public System.Uri KeyUri { get { throw null; } } + public string KeyUriWithVersion { get { throw null; } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy ReleasePolicy { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.RotationPolicy RotationPolicy { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.KeyProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.KeyProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class KeyReleasePolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyReleasePolicy() { } + public string ContentType { get { throw null; } set { } } + public byte[] Data { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public enum KeyRotationPolicyActionType + { + Rotate = 0, + Notify = 1, + } + public partial class KeyRotationPolicyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyRotationPolicyAttributes() { } + public long? Created { get { throw null; } } + public string ExpiryTime { get { throw null; } set { } } + public long? Updated { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class KeyRotationTrigger : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyRotationTrigger() { } + public string TimeAfterCreate { get { throw null; } set { } } + public string TimeBeforeExpiry { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.KeyRotationTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.KeyRotationTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class KeyVaultAccessPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeyVaultAccessPolicy(System.Guid tenantId, string objectId, Azure.ResourceManager.KeyVault.Models.IdentityAccessPermissions permissions) { } @@ -1045,6 +1405,17 @@ public KeyVaultVirtualNetworkRule(string id) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class LifetimeAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LifetimeAction() { } + public Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyActionType? ActionType { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.KeyRotationTrigger Trigger { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.LifetimeAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.LifetimeAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ManagedHsmActionsRequiredMessage : System.IEquatable { @@ -1111,6 +1482,85 @@ public ManagedHsmIPRule(string addressRange) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class ManagedHsmKeyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmKeyAttributes() { } + public long? Created { get { throw null; } } + public bool? Enabled { get { throw null; } set { } } + public long? Expires { get { throw null; } set { } } + public bool? Exportable { get { throw null; } set { } } + public long? NotBefore { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? RecoveryLevel { get { throw null; } } + public long? Updated { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ManagedHSMKeyCreateOrUpdateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHSMKeyCreateOrUpdateContent(Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties properties) { } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties Properties { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ManagedHsmKeyProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmKeyProperties() { } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes Attributes { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } + public System.Collections.Generic.IList KeyOps { get { throw null; } } + public int? KeySize { get { throw null; } set { } } + public System.Uri KeyUri { get { throw null; } } + public string KeyUriWithVersion { get { throw null; } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy ReleasePolicy { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy RotationPolicy { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ManagedHsmKeyReleasePolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmKeyReleasePolicy() { } + public string ContentType { get { throw null; } set { } } + public byte[] Data { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ManagedHsmKeyRotationPolicyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmKeyRotationPolicyAttributes() { } + public long? Created { get { throw null; } } + public string ExpiryTime { get { throw null; } set { } } + public long? Updated { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ManagedHsmLifetimeAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmLifetimeAction() { } + public Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyActionType? KeyRotationPolicyActionType { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmTrigger Trigger { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmLifetimeAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmLifetimeAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class ManagedHsmNameAvailabilityContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagedHsmNameAvailabilityContent(string name) { } @@ -1260,6 +1710,7 @@ public partial class ManagedHsmPrivateLinkResourceData : Azure.ResourceManager.M { public ManagedHsmPrivateLinkResourceData(Azure.Core.AzureLocation location) { } public string GroupId { get { throw null; } } + public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyList RequiredMembers { get { throw null; } } public System.Collections.Generic.IList RequiredZoneNames { get { throw null; } } public Azure.ResourceManager.KeyVault.Models.ManagedHsmSku Sku { get { throw null; } set { } } @@ -1347,6 +1798,17 @@ public ManagedHsmProperties() { } public static bool operator !=(Azure.ResourceManager.KeyVault.Models.ManagedHsmPublicNetworkAccess left, Azure.ResourceManager.KeyVault.Models.ManagedHsmPublicNetworkAccess right) { throw null; } public override string ToString() { throw null; } } + public partial class ManagedHsmRotationPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmRotationPolicy() { } + public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes Attributes { get { throw null; } set { } } + public System.Collections.Generic.IList LifetimeActions { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ManagedHSMSecurityDomainActivationStatus : System.IEquatable { @@ -1412,6 +1874,17 @@ public enum ManagedHsmSkuName CustomB32 = 1, CustomB6 = 2, } + public partial class ManagedHsmTrigger : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedHsmTrigger() { } + public string TimeAfterCreate { get { throw null; } set { } } + public string TimeBeforeExpiry { get { throw null; } set { } } + Azure.ResourceManager.KeyVault.Models.ManagedHsmTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.ManagedHsmTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class ManagedHsmVirtualNetworkRule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagedHsmVirtualNetworkRule(Azure.Core.ResourceIdentifier subnetId) { } @@ -1422,6 +1895,17 @@ public ManagedHsmVirtualNetworkRule(Azure.Core.ResourceIdentifier subnetId) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class RotationPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RotationPolicy() { } + public Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes Attributes { get { throw null; } set { } } + public System.Collections.Generic.IList LifetimeActions { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.RotationPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.RotationPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class SecretAttributes : Azure.ResourceManager.KeyVault.Models.SecretBaseAttributes, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SecretAttributes() { } @@ -1471,4 +1955,15 @@ public SecretProperties() { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class VaultKeyCreateOrUpdateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public VaultKeyCreateOrUpdateContent(Azure.ResourceManager.KeyVault.Models.KeyProperties properties) { } + public Azure.ResourceManager.KeyVault.Models.KeyProperties Properties { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index 83d35fae8abe7..3ffb894ba0bd3 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -154,10 +154,11 @@ directive: $.VaultProperties.properties.provisioningState['x-ms-enum']['name'] = 'KeyVaultProvisioningState'; $.Vault['x-csharp-usage'] = 'model,input,output'; $.CheckNameAvailabilityResult.properties.reason['x-ms-enum']['name'] = 'KeyVaultNameUnavailableReason'; +# Remove the flatten since it will cause Tag operation error - from: keysManagedHsm.json where: $.definitions transform: > - $.ManagedHsmKey.properties.properties['x-ms-client-flatten'] = false; + delete $.ManagedHsmKey.properties.properties['x-ms-client-flatten'] ``` ### Tag: package-2023-02 From 996218a16b5b628117426969dbaf1747691a0c62 Mon Sep 17 00:00:00 2001 From: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:39:33 +0800 Subject: [PATCH 5/8] regen --- .../Samples/Sample_VaultKeyCollection.cs | 8 ++-- .../Samples/Sample_VaultKeyResource.cs | 4 +- .../Sample_VaultKeyVersionCollection.cs | 6 +-- .../Samples/Sample_VaultKeyVersionResource.cs | 2 +- .../src/Generated/ArmKeyVaultModelFactory.cs | 8 ++-- ...on.cs => KeyVaultKeyData.Serialization.cs} | 38 ++++++++-------- .../{KeyData.cs => KeyVaultKeyData.cs} | 12 ++--- .../Models/KeyListResult.Serialization.cs | 8 ++-- .../src/Generated/Models/KeyListResult.cs | 6 +-- .../RestOperations/KeysRestOperations.cs | 44 +++++++++---------- .../src/Generated/VaultKeyCollection.cs | 4 +- .../VaultKeyResource.Serialization.cs | 12 ++--- .../src/Generated/VaultKeyResource.cs | 6 +-- .../Generated/VaultKeyVersionCollection.cs | 4 +- .../VaultKeyVersionResource.Serialization.cs | 12 ++--- .../src/Generated/VaultKeyVersionResource.cs | 6 +-- .../src/autorest.md | 1 + 17 files changed, 91 insertions(+), 90 deletions(-) rename sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/{KeyData.Serialization.cs => KeyVaultKeyData.Serialization.cs} (93%) rename sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/{KeyData.cs => KeyVaultKeyData.cs} (89%) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs index ec4e8a88be62c..d59bb2a0e4657 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs @@ -50,7 +50,7 @@ public async Task CreateOrUpdate_CreateAKey() // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -85,7 +85,7 @@ public async Task Get_GetAKey() // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -158,7 +158,7 @@ public async Task GetIfExists_GetAKey() { // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -193,7 +193,7 @@ public async Task GetAll_ListKeysInTheVault() { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = item.Data; + KeyVaultKeyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs index 088244b70235e..c86970da5cd3b 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs @@ -47,7 +47,7 @@ public async Task Update_CreateAKey() // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -79,7 +79,7 @@ public async Task Get_GetAKey() // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs index e2755edb1fbde..29ec653579da2 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs @@ -45,7 +45,7 @@ public async Task Get_GetAKeyVersion() // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -120,7 +120,7 @@ public async Task GetIfExists_GetAKeyVersion() { // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -156,7 +156,7 @@ public async Task GetAll_ListKeyVersionsInTheVault() { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = item.Data; + KeyVaultKeyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs index 51ffb78dceb2e..be9f0b611d07c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs @@ -42,7 +42,7 @@ public async Task Get_GetAKeyVersion() // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyData resourceData = result.Data; + KeyVaultKeyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs index 85e5fe6fe72a9..fc0d4795e2c57 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs @@ -88,7 +88,7 @@ public static KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? crea return new KeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The id. /// The name. /// The resourceType. @@ -104,13 +104,13 @@ public static KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? crea /// Key release policy in response. It will be used for both output and input. Omitted if empty. /// Azure location of the key vault resource. /// Tags assigned to the key vault resource. - /// A new instance for mocking. - public static KeyData KeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, KeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null, AzureLocation? location = null, IReadOnlyDictionary tags = null) + /// A new instance for mocking. + public static KeyVaultKeyData KeyVaultKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, KeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null, AzureLocation? location = null, IReadOnlyDictionary tags = null) { keyOps ??= new List(); tags ??= new Dictionary(); - return new KeyData( + return new KeyVaultKeyData( id, name, resourceType, diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs similarity index 93% rename from sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs rename to sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs index 064256eb74172..375cfa7e5a4df 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs @@ -17,16 +17,16 @@ namespace Azure.ResourceManager.KeyVault { - public partial class KeyData : IUtf8JsonSerializable, IJsonModel + public partial class KeyVaultKeyData : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(KeyData)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -137,19 +137,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions o writer.WriteEndObject(); } - KeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + KeyVaultKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(KeyData)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyData(document.RootElement, options); + return DeserializeKeyVaultKeyData(document.RootElement, options); } - internal static KeyData DeserializeKeyData(JsonElement element, ModelReaderWriterOptions options = null) + internal static KeyVaultKeyData DeserializeKeyVaultKeyData(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -323,7 +323,7 @@ internal static KeyData DeserializeKeyData(JsonElement element, ModelReaderWrite } } serializedAdditionalRawData = rawDataDictionary; - return new KeyData( + return new KeyVaultKeyData( id, name, type, @@ -616,9 +616,9 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { @@ -627,26 +627,26 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) case "bicep": return SerializeBicep(options); default: - throw new FormatException($"The model {nameof(KeyData)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support writing '{options.Format}' format."); } } - KeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + KeyVaultKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyData(document.RootElement, options); + return DeserializeKeyVaultKeyData(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(KeyData)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs similarity index 89% rename from sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs rename to sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs index 9d2c370211aad..b60a7a4e4fd27 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyData.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs @@ -14,10 +14,10 @@ namespace Azure.ResourceManager.KeyVault { /// - /// A class representing the Key data model. + /// A class representing the KeyVaultKey data model. /// The key resource. /// - public partial class KeyData : ResourceData + public partial class KeyVaultKeyData : ResourceData { /// /// Keeps track of any properties unknown to the library. @@ -51,14 +51,14 @@ public partial class KeyData : ResourceData /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - public KeyData() + /// Initializes a new instance of . + public KeyVaultKeyData() { KeyOps = new ChangeTrackingList(); Tags = new ChangeTrackingDictionary(); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The id. /// The name. /// The resourceType. @@ -75,7 +75,7 @@ public KeyData() /// Azure location of the key vault resource. /// Tags assigned to the key vault resource. /// Keeps track of any properties unknown to the library. - internal KeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, KeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, AzureLocation? location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal KeyVaultKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, KeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, AzureLocation? location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Attributes = attributes; Kty = kty; diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs index 18e6aa8e4ef40..e1fe381dcee3c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs @@ -81,7 +81,7 @@ internal static KeyListResult DeserializeKeyListResult(JsonElement element, Mode { return null; } - IReadOnlyList value = default; + IReadOnlyList value = default; string nextLink = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -93,10 +93,10 @@ internal static KeyListResult DeserializeKeyListResult(JsonElement element, Mode { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KeyData.DeserializeKeyData(item, options)); + array.Add(KeyVaultKeyData.DeserializeKeyVaultKeyData(item, options)); } value = array; continue; @@ -112,7 +112,7 @@ internal static KeyListResult DeserializeKeyListResult(JsonElement element, Mode } } serializedAdditionalRawData = rawDataDictionary; - return new KeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + return new KeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs index c882d391234ef..923b48e34317e 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs @@ -48,14 +48,14 @@ internal partial class KeyListResult /// Initializes a new instance of . internal KeyListResult() { - Value = new ChangeTrackingList(); + Value = new ChangeTrackingList(); } /// Initializes a new instance of . /// The key resources. /// The URL to get the next page of keys. /// Keeps track of any properties unknown to the library. - internal KeyListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + internal KeyListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; @@ -63,7 +63,7 @@ internal KeyListResult(IReadOnlyList value, string nextLink, IDictionar } /// The key resources. - public IReadOnlyList Value { get; } + public IReadOnlyList Value { get; } /// The URL to get the next page of keys. public string NextLink { get; } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs index 3391b595652d0..e16e77485d1d0 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs @@ -87,7 +87,7 @@ internal HttpMessage CreateCreateIfNotExistRequest(string subscriptionId, string /// The cancellation token to use. /// , , , or is null. /// , , or is an empty string, and was expected to be non-empty. - public async Task> CreateIfNotExistAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + public async Task> CreateIfNotExistAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -101,9 +101,9 @@ public async Task> CreateIfNotExistAsync(string subscriptionId { case 200: { - KeyData value = default; + KeyVaultKeyData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyData.DeserializeKeyData(document.RootElement); + value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -120,7 +120,7 @@ public async Task> CreateIfNotExistAsync(string subscriptionId /// The cancellation token to use. /// , , , or is null. /// , , or is an empty string, and was expected to be non-empty. - public Response CreateIfNotExist(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) + public Response CreateIfNotExist(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -134,9 +134,9 @@ public Response CreateIfNotExist(string subscriptionId, string resource { case 200: { - KeyData value = default; + KeyVaultKeyData value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyData.DeserializeKeyData(document.RootElement); + value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -190,7 +190,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou /// The cancellation token to use. /// , , or is null. /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -203,13 +203,13 @@ public async Task> GetAsync(string subscriptionId, string reso { case 200: { - KeyData value = default; + KeyVaultKeyData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyData.DeserializeKeyData(document.RootElement); + value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); return Response.FromValue(value, message.Response); } case 404: - return Response.FromValue((KeyData)null, message.Response); + return Response.FromValue((KeyVaultKeyData)null, message.Response); default: throw new RequestFailedException(message.Response); } @@ -223,7 +223,7 @@ public async Task> GetAsync(string subscriptionId, string reso /// The cancellation token to use. /// , , or is null. /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) + public Response Get(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -236,13 +236,13 @@ public Response Get(string subscriptionId, string resourceGroupName, st { case 200: { - KeyData value = default; + KeyVaultKeyData value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyData.DeserializeKeyData(document.RootElement); + value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); return Response.FromValue(value, message.Response); } case 404: - return Response.FromValue((KeyData)null, message.Response); + return Response.FromValue((KeyVaultKeyData)null, message.Response); default: throw new RequestFailedException(message.Response); } @@ -393,7 +393,7 @@ internal HttpMessage CreateGetVersionRequest(string subscriptionId, string resou /// The cancellation token to use. /// , , , or is null. /// , , , or is an empty string, and was expected to be non-empty. - public async Task> GetVersionAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) + public async Task> GetVersionAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -407,13 +407,13 @@ public async Task> GetVersionAsync(string subscriptionId, stri { case 200: { - KeyData value = default; + KeyVaultKeyData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyData.DeserializeKeyData(document.RootElement); + value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); return Response.FromValue(value, message.Response); } case 404: - return Response.FromValue((KeyData)null, message.Response); + return Response.FromValue((KeyVaultKeyData)null, message.Response); default: throw new RequestFailedException(message.Response); } @@ -428,7 +428,7 @@ public async Task> GetVersionAsync(string subscriptionId, stri /// The cancellation token to use. /// , , , or is null. /// , , , or is an empty string, and was expected to be non-empty. - public Response GetVersion(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) + public Response GetVersion(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); @@ -442,13 +442,13 @@ public Response GetVersion(string subscriptionId, string resourceGroupN { case 200: { - KeyData value = default; + KeyVaultKeyData value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyData.DeserializeKeyData(document.RootElement); + value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); return Response.FromValue(value, message.Response); } case 404: - return Response.FromValue((KeyData)null, message.Response); + return Response.FromValue((KeyVaultKeyData)null, message.Response); default: throw new RequestFailedException(message.Response); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs index 68f3e39516ad9..b034f0f009ef1 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs @@ -271,7 +271,7 @@ public virtual AsyncPageable GetAllAsync(CancellationToken can { HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); } /// @@ -301,7 +301,7 @@ public virtual Pageable GetAll(CancellationToken cancellationT { HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); } /// diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs index c322128e55e4e..db3cf2794b497 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs @@ -11,16 +11,16 @@ namespace Azure.ResourceManager.KeyVault { - public partial class VaultKeyResource : IJsonModel + public partial class VaultKeyResource : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - KeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + KeyVaultKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); - KeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + KeyVaultKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs index 7d661296147ae..a26d25d42a1aa 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs @@ -36,7 +36,7 @@ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, private readonly ClientDiagnostics _vaultKeyKeysClientDiagnostics; private readonly KeysRestOperations _vaultKeyKeysRestClient; - private readonly KeyData _data; + private readonly KeyVaultKeyData _data; /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.KeyVault/vaults/keys"; @@ -49,7 +49,7 @@ protected VaultKeyResource() /// Initializes a new instance of the class. /// The client parameters to use in these operations. /// The resource that is the target of operations. - internal VaultKeyResource(ArmClient client, KeyData data) : this(client, data.Id) + internal VaultKeyResource(ArmClient client, KeyVaultKeyData data) : this(client, data.Id) { HasData = true; _data = data; @@ -73,7 +73,7 @@ internal VaultKeyResource(ArmClient client, ResourceIdentifier id) : base(client /// Gets the data representing this Feature. /// Throws if there is no data loaded in the current instance. - public virtual KeyData Data + public virtual KeyVaultKeyData Data { get { diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs index 81e7f1853a756..b5191a7a60d06 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs @@ -168,7 +168,7 @@ public virtual AsyncPageable GetAllAsync(CancellationTo { HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyVersionKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyVersionKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); } /// @@ -198,7 +198,7 @@ public virtual Pageable GetAll(CancellationToken cancel { HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyVersionKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyVersionKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyData.DeserializeKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); } /// diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs index 2e934cedc0573..36c80d822bd6e 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs @@ -11,16 +11,16 @@ namespace Azure.ResourceManager.KeyVault { - public partial class VaultKeyVersionResource : IJsonModel + public partial class VaultKeyVersionResource : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - KeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + KeyVaultKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); - KeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + KeyVaultKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs index b9cbc8e78a2e2..ee7267013dbed 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs @@ -36,7 +36,7 @@ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, private readonly ClientDiagnostics _vaultKeyVersionKeysClientDiagnostics; private readonly KeysRestOperations _vaultKeyVersionKeysRestClient; - private readonly KeyData _data; + private readonly KeyVaultKeyData _data; /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.KeyVault/vaults/keys/versions"; @@ -49,7 +49,7 @@ protected VaultKeyVersionResource() /// Initializes a new instance of the class. /// The client parameters to use in these operations. /// The resource that is the target of operations. - internal VaultKeyVersionResource(ArmClient client, KeyData data) : this(client, data.Id) + internal VaultKeyVersionResource(ArmClient client, KeyVaultKeyData data) : this(client, data.Id) { HasData = true; _data = data; @@ -73,7 +73,7 @@ internal VaultKeyVersionResource(ArmClient client, ResourceIdentifier id) : base /// Gets the data representing this Feature. /// Throws if there is no data loaded in the current instance. - public virtual KeyData Data + public virtual KeyVaultKeyData Data { get { diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index 3ffb894ba0bd3..befcc2b790e4c 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -123,6 +123,7 @@ rename-mapping: CheckNameAvailabilityResult: KeyVaultNameAvailabilityResult Trigger: KeyRotationTrigger Action: KeyRotationAction + Key: KeyVaultKey prompted-enum-values: Default From 9bda491072b575a99bad78d8a16d72762048c385 Mon Sep 17 00:00:00 2001 From: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:39:23 +0800 Subject: [PATCH 6/8] Update Azure.ResourceManager.KeyVault.netstandard2.0.cs --- ...ResourceManager.KeyVault.netstandard2.0.cs | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs index 58e5c2c63bb59..f860cf68827bb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs @@ -74,26 +74,6 @@ protected DeletedManagedHsmResource() { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyData() { } - public Azure.ResourceManager.KeyVault.Models.KeyAttributes Attributes { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } - public System.Collections.Generic.IList KeyOps { get { throw null; } } - public int? KeySize { get { throw null; } set { } } - public System.Uri KeyUri { get { throw null; } } - public string KeyUriWithVersion { get { throw null; } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } - public Azure.Core.AzureLocation? Location { get { throw null; } } - public Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy ReleasePolicy { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.RotationPolicy RotationPolicy { get { throw null; } set { } } - public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } - Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } public partial class KeyVaultCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected KeyVaultCollection() { } @@ -159,6 +139,26 @@ public static partial class KeyVaultExtensions public static Azure.ResourceManager.KeyVault.VaultKeyResource GetVaultKeyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.VaultKeyVersionResource GetVaultKeyVersionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } } + public partial class KeyVaultKeyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public KeyVaultKeyData() { } + public Azure.ResourceManager.KeyVault.Models.KeyAttributes Attributes { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } + public System.Collections.Generic.IList KeyOps { get { throw null; } } + public int? KeySize { get { throw null; } set { } } + public System.Uri KeyUri { get { throw null; } } + public string KeyUriWithVersion { get { throw null; } } + public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } + public Azure.Core.AzureLocation? Location { get { throw null; } } + public Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy ReleasePolicy { get { throw null; } set { } } + public Azure.ResourceManager.KeyVault.Models.RotationPolicy RotationPolicy { get { throw null; } set { } } + public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } + Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class KeyVaultPrivateEndpointConnectionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected KeyVaultPrivateEndpointConnectionCollection() { } @@ -534,11 +534,11 @@ protected VaultKeyCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class VaultKeyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class VaultKeyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public static readonly Azure.Core.ResourceType ResourceType; protected VaultKeyResource() { } - public virtual Azure.ResourceManager.KeyVault.KeyData Data { get { throw null; } } + public virtual Azure.ResourceManager.KeyVault.KeyVaultKeyData Data { get { throw null; } } public virtual bool HasData { get { throw null; } } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -546,11 +546,11 @@ protected VaultKeyResource() { } public virtual Azure.Response GetVaultKeyVersion(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetVaultKeyVersionAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.KeyVault.VaultKeyVersionCollection GetVaultKeyVersions() { throw null; } - Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } @@ -569,20 +569,20 @@ protected VaultKeyVersionCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class VaultKeyVersionResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class VaultKeyVersionResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public static readonly Azure.Core.ResourceType ResourceType; protected VaultKeyVersionResource() { } - public virtual Azure.ResourceManager.KeyVault.KeyData Data { get { throw null; } } + public virtual Azure.ResourceManager.KeyVault.KeyVaultKeyData Data { get { throw null; } } public virtual bool HasData { get { throw null; } } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.KeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.ResourceManager.KeyVault.Mocking @@ -650,12 +650,12 @@ public static partial class ArmKeyVaultModelFactory public static Azure.ResourceManager.KeyVault.DeletedManagedHsmData DeletedManagedHsmData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.DeletedManagedHsmProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.DeletedManagedHsmProperties DeletedManagedHsmProperties(Azure.Core.ResourceIdentifier managedHsmId = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledPurgeOn = default(System.DateTimeOffset?), bool? purgeProtectionEnabled = default(bool?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyAttributes KeyAttributes(bool? enabled = default(bool?), long? notBefore = default(long?), long? expires = default(long?), long? created = default(long?), long? updated = default(long?), Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? recoveryLevel = default(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel?), bool? exportable = default(bool?)) { throw null; } - public static Azure.ResourceManager.KeyVault.KeyData KeyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyProperties KeyProperties(Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? created = default(long?), long? updated = default(long?), string expiryTime = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultAccessPolicyParameters KeyVaultAccessPolicyParameters(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IEnumerable accessPolicies = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultCreateOrUpdateContent KeyVaultCreateOrUpdateContent(Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.KeyVaultProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.KeyVaultData KeyVaultData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.KeyVault.Models.KeyVaultProperties properties = null) { throw null; } + public static Azure.ResourceManager.KeyVault.KeyVaultKeyData KeyVaultKeyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultNameAvailabilityContent KeyVaultNameAvailabilityContent(string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType)) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultNameAvailabilityResult KeyVaultNameAvailabilityResult(bool? nameAvailable = default(bool?), Azure.ResourceManager.KeyVault.Models.KeyVaultNameUnavailableReason? reason = default(Azure.ResourceManager.KeyVault.Models.KeyVaultNameUnavailableReason?), string message = null) { throw null; } public static Azure.ResourceManager.KeyVault.KeyVaultPrivateEndpointConnectionData KeyVaultPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), Azure.Core.ResourceIdentifier privateEndpointId = null, Azure.ResourceManager.KeyVault.Models.KeyVaultPrivateLinkServiceConnectionState connectionState = null, Azure.ResourceManager.KeyVault.Models.KeyVaultPrivateEndpointConnectionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.KeyVaultPrivateEndpointConnectionProvisioningState?), Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } From ebd7ccb42c412f48a2f95908f65c274e9525b5f2 Mon Sep 17 00:00:00 2001 From: melina5656 <140602263+melina5656@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:37:59 +0800 Subject: [PATCH 7/8] rename --- .../Samples/Sample_ManagedHSMKeyCollection.cs | 2 +- .../Samples/Sample_ManagedHSMKeyResource.cs | 2 +- .../Samples/Sample_VaultKeyCollection.cs | 2 +- .../Samples/Sample_VaultKeyResource.cs | 2 +- .../src/Generated/ArmKeyVaultModelFactory.cs | 38 +++++++++---------- .../KeyVaultKeyData.Serialization.cs | 10 ++--- .../src/Generated/KeyVaultKeyData.cs | 8 ++-- .../Models/KeyAttributes.Serialization.cs | 20 +++++----- .../src/Generated/Models/KeyAttributes.cs | 14 +++---- .../Models/KeyProperties.Serialization.cs | 4 +- .../src/Generated/Models/KeyProperties.cs | 8 ++-- .../ManagedHsmKeyAttributes.Serialization.cs | 20 +++++----- .../Models/ManagedHsmKeyAttributes.cs | 14 +++---- .../ManagedHsmKeyProperties.Serialization.cs | 10 ++--- .../Models/ManagedHsmKeyProperties.cs | 8 ++-- .../src/autorest.md | 7 ++++ 16 files changed, 88 insertions(+), 81 deletions(-) diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs index 45f00152a2635..578847661c558 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateAKey() string keyName = "sample-key-name"; ManagedHSMKeyCreateOrUpdateContent content = new ManagedHSMKeyCreateOrUpdateContent(new ManagedHsmKeyProperties() { - Kty = JsonWebKeyType.RSA, + KeyType = JsonWebKeyType.RSA, }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, content); ManagedHSMKeyResource result = lro.Value; diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs index 4be0549e3c5ef..cea8b18cecdfb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs @@ -40,7 +40,7 @@ public async Task Update_CreateAKey() // invoke the operation ManagedHSMKeyCreateOrUpdateContent content = new ManagedHSMKeyCreateOrUpdateContent(new ManagedHsmKeyProperties() { - Kty = JsonWebKeyType.RSA, + KeyType = JsonWebKeyType.RSA, }); ArmOperation lro = await managedHSMKey.UpdateAsync(WaitUntil.Completed, content); ManagedHSMKeyResource result = lro.Value; diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs index d59bb2a0e4657..70eab7ec04caa 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateAKey() string keyName = "sample-key-name"; VaultKeyCreateOrUpdateContent content = new VaultKeyCreateOrUpdateContent(new KeyProperties() { - Kty = JsonWebKeyType.RSA, + KeyType = JsonWebKeyType.RSA, }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, content); VaultKeyResource result = lro.Value; diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs index c86970da5cd3b..67f1d07216619 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs @@ -40,7 +40,7 @@ public async Task Update_CreateAKey() // invoke the operation VaultKeyCreateOrUpdateContent content = new VaultKeyCreateOrUpdateContent(new KeyProperties() { - Kty = JsonWebKeyType.RSA, + KeyType = JsonWebKeyType.RSA, }); ArmOperation lro = await vaultKey.UpdateAsync(WaitUntil.Completed, content); VaultKeyResource result = lro.Value; diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs index fc0d4795e2c57..22f1eac7fc1f5 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs @@ -30,7 +30,7 @@ public static VaultKeyCreateOrUpdateContent VaultKeyCreateOrUpdateContent(IDicti /// Initializes a new instance of . /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. + /// The type of the key. For valid values, see JsonWebKeyType. /// /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. @@ -39,13 +39,13 @@ public static VaultKeyCreateOrUpdateContent VaultKeyCreateOrUpdateContent(IDicti /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. /// Key release policy in response. It will be used for both output and input. Omitted if empty. /// A new instance for mocking. - public static KeyProperties KeyProperties(KeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null) + public static KeyProperties KeyProperties(KeyAttributes attributes = null, JsonWebKeyType? keyType = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null) { keyOps ??= new List(); return new KeyProperties( attributes, - kty, + keyType, keyOps?.ToList(), keySize, curveName, @@ -57,24 +57,24 @@ public static KeyProperties KeyProperties(KeyAttributes attributes = null, JsonW } /// Initializes a new instance of . - /// Determines whether or not the object is enabled. + /// Determines whether or not the object is enabled. /// Not before date in seconds since 1970-01-01T00:00:00Z. /// Expiry date in seconds since 1970-01-01T00:00:00Z. /// Creation time in seconds since 1970-01-01T00:00:00Z. /// Last updated time in seconds since 1970-01-01T00:00:00Z. /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. + /// Indicates if the private key can be exported. /// A new instance for mocking. - public static KeyAttributes KeyAttributes(bool? enabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? exportable = null) + public static KeyAttributes KeyAttributes(bool? isEnabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? canExported = null) { return new KeyAttributes( - enabled, + isEnabled, notBefore, expires, created, updated, recoveryLevel, - exportable, + canExported, serializedAdditionalRawData: null); } @@ -94,7 +94,7 @@ public static KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? crea /// The resourceType. /// The systemData. /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. + /// The type of the key. For valid values, see JsonWebKeyType. /// /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. @@ -105,7 +105,7 @@ public static KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? crea /// Azure location of the key vault resource. /// Tags assigned to the key vault resource. /// A new instance for mocking. - public static KeyVaultKeyData KeyVaultKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, KeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null, AzureLocation? location = null, IReadOnlyDictionary tags = null) + public static KeyVaultKeyData KeyVaultKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, KeyAttributes attributes = null, JsonWebKeyType? keyType = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null, AzureLocation? location = null, IReadOnlyDictionary tags = null) { keyOps ??= new List(); tags ??= new Dictionary(); @@ -116,7 +116,7 @@ public static KeyVaultKeyData KeyVaultKeyData(ResourceIdentifier id = null, stri resourceType, systemData, attributes, - kty, + keyType, keyOps?.ToList(), keySize, curveName, @@ -142,7 +142,7 @@ public static ManagedHSMKeyCreateOrUpdateContent ManagedHSMKeyCreateOrUpdateCont /// Initializes a new instance of . /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. + /// The type of the key. For valid values, see JsonWebKeyType. /// /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. @@ -151,13 +151,13 @@ public static ManagedHSMKeyCreateOrUpdateContent ManagedHSMKeyCreateOrUpdateCont /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. /// Key release policy in response. It will be used for both output and input. Omitted if empty. /// A new instance for mocking. - public static ManagedHsmKeyProperties ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes = null, JsonWebKeyType? kty = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, ManagedHsmRotationPolicy rotationPolicy = null, ManagedHsmKeyReleasePolicy releasePolicy = null) + public static ManagedHsmKeyProperties ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes = null, JsonWebKeyType? keyType = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, ManagedHsmRotationPolicy rotationPolicy = null, ManagedHsmKeyReleasePolicy releasePolicy = null) { keyOps ??= new List(); return new ManagedHsmKeyProperties( attributes, - kty, + keyType, keyOps?.ToList(), keySize, curveName, @@ -169,24 +169,24 @@ public static ManagedHsmKeyProperties ManagedHsmKeyProperties(ManagedHsmKeyAttri } /// Initializes a new instance of . - /// Determines whether or not the object is enabled. + /// Determines whether or not the object is enabled. /// Not before date in seconds since 1970-01-01T00:00:00Z. /// Expiry date in seconds since 1970-01-01T00:00:00Z. /// Creation time in seconds since 1970-01-01T00:00:00Z. /// Last updated time in seconds since 1970-01-01T00:00:00Z. /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. + /// Indicates if the private key can be exported. /// A new instance for mocking. - public static ManagedHsmKeyAttributes ManagedHsmKeyAttributes(bool? enabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? exportable = null) + public static ManagedHsmKeyAttributes ManagedHsmKeyAttributes(bool? isEnabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? canExported = null) { return new ManagedHsmKeyAttributes( - enabled, + isEnabled, notBefore, expires, created, updated, recoveryLevel, - exportable, + canExported, serializedAdditionalRawData: null); } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs index 375cfa7e5a4df..6c473b4cd4285 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs @@ -73,10 +73,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO writer.WritePropertyName("attributes"u8); writer.WriteObjectValue(Attributes, options); } - if (Optional.IsDefined(Kty)) + if (Optional.IsDefined(KeyType)) { writer.WritePropertyName("kty"u8); - writer.WriteStringValue(Kty.Value.ToString()); + writer.WriteStringValue(KeyType.Value.ToString()); } if (Optional.IsCollectionDefined(KeyOps)) { @@ -475,7 +475,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kty), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyType), out propertyOverride); if (hasPropertyOverride) { builder.Append(" kty: "); @@ -483,10 +483,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(Kty)) + if (Optional.IsDefined(KeyType)) { builder.Append(" kty: "); - builder.AppendLine($"'{Kty.Value.ToString()}'"); + builder.AppendLine($"'{KeyType.Value.ToString()}'"); } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs index b60a7a4e4fd27..c2641fe796fd9 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs @@ -64,7 +64,7 @@ public KeyVaultKeyData() /// The resourceType. /// The systemData. /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. + /// The type of the key. For valid values, see JsonWebKeyType. /// /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. @@ -75,10 +75,10 @@ public KeyVaultKeyData() /// Azure location of the key vault resource. /// Tags assigned to the key vault resource. /// Keeps track of any properties unknown to the library. - internal KeyVaultKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, KeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, AzureLocation? location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal KeyVaultKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, KeyAttributes attributes, JsonWebKeyType? keyType, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, AzureLocation? location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Attributes = attributes; - Kty = kty; + KeyType = keyType; KeyOps = keyOps; KeySize = keySize; CurveName = curveName; @@ -96,7 +96,7 @@ internal KeyVaultKeyData(ResourceIdentifier id, string name, ResourceType resour public KeyAttributes Attributes { get; set; } /// The type of the key. For valid values, see JsonWebKeyType. [WirePath("properties.kty")] - public JsonWebKeyType? Kty { get; set; } + public JsonWebKeyType? KeyType { get; set; } /// Gets the key ops. [WirePath("properties.keyOps")] public IList KeyOps { get; } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs index a264a8812e927..b37eb5d776cfb 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs @@ -27,10 +27,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt } writer.WriteStartObject(); - if (Optional.IsDefined(Enabled)) + if (Optional.IsDefined(IsEnabled)) { writer.WritePropertyName("enabled"u8); - writer.WriteBooleanValue(Enabled.Value); + writer.WriteBooleanValue(IsEnabled.Value); } if (Optional.IsDefined(NotBefore)) { @@ -57,10 +57,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt writer.WritePropertyName("recoveryLevel"u8); writer.WriteStringValue(RecoveryLevel.Value.ToString()); } - if (Optional.IsDefined(Exportable)) + if (Optional.IsDefined(CanExported)) { writer.WritePropertyName("exportable"u8); - writer.WriteBooleanValue(Exportable.Value); + writer.WriteBooleanValue(CanExported.Value); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -202,7 +202,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (hasPropertyOverride) { builder.Append(" enabled: "); @@ -210,10 +210,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(Enabled)) + if (Optional.IsDefined(IsEnabled)) { builder.Append(" enabled: "); - var boolValue = Enabled.Value == true ? "true" : "false"; + var boolValue = IsEnabled.Value == true ? "true" : "false"; builder.AppendLine($"{boolValue}"); } } @@ -293,7 +293,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Exportable), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanExported), out propertyOverride); if (hasPropertyOverride) { builder.Append(" exportable: "); @@ -301,10 +301,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(Exportable)) + if (Optional.IsDefined(CanExported)) { builder.Append(" exportable: "); - var boolValue = Exportable.Value == true ? "true" : "false"; + var boolValue = CanExported.Value == true ? "true" : "false"; builder.AppendLine($"{boolValue}"); } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs index c70bfbafd90f4..2a5e1cc17f496 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs @@ -51,29 +51,29 @@ public KeyAttributes() } /// Initializes a new instance of . - /// Determines whether or not the object is enabled. + /// Determines whether or not the object is enabled. /// Not before date in seconds since 1970-01-01T00:00:00Z. /// Expiry date in seconds since 1970-01-01T00:00:00Z. /// Creation time in seconds since 1970-01-01T00:00:00Z. /// Last updated time in seconds since 1970-01-01T00:00:00Z. /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. + /// Indicates if the private key can be exported. /// Keeps track of any properties unknown to the library. - internal KeyAttributes(bool? enabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? exportable, IDictionary serializedAdditionalRawData) + internal KeyAttributes(bool? isEnabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? canExported, IDictionary serializedAdditionalRawData) { - Enabled = enabled; + IsEnabled = isEnabled; NotBefore = notBefore; Expires = expires; Created = created; Updated = updated; RecoveryLevel = recoveryLevel; - Exportable = exportable; + CanExported = canExported; _serializedAdditionalRawData = serializedAdditionalRawData; } /// Determines whether or not the object is enabled. [WirePath("enabled")] - public bool? Enabled { get; set; } + public bool? IsEnabled { get; set; } /// Not before date in seconds since 1970-01-01T00:00:00Z. [WirePath("nbf")] public long? NotBefore { get; set; } @@ -91,6 +91,6 @@ internal KeyAttributes(bool? enabled, long? notBefore, long? expires, long? crea public DeletionRecoveryLevel? RecoveryLevel { get; } /// Indicates if the private key can be exported. [WirePath("exportable")] - public bool? Exportable { get; set; } + public bool? CanExported { get; set; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs index 3760ff44ea8d4..fe126516b4684 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs @@ -31,10 +31,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt writer.WritePropertyName("attributes"u8); writer.WriteObjectValue(Attributes, options); } - if (Optional.IsDefined(Kty)) + if (Optional.IsDefined(KeyType)) { writer.WritePropertyName("kty"u8); - writer.WriteStringValue(Kty.Value.ToString()); + writer.WriteStringValue(KeyType.Value.ToString()); } if (Optional.IsCollectionDefined(KeyOps)) { diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs index 13e0080367eea..7e765c74da77d 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs @@ -53,7 +53,7 @@ public KeyProperties() /// Initializes a new instance of . /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. + /// The type of the key. For valid values, see JsonWebKeyType. /// /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. @@ -62,10 +62,10 @@ public KeyProperties() /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. /// Key release policy in response. It will be used for both output and input. Omitted if empty. /// Keeps track of any properties unknown to the library. - internal KeyProperties(KeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) + internal KeyProperties(KeyAttributes attributes, JsonWebKeyType? keyType, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) { Attributes = attributes; - Kty = kty; + KeyType = keyType; KeyOps = keyOps; KeySize = keySize; CurveName = curveName; @@ -81,7 +81,7 @@ internal KeyProperties(KeyAttributes attributes, JsonWebKeyType? kty, IList The type of the key. For valid values, see JsonWebKeyType. [WirePath("kty")] - public JsonWebKeyType? Kty { get; set; } + public JsonWebKeyType? KeyType { get; set; } /// Gets the key ops. [WirePath("keyOps")] public IList KeyOps { get; } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs index 635e7e4257b79..05122d953c8a2 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs @@ -27,10 +27,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade } writer.WriteStartObject(); - if (Optional.IsDefined(Enabled)) + if (Optional.IsDefined(IsEnabled)) { writer.WritePropertyName("enabled"u8); - writer.WriteBooleanValue(Enabled.Value); + writer.WriteBooleanValue(IsEnabled.Value); } if (Optional.IsDefined(NotBefore)) { @@ -57,10 +57,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade writer.WritePropertyName("recoveryLevel"u8); writer.WriteStringValue(RecoveryLevel.Value.ToString()); } - if (Optional.IsDefined(Exportable)) + if (Optional.IsDefined(CanExported)) { writer.WritePropertyName("exportable"u8); - writer.WriteBooleanValue(Exportable.Value); + writer.WriteBooleanValue(CanExported.Value); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -202,7 +202,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); if (hasPropertyOverride) { builder.Append(" enabled: "); @@ -210,10 +210,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(Enabled)) + if (Optional.IsDefined(IsEnabled)) { builder.Append(" enabled: "); - var boolValue = Enabled.Value == true ? "true" : "false"; + var boolValue = IsEnabled.Value == true ? "true" : "false"; builder.AppendLine($"{boolValue}"); } } @@ -293,7 +293,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Exportable), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanExported), out propertyOverride); if (hasPropertyOverride) { builder.Append(" exportable: "); @@ -301,10 +301,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(Exportable)) + if (Optional.IsDefined(CanExported)) { builder.Append(" exportable: "); - var boolValue = Exportable.Value == true ? "true" : "false"; + var boolValue = CanExported.Value == true ? "true" : "false"; builder.AppendLine($"{boolValue}"); } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs index 7d7294121f75a..8f52a3fcf7ff4 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs @@ -51,29 +51,29 @@ public ManagedHsmKeyAttributes() } /// Initializes a new instance of . - /// Determines whether or not the object is enabled. + /// Determines whether or not the object is enabled. /// Not before date in seconds since 1970-01-01T00:00:00Z. /// Expiry date in seconds since 1970-01-01T00:00:00Z. /// Creation time in seconds since 1970-01-01T00:00:00Z. /// Last updated time in seconds since 1970-01-01T00:00:00Z. /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. + /// Indicates if the private key can be exported. /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyAttributes(bool? enabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? exportable, IDictionary serializedAdditionalRawData) + internal ManagedHsmKeyAttributes(bool? isEnabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? canExported, IDictionary serializedAdditionalRawData) { - Enabled = enabled; + IsEnabled = isEnabled; NotBefore = notBefore; Expires = expires; Created = created; Updated = updated; RecoveryLevel = recoveryLevel; - Exportable = exportable; + CanExported = canExported; _serializedAdditionalRawData = serializedAdditionalRawData; } /// Determines whether or not the object is enabled. [WirePath("enabled")] - public bool? Enabled { get; set; } + public bool? IsEnabled { get; set; } /// Not before date in seconds since 1970-01-01T00:00:00Z. [WirePath("nbf")] public long? NotBefore { get; set; } @@ -91,6 +91,6 @@ internal ManagedHsmKeyAttributes(bool? enabled, long? notBefore, long? expires, public DeletionRecoveryLevel? RecoveryLevel { get; } /// Indicates if the private key can be exported. [WirePath("exportable")] - public bool? Exportable { get; set; } + public bool? CanExported { get; set; } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs index 4b989666dce7d..fa3a731f2ad51 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs @@ -33,10 +33,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade writer.WritePropertyName("attributes"u8); writer.WriteObjectValue(Attributes, options); } - if (Optional.IsDefined(Kty)) + if (Optional.IsDefined(KeyType)) { writer.WritePropertyName("kty"u8); - writer.WriteStringValue(Kty.Value.ToString()); + writer.WriteStringValue(KeyType.Value.ToString()); } if (Optional.IsCollectionDefined(KeyOps)) { @@ -256,7 +256,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kty), out propertyOverride); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyType), out propertyOverride); if (hasPropertyOverride) { builder.Append(" kty: "); @@ -264,10 +264,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - if (Optional.IsDefined(Kty)) + if (Optional.IsDefined(KeyType)) { builder.Append(" kty: "); - builder.AppendLine($"'{Kty.Value.ToString()}'"); + builder.AppendLine($"'{KeyType.Value.ToString()}'"); } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs index 9a5f3b83e8655..c119708a96f81 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs @@ -53,7 +53,7 @@ public ManagedHsmKeyProperties() /// Initializes a new instance of . /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. + /// The type of the key. For valid values, see JsonWebKeyType. /// /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. @@ -62,10 +62,10 @@ public ManagedHsmKeyProperties() /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. /// Key release policy in response. It will be used for both output and input. Omitted if empty. /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes, JsonWebKeyType? kty, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, ManagedHsmRotationPolicy rotationPolicy, ManagedHsmKeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) + internal ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes, JsonWebKeyType? keyType, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, ManagedHsmRotationPolicy rotationPolicy, ManagedHsmKeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) { Attributes = attributes; - Kty = kty; + KeyType = keyType; KeyOps = keyOps; KeySize = keySize; CurveName = curveName; @@ -81,7 +81,7 @@ internal ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes, JsonWebKeyT public ManagedHsmKeyAttributes Attributes { get; set; } /// The type of the key. For valid values, see JsonWebKeyType. [WirePath("kty")] - public JsonWebKeyType? Kty { get; set; } + public JsonWebKeyType? KeyType { get; set; } /// Gets the key ops. [WirePath("keyOps")] public IList KeyOps { get; } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index befcc2b790e4c..5b2a04c08a775 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -124,6 +124,13 @@ rename-mapping: Trigger: KeyRotationTrigger Action: KeyRotationAction Key: KeyVaultKey + Key.properties.kty: keyType + KeyAttributes.enabled: isEnabled + KeyAttributes.exportable: canExported + KeyProperties.kty: keyType + ManagedHsmKeyAttributes.enabled: isEnabled + ManagedHsmKeyAttributes.exportable: canExported + ManagedHsmKeyProperties.kty: keyType prompted-enum-values: Default From ea4a6bcc61a29e039c73549f698e9ecb88dac9e0 Mon Sep 17 00:00:00 2001 From: Arthur Ma Date: Fri, 5 Jul 2024 15:23:38 +0800 Subject: [PATCH 8/8] update --- .../CHANGELOG.md | 22 +- ...ResourceManager.KeyVault.netstandard2.0.cs | 486 ------------ .../Samples/Sample_ManagedHSMKeyCollection.cs | 204 ----- .../Samples/Sample_ManagedHSMKeyResource.cs | 87 --- .../Sample_ManagedHSMKeyVersionCollection.cs | 167 ---- .../Sample_ManagedHSMKeyVersionResource.cs | 50 -- .../Samples/Sample_VaultKeyCollection.cs | 204 ----- .../Samples/Sample_VaultKeyResource.cs | 87 --- .../Sample_VaultKeyVersionCollection.cs | 167 ---- .../Samples/Sample_VaultKeyVersionResource.cs | 50 -- .../src/Azure.ResourceManager.KeyVault.csproj | 2 +- .../src/Generated/ArmKeyVaultModelFactory.cs | 205 ----- .../Extensions/KeyVaultExtensions.cs | 76 -- .../Extensions/MockableKeyVaultArmClient.cs | 48 -- .../KeyVaultKeyData.Serialization.cs | 652 ---------------- .../src/Generated/KeyVaultKeyData.cs | 128 --- .../src/Generated/KeyVaultResource.cs | 69 -- .../src/Generated/ManagedHSMKeyCollection.cs | 498 ------------ .../ManagedHSMKeyResource.Serialization.cs | 26 - .../src/Generated/ManagedHSMKeyResource.cs | 696 ----------------- .../ManagedHSMKeyVersionCollection.cs | 395 ---------- ...agedHSMKeyVersionResource.Serialization.cs | 26 - .../Generated/ManagedHSMKeyVersionResource.cs | 172 ----- .../ManagedHsmKeyData.Serialization.cs | 326 -------- .../src/Generated/ManagedHsmKeyData.cs | 92 --- .../src/Generated/ManagedHsmResource.cs | 69 -- .../Generated/Models/DeletionRecoveryLevel.cs | 57 -- .../Generated/Models/JsonWebKeyCurveName.cs | 57 -- .../Generated/Models/JsonWebKeyOperation.cs | 69 -- .../src/Generated/Models/JsonWebKeyType.cs | 57 -- .../Models/KeyAttributes.Serialization.cs | 349 --------- .../src/Generated/Models/KeyAttributes.cs | 96 --- .../Models/KeyListResult.Serialization.cs | 212 ----- .../src/Generated/Models/KeyListResult.cs | 70 -- .../Models/KeyProperties.Serialization.cs | 262 ------- .../src/Generated/Models/KeyProperties.cs | 107 --- .../Models/KeyReleasePolicy.Serialization.cs | 193 ----- .../src/Generated/Models/KeyReleasePolicy.cs | 71 -- .../Models/KeyRotationAction.Serialization.cs | 159 ---- .../src/Generated/Models/KeyRotationAction.cs | 66 -- ...yRotationPolicyActionType.Serialization.cs | 28 - .../Models/KeyRotationPolicyActionType.cs | 18 - ...yRotationPolicyAttributes.Serialization.cs | 223 ------ .../Models/KeyRotationPolicyAttributes.cs | 76 -- .../KeyRotationTrigger.Serialization.cs | 197 ----- .../Generated/Models/KeyRotationTrigger.cs | 71 -- .../Models/LifetimeAction.Serialization.cs | 192 ----- .../src/Generated/Models/LifetimeAction.cs | 82 -- ...MKeyCreateOrUpdateContent.Serialization.cs | 145 ---- .../ManagedHSMKeyCreateOrUpdateContent.cs | 82 -- .../Models/ManagedHsmAction.Serialization.cs | 159 ---- .../src/Generated/Models/ManagedHsmAction.cs | 66 -- .../ManagedHsmKeyAttributes.Serialization.cs | 349 --------- .../Models/ManagedHsmKeyAttributes.cs | 96 --- .../ManagedHsmKeyListResult.Serialization.cs | 212 ----- .../Models/ManagedHsmKeyListResult.cs | 70 -- .../ManagedHsmKeyProperties.Serialization.cs | 432 ----------- .../Models/ManagedHsmKeyProperties.cs | 107 --- ...anagedHsmKeyReleasePolicy.Serialization.cs | 193 ----- .../Models/ManagedHsmKeyReleasePolicy.cs | 71 -- ...yRotationPolicyAttributes.Serialization.cs | 223 ------ .../ManagedHsmKeyRotationPolicyAttributes.cs | 76 -- .../ManagedHsmLifetimeAction.Serialization.cs | 192 ----- .../Models/ManagedHsmLifetimeAction.cs | 82 -- .../ManagedHsmRotationPolicy.Serialization.cs | 208 ----- .../Models/ManagedHsmRotationPolicy.cs | 72 -- .../Models/ManagedHsmTrigger.Serialization.cs | 197 ----- .../src/Generated/Models/ManagedHsmTrigger.cs | 71 -- .../Models/RotationPolicy.Serialization.cs | 208 ----- .../src/Generated/Models/RotationPolicy.cs | 72 -- ...tKeyCreateOrUpdateContent.Serialization.cs | 145 ---- .../Models/VaultKeyCreateOrUpdateContent.cs | 82 -- .../RestOperations/KeysRestOperations.cs | 731 ------------------ .../ManagedHsmKeysRestOperations.cs | 731 ------------------ .../src/Generated/VaultKeyCollection.cs | 498 ------------ .../VaultKeyResource.Serialization.cs | 26 - .../src/Generated/VaultKeyResource.cs | 337 -------- .../Generated/VaultKeyVersionCollection.cs | 395 ---------- .../VaultKeyVersionResource.Serialization.cs | 26 - .../src/Generated/VaultKeyVersionResource.cs | 172 ----- .../src/autorest.md | 33 +- 81 files changed, 27 insertions(+), 14248 deletions(-) delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs delete mode 100644 sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/CHANGELOG.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/CHANGELOG.md index 3f84c3d2b6d9e..12c5cc84fbf3f 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/CHANGELOG.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/CHANGELOG.md @@ -1,15 +1,15 @@ # Release History -## 1.3.0-beta.1 (Unreleased) +## 1.3.0 (2024-07-05) ### Features Added -### Breaking Changes - -### Bugs Fixed +- Upgraded api-version tag from 'package-2023-02' to 'package-2023-07'. Tag detail available at https://github.com/Azure/azure-rest-api-specs/blob/d1296700aa6cd650970e9891dd58eef5698327fd/specification/keyvault/resource-manager/readme.md ### Other Changes +- Upgraded Azure.Core from 1.39.0 to 1.40.0 + ## 1.2.3 (2024-05-07) ### Bugs Fixed @@ -20,20 +20,20 @@ ### Features Added -- Add `ArmOperation.Rehydrate` and `ArmOperation.Rehydrate` static methods to rehydrate a long-running operation. +- Added `ArmOperation.Rehydrate` and `ArmOperation.Rehydrate` static methods to rehydrate a long-running operation. ## 1.2.1 (2024-03-23) ### Features Added -- Enable the new model serialization by using the System.ClientModel, refer this [document](https://aka.ms/azsdk/net/mrw) for more details. +- Enabled the new model serialization by using the System.ClientModel, refer this [document](https://aka.ms/azsdk/net/mrw) for more details. - Added experimental Bicep serialization. ## 1.2.0 (2023-11-21) ### Features Added -- Enable mocking for extension methods, refer this [document](https://aka.ms/azsdk/net/mocking) for more details. +- Enabled mocking for extension methods, refer this [document](https://aka.ms/azsdk/net/mocking) for more details. ### Other Changes @@ -43,7 +43,7 @@ ### Features Added -- Enable the model factory feature for model mocking, more information can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-mocking-factory-builder). +- Enabled the model factory feature for model mocking, more information can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-mocking-factory-builder). ### Other Changes @@ -54,8 +54,8 @@ ### Features Added -- Add `Secret` operations -- Add some new properties for `ManagedHsmProperties` +- Added `Secret` operations +- Added some new properties for `ManagedHsmProperties` ### Other Changes @@ -264,4 +264,4 @@ After upgrade: ```C# Snippet:Changelog_CreateModel KeyVaultProperties properties = new KeyVaultProperties(Guid.NewGuid(), new KeyVaultSku(KeyVaultSkuFamily.A, KeyVaultSkuName.Standard)); KeyVaultCreateOrUpdateContent parameters = new KeyVaultCreateOrUpdateContent(AzureLocation.WestUS2, properties); -``` +``` \ No newline at end of file diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs index f860cf68827bb..63dbfd6509658 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/api/Azure.ResourceManager.KeyVault.netstandard2.0.cs @@ -129,35 +129,11 @@ public static partial class KeyVaultExtensions public static Azure.ResourceManager.KeyVault.KeyVaultSecretResource GetKeyVaultSecretResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Response GetManagedHsm(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> GetManagedHsmAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public static Azure.ResourceManager.KeyVault.ManagedHSMKeyResource GetManagedHSMKeyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } - public static Azure.ResourceManager.KeyVault.ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionResource GetManagedHsmPrivateEndpointConnectionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmResource GetManagedHsmResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmCollection GetManagedHsms(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetManagedHsms(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetManagedHsmsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public static Azure.ResourceManager.KeyVault.VaultKeyResource GetVaultKeyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } - public static Azure.ResourceManager.KeyVault.VaultKeyVersionResource GetVaultKeyVersionResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } - } - public partial class KeyVaultKeyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyVaultKeyData() { } - public Azure.ResourceManager.KeyVault.Models.KeyAttributes Attributes { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } - public System.Collections.Generic.IList KeyOps { get { throw null; } } - public int? KeySize { get { throw null; } set { } } - public System.Uri KeyUri { get { throw null; } } - public string KeyUriWithVersion { get { throw null; } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } - public Azure.Core.AzureLocation? Location { get { throw null; } } - public Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy ReleasePolicy { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.RotationPolicy RotationPolicy { get { throw null; } set { } } - public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } - Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class KeyVaultPrivateEndpointConnectionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { @@ -249,9 +225,6 @@ protected KeyVaultResource() { } public virtual Azure.ResourceManager.KeyVault.KeyVaultSecretCollection GetKeyVaultSecrets() { throw null; } public virtual Azure.Pageable GetPrivateLinkResources(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetPrivateLinkResourcesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetVaultKey(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetVaultKeyAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.ResourceManager.KeyVault.VaultKeyCollection GetVaultKeys() { throw null; } public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -341,90 +314,6 @@ public ManagedHsmData(Azure.Core.AzureLocation location) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ManagedHSMKeyCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - protected ManagedHSMKeyCollection() { } - public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Exists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> ExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Get(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.NullableResponse GetIfExists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } - public partial class ManagedHsmKeyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - internal ManagedHsmKeyData() { } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties Properties { get { throw null; } } - public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } - Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class ManagedHSMKeyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public static readonly Azure.Core.ResourceType ResourceType; - protected ManagedHSMKeyResource() { } - public virtual Azure.ResourceManager.KeyVault.ManagedHsmKeyData Data { get { throw null; } } - public virtual bool HasData { get { throw null; } } - public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName) { throw null; } - public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetManagedHSMKeyVersion(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetManagedHSMKeyVersionAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyVersionCollection GetManagedHSMKeyVersions() { throw null; } - public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - } - public partial class ManagedHSMKeyVersionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - protected ManagedHSMKeyVersionCollection() { } - public virtual Azure.Response Exists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> ExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Get(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.NullableResponse GetIfExists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } - public partial class ManagedHSMKeyVersionResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public static readonly Azure.Core.ResourceType ResourceType; - protected ManagedHSMKeyVersionResource() { } - public virtual Azure.ResourceManager.KeyVault.ManagedHsmKeyData Data { get { throw null; } } - public virtual bool HasData { get { throw null; } } - public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) { throw null; } - public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.ManagedHsmKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } public partial class ManagedHsmPrivateEndpointConnectionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected ManagedHsmPrivateEndpointConnectionCollection() { } @@ -495,9 +384,6 @@ protected ManagedHsmResource() { } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetManagedHSMKey(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetManagedHSMKeyAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyCollection GetManagedHSMKeys() { throw null; } public virtual Azure.Response GetManagedHsmPrivateEndpointConnection(string privateEndpointConnectionName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetManagedHsmPrivateEndpointConnectionAsync(string privateEndpointConnectionName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionCollection GetManagedHsmPrivateEndpointConnections() { throw null; } @@ -517,73 +403,6 @@ protected ManagedHsmResource() { } public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.ManagedHsmData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.ManagedHsmData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class VaultKeyCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - protected VaultKeyCollection() { } - public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string keyName, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Exists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> ExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Get(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.NullableResponse GetIfExists(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } - public partial class VaultKeyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public static readonly Azure.Core.ResourceType ResourceType; - protected VaultKeyResource() { } - public virtual Azure.ResourceManager.KeyVault.KeyVaultKeyData Data { get { throw null; } } - public virtual bool HasData { get { throw null; } } - public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName) { throw null; } - public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetVaultKeyVersion(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetVaultKeyVersionAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.ResourceManager.KeyVault.VaultKeyVersionCollection GetVaultKeyVersions() { throw null; } - Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - } - public partial class VaultKeyVersionCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - protected VaultKeyVersionCollection() { } - public virtual Azure.Response Exists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> ExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Get(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.NullableResponse GetIfExists(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string keyVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } - public partial class VaultKeyVersionResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public static readonly Azure.Core.ResourceType ResourceType; - protected VaultKeyVersionResource() { } - public virtual Azure.ResourceManager.KeyVault.KeyVaultKeyData Data { get { throw null; } } - public virtual bool HasData { get { throw null; } } - public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) { throw null; } - public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.KeyVaultKeyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } } namespace Azure.ResourceManager.KeyVault.Mocking { @@ -595,12 +414,8 @@ protected MockableKeyVaultArmClient() { } public virtual Azure.ResourceManager.KeyVault.KeyVaultPrivateEndpointConnectionResource GetKeyVaultPrivateEndpointConnectionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.KeyVaultResource GetKeyVaultResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.KeyVaultSecretResource GetKeyVaultSecretResource(Azure.Core.ResourceIdentifier id) { throw null; } - public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyResource GetManagedHSMKeyResource(Azure.Core.ResourceIdentifier id) { throw null; } - public virtual Azure.ResourceManager.KeyVault.ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionResource GetManagedHsmPrivateEndpointConnectionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.KeyVault.ManagedHsmResource GetManagedHsmResource(Azure.Core.ResourceIdentifier id) { throw null; } - public virtual Azure.ResourceManager.KeyVault.VaultKeyResource GetVaultKeyResource(Azure.Core.ResourceIdentifier id) { throw null; } - public virtual Azure.ResourceManager.KeyVault.VaultKeyVersionResource GetVaultKeyVersionResource(Azure.Core.ResourceIdentifier id) { throw null; } } public partial class MockableKeyVaultResourceGroupResource : Azure.ResourceManager.ArmResource { @@ -649,13 +464,9 @@ public static partial class ArmKeyVaultModelFactory public static Azure.ResourceManager.KeyVault.Models.DeletedKeyVaultProperties DeletedKeyVaultProperties(Azure.Core.ResourceIdentifier vaultId = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledPurgeOn = default(System.DateTimeOffset?), System.Collections.Generic.IReadOnlyDictionary tags = null, bool? purgeProtectionEnabled = default(bool?)) { throw null; } public static Azure.ResourceManager.KeyVault.DeletedManagedHsmData DeletedManagedHsmData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.DeletedManagedHsmProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.DeletedManagedHsmProperties DeletedManagedHsmProperties(Azure.Core.ResourceIdentifier managedHsmId = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? scheduledPurgeOn = default(System.DateTimeOffset?), bool? purgeProtectionEnabled = default(bool?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.KeyAttributes KeyAttributes(bool? enabled = default(bool?), long? notBefore = default(long?), long? expires = default(long?), long? created = default(long?), long? updated = default(long?), Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? recoveryLevel = default(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel?), bool? exportable = default(bool?)) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.KeyProperties KeyProperties(Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? created = default(long?), long? updated = default(long?), string expiryTime = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultAccessPolicyParameters KeyVaultAccessPolicyParameters(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IEnumerable accessPolicies = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultCreateOrUpdateContent KeyVaultCreateOrUpdateContent(Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.KeyVaultProperties properties = null) { throw null; } public static Azure.ResourceManager.KeyVault.KeyVaultData KeyVaultData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.KeyVault.Models.KeyVaultProperties properties = null) { throw null; } - public static Azure.ResourceManager.KeyVault.KeyVaultKeyData KeyVaultKeyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.KeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.RotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy releasePolicy = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultNameAvailabilityContent KeyVaultNameAvailabilityContent(string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType)) { throw null; } public static Azure.ResourceManager.KeyVault.Models.KeyVaultNameAvailabilityResult KeyVaultNameAvailabilityResult(bool? nameAvailable = default(bool?), Azure.ResourceManager.KeyVault.Models.KeyVaultNameUnavailableReason? reason = default(Azure.ResourceManager.KeyVault.Models.KeyVaultNameUnavailableReason?), string message = null) { throw null; } public static Azure.ResourceManager.KeyVault.KeyVaultPrivateEndpointConnectionData KeyVaultPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), Azure.Core.ResourceIdentifier privateEndpointId = null, Azure.ResourceManager.KeyVault.Models.KeyVaultPrivateLinkServiceConnectionState connectionState = null, Azure.ResourceManager.KeyVault.Models.KeyVaultPrivateEndpointConnectionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.KeyVaultPrivateEndpointConnectionProvisioningState?), Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } @@ -668,11 +479,6 @@ public static partial class ArmKeyVaultModelFactory public static Azure.ResourceManager.KeyVault.ManagedHsmData ManagedHsmData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties properties, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku) { throw null; } public static Azure.ResourceManager.KeyVault.ManagedHsmData ManagedHsmData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.KeyVault.Models.ManagedHsmProperties properties = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku = null, Azure.ResourceManager.Models.ManagedServiceIdentity identity = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHsmGeoReplicatedRegion ManagedHsmGeoReplicatedRegion(string name = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmGeoReplicatedRegionProvisioningState? provisioningState = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmGeoReplicatedRegionProvisioningState?), bool? isPrimary = default(bool?)) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes ManagedHsmKeyAttributes(bool? enabled = default(bool?), long? notBefore = default(long?), long? expires = default(long?), long? created = default(long?), long? updated = default(long?), Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? recoveryLevel = default(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel?), bool? exportable = default(bool?)) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent ManagedHSMKeyCreateOrUpdateContent(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties properties = null) { throw null; } - public static Azure.ResourceManager.KeyVault.ManagedHsmKeyData ManagedHsmKeyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties properties = null, System.Collections.Generic.IReadOnlyDictionary tags = null) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties ManagedHsmKeyProperties(Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes attributes = null, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? kty = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType?), System.Collections.Generic.IEnumerable keyOps = null, int? keySize = default(int?), Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? curveName = default(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName?), System.Uri keyUri = null, string keyUriWithVersion = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy rotationPolicy = null, Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy releasePolicy = null) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes ManagedHsmKeyRotationPolicyAttributes(long? created = default(long?), long? updated = default(long?), string expiryTime = null) { throw null; } public static Azure.ResourceManager.KeyVault.Models.ManagedHsmNameAvailabilityResult ManagedHsmNameAvailabilityResult(bool? isNameAvailable = default(bool?), Azure.ResourceManager.KeyVault.Models.ManagedHsmNameUnavailableReason? reason = default(Azure.ResourceManager.KeyVault.Models.ManagedHsmNameUnavailableReason?), string message = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.ResourceManager.KeyVault.ManagedHsmPrivateEndpointConnectionData ManagedHsmPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ETag? etag, Azure.Core.ResourceIdentifier privateEndpointId, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateLinkServiceConnectionState privateLinkServiceConnectionState, Azure.ResourceManager.KeyVault.Models.ManagedHsmPrivateEndpointConnectionProvisioningState? provisioningState, Azure.ResourceManager.KeyVault.Models.ManagedHsmSku sku) { throw null; } @@ -686,7 +492,6 @@ public static partial class ArmKeyVaultModelFactory public static Azure.ResourceManager.KeyVault.Models.SecretAttributes SecretAttributes(bool? enabled = default(bool?), System.DateTimeOffset? notBefore = default(System.DateTimeOffset?), System.DateTimeOffset? expires = default(System.DateTimeOffset?), System.DateTimeOffset? created = default(System.DateTimeOffset?), System.DateTimeOffset? updated = default(System.DateTimeOffset?)) { throw null; } public static Azure.ResourceManager.KeyVault.Models.SecretBaseAttributes SecretBaseAttributes(bool? enabled = default(bool?), System.DateTimeOffset? notBefore = default(System.DateTimeOffset?), System.DateTimeOffset? expires = default(System.DateTimeOffset?), System.DateTimeOffset? created = default(System.DateTimeOffset?), System.DateTimeOffset? updated = default(System.DateTimeOffset?)) { throw null; } public static Azure.ResourceManager.KeyVault.Models.SecretProperties SecretProperties(string value = null, string contentType = null, Azure.ResourceManager.KeyVault.Models.SecretAttributes attributes = null, System.Uri secretUri = null, string secretUriWithVersion = null) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent VaultKeyCreateOrUpdateContent(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.KeyVault.Models.KeyProperties properties = null) { throw null; } } public partial class DeletedKeyVaultProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -725,26 +530,6 @@ internal DeletedManagedHsmProperties() { } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct DeletionRecoveryLevel : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public DeletionRecoveryLevel(string value) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel Purgeable { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel Recoverable { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel RecoverableProtectedSubscription { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel RecoverablePurgeable { get { throw null; } } - public bool Equals(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel left, Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel right) { throw null; } - public static implicit operator Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel left, Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel right) { throw null; } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct IdentityAccessCertificatePermission : System.IEquatable { private readonly object _dummy; @@ -883,143 +668,6 @@ public IdentityAccessPermissions() { } public static bool operator !=(Azure.ResourceManager.KeyVault.Models.IdentityAccessStoragePermission left, Azure.ResourceManager.KeyVault.Models.IdentityAccessStoragePermission right) { throw null; } public override string ToString() { throw null; } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct JsonWebKeyCurveName : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public JsonWebKeyCurveName(string value) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P256 { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P256K { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P384 { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName P521 { get { throw null; } } - public bool Equals(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName right) { throw null; } - public static implicit operator Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName right) { throw null; } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct JsonWebKeyOperation : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public JsonWebKeyOperation(string value) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Decrypt { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Encrypt { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Import { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Release { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Sign { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation UnwrapKey { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation Verify { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation WrapKey { get { throw null; } } - public bool Equals(Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation right) { throw null; } - public static implicit operator Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyOperation right) { throw null; } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct JsonWebKeyType : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public JsonWebKeyType(string value) { throw null; } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType EC { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType ECHSM { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType RSA { get { throw null; } } - public static Azure.ResourceManager.KeyVault.Models.JsonWebKeyType RSAHSM { get { throw null; } } - public bool Equals(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType right) { throw null; } - public static implicit operator Azure.ResourceManager.KeyVault.Models.JsonWebKeyType (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.KeyVault.Models.JsonWebKeyType left, Azure.ResourceManager.KeyVault.Models.JsonWebKeyType right) { throw null; } - public override string ToString() { throw null; } - } - public partial class KeyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyAttributes() { } - public long? Created { get { throw null; } } - public bool? Enabled { get { throw null; } set { } } - public long? Expires { get { throw null; } set { } } - public bool? Exportable { get { throw null; } set { } } - public long? NotBefore { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? RecoveryLevel { get { throw null; } } - public long? Updated { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.KeyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.KeyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class KeyProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyProperties() { } - public Azure.ResourceManager.KeyVault.Models.KeyAttributes Attributes { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } - public System.Collections.Generic.IList KeyOps { get { throw null; } } - public int? KeySize { get { throw null; } set { } } - public System.Uri KeyUri { get { throw null; } } - public string KeyUriWithVersion { get { throw null; } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy ReleasePolicy { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.RotationPolicy RotationPolicy { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.KeyProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.KeyProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class KeyReleasePolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyReleasePolicy() { } - public string ContentType { get { throw null; } set { } } - public byte[] Data { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.KeyReleasePolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public enum KeyRotationPolicyActionType - { - Rotate = 0, - Notify = 1, - } - public partial class KeyRotationPolicyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyRotationPolicyAttributes() { } - public long? Created { get { throw null; } } - public string ExpiryTime { get { throw null; } set { } } - public long? Updated { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class KeyRotationTrigger : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public KeyRotationTrigger() { } - public string TimeAfterCreate { get { throw null; } set { } } - public string TimeBeforeExpiry { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.KeyRotationTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.KeyRotationTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } public partial class KeyVaultAccessPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeyVaultAccessPolicy(System.Guid tenantId, string objectId, Azure.ResourceManager.KeyVault.Models.IdentityAccessPermissions permissions) { } @@ -1405,17 +1053,6 @@ public KeyVaultVirtualNetworkRule(string id) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LifetimeAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public LifetimeAction() { } - public Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyActionType? ActionType { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.KeyRotationTrigger Trigger { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.LifetimeAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.LifetimeAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ManagedHsmActionsRequiredMessage : System.IEquatable { @@ -1482,85 +1119,6 @@ public ManagedHsmIPRule(string addressRange) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ManagedHsmKeyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmKeyAttributes() { } - public long? Created { get { throw null; } } - public bool? Enabled { get { throw null; } set { } } - public long? Expires { get { throw null; } set { } } - public bool? Exportable { get { throw null; } set { } } - public long? NotBefore { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.DeletionRecoveryLevel? RecoveryLevel { get { throw null; } } - public long? Updated { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class ManagedHSMKeyCreateOrUpdateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHSMKeyCreateOrUpdateContent(Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties properties) { } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties Properties { get { throw null; } } - public System.Collections.Generic.IDictionary Tags { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHSMKeyCreateOrUpdateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class ManagedHsmKeyProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmKeyProperties() { } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyAttributes Attributes { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyCurveName? CurveName { get { throw null; } set { } } - public System.Collections.Generic.IList KeyOps { get { throw null; } } - public int? KeySize { get { throw null; } set { } } - public System.Uri KeyUri { get { throw null; } } - public string KeyUriWithVersion { get { throw null; } } - public Azure.ResourceManager.KeyVault.Models.JsonWebKeyType? Kty { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy ReleasePolicy { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy RotationPolicy { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class ManagedHsmKeyReleasePolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmKeyReleasePolicy() { } - public string ContentType { get { throw null; } set { } } - public byte[] Data { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyReleasePolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class ManagedHsmKeyRotationPolicyAttributes : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmKeyRotationPolicyAttributes() { } - public long? Created { get { throw null; } } - public string ExpiryTime { get { throw null; } set { } } - public long? Updated { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } - public partial class ManagedHsmLifetimeAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmLifetimeAction() { } - public Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyActionType? KeyRotationPolicyActionType { get { throw null; } set { } } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmTrigger Trigger { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmLifetimeAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmLifetimeAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } public partial class ManagedHsmNameAvailabilityContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagedHsmNameAvailabilityContent(string name) { } @@ -1798,17 +1356,6 @@ public ManagedHsmProperties() { } public static bool operator !=(Azure.ResourceManager.KeyVault.Models.ManagedHsmPublicNetworkAccess left, Azure.ResourceManager.KeyVault.Models.ManagedHsmPublicNetworkAccess right) { throw null; } public override string ToString() { throw null; } } - public partial class ManagedHsmRotationPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmRotationPolicy() { } - public Azure.ResourceManager.KeyVault.Models.ManagedHsmKeyRotationPolicyAttributes Attributes { get { throw null; } set { } } - public System.Collections.Generic.IList LifetimeActions { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmRotationPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ManagedHSMSecurityDomainActivationStatus : System.IEquatable { @@ -1874,17 +1421,6 @@ public enum ManagedHsmSkuName CustomB32 = 1, CustomB6 = 2, } - public partial class ManagedHsmTrigger : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public ManagedHsmTrigger() { } - public string TimeAfterCreate { get { throw null; } set { } } - public string TimeBeforeExpiry { get { throw null; } set { } } - Azure.ResourceManager.KeyVault.Models.ManagedHsmTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.ManagedHsmTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } public partial class ManagedHsmVirtualNetworkRule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagedHsmVirtualNetworkRule(Azure.Core.ResourceIdentifier subnetId) { } @@ -1895,17 +1431,6 @@ public ManagedHsmVirtualNetworkRule(Azure.Core.ResourceIdentifier subnetId) { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class RotationPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public RotationPolicy() { } - public Azure.ResourceManager.KeyVault.Models.KeyRotationPolicyAttributes Attributes { get { throw null; } set { } } - public System.Collections.Generic.IList LifetimeActions { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.RotationPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.RotationPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } public partial class SecretAttributes : Azure.ResourceManager.KeyVault.Models.SecretBaseAttributes, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SecretAttributes() { } @@ -1955,15 +1480,4 @@ public SecretProperties() { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VaultKeyCreateOrUpdateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public VaultKeyCreateOrUpdateContent(Azure.ResourceManager.KeyVault.Models.KeyProperties properties) { } - public Azure.ResourceManager.KeyVault.Models.KeyProperties Properties { get { throw null; } } - public System.Collections.Generic.IDictionary Tags { get { throw null; } } - Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.ResourceManager.KeyVault.Models.VaultKeyCreateOrUpdateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs deleted file mode 100644 index 578847661c558..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyCollection.cs +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_ManagedHSMKeyCollection - { - // Create a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmCreateKey.json - // this example is just showing the usage of "ManagedHsmKeys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHsmResource created on azure - // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); - ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); - - // get the collection of this ManagedHSMKeyResource - ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - ManagedHSMKeyCreateOrUpdateContent content = new ManagedHSMKeyCreateOrUpdateContent(new ManagedHsmKeyProperties() - { - KeyType = JsonWebKeyType.RSA, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, content); - ManagedHSMKeyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json - // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHsmResource created on azure - // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); - ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); - - // get the collection of this ManagedHSMKeyResource - ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - ManagedHSMKeyResource result = await collection.GetAsync(keyName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json - // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHsmResource created on azure - // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); - ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); - - // get the collection of this ManagedHSMKeyResource - ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - bool result = await collection.ExistsAsync(keyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json - // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHsmResource created on azure - // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); - ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); - - // get the collection of this ManagedHSMKeyResource - ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - ManagedHSMKeyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine($"Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List keys in the managed HSM - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListKeysInTheManagedHSM() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmListKeys.json - // this example is just showing the usage of "ManagedHsmKeys_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHsmResource created on azure - // for more information of creating ManagedHsmResource, please refer to the document of ManagedHsmResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - ResourceIdentifier managedHsmResourceId = ManagedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); - ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); - - // get the collection of this ManagedHSMKeyResource - ManagedHSMKeyCollection collection = managedHsm.GetManagedHSMKeys(); - - // invoke the operation and iterate over the result - await foreach (ManagedHSMKeyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs deleted file mode 100644 index cea8b18cecdfb..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyResource.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_ManagedHSMKeyResource - { - // Create a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmCreateKey.json - // this example is just showing the usage of "ManagedHsmKeys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyResource created on azure - // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); - ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); - - // invoke the operation - ManagedHSMKeyCreateOrUpdateContent content = new ManagedHSMKeyCreateOrUpdateContent(new ManagedHsmKeyProperties() - { - KeyType = JsonWebKeyType.RSA, - }); - ArmOperation lro = await managedHSMKey.UpdateAsync(WaitUntil.Completed, content); - ManagedHSMKeyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKey.json - // this example is just showing the usage of "ManagedHsmKeys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyResource created on azure - // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); - ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); - - // invoke the operation - ManagedHSMKeyResource result = await managedHSMKey.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs deleted file mode 100644 index 0670642abbb1a..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionCollection.cs +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_ManagedHSMKeyVersionCollection - { - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json - // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyResource created on azure - // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); - ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); - - // get the collection of this ManagedHSMKeyVersionResource - ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); - - // invoke the operation - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - ManagedHSMKeyVersionResource result = await collection.GetAsync(keyVersion); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json - // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyResource created on azure - // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); - ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); - - // get the collection of this ManagedHSMKeyVersionResource - ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); - - // invoke the operation - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - bool result = await collection.ExistsAsync(keyVersion); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json - // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyResource created on azure - // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); - ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); - - // get the collection of this ManagedHSMKeyVersionResource - ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); - - // invoke the operation - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - NullableResponse response = await collection.GetIfExistsAsync(keyVersion); - ManagedHSMKeyVersionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine($"Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List key versions in the managed HSM - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListKeyVersionsInTheManagedHSM() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmListKeyVersions.json - // this example is just showing the usage of "ManagedHsmKeys_ListVersions" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyResource created on azure - // for more information of creating ManagedHSMKeyResource, please refer to the document of ManagedHSMKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - ResourceIdentifier managedHSMKeyResourceId = ManagedHSMKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName); - ManagedHSMKeyResource managedHSMKey = client.GetManagedHSMKeyResource(managedHSMKeyResourceId); - - // get the collection of this ManagedHSMKeyVersionResource - ManagedHSMKeyVersionCollection collection = managedHSMKey.GetManagedHSMKeyVersions(); - - // invoke the operation and iterate over the result - await foreach (ManagedHSMKeyVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs deleted file mode 100644 index e3263f9e22ae9..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHSMKeyVersionResource.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_ManagedHSMKeyVersionResource - { - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/managedHsmGetKeyVersion.json - // this example is just showing the usage of "ManagedHsmKeys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedHSMKeyVersionResource created on azure - // for more information of creating ManagedHSMKeyVersionResource, please refer to the document of ManagedHSMKeyVersionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string name = "sample-managedhsm-name"; - string keyName = "sample-key-name"; - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - ResourceIdentifier managedHSMKeyVersionResourceId = ManagedHSMKeyVersionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, keyName, keyVersion); - ManagedHSMKeyVersionResource managedHSMKeyVersion = client.GetManagedHSMKeyVersionResource(managedHSMKeyVersionResourceId); - - // invoke the operation - ManagedHSMKeyVersionResource result = await managedHSMKeyVersion.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs deleted file mode 100644 index 70eab7ec04caa..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyCollection.cs +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_VaultKeyCollection - { - // Create a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task CreateOrUpdate_CreateAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createKey.json - // this example is just showing the usage of "Keys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KeyVaultResource created on azure - // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); - - // get the collection of this VaultKeyResource - VaultKeyCollection collection = keyVault.GetVaultKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - VaultKeyCreateOrUpdateContent content = new VaultKeyCreateOrUpdateContent(new KeyProperties() - { - KeyType = JsonWebKeyType.RSA, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, content); - VaultKeyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json - // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KeyVaultResource created on azure - // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); - - // get the collection of this VaultKeyResource - VaultKeyCollection collection = keyVault.GetVaultKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - VaultKeyResource result = await collection.GetAsync(keyName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json - // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KeyVaultResource created on azure - // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); - - // get the collection of this VaultKeyResource - VaultKeyCollection collection = keyVault.GetVaultKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - bool result = await collection.ExistsAsync(keyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json - // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KeyVaultResource created on azure - // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); - - // get the collection of this VaultKeyResource - VaultKeyCollection collection = keyVault.GetVaultKeys(); - - // invoke the operation - string keyName = "sample-key-name"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - VaultKeyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine($"Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List keys in the vault - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListKeysInTheVault() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listKeys.json - // this example is just showing the usage of "Keys_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KeyVaultResource created on azure - // for more information of creating KeyVaultResource, please refer to the document of KeyVaultResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - ResourceIdentifier keyVaultResourceId = KeyVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); - - // get the collection of this VaultKeyResource - VaultKeyCollection collection = keyVault.GetVaultKeys(); - - // invoke the operation and iterate over the result - await foreach (VaultKeyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs deleted file mode 100644 index 67f1d07216619..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyResource.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_VaultKeyResource - { - // Create a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_CreateAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/createKey.json - // this example is just showing the usage of "Keys_CreateIfNotExist" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyResource created on azure - // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); - VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); - - // invoke the operation - VaultKeyCreateOrUpdateContent content = new VaultKeyCreateOrUpdateContent(new KeyProperties() - { - KeyType = JsonWebKeyType.RSA, - }); - ArmOperation lro = await vaultKey.UpdateAsync(WaitUntil.Completed, content); - VaultKeyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKey() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKey.json - // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyResource created on azure - // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); - VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); - - // invoke the operation - VaultKeyResource result = await vaultKey.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs deleted file mode 100644 index 29ec653579da2..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionCollection.cs +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_VaultKeyVersionCollection - { - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json - // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyResource created on azure - // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); - VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); - - // get the collection of this VaultKeyVersionResource - VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); - - // invoke the operation - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - VaultKeyVersionResource result = await collection.GetAsync(keyVersion); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Exists_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json - // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyResource created on azure - // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); - VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); - - // get the collection of this VaultKeyVersionResource - VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); - - // invoke the operation - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - bool result = await collection.ExistsAsync(keyVersion); - - Console.WriteLine($"Succeeded: {result}"); - } - - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetIfExists_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json - // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyResource created on azure - // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); - VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); - - // get the collection of this VaultKeyVersionResource - VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); - - // invoke the operation - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - NullableResponse response = await collection.GetIfExistsAsync(keyVersion); - VaultKeyVersionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine($"Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - // List key versions in the vault - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetAll_ListKeyVersionsInTheVault() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listKeyVersions.json - // this example is just showing the usage of "Keys_ListVersions" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyResource created on azure - // for more information of creating VaultKeyResource, please refer to the document of VaultKeyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - ResourceIdentifier vaultKeyResourceId = VaultKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName); - VaultKeyResource vaultKey = client.GetVaultKeyResource(vaultKeyResourceId); - - // get the collection of this VaultKeyVersionResource - VaultKeyVersionCollection collection = vaultKey.GetVaultKeyVersions(); - - // invoke the operation and iterate over the result - await foreach (VaultKeyVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine($"Succeeded"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs deleted file mode 100644 index be9f0b611d07c..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_VaultKeyVersionResource.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; - -namespace Azure.ResourceManager.KeyVault.Samples -{ - public partial class Sample_VaultKeyVersionResource - { - // Get a key version - [NUnit.Framework.Test] - [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Get_GetAKeyVersion() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getKeyVersion.json - // this example is just showing the usage of "Keys_GetVersion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VaultKeyVersionResource created on azure - // for more information of creating VaultKeyVersionResource, please refer to the document of VaultKeyVersionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; - string vaultName = "sample-vault-name"; - string keyName = "sample-key-name"; - string keyVersion = "fd618d9519b74f9aae94ade66b876acc"; - ResourceIdentifier vaultKeyVersionResourceId = VaultKeyVersionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, keyName, keyVersion); - VaultKeyVersionResource vaultKeyVersion = client.GetVaultKeyVersionResource(vaultKeyVersionResourceId); - - // invoke the operation - VaultKeyVersionResource result = await vaultKeyVersion.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Azure.ResourceManager.KeyVault.csproj b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Azure.ResourceManager.KeyVault.csproj index aae8b4b868663..b245da30a7743 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Azure.ResourceManager.KeyVault.csproj +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Azure.ResourceManager.KeyVault.csproj @@ -1,6 +1,6 @@ - 1.3.0-beta.1 + 1.3.0 1.2.3 Azure.ResourceManager.KeyVault diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs index 22f1eac7fc1f5..ab20a59df3e67 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ArmKeyVaultModelFactory.cs @@ -17,211 +17,6 @@ namespace Azure.ResourceManager.KeyVault.Models /// Model factory for models. public static partial class ArmKeyVaultModelFactory { - /// Initializes a new instance of . - /// The tags that will be assigned to the key. - /// The properties of the key to be created. - /// A new instance for mocking. - public static VaultKeyCreateOrUpdateContent VaultKeyCreateOrUpdateContent(IDictionary tags = null, KeyProperties properties = null) - { - tags ??= new Dictionary(); - - return new VaultKeyCreateOrUpdateContent(tags, properties, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - /// A new instance for mocking. - public static KeyProperties KeyProperties(KeyAttributes attributes = null, JsonWebKeyType? keyType = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null) - { - keyOps ??= new List(); - - return new KeyProperties( - attributes, - keyType, - keyOps?.ToList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Determines whether or not the object is enabled. - /// Not before date in seconds since 1970-01-01T00:00:00Z. - /// Expiry date in seconds since 1970-01-01T00:00:00Z. - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. - /// A new instance for mocking. - public static KeyAttributes KeyAttributes(bool? isEnabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? canExported = null) - { - return new KeyAttributes( - isEnabled, - notBefore, - expires, - created, - updated, - recoveryLevel, - canExported, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. - /// A new instance for mocking. - public static KeyRotationPolicyAttributes KeyRotationPolicyAttributes(long? created = null, long? updated = null, string expiryTime = null) - { - return new KeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - /// Azure location of the key vault resource. - /// Tags assigned to the key vault resource. - /// A new instance for mocking. - public static KeyVaultKeyData KeyVaultKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, KeyAttributes attributes = null, JsonWebKeyType? keyType = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, RotationPolicy rotationPolicy = null, KeyReleasePolicy releasePolicy = null, AzureLocation? location = null, IReadOnlyDictionary tags = null) - { - keyOps ??= new List(); - tags ??= new Dictionary(); - - return new KeyVaultKeyData( - id, - name, - resourceType, - systemData, - attributes, - keyType, - keyOps?.ToList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, - location, - tags, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The tags that will be assigned to the key. - /// The properties of the key to be created. - /// A new instance for mocking. - public static ManagedHSMKeyCreateOrUpdateContent ManagedHSMKeyCreateOrUpdateContent(IDictionary tags = null, ManagedHsmKeyProperties properties = null) - { - tags ??= new Dictionary(); - - return new ManagedHSMKeyCreateOrUpdateContent(tags, properties, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - /// A new instance for mocking. - public static ManagedHsmKeyProperties ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes = null, JsonWebKeyType? keyType = null, IEnumerable keyOps = null, int? keySize = null, JsonWebKeyCurveName? curveName = null, Uri keyUri = null, string keyUriWithVersion = null, ManagedHsmRotationPolicy rotationPolicy = null, ManagedHsmKeyReleasePolicy releasePolicy = null) - { - keyOps ??= new List(); - - return new ManagedHsmKeyProperties( - attributes, - keyType, - keyOps?.ToList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Determines whether or not the object is enabled. - /// Not before date in seconds since 1970-01-01T00:00:00Z. - /// Expiry date in seconds since 1970-01-01T00:00:00Z. - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. - /// A new instance for mocking. - public static ManagedHsmKeyAttributes ManagedHsmKeyAttributes(bool? isEnabled = null, long? notBefore = null, long? expires = null, long? created = null, long? updated = null, DeletionRecoveryLevel? recoveryLevel = null, bool? canExported = null) - { - return new ManagedHsmKeyAttributes( - isEnabled, - notBefore, - expires, - created, - updated, - recoveryLevel, - canExported, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. - /// A new instance for mocking. - public static ManagedHsmKeyRotationPolicyAttributes ManagedHsmKeyRotationPolicyAttributes(long? created = null, long? updated = null, string expiryTime = null) - { - return new ManagedHsmKeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The properties of the key. - /// Resource tags. - /// A new instance for mocking. - public static ManagedHsmKeyData ManagedHsmKeyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ManagedHsmKeyProperties properties = null, IReadOnlyDictionary tags = null) - { - tags ??= new Dictionary(); - - return new ManagedHsmKeyData( - id, - name, - resourceType, - systemData, - properties, - tags, - serializedAdditionalRawData: null); - } - /// Initializes a new instance of . /// The supported Azure location where the key vault should be created. /// The tags that will be assigned to the key vault. diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs index dc0c50c6340c6..720334f5df2dd 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/KeyVaultExtensions.cs @@ -33,82 +33,6 @@ private static MockableKeyVaultSubscriptionResource GetMockableKeyVaultSubscript return resource.GetCachedClient(client => new MockableKeyVaultSubscriptionResource(client, resource.Id)); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// is null. - /// Returns a object. - public static VaultKeyResource GetVaultKeyResource(this ArmClient client, ResourceIdentifier id) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableKeyVaultArmClient(client).GetVaultKeyResource(id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// is null. - /// Returns a object. - public static VaultKeyVersionResource GetVaultKeyVersionResource(this ArmClient client, ResourceIdentifier id) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableKeyVaultArmClient(client).GetVaultKeyVersionResource(id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// is null. - /// Returns a object. - public static ManagedHSMKeyResource GetManagedHSMKeyResource(this ArmClient client, ResourceIdentifier id) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableKeyVaultArmClient(client).GetManagedHSMKeyResource(id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// is null. - /// Returns a object. - public static ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(this ArmClient client, ResourceIdentifier id) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableKeyVaultArmClient(client).GetManagedHSMKeyVersionResource(id); - } - /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// You can use to create a from its components. diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs index b2b1c4b68f926..7e34193bd5fad 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Extensions/MockableKeyVaultArmClient.cs @@ -34,54 +34,6 @@ private string GetApiVersionOrNull(ResourceType resourceType) return apiVersion; } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual VaultKeyResource GetVaultKeyResource(ResourceIdentifier id) - { - VaultKeyResource.ValidateResourceId(id); - return new VaultKeyResource(Client, id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual VaultKeyVersionResource GetVaultKeyVersionResource(ResourceIdentifier id) - { - VaultKeyVersionResource.ValidateResourceId(id); - return new VaultKeyVersionResource(Client, id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual ManagedHSMKeyResource GetManagedHSMKeyResource(ResourceIdentifier id) - { - ManagedHSMKeyResource.ValidateResourceId(id); - return new ManagedHSMKeyResource(Client, id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual ManagedHSMKeyVersionResource GetManagedHSMKeyVersionResource(ResourceIdentifier id) - { - ManagedHSMKeyVersionResource.ValidateResourceId(id); - return new ManagedHSMKeyVersionResource(Client, id); - } - /// /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// You can use to create a from its components. diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs deleted file mode 100644 index 6c473b4cd4285..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.Serialization.cs +++ /dev/null @@ -1,652 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; -using Azure.ResourceManager.KeyVault.Models; -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.KeyVault -{ - public partial class KeyVaultKeyData : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(Location)) - { - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location.Value); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(Attributes)) - { - writer.WritePropertyName("attributes"u8); - writer.WriteObjectValue(Attributes, options); - } - if (Optional.IsDefined(KeyType)) - { - writer.WritePropertyName("kty"u8); - writer.WriteStringValue(KeyType.Value.ToString()); - } - if (Optional.IsCollectionDefined(KeyOps)) - { - writer.WritePropertyName("keyOps"u8); - writer.WriteStartArray(); - foreach (var item in KeyOps) - { - writer.WriteStringValue(item.ToString()); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(KeySize)) - { - writer.WritePropertyName("keySize"u8); - writer.WriteNumberValue(KeySize.Value); - } - if (Optional.IsDefined(CurveName)) - { - writer.WritePropertyName("curveName"u8); - writer.WriteStringValue(CurveName.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(KeyUri)) - { - writer.WritePropertyName("keyUri"u8); - writer.WriteStringValue(KeyUri.AbsoluteUri); - } - if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) - { - writer.WritePropertyName("keyUriWithVersion"u8); - writer.WriteStringValue(KeyUriWithVersion); - } - if (Optional.IsDefined(RotationPolicy)) - { - writer.WritePropertyName("rotationPolicy"u8); - writer.WriteObjectValue(RotationPolicy, options); - } - if (Optional.IsDefined(ReleasePolicy)) - { - writer.WritePropertyName("release_policy"u8); - writer.WriteObjectValue(ReleasePolicy, options); - } - writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyVaultKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyVaultKeyData(document.RootElement, options); - } - - internal static KeyVaultKeyData DeserializeKeyVaultKeyData(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AzureLocation? location = default; - IReadOnlyDictionary tags = default; - ResourceIdentifier id = default; - string name = default; - ResourceType type = default; - SystemData systemData = default; - KeyAttributes attributes = default; - JsonWebKeyType? kty = default; - IList keyOps = default; - int? keySize = default; - JsonWebKeyCurveName? curveName = default; - Uri keyUri = default; - string keyUriWithVersion = default; - RotationPolicy rotationPolicy = default; - KeyReleasePolicy releasePolicy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("location"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - location = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("tags"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; - continue; - } - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("systemData"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("properties"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("attributes"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - attributes = KeyAttributes.DeserializeKeyAttributes(property0.Value, options); - continue; - } - if (property0.NameEquals("kty"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - kty = new JsonWebKeyType(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("keyOps"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(new JsonWebKeyOperation(item.GetString())); - } - keyOps = array; - continue; - } - if (property0.NameEquals("keySize"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keySize = property0.Value.GetInt32(); - continue; - } - if (property0.NameEquals("curveName"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - curveName = new JsonWebKeyCurveName(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("keyUri"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keyUri = new Uri(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("keyUriWithVersion"u8)) - { - keyUriWithVersion = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("rotationPolicy"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rotationPolicy = RotationPolicy.DeserializeRotationPolicy(property0.Value, options); - continue; - } - if (property0.NameEquals("release_policy"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - releasePolicy = KeyReleasePolicy.DeserializeKeyReleasePolicy(property0.Value, options); - continue; - } - } - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyVaultKeyData( - id, - name, - type, - systemData, - attributes, - kty, - keyOps ?? new ChangeTrackingList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, - location, - tags ?? new ChangeTrackingDictionary(), - serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" name: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Name)) - { - builder.Append(" name: "); - if (Name.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); - } - else - { - builder.AppendLine($"'{Name}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" location: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Location)) - { - builder.Append(" location: "); - builder.AppendLine($"'{Location.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" tags: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(Tags)) - { - if (Tags.Any()) - { - builder.Append(" tags: "); - builder.AppendLine("{"); - foreach (var item in Tags) - { - builder.Append($" '{item.Key}': "); - if (item.Value == null) - { - builder.Append("null"); - continue; - } - if (item.Value.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{item.Value}'''"); - } - else - { - builder.AppendLine($"'{item.Value}'"); - } - } - builder.AppendLine(" }"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" id: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Id)) - { - builder.Append(" id: "); - builder.AppendLine($"'{Id.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" systemData: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(SystemData)) - { - builder.Append(" systemData: "); - builder.AppendLine($"'{SystemData.ToString()}'"); - } - } - - builder.Append(" properties:"); - builder.AppendLine(" {"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" attributes: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Attributes)) - { - builder.Append(" attributes: "); - BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 4, false, " attributes: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyType), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" kty: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyType)) - { - builder.Append(" kty: "); - builder.AppendLine($"'{KeyType.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyOps), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyOps: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(KeyOps)) - { - if (KeyOps.Any()) - { - builder.Append(" keyOps: "); - builder.AppendLine("["); - foreach (var item in KeyOps) - { - builder.AppendLine($" '{item.ToString()}'"); - } - builder.AppendLine(" ]"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keySize: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeySize)) - { - builder.Append(" keySize: "); - builder.AppendLine($"{KeySize.Value}"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurveName), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" curveName: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(CurveName)) - { - builder.Append(" curveName: "); - builder.AppendLine($"'{CurveName.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyUri: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyUri)) - { - builder.Append(" keyUri: "); - builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUriWithVersion), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyUriWithVersion: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyUriWithVersion)) - { - builder.Append(" keyUriWithVersion: "); - if (KeyUriWithVersion.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{KeyUriWithVersion}'''"); - } - else - { - builder.AppendLine($"'{KeyUriWithVersion}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RotationPolicy), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" rotationPolicy: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(RotationPolicy)) - { - builder.Append(" rotationPolicy: "); - BicepSerializationHelpers.AppendChildObject(builder, RotationPolicy, options, 4, false, " rotationPolicy: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReleasePolicy), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" release_policy: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ReleasePolicy)) - { - builder.Append(" release_policy: "); - BicepSerializationHelpers.AppendChildObject(builder, ReleasePolicy, options, 4, false, " release_policy: "); - } - } - - builder.AppendLine(" }"); - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support writing '{options.Format}' format."); - } - } - - KeyVaultKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyVaultKeyData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyVaultKeyData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs deleted file mode 100644 index c2641fe796fd9..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultKeyData.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using Azure.Core; -using Azure.ResourceManager.KeyVault.Models; -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A class representing the KeyVaultKey data model. - /// The key resource. - /// - public partial class KeyVaultKeyData : ResourceData - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyVaultKeyData() - { - KeyOps = new ChangeTrackingList(); - Tags = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - /// Azure location of the key vault resource. - /// Tags assigned to the key vault resource. - /// Keeps track of any properties unknown to the library. - internal KeyVaultKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, KeyAttributes attributes, JsonWebKeyType? keyType, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, AzureLocation? location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) - { - Attributes = attributes; - KeyType = keyType; - KeyOps = keyOps; - KeySize = keySize; - CurveName = curveName; - KeyUri = keyUri; - KeyUriWithVersion = keyUriWithVersion; - RotationPolicy = rotationPolicy; - ReleasePolicy = releasePolicy; - Location = location; - Tags = tags; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The attributes of the key. - [WirePath("properties.attributes")] - public KeyAttributes Attributes { get; set; } - /// The type of the key. For valid values, see JsonWebKeyType. - [WirePath("properties.kty")] - public JsonWebKeyType? KeyType { get; set; } - /// Gets the key ops. - [WirePath("properties.keyOps")] - public IList KeyOps { get; } - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - [WirePath("properties.keySize")] - public int? KeySize { get; set; } - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - [WirePath("properties.curveName")] - public JsonWebKeyCurveName? CurveName { get; set; } - /// The URI to retrieve the current version of the key. - [WirePath("properties.keyUri")] - public Uri KeyUri { get; } - /// The URI to retrieve the specific version of the key. - [WirePath("properties.keyUriWithVersion")] - public string KeyUriWithVersion { get; } - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("properties.rotationPolicy")] - public RotationPolicy RotationPolicy { get; set; } - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("properties.release_policy")] - public KeyReleasePolicy ReleasePolicy { get; set; } - /// Azure location of the key vault resource. - [WirePath("location")] - public AzureLocation? Location { get; } - /// Tags assigned to the key vault resource. - [WirePath("tags")] - public IReadOnlyDictionary Tags { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs index 329feabb5bc41..b4b49e0a267ea 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/KeyVaultResource.cs @@ -95,75 +95,6 @@ internal static void ValidateResourceId(ResourceIdentifier id) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); } - /// Gets a collection of VaultKeyResources in the KeyVault. - /// An object representing collection of VaultKeyResources and their operations over a VaultKeyResource. - public virtual VaultKeyCollection GetVaultKeys() - { - return GetCachedClient(client => new VaultKeyCollection(client, Id)); - } - - /// - /// Gets the current version of the specified key from the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetVaultKeyAsync(string keyName, CancellationToken cancellationToken = default) - { - return await GetVaultKeys().GetAsync(keyName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the current version of the specified key from the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetVaultKey(string keyName, CancellationToken cancellationToken = default) - { - return GetVaultKeys().Get(keyName, cancellationToken); - } - /// Gets a collection of KeyVaultPrivateEndpointConnectionResources in the KeyVault. /// An object representing collection of KeyVaultPrivateEndpointConnectionResources and their operations over a KeyVaultPrivateEndpointConnectionResource. public virtual KeyVaultPrivateEndpointConnectionCollection GetKeyVaultPrivateEndpointConnections() diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs deleted file mode 100644 index 516ae88e0e833..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyCollection.cs +++ /dev/null @@ -1,498 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetManagedHSMKeys method from an instance of . - /// - public partial class ManagedHSMKeyCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _managedHSMKeyManagedHsmKeysClientDiagnostics; - private readonly ManagedHsmKeysRestOperations _managedHSMKeyManagedHsmKeysRestClient; - - /// Initializes a new instance of the class for mocking. - protected ManagedHSMKeyCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal ManagedHSMKeyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _managedHSMKeyManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ManagedHSMKeyResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ManagedHSMKeyResource.ResourceType, out string managedHSMKeyManagedHsmKeysApiVersion); - _managedHSMKeyManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyManagedHsmKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ManagedHsmResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedHsmResource.ResourceType), nameof(id)); - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken).ConfigureAwait(false); - var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken); - var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the current version of the specified key from the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Get"); - scope.Start(); - try - { - var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the current version of the specified key from the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Get"); - scope.Start(); - try - { - var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Lists the keys in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys - /// - /// - /// Operation Id - /// ManagedHsmKeys_List - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyManagedHsmKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyManagedHsmKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Lists the keys in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys - /// - /// - /// Operation Id - /// ManagedHsmKeys_List - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyManagedHsmKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyManagedHsmKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Exists"); - scope.Start(); - try - { - var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.Exists"); - scope.Start(); - try - { - var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyCollection.GetIfExists"); - scope.Start(); - try - { - var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs deleted file mode 100644 index 7ba0bbc02f664..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.Serialization.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.KeyVault -{ - public partial class ManagedHSMKeyResource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - ManagedHsmKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); - - ManagedHsmKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs deleted file mode 100644 index 334f85ceef200..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyResource.cs +++ /dev/null @@ -1,696 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A Class representing a ManagedHSMKey along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetManagedHSMKeyResource method. - /// Otherwise you can get one from its parent resource using the GetManagedHSMKey method. - /// - public partial class ManagedHSMKeyResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The name. - /// The keyName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _managedHSMKeyManagedHsmKeysClientDiagnostics; - private readonly ManagedHsmKeysRestOperations _managedHSMKeyManagedHsmKeysRestClient; - private readonly ManagedHsmKeyData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.KeyVault/managedHSMs/keys"; - - /// Initializes a new instance of the class for mocking. - protected ManagedHSMKeyResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal ManagedHSMKeyResource(ArmClient client, ManagedHsmKeyData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal ManagedHSMKeyResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _managedHSMKeyManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string managedHSMKeyManagedHsmKeysApiVersion); - _managedHSMKeyManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyManagedHsmKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual ManagedHsmKeyData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// Gets a collection of ManagedHSMKeyVersionResources in the ManagedHSMKey. - /// An object representing collection of ManagedHSMKeyVersionResources and their operations over a ManagedHSMKeyVersionResource. - public virtual ManagedHSMKeyVersionCollection GetManagedHSMKeyVersions() - { - return GetCachedClient(client => new ManagedHSMKeyVersionCollection(client, Id)); - } - - /// - /// Gets the specified version of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetManagedHSMKeyVersionAsync(string keyVersion, CancellationToken cancellationToken = default) - { - return await GetManagedHSMKeyVersions().GetAsync(keyVersion, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified version of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetManagedHSMKeyVersion(string keyVersion, CancellationToken cancellationToken = default) - { - return GetManagedHSMKeyVersions().Get(keyVersion, cancellationToken); - } - - /// - /// Gets the current version of the specified key from the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Get"); - scope.Start(); - try - { - var response = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the current version of the specified key from the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Get"); - scope.Start(); - try - { - var response = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Update"); - scope.Start(); - try - { - var response = await _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); - var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.Update"); - scope.Start(); - try - { - var response = _managedHSMKeyManagedHsmKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); - var uri = _managedHSMKeyManagedHsmKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new ManagedHSMKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The key for the tag. - /// The value for the tag. - /// The cancellation token to use. - /// or is null. - public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(key, nameof(key)); - Argument.AssertNotNull(value, nameof(value)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.AddTag"); - scope.Start(); - try - { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) - { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); - originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); - } - else - { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); - foreach (var tag in current.Tags) - { - patch.Tags.Add(tag); - } - patch.Tags[key] = value; - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(result.Value, result.GetRawResponse()); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The key for the tag. - /// The value for the tag. - /// The cancellation token to use. - /// or is null. - public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(key, nameof(key)); - Argument.AssertNotNull(value, nameof(value)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.AddTag"); - scope.Start(); - try - { - if (CanUseTagResource(cancellationToken: cancellationToken)) - { - var originalTags = GetTagResource().Get(cancellationToken); - originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); - } - else - { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); - foreach (var tag in current.Tags) - { - patch.Tags.Add(tag); - } - patch.Tags[key] = value; - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); - return Response.FromValue(result.Value, result.GetRawResponse()); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. - /// The cancellation token to use. - /// is null. - public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(tags, nameof(tags)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.SetTags"); - scope.Start(); - try - { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) - { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); - originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); - } - else - { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); - patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(result.Value, result.GetRawResponse()); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. - /// The cancellation token to use. - /// is null. - public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(tags, nameof(tags)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.SetTags"); - scope.Start(); - try - { - if (CanUseTagResource(cancellationToken: cancellationToken)) - { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); - originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); - } - else - { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); - patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); - return Response.FromValue(result.Value, result.GetRawResponse()); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The key for the tag. - /// The cancellation token to use. - /// is null. - public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(key, nameof(key)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.RemoveTag"); - scope.Start(); - try - { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) - { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); - originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _managedHSMKeyManagedHsmKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); - } - else - { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); - foreach (var tag in current.Tags) - { - patch.Tags.Add(tag); - } - patch.Tags.Remove(key); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(result.Value, result.GetRawResponse()); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The key for the tag. - /// The cancellation token to use. - /// is null. - public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(key, nameof(key)); - - using var scope = _managedHSMKeyManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyResource.RemoveTag"); - scope.Start(); - try - { - if (CanUseTagResource(cancellationToken: cancellationToken)) - { - var originalTags = GetTagResource().Get(cancellationToken); - originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _managedHSMKeyManagedHsmKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ManagedHSMKeyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); - } - else - { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ManagedHSMKeyCreateOrUpdateContent(current.Properties); - foreach (var tag in current.Tags) - { - patch.Tags.Add(tag); - } - patch.Tags.Remove(key); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); - return Response.FromValue(result.Value, result.GetRawResponse()); - } - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs deleted file mode 100644 index a80834affaf4c..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionCollection.cs +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetManagedHSMKeyVersions method from an instance of . - /// - public partial class ManagedHSMKeyVersionCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _managedHSMKeyVersionManagedHsmKeysClientDiagnostics; - private readonly ManagedHsmKeysRestOperations _managedHSMKeyVersionManagedHsmKeysRestClient; - - /// Initializes a new instance of the class for mocking. - protected ManagedHSMKeyVersionCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal ManagedHSMKeyVersionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _managedHSMKeyVersionManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ManagedHSMKeyVersionResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ManagedHSMKeyVersionResource.ResourceType, out string managedHSMKeyVersionManagedHsmKeysApiVersion); - _managedHSMKeyVersionManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyVersionManagedHsmKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ManagedHSMKeyResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedHSMKeyResource.ResourceType), nameof(id)); - } - - /// - /// Gets the specified version of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Get"); - scope.Start(); - try - { - var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the specified version of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Get"); - scope.Start(); - try - { - var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Lists the versions of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions - /// - /// - /// Operation Id - /// ManagedHsmKeys_ListVersions - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyVersionResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyVersionManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Lists the versions of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions - /// - /// - /// Operation Id - /// ManagedHsmKeys_ListVersions - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managedHSMKeyVersionManagedHsmKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedHSMKeyVersionResource(Client, ManagedHsmKeyData.DeserializeManagedHsmKeyData(e)), _managedHSMKeyVersionManagedHsmKeysClientDiagnostics, Pipeline, "ManagedHSMKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Exists"); - scope.Start(); - try - { - var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.Exists"); - scope.Start(); - try - { - var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionCollection.GetIfExists"); - scope.Start(); - try - { - var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs deleted file mode 100644 index db9ef782ca1fe..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.Serialization.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.KeyVault -{ - public partial class ManagedHSMKeyVersionResource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - ManagedHsmKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); - - ManagedHsmKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs deleted file mode 100644 index 1d50d506ee863..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHSMKeyVersionResource.cs +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A Class representing a ManagedHSMKeyVersion along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetManagedHSMKeyVersionResource method. - /// Otherwise you can get one from its parent resource using the GetManagedHSMKeyVersion method. - /// - public partial class ManagedHSMKeyVersionResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The name. - /// The keyName. - /// The keyVersion. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _managedHSMKeyVersionManagedHsmKeysClientDiagnostics; - private readonly ManagedHsmKeysRestOperations _managedHSMKeyVersionManagedHsmKeysRestClient; - private readonly ManagedHsmKeyData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.KeyVault/managedHSMs/keys/versions"; - - /// Initializes a new instance of the class for mocking. - protected ManagedHSMKeyVersionResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal ManagedHSMKeyVersionResource(ArmClient client, ManagedHsmKeyData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal ManagedHSMKeyVersionResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _managedHSMKeyVersionManagedHsmKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string managedHSMKeyVersionManagedHsmKeysApiVersion); - _managedHSMKeyVersionManagedHsmKeysRestClient = new ManagedHsmKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedHSMKeyVersionManagedHsmKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual ManagedHsmKeyData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// - /// Gets the specified version of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionResource.Get"); - scope.Start(); - try - { - var response = await _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the specified version of the specified key in the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// ManagedHsmKeys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _managedHSMKeyVersionManagedHsmKeysClientDiagnostics.CreateScope("ManagedHSMKeyVersionResource.Get"); - scope.Start(); - try - { - var response = _managedHSMKeyVersionManagedHsmKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ManagedHSMKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs deleted file mode 100644 index 38f493f118cd3..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.Serialization.cs +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; -using Azure.ResourceManager.KeyVault.Models; -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.KeyVault -{ - public partial class ManagedHsmKeyData : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmKeyData(document.RootElement, options); - } - - internal static ManagedHsmKeyData DeserializeManagedHsmKeyData(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ManagedHsmKeyProperties properties = default; - IReadOnlyDictionary tags = default; - ResourceIdentifier id = default; - string name = default; - ResourceType type = default; - SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("properties"u8)) - { - properties = ManagedHsmKeyProperties.DeserializeManagedHsmKeyProperties(property.Value, options); - continue; - } - if (property.NameEquals("tags"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; - continue; - } - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("systemData"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmKeyData( - id, - name, - type, - systemData, - properties, - tags ?? new ChangeTrackingDictionary(), - serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" name: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Name)) - { - builder.Append(" name: "); - if (Name.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); - } - else - { - builder.AppendLine($"'{Name}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" tags: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(Tags)) - { - if (Tags.Any()) - { - builder.Append(" tags: "); - builder.AppendLine("{"); - foreach (var item in Tags) - { - builder.Append($" '{item.Key}': "); - if (item.Value == null) - { - builder.Append("null"); - continue; - } - if (item.Value.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{item.Value}'''"); - } - else - { - builder.AppendLine($"'{item.Value}'"); - } - } - builder.AppendLine(" }"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" properties: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Properties)) - { - builder.Append(" properties: "); - BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" id: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Id)) - { - builder.Append(" id: "); - builder.AppendLine($"'{Id.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" systemData: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(SystemData)) - { - builder.Append(" systemData: "); - builder.AppendLine($"'{SystemData.ToString()}'"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmKeyData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs deleted file mode 100644 index 178ab6672b7d8..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmKeyData.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using Azure.Core; -using Azure.ResourceManager.KeyVault.Models; -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A class representing the ManagedHsmKey data model. - /// The key resource. - /// - public partial class ManagedHsmKeyData : ResourceData - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The properties of the key. - /// is null. - internal ManagedHsmKeyData(ManagedHsmKeyProperties properties) - { - Argument.AssertNotNull(properties, nameof(properties)); - - Properties = properties; - Tags = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The properties of the key. - /// Resource tags. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagedHsmKeyProperties properties, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) - { - Properties = properties; - Tags = tags; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedHsmKeyData() - { - } - - /// The properties of the key. - [WirePath("properties")] - public ManagedHsmKeyProperties Properties { get; } - /// Resource tags. - [WirePath("tags")] - public IReadOnlyDictionary Tags { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs index c9edaf601f30d..861b150606679 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/ManagedHsmResource.cs @@ -99,75 +99,6 @@ internal static void ValidateResourceId(ResourceIdentifier id) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); } - /// Gets a collection of ManagedHSMKeyResources in the ManagedHsm. - /// An object representing collection of ManagedHSMKeyResources and their operations over a ManagedHSMKeyResource. - public virtual ManagedHSMKeyCollection GetManagedHSMKeys() - { - return GetCachedClient(client => new ManagedHSMKeyCollection(client, Id)); - } - - /// - /// Gets the current version of the specified key from the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetManagedHSMKeyAsync(string keyName, CancellationToken cancellationToken = default) - { - return await GetManagedHSMKeys().GetAsync(keyName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the current version of the specified key from the specified managed HSM. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName} - /// - /// - /// Operation Id - /// ManagedHsmKeys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetManagedHSMKey(string keyName, CancellationToken cancellationToken = default) - { - return GetManagedHSMKeys().Get(keyName, cancellationToken); - } - /// Gets a collection of ManagedHsmPrivateEndpointConnectionResources in the ManagedHsm. /// An object representing collection of ManagedHsmPrivateEndpointConnectionResources and their operations over a ManagedHsmPrivateEndpointConnectionResource. public virtual ManagedHsmPrivateEndpointConnectionCollection GetManagedHsmPrivateEndpointConnections() diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs deleted file mode 100644 index b8633c7a1cba3..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/DeletionRecoveryLevel.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - public readonly partial struct DeletionRecoveryLevel : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DeletionRecoveryLevel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string PurgeableValue = "Purgeable"; - private const string RecoverablePurgeableValue = "Recoverable+Purgeable"; - private const string RecoverableValue = "Recoverable"; - private const string RecoverableProtectedSubscriptionValue = "Recoverable+ProtectedSubscription"; - - /// Purgeable. - public static DeletionRecoveryLevel Purgeable { get; } = new DeletionRecoveryLevel(PurgeableValue); - /// Recoverable+Purgeable. - public static DeletionRecoveryLevel RecoverablePurgeable { get; } = new DeletionRecoveryLevel(RecoverablePurgeableValue); - /// Recoverable. - public static DeletionRecoveryLevel Recoverable { get; } = new DeletionRecoveryLevel(RecoverableValue); - /// Recoverable+ProtectedSubscription. - public static DeletionRecoveryLevel RecoverableProtectedSubscription { get; } = new DeletionRecoveryLevel(RecoverableProtectedSubscriptionValue); - /// Determines if two values are the same. - public static bool operator ==(DeletionRecoveryLevel left, DeletionRecoveryLevel right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(DeletionRecoveryLevel left, DeletionRecoveryLevel right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator DeletionRecoveryLevel(string value) => new DeletionRecoveryLevel(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is DeletionRecoveryLevel other && Equals(other); - /// - public bool Equals(DeletionRecoveryLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs deleted file mode 100644 index 931c9aef9361f..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyCurveName.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - public readonly partial struct JsonWebKeyCurveName : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public JsonWebKeyCurveName(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string P256Value = "P-256"; - private const string P384Value = "P-384"; - private const string P521Value = "P-521"; - private const string P256KValue = "P-256K"; - - /// P-256. - public static JsonWebKeyCurveName P256 { get; } = new JsonWebKeyCurveName(P256Value); - /// P-384. - public static JsonWebKeyCurveName P384 { get; } = new JsonWebKeyCurveName(P384Value); - /// P-521. - public static JsonWebKeyCurveName P521 { get; } = new JsonWebKeyCurveName(P521Value); - /// P-256K. - public static JsonWebKeyCurveName P256K { get; } = new JsonWebKeyCurveName(P256KValue); - /// Determines if two values are the same. - public static bool operator ==(JsonWebKeyCurveName left, JsonWebKeyCurveName right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(JsonWebKeyCurveName left, JsonWebKeyCurveName right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator JsonWebKeyCurveName(string value) => new JsonWebKeyCurveName(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is JsonWebKeyCurveName other && Equals(other); - /// - public bool Equals(JsonWebKeyCurveName other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs deleted file mode 100644 index 6ad565cdcc8fe..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyOperation.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The permitted JSON web key operations of the key. For more information, see JsonWebKeyOperation. - public readonly partial struct JsonWebKeyOperation : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public JsonWebKeyOperation(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string EncryptValue = "encrypt"; - private const string DecryptValue = "decrypt"; - private const string SignValue = "sign"; - private const string VerifyValue = "verify"; - private const string WrapKeyValue = "wrapKey"; - private const string UnwrapKeyValue = "unwrapKey"; - private const string ImportValue = "import"; - private const string ReleaseValue = "release"; - - /// encrypt. - public static JsonWebKeyOperation Encrypt { get; } = new JsonWebKeyOperation(EncryptValue); - /// decrypt. - public static JsonWebKeyOperation Decrypt { get; } = new JsonWebKeyOperation(DecryptValue); - /// sign. - public static JsonWebKeyOperation Sign { get; } = new JsonWebKeyOperation(SignValue); - /// verify. - public static JsonWebKeyOperation Verify { get; } = new JsonWebKeyOperation(VerifyValue); - /// wrapKey. - public static JsonWebKeyOperation WrapKey { get; } = new JsonWebKeyOperation(WrapKeyValue); - /// unwrapKey. - public static JsonWebKeyOperation UnwrapKey { get; } = new JsonWebKeyOperation(UnwrapKeyValue); - /// import. - public static JsonWebKeyOperation Import { get; } = new JsonWebKeyOperation(ImportValue); - /// release. - public static JsonWebKeyOperation Release { get; } = new JsonWebKeyOperation(ReleaseValue); - /// Determines if two values are the same. - public static bool operator ==(JsonWebKeyOperation left, JsonWebKeyOperation right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(JsonWebKeyOperation left, JsonWebKeyOperation right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator JsonWebKeyOperation(string value) => new JsonWebKeyOperation(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is JsonWebKeyOperation other && Equals(other); - /// - public bool Equals(JsonWebKeyOperation other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs deleted file mode 100644 index 4a24c59b92ced..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/JsonWebKeyType.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The type of the key. For valid values, see JsonWebKeyType. - public readonly partial struct JsonWebKeyType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public JsonWebKeyType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ECValue = "EC"; - private const string ECHSMValue = "EC-HSM"; - private const string RSAValue = "RSA"; - private const string RSAHSMValue = "RSA-HSM"; - - /// EC. - public static JsonWebKeyType EC { get; } = new JsonWebKeyType(ECValue); - /// EC-HSM. - public static JsonWebKeyType ECHSM { get; } = new JsonWebKeyType(ECHSMValue); - /// RSA. - public static JsonWebKeyType RSA { get; } = new JsonWebKeyType(RSAValue); - /// RSA-HSM. - public static JsonWebKeyType RSAHSM { get; } = new JsonWebKeyType(RSAHSMValue); - /// Determines if two values are the same. - public static bool operator ==(JsonWebKeyType left, JsonWebKeyType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(JsonWebKeyType left, JsonWebKeyType right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator JsonWebKeyType(string value) => new JsonWebKeyType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is JsonWebKeyType other && Equals(other); - /// - public bool Equals(JsonWebKeyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs deleted file mode 100644 index b37eb5d776cfb..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.Serialization.cs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class KeyAttributes : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyAttributes)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(IsEnabled)) - { - writer.WritePropertyName("enabled"u8); - writer.WriteBooleanValue(IsEnabled.Value); - } - if (Optional.IsDefined(NotBefore)) - { - writer.WritePropertyName("nbf"u8); - writer.WriteNumberValue(NotBefore.Value); - } - if (Optional.IsDefined(Expires)) - { - writer.WritePropertyName("exp"u8); - writer.WriteNumberValue(Expires.Value); - } - if (options.Format != "W" && Optional.IsDefined(Created)) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(Created.Value); - } - if (options.Format != "W" && Optional.IsDefined(Updated)) - { - writer.WritePropertyName("updated"u8); - writer.WriteNumberValue(Updated.Value); - } - if (options.Format != "W" && Optional.IsDefined(RecoveryLevel)) - { - writer.WritePropertyName("recoveryLevel"u8); - writer.WriteStringValue(RecoveryLevel.Value.ToString()); - } - if (Optional.IsDefined(CanExported)) - { - writer.WritePropertyName("exportable"u8); - writer.WriteBooleanValue(CanExported.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyAttributes)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyAttributes(document.RootElement, options); - } - - internal static KeyAttributes DeserializeKeyAttributes(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - bool? enabled = default; - long? nbf = default; - long? exp = default; - long? created = default; - long? updated = default; - DeletionRecoveryLevel? recoveryLevel = default; - bool? exportable = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("enabled"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - enabled = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("nbf"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - nbf = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("exp"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - exp = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("created"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - created = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("updated"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - updated = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("recoveryLevel"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - recoveryLevel = new DeletionRecoveryLevel(property.Value.GetString()); - continue; - } - if (property.NameEquals("exportable"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - exportable = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyAttributes( - enabled, - nbf, - exp, - created, - updated, - recoveryLevel, - exportable, - serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" enabled: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(IsEnabled)) - { - builder.Append(" enabled: "); - var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($"{boolValue}"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" nbf: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(NotBefore)) - { - builder.Append(" nbf: "); - builder.AppendLine($"'{NotBefore.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Expires), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" exp: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Expires)) - { - builder.Append(" exp: "); - builder.AppendLine($"'{Expires.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" created: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Created)) - { - builder.Append(" created: "); - builder.AppendLine($"'{Created.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" updated: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Updated)) - { - builder.Append(" updated: "); - builder.AppendLine($"'{Updated.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoveryLevel), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" recoveryLevel: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(RecoveryLevel)) - { - builder.Append(" recoveryLevel: "); - builder.AppendLine($"'{RecoveryLevel.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanExported), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" exportable: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(CanExported)) - { - builder.Append(" exportable: "); - var boolValue = CanExported.Value == true ? "true" : "false"; - builder.AppendLine($"{boolValue}"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyAttributes)} does not support writing '{options.Format}' format."); - } - } - - KeyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyAttributes(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyAttributes)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs deleted file mode 100644 index 2a5e1cc17f496..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyAttributes.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The object attributes managed by the Azure Key Vault service. - public partial class KeyAttributes - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyAttributes() - { - } - - /// Initializes a new instance of . - /// Determines whether or not the object is enabled. - /// Not before date in seconds since 1970-01-01T00:00:00Z. - /// Expiry date in seconds since 1970-01-01T00:00:00Z. - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. - /// Keeps track of any properties unknown to the library. - internal KeyAttributes(bool? isEnabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? canExported, IDictionary serializedAdditionalRawData) - { - IsEnabled = isEnabled; - NotBefore = notBefore; - Expires = expires; - Created = created; - Updated = updated; - RecoveryLevel = recoveryLevel; - CanExported = canExported; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Determines whether or not the object is enabled. - [WirePath("enabled")] - public bool? IsEnabled { get; set; } - /// Not before date in seconds since 1970-01-01T00:00:00Z. - [WirePath("nbf")] - public long? NotBefore { get; set; } - /// Expiry date in seconds since 1970-01-01T00:00:00Z. - [WirePath("exp")] - public long? Expires { get; set; } - /// Creation time in seconds since 1970-01-01T00:00:00Z. - [WirePath("created")] - public long? Created { get; } - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - [WirePath("updated")] - public long? Updated { get; } - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - [WirePath("recoveryLevel")] - public DeletionRecoveryLevel? RecoveryLevel { get; } - /// Indicates if the private key can be exported. - [WirePath("exportable")] - public bool? CanExported { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs deleted file mode 100644 index e1fe381dcee3c..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.Serialization.cs +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - internal partial class KeyListResult : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyListResult)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Value)) - { - writer.WritePropertyName("value"u8); - writer.WriteStartArray(); - foreach (var item in Value) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(NextLink)) - { - writer.WritePropertyName("nextLink"u8); - writer.WriteStringValue(NextLink); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyListResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyListResult(document.RootElement, options); - } - - internal static KeyListResult DeserializeKeyListResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList value = default; - string nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("value"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(KeyVaultKeyData.DeserializeKeyVaultKeyData(item, options)); - } - value = array; - continue; - } - if (property.NameEquals("nextLink"u8)) - { - nextLink = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" value: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(Value)) - { - if (Value.Any()) - { - builder.Append(" value: "); - builder.AppendLine("["); - foreach (var item in Value) - { - BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); - } - builder.AppendLine(" ]"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" nextLink: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(NextLink)) - { - builder.Append(" nextLink: "); - if (NextLink.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{NextLink}'''"); - } - else - { - builder.AppendLine($"'{NextLink}'"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyListResult)} does not support writing '{options.Format}' format."); - } - } - - KeyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyListResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyListResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs deleted file mode 100644 index 923b48e34317e..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyListResult.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The page of keys. - internal partial class KeyListResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - internal KeyListResult() - { - Value = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The key resources. - /// The URL to get the next page of keys. - /// Keeps track of any properties unknown to the library. - internal KeyListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) - { - Value = value; - NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The key resources. - public IReadOnlyList Value { get; } - /// The URL to get the next page of keys. - public string NextLink { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs deleted file mode 100644 index fe126516b4684..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.Serialization.cs +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class KeyProperties : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyProperties)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Attributes)) - { - writer.WritePropertyName("attributes"u8); - writer.WriteObjectValue(Attributes, options); - } - if (Optional.IsDefined(KeyType)) - { - writer.WritePropertyName("kty"u8); - writer.WriteStringValue(KeyType.Value.ToString()); - } - if (Optional.IsCollectionDefined(KeyOps)) - { - writer.WritePropertyName("keyOps"u8); - writer.WriteStartArray(); - foreach (var item in KeyOps) - { - writer.WriteStringValue(item.ToString()); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(KeySize)) - { - writer.WritePropertyName("keySize"u8); - writer.WriteNumberValue(KeySize.Value); - } - if (Optional.IsDefined(CurveName)) - { - writer.WritePropertyName("curveName"u8); - writer.WriteStringValue(CurveName.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(KeyUri)) - { - writer.WritePropertyName("keyUri"u8); - writer.WriteStringValue(KeyUri.AbsoluteUri); - } - if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) - { - writer.WritePropertyName("keyUriWithVersion"u8); - writer.WriteStringValue(KeyUriWithVersion); - } - if (Optional.IsDefined(RotationPolicy)) - { - writer.WritePropertyName("rotationPolicy"u8); - writer.WriteObjectValue(RotationPolicy, options); - } - if (Optional.IsDefined(ReleasePolicy)) - { - writer.WritePropertyName("release_policy"u8); - writer.WriteObjectValue(ReleasePolicy, options); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyProperties)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyProperties(document.RootElement, options); - } - - internal static KeyProperties DeserializeKeyProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - KeyAttributes attributes = default; - JsonWebKeyType? kty = default; - IList keyOps = default; - int? keySize = default; - JsonWebKeyCurveName? curveName = default; - Uri keyUri = default; - string keyUriWithVersion = default; - RotationPolicy rotationPolicy = default; - KeyReleasePolicy releasePolicy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("attributes"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - attributes = KeyAttributes.DeserializeKeyAttributes(property.Value, options); - continue; - } - if (property.NameEquals("kty"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - kty = new JsonWebKeyType(property.Value.GetString()); - continue; - } - if (property.NameEquals("keyOps"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(new JsonWebKeyOperation(item.GetString())); - } - keyOps = array; - continue; - } - if (property.NameEquals("keySize"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keySize = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("curveName"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - curveName = new JsonWebKeyCurveName(property.Value.GetString()); - continue; - } - if (property.NameEquals("keyUri"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keyUri = new Uri(property.Value.GetString()); - continue; - } - if (property.NameEquals("keyUriWithVersion"u8)) - { - keyUriWithVersion = property.Value.GetString(); - continue; - } - if (property.NameEquals("rotationPolicy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rotationPolicy = RotationPolicy.DeserializeRotationPolicy(property.Value, options); - continue; - } - if (property.NameEquals("release_policy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - releasePolicy = KeyReleasePolicy.DeserializeKeyReleasePolicy(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyProperties( - attributes, - kty, - keyOps ?? new ChangeTrackingList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(KeyProperties)} does not support writing '{options.Format}' format."); - } - } - - KeyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyProperties)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs deleted file mode 100644 index 7e765c74da77d..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyProperties.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The properties of the key. - public partial class KeyProperties - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyProperties() - { - KeyOps = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - /// Keeps track of any properties unknown to the library. - internal KeyProperties(KeyAttributes attributes, JsonWebKeyType? keyType, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, RotationPolicy rotationPolicy, KeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) - { - Attributes = attributes; - KeyType = keyType; - KeyOps = keyOps; - KeySize = keySize; - CurveName = curveName; - KeyUri = keyUri; - KeyUriWithVersion = keyUriWithVersion; - RotationPolicy = rotationPolicy; - ReleasePolicy = releasePolicy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The attributes of the key. - [WirePath("attributes")] - public KeyAttributes Attributes { get; set; } - /// The type of the key. For valid values, see JsonWebKeyType. - [WirePath("kty")] - public JsonWebKeyType? KeyType { get; set; } - /// Gets the key ops. - [WirePath("keyOps")] - public IList KeyOps { get; } - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - [WirePath("keySize")] - public int? KeySize { get; set; } - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - [WirePath("curveName")] - public JsonWebKeyCurveName? CurveName { get; set; } - /// The URI to retrieve the current version of the key. - [WirePath("keyUri")] - public Uri KeyUri { get; } - /// The URI to retrieve the specific version of the key. - [WirePath("keyUriWithVersion")] - public string KeyUriWithVersion { get; } - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("rotationPolicy")] - public RotationPolicy RotationPolicy { get; set; } - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("release_policy")] - public KeyReleasePolicy ReleasePolicy { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs deleted file mode 100644 index 818bc23c7934e..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.Serialization.cs +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class KeyReleasePolicy : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(ContentType)) - { - writer.WritePropertyName("contentType"u8); - writer.WriteStringValue(ContentType); - } - if (Optional.IsDefined(Data)) - { - writer.WritePropertyName("data"u8); - writer.WriteBase64StringValue(Data, "U"); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyReleasePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyReleasePolicy(document.RootElement, options); - } - - internal static KeyReleasePolicy DeserializeKeyReleasePolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string contentType = default; - byte[] data = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("contentType"u8)) - { - contentType = property.Value.GetString(); - continue; - } - if (property.NameEquals("data"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - data = property.Value.GetBytesFromBase64("U"); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyReleasePolicy(contentType, data, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentType), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" contentType: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ContentType)) - { - builder.Append(" contentType: "); - if (ContentType.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{ContentType}'''"); - } - else - { - builder.AppendLine($"'{ContentType}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Data), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" data: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Data)) - { - builder.Append(" data: "); - builder.AppendLine($"'{Data.ToString()}'"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support writing '{options.Format}' format."); - } - } - - KeyReleasePolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyReleasePolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyReleasePolicy)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs deleted file mode 100644 index 1074b9653e7c2..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyReleasePolicy.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The KeyReleasePolicy. - public partial class KeyReleasePolicy - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyReleasePolicy() - { - } - - /// Initializes a new instance of . - /// Content type and version of key release policy. - /// Blob encoding the policy rules under which the key can be released. - /// Keeps track of any properties unknown to the library. - internal KeyReleasePolicy(string contentType, byte[] data, IDictionary serializedAdditionalRawData) - { - ContentType = contentType; - Data = data; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Content type and version of key release policy. - [WirePath("contentType")] - public string ContentType { get; set; } - /// Blob encoding the policy rules under which the key can be released. - [WirePath("data")] - public byte[] Data { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs deleted file mode 100644 index 65385074f5ecf..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.Serialization.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - internal partial class KeyRotationAction : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyRotationAction)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(ActionType)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ActionType.Value.ToSerialString()); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyRotationAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyRotationAction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyRotationAction(document.RootElement, options); - } - - internal static KeyRotationAction DeserializeKeyRotationAction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - KeyRotationPolicyActionType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - type = property.Value.GetString().ToKeyRotationPolicyActionType(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyRotationAction(type, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionType), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" type: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ActionType)) - { - builder.Append(" type: "); - builder.AppendLine($"'{ActionType.Value.ToSerialString()}'"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyRotationAction)} does not support writing '{options.Format}' format."); - } - } - - KeyRotationAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyRotationAction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyRotationAction)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs deleted file mode 100644 index b72cbb9c25f41..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationAction.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The KeyRotationAction. - internal partial class KeyRotationAction - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyRotationAction() - { - } - - /// Initializes a new instance of . - /// The type of action. - /// Keeps track of any properties unknown to the library. - internal KeyRotationAction(KeyRotationPolicyActionType? actionType, IDictionary serializedAdditionalRawData) - { - ActionType = actionType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The type of action. - [WirePath("type")] - public KeyRotationPolicyActionType? ActionType { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs deleted file mode 100644 index 2f6a46a5dea2e..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.Serialization.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.ResourceManager.KeyVault.Models -{ - internal static partial class KeyRotationPolicyActionTypeExtensions - { - public static string ToSerialString(this KeyRotationPolicyActionType value) => value switch - { - KeyRotationPolicyActionType.Rotate => "rotate", - KeyRotationPolicyActionType.Notify => "notify", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown KeyRotationPolicyActionType value.") - }; - - public static KeyRotationPolicyActionType ToKeyRotationPolicyActionType(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "rotate")) return KeyRotationPolicyActionType.Rotate; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "notify")) return KeyRotationPolicyActionType.Notify; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown KeyRotationPolicyActionType value."); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs deleted file mode 100644 index 1b13ec69f697d..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyActionType.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The type of action. - public enum KeyRotationPolicyActionType - { - /// rotate. - Rotate, - /// notify. - Notify - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs deleted file mode 100644 index 28d61fa1720fa..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.Serialization.cs +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class KeyRotationPolicyAttributes : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(Created)) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(Created.Value); - } - if (options.Format != "W" && Optional.IsDefined(Updated)) - { - writer.WritePropertyName("updated"u8); - writer.WriteNumberValue(Updated.Value); - } - if (Optional.IsDefined(ExpiryTime)) - { - writer.WritePropertyName("expiryTime"u8); - writer.WriteStringValue(ExpiryTime); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyRotationPolicyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyRotationPolicyAttributes(document.RootElement, options); - } - - internal static KeyRotationPolicyAttributes DeserializeKeyRotationPolicyAttributes(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - long? created = default; - long? updated = default; - string expiryTime = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("created"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - created = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("updated"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - updated = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("expiryTime"u8)) - { - expiryTime = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" created: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Created)) - { - builder.Append(" created: "); - builder.AppendLine($"'{Created.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" updated: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Updated)) - { - builder.Append(" updated: "); - builder.AppendLine($"'{Updated.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpiryTime), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" expiryTime: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ExpiryTime)) - { - builder.Append(" expiryTime: "); - if (ExpiryTime.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{ExpiryTime}'''"); - } - else - { - builder.AppendLine($"'{ExpiryTime}'"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support writing '{options.Format}' format."); - } - } - - KeyRotationPolicyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyRotationPolicyAttributes(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyRotationPolicyAttributes)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs deleted file mode 100644 index 106a305064a2b..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationPolicyAttributes.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The KeyRotationPolicyAttributes. - public partial class KeyRotationPolicyAttributes - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyRotationPolicyAttributes() - { - } - - /// Initializes a new instance of . - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. - /// Keeps track of any properties unknown to the library. - internal KeyRotationPolicyAttributes(long? created, long? updated, string expiryTime, IDictionary serializedAdditionalRawData) - { - Created = created; - Updated = updated; - ExpiryTime = expiryTime; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Creation time in seconds since 1970-01-01T00:00:00Z. - [WirePath("created")] - public long? Created { get; } - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - [WirePath("updated")] - public long? Updated { get; } - /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. - [WirePath("expiryTime")] - public string ExpiryTime { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs deleted file mode 100644 index ac11fb15f13e6..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.Serialization.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class KeyRotationTrigger : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(TimeAfterCreate)) - { - writer.WritePropertyName("timeAfterCreate"u8); - writer.WriteStringValue(TimeAfterCreate); - } - if (Optional.IsDefined(TimeBeforeExpiry)) - { - writer.WritePropertyName("timeBeforeExpiry"u8); - writer.WriteStringValue(TimeBeforeExpiry); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - KeyRotationTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeKeyRotationTrigger(document.RootElement, options); - } - - internal static KeyRotationTrigger DeserializeKeyRotationTrigger(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string timeAfterCreate = default; - string timeBeforeExpiry = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("timeAfterCreate"u8)) - { - timeAfterCreate = property.Value.GetString(); - continue; - } - if (property.NameEquals("timeBeforeExpiry"u8)) - { - timeBeforeExpiry = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new KeyRotationTrigger(timeAfterCreate, timeBeforeExpiry, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeAfterCreate), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" timeAfterCreate: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(TimeAfterCreate)) - { - builder.Append(" timeAfterCreate: "); - if (TimeAfterCreate.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{TimeAfterCreate}'''"); - } - else - { - builder.AppendLine($"'{TimeAfterCreate}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeBeforeExpiry), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" timeBeforeExpiry: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(TimeBeforeExpiry)) - { - builder.Append(" timeBeforeExpiry: "); - if (TimeBeforeExpiry.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{TimeBeforeExpiry}'''"); - } - else - { - builder.AppendLine($"'{TimeBeforeExpiry}'"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support writing '{options.Format}' format."); - } - } - - KeyRotationTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeKeyRotationTrigger(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(KeyRotationTrigger)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs deleted file mode 100644 index 03244e2c23145..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/KeyRotationTrigger.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The KeyRotationTrigger. - public partial class KeyRotationTrigger - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public KeyRotationTrigger() - { - } - - /// Initializes a new instance of . - /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - /// Keeps track of any properties unknown to the library. - internal KeyRotationTrigger(string timeAfterCreate, string timeBeforeExpiry, IDictionary serializedAdditionalRawData) - { - TimeAfterCreate = timeAfterCreate; - TimeBeforeExpiry = timeBeforeExpiry; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - [WirePath("timeAfterCreate")] - public string TimeAfterCreate { get; set; } - /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - [WirePath("timeBeforeExpiry")] - public string TimeBeforeExpiry { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs deleted file mode 100644 index 2cedba0792e4c..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.Serialization.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class LifetimeAction : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(LifetimeAction)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Trigger)) - { - writer.WritePropertyName("trigger"u8); - writer.WriteObjectValue(Trigger, options); - } - if (Optional.IsDefined(Action)) - { - writer.WritePropertyName("action"u8); - writer.WriteObjectValue(Action, options); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - LifetimeAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(LifetimeAction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeLifetimeAction(document.RootElement, options); - } - - internal static LifetimeAction DeserializeLifetimeAction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - KeyRotationTrigger trigger = default; - KeyRotationAction action = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("trigger"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - trigger = KeyRotationTrigger.DeserializeKeyRotationTrigger(property.Value, options); - continue; - } - if (property.NameEquals("action"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - action = KeyRotationAction.DeserializeKeyRotationAction(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new LifetimeAction(trigger, action, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Trigger), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" trigger: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Trigger)) - { - builder.Append(" trigger: "); - BicepSerializationHelpers.AppendChildObject(builder, Trigger, options, 2, false, " trigger: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("ActionType", out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" action: "); - builder.AppendLine("{"); - builder.Append(" type: "); - builder.AppendLine(propertyOverride); - builder.AppendLine(" }"); - } - else - { - if (Optional.IsDefined(Action)) - { - builder.Append(" action: "); - BicepSerializationHelpers.AppendChildObject(builder, Action, options, 2, false, " action: "); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(LifetimeAction)} does not support writing '{options.Format}' format."); - } - } - - LifetimeAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeLifetimeAction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(LifetimeAction)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs deleted file mode 100644 index 458d6777e4f5c..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/LifetimeAction.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The LifetimeAction. - public partial class LifetimeAction - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public LifetimeAction() - { - } - - /// Initializes a new instance of . - /// The trigger of key rotation policy lifetimeAction. - /// The action of key rotation policy lifetimeAction. - /// Keeps track of any properties unknown to the library. - internal LifetimeAction(KeyRotationTrigger trigger, KeyRotationAction action, IDictionary serializedAdditionalRawData) - { - Trigger = trigger; - Action = action; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The trigger of key rotation policy lifetimeAction. - [WirePath("trigger")] - public KeyRotationTrigger Trigger { get; set; } - /// The action of key rotation policy lifetimeAction. - internal KeyRotationAction Action { get; set; } - /// The type of action. - [WirePath("action.type")] - public KeyRotationPolicyActionType? ActionType - { - get => Action is null ? default : Action.ActionType; - set - { - if (Action is null) - Action = new KeyRotationAction(); - Action.ActionType = value; - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs deleted file mode 100644 index 115b6bd71bf50..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHSMKeyCreateOrUpdateContent : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHSMKeyCreateOrUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHSMKeyCreateOrUpdateContent(document.RootElement, options); - } - - internal static ManagedHSMKeyCreateOrUpdateContent DeserializeManagedHSMKeyCreateOrUpdateContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary tags = default; - ManagedHsmKeyProperties properties = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tags"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; - continue; - } - if (property.NameEquals("properties"u8)) - { - properties = ManagedHsmKeyProperties.DeserializeManagedHsmKeyProperties(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHSMKeyCreateOrUpdateContent(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support writing '{options.Format}' format."); - } - } - - ManagedHSMKeyCreateOrUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHSMKeyCreateOrUpdateContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHSMKeyCreateOrUpdateContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs deleted file mode 100644 index 9bb011b0ffe6a..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHSMKeyCreateOrUpdateContent.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The parameters used to create a key. - public partial class ManagedHSMKeyCreateOrUpdateContent - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The properties of the key to be created. - /// is null. - public ManagedHSMKeyCreateOrUpdateContent(ManagedHsmKeyProperties properties) - { - Argument.AssertNotNull(properties, nameof(properties)); - - Tags = new ChangeTrackingDictionary(); - Properties = properties; - } - - /// Initializes a new instance of . - /// The tags that will be assigned to the key. - /// The properties of the key to be created. - /// Keeps track of any properties unknown to the library. - internal ManagedHSMKeyCreateOrUpdateContent(IDictionary tags, ManagedHsmKeyProperties properties, IDictionary serializedAdditionalRawData) - { - Tags = tags; - Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ManagedHSMKeyCreateOrUpdateContent() - { - } - - /// The tags that will be assigned to the key. - [WirePath("tags")] - public IDictionary Tags { get; } - /// The properties of the key to be created. - [WirePath("properties")] - public ManagedHsmKeyProperties Properties { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs deleted file mode 100644 index e9857d553e782..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.Serialization.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - internal partial class ManagedHsmAction : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(KeyRotationPolicyActionType)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(KeyRotationPolicyActionType.Value.ToSerialString()); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmAction(document.RootElement, options); - } - - internal static ManagedHsmAction DeserializeManagedHsmAction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - KeyRotationPolicyActionType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - type = property.Value.GetString().ToKeyRotationPolicyActionType(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmAction(type, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyRotationPolicyActionType), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" type: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyRotationPolicyActionType)) - { - builder.Append(" type: "); - builder.AppendLine($"'{KeyRotationPolicyActionType.Value.ToSerialString()}'"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmAction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmAction)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs deleted file mode 100644 index 55c59972391ea..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmAction.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The ManagedHsmAction. - internal partial class ManagedHsmAction - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmAction() - { - } - - /// Initializes a new instance of . - /// The type of action. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmAction(KeyRotationPolicyActionType? keyRotationPolicyActionType, IDictionary serializedAdditionalRawData) - { - KeyRotationPolicyActionType = keyRotationPolicyActionType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The type of action. - [WirePath("type")] - public KeyRotationPolicyActionType? KeyRotationPolicyActionType { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs deleted file mode 100644 index 05122d953c8a2..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.Serialization.cs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmKeyAttributes : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(IsEnabled)) - { - writer.WritePropertyName("enabled"u8); - writer.WriteBooleanValue(IsEnabled.Value); - } - if (Optional.IsDefined(NotBefore)) - { - writer.WritePropertyName("nbf"u8); - writer.WriteNumberValue(NotBefore.Value); - } - if (Optional.IsDefined(Expires)) - { - writer.WritePropertyName("exp"u8); - writer.WriteNumberValue(Expires.Value); - } - if (options.Format != "W" && Optional.IsDefined(Created)) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(Created.Value); - } - if (options.Format != "W" && Optional.IsDefined(Updated)) - { - writer.WritePropertyName("updated"u8); - writer.WriteNumberValue(Updated.Value); - } - if (options.Format != "W" && Optional.IsDefined(RecoveryLevel)) - { - writer.WritePropertyName("recoveryLevel"u8); - writer.WriteStringValue(RecoveryLevel.Value.ToString()); - } - if (Optional.IsDefined(CanExported)) - { - writer.WritePropertyName("exportable"u8); - writer.WriteBooleanValue(CanExported.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmKeyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmKeyAttributes(document.RootElement, options); - } - - internal static ManagedHsmKeyAttributes DeserializeManagedHsmKeyAttributes(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - bool? enabled = default; - long? nbf = default; - long? exp = default; - long? created = default; - long? updated = default; - DeletionRecoveryLevel? recoveryLevel = default; - bool? exportable = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("enabled"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - enabled = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("nbf"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - nbf = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("exp"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - exp = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("created"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - created = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("updated"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - updated = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("recoveryLevel"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - recoveryLevel = new DeletionRecoveryLevel(property.Value.GetString()); - continue; - } - if (property.NameEquals("exportable"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - exportable = property.Value.GetBoolean(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmKeyAttributes( - enabled, - nbf, - exp, - created, - updated, - recoveryLevel, - exportable, - serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" enabled: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(IsEnabled)) - { - builder.Append(" enabled: "); - var boolValue = IsEnabled.Value == true ? "true" : "false"; - builder.AppendLine($"{boolValue}"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NotBefore), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" nbf: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(NotBefore)) - { - builder.Append(" nbf: "); - builder.AppendLine($"'{NotBefore.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Expires), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" exp: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Expires)) - { - builder.Append(" exp: "); - builder.AppendLine($"'{Expires.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" created: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Created)) - { - builder.Append(" created: "); - builder.AppendLine($"'{Created.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" updated: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Updated)) - { - builder.Append(" updated: "); - builder.AppendLine($"'{Updated.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecoveryLevel), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" recoveryLevel: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(RecoveryLevel)) - { - builder.Append(" recoveryLevel: "); - builder.AppendLine($"'{RecoveryLevel.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CanExported), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" exportable: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(CanExported)) - { - builder.Append(" exportable: "); - var boolValue = CanExported.Value == true ? "true" : "false"; - builder.AppendLine($"{boolValue}"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmKeyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmKeyAttributes(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyAttributes)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs deleted file mode 100644 index 8f52a3fcf7ff4..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyAttributes.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The object attributes managed by the Azure Key Vault service. - public partial class ManagedHsmKeyAttributes - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmKeyAttributes() - { - } - - /// Initializes a new instance of . - /// Determines whether or not the object is enabled. - /// Not before date in seconds since 1970-01-01T00:00:00Z. - /// Expiry date in seconds since 1970-01-01T00:00:00Z. - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - /// Indicates if the private key can be exported. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyAttributes(bool? isEnabled, long? notBefore, long? expires, long? created, long? updated, DeletionRecoveryLevel? recoveryLevel, bool? canExported, IDictionary serializedAdditionalRawData) - { - IsEnabled = isEnabled; - NotBefore = notBefore; - Expires = expires; - Created = created; - Updated = updated; - RecoveryLevel = recoveryLevel; - CanExported = canExported; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Determines whether or not the object is enabled. - [WirePath("enabled")] - public bool? IsEnabled { get; set; } - /// Not before date in seconds since 1970-01-01T00:00:00Z. - [WirePath("nbf")] - public long? NotBefore { get; set; } - /// Expiry date in seconds since 1970-01-01T00:00:00Z. - [WirePath("exp")] - public long? Expires { get; set; } - /// Creation time in seconds since 1970-01-01T00:00:00Z. - [WirePath("created")] - public long? Created { get; } - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - [WirePath("updated")] - public long? Updated { get; } - /// The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. - [WirePath("recoveryLevel")] - public DeletionRecoveryLevel? RecoveryLevel { get; } - /// Indicates if the private key can be exported. - [WirePath("exportable")] - public bool? CanExported { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs deleted file mode 100644 index dba0296c27479..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.Serialization.cs +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - internal partial class ManagedHsmKeyListResult : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Value)) - { - writer.WritePropertyName("value"u8); - writer.WriteStartArray(); - foreach (var item in Value) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(NextLink)) - { - writer.WritePropertyName("nextLink"u8); - writer.WriteStringValue(NextLink); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmKeyListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmKeyListResult(document.RootElement, options); - } - - internal static ManagedHsmKeyListResult DeserializeManagedHsmKeyListResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList value = default; - string nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("value"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ManagedHsmKeyData.DeserializeManagedHsmKeyData(item, options)); - } - value = array; - continue; - } - if (property.NameEquals("nextLink"u8)) - { - nextLink = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmKeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" value: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(Value)) - { - if (Value.Any()) - { - builder.Append(" value: "); - builder.AppendLine("["); - foreach (var item in Value) - { - BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); - } - builder.AppendLine(" ]"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" nextLink: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(NextLink)) - { - builder.Append(" nextLink: "); - if (NextLink.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{NextLink}'''"); - } - else - { - builder.AppendLine($"'{NextLink}'"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmKeyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmKeyListResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyListResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs deleted file mode 100644 index 5cd48f9b6d32b..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyListResult.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The page of keys. - internal partial class ManagedHsmKeyListResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - internal ManagedHsmKeyListResult() - { - Value = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The key resources. - /// The URL to get the next page of keys. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) - { - Value = value; - NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The key resources. - public IReadOnlyList Value { get; } - /// The URL to get the next page of keys. - public string NextLink { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs deleted file mode 100644 index fa3a731f2ad51..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.Serialization.cs +++ /dev/null @@ -1,432 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmKeyProperties : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Attributes)) - { - writer.WritePropertyName("attributes"u8); - writer.WriteObjectValue(Attributes, options); - } - if (Optional.IsDefined(KeyType)) - { - writer.WritePropertyName("kty"u8); - writer.WriteStringValue(KeyType.Value.ToString()); - } - if (Optional.IsCollectionDefined(KeyOps)) - { - writer.WritePropertyName("keyOps"u8); - writer.WriteStartArray(); - foreach (var item in KeyOps) - { - writer.WriteStringValue(item.ToString()); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(KeySize)) - { - writer.WritePropertyName("keySize"u8); - writer.WriteNumberValue(KeySize.Value); - } - if (Optional.IsDefined(CurveName)) - { - writer.WritePropertyName("curveName"u8); - writer.WriteStringValue(CurveName.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(KeyUri)) - { - writer.WritePropertyName("keyUri"u8); - writer.WriteStringValue(KeyUri.AbsoluteUri); - } - if (options.Format != "W" && Optional.IsDefined(KeyUriWithVersion)) - { - writer.WritePropertyName("keyUriWithVersion"u8); - writer.WriteStringValue(KeyUriWithVersion); - } - if (Optional.IsDefined(RotationPolicy)) - { - writer.WritePropertyName("rotationPolicy"u8); - writer.WriteObjectValue(RotationPolicy, options); - } - if (Optional.IsDefined(ReleasePolicy)) - { - writer.WritePropertyName("release_policy"u8); - writer.WriteObjectValue(ReleasePolicy, options); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmKeyProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmKeyProperties(document.RootElement, options); - } - - internal static ManagedHsmKeyProperties DeserializeManagedHsmKeyProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ManagedHsmKeyAttributes attributes = default; - JsonWebKeyType? kty = default; - IList keyOps = default; - int? keySize = default; - JsonWebKeyCurveName? curveName = default; - Uri keyUri = default; - string keyUriWithVersion = default; - ManagedHsmRotationPolicy rotationPolicy = default; - ManagedHsmKeyReleasePolicy releasePolicy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("attributes"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - attributes = ManagedHsmKeyAttributes.DeserializeManagedHsmKeyAttributes(property.Value, options); - continue; - } - if (property.NameEquals("kty"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - kty = new JsonWebKeyType(property.Value.GetString()); - continue; - } - if (property.NameEquals("keyOps"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(new JsonWebKeyOperation(item.GetString())); - } - keyOps = array; - continue; - } - if (property.NameEquals("keySize"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keySize = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("curveName"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - curveName = new JsonWebKeyCurveName(property.Value.GetString()); - continue; - } - if (property.NameEquals("keyUri"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - keyUri = new Uri(property.Value.GetString()); - continue; - } - if (property.NameEquals("keyUriWithVersion"u8)) - { - keyUriWithVersion = property.Value.GetString(); - continue; - } - if (property.NameEquals("rotationPolicy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rotationPolicy = ManagedHsmRotationPolicy.DeserializeManagedHsmRotationPolicy(property.Value, options); - continue; - } - if (property.NameEquals("release_policy"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - releasePolicy = ManagedHsmKeyReleasePolicy.DeserializeManagedHsmKeyReleasePolicy(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmKeyProperties( - attributes, - kty, - keyOps ?? new ChangeTrackingList(), - keySize, - curveName, - keyUri, - keyUriWithVersion, - rotationPolicy, - releasePolicy, - serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" attributes: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Attributes)) - { - builder.Append(" attributes: "); - BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyType), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" kty: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyType)) - { - builder.Append(" kty: "); - builder.AppendLine($"'{KeyType.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyOps), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyOps: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(KeyOps)) - { - if (KeyOps.Any()) - { - builder.Append(" keyOps: "); - builder.AppendLine("["); - foreach (var item in KeyOps) - { - builder.AppendLine($" '{item.ToString()}'"); - } - builder.AppendLine(" ]"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySize), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keySize: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeySize)) - { - builder.Append(" keySize: "); - builder.AppendLine($"{KeySize.Value}"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurveName), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" curveName: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(CurveName)) - { - builder.Append(" curveName: "); - builder.AppendLine($"'{CurveName.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUri), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyUri: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyUri)) - { - builder.Append(" keyUri: "); - builder.AppendLine($"'{KeyUri.AbsoluteUri}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyUriWithVersion), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" keyUriWithVersion: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(KeyUriWithVersion)) - { - builder.Append(" keyUriWithVersion: "); - if (KeyUriWithVersion.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{KeyUriWithVersion}'''"); - } - else - { - builder.AppendLine($"'{KeyUriWithVersion}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RotationPolicy), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" rotationPolicy: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(RotationPolicy)) - { - builder.Append(" rotationPolicy: "); - BicepSerializationHelpers.AppendChildObject(builder, RotationPolicy, options, 2, false, " rotationPolicy: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReleasePolicy), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" release_policy: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ReleasePolicy)) - { - builder.Append(" release_policy: "); - BicepSerializationHelpers.AppendChildObject(builder, ReleasePolicy, options, 2, false, " release_policy: "); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmKeyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmKeyProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyProperties)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs deleted file mode 100644 index c119708a96f81..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyProperties.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The properties of the key. - public partial class ManagedHsmKeyProperties - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmKeyProperties() - { - KeyOps = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The attributes of the key. - /// The type of the key. For valid values, see JsonWebKeyType. - /// - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - /// The URI to retrieve the current version of the key. - /// The URI to retrieve the specific version of the key. - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyProperties(ManagedHsmKeyAttributes attributes, JsonWebKeyType? keyType, IList keyOps, int? keySize, JsonWebKeyCurveName? curveName, Uri keyUri, string keyUriWithVersion, ManagedHsmRotationPolicy rotationPolicy, ManagedHsmKeyReleasePolicy releasePolicy, IDictionary serializedAdditionalRawData) - { - Attributes = attributes; - KeyType = keyType; - KeyOps = keyOps; - KeySize = keySize; - CurveName = curveName; - KeyUri = keyUri; - KeyUriWithVersion = keyUriWithVersion; - RotationPolicy = rotationPolicy; - ReleasePolicy = releasePolicy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The attributes of the key. - [WirePath("attributes")] - public ManagedHsmKeyAttributes Attributes { get; set; } - /// The type of the key. For valid values, see JsonWebKeyType. - [WirePath("kty")] - public JsonWebKeyType? KeyType { get; set; } - /// Gets the key ops. - [WirePath("keyOps")] - public IList KeyOps { get; } - /// The key size in bits. For example: 2048, 3072, or 4096 for RSA. - [WirePath("keySize")] - public int? KeySize { get; set; } - /// The elliptic curve name. For valid values, see JsonWebKeyCurveName. - [WirePath("curveName")] - public JsonWebKeyCurveName? CurveName { get; set; } - /// The URI to retrieve the current version of the key. - [WirePath("keyUri")] - public Uri KeyUri { get; } - /// The URI to retrieve the specific version of the key. - [WirePath("keyUriWithVersion")] - public string KeyUriWithVersion { get; } - /// Key rotation policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("rotationPolicy")] - public ManagedHsmRotationPolicy RotationPolicy { get; set; } - /// Key release policy in response. It will be used for both output and input. Omitted if empty. - [WirePath("release_policy")] - public ManagedHsmKeyReleasePolicy ReleasePolicy { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs deleted file mode 100644 index ea74b060a6562..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.Serialization.cs +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmKeyReleasePolicy : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(ContentType)) - { - writer.WritePropertyName("contentType"u8); - writer.WriteStringValue(ContentType); - } - if (Optional.IsDefined(Data)) - { - writer.WritePropertyName("data"u8); - writer.WriteBase64StringValue(Data, "U"); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmKeyReleasePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmKeyReleasePolicy(document.RootElement, options); - } - - internal static ManagedHsmKeyReleasePolicy DeserializeManagedHsmKeyReleasePolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string contentType = default; - byte[] data = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("contentType"u8)) - { - contentType = property.Value.GetString(); - continue; - } - if (property.NameEquals("data"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - data = property.Value.GetBytesFromBase64("U"); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmKeyReleasePolicy(contentType, data, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentType), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" contentType: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ContentType)) - { - builder.Append(" contentType: "); - if (ContentType.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{ContentType}'''"); - } - else - { - builder.AppendLine($"'{ContentType}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Data), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" data: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Data)) - { - builder.Append(" data: "); - builder.AppendLine($"'{Data.ToString()}'"); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmKeyReleasePolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmKeyReleasePolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyReleasePolicy)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs deleted file mode 100644 index 627f59b4ecc82..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyReleasePolicy.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The ManagedHsmKeyReleasePolicy. - public partial class ManagedHsmKeyReleasePolicy - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmKeyReleasePolicy() - { - } - - /// Initializes a new instance of . - /// Content type and version of key release policy. - /// Blob encoding the policy rules under which the key can be released. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyReleasePolicy(string contentType, byte[] data, IDictionary serializedAdditionalRawData) - { - ContentType = contentType; - Data = data; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Content type and version of key release policy. - [WirePath("contentType")] - public string ContentType { get; set; } - /// Blob encoding the policy rules under which the key can be released. - [WirePath("data")] - public byte[] Data { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs deleted file mode 100644 index 00486526c6232..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.Serialization.cs +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmKeyRotationPolicyAttributes : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(Created)) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(Created.Value); - } - if (options.Format != "W" && Optional.IsDefined(Updated)) - { - writer.WritePropertyName("updated"u8); - writer.WriteNumberValue(Updated.Value); - } - if (Optional.IsDefined(ExpiryTime)) - { - writer.WritePropertyName("expiryTime"u8); - writer.WriteStringValue(ExpiryTime); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmKeyRotationPolicyAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmKeyRotationPolicyAttributes(document.RootElement, options); - } - - internal static ManagedHsmKeyRotationPolicyAttributes DeserializeManagedHsmKeyRotationPolicyAttributes(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - long? created = default; - long? updated = default; - string expiryTime = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("created"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - created = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("updated"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - updated = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("expiryTime"u8)) - { - expiryTime = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmKeyRotationPolicyAttributes(created, updated, expiryTime, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Created), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" created: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Created)) - { - builder.Append(" created: "); - builder.AppendLine($"'{Created.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Updated), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" updated: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Updated)) - { - builder.Append(" updated: "); - builder.AppendLine($"'{Updated.Value.ToString()}'"); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpiryTime), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" expiryTime: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(ExpiryTime)) - { - builder.Append(" expiryTime: "); - if (ExpiryTime.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{ExpiryTime}'''"); - } - else - { - builder.AppendLine($"'{ExpiryTime}'"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmKeyRotationPolicyAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmKeyRotationPolicyAttributes(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmKeyRotationPolicyAttributes)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs deleted file mode 100644 index ec6ef95cff4f1..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmKeyRotationPolicyAttributes.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The ManagedHsmKeyRotationPolicyAttributes. - public partial class ManagedHsmKeyRotationPolicyAttributes - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmKeyRotationPolicyAttributes() - { - } - - /// Initializes a new instance of . - /// Creation time in seconds since 1970-01-01T00:00:00Z. - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmKeyRotationPolicyAttributes(long? created, long? updated, string expiryTime, IDictionary serializedAdditionalRawData) - { - Created = created; - Updated = updated; - ExpiryTime = expiryTime; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Creation time in seconds since 1970-01-01T00:00:00Z. - [WirePath("created")] - public long? Created { get; } - /// Last updated time in seconds since 1970-01-01T00:00:00Z. - [WirePath("updated")] - public long? Updated { get; } - /// The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. - [WirePath("expiryTime")] - public string ExpiryTime { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs deleted file mode 100644 index 0f43c6083348e..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.Serialization.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmLifetimeAction : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Trigger)) - { - writer.WritePropertyName("trigger"u8); - writer.WriteObjectValue(Trigger, options); - } - if (Optional.IsDefined(Action)) - { - writer.WritePropertyName("action"u8); - writer.WriteObjectValue(Action, options); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmLifetimeAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmLifetimeAction(document.RootElement, options); - } - - internal static ManagedHsmLifetimeAction DeserializeManagedHsmLifetimeAction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ManagedHsmTrigger trigger = default; - ManagedHsmAction action = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("trigger"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - trigger = ManagedHsmTrigger.DeserializeManagedHsmTrigger(property.Value, options); - continue; - } - if (property.NameEquals("action"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - action = ManagedHsmAction.DeserializeManagedHsmAction(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmLifetimeAction(trigger, action, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Trigger), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" trigger: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Trigger)) - { - builder.Append(" trigger: "); - BicepSerializationHelpers.AppendChildObject(builder, Trigger, options, 2, false, " trigger: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("KeyRotationPolicyActionType", out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" action: "); - builder.AppendLine("{"); - builder.Append(" type: "); - builder.AppendLine(propertyOverride); - builder.AppendLine(" }"); - } - else - { - if (Optional.IsDefined(Action)) - { - builder.Append(" action: "); - BicepSerializationHelpers.AppendChildObject(builder, Action, options, 2, false, " action: "); - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmLifetimeAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmLifetimeAction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmLifetimeAction)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs deleted file mode 100644 index 6165098284c61..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmLifetimeAction.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The ManagedHsmLifetimeAction. - public partial class ManagedHsmLifetimeAction - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmLifetimeAction() - { - } - - /// Initializes a new instance of . - /// The trigger of key rotation policy lifetimeAction. - /// The action of key rotation policy lifetimeAction. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmLifetimeAction(ManagedHsmTrigger trigger, ManagedHsmAction action, IDictionary serializedAdditionalRawData) - { - Trigger = trigger; - Action = action; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The trigger of key rotation policy lifetimeAction. - [WirePath("trigger")] - public ManagedHsmTrigger Trigger { get; set; } - /// The action of key rotation policy lifetimeAction. - internal ManagedHsmAction Action { get; set; } - /// The type of action. - [WirePath("action.type")] - public KeyRotationPolicyActionType? KeyRotationPolicyActionType - { - get => Action is null ? default : Action.KeyRotationPolicyActionType; - set - { - if (Action is null) - Action = new ManagedHsmAction(); - Action.KeyRotationPolicyActionType = value; - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs deleted file mode 100644 index a30f50e0a39ec..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.Serialization.cs +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmRotationPolicy : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Attributes)) - { - writer.WritePropertyName("attributes"u8); - writer.WriteObjectValue(Attributes, options); - } - if (Optional.IsCollectionDefined(LifetimeActions)) - { - writer.WritePropertyName("lifetimeActions"u8); - writer.WriteStartArray(); - foreach (var item in LifetimeActions) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmRotationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmRotationPolicy(document.RootElement, options); - } - - internal static ManagedHsmRotationPolicy DeserializeManagedHsmRotationPolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ManagedHsmKeyRotationPolicyAttributes attributes = default; - IList lifetimeActions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("attributes"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - attributes = ManagedHsmKeyRotationPolicyAttributes.DeserializeManagedHsmKeyRotationPolicyAttributes(property.Value, options); - continue; - } - if (property.NameEquals("lifetimeActions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ManagedHsmLifetimeAction.DeserializeManagedHsmLifetimeAction(item, options)); - } - lifetimeActions = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmRotationPolicy(attributes, lifetimeActions ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" attributes: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Attributes)) - { - builder.Append(" attributes: "); - BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LifetimeActions), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" lifetimeActions: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(LifetimeActions)) - { - if (LifetimeActions.Any()) - { - builder.Append(" lifetimeActions: "); - builder.AppendLine("["); - foreach (var item in LifetimeActions) - { - BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " lifetimeActions: "); - } - builder.AppendLine(" ]"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmRotationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmRotationPolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmRotationPolicy)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs deleted file mode 100644 index 5ed549348ac4f..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmRotationPolicy.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The ManagedHsmRotationPolicy. - public partial class ManagedHsmRotationPolicy - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmRotationPolicy() - { - LifetimeActions = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The attributes of key rotation policy. - /// The lifetimeActions for key rotation action. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmRotationPolicy(ManagedHsmKeyRotationPolicyAttributes attributes, IList lifetimeActions, IDictionary serializedAdditionalRawData) - { - Attributes = attributes; - LifetimeActions = lifetimeActions; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The attributes of key rotation policy. - [WirePath("attributes")] - public ManagedHsmKeyRotationPolicyAttributes Attributes { get; set; } - /// The lifetimeActions for key rotation action. - [WirePath("lifetimeActions")] - public IList LifetimeActions { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs deleted file mode 100644 index db04428691550..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.Serialization.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class ManagedHsmTrigger : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(TimeAfterCreate)) - { - writer.WritePropertyName("timeAfterCreate"u8); - writer.WriteStringValue(TimeAfterCreate); - } - if (Optional.IsDefined(TimeBeforeExpiry)) - { - writer.WritePropertyName("timeBeforeExpiry"u8); - writer.WriteStringValue(TimeBeforeExpiry); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - ManagedHsmTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeManagedHsmTrigger(document.RootElement, options); - } - - internal static ManagedHsmTrigger DeserializeManagedHsmTrigger(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string timeAfterCreate = default; - string timeBeforeExpiry = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("timeAfterCreate"u8)) - { - timeAfterCreate = property.Value.GetString(); - continue; - } - if (property.NameEquals("timeBeforeExpiry"u8)) - { - timeBeforeExpiry = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ManagedHsmTrigger(timeAfterCreate, timeBeforeExpiry, serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeAfterCreate), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" timeAfterCreate: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(TimeAfterCreate)) - { - builder.Append(" timeAfterCreate: "); - if (TimeAfterCreate.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{TimeAfterCreate}'''"); - } - else - { - builder.AppendLine($"'{TimeAfterCreate}'"); - } - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeBeforeExpiry), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" timeBeforeExpiry: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(TimeBeforeExpiry)) - { - builder.Append(" timeBeforeExpiry: "); - if (TimeBeforeExpiry.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{TimeBeforeExpiry}'''"); - } - else - { - builder.AppendLine($"'{TimeBeforeExpiry}'"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support writing '{options.Format}' format."); - } - } - - ManagedHsmTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeManagedHsmTrigger(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ManagedHsmTrigger)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs deleted file mode 100644 index 7099a9da7eed7..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/ManagedHsmTrigger.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The ManagedHsmTrigger. - public partial class ManagedHsmTrigger - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public ManagedHsmTrigger() - { - } - - /// Initializes a new instance of . - /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - /// Keeps track of any properties unknown to the library. - internal ManagedHsmTrigger(string timeAfterCreate, string timeBeforeExpiry, IDictionary serializedAdditionalRawData) - { - TimeAfterCreate = timeAfterCreate; - TimeBeforeExpiry = timeBeforeExpiry; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The time duration after key creation to rotate the key. It only applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - [WirePath("timeAfterCreate")] - public string TimeAfterCreate { get; set; } - /// The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - [WirePath("timeBeforeExpiry")] - public string TimeBeforeExpiry { get; set; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs deleted file mode 100644 index d7754d2f19adb..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.Serialization.cs +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class RotationPolicy : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RotationPolicy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Attributes)) - { - writer.WritePropertyName("attributes"u8); - writer.WriteObjectValue(Attributes, options); - } - if (Optional.IsCollectionDefined(LifetimeActions)) - { - writer.WritePropertyName("lifetimeActions"u8); - writer.WriteStartArray(); - foreach (var item in LifetimeActions) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - RotationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RotationPolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRotationPolicy(document.RootElement, options); - } - - internal static RotationPolicy DeserializeRotationPolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - KeyRotationPolicyAttributes attributes = default; - IList lifetimeActions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("attributes"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - attributes = KeyRotationPolicyAttributes.DeserializeKeyRotationPolicyAttributes(property.Value, options); - continue; - } - if (property.NameEquals("lifetimeActions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(LifetimeAction.DeserializeLifetimeAction(item, options)); - } - lifetimeActions = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new RotationPolicy(attributes, lifetimeActions ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - private BinaryData SerializeBicep(ModelReaderWriterOptions options) - { - StringBuilder builder = new StringBuilder(); - BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; - IDictionary propertyOverrides = null; - bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); - bool hasPropertyOverride = false; - string propertyOverride = null; - - builder.AppendLine("{"); - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" attributes: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsDefined(Attributes)) - { - builder.Append(" attributes: "); - BicepSerializationHelpers.AppendChildObject(builder, Attributes, options, 2, false, " attributes: "); - } - } - - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LifetimeActions), out propertyOverride); - if (hasPropertyOverride) - { - builder.Append(" lifetimeActions: "); - builder.AppendLine(propertyOverride); - } - else - { - if (Optional.IsCollectionDefined(LifetimeActions)) - { - if (LifetimeActions.Any()) - { - builder.Append(" lifetimeActions: "); - builder.AppendLine("["); - foreach (var item in LifetimeActions) - { - BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " lifetimeActions: "); - } - builder.AppendLine(" ]"); - } - } - } - - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "bicep": - return SerializeBicep(options); - default: - throw new FormatException($"The model {nameof(RotationPolicy)} does not support writing '{options.Format}' format."); - } - } - - RotationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRotationPolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RotationPolicy)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs deleted file mode 100644 index 467ef8d13f342..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/RotationPolicy.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The RotationPolicy. - public partial class RotationPolicy - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public RotationPolicy() - { - LifetimeActions = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The attributes of key rotation policy. - /// The lifetimeActions for key rotation action. - /// Keeps track of any properties unknown to the library. - internal RotationPolicy(KeyRotationPolicyAttributes attributes, IList lifetimeActions, IDictionary serializedAdditionalRawData) - { - Attributes = attributes; - LifetimeActions = lifetimeActions; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The attributes of key rotation policy. - [WirePath("attributes")] - public KeyRotationPolicyAttributes Attributes { get; set; } - /// The lifetimeActions for key rotation action. - [WirePath("lifetimeActions")] - public IList LifetimeActions { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs deleted file mode 100644 index a31017356476d..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.KeyVault.Models -{ - public partial class VaultKeyCreateOrUpdateContent : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - VaultKeyCreateOrUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVaultKeyCreateOrUpdateContent(document.RootElement, options); - } - - internal static VaultKeyCreateOrUpdateContent DeserializeVaultKeyCreateOrUpdateContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary tags = default; - KeyProperties properties = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("tags"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; - continue; - } - if (property.NameEquals("properties"u8)) - { - properties = KeyProperties.DeserializeKeyProperties(property.Value, options); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new VaultKeyCreateOrUpdateContent(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support writing '{options.Format}' format."); - } - } - - VaultKeyCreateOrUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVaultKeyCreateOrUpdateContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VaultKeyCreateOrUpdateContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs deleted file mode 100644 index 21b3018178dc7..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/Models/VaultKeyCreateOrUpdateContent.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.KeyVault.Models -{ - /// The parameters used to create a key. - public partial class VaultKeyCreateOrUpdateContent - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - /// The properties of the key to be created. - /// is null. - public VaultKeyCreateOrUpdateContent(KeyProperties properties) - { - Argument.AssertNotNull(properties, nameof(properties)); - - Tags = new ChangeTrackingDictionary(); - Properties = properties; - } - - /// Initializes a new instance of . - /// The tags that will be assigned to the key. - /// The properties of the key to be created. - /// Keeps track of any properties unknown to the library. - internal VaultKeyCreateOrUpdateContent(IDictionary tags, KeyProperties properties, IDictionary serializedAdditionalRawData) - { - Tags = tags; - Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal VaultKeyCreateOrUpdateContent() - { - } - - /// The tags that will be assigned to the key. - [WirePath("tags")] - public IDictionary Tags { get; } - /// The properties of the key to be created. - [WirePath("properties")] - public KeyProperties Properties { get; } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs deleted file mode 100644 index e16e77485d1d0..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/KeysRestOperations.cs +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault -{ - internal partial class KeysRestOperations - { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - - /// Initializes a new instance of KeysRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public KeysRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-07-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateCreateIfNotExistRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCreateIfNotExistRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the key vault which contains the key to be created. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> CreateIfNotExistAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, vaultName, keyName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyVaultKeyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the key vault which contains the key to be created. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response CreateIfNotExist(string subscriptionId, string resourceGroupName, string vaultName, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, vaultName, keyName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyVaultKeyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets the current version of the specified key from the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key to be retrieved. - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, vaultName, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyVaultKeyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((KeyVaultKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets the current version of the specified key from the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key to be retrieved. - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, vaultName, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyVaultKeyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((KeyVaultKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string vaultName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string vaultName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the keys in the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the keys to be retrieved. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, vaultName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the keys in the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the keys to be retrieved. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, vaultName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetVersionRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions/", false); - uri.AppendPath(keyVersion, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetVersionRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions/", false); - uri.AppendPath(keyVersion, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets the specified version of the specified key in the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key version to be retrieved. - /// The name of the key version to be retrieved. - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public async Task> GetVersionAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, vaultName, keyName, keyVersion); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyVaultKeyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((KeyVaultKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets the specified version of the specified key in the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key version to be retrieved. - /// The name of the key version to be retrieved. - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public Response GetVersion(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, vaultName, keyName, keyVersion); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyVaultKeyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyVaultKeyData.DeserializeKeyVaultKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((KeyVaultKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListVersionsRequestUri(string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListVersionsRequest(string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); - uri.AppendPath(vaultName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the versions of the specified key in the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key versions to be retrieved. - /// The name of the key versions to be retrieved. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> ListVersionsAsync(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, vaultName, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the versions of the specified key in the specified key vault. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key versions to be retrieved. - /// The name of the key versions to be retrieved. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response ListVersions(string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, vaultName, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string vaultName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string vaultName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the keys in the specified key vault. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the keys to be retrieved. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the keys in the specified key vault. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the keys to be retrieved. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListVersionsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListVersionsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the versions of the specified key in the specified key vault. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key versions to be retrieved. - /// The name of the key versions to be retrieved. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> ListVersionsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the versions of the specified key in the specified key vault. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group which contains the specified key vault. - /// The name of the vault which contains the key versions to be retrieved. - /// The name of the key versions to be retrieved. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response ListVersionsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string vaultName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - KeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = KeyListResult.DeserializeKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs deleted file mode 100644 index 81877c2718ec0..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/RestOperations/ManagedHsmKeysRestOperations.cs +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault -{ - internal partial class ManagedHsmKeysRestOperations - { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - - /// Initializes a new instance of ManagedHsmKeysRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public ManagedHsmKeysRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-07-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateCreateIfNotExistRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCreateIfNotExistRequest(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> CreateIfNotExistAsync(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, name, keyName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response CreateIfNotExist(string subscriptionId, string resourceGroupName, string name, string keyName, ManagedHSMKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCreateIfNotExistRequest(subscriptionId, resourceGroupName, name, keyName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string name, string keyName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets the current version of the specified key from the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, name, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedHsmKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets the current version of the specified key from the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, name, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedHsmKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string name) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string name) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the keys in the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, name); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the keys in the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, name); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetVersionRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions/", false); - uri.AppendPath(keyVersion, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetVersionRequest(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions/", false); - uri.AppendPath(keyVersion, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets the specified version of the specified key in the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public async Task> GetVersionAsync(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, name, keyName, keyVersion); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedHsmKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets the specified version of the specified key in the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public Response GetVersion(string subscriptionId, string resourceGroupName, string name, string keyName, string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var message = CreateGetVersionRequest(subscriptionId, resourceGroupName, name, keyName, keyVersion); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyData.DeserializeManagedHsmKeyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ManagedHsmKeyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListVersionsRequestUri(string subscriptionId, string resourceGroupName, string name, string keyName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListVersionsRequest(string subscriptionId, string resourceGroupName, string name, string keyName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.KeyVault/managedHSMs/", false); - uri.AppendPath(name, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/versions", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the versions of the specified key in the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> ListVersionsAsync(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, name, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the versions of the specified key in the specified managed HSM. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response ListVersions(string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsRequest(subscriptionId, resourceGroupName, name, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string name) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string name) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the keys in the specified managed HSM. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the keys in the specified managed HSM. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListVersionsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListVersionsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists the versions of the specified key in the specified managed HSM. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> ListVersionsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the versions of the specified key in the specified managed HSM. - /// The URL to the next page of results. - /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. - /// The name of the resource group. The name is case insensitive. - /// The name of the Managed HSM Pool within the specified resource group. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response ListVersionsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string name, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateListVersionsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ManagedHsmKeyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = ManagedHsmKeyListResult.DeserializeManagedHsmKeyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs deleted file mode 100644 index b034f0f009ef1..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyCollection.cs +++ /dev/null @@ -1,498 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetVaultKeys method from an instance of . - /// - public partial class VaultKeyCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _vaultKeyKeysClientDiagnostics; - private readonly KeysRestOperations _vaultKeyKeysRestClient; - - /// Initializes a new instance of the class for mocking. - protected VaultKeyCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal VaultKeyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _vaultKeyKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", VaultKeyResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(VaultKeyResource.ResourceType, out string vaultKeyKeysApiVersion); - _vaultKeyKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != KeyVaultResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, KeyVaultResource.ResourceType), nameof(id)); - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _vaultKeyKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken).ConfigureAwait(false); - var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the key to be created. The value you provide may be copied globally for the purpose of running the service. The value provided should not include personally identifiable or sensitive information. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string keyName, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _vaultKeyKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content, cancellationToken); - var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the current version of the specified key from the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Get"); - scope.Start(); - try - { - var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the current version of the specified key from the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Get"); - scope.Start(); - try - { - var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Lists the keys in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys - /// - /// - /// Operation Id - /// Keys_List - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Lists the keys in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys - /// - /// - /// Operation Id - /// Keys_List - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyKeysRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyKeysRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyKeysClientDiagnostics, Pipeline, "VaultKeyCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Exists"); - scope.Start(); - try - { - var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Exists"); - scope.Start(); - try - { - var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.GetIfExists"); - scope.Start(); - try - { - var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs deleted file mode 100644 index db3cf2794b497..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.Serialization.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.KeyVault -{ - public partial class VaultKeyResource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - KeyVaultKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); - - KeyVaultKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs deleted file mode 100644 index a26d25d42a1aa..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyResource.cs +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.KeyVault.Models; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A Class representing a VaultKey along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetVaultKeyResource method. - /// Otherwise you can get one from its parent resource using the GetVaultKey method. - /// - public partial class VaultKeyResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The vaultName. - /// The keyName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _vaultKeyKeysClientDiagnostics; - private readonly KeysRestOperations _vaultKeyKeysRestClient; - private readonly KeyVaultKeyData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.KeyVault/vaults/keys"; - - /// Initializes a new instance of the class for mocking. - protected VaultKeyResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal VaultKeyResource(ArmClient client, KeyVaultKeyData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal VaultKeyResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _vaultKeyKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string vaultKeyKeysApiVersion); - _vaultKeyKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual KeyVaultKeyData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// Gets a collection of VaultKeyVersionResources in the VaultKey. - /// An object representing collection of VaultKeyVersionResources and their operations over a VaultKeyVersionResource. - public virtual VaultKeyVersionCollection GetVaultKeyVersions() - { - return GetCachedClient(client => new VaultKeyVersionCollection(client, Id)); - } - - /// - /// Gets the specified version of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetVaultKeyVersionAsync(string keyVersion, CancellationToken cancellationToken = default) - { - return await GetVaultKeyVersions().GetAsync(keyVersion, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets the specified version of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetVaultKeyVersion(string keyVersion, CancellationToken cancellationToken = default) - { - return GetVaultKeyVersions().Get(keyVersion, cancellationToken); - } - - /// - /// Gets the current version of the specified key from the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Get"); - scope.Start(); - try - { - var response = await _vaultKeyKeysRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the current version of the specified key from the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_Get - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Get"); - scope.Start(); - try - { - var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Update"); - scope.Start(); - try - { - var response = await _vaultKeyKeysRestClient.CreateIfNotExistAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); - var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName} - /// - /// - /// Operation Id - /// Keys_CreateIfNotExist - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The parameters used to create the specified key. - /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, VaultKeyCreateOrUpdateContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyResource.Update"); - scope.Start(); - try - { - var response = _vaultKeyKeysRestClient.CreateIfNotExist(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); - var uri = _vaultKeyKeysRestClient.CreateCreateIfNotExistRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new KeyVaultArmOperation(Response.FromValue(new VaultKeyResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs deleted file mode 100644 index b5191a7a60d06..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionCollection.cs +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetVaultKeyVersions method from an instance of . - /// - public partial class VaultKeyVersionCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _vaultKeyVersionKeysClientDiagnostics; - private readonly KeysRestOperations _vaultKeyVersionKeysRestClient; - - /// Initializes a new instance of the class for mocking. - protected VaultKeyVersionCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal VaultKeyVersionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _vaultKeyVersionKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", VaultKeyVersionResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(VaultKeyVersionResource.ResourceType, out string vaultKeyVersionKeysApiVersion); - _vaultKeyVersionKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyVersionKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != VaultKeyResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, VaultKeyResource.ResourceType), nameof(id)); - } - - /// - /// Gets the specified version of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Get"); - scope.Start(); - try - { - var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the specified version of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Get"); - scope.Start(); - try - { - var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Lists the versions of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions - /// - /// - /// Operation Id - /// Keys_ListVersions - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyVersionKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyVersionKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Lists the versions of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions - /// - /// - /// Operation Id - /// Keys_ListVersions - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _vaultKeyVersionKeysRestClient.CreateListVersionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _vaultKeyVersionKeysRestClient.CreateListVersionsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultKeyVersionResource(Client, KeyVaultKeyData.DeserializeKeyVaultKeyData(e)), _vaultKeyVersionKeysClientDiagnostics, Pipeline, "VaultKeyVersionCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Exists"); - scope.Start(); - try - { - var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.Exists"); - scope.Start(); - try - { - var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The version of the key to be retrieved. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string keyVersion, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(keyVersion, nameof(keyVersion)); - - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.GetIfExists"); - scope.Start(); - try - { - var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, keyVersion, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs deleted file mode 100644 index 36c80d822bd6e..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.Serialization.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.KeyVault -{ - public partial class VaultKeyVersionResource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - KeyVaultKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); - - KeyVaultKeyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs deleted file mode 100644 index ee7267013dbed..0000000000000 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/Generated/VaultKeyVersionResource.cs +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.KeyVault -{ - /// - /// A Class representing a VaultKeyVersion along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetVaultKeyVersionResource method. - /// Otherwise you can get one from its parent resource using the GetVaultKeyVersion method. - /// - public partial class VaultKeyVersionResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The vaultName. - /// The keyName. - /// The keyVersion. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string keyName, string keyVersion) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _vaultKeyVersionKeysClientDiagnostics; - private readonly KeysRestOperations _vaultKeyVersionKeysRestClient; - private readonly KeyVaultKeyData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.KeyVault/vaults/keys/versions"; - - /// Initializes a new instance of the class for mocking. - protected VaultKeyVersionResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal VaultKeyVersionResource(ArmClient client, KeyVaultKeyData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal VaultKeyVersionResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _vaultKeyVersionKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.KeyVault", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string vaultKeyVersionKeysApiVersion); - _vaultKeyVersionKeysRestClient = new KeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, vaultKeyVersionKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual KeyVaultKeyData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// - /// Gets the specified version of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionResource.Get"); - scope.Start(); - try - { - var response = await _vaultKeyVersionKeysRestClient.GetVersionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Gets the specified version of the specified key in the specified key vault. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion} - /// - /// - /// Operation Id - /// Keys_GetVersion - /// - /// - /// Default Api Version - /// 2023-07-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionResource.Get"); - scope.Start(); - try - { - var response = _vaultKeyVersionKeysRestClient.GetVersion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new VaultKeyVersionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md index 5b2a04c08a775..d31ada8432836 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/src/autorest.md @@ -8,7 +8,7 @@ csharp: true library-name: KeyVault namespace: Azure.ResourceManager.KeyVault require: https://github.com/Azure/azure-rest-api-specs/blob/d1296700aa6cd650970e9891dd58eef5698327fd/specification/keyvault/resource-manager/readme.md -#tag: package-2023-02 +#tag: package-2023-07 output-folder: $(this-folder)/Generated clear-output-folder: true sample-gen: @@ -162,22 +162,19 @@ directive: $.VaultProperties.properties.provisioningState['x-ms-enum']['name'] = 'KeyVaultProvisioningState'; $.Vault['x-csharp-usage'] = 'model,input,output'; $.CheckNameAvailabilityResult.properties.reason['x-ms-enum']['name'] = 'KeyVaultNameUnavailableReason'; -# Remove the flatten since it will cause Tag operation error + # Remove keysManagedHsm.json and keys.json since these 2 are part of data plane - from: keysManagedHsm.json - where: $.definitions - transform: > - delete $.ManagedHsmKey.properties.properties['x-ms-client-flatten'] -``` - -### Tag: package-2023-02 - -These settings apply only when `--tag=package-2023-02` is specified on the command line. - -```yaml $(tag) == 'package-2023-02' -input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/33f06ff82a4c751bcbc842b7ed4da2e81b0717b6/specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/common.json - - https://github.com/Azure/azure-rest-api-specs/blob/33f06ff82a4c751bcbc842b7ed4da2e81b0717b6/specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/keyvault.json - - https://github.com/Azure/azure-rest-api-specs/blob/33f06ff82a4c751bcbc842b7ed4da2e81b0717b6/specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/managedHsm.json - - https://github.com/Azure/azure-rest-api-specs/blob/33f06ff82a4c751bcbc842b7ed4da2e81b0717b6/specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/providers.json - - https://github.com/Azure/azure-rest-api-specs/blob/33f06ff82a4c751bcbc842b7ed4da2e81b0717b6/specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/secrets.json + where: $.paths + transform: > + for (var path in $) + { + delete $[path]; + } + - from: keys.json + where: $.paths + transform: > + for (var path in $) + { + delete $[path]; + } ```