From c8be96df69d6eea05352824d1fcfc196a3c56e55 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Tue, 11 Apr 2023 09:36:16 +0800 Subject: [PATCH 1/2] keyvault release --- common/config/rush/pnpm-lock.yaml | 24 +- sdk/keyvault/arm-keyvault/CHANGELOG.md | 75 ++- sdk/keyvault/arm-keyvault/LICENSE | 2 +- sdk/keyvault/arm-keyvault/README.md | 2 +- sdk/keyvault/arm-keyvault/_meta.json | 8 +- sdk/keyvault/arm-keyvault/package.json | 13 +- .../recording_vaults_create_test.json | 24 +- .../recording_vaults_delete_test.json | 34 +- .../recording_vaults_get_test.json | 24 +- .../recording_vaults_list_test.json | 82 +-- .../recording_vaults_update_test.json | 24 +- .../arm-keyvault/review/arm-keyvault.api.md | 292 +++++++- .../samples-dev/keysCreateIfNotExistSample.ts | 18 +- .../arm-keyvault/samples-dev/keysGetSample.ts | 18 +- .../samples-dev/keysGetVersionSample.ts | 18 +- .../samples-dev/keysListSample.ts | 18 +- .../samples-dev/keysListVersionsSample.ts | 18 +- .../managedHsmKeysCreateIfNotExistSample.ts | 52 ++ .../samples-dev/managedHsmKeysGetSample.ts | 45 ++ .../managedHsmKeysGetVersionSample.ts | 47 ++ .../samples-dev/managedHsmKeysListSample.ts | 43 ++ .../managedHsmKeysListVersionsSample.ts | 48 ++ ...agedHsmsCheckMhsmNameAvailabilitySample.ts | 41 ++ .../managedHsmsCreateOrUpdateSample.ts | 20 +- .../samples-dev/managedHsmsDeleteSample.ts | 18 +- .../managedHsmsGetDeletedSample.ts | 15 +- .../samples-dev/managedHsmsGetSample.ts | 18 +- .../managedHsmsListByResourceGroupSample.ts | 18 +- .../managedHsmsListBySubscriptionSample.ts | 15 +- .../managedHsmsListDeletedSample.ts | 15 +- .../managedHsmsPurgeDeletedSample.ts | 15 +- .../samples-dev/managedHsmsUpdateSample.ts | 18 +- ...mPrivateEndpointConnectionsDeleteSample.ts | 18 +- ...mhsmPrivateEndpointConnectionsGetSample.ts | 18 +- ...EndpointConnectionsListByResourceSample.ts | 18 +- ...mhsmPrivateEndpointConnectionsPutSample.ts | 18 +- ...teLinkResourcesListByMhsmResourceSample.ts | 18 +- .../mhsmRegionsListByResourceSample.ts | 46 ++ .../samples-dev/operationsListSample.ts | 15 +- .../privateEndpointConnectionsDeleteSample.ts | 18 +- .../privateEndpointConnectionsGetSample.ts | 18 +- ...EndpointConnectionsListByResourceSample.ts | 18 +- .../privateEndpointConnectionsPutSample.ts | 18 +- .../privateLinkResourcesListByVaultSample.ts | 18 +- .../secretsCreateOrUpdateSample.ts | 18 +- .../samples-dev/secretsGetSample.ts | 18 +- .../samples-dev/secretsListSample.ts | 18 +- .../samples-dev/secretsUpdateSample.ts | 18 +- .../vaultsCheckNameAvailabilitySample.ts | 15 +- .../samples-dev/vaultsCreateOrUpdateSample.ts | 30 +- .../samples-dev/vaultsDeleteSample.ts | 18 +- .../samples-dev/vaultsGetDeletedSample.ts | 15 +- .../samples-dev/vaultsGetSample.ts | 18 +- .../vaultsListByResourceGroupSample.ts | 18 +- .../vaultsListBySubscriptionSample.ts | 15 +- .../samples-dev/vaultsListDeletedSample.ts | 15 +- .../samples-dev/vaultsListSample.ts | 15 +- .../samples-dev/vaultsPurgeDeletedSample.ts | 15 +- .../vaultsUpdateAccessPolicySample.ts | 20 +- .../samples-dev/vaultsUpdateSample.ts | 18 +- .../samples/v3/javascript/README.md | 144 ++++ .../javascript/keysCreateIfNotExistSample.js | 43 ++ .../samples/v3/javascript/keysGetSample.js | 37 + .../v3/javascript/keysGetVersionSample.js | 38 ++ .../samples/v3/javascript/keysListSample.js | 39 ++ .../v3/javascript/keysListVersionsSample.js | 40 ++ .../managedHsmKeysCreateIfNotExistSample.js | 45 ++ .../v3/javascript/managedHsmKeysGetSample.js | 37 + .../managedHsmKeysGetVersionSample.js | 43 ++ .../v3/javascript/managedHsmKeysListSample.js | 39 ++ .../managedHsmKeysListVersionsSample.js | 40 ++ ...agedHsmsCheckMhsmNameAvailabilitySample.js | 35 + .../managedHsmsCreateOrUpdateSample.js | 52 ++ .../v3/javascript/managedHsmsDeleteSample.js | 36 + .../javascript/managedHsmsGetDeletedSample.js | 36 + .../v3/javascript/managedHsmsGetSample.js | 36 + .../managedHsmsListByResourceGroupSample.js | 38 ++ .../managedHsmsListBySubscriptionSample.js | 37 + .../managedHsmsListDeletedSample.js | 37 + .../managedHsmsPurgeDeletedSample.js | 36 + .../v3/javascript/managedHsmsUpdateSample.js | 39 ++ ...mPrivateEndpointConnectionsDeleteSample.js | 41 ++ ...mhsmPrivateEndpointConnectionsGetSample.js | 41 ++ ...EndpointConnectionsListByResourceSample.js | 42 ++ ...mhsmPrivateEndpointConnectionsPutSample.js | 48 ++ ...teLinkResourcesListByMhsmResourceSample.js | 36 + .../mhsmRegionsListByResourceSample.js | 39 ++ .../v3/javascript/operationsListSample.js | 37 + .../samples/v3/javascript/package.json | 32 + .../privateEndpointConnectionsDeleteSample.js | 41 ++ .../privateEndpointConnectionsGetSample.js | 41 ++ ...EndpointConnectionsListByResourceSample.js | 42 ++ .../privateEndpointConnectionsPutSample.js | 49 ++ .../privateLinkResourcesListByVaultSample.js | 36 + .../samples/v3/javascript/sample.env | 4 + .../javascript/secretsCreateOrUpdateSample.js | 45 ++ .../samples/v3/javascript/secretsGetSample.js | 37 + .../v3/javascript/secretsListSample.js | 39 ++ .../v3/javascript/secretsUpdateSample.js | 40 ++ .../vaultsCheckNameAvailabilitySample.js | 38 ++ .../javascript/vaultsCreateOrUpdateSample.js | 136 ++++ .../v3/javascript/vaultsDeleteSample.js | 36 + .../v3/javascript/vaultsGetDeletedSample.js | 36 + .../samples/v3/javascript/vaultsGetSample.js | 36 + .../vaultsListByResourceGroupSample.js | 40 ++ .../vaultsListBySubscriptionSample.js | 39 ++ .../v3/javascript/vaultsListDeletedSample.js | 37 + .../samples/v3/javascript/vaultsListSample.js | 39 ++ .../v3/javascript/vaultsPurgeDeletedSample.js | 36 + .../vaultsUpdateAccessPolicySample.js | 57 ++ .../v3/javascript/vaultsUpdateSample.js | 89 +++ .../samples/v3/typescript/README.md | 157 +++++ .../samples/v3/typescript/package.json | 41 ++ .../samples/v3/typescript/sample.env | 4 + .../src/keysCreateIfNotExistSample.ts | 50 ++ .../v3/typescript/src/keysGetSample.ts | 41 ++ .../v3/typescript/src/keysGetVersionSample.ts | 47 ++ .../v3/typescript/src/keysListSample.ts | 43 ++ .../typescript/src/keysListVersionsSample.ts | 48 ++ .../managedHsmKeysCreateIfNotExistSample.ts | 52 ++ .../typescript/src/managedHsmKeysGetSample.ts | 45 ++ .../src/managedHsmKeysGetVersionSample.ts | 47 ++ .../src/managedHsmKeysListSample.ts | 43 ++ .../src/managedHsmKeysListVersionsSample.ts | 48 ++ ...agedHsmsCheckMhsmNameAvailabilitySample.ts | 41 ++ .../src/managedHsmsCreateOrUpdateSample.ts | 56 ++ .../typescript/src/managedHsmsDeleteSample.ts | 43 ++ .../src/managedHsmsGetDeletedSample.ts | 39 ++ .../v3/typescript/src/managedHsmsGetSample.ts | 40 ++ .../managedHsmsListByResourceGroupSample.ts | 44 ++ .../managedHsmsListBySubscriptionSample.ts | 40 ++ .../src/managedHsmsListDeletedSample.ts | 40 ++ .../src/managedHsmsPurgeDeletedSample.ts | 42 ++ .../typescript/src/managedHsmsUpdateSample.ts | 47 ++ ...mPrivateEndpointConnectionsDeleteSample.ts | 45 ++ ...mhsmPrivateEndpointConnectionsGetSample.ts | 45 ++ ...EndpointConnectionsListByResourceSample.ts | 46 ++ ...mhsmPrivateEndpointConnectionsPutSample.ts | 55 ++ ...teLinkResourcesListByMhsmResourceSample.ts | 43 ++ .../src/mhsmRegionsListByResourceSample.ts | 46 ++ .../v3/typescript/src/operationsListSample.ts | 40 ++ .../privateEndpointConnectionsDeleteSample.ts | 45 ++ .../privateEndpointConnectionsGetSample.ts | 45 ++ ...EndpointConnectionsListByResourceSample.ts | 46 ++ .../privateEndpointConnectionsPutSample.ts | 56 ++ .../privateLinkResourcesListByVaultSample.ts | 43 ++ .../src/secretsCreateOrUpdateSample.ts | 52 ++ .../v3/typescript/src/secretsGetSample.ts | 45 ++ .../v3/typescript/src/secretsListSample.ts | 43 ++ .../v3/typescript/src/secretsUpdateSample.ts | 52 ++ .../src/vaultsCheckNameAvailabilitySample.ts | 44 ++ .../src/vaultsCreateOrUpdateSample.ts | 155 +++++ .../v3/typescript/src/vaultsDeleteSample.ts | 40 ++ .../typescript/src/vaultsGetDeletedSample.ts | 39 ++ .../v3/typescript/src/vaultsGetSample.ts | 40 ++ .../src/vaultsListByResourceGroupSample.ts | 50 ++ .../src/vaultsListBySubscriptionSample.ts | 45 ++ .../typescript/src/vaultsListDeletedSample.ts | 40 ++ .../v3/typescript/src/vaultsListSample.ts | 45 ++ .../src/vaultsPurgeDeletedSample.ts | 42 ++ .../src/vaultsUpdateAccessPolicySample.ts | 64 ++ .../v3/typescript/src/vaultsUpdateSample.ts | 109 +++ .../samples/v3/typescript/tsconfig.json | 17 + .../src/keyVaultManagementClient.ts | 12 +- sdk/keyvault/arm-keyvault/src/lroImpl.ts | 54 +- sdk/keyvault/arm-keyvault/src/models/index.ts | 416 +++++++++++- .../arm-keyvault/src/models/mappers.ts | 633 +++++++++++++++++- .../arm-keyvault/src/models/parameters.ts | 57 +- .../arm-keyvault/src/operations/index.ts | 2 + .../arm-keyvault/src/operations/keys.ts | 6 +- .../src/operations/managedHsmKeys.ts | 525 +++++++++++++++ .../src/operations/managedHsms.ts | 176 +++-- .../mhsmPrivateEndpointConnections.ts | 42 +- .../operations/mhsmPrivateLinkResources.ts | 2 +- .../src/operations/mhsmRegions.ts | 194 ++++++ .../arm-keyvault/src/operations/operations.ts | 1 - .../operations/privateEndpointConnections.ts | 37 +- .../arm-keyvault/src/operations/secrets.ts | 9 +- .../arm-keyvault/src/operations/vaults.ts | 59 +- .../src/operationsInterfaces/index.ts | 2 + .../src/operationsInterfaces/keys.ts | 4 +- .../operationsInterfaces/managedHsmKeys.ts | 103 +++ .../src/operationsInterfaces/managedHsms.ts | 36 +- .../mhsmPrivateEndpointConnections.ts | 6 +- .../src/operationsInterfaces/mhsmRegions.ts | 29 + .../privateEndpointConnections.ts | 6 +- .../src/operationsInterfaces/secrets.ts | 4 +- .../src/operationsInterfaces/vaults.ts | 8 +- sdk/keyvault/arm-keyvault/src/pagingHelper.ts | 8 +- .../arm-keyvault/test/keyvault_examples.ts | 2 +- 190 files changed, 8339 insertions(+), 552 deletions(-) create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysCreateIfNotExistSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetVersionSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListVersionsSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCheckMhsmNameAvailabilitySample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples-dev/mhsmRegionsListByResourceSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/README.md create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/keysCreateIfNotExistSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetVersionSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListVersionsSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysCreateIfNotExistSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetVersionSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListVersionsSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCheckMhsmNameAvailabilitySample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCreateOrUpdateSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsDeleteSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetDeletedSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListByResourceGroupSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListBySubscriptionSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListDeletedSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsPurgeDeletedSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsUpdateSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsDeleteSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsListByResourceSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsPutSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateLinkResourcesListByMhsmResourceSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmRegionsListByResourceSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/operationsListSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/package.json create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsDeleteSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsListByResourceSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsPutSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/privateLinkResourcesListByVaultSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/sample.env create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsCreateOrUpdateSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsListSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsUpdateSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCheckNameAvailabilitySample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCreateOrUpdateSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsDeleteSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetDeletedSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListByResourceGroupSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListBySubscriptionSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListDeletedSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsPurgeDeletedSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateAccessPolicySample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateSample.js create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/README.md create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/package.json create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/sample.env create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysCreateIfNotExistSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetVersionSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListVersionsSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysCreateIfNotExistSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetVersionSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListVersionsSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCheckMhsmNameAvailabilitySample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCreateOrUpdateSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsDeleteSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetDeletedSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListByResourceGroupSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListBySubscriptionSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListDeletedSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsPurgeDeletedSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsUpdateSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsDeleteSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsListByResourceSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsPutSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmRegionsListByResourceSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/operationsListSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsDeleteSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsListByResourceSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsPutSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateLinkResourcesListByVaultSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsCreateOrUpdateSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsListSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsUpdateSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCheckNameAvailabilitySample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCreateOrUpdateSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsDeleteSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetDeletedSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListByResourceGroupSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListBySubscriptionSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListDeletedSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsPurgeDeletedSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateAccessPolicySample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateSample.ts create mode 100644 sdk/keyvault/arm-keyvault/samples/v3/typescript/tsconfig.json create mode 100644 sdk/keyvault/arm-keyvault/src/operations/managedHsmKeys.ts create mode 100644 sdk/keyvault/arm-keyvault/src/operations/mhsmRegions.ts create mode 100644 sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsmKeys.ts create mode 100644 sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmRegions.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 14cd0cf2ff92..d817c6e4df92 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3998,7 +3998,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.1.0-dev.20230405 + typescript: 5.1.0-dev.20230410 dev: false /ecdsa-sig-formatter/1.0.11: @@ -8855,14 +8855,14 @@ packages: hasBin: true dev: false - /typescript/5.0.3: - resolution: {integrity: sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==} + /typescript/5.0.4: + resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} engines: {node: '>=12.20'} hasBin: true dev: false - /typescript/5.1.0-dev.20230405: - resolution: {integrity: sha512-4unWRVmR6URHndao/lK2XCSabqveeczgOSGNNQbfZW7Hu4b+YND5DlpVQOL/Yaz9olB1FgeZidZwYnTQbOXc6w==} + /typescript/5.1.0-dev.20230410: + resolution: {integrity: sha512-7aQS6nNYt3XVJic6FBmnxasor6MZFwi5Odj0Z0UtHode4ID21KgCjFgJcdtiWrmSIZ/PLfrp6QiE179hwbB5tQ==} engines: {node: '>=12.20'} hasBin: true dev: false @@ -12658,7 +12658,7 @@ packages: dev: false file:projects/arm-keyvault.tgz: - resolution: {integrity: sha512-YdBoEvpK1VYdKtLIP4EPBALD6QFSzKa1Jy9ukIXzcsLrH0FCeWm2mSlEWSWx1GJ7O1fus2fnMXoN5OXt828+Qg==, tarball: file:projects/arm-keyvault.tgz} + resolution: {integrity: sha512-MG2HgZl6Up5VQ83oAMkPXCG6S33Wwqh+iWzlEKZtQ0FILK+dnwKB6L2teZGHmL4irpoFB8Mb3kQYsVbUBF2HvQ==, tarball: file:projects/arm-keyvault.tgz} name: '@rush-temp/arm-keyvault' version: 0.0.0 dependencies: @@ -12672,7 +12672,8 @@ packages: '@types/node': 14.18.42 chai: 4.3.7 cross-env: 7.0.3 - mkdirp: 1.0.4 + dotenv: 16.0.3 + mkdirp: 2.1.6 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 @@ -15680,7 +15681,7 @@ packages: dev: false file:projects/communication-call-automation.tgz: - resolution: {integrity: sha512-BCxCcEVIqXSsumZ5b/0E4S4wAsI6WI7EsbY8tNQX/yEMYeMOKchffplek8nBnjjMXJh93itkE3Im9HTTAd4HBQ==, tarball: file:projects/communication-call-automation.tgz} + resolution: {integrity: sha512-5/l5GYmYlgc007crbcLNODtwZn7Ge10AZ7fONGz/FWCszObt2YQn/6xXttfS8zKo6XNmUFqlUd6qGhJnyv0FjA==, tarball: file:projects/communication-call-automation.tgz} name: '@rush-temp/communication-call-automation' version: 0.0.0 dependencies: @@ -15722,7 +15723,6 @@ packages: transitivePeerDependencies: - bufferutil - debug - - encoding - supports-color - utf-8-validate dev: false @@ -16923,7 +16923,7 @@ packages: name: '@rush-temp/dev-tool' version: 0.0.0 dependencies: - '@_ts/max': /typescript/5.0.3 + '@_ts/max': /typescript/5.0.4 '@_ts/min': /typescript/4.2.4 '@microsoft/api-extractor': 7.34.4_@types+node@14.18.42 '@rollup/plugin-commonjs': 24.0.1_rollup@2.79.1 @@ -17171,7 +17171,7 @@ packages: dev: false file:projects/eventgrid.tgz: - resolution: {integrity: sha512-55L6D3Zr5nZu7iJ/bEuLzhKZ2AG4xeZ3aqkU2H9n3h1/bCp8g9Z4IhCZ3zBj5tSyZolhXot3cbINTIHlvDZZtA==, tarball: file:projects/eventgrid.tgz} + resolution: {integrity: sha512-/v2/2q6QmBLAy9IctuvCXDMjEedZw7eU0nNBrsQYr1zZqFHDyQRVJXLYYZVsIjWpuYTb6c/o7fkUhfe8YIuFAg==, tarball: file:projects/eventgrid.tgz} name: '@rush-temp/eventgrid' version: 0.0.0 dependencies: @@ -18744,7 +18744,7 @@ packages: dev: false file:projects/perf-service-bus.tgz: - resolution: {integrity: sha512-X1NvwwnX9KW680X8qYAvWSab7HtqQCZXw/alWYUXwIV5glv3ivLmPYQ5Piid4yK4GyhBRMmd1zmgHk+MHPXiOQ==, tarball: file:projects/perf-service-bus.tgz} + resolution: {integrity: sha512-wioVHbwMitD5Oi7RoiJr6nKap7VrDmz+QfijZnl1FWfCgRdtrCyIpYp2oC+VDnmCiPQavSFrLpW+6qmzGR1jrg==, tarball: file:projects/perf-service-bus.tgz} name: '@rush-temp/perf-service-bus' version: 0.0.0 dependencies: diff --git a/sdk/keyvault/arm-keyvault/CHANGELOG.md b/sdk/keyvault/arm-keyvault/CHANGELOG.md index b6b19d11ad9a..a605f8ce9b74 100644 --- a/sdk/keyvault/arm-keyvault/CHANGELOG.md +++ b/sdk/keyvault/arm-keyvault/CHANGELOG.md @@ -1,44 +1,95 @@ # Release History - -## 2.1.0-beta.3 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 2.1.0-beta.2 (2022-11-28) + +## 3.0.0 (2023-04-10) **Features** + - Added operation group ManagedHsmKeys + - Added operation group MhsmRegions + - Added operation ManagedHsms.checkMhsmNameAvailability - Added Interface Action + - Added Interface CheckMhsmNameAvailabilityParameters + - Added Interface CheckMhsmNameAvailabilityResult - Added Interface Key - Added Interface KeyReleasePolicy - Added Interface KeyRotationPolicyAttributes - Added Interface LifetimeAction - Added Interface ManagedHsm + - Added Interface ManagedHsmAction + - Added Interface ManagedHsmKey + - Added Interface ManagedHsmKeyAttributes + - Added Interface ManagedHsmKeyCreateParameters + - Added Interface ManagedHsmKeyListResult + - Added Interface ManagedHsmKeyProperties + - Added Interface ManagedHsmKeyReleasePolicy + - Added Interface ManagedHsmKeyRotationPolicyAttributes + - Added Interface ManagedHsmKeysCreateIfNotExistOptionalParams + - Added Interface ManagedHsmKeysGetOptionalParams + - Added Interface ManagedHsmKeysGetVersionOptionalParams + - Added Interface ManagedHsmKeysListNextOptionalParams + - Added Interface ManagedHsmKeysListOptionalParams + - Added Interface ManagedHsmKeysListVersionsNextOptionalParams + - Added Interface ManagedHsmKeysListVersionsOptionalParams + - Added Interface ManagedHsmLifetimeAction + - Added Interface ManagedHsmRotationPolicy + - Added Interface ManagedHsmsCheckMhsmNameAvailabilityOptionalParams + - Added Interface ManagedHsmsCreateOrUpdateHeaders + - Added Interface ManagedHsmsDeleteHeaders + - Added Interface ManagedHSMSecurityDomainProperties + - Added Interface ManagedHsmsPurgeDeletedHeaders - Added Interface ManagedHsmsUpdateHeaders + - Added Interface ManagedHsmTrigger + - Added Interface MhsmGeoReplicatedRegion - Added Interface MhsmPrivateEndpointConnection - Added Interface MhsmPrivateLinkResource + - Added Interface MhsmRegionsListByResourceNextOptionalParams + - Added Interface MhsmRegionsListByResourceOptionalParams + - Added Interface MhsmRegionsListResult - Added Interface PrivateEndpointConnection - Added Interface PrivateLinkResource + - Added Interface ProxyResourceWithoutSystemData - Added Interface RotationPolicy - Added Interface Secret - Added Interface SecretAttributes - Added Interface Trigger + - Added Type Alias ActivationStatus + - Added Type Alias GeoReplicationRegionProvisioningState - Added Type Alias KeyRotationPolicyActionType + - Added Type Alias ManagedHsmKeysCreateIfNotExistResponse + - Added Type Alias ManagedHsmKeysGetResponse + - Added Type Alias ManagedHsmKeysGetVersionResponse + - Added Type Alias ManagedHsmKeysListNextResponse + - Added Type Alias ManagedHsmKeysListResponse + - Added Type Alias ManagedHsmKeysListVersionsNextResponse + - Added Type Alias ManagedHsmKeysListVersionsResponse + - Added Type Alias ManagedHsmsCheckMhsmNameAvailabilityResponse + - Added Type Alias ManagedHsmsPurgeDeletedResponse + - Added Type Alias MhsmRegionsListByResourceNextResponse + - Added Type Alias MhsmRegionsListByResourceResponse - Interface KeyProperties has a new optional parameter releasePolicy - Interface KeyProperties has a new optional parameter rotationPolicy + - Interface ManagedHsmProperties has a new optional parameter regions + - Interface ManagedHsmProperties has a new optional parameter securityDomainProperties - Interface MhsmPrivateEndpointConnectionItem has a new optional parameter etag - Interface MhsmPrivateEndpointConnectionItem has a new optional parameter id + - Added Enum KnownActivationStatus + - Added Enum KnownGeoReplicationRegionProvisioningState - Enum KnownJsonWebKeyOperation has a new value Release - Enum KnownKeyPermissions has a new value Getrotationpolicy - Enum KnownKeyPermissions has a new value Release - Enum KnownKeyPermissions has a new value Rotate - Enum KnownKeyPermissions has a new value Setrotationpolicy + - Added function getContinuationToken + - Interface SecretsListNextOptionalParams no longer has parameter top + - Interface VaultsListByResourceGroupNextOptionalParams no longer has parameter top + - Interface VaultsListBySubscriptionNextOptionalParams no longer has parameter top + - Interface VaultsListNextOptionalParams no longer has parameter top + - Interface ManagedHsmsListByResourceGroupNextOptionalParams no longer has parameter top + - Interface ManagedHsmsListBySubscriptionNextOptionalParams no longer has parameter top + +**Breaking Changes** + + - Interface MhsmPrivateEndpointConnectionsDeleteHeaders no longer has parameter retryAfter ## 2.0.0 (2022-01-17) diff --git a/sdk/keyvault/arm-keyvault/LICENSE b/sdk/keyvault/arm-keyvault/LICENSE index 5d1d36e0af80..3a1d9b6f24f7 100644 --- a/sdk/keyvault/arm-keyvault/LICENSE +++ b/sdk/keyvault/arm-keyvault/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Microsoft +Copyright (c) 2023 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/keyvault/arm-keyvault/README.md b/sdk/keyvault/arm-keyvault/README.md index 78324c43b8ce..f582b32c1190 100644 --- a/sdk/keyvault/arm-keyvault/README.md +++ b/sdk/keyvault/arm-keyvault/README.md @@ -6,7 +6,7 @@ The Azure management API provides a RESTful set of web services that interact wi [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault) | [Package (NPM)](https://www.npmjs.com/package/@azure/arm-keyvault) | -[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-keyvault?view=azure-node-preview) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-keyvault) | [Samples](https://github.com/Azure-Samples/azure-samples-js-management) ## Getting started diff --git a/sdk/keyvault/arm-keyvault/_meta.json b/sdk/keyvault/arm-keyvault/_meta.json index 181c4273f370..e59ec18c6cbe 100644 --- a/sdk/keyvault/arm-keyvault/_meta.json +++ b/sdk/keyvault/arm-keyvault/_meta.json @@ -1,8 +1,8 @@ { - "commit": "1fefe3f5cee88319b17c08a2dbf95e1e983a9f8c", + "commit": "6b992c049ed7d6a95465d5c0a2234fc54c87b9bf", "readme": "specification/keyvault/resource-manager/readme.md", - "autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\keyvault\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.3.20221108.1 --generate-sample=true", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\keyvault\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.10 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.4.2", - "use": "@autorest/typescript@6.0.0-rc.3.20221108.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.6.2", + "use": "@autorest/typescript@6.0.0-rc.10" } \ No newline at end of file diff --git a/sdk/keyvault/arm-keyvault/package.json b/sdk/keyvault/arm-keyvault/package.json index a0a1ac7d3d04..27dd786b96c7 100644 --- a/sdk/keyvault/arm-keyvault/package.json +++ b/sdk/keyvault/arm-keyvault/package.json @@ -3,15 +3,15 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for KeyVaultManagementClient.", - "version": "2.1.0-beta.3", + "version": "3.0.0", "engines": { "node": ">=14.0.0" }, "dependencies": { - "@azure/core-lro": "^2.2.0", + "@azure/core-lro": "^2.5.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.6.1", + "@azure/core-client": "^1.7.0", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -33,12 +33,13 @@ "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-multi-entry": "^6.0.0", "@rollup/plugin-node-resolve": "^13.1.3", - "mkdirp": "^1.0.4", + "mkdirp": "^2.1.2", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^16.0.0", "@azure/identity": "^2.0.1", "@azure-tools/test-recorder": "^3.0.0", "@azure-tools/test-credential": "^1.0.0", @@ -49,7 +50,6 @@ "@types/node": "^14.0.0", "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -111,6 +111,7 @@ ] }, "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault", "//sampleConfiguration": { "productName": "", "productSlugs": [ @@ -119,4 +120,4 @@ "disableDocsMs": true, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-keyvault?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json index 8745fb107149..6386af75ef02 100644 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json +++ b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2021-11-01-preview", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/json", @@ -10,8 +10,8 @@ "Connection": "keep-alive", "Content-Length": "761", "Content-Type": "application/json", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "c9ef49c0-94e9-4677-890c-5f4a252e4eb1" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "7dc97de3-ee29-4e47-8061-ff062e34331f" }, "RequestBody": { "location": "eastus", @@ -83,7 +83,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:20 GMT", + "Date": "Mon, 10 Apr 2023 09:25:52 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-IIS/10.0", @@ -92,15 +92,15 @@ "Vary": "Accept-Encoding", "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "c9ef49c0-94e9-4677-890c-5f4a252e4eb1", - "x-ms-correlation-request-id": "74daccc2-5b78-4d28-a1cd-06b8d58a1a92", - "x-ms-keyvault-service-version": "1.5.564.0", + "x-ms-client-request-id": "7dc97de3-ee29-4e47-8061-ff062e34331f", + "x-ms-correlation-request-id": "2ca7a39e-1883-40b7-b56c-d7205b4e1e1b", + "x-ms-keyvault-service-version": "1.5.692.1", "x-ms-ratelimit-remaining-subscription-writes": "1199", - "x-ms-request-id": "bbc8217a-5abe-4321-8260-c5b0eedf9243", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054721Z:74daccc2-5b78-4d28-a1cd-06b8d58a1a92" + "x-ms-request-id": "3bff7e0f-4d17-4f66-9ee1-315c2e716b9a", + "x-ms-routing-request-id": "JAPANEAST:20230410T092553Z:2ca7a39e-1883-40b7-b56c-d7205b4e1e1b" }, "ResponseBody": { - "id": "/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", + "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", "name": "myvaultzzzz", "type": "Microsoft.KeyVault/vaults", "location": "eastus", @@ -108,10 +108,10 @@ "systemData": { "createdBy": "azure_client_id", "createdByType": "Application", - "createdAt": "2022-11-28T05:37:14.489Z", + "createdAt": "2023-04-10T09:15:41.477Z", "lastModifiedBy": "azure_client_id", "lastModifiedByType": "Application", - "lastModifiedAt": "2022-11-28T05:47:19.768Z" + "lastModifiedAt": "2023-04-10T09:25:51.652Z" }, "properties": { "sku": { diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json index 74eaf4c990ab..de9305614140 100644 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json +++ b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json @@ -1,47 +1,47 @@ { "Entries": [ { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2021-11-01-preview", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Authorization": "Sanitized", "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "a9c08ff0-c4f2-43b3-91a8-e2e7c4dc338c" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "df941ad5-0213-45c8-8f67-75de3e69f36a" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Mon, 28 Nov 2022 05:47:33 GMT", + "Date": "Mon, 10 Apr 2023 09:26:03 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-IIS/10.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "a9c08ff0-c4f2-43b3-91a8-e2e7c4dc338c", - "x-ms-correlation-request-id": "00dd847d-daa1-4de1-a76b-fefb6822e642", - "x-ms-keyvault-service-version": "1.5.564.0", + "x-ms-client-request-id": "df941ad5-0213-45c8-8f67-75de3e69f36a", + "x-ms-correlation-request-id": "d4540343-ed21-44c9-bf08-38c37a7ca949", + "x-ms-keyvault-service-version": "1.5.692.1", "x-ms-ratelimit-remaining-subscription-deletes": "14999", - "x-ms-request-id": "40ab5a73-2454-4bf6-8ea9-52fe8f8123c7", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054734Z:00dd847d-daa1-4de1-a76b-fefb6822e642" + "x-ms-request-id": "3445da3e-9704-4e6b-b00b-45109d530dda", + "x-ms-routing-request-id": "JAPANEAST:20230410T092603Z:d4540343-ed21-44c9-bf08-38c37a7ca949" }, "ResponseBody": null }, { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Authorization": "Sanitized", "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "5b949b7c-608f-4363-824a-6e60a4bb2e3a" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "ebd08a48-4766-496d-af7f-83f20e01eb98" }, "RequestBody": null, "StatusCode": 200, @@ -50,16 +50,16 @@ "Content-Encoding": "gzip", "Content-Length": "12", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:33 GMT", + "Date": "Mon, 10 Apr 2023 09:26:03 GMT", "Expires": "-1", "Pragma": "no-cache", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "c131c9ee-242f-4756-bfe3-1ece68a8516a", - "x-ms-ratelimit-remaining-subscription-reads": "11995", - "x-ms-request-id": "c131c9ee-242f-4756-bfe3-1ece68a8516a", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054734Z:c131c9ee-242f-4756-bfe3-1ece68a8516a" + "x-ms-correlation-request-id": "efab7c5a-e432-46e8-b121-5018bcdd4b58", + "x-ms-ratelimit-remaining-subscription-reads": "11996", + "x-ms-request-id": "efab7c5a-e432-46e8-b121-5018bcdd4b58", + "x-ms-routing-request-id": "JAPANEAST:20230410T092603Z:efab7c5a-e432-46e8-b121-5018bcdd4b58" }, "ResponseBody": { "value": [] diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json index f4484185327c..8745d6fc37d3 100644 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json +++ b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json @@ -1,15 +1,15 @@ { "Entries": [ { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2021-11-01-preview", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Authorization": "Sanitized", "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "710900f4-00dc-454a-a573-4ebaa4733892" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "3560a25a-7afb-4be6-a5d1-64cfd3c760ea" }, "RequestBody": null, "StatusCode": 200, @@ -17,7 +17,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:22 GMT", + "Date": "Mon, 10 Apr 2023 09:25:53 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-IIS/10.0", @@ -26,15 +26,15 @@ "Vary": "Accept-Encoding", "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "710900f4-00dc-454a-a573-4ebaa4733892", - "x-ms-correlation-request-id": "8a71d829-9f21-4655-b848-d4f10f69042c", - "x-ms-keyvault-service-version": "1.5.564.0", + "x-ms-client-request-id": "3560a25a-7afb-4be6-a5d1-64cfd3c760ea", + "x-ms-correlation-request-id": "aa464d69-6016-4a20-bba0-9c08efe06804", + "x-ms-keyvault-service-version": "1.5.692.1", "x-ms-ratelimit-remaining-subscription-reads": "11999", - "x-ms-request-id": "679225a1-381d-4b82-acf6-2b6c0b768b6d", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054722Z:8a71d829-9f21-4655-b848-d4f10f69042c" + "x-ms-request-id": "b4dfe27c-1225-4a85-bc8f-833f19e664df", + "x-ms-routing-request-id": "JAPANEAST:20230410T092554Z:aa464d69-6016-4a20-bba0-9c08efe06804" }, "ResponseBody": { - "id": "/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", + "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", "name": "myvaultzzzz", "type": "Microsoft.KeyVault/vaults", "location": "eastus", @@ -42,10 +42,10 @@ "systemData": { "createdBy": "azure_client_id", "createdByType": "Application", - "createdAt": "2022-11-28T05:37:14.489Z", + "createdAt": "2023-04-10T09:15:41.477Z", "lastModifiedBy": "azure_client_id", "lastModifiedByType": "Application", - "lastModifiedAt": "2022-11-28T05:47:19.768Z" + "lastModifiedAt": "2023-04-10T09:25:51.652Z" }, "properties": { "sku": { diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json index bb6d636fb0ad..7cda3e03db38 100644 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json +++ b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json @@ -1,15 +1,15 @@ { "Entries": [ { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Authorization": "Sanitized", "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "e9e3eff0-2568-426d-acb3-c5229d4e436b" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "ac7fe413-dd72-4224-bb7a-0154907acd97" }, "RequestBody": null, "StatusCode": 200, @@ -17,7 +17,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:23 GMT", + "Date": "Mon, 10 Apr 2023 09:25:54 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-IIS/10.0", @@ -26,17 +26,17 @@ "Vary": "Accept-Encoding", "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "e9e3eff0-2568-426d-acb3-c5229d4e436b", - "x-ms-correlation-request-id": "83e4de84-ed92-4250-9b57-b2138ddf468c", - "x-ms-keyvault-service-version": "1.5.564.0", + "x-ms-client-request-id": "ac7fe413-dd72-4224-bb7a-0154907acd97", + "x-ms-correlation-request-id": "6bbbc8ef-548b-46d2-b57c-e9db387166c5", + "x-ms-keyvault-service-version": "1.5.692.1", "x-ms-ratelimit-remaining-subscription-reads": "11998", - "x-ms-request-id": "3b595e57-c897-4878-8242-b0b3ef2e4dbf", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054723Z:83e4de84-ed92-4250-9b57-b2138ddf468c" + "x-ms-request-id": "7c7d8a98-73be-4aa0-a97a-4adfc85f2b28", + "x-ms-routing-request-id": "JAPANEAST:20230410T092555Z:6bbbc8ef-548b-46d2-b57c-e9db387166c5" }, "ResponseBody": { "value": [ { - "id": "/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", + "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", "name": "myvaultzzzz", "type": "Microsoft.KeyVault/vaults", "location": "eastus", @@ -44,10 +44,10 @@ "systemData": { "createdBy": "azure_client_id", "createdByType": "Application", - "createdAt": "2022-11-28T05:37:14.489Z", + "createdAt": "2023-04-10T09:15:41.477Z", "lastModifiedBy": "azure_client_id", "lastModifiedByType": "Application", - "lastModifiedAt": "2022-11-28T05:47:19.768Z" + "lastModifiedAt": "2023-04-10T09:25:51.652Z" }, "properties": { "sku": { @@ -117,19 +117,19 @@ } } ], - "nextLink": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview\u0026$skiptoken=bXl3b3Jrc3BhY2VuYW0zNTYwODU2MDA0" + "nextLink": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01\u0026$skiptoken=bXl2YXVsdHp6eno=" } }, { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview\u0026$skiptoken=bXl3b3Jrc3BhY2VuYW0zNTYwODU2MDA0", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01\u0026$skiptoken=bXl2YXVsdHp6eno=", "RequestMethod": "GET", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Authorization": "Sanitized", "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "d2ace36b-d153-4d21-bbce-7fb26453eb92" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "babc6c5b-8049-448f-ba59-87b9b7fb29ff" }, "RequestBody": null, "StatusCode": 200, @@ -137,7 +137,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:23 GMT", + "Date": "Mon, 10 Apr 2023 09:25:55 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-IIS/10.0", @@ -146,50 +146,12 @@ "Vary": "Accept-Encoding", "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "d2ace36b-d153-4d21-bbce-7fb26453eb92", - "x-ms-correlation-request-id": "8427f64a-7a8d-431b-8739-30ae56d05f1e", - "x-ms-keyvault-service-version": "1.5.564.0", + "x-ms-client-request-id": "babc6c5b-8049-448f-ba59-87b9b7fb29ff", + "x-ms-correlation-request-id": "9f2174ce-d317-4d80-9d37-0119663796f9", + "x-ms-keyvault-service-version": "1.5.692.1", "x-ms-ratelimit-remaining-subscription-reads": "11997", - "x-ms-request-id": "bb442bda-45ea-4090-a9d4-1bf7a347dda5", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054724Z:8427f64a-7a8d-431b-8739-30ae56d05f1e" - }, - "ResponseBody": { - "value": [], - "nextLink": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview\u0026$skiptoken=bXl3b3Jrc3BhY2VuYW04MDAwMjEwMjYz" - } - }, - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults?api-version=2021-11-01-preview\u0026$skiptoken=bXl3b3Jrc3BhY2VuYW04MDAwMjEwMjYz", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "2153f3b7-2007-4f2e-8f56-79638b3e1693" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:23 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked", - "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "2153f3b7-2007-4f2e-8f56-79638b3e1693", - "x-ms-correlation-request-id": "da613d4a-7b7d-4344-ab60-f4d9cdddcec5", - "x-ms-keyvault-service-version": "1.5.564.0", - "x-ms-ratelimit-remaining-subscription-reads": "11996", - "x-ms-request-id": "d6bdd912-5d4b-4eea-b578-8336d589ab3f", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054724Z:da613d4a-7b7d-4344-ab60-f4d9cdddcec5" + "x-ms-request-id": "4ddcfea7-990b-453e-8515-d6dc7b805ee0", + "x-ms-routing-request-id": "JAPANEAST:20230410T092556Z:9f2174ce-d317-4d80-9d37-0119663796f9" }, "ResponseBody": { "value": [] diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json index 77a4b92955ad..ea213f7d1d73 100644 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json +++ b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2021-11-01-preview", + "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", "RequestMethod": "PATCH", "RequestHeaders": { "Accept": "application/json", @@ -10,8 +10,8 @@ "Connection": "keep-alive", "Content-Length": "741", "Content-Type": "application/json", - "User-Agent": "azsdk-js-arm-keyvault/2.1.0-beta.2 core-rest-pipeline/1.10.1 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "f6142ee0-9a34-44cb-9da3-025df8db24dc" + "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "6948c5a2-bd32-4b35-af46-073dde26d2af" }, "RequestBody": { "properties": { @@ -82,7 +82,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 28 Nov 2022 05:47:26 GMT", + "Date": "Mon, 10 Apr 2023 09:25:58 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-IIS/10.0", @@ -91,15 +91,15 @@ "Vary": "Accept-Encoding", "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "f6142ee0-9a34-44cb-9da3-025df8db24dc", - "x-ms-correlation-request-id": "79af0de1-cf9a-4f2b-b5d0-fd35b27153f6", - "x-ms-keyvault-service-version": "1.5.564.0", + "x-ms-client-request-id": "6948c5a2-bd32-4b35-af46-073dde26d2af", + "x-ms-correlation-request-id": "91195ab7-d8c0-4351-8582-4d95599b3c56", + "x-ms-keyvault-service-version": "1.5.692.1", "x-ms-ratelimit-remaining-subscription-writes": "1198", - "x-ms-request-id": "a5653408-69fe-4d20-9fe0-b699a12897e2", - "x-ms-routing-request-id": "SOUTHEASTASIA:20221128T054727Z:79af0de1-cf9a-4f2b-b5d0-fd35b27153f6" + "x-ms-request-id": "a257674c-12b0-43bb-bd80-2f4b085e2ef8", + "x-ms-routing-request-id": "JAPANEAST:20230410T092558Z:91195ab7-d8c0-4351-8582-4d95599b3c56" }, "ResponseBody": { - "id": "/subscriptions/azure_subscription_id/resourceGroups/myjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", + "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", "name": "myvaultzzzz", "type": "Microsoft.KeyVault/vaults", "location": "eastus", @@ -107,10 +107,10 @@ "systemData": { "createdBy": "azure_client_id", "createdByType": "Application", - "createdAt": "2022-11-28T05:37:14.489Z", + "createdAt": "2023-04-10T09:15:41.477Z", "lastModifiedBy": "azure_client_id", "lastModifiedByType": "Application", - "lastModifiedAt": "2022-11-28T05:47:26.924Z" + "lastModifiedAt": "2023-04-10T09:25:57.792Z" }, "properties": { "sku": { diff --git a/sdk/keyvault/arm-keyvault/review/arm-keyvault.api.md b/sdk/keyvault/arm-keyvault/review/arm-keyvault.api.md index 92386afbe3c1..733eed42bd11 100644 --- a/sdk/keyvault/arm-keyvault/review/arm-keyvault.api.md +++ b/sdk/keyvault/arm-keyvault/review/arm-keyvault.api.md @@ -6,9 +6,9 @@ import * as coreAuth from '@azure/core-auth'; import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; -import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import { SimplePollerLike } from '@azure/core-lro'; // @public export interface AccessPolicyEntry { @@ -29,6 +29,9 @@ export interface Action { // @public export type ActionsRequired = string; +// @public +export type ActivationStatus = string; + // @public export interface Attributes { readonly created?: Date; @@ -41,6 +44,18 @@ export interface Attributes { // @public export type CertificatePermissions = string; +// @public +export interface CheckMhsmNameAvailabilityParameters { + name: string; +} + +// @public +export interface CheckMhsmNameAvailabilityResult { + readonly message?: string; + readonly nameAvailable?: boolean; + readonly reason?: Reason; +} + // @public export interface CheckNameAvailabilityResult { readonly message?: string; @@ -131,6 +146,9 @@ export interface ErrorModel { readonly message?: string; } +// @public +export type GeoReplicationRegionProvisioningState = string; + // @public export function getContinuationToken(page: unknown): string | undefined; @@ -291,12 +309,16 @@ export class KeyVaultManagementClient extends coreClient.ServiceClient { // (undocumented) keys: Keys; // (undocumented) + managedHsmKeys: ManagedHsmKeys; + // (undocumented) managedHsms: ManagedHsms; // (undocumented) mhsmPrivateEndpointConnections: MhsmPrivateEndpointConnections; // (undocumented) mhsmPrivateLinkResources: MhsmPrivateLinkResources; // (undocumented) + mhsmRegions: MhsmRegions; + // (undocumented) operations: Operations; // (undocumented) privateEndpointConnections: PrivateEndpointConnections; @@ -322,6 +344,14 @@ export enum KnownActionsRequired { None = "None" } +// @public +export enum KnownActivationStatus { + Active = "Active", + Failed = "Failed", + NotActivated = "NotActivated", + Unknown = "Unknown" +} + // @public export enum KnownCertificatePermissions { All = "all", @@ -351,6 +381,16 @@ export enum KnownDeletionRecoveryLevel { RecoverablePurgeable = "Recoverable+Purgeable" } +// @public +export enum KnownGeoReplicationRegionProvisioningState { + Cleanup = "Cleanup", + Deleting = "Deleting", + Failed = "Failed", + Preprovisioning = "Preprovisioning", + Provisioning = "Provisioning", + Succeeded = "Succeeded" +} + // @public export enum KnownIdentityType { Application = "Application", @@ -528,11 +568,146 @@ export interface ManagedHsm extends ManagedHsmResource { properties?: ManagedHsmProperties; } +// @public (undocumented) +export interface ManagedHsmAction { + type?: KeyRotationPolicyActionType; +} + // @public export interface ManagedHsmError { readonly error?: ErrorModel; } +// @public +export interface ManagedHsmKey extends ProxyResourceWithoutSystemData { + attributes?: ManagedHsmKeyAttributes; + curveName?: JsonWebKeyCurveName; + // (undocumented) + keyOps?: JsonWebKeyOperation[]; + keySize?: number; + readonly keyUri?: string; + readonly keyUriWithVersion?: string; + kty?: JsonWebKeyType; + releasePolicy?: ManagedHsmKeyReleasePolicy; + rotationPolicy?: ManagedHsmRotationPolicy; +} + +// @public +export interface ManagedHsmKeyAttributes { + readonly created?: number; + enabled?: boolean; + expires?: number; + exportable?: boolean; + notBefore?: number; + readonly recoveryLevel?: DeletionRecoveryLevel; + readonly updated?: number; +} + +// @public +export interface ManagedHsmKeyCreateParameters { + properties: ManagedHsmKeyProperties; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface ManagedHsmKeyListResult { + nextLink?: string; + value?: ManagedHsmKey[]; +} + +// @public +export interface ManagedHsmKeyProperties { + attributes?: ManagedHsmKeyAttributes; + curveName?: JsonWebKeyCurveName; + // (undocumented) + keyOps?: JsonWebKeyOperation[]; + keySize?: number; + readonly keyUri?: string; + readonly keyUriWithVersion?: string; + kty?: JsonWebKeyType; + releasePolicy?: ManagedHsmKeyReleasePolicy; + rotationPolicy?: ManagedHsmRotationPolicy; +} + +// @public (undocumented) +export interface ManagedHsmKeyReleasePolicy { + contentType?: string; + data?: Uint8Array; +} + +// @public (undocumented) +export interface ManagedHsmKeyRotationPolicyAttributes { + readonly created?: number; + expiryTime?: string; + readonly updated?: number; +} + +// @public +export interface ManagedHsmKeys { + createIfNotExist(resourceGroupName: string, name: string, keyName: string, parameters: ManagedHsmKeyCreateParameters, options?: ManagedHsmKeysCreateIfNotExistOptionalParams): Promise; + get(resourceGroupName: string, name: string, keyName: string, options?: ManagedHsmKeysGetOptionalParams): Promise; + getVersion(resourceGroupName: string, name: string, keyName: string, keyVersion: string, options?: ManagedHsmKeysGetVersionOptionalParams): Promise; + list(resourceGroupName: string, name: string, options?: ManagedHsmKeysListOptionalParams): PagedAsyncIterableIterator; + listVersions(resourceGroupName: string, name: string, keyName: string, options?: ManagedHsmKeysListVersionsOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface ManagedHsmKeysCreateIfNotExistOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysCreateIfNotExistResponse = ManagedHsmKey; + +// @public +export interface ManagedHsmKeysGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysGetResponse = ManagedHsmKey; + +// @public +export interface ManagedHsmKeysGetVersionOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysGetVersionResponse = ManagedHsmKey; + +// @public +export interface ManagedHsmKeysListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysListNextResponse = ManagedHsmKeyListResult; + +// @public +export interface ManagedHsmKeysListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysListResponse = ManagedHsmKeyListResult; + +// @public +export interface ManagedHsmKeysListVersionsNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysListVersionsNextResponse = ManagedHsmKeyListResult; + +// @public +export interface ManagedHsmKeysListVersionsOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmKeysListVersionsResponse = ManagedHsmKeyListResult; + +// @public (undocumented) +export interface ManagedHsmLifetimeAction { + action?: ManagedHsmAction; + trigger?: ManagedHsmTrigger; +} + // @public export interface ManagedHsmListResult { nextLink?: string; @@ -550,7 +725,9 @@ export interface ManagedHsmProperties { readonly privateEndpointConnections?: MhsmPrivateEndpointConnectionItem[]; readonly provisioningState?: ProvisioningState; publicNetworkAccess?: PublicNetworkAccess; + regions?: MhsmGeoReplicatedRegion[]; readonly scheduledPurgeDate?: Date; + readonly securityDomainProperties?: ManagedHSMSecurityDomainProperties; softDeleteRetentionInDays?: number; readonly statusMessage?: string; tenantId?: string; @@ -569,16 +746,23 @@ export interface ManagedHsmResource { readonly type?: string; } +// @public (undocumented) +export interface ManagedHsmRotationPolicy { + attributes?: ManagedHsmKeyRotationPolicyAttributes; + lifetimeActions?: ManagedHsmLifetimeAction[]; +} + // @public export interface ManagedHsms { - beginCreateOrUpdate(resourceGroupName: string, name: string, parameters: ManagedHsm, options?: ManagedHsmsCreateOrUpdateOptionalParams): Promise, ManagedHsmsCreateOrUpdateResponse>>; + beginCreateOrUpdate(resourceGroupName: string, name: string, parameters: ManagedHsm, options?: ManagedHsmsCreateOrUpdateOptionalParams): Promise, ManagedHsmsCreateOrUpdateResponse>>; beginCreateOrUpdateAndWait(resourceGroupName: string, name: string, parameters: ManagedHsm, options?: ManagedHsmsCreateOrUpdateOptionalParams): Promise; - beginDelete(resourceGroupName: string, name: string, options?: ManagedHsmsDeleteOptionalParams): Promise, void>>; + beginDelete(resourceGroupName: string, name: string, options?: ManagedHsmsDeleteOptionalParams): Promise, void>>; beginDeleteAndWait(resourceGroupName: string, name: string, options?: ManagedHsmsDeleteOptionalParams): Promise; - beginPurgeDeleted(name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams): Promise, void>>; - beginPurgeDeletedAndWait(name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams): Promise; - beginUpdate(resourceGroupName: string, name: string, parameters: ManagedHsm, options?: ManagedHsmsUpdateOptionalParams): Promise, ManagedHsmsUpdateResponse>>; + beginPurgeDeleted(name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams): Promise, ManagedHsmsPurgeDeletedResponse>>; + beginPurgeDeletedAndWait(name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams): Promise; + beginUpdate(resourceGroupName: string, name: string, parameters: ManagedHsm, options?: ManagedHsmsUpdateOptionalParams): Promise, ManagedHsmsUpdateResponse>>; beginUpdateAndWait(resourceGroupName: string, name: string, parameters: ManagedHsm, options?: ManagedHsmsUpdateOptionalParams): Promise; + checkMhsmNameAvailability(mhsmName: CheckMhsmNameAvailabilityParameters, options?: ManagedHsmsCheckMhsmNameAvailabilityOptionalParams): Promise; get(resourceGroupName: string, name: string, options?: ManagedHsmsGetOptionalParams): Promise; getDeleted(name: string, location: string, options?: ManagedHsmsGetDeletedOptionalParams): Promise; listByResourceGroup(resourceGroupName: string, options?: ManagedHsmsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; @@ -586,6 +770,18 @@ export interface ManagedHsms { listDeleted(options?: ManagedHsmsListDeletedOptionalParams): PagedAsyncIterableIterator; } +// @public +export interface ManagedHsmsCheckMhsmNameAvailabilityOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ManagedHsmsCheckMhsmNameAvailabilityResponse = CheckMhsmNameAvailabilityResult; + +// @public +export interface ManagedHsmsCreateOrUpdateHeaders { + location?: string; +} + // @public export interface ManagedHsmsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { resumeFrom?: string; @@ -595,12 +791,23 @@ export interface ManagedHsmsCreateOrUpdateOptionalParams extends coreClient.Oper // @public export type ManagedHsmsCreateOrUpdateResponse = ManagedHsm; +// @public +export interface ManagedHsmsDeleteHeaders { + location?: string; +} + // @public export interface ManagedHsmsDeleteOptionalParams extends coreClient.OperationOptions { resumeFrom?: string; updateIntervalInMs?: number; } +// @public +export interface ManagedHSMSecurityDomainProperties { + readonly activationStatus?: ActivationStatus; + readonly activationStatusMessage?: string; +} + // @public export interface ManagedHsmsGetDeletedOptionalParams extends coreClient.OperationOptions { } @@ -629,7 +836,6 @@ export type ManagedHsmSkuName = "Standard_B1" | "Custom_B32"; // @public export interface ManagedHsmsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -645,7 +851,6 @@ export type ManagedHsmsListByResourceGroupResponse = ManagedHsmListResult; // @public export interface ManagedHsmsListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -673,12 +878,20 @@ export interface ManagedHsmsListDeletedOptionalParams extends coreClient.Operati // @public export type ManagedHsmsListDeletedResponse = DeletedManagedHsmListResult; +// @public +export interface ManagedHsmsPurgeDeletedHeaders { + location?: string; +} + // @public export interface ManagedHsmsPurgeDeletedOptionalParams extends coreClient.OperationOptions { resumeFrom?: string; updateIntervalInMs?: number; } +// @public +export type ManagedHsmsPurgeDeletedResponse = ManagedHsmsPurgeDeletedHeaders; + // @public export interface ManagedHsmsUpdateHeaders { location?: string; @@ -693,6 +906,12 @@ export interface ManagedHsmsUpdateOptionalParams extends coreClient.OperationOpt // @public export type ManagedHsmsUpdateResponse = ManagedHsm; +// @public (undocumented) +export interface ManagedHsmTrigger { + timeAfterCreate?: string; + timeBeforeExpiry?: string; +} + // @public export interface MetricSpecification { aggregationType?: string; @@ -708,6 +927,13 @@ export interface MetricSpecification { unit?: string; } +// @public +export interface MhsmGeoReplicatedRegion { + isPrimary?: boolean; + name?: string; + readonly provisioningState?: GeoReplicationRegionProvisioningState; +} + // @public export interface MhsmipRule { value: string; @@ -745,7 +971,7 @@ export interface MhsmPrivateEndpointConnectionItem { // @public export interface MhsmPrivateEndpointConnections { - beginDelete(resourceGroupName: string, name: string, privateEndpointConnectionName: string, options?: MhsmPrivateEndpointConnectionsDeleteOptionalParams): Promise, MhsmPrivateEndpointConnectionsDeleteResponse>>; + beginDelete(resourceGroupName: string, name: string, privateEndpointConnectionName: string, options?: MhsmPrivateEndpointConnectionsDeleteOptionalParams): Promise, MhsmPrivateEndpointConnectionsDeleteResponse>>; beginDeleteAndWait(resourceGroupName: string, name: string, privateEndpointConnectionName: string, options?: MhsmPrivateEndpointConnectionsDeleteOptionalParams): Promise; get(resourceGroupName: string, name: string, privateEndpointConnectionName: string, options?: MhsmPrivateEndpointConnectionsGetOptionalParams): Promise; listByResource(resourceGroupName: string, name: string, options?: MhsmPrivateEndpointConnectionsListByResourceOptionalParams): PagedAsyncIterableIterator; @@ -755,7 +981,6 @@ export interface MhsmPrivateEndpointConnections { // @public export interface MhsmPrivateEndpointConnectionsDeleteHeaders { location?: string; - retryAfter?: number; } // @public @@ -838,6 +1063,31 @@ export interface MhsmPrivateLinkServiceConnectionState { status?: PrivateEndpointServiceConnectionStatus; } +// @public +export interface MhsmRegions { + listByResource(resourceGroupName: string, name: string, options?: MhsmRegionsListByResourceOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface MhsmRegionsListByResourceNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type MhsmRegionsListByResourceNextResponse = MhsmRegionsListResult; + +// @public +export interface MhsmRegionsListByResourceOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type MhsmRegionsListByResourceResponse = MhsmRegionsListResult; + +// @public +export interface MhsmRegionsListResult { + nextLink?: string; + value?: MhsmGeoReplicatedRegion[]; +} + // @public export interface MhsmVirtualNetworkRule { id: string; @@ -941,7 +1191,7 @@ export type PrivateEndpointConnectionProvisioningState = string; // @public export interface PrivateEndpointConnections { - beginDelete(resourceGroupName: string, vaultName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsDeleteOptionalParams): Promise, PrivateEndpointConnectionsDeleteResponse>>; + beginDelete(resourceGroupName: string, vaultName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsDeleteOptionalParams): Promise, PrivateEndpointConnectionsDeleteResponse>>; beginDeleteAndWait(resourceGroupName: string, vaultName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsDeleteOptionalParams): Promise; get(resourceGroupName: string, vaultName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsGetOptionalParams): Promise; listByResource(resourceGroupName: string, vaultName: string, options?: PrivateEndpointConnectionsListByResourceOptionalParams): PagedAsyncIterableIterator; @@ -1034,6 +1284,16 @@ export interface PrivateLinkServiceConnectionState { // @public export type ProvisioningState = string; +// @public +export interface ProxyResourceWithoutSystemData { + readonly id?: string; + readonly name?: string; + tags?: { + [propertyName: string]: string; + }; + readonly type?: string; +} + // @public export type PublicNetworkAccess = string; @@ -1137,7 +1397,6 @@ export type SecretsGetResponse = Secret; // @public export interface SecretsListNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -1294,9 +1553,9 @@ export type VaultProvisioningState = string; // @public export interface Vaults { - beginCreateOrUpdate(resourceGroupName: string, vaultName: string, parameters: VaultCreateOrUpdateParameters, options?: VaultsCreateOrUpdateOptionalParams): Promise, VaultsCreateOrUpdateResponse>>; + beginCreateOrUpdate(resourceGroupName: string, vaultName: string, parameters: VaultCreateOrUpdateParameters, options?: VaultsCreateOrUpdateOptionalParams): Promise, VaultsCreateOrUpdateResponse>>; beginCreateOrUpdateAndWait(resourceGroupName: string, vaultName: string, parameters: VaultCreateOrUpdateParameters, options?: VaultsCreateOrUpdateOptionalParams): Promise; - beginPurgeDeleted(vaultName: string, location: string, options?: VaultsPurgeDeletedOptionalParams): Promise, void>>; + beginPurgeDeleted(vaultName: string, location: string, options?: VaultsPurgeDeletedOptionalParams): Promise, void>>; beginPurgeDeletedAndWait(vaultName: string, location: string, options?: VaultsPurgeDeletedOptionalParams): Promise; checkNameAvailability(vaultName: VaultCheckNameAvailabilityParameters, options?: VaultsCheckNameAvailabilityOptionalParams): Promise; delete(resourceGroupName: string, vaultName: string, options?: VaultsDeleteOptionalParams): Promise; @@ -1346,7 +1605,6 @@ export type VaultsGetResponse = Vault; // @public export interface VaultsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -1362,7 +1620,6 @@ export type VaultsListByResourceGroupResponse = VaultListResult; // @public export interface VaultsListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -1392,7 +1649,6 @@ export type VaultsListDeletedResponse = DeletedVaultListResult; // @public export interface VaultsListNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public diff --git a/sdk/keyvault/arm-keyvault/samples-dev/keysCreateIfNotExistSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/keysCreateIfNotExistSample.ts index 7ecd3c637f1a..e6e05de6641c 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/keysCreateIfNotExistSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/keysCreateIfNotExistSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to 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. * * @summary 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. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/createKey.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createKey.json */ async function createAKey() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault-name"; const keyName = "sample-key-name"; const parameters: KeyCreateParameters = { properties: { kty: "RSA" } }; @@ -37,4 +43,8 @@ async function createAKey() { console.log(result); } -createAKey().catch(console.error); +async function main() { + createAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/keysGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/keysGetSample.ts index 735ec5f853db..ffac62a62833 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/keysGetSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/keysGetSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the current version of the specified key from the specified key vault. * * @summary Gets the current version of the specified key from the specified key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/getKey.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKey.json */ async function getAKey() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault-name"; const keyName = "sample-key-name"; const credential = new DefaultAzureCredential(); @@ -28,4 +34,8 @@ async function getAKey() { console.log(result); } -getAKey().catch(console.error); +async function main() { + getAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/keysGetVersionSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/keysGetVersionSample.ts index 1762ef9dbdd7..a5cdfaa99d04 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/keysGetVersionSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/keysGetVersionSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified version of the specified key in the specified key vault. * * @summary Gets the specified version of the specified key in the specified key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/getKeyVersion.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKeyVersion.json */ async function getAKeyVersion() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault-name"; const keyName = "sample-key-name"; const keyVersion = "fd618d9519b74f9aae94ade66b876acc"; @@ -34,4 +40,8 @@ async function getAKeyVersion() { console.log(result); } -getAKeyVersion().catch(console.error); +async function main() { + getAKeyVersion(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/keysListSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/keysListSample.ts index 2a9ba2c0ec22..2c1f532c1183 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/keysListSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/keysListSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Lists the keys in the specified key vault. * * @summary Lists the keys in the specified key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listKeys.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeys.json */ async function listKeysInTheVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault-name"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -30,4 +36,8 @@ async function listKeysInTheVault() { console.log(resArray); } -listKeysInTheVault().catch(console.error); +async function main() { + listKeysInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/keysListVersionsSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/keysListVersionsSample.ts index cbb7d74b055f..85e9a12364fd 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/keysListVersionsSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/keysListVersionsSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Lists the versions of the specified key in the specified key vault. * * @summary Lists the versions of the specified key in the specified key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listKeyVersions.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeyVersions.json */ async function listKeyVersionsInTheVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault-name"; const keyName = "sample-key-name"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function listKeyVersionsInTheVault() { console.log(resArray); } -listKeyVersionsInTheVault().catch(console.error); +async function main() { + listKeyVersionsInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysCreateIfNotExistSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysCreateIfNotExistSample.ts new file mode 100644 index 000000000000..2889fa177aa1 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysCreateIfNotExistSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + ManagedHsmKeyCreateParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to 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. + * + * @summary 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. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmCreateKey.json + */ +async function createAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const parameters: ManagedHsmKeyCreateParameters = { + properties: { kty: "RSA" } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.createIfNotExist( + resourceGroupName, + name, + keyName, + parameters + ); + console.log(result); +} + +async function main() { + createAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetSample.ts new file mode 100644 index 000000000000..b9a76ad1dc70 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the current version of the specified key from the specified managed HSM. + * + * @summary Gets the current version of the specified key from the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKey.json + */ +async function getAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.get( + resourceGroupName, + name, + keyName + ); + console.log(result); +} + +async function main() { + getAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetVersionSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetVersionSample.ts new file mode 100644 index 000000000000..dd3b842997f8 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysGetVersionSample.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified version of the specified key in the specified managed HSM. + * + * @summary Gets the specified version of the specified key in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKeyVersion.json + */ +async function getAKeyVersion() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.getVersion( + resourceGroupName, + name, + keyName, + keyVersion + ); + console.log(result); +} + +async function main() { + getAKeyVersion(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListSample.ts new file mode 100644 index 000000000000..4e8c320e4ba3 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the keys in the specified managed HSM. + * + * @summary Lists the keys in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeys.json + */ +async function listKeysInTheManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsmKeys.list(resourceGroupName, name)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeysInTheManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListVersionsSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListVersionsSample.ts new file mode 100644 index 000000000000..92790c2ddee2 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmKeysListVersionsSample.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the versions of the specified key in the specified managed HSM. + * + * @summary Lists the versions of the specified key in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeyVersions.json + */ +async function listKeyVersionsInTheManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsmKeys.listVersions( + resourceGroupName, + name, + keyName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeyVersionsInTheManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCheckMhsmNameAvailabilitySample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCheckMhsmNameAvailabilitySample.ts new file mode 100644 index 000000000000..aea7dd03a24f --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCheckMhsmNameAvailabilitySample.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + CheckMhsmNameAvailabilityParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks that the managed hsm name is valid and is not already in use. + * + * @summary Checks that the managed hsm name is valid and is not already in use. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_checkMhsmNameAvailability.json + */ +async function validateAManagedHsmName() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const mhsmName: CheckMhsmNameAvailabilityParameters = { name: "sample-mhsm" }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.checkMhsmNameAvailability(mhsmName); + console.log(result); +} + +async function main() { + validateAManagedHsmName(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCreateOrUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCreateOrUpdateSample.ts index 64e8c46777d4..59c9c15f02b4 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCreateOrUpdateSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsCreateOrUpdateSample.ts @@ -10,21 +10,27 @@ // Licensed under the MIT License. import { ManagedHsm, KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Create or update a managed HSM Pool in the specified subscription. * * @summary Create or update a managed HSM Pool in the specified subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_CreateOrUpdate.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_CreateOrUpdate.json */ async function createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "hsm-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; const name = "hsm1"; const parameters: ManagedHsm = { location: "westus", properties: { - enablePurgeProtection: true, + enablePurgeProtection: false, enableSoftDelete: true, initialAdminObjectIds: ["00000000-0000-0000-0000-000000000000"], softDeleteRetentionInDays: 90, @@ -43,4 +49,8 @@ async function createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool() { console.log(result); } -createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool().catch(console.error); +async function main() { + createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsDeleteSample.ts index 88ca08b48f15..5eecebfd3557 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsDeleteSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsDeleteSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes the specified managed HSM Pool. * * @summary Deletes the specified managed HSM Pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_Delete.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Delete.json */ async function deleteAManagedHsmPool() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "hsm-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; const name = "hsm1"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -30,4 +36,8 @@ async function deleteAManagedHsmPool() { console.log(result); } -deleteAManagedHsmPool().catch(console.error); +async function main() { + deleteAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetDeletedSample.ts index b2c45209e9d9..9344dffbf5f5 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetDeletedSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetDeletedSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified deleted managed HSM. * * @summary Gets the specified deleted managed HSM. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/DeletedManagedHsm_Get.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json */ async function retrieveADeletedManagedHsm() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const name = "hsm1"; const location = "westus"; const credential = new DefaultAzureCredential(); @@ -27,4 +32,8 @@ async function retrieveADeletedManagedHsm() { console.log(result); } -retrieveADeletedManagedHsm().catch(console.error); +async function main() { + retrieveADeletedManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetSample.ts index df748000be72..7a3ca6e0fdd6 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsGetSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified managed HSM Pool. * * @summary Gets the specified managed HSM Pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_Get.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json */ async function retrieveAManagedHsmPool() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "hsm-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; const name = "hsm1"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -27,4 +33,8 @@ async function retrieveAManagedHsmPool() { console.log(result); } -retrieveAManagedHsmPool().catch(console.error); +async function main() { + retrieveAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListByResourceGroupSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListByResourceGroupSample.ts index b9dc53b31d49..e6a36394c66f 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListByResourceGroupSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListByResourceGroupSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. * * @summary The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_ListByResourceGroup.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListByResourceGroup.json */ async function listManagedHsmPoolsInAResourceGroup() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "hsm-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); const resArray = new Array(); @@ -31,4 +37,8 @@ async function listManagedHsmPoolsInAResourceGroup() { console.log(resArray); } -listManagedHsmPoolsInAResourceGroup().catch(console.error); +async function main() { + listManagedHsmPoolsInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListBySubscriptionSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListBySubscriptionSample.ts index d03bc70a78c2..26d4b038780b 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListBySubscriptionSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListBySubscriptionSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the managed HSM Pools associated with the subscription. * * @summary The List operation gets information about the managed HSM Pools associated with the subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_ListBySubscription.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListBySubscription.json */ async function listManagedHsmPoolsInASubscription() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); const resArray = new Array(); @@ -28,4 +33,8 @@ async function listManagedHsmPoolsInASubscription() { console.log(resArray); } -listManagedHsmPoolsInASubscription().catch(console.error); +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListDeletedSample.ts index f7c05c458b9b..156e074e8ab8 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListDeletedSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsListDeletedSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the deleted managed HSMs associated with the subscription. * * @summary The List operation gets information about the deleted managed HSMs associated with the subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/DeletedManagedHsm_List.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_List.json */ async function listDeletedManagedHsMSInTheSpecifiedSubscription() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); const resArray = new Array(); @@ -28,4 +33,8 @@ async function listDeletedManagedHsMSInTheSpecifiedSubscription() { console.log(resArray); } -listDeletedManagedHsMSInTheSpecifiedSubscription().catch(console.error); +async function main() { + listDeletedManagedHsMSInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsPurgeDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsPurgeDeletedSample.ts index d74878613346..d5aa35e64a2d 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsPurgeDeletedSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsPurgeDeletedSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Permanently deletes the specified managed HSM. * * @summary Permanently deletes the specified managed HSM. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/DeletedManagedHsm_Purge.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Purge.json */ async function purgeAManagedHsmPool() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const name = "hsm1"; const location = "westus"; const credential = new DefaultAzureCredential(); @@ -30,4 +35,8 @@ async function purgeAManagedHsmPool() { console.log(result); } -purgeAManagedHsmPool().catch(console.error); +async function main() { + purgeAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsUpdateSample.ts index 5fc0dcd5e35f..cd8f26501638 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsUpdateSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/managedHsmsUpdateSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { ManagedHsm, KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Update a managed HSM Pool in the specified subscription. * * @summary Update a managed HSM Pool in the specified subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_Update.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Update.json */ async function updateAnExistingManagedHsmPool() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "hsm-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; const name = "hsm1"; const parameters: ManagedHsm = { tags: { dept: "hsm", environment: "dogfood", slice: "A" } @@ -34,4 +40,8 @@ async function updateAnExistingManagedHsmPool() { console.log(result); } -updateAnExistingManagedHsmPool().catch(console.error); +async function main() { + updateAnExistingManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsDeleteSample.ts index afadceabc004..93840d3c98d0 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsDeleteSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsDeleteSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes the specified private endpoint connection associated with the managed hsm pool. * * @summary Deletes the specified private endpoint connection associated with the managed hsm pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_deletePrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_deletePrivateEndpointConnection.json */ async function managedHsmDeletePrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const name = "sample-mhsm"; const privateEndpointConnectionName = "sample-pec"; const credential = new DefaultAzureCredential(); @@ -32,4 +38,8 @@ async function managedHsmDeletePrivateEndpointConnection() { console.log(result); } -managedHsmDeletePrivateEndpointConnection().catch(console.error); +async function main() { + managedHsmDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsGetSample.ts index ee34199bc637..7c51c0d76a7a 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsGetSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsGetSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified private endpoint connection associated with the managed HSM Pool. * * @summary Gets the specified private endpoint connection associated with the managed HSM Pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_getPrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json */ async function managedHsmGetPrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const name = "sample-mhsm"; const privateEndpointConnectionName = "sample-pec"; const credential = new DefaultAzureCredential(); @@ -32,4 +38,8 @@ async function managedHsmGetPrivateEndpointConnection() { console.log(result); } -managedHsmGetPrivateEndpointConnection().catch(console.error); +async function main() { + managedHsmGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsListByResourceSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsListByResourceSample.ts index ea86e99f81ea..9ea5ff149a73 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsListByResourceSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsListByResourceSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the private endpoint connections associated with the managed HSM Pool. * * @summary The List operation gets information about the private endpoint connections associated with the managed HSM Pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json */ async function listManagedHsmPoolsInASubscription() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const name = "sample-mhsm"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -33,4 +39,8 @@ async function listManagedHsmPoolsInASubscription() { console.log(resArray); } -listManagedHsmPoolsInASubscription().catch(console.error); +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsPutSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsPutSample.ts index f51b0aab2497..32a627c5b1aa 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsPutSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateEndpointConnectionsPutSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates the specified private endpoint connection associated with the managed hsm pool. * * @summary Updates the specified private endpoint connection associated with the managed hsm pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_putPrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json */ async function managedHsmPutPrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const name = "sample-mhsm"; const privateEndpointConnectionName = "sample-pec"; const properties: MhsmPrivateEndpointConnection = { @@ -42,4 +48,8 @@ async function managedHsmPutPrivateEndpointConnection() { console.log(result); } -managedHsmPutPrivateEndpointConnection().catch(console.error); +async function main() { + managedHsmPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts index 2456c6552d0d..8042ff4a98f7 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the private link resources supported for the managed hsm pool. * * @summary Gets the private link resources supported for the managed hsm pool. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/ManagedHsm_listPrivateLinkResources.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_listPrivateLinkResources.json */ async function keyVaultListPrivateLinkResources() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const name = "sample-mhsm"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -30,4 +36,8 @@ async function keyVaultListPrivateLinkResources() { console.log(result); } -keyVaultListPrivateLinkResources().catch(console.error); +async function main() { + keyVaultListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/mhsmRegionsListByResourceSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/mhsmRegionsListByResourceSample.ts new file mode 100644 index 000000000000..73328e7bdf29 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples-dev/mhsmRegionsListByResourceSample.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the regions associated with the managed HSM Pool. + * + * @summary The List operation gets information about the regions associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListRegionsByResource.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.mhsmRegions.listByResource( + resourceGroupName, + name + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/operationsListSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/operationsListSample.ts index 07dcba2bed08..391fc0d6fd27 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/operationsListSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/operationsListSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Lists all of the available Key Vault Rest API operations. * * @summary Lists all of the available Key Vault Rest API operations. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listOperations.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listOperations.json */ async function listsAvailableRestApiOperations() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); const resArray = new Array(); @@ -28,4 +33,8 @@ async function listsAvailableRestApiOperations() { console.log(resArray); } -listsAvailableRestApiOperations().catch(console.error); +async function main() { + listsAvailableRestApiOperations(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsDeleteSample.ts index 03f59c48cfde..0735dc74ff4f 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsDeleteSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsDeleteSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes the specified private endpoint connection associated with the key vault. * * @summary Deletes the specified private endpoint connection associated with the key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/deletePrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deletePrivateEndpointConnection.json */ async function keyVaultDeletePrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const privateEndpointConnectionName = "sample-pec"; const credential = new DefaultAzureCredential(); @@ -32,4 +38,8 @@ async function keyVaultDeletePrivateEndpointConnection() { console.log(result); } -keyVaultDeletePrivateEndpointConnection().catch(console.error); +async function main() { + keyVaultDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsGetSample.ts index 2a9c58508080..79ee19a5663b 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsGetSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsGetSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified private endpoint connection associated with the key vault. * * @summary Gets the specified private endpoint connection associated with the key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/getPrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json */ async function keyVaultGetPrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const privateEndpointConnectionName = "sample-pec"; const credential = new DefaultAzureCredential(); @@ -32,4 +38,8 @@ async function keyVaultGetPrivateEndpointConnection() { console.log(result); } -keyVaultGetPrivateEndpointConnection().catch(console.error); +async function main() { + keyVaultGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsListByResourceSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsListByResourceSample.ts index 048fb736fe9d..3d145b68aaaf 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsListByResourceSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsListByResourceSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the private endpoint connections associated with the vault. * * @summary The List operation gets information about the private endpoint connections associated with the vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listPrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateEndpointConnection.json */ async function keyVaultListPrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -33,4 +39,8 @@ async function keyVaultListPrivateEndpointConnection() { console.log(resArray); } -keyVaultListPrivateEndpointConnection().catch(console.error); +async function main() { + keyVaultListPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsPutSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsPutSample.ts index b4cd6bbb3136..292467782b5d 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsPutSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/privateEndpointConnectionsPutSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates the specified private endpoint connection associated with the key vault. * * @summary Updates the specified private endpoint connection associated with the key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/putPrivateEndpointConnection.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json */ async function keyVaultPutPrivateEndpointConnection() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const privateEndpointConnectionName = "sample-pec"; const properties: PrivateEndpointConnection = { @@ -43,4 +49,8 @@ async function keyVaultPutPrivateEndpointConnection() { console.log(result); } -keyVaultPutPrivateEndpointConnection().catch(console.error); +async function main() { + keyVaultPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/privateLinkResourcesListByVaultSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/privateLinkResourcesListByVaultSample.ts index 2683391abe5e..c6f5b46de290 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/privateLinkResourcesListByVaultSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/privateLinkResourcesListByVaultSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the private link resources supported for the key vault. * * @summary Gets the private link resources supported for the key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listPrivateLinkResources.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateLinkResources.json */ async function keyVaultListPrivateLinkResources() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -30,4 +36,8 @@ async function keyVaultListPrivateLinkResources() { console.log(result); } -keyVaultListPrivateLinkResources().catch(console.error); +async function main() { + keyVaultListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/secretsCreateOrUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/secretsCreateOrUpdateSample.ts index 4247d9cfca4c..23eb3b154ddb 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/secretsCreateOrUpdateSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/secretsCreateOrUpdateSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. * * @summary Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/createSecret.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createSecret.json */ async function createASecret() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const secretName = "secret-name"; const parameters: SecretCreateOrUpdateParameters = { @@ -39,4 +45,8 @@ async function createASecret() { console.log(result); } -createASecret().catch(console.error); +async function main() { + createASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/secretsGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/secretsGetSample.ts index 45bcee718252..c34d89a2bf01 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/secretsGetSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/secretsGetSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. * * @summary Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/getSecret.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json */ async function getASecret() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const secretName = "secret-name"; const credential = new DefaultAzureCredential(); @@ -32,4 +38,8 @@ async function getASecret() { console.log(result); } -getASecret().catch(console.error); +async function main() { + getASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/secretsListSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/secretsListSample.ts index 27ce26c6f38e..ed4032df492d 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/secretsListSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/secretsListSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. * * @summary The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listSecrets.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listSecrets.json */ async function listSecretsInTheVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -30,4 +36,8 @@ async function listSecretsInTheVault() { console.log(resArray); } -listSecretsInTheVault().catch(console.error); +async function main() { + listSecretsInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/secretsUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/secretsUpdateSample.ts index feec1bf2a886..30c3658c557a 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/secretsUpdateSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/secretsUpdateSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. * * @summary Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/updateSecret.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateSecret.json */ async function updateASecret() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const secretName = "secret-name"; const parameters: SecretPatchParameters = { @@ -39,4 +45,8 @@ async function updateASecret() { console.log(result); } -updateASecret().catch(console.error); +async function main() { + updateASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsCheckNameAvailabilitySample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsCheckNameAvailabilitySample.ts index bc480eacecbc..51f54ce1ae2a 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsCheckNameAvailabilitySample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsCheckNameAvailabilitySample.ts @@ -13,15 +13,20 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Checks that the vault name is valid and is not already in use. * * @summary Checks that the vault name is valid and is not already in use. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/checkVaultNameAvailability.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/checkVaultNameAvailability.json */ async function validateAVaultName() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const vaultName: VaultCheckNameAvailabilityParameters = { name: "sample-vault", type: "Microsoft.KeyVault/vaults" @@ -32,4 +37,8 @@ async function validateAVaultName() { console.log(result); } -validateAVaultName().catch(console.error); +async function main() { + validateAVaultName(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsCreateOrUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsCreateOrUpdateSample.ts index 1a3747bb3a4e..a5d5d3a10677 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsCreateOrUpdateSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsCreateOrUpdateSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Create or update a key vault in the specified subscription. * * @summary Create or update a key vault in the specified subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/createVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVault.json */ async function createANewVaultOrUpdateAnExistingVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-resource-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; const vaultName = "sample-vault"; const parameters: VaultCreateOrUpdateParameters = { location: "westus", @@ -97,17 +103,18 @@ async function createANewVaultOrUpdateAnExistingVault() { console.log(result); } -createANewVaultOrUpdateAnExistingVault().catch(console.error); - /** * This sample demonstrates how to Create or update a key vault in the specified subscription. * * @summary Create or update a key vault in the specified subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/createVaultWithNetworkAcls.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVaultWithNetworkAcls.json */ async function createOrUpdateAVaultWithNetworkAcls() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-resource-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; const vaultName = "sample-vault"; const parameters: VaultCreateOrUpdateParameters = { location: "westus", @@ -140,4 +147,9 @@ async function createOrUpdateAVaultWithNetworkAcls() { console.log(result); } -createOrUpdateAVaultWithNetworkAcls().catch(console.error); +async function main() { + createANewVaultOrUpdateAnExistingVault(); + createOrUpdateAVaultWithNetworkAcls(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsDeleteSample.ts index 22bc008bcd73..6063938d1db3 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsDeleteSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsDeleteSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes the specified Azure key vault. * * @summary Deletes the specified Azure key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/deleteVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deleteVault.json */ async function deleteAVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-resource-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; const vaultName = "sample-vault"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -27,4 +33,8 @@ async function deleteAVault() { console.log(result); } -deleteAVault().catch(console.error); +async function main() { + deleteAVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetDeletedSample.ts index 1e89e15be633..8bfcbbfd0a93 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetDeletedSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetDeletedSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the deleted Azure key vault. * * @summary Gets the deleted Azure key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/getDeletedVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json */ async function retrieveADeletedVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const vaultName = "sample-vault"; const location = "westus"; const credential = new DefaultAzureCredential(); @@ -27,4 +32,8 @@ async function retrieveADeletedVault() { console.log(result); } -retrieveADeletedVault().catch(console.error); +async function main() { + retrieveADeletedVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetSample.ts index a07ac78782dd..5101b5749369 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsGetSample.ts @@ -10,16 +10,22 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets the specified Azure key vault. * * @summary Gets the specified Azure key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/getVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json */ async function retrieveAVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-resource-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; const vaultName = "sample-vault"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); @@ -27,4 +33,8 @@ async function retrieveAVault() { console.log(result); } -retrieveAVault().catch(console.error); +async function main() { + retrieveAVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListByResourceGroupSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListByResourceGroupSample.ts index c86324f46b60..6bd75e33cba5 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListByResourceGroupSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListByResourceGroupSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription and within the specified resource group. * * @summary The List operation gets information about the vaults associated with the subscription and within the specified resource group. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listVaultByResourceGroup.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultByResourceGroup.json */ async function listVaultsInTheSpecifiedResourceGroup() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const top = 1; const options: VaultsListByResourceGroupOptionalParams = { top }; const credential = new DefaultAzureCredential(); @@ -37,4 +43,8 @@ async function listVaultsInTheSpecifiedResourceGroup() { console.log(resArray); } -listVaultsInTheSpecifiedResourceGroup().catch(console.error); +async function main() { + listVaultsInTheSpecifiedResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListBySubscriptionSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListBySubscriptionSample.ts index aabe41f4bea1..9d3e51523414 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListBySubscriptionSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListBySubscriptionSample.ts @@ -13,15 +13,20 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription. * * @summary The List operation gets information about the vaults associated with the subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listVaultBySubscription.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultBySubscription.json */ async function listVaultsInTheSpecifiedSubscription() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const top = 1; const options: VaultsListBySubscriptionOptionalParams = { top }; const credential = new DefaultAzureCredential(); @@ -33,4 +38,8 @@ async function listVaultsInTheSpecifiedSubscription() { console.log(resArray); } -listVaultsInTheSpecifiedSubscription().catch(console.error); +async function main() { + listVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListDeletedSample.ts index 8256ba178896..330f29acb182 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListDeletedSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListDeletedSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about the deleted vaults in a subscription. * * @summary Gets information about the deleted vaults in a subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listDeletedVaults.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listDeletedVaults.json */ async function listDeletedVaultsInTheSpecifiedSubscription() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new KeyVaultManagementClient(credential, subscriptionId); const resArray = new Array(); @@ -28,4 +33,8 @@ async function listDeletedVaultsInTheSpecifiedSubscription() { console.log(resArray); } -listDeletedVaultsInTheSpecifiedSubscription().catch(console.error); +async function main() { + listDeletedVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListSample.ts index c8116c5253ea..b97fefc3aeed 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsListSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsListSample.ts @@ -13,15 +13,20 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription. * * @summary The List operation gets information about the vaults associated with the subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/listVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVault.json */ async function listVaultsInTheSpecifiedSubscription() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const top = 1; const options: VaultsListOptionalParams = { top }; const credential = new DefaultAzureCredential(); @@ -33,4 +38,8 @@ async function listVaultsInTheSpecifiedSubscription() { console.log(resArray); } -listVaultsInTheSpecifiedSubscription().catch(console.error); +async function main() { + listVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsPurgeDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsPurgeDeletedSample.ts index 22638c25015d..3bbeb6235b87 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsPurgeDeletedSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsPurgeDeletedSample.ts @@ -10,15 +10,20 @@ // Licensed under the MIT License. import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Permanently deletes the specified vault. aka Purges the deleted Azure key vault. * * @summary Permanently deletes the specified vault. aka Purges the deleted Azure key vault. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/purgeDeletedVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/purgeDeletedVault.json */ async function purgeADeletedVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const vaultName = "sample-vault"; const location = "westus"; const credential = new DefaultAzureCredential(); @@ -30,4 +35,8 @@ async function purgeADeletedVault() { console.log(result); } -purgeADeletedVault().catch(console.error); +async function main() { + purgeADeletedVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateAccessPolicySample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateAccessPolicySample.ts index 039eeb0a1f90..51dfe4bbe3d7 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateAccessPolicySample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateAccessPolicySample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Update access policies in a key vault in the specified subscription. * * @summary Update access policies in a key vault in the specified subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/updateAccessPoliciesAdd.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateAccessPoliciesAdd.json */ async function addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; const vaultName = "sample-vault"; const operationKind = "add"; const parameters: VaultAccessPolicyParameters = { @@ -51,6 +57,8 @@ async function addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions() { console.log(result); } -addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions().catch( - console.error -); +async function main() { + addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateSample.ts index 6c07e2f333e3..ef324f6330ca 100644 --- a/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateSample.ts +++ b/sdk/keyvault/arm-keyvault/samples-dev/vaultsUpdateSample.ts @@ -13,16 +13,22 @@ import { KeyVaultManagementClient } from "@azure/arm-keyvault"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Update a key vault in the specified subscription. * * @summary Update a key vault in the specified subscription. - * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/preview/2021-11-01-preview/examples/updateVault.json + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateVault.json */ async function updateAnExistingVault() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = "sample-resource-group"; + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; const vaultName = "sample-vault"; const parameters: VaultPatchParameters = { properties: { @@ -96,4 +102,8 @@ async function updateAnExistingVault() { console.log(result); } -updateAnExistingVault().catch(console.error); +async function main() { + updateAnExistingVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/README.md b/sdk/keyvault/arm-keyvault/samples/v3/javascript/README.md new file mode 100644 index 000000000000..c3dcc16b9d99 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/README.md @@ -0,0 +1,144 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [keysCreateIfNotExistSample.js][keyscreateifnotexistsample] | 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. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createKey.json | +| [keysGetSample.js][keysgetsample] | Gets the current version of the specified key from the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKey.json | +| [keysGetVersionSample.js][keysgetversionsample] | Gets the specified version of the specified key in the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKeyVersion.json | +| [keysListSample.js][keyslistsample] | Lists the keys in the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeys.json | +| [keysListVersionsSample.js][keyslistversionssample] | Lists the versions of the specified key in the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeyVersions.json | +| [managedHsmKeysCreateIfNotExistSample.js][managedhsmkeyscreateifnotexistsample] | 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. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmCreateKey.json | +| [managedHsmKeysGetSample.js][managedhsmkeysgetsample] | Gets the current version of the specified key from the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKey.json | +| [managedHsmKeysGetVersionSample.js][managedhsmkeysgetversionsample] | Gets the specified version of the specified key in the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKeyVersion.json | +| [managedHsmKeysListSample.js][managedhsmkeyslistsample] | Lists the keys in the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeys.json | +| [managedHsmKeysListVersionsSample.js][managedhsmkeyslistversionssample] | Lists the versions of the specified key in the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeyVersions.json | +| [managedHsmsCheckMhsmNameAvailabilitySample.js][managedhsmscheckmhsmnameavailabilitysample] | Checks that the managed hsm name is valid and is not already in use. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_checkMhsmNameAvailability.json | +| [managedHsmsCreateOrUpdateSample.js][managedhsmscreateorupdatesample] | Create or update a managed HSM Pool in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_CreateOrUpdate.json | +| [managedHsmsDeleteSample.js][managedhsmsdeletesample] | Deletes the specified managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Delete.json | +| [managedHsmsGetDeletedSample.js][managedhsmsgetdeletedsample] | Gets the specified deleted managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json | +| [managedHsmsGetSample.js][managedhsmsgetsample] | Gets the specified managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json | +| [managedHsmsListByResourceGroupSample.js][managedhsmslistbyresourcegroupsample] | The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListByResourceGroup.json | +| [managedHsmsListBySubscriptionSample.js][managedhsmslistbysubscriptionsample] | The List operation gets information about the managed HSM Pools associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListBySubscription.json | +| [managedHsmsListDeletedSample.js][managedhsmslistdeletedsample] | The List operation gets information about the deleted managed HSMs associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_List.json | +| [managedHsmsPurgeDeletedSample.js][managedhsmspurgedeletedsample] | Permanently deletes the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Purge.json | +| [managedHsmsUpdateSample.js][managedhsmsupdatesample] | Update a managed HSM Pool in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Update.json | +| [mhsmPrivateEndpointConnectionsDeleteSample.js][mhsmprivateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the managed hsm pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_deletePrivateEndpointConnection.json | +| [mhsmPrivateEndpointConnectionsGetSample.js][mhsmprivateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json | +| [mhsmPrivateEndpointConnectionsListByResourceSample.js][mhsmprivateendpointconnectionslistbyresourcesample] | The List operation gets information about the private endpoint connections associated with the managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json | +| [mhsmPrivateEndpointConnectionsPutSample.js][mhsmprivateendpointconnectionsputsample] | Updates the specified private endpoint connection associated with the managed hsm pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json | +| [mhsmPrivateLinkResourcesListByMhsmResourceSample.js][mhsmprivatelinkresourceslistbymhsmresourcesample] | Gets the private link resources supported for the managed hsm pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_listPrivateLinkResources.json | +| [mhsmRegionsListByResourceSample.js][mhsmregionslistbyresourcesample] | The List operation gets information about the regions associated with the managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListRegionsByResource.json | +| [operationsListSample.js][operationslistsample] | Lists all of the available Key Vault Rest API operations. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listOperations.json | +| [privateEndpointConnectionsDeleteSample.js][privateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deletePrivateEndpointConnection.json | +| [privateEndpointConnectionsGetSample.js][privateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json | +| [privateEndpointConnectionsListByResourceSample.js][privateendpointconnectionslistbyresourcesample] | The List operation gets information about the private endpoint connections associated with the vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateEndpointConnection.json | +| [privateEndpointConnectionsPutSample.js][privateendpointconnectionsputsample] | Updates the specified private endpoint connection associated with the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json | +| [privateLinkResourcesListByVaultSample.js][privatelinkresourceslistbyvaultsample] | Gets the private link resources supported for the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateLinkResources.json | +| [secretsCreateOrUpdateSample.js][secretscreateorupdatesample] | Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createSecret.json | +| [secretsGetSample.js][secretsgetsample] | Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json | +| [secretsListSample.js][secretslistsample] | The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listSecrets.json | +| [secretsUpdateSample.js][secretsupdatesample] | Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateSecret.json | +| [vaultsCheckNameAvailabilitySample.js][vaultschecknameavailabilitysample] | Checks that the vault name is valid and is not already in use. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/checkVaultNameAvailability.json | +| [vaultsCreateOrUpdateSample.js][vaultscreateorupdatesample] | Create or update a key vault in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVault.json | +| [vaultsDeleteSample.js][vaultsdeletesample] | Deletes the specified Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deleteVault.json | +| [vaultsGetDeletedSample.js][vaultsgetdeletedsample] | Gets the deleted Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json | +| [vaultsGetSample.js][vaultsgetsample] | Gets the specified Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json | +| [vaultsListByResourceGroupSample.js][vaultslistbyresourcegroupsample] | The List operation gets information about the vaults associated with the subscription and within the specified resource group. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultByResourceGroup.json | +| [vaultsListBySubscriptionSample.js][vaultslistbysubscriptionsample] | The List operation gets information about the vaults associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultBySubscription.json | +| [vaultsListDeletedSample.js][vaultslistdeletedsample] | Gets information about the deleted vaults in a subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listDeletedVaults.json | +| [vaultsListSample.js][vaultslistsample] | The List operation gets information about the vaults associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVault.json | +| [vaultsPurgeDeletedSample.js][vaultspurgedeletedsample] | Permanently deletes the specified vault. aka Purges the deleted Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/purgeDeletedVault.json | +| [vaultsUpdateAccessPolicySample.js][vaultsupdateaccesspolicysample] | Update access policies in a key vault in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateAccessPoliciesAdd.json | +| [vaultsUpdateSample.js][vaultsupdatesample] | Update a key vault in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateVault.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node keysCreateIfNotExistSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env KEYVAULT_SUBSCRIPTION_ID="" KEYVAULT_RESOURCE_GROUP="" node keysCreateIfNotExistSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[keyscreateifnotexistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysCreateIfNotExistSample.js +[keysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetSample.js +[keysgetversionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetVersionSample.js +[keyslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListSample.js +[keyslistversionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListVersionsSample.js +[managedhsmkeyscreateifnotexistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysCreateIfNotExistSample.js +[managedhsmkeysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetSample.js +[managedhsmkeysgetversionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetVersionSample.js +[managedhsmkeyslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListSample.js +[managedhsmkeyslistversionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListVersionsSample.js +[managedhsmscheckmhsmnameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCheckMhsmNameAvailabilitySample.js +[managedhsmscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCreateOrUpdateSample.js +[managedhsmsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsDeleteSample.js +[managedhsmsgetdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetDeletedSample.js +[managedhsmsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetSample.js +[managedhsmslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListByResourceGroupSample.js +[managedhsmslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListBySubscriptionSample.js +[managedhsmslistdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListDeletedSample.js +[managedhsmspurgedeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsPurgeDeletedSample.js +[managedhsmsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsUpdateSample.js +[mhsmprivateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsDeleteSample.js +[mhsmprivateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsGetSample.js +[mhsmprivateendpointconnectionslistbyresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsListByResourceSample.js +[mhsmprivateendpointconnectionsputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsPutSample.js +[mhsmprivatelinkresourceslistbymhsmresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateLinkResourcesListByMhsmResourceSample.js +[mhsmregionslistbyresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmRegionsListByResourceSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/operationsListSample.js +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsDeleteSample.js +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsGetSample.js +[privateendpointconnectionslistbyresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsListByResourceSample.js +[privateendpointconnectionsputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsPutSample.js +[privatelinkresourceslistbyvaultsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateLinkResourcesListByVaultSample.js +[secretscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsCreateOrUpdateSample.js +[secretsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsGetSample.js +[secretslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsListSample.js +[secretsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsUpdateSample.js +[vaultschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCheckNameAvailabilitySample.js +[vaultscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCreateOrUpdateSample.js +[vaultsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsDeleteSample.js +[vaultsgetdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetDeletedSample.js +[vaultsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetSample.js +[vaultslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListByResourceGroupSample.js +[vaultslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListBySubscriptionSample.js +[vaultslistdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListDeletedSample.js +[vaultslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListSample.js +[vaultspurgedeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsPurgeDeletedSample.js +[vaultsupdateaccesspolicysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateAccessPolicySample.js +[vaultsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-keyvault?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault/README.md diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysCreateIfNotExistSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysCreateIfNotExistSample.js new file mode 100644 index 000000000000..c8ab98cb8f09 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysCreateIfNotExistSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to 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. + * + * @summary 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. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createKey.json + */ +async function createAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const parameters = { properties: { kty: "RSA" } }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.keys.createIfNotExist( + resourceGroupName, + vaultName, + keyName, + parameters + ); + console.log(result); +} + +async function main() { + createAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetSample.js new file mode 100644 index 000000000000..f4662709964f --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the current version of the specified key from the specified key vault. + * + * @summary Gets the current version of the specified key from the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKey.json + */ +async function getAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.keys.get(resourceGroupName, vaultName, keyName); + console.log(result); +} + +async function main() { + getAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetVersionSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetVersionSample.js new file mode 100644 index 000000000000..2c8fbc07e538 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysGetVersionSample.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified version of the specified key in the specified key vault. + * + * @summary Gets the specified version of the specified key in the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKeyVersion.json + */ +async function getAKeyVersion() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.keys.getVersion(resourceGroupName, vaultName, keyName, keyVersion); + console.log(result); +} + +async function main() { + getAKeyVersion(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListSample.js new file mode 100644 index 000000000000..e206bed44550 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists the keys in the specified key vault. + * + * @summary Lists the keys in the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeys.json + */ +async function listKeysInTheVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.keys.list(resourceGroupName, vaultName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeysInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListVersionsSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListVersionsSample.js new file mode 100644 index 000000000000..d95b03479bfa --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/keysListVersionsSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists the versions of the specified key in the specified key vault. + * + * @summary Lists the versions of the specified key in the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeyVersions.json + */ +async function listKeyVersionsInTheVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.keys.listVersions(resourceGroupName, vaultName, keyName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeyVersionsInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysCreateIfNotExistSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysCreateIfNotExistSample.js new file mode 100644 index 000000000000..cdd761866d45 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysCreateIfNotExistSample.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to 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. + * + * @summary 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. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmCreateKey.json + */ +async function createAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const parameters = { + properties: { kty: "RSA" }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.createIfNotExist( + resourceGroupName, + name, + keyName, + parameters + ); + console.log(result); +} + +async function main() { + createAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetSample.js new file mode 100644 index 000000000000..063ddd3c1cb2 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the current version of the specified key from the specified managed HSM. + * + * @summary Gets the current version of the specified key from the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKey.json + */ +async function getAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.get(resourceGroupName, name, keyName); + console.log(result); +} + +async function main() { + getAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetVersionSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetVersionSample.js new file mode 100644 index 000000000000..50817a6fee23 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysGetVersionSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified version of the specified key in the specified managed HSM. + * + * @summary Gets the specified version of the specified key in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKeyVersion.json + */ +async function getAKeyVersion() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.getVersion( + resourceGroupName, + name, + keyName, + keyVersion + ); + console.log(result); +} + +async function main() { + getAKeyVersion(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListSample.js new file mode 100644 index 000000000000..9bf435a6cd75 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists the keys in the specified managed HSM. + * + * @summary Lists the keys in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeys.json + */ +async function listKeysInTheManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsmKeys.list(resourceGroupName, name)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeysInTheManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListVersionsSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListVersionsSample.js new file mode 100644 index 000000000000..afe9e1eb4228 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmKeysListVersionsSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists the versions of the specified key in the specified managed HSM. + * + * @summary Lists the versions of the specified key in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeyVersions.json + */ +async function listKeyVersionsInTheManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsmKeys.listVersions(resourceGroupName, name, keyName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeyVersionsInTheManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCheckMhsmNameAvailabilitySample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCheckMhsmNameAvailabilitySample.js new file mode 100644 index 000000000000..db6efaaa662b --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCheckMhsmNameAvailabilitySample.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Checks that the managed hsm name is valid and is not already in use. + * + * @summary Checks that the managed hsm name is valid and is not already in use. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_checkMhsmNameAvailability.json + */ +async function validateAManagedHsmName() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const mhsmName = { name: "sample-mhsm" }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.checkMhsmNameAvailability(mhsmName); + console.log(result); +} + +async function main() { + validateAManagedHsmName(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCreateOrUpdateSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCreateOrUpdateSample.js new file mode 100644 index 000000000000..7d18cc03bac9 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsCreateOrUpdateSample.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or update a managed HSM Pool in the specified subscription. + * + * @summary Create or update a managed HSM Pool in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_CreateOrUpdate.json + */ +async function createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const parameters = { + location: "westus", + properties: { + enablePurgeProtection: false, + enableSoftDelete: true, + initialAdminObjectIds: ["00000000-0000-0000-0000-000000000000"], + softDeleteRetentionInDays: 90, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + sku: { name: "Standard_B1", family: "B" }, + tags: { dept: "hsm", environment: "dogfood" }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginCreateOrUpdateAndWait( + resourceGroupName, + name, + parameters + ); + console.log(result); +} + +async function main() { + createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsDeleteSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsDeleteSample.js new file mode 100644 index 000000000000..b5d946b07f49 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsDeleteSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified managed HSM Pool. + * + * @summary Deletes the specified managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Delete.json + */ +async function deleteAManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginDeleteAndWait(resourceGroupName, name); + console.log(result); +} + +async function main() { + deleteAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetDeletedSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetDeletedSample.js new file mode 100644 index 000000000000..e4d411f2812a --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetDeletedSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified deleted managed HSM. + * + * @summary Gets the specified deleted managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json + */ +async function retrieveADeletedManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const name = "hsm1"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.getDeleted(name, location); + console.log(result); +} + +async function main() { + retrieveADeletedManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetSample.js new file mode 100644 index 000000000000..5989a3415f1d --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsGetSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified managed HSM Pool. + * + * @summary Gets the specified managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json + */ +async function retrieveAManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.get(resourceGroupName, name); + console.log(result); +} + +async function main() { + retrieveAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListByResourceGroupSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListByResourceGroupSample.js new file mode 100644 index 000000000000..bac9c574b05c --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListByResourceGroupSample.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. + * + * @summary The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListByResourceGroup.json + */ +async function listManagedHsmPoolsInAResourceGroup() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsms.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListBySubscriptionSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListBySubscriptionSample.js new file mode 100644 index 000000000000..63f27db660df --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListBySubscriptionSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the managed HSM Pools associated with the subscription. + * + * @summary The List operation gets information about the managed HSM Pools associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListBySubscription.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsms.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListDeletedSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListDeletedSample.js new file mode 100644 index 000000000000..639c68c4d71d --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsListDeletedSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the deleted managed HSMs associated with the subscription. + * + * @summary The List operation gets information about the deleted managed HSMs associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_List.json + */ +async function listDeletedManagedHsMSInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsms.listDeleted()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDeletedManagedHsMSInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsPurgeDeletedSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsPurgeDeletedSample.js new file mode 100644 index 000000000000..118295d37761 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsPurgeDeletedSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Permanently deletes the specified managed HSM. + * + * @summary Permanently deletes the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Purge.json + */ +async function purgeAManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const name = "hsm1"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginPurgeDeletedAndWait(name, location); + console.log(result); +} + +async function main() { + purgeAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsUpdateSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsUpdateSample.js new file mode 100644 index 000000000000..226bfa96d7c7 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/managedHsmsUpdateSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update a managed HSM Pool in the specified subscription. + * + * @summary Update a managed HSM Pool in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Update.json + */ +async function updateAnExistingManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const parameters = { + tags: { dept: "hsm", environment: "dogfood", slice: "A" }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginUpdateAndWait(resourceGroupName, name, parameters); + console.log(result); +} + +async function main() { + updateAnExistingManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsDeleteSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsDeleteSample.js new file mode 100644 index 000000000000..5f86d07a29ec --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsDeleteSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the managed hsm pool. + * + * @summary Deletes the specified private endpoint connection associated with the managed hsm pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_deletePrivateEndpointConnection.json + */ +async function managedHsmDeletePrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + name, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + managedHsmDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsGetSample.js new file mode 100644 index 000000000000..623ce0d9e765 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsGetSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the managed HSM Pool. + * + * @summary Gets the specified private endpoint connection associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json + */ +async function managedHsmGetPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateEndpointConnections.get( + resourceGroupName, + name, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + managedHsmGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsListByResourceSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsListByResourceSample.js new file mode 100644 index 000000000000..e8ee6e7fe10a --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsListByResourceSample.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the private endpoint connections associated with the managed HSM Pool. + * + * @summary The List operation gets information about the private endpoint connections associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.mhsmPrivateEndpointConnections.listByResource( + resourceGroupName, + name + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsPutSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsPutSample.js new file mode 100644 index 000000000000..c8bec5d08e12 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateEndpointConnectionsPutSample.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates the specified private endpoint connection associated with the managed hsm pool. + * + * @summary Updates the specified private endpoint connection associated with the managed hsm pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json + */ +async function managedHsmPutPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const privateEndpointConnectionName = "sample-pec"; + const properties = { + privateLinkServiceConnectionState: { + description: "My name is Joe and I'm approving this.", + status: "Approved", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateEndpointConnections.put( + resourceGroupName, + name, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + managedHsmPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateLinkResourcesListByMhsmResourceSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateLinkResourcesListByMhsmResourceSample.js new file mode 100644 index 000000000000..20e8a71ee51b --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmPrivateLinkResourcesListByMhsmResourceSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the private link resources supported for the managed hsm pool. + * + * @summary Gets the private link resources supported for the managed hsm pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_listPrivateLinkResources.json + */ +async function keyVaultListPrivateLinkResources() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateLinkResources.listByMhsmResource(resourceGroupName, name); + console.log(result); +} + +async function main() { + keyVaultListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmRegionsListByResourceSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmRegionsListByResourceSample.js new file mode 100644 index 000000000000..e98920b7ecda --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/mhsmRegionsListByResourceSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the regions associated with the managed HSM Pool. + * + * @summary The List operation gets information about the regions associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListRegionsByResource.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.mhsmRegions.listByResource(resourceGroupName, name)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/operationsListSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/operationsListSample.js new file mode 100644 index 000000000000..23bf1e50f444 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/operationsListSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists all of the available Key Vault Rest API operations. + * + * @summary Lists all of the available Key Vault Rest API operations. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listOperations.json + */ +async function listsAvailableRestApiOperations() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listsAvailableRestApiOperations(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/package.json b/sdk/keyvault/arm-keyvault/samples/v3/javascript/package.json new file mode 100644 index 000000000000..61fb6438b4c3 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-keyvault-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/keyvault/arm-keyvault" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault", + "dependencies": { + "@azure/arm-keyvault": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsDeleteSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsDeleteSample.js new file mode 100644 index 000000000000..5a98506aee48 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsDeleteSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the key vault. + * + * @summary Deletes the specified private endpoint connection associated with the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deletePrivateEndpointConnection.json + */ +async function keyVaultDeletePrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + vaultName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + keyVaultDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsGetSample.js new file mode 100644 index 000000000000..1d8c151e922e --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsGetSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the key vault. + * + * @summary Gets the specified private endpoint connection associated with the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json + */ +async function keyVaultGetPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + vaultName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + keyVaultGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsListByResourceSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsListByResourceSample.js new file mode 100644 index 000000000000..47d1de0b13ae --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsListByResourceSample.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the private endpoint connections associated with the vault. + * + * @summary The List operation gets information about the private endpoint connections associated with the vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateEndpointConnection.json + */ +async function keyVaultListPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.listByResource( + resourceGroupName, + vaultName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + keyVaultListPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsPutSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsPutSample.js new file mode 100644 index 000000000000..9987a1632754 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateEndpointConnectionsPutSample.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates the specified private endpoint connection associated with the key vault. + * + * @summary Updates the specified private endpoint connection associated with the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json + */ +async function keyVaultPutPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const privateEndpointConnectionName = "sample-pec"; + const properties = { + etag: "", + privateLinkServiceConnectionState: { + description: "My name is Joe and I'm approving this.", + status: "Approved", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.put( + resourceGroupName, + vaultName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + keyVaultPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateLinkResourcesListByVaultSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateLinkResourcesListByVaultSample.js new file mode 100644 index 000000000000..ad7aafd652be --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/privateLinkResourcesListByVaultSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the private link resources supported for the key vault. + * + * @summary Gets the private link resources supported for the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateLinkResources.json + */ +async function keyVaultListPrivateLinkResources() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.listByVault(resourceGroupName, vaultName); + console.log(result); +} + +async function main() { + keyVaultListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/sample.env b/sdk/keyvault/arm-keyvault/samples/v3/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsCreateOrUpdateSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsCreateOrUpdateSample.js new file mode 100644 index 000000000000..4e7039acf8fb --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsCreateOrUpdateSample.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createSecret.json + */ +async function createASecret() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const secretName = "secret-name"; + const parameters = { + properties: { value: "secret-value" }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.secrets.createOrUpdate( + resourceGroupName, + vaultName, + secretName, + parameters + ); + console.log(result); +} + +async function main() { + createASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsGetSample.js new file mode 100644 index 000000000000..7b41dd584420 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsGetSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json + */ +async function getASecret() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const secretName = "secret-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.secrets.get(resourceGroupName, vaultName, secretName); + console.log(result); +} + +async function main() { + getASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsListSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsListSample.js new file mode 100644 index 000000000000..2f9e41fd4525 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsListSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listSecrets.json + */ +async function listSecretsInTheVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.secrets.list(resourceGroupName, vaultName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listSecretsInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsUpdateSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsUpdateSample.js new file mode 100644 index 000000000000..f8732df0a64d --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/secretsUpdateSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateSecret.json + */ +async function updateASecret() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const secretName = "secret-name"; + const parameters = { + properties: { value: "secret-value2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.secrets.update(resourceGroupName, vaultName, secretName, parameters); + console.log(result); +} + +async function main() { + updateASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCheckNameAvailabilitySample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCheckNameAvailabilitySample.js new file mode 100644 index 000000000000..ff6798fa4949 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCheckNameAvailabilitySample.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Checks that the vault name is valid and is not already in use. + * + * @summary Checks that the vault name is valid and is not already in use. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/checkVaultNameAvailability.json + */ +async function validateAVaultName() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const vaultName = { + name: "sample-vault", + type: "Microsoft.KeyVault/vaults", + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.checkNameAvailability(vaultName); + console.log(result); +} + +async function main() { + validateAVaultName(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCreateOrUpdateSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCreateOrUpdateSample.js new file mode 100644 index 000000000000..43a3639c9c59 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsCreateOrUpdateSample.js @@ -0,0 +1,136 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or update a key vault in the specified subscription. + * + * @summary Create or update a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVault.json + */ +async function createANewVaultOrUpdateAnExistingVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const parameters = { + location: "westus", + properties: { + accessPolicies: [ + { + objectId: "00000000-0000-0000-0000-000000000000", + permissions: { + certificates: [ + "get", + "list", + "delete", + "create", + "import", + "update", + "managecontacts", + "getissuers", + "listissuers", + "setissuers", + "deleteissuers", + "manageissuers", + "recover", + "purge", + ], + keys: [ + "encrypt", + "decrypt", + "wrapKey", + "unwrapKey", + "sign", + "verify", + "get", + "list", + "create", + "update", + "import", + "delete", + "backup", + "restore", + "recover", + "purge", + ], + secrets: ["get", "list", "set", "delete", "backup", "restore", "recover", "purge"], + }, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + ], + enabledForDeployment: true, + enabledForDiskEncryption: true, + enabledForTemplateDeployment: true, + publicNetworkAccess: "Enabled", + sku: { name: "standard", family: "A" }, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.beginCreateOrUpdateAndWait( + resourceGroupName, + vaultName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a key vault in the specified subscription. + * + * @summary Create or update a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVaultWithNetworkAcls.json + */ +async function createOrUpdateAVaultWithNetworkAcls() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const parameters = { + location: "westus", + properties: { + enabledForDeployment: true, + enabledForDiskEncryption: true, + enabledForTemplateDeployment: true, + networkAcls: { + bypass: "AzureServices", + defaultAction: "Deny", + ipRules: [{ value: "124.56.78.91" }, { value: "'10.91.4.0/24'" }], + virtualNetworkRules: [ + { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1", + }, + ], + }, + sku: { name: "standard", family: "A" }, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.beginCreateOrUpdateAndWait( + resourceGroupName, + vaultName, + parameters + ); + console.log(result); +} + +async function main() { + createANewVaultOrUpdateAnExistingVault(); + createOrUpdateAVaultWithNetworkAcls(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsDeleteSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsDeleteSample.js new file mode 100644 index 000000000000..0f636c97cd34 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsDeleteSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified Azure key vault. + * + * @summary Deletes the specified Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deleteVault.json + */ +async function deleteAVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.delete(resourceGroupName, vaultName); + console.log(result); +} + +async function main() { + deleteAVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetDeletedSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetDeletedSample.js new file mode 100644 index 000000000000..2bc71a2634cf --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetDeletedSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the deleted Azure key vault. + * + * @summary Gets the deleted Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json + */ +async function retrieveADeletedVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const vaultName = "sample-vault"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.getDeleted(vaultName, location); + console.log(result); +} + +async function main() { + retrieveADeletedVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetSample.js new file mode 100644 index 000000000000..0750592819f5 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsGetSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified Azure key vault. + * + * @summary Gets the specified Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json + */ +async function retrieveAVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.get(resourceGroupName, vaultName); + console.log(result); +} + +async function main() { + retrieveAVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListByResourceGroupSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListByResourceGroupSample.js new file mode 100644 index 000000000000..e8ebe7ef34bc --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListByResourceGroupSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription and within the specified resource group. + * + * @summary The List operation gets information about the vaults associated with the subscription and within the specified resource group. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultByResourceGroup.json + */ +async function listVaultsInTheSpecifiedResourceGroup() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const top = 1; + const options = { top }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.listByResourceGroup(resourceGroupName, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVaultsInTheSpecifiedResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListBySubscriptionSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListBySubscriptionSample.js new file mode 100644 index 000000000000..6cd1d51e0e20 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListBySubscriptionSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription. + * + * @summary The List operation gets information about the vaults associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultBySubscription.json + */ +async function listVaultsInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const top = 1; + const options = { top }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.listBySubscription(options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListDeletedSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListDeletedSample.js new file mode 100644 index 000000000000..27722145f95f --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListDeletedSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets information about the deleted vaults in a subscription. + * + * @summary Gets information about the deleted vaults in a subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listDeletedVaults.json + */ +async function listDeletedVaultsInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.listDeleted()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDeletedVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListSample.js new file mode 100644 index 000000000000..7231a5021304 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsListSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription. + * + * @summary The List operation gets information about the vaults associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVault.json + */ +async function listVaultsInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const top = 1; + const options = { top }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsPurgeDeletedSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsPurgeDeletedSample.js new file mode 100644 index 000000000000..2bde882d48a0 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsPurgeDeletedSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Permanently deletes the specified vault. aka Purges the deleted Azure key vault. + * + * @summary Permanently deletes the specified vault. aka Purges the deleted Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/purgeDeletedVault.json + */ +async function purgeADeletedVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const vaultName = "sample-vault"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.beginPurgeDeletedAndWait(vaultName, location); + console.log(result); +} + +async function main() { + purgeADeletedVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateAccessPolicySample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateAccessPolicySample.js new file mode 100644 index 000000000000..c0babe0a0b62 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateAccessPolicySample.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update access policies in a key vault in the specified subscription. + * + * @summary Update access policies in a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateAccessPoliciesAdd.json + */ +async function addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const operationKind = "add"; + const parameters = { + properties: { + accessPolicies: [ + { + objectId: "00000000-0000-0000-0000-000000000000", + permissions: { + certificates: ["get"], + keys: ["encrypt"], + secrets: ["get"], + }, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + ], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.updateAccessPolicy( + resourceGroupName, + vaultName, + operationKind, + parameters + ); + console.log(result); +} + +async function main() { + addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateSample.js b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateSample.js new file mode 100644 index 000000000000..8af25100d200 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/javascript/vaultsUpdateSample.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update a key vault in the specified subscription. + * + * @summary Update a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateVault.json + */ +async function updateAnExistingVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const parameters = { + properties: { + accessPolicies: [ + { + objectId: "00000000-0000-0000-0000-000000000000", + permissions: { + certificates: [ + "get", + "list", + "delete", + "create", + "import", + "update", + "managecontacts", + "getissuers", + "listissuers", + "setissuers", + "deleteissuers", + "manageissuers", + "recover", + "purge", + ], + keys: [ + "encrypt", + "decrypt", + "wrapKey", + "unwrapKey", + "sign", + "verify", + "get", + "list", + "create", + "update", + "import", + "delete", + "backup", + "restore", + "recover", + "purge", + ], + secrets: ["get", "list", "set", "delete", "backup", "restore", "recover", "purge"], + }, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + ], + enabledForDeployment: true, + enabledForDiskEncryption: true, + enabledForTemplateDeployment: true, + publicNetworkAccess: "Enabled", + sku: { name: "standard", family: "A" }, + tenantId: "00000000-0000-0000-0000-000000000000", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.update(resourceGroupName, vaultName, parameters); + console.log(result); +} + +async function main() { + updateAnExistingVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/README.md b/sdk/keyvault/arm-keyvault/samples/v3/typescript/README.md new file mode 100644 index 000000000000..099534009fee --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/README.md @@ -0,0 +1,157 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [keysCreateIfNotExistSample.ts][keyscreateifnotexistsample] | 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. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createKey.json | +| [keysGetSample.ts][keysgetsample] | Gets the current version of the specified key from the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKey.json | +| [keysGetVersionSample.ts][keysgetversionsample] | Gets the specified version of the specified key in the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKeyVersion.json | +| [keysListSample.ts][keyslistsample] | Lists the keys in the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeys.json | +| [keysListVersionsSample.ts][keyslistversionssample] | Lists the versions of the specified key in the specified key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeyVersions.json | +| [managedHsmKeysCreateIfNotExistSample.ts][managedhsmkeyscreateifnotexistsample] | 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. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmCreateKey.json | +| [managedHsmKeysGetSample.ts][managedhsmkeysgetsample] | Gets the current version of the specified key from the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKey.json | +| [managedHsmKeysGetVersionSample.ts][managedhsmkeysgetversionsample] | Gets the specified version of the specified key in the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKeyVersion.json | +| [managedHsmKeysListSample.ts][managedhsmkeyslistsample] | Lists the keys in the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeys.json | +| [managedHsmKeysListVersionsSample.ts][managedhsmkeyslistversionssample] | Lists the versions of the specified key in the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeyVersions.json | +| [managedHsmsCheckMhsmNameAvailabilitySample.ts][managedhsmscheckmhsmnameavailabilitysample] | Checks that the managed hsm name is valid and is not already in use. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_checkMhsmNameAvailability.json | +| [managedHsmsCreateOrUpdateSample.ts][managedhsmscreateorupdatesample] | Create or update a managed HSM Pool in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_CreateOrUpdate.json | +| [managedHsmsDeleteSample.ts][managedhsmsdeletesample] | Deletes the specified managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Delete.json | +| [managedHsmsGetDeletedSample.ts][managedhsmsgetdeletedsample] | Gets the specified deleted managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json | +| [managedHsmsGetSample.ts][managedhsmsgetsample] | Gets the specified managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json | +| [managedHsmsListByResourceGroupSample.ts][managedhsmslistbyresourcegroupsample] | The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListByResourceGroup.json | +| [managedHsmsListBySubscriptionSample.ts][managedhsmslistbysubscriptionsample] | The List operation gets information about the managed HSM Pools associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListBySubscription.json | +| [managedHsmsListDeletedSample.ts][managedhsmslistdeletedsample] | The List operation gets information about the deleted managed HSMs associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_List.json | +| [managedHsmsPurgeDeletedSample.ts][managedhsmspurgedeletedsample] | Permanently deletes the specified managed HSM. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Purge.json | +| [managedHsmsUpdateSample.ts][managedhsmsupdatesample] | Update a managed HSM Pool in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Update.json | +| [mhsmPrivateEndpointConnectionsDeleteSample.ts][mhsmprivateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the managed hsm pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_deletePrivateEndpointConnection.json | +| [mhsmPrivateEndpointConnectionsGetSample.ts][mhsmprivateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json | +| [mhsmPrivateEndpointConnectionsListByResourceSample.ts][mhsmprivateendpointconnectionslistbyresourcesample] | The List operation gets information about the private endpoint connections associated with the managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json | +| [mhsmPrivateEndpointConnectionsPutSample.ts][mhsmprivateendpointconnectionsputsample] | Updates the specified private endpoint connection associated with the managed hsm pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json | +| [mhsmPrivateLinkResourcesListByMhsmResourceSample.ts][mhsmprivatelinkresourceslistbymhsmresourcesample] | Gets the private link resources supported for the managed hsm pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_listPrivateLinkResources.json | +| [mhsmRegionsListByResourceSample.ts][mhsmregionslistbyresourcesample] | The List operation gets information about the regions associated with the managed HSM Pool. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListRegionsByResource.json | +| [operationsListSample.ts][operationslistsample] | Lists all of the available Key Vault Rest API operations. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listOperations.json | +| [privateEndpointConnectionsDeleteSample.ts][privateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deletePrivateEndpointConnection.json | +| [privateEndpointConnectionsGetSample.ts][privateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json | +| [privateEndpointConnectionsListByResourceSample.ts][privateendpointconnectionslistbyresourcesample] | The List operation gets information about the private endpoint connections associated with the vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateEndpointConnection.json | +| [privateEndpointConnectionsPutSample.ts][privateendpointconnectionsputsample] | Updates the specified private endpoint connection associated with the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json | +| [privateLinkResourcesListByVaultSample.ts][privatelinkresourceslistbyvaultsample] | Gets the private link resources supported for the key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateLinkResources.json | +| [secretsCreateOrUpdateSample.ts][secretscreateorupdatesample] | Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createSecret.json | +| [secretsGetSample.ts][secretsgetsample] | Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json | +| [secretsListSample.ts][secretslistsample] | The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listSecrets.json | +| [secretsUpdateSample.ts][secretsupdatesample] | Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateSecret.json | +| [vaultsCheckNameAvailabilitySample.ts][vaultschecknameavailabilitysample] | Checks that the vault name is valid and is not already in use. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/checkVaultNameAvailability.json | +| [vaultsCreateOrUpdateSample.ts][vaultscreateorupdatesample] | Create or update a key vault in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVault.json | +| [vaultsDeleteSample.ts][vaultsdeletesample] | Deletes the specified Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deleteVault.json | +| [vaultsGetDeletedSample.ts][vaultsgetdeletedsample] | Gets the deleted Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json | +| [vaultsGetSample.ts][vaultsgetsample] | Gets the specified Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json | +| [vaultsListByResourceGroupSample.ts][vaultslistbyresourcegroupsample] | The List operation gets information about the vaults associated with the subscription and within the specified resource group. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultByResourceGroup.json | +| [vaultsListBySubscriptionSample.ts][vaultslistbysubscriptionsample] | The List operation gets information about the vaults associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultBySubscription.json | +| [vaultsListDeletedSample.ts][vaultslistdeletedsample] | Gets information about the deleted vaults in a subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listDeletedVaults.json | +| [vaultsListSample.ts][vaultslistsample] | The List operation gets information about the vaults associated with the subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVault.json | +| [vaultsPurgeDeletedSample.ts][vaultspurgedeletedsample] | Permanently deletes the specified vault. aka Purges the deleted Azure key vault. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/purgeDeletedVault.json | +| [vaultsUpdateAccessPolicySample.ts][vaultsupdateaccesspolicysample] | Update access policies in a key vault in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateAccessPoliciesAdd.json | +| [vaultsUpdateSample.ts][vaultsupdatesample] | Update a key vault in the specified subscription. x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateVault.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/keysCreateIfNotExistSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env KEYVAULT_SUBSCRIPTION_ID="" KEYVAULT_RESOURCE_GROUP="" node dist/keysCreateIfNotExistSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[keyscreateifnotexistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysCreateIfNotExistSample.ts +[keysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetSample.ts +[keysgetversionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetVersionSample.ts +[keyslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListSample.ts +[keyslistversionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListVersionsSample.ts +[managedhsmkeyscreateifnotexistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysCreateIfNotExistSample.ts +[managedhsmkeysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetSample.ts +[managedhsmkeysgetversionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetVersionSample.ts +[managedhsmkeyslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListSample.ts +[managedhsmkeyslistversionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListVersionsSample.ts +[managedhsmscheckmhsmnameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCheckMhsmNameAvailabilitySample.ts +[managedhsmscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCreateOrUpdateSample.ts +[managedhsmsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsDeleteSample.ts +[managedhsmsgetdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetDeletedSample.ts +[managedhsmsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetSample.ts +[managedhsmslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListByResourceGroupSample.ts +[managedhsmslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListBySubscriptionSample.ts +[managedhsmslistdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListDeletedSample.ts +[managedhsmspurgedeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsPurgeDeletedSample.ts +[managedhsmsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsUpdateSample.ts +[mhsmprivateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsDeleteSample.ts +[mhsmprivateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsGetSample.ts +[mhsmprivateendpointconnectionslistbyresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsListByResourceSample.ts +[mhsmprivateendpointconnectionsputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsPutSample.ts +[mhsmprivatelinkresourceslistbymhsmresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts +[mhsmregionslistbyresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmRegionsListByResourceSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/operationsListSample.ts +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsDeleteSample.ts +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsGetSample.ts +[privateendpointconnectionslistbyresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsListByResourceSample.ts +[privateendpointconnectionsputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsPutSample.ts +[privatelinkresourceslistbyvaultsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateLinkResourcesListByVaultSample.ts +[secretscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsCreateOrUpdateSample.ts +[secretsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsGetSample.ts +[secretslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsListSample.ts +[secretsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsUpdateSample.ts +[vaultschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCheckNameAvailabilitySample.ts +[vaultscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCreateOrUpdateSample.ts +[vaultsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsDeleteSample.ts +[vaultsgetdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetDeletedSample.ts +[vaultsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetSample.ts +[vaultslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListByResourceGroupSample.ts +[vaultslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListBySubscriptionSample.ts +[vaultslistdeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListDeletedSample.ts +[vaultslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListSample.ts +[vaultspurgedeletedsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsPurgeDeletedSample.ts +[vaultsupdateaccesspolicysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateAccessPolicySample.ts +[vaultsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-keyvault?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/package.json b/sdk/keyvault/arm-keyvault/samples/v3/typescript/package.json new file mode 100644 index 000000000000..ffd48db14333 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-keyvault-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/keyvault/arm-keyvault" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault", + "dependencies": { + "@azure/arm-keyvault": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~4.8.0", + "rimraf": "latest" + } +} diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/sample.env b/sdk/keyvault/arm-keyvault/samples/v3/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysCreateIfNotExistSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysCreateIfNotExistSample.ts new file mode 100644 index 000000000000..e6e05de6641c --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysCreateIfNotExistSample.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + KeyCreateParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to 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. + * + * @summary 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. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createKey.json + */ +async function createAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const parameters: KeyCreateParameters = { properties: { kty: "RSA" } }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.keys.createIfNotExist( + resourceGroupName, + vaultName, + keyName, + parameters + ); + console.log(result); +} + +async function main() { + createAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetSample.ts new file mode 100644 index 000000000000..ffac62a62833 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetSample.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the current version of the specified key from the specified key vault. + * + * @summary Gets the current version of the specified key from the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKey.json + */ +async function getAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.keys.get(resourceGroupName, vaultName, keyName); + console.log(result); +} + +async function main() { + getAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetVersionSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetVersionSample.ts new file mode 100644 index 000000000000..a5cdfaa99d04 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysGetVersionSample.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified version of the specified key in the specified key vault. + * + * @summary Gets the specified version of the specified key in the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getKeyVersion.json + */ +async function getAKeyVersion() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.keys.getVersion( + resourceGroupName, + vaultName, + keyName, + keyVersion + ); + console.log(result); +} + +async function main() { + getAKeyVersion(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListSample.ts new file mode 100644 index 000000000000..2c1f532c1183 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the keys in the specified key vault. + * + * @summary Lists the keys in the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeys.json + */ +async function listKeysInTheVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.keys.list(resourceGroupName, vaultName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeysInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListVersionsSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListVersionsSample.ts new file mode 100644 index 000000000000..85e9a12364fd --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/keysListVersionsSample.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the versions of the specified key in the specified key vault. + * + * @summary Lists the versions of the specified key in the specified key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listKeyVersions.json + */ +async function listKeyVersionsInTheVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.keys.listVersions( + resourceGroupName, + vaultName, + keyName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeyVersionsInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysCreateIfNotExistSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysCreateIfNotExistSample.ts new file mode 100644 index 000000000000..2889fa177aa1 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysCreateIfNotExistSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + ManagedHsmKeyCreateParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to 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. + * + * @summary 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. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmCreateKey.json + */ +async function createAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const parameters: ManagedHsmKeyCreateParameters = { + properties: { kty: "RSA" } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.createIfNotExist( + resourceGroupName, + name, + keyName, + parameters + ); + console.log(result); +} + +async function main() { + createAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetSample.ts new file mode 100644 index 000000000000..b9a76ad1dc70 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the current version of the specified key from the specified managed HSM. + * + * @summary Gets the current version of the specified key from the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKey.json + */ +async function getAKey() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.get( + resourceGroupName, + name, + keyName + ); + console.log(result); +} + +async function main() { + getAKey(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetVersionSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetVersionSample.ts new file mode 100644 index 000000000000..dd3b842997f8 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysGetVersionSample.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified version of the specified key in the specified managed HSM. + * + * @summary Gets the specified version of the specified key in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmGetKeyVersion.json + */ +async function getAKeyVersion() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const keyVersion = "fd618d9519b74f9aae94ade66b876acc"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsmKeys.getVersion( + resourceGroupName, + name, + keyName, + keyVersion + ); + console.log(result); +} + +async function main() { + getAKeyVersion(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListSample.ts new file mode 100644 index 000000000000..4e8c320e4ba3 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the keys in the specified managed HSM. + * + * @summary Lists the keys in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeys.json + */ +async function listKeysInTheManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsmKeys.list(resourceGroupName, name)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeysInTheManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListVersionsSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListVersionsSample.ts new file mode 100644 index 000000000000..92790c2ddee2 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmKeysListVersionsSample.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the versions of the specified key in the specified managed HSM. + * + * @summary Lists the versions of the specified key in the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/managedHsmListKeyVersions.json + */ +async function listKeyVersionsInTheManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-managedhsm-name"; + const keyName = "sample-key-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsmKeys.listVersions( + resourceGroupName, + name, + keyName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listKeyVersionsInTheManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCheckMhsmNameAvailabilitySample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCheckMhsmNameAvailabilitySample.ts new file mode 100644 index 000000000000..aea7dd03a24f --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCheckMhsmNameAvailabilitySample.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + CheckMhsmNameAvailabilityParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks that the managed hsm name is valid and is not already in use. + * + * @summary Checks that the managed hsm name is valid and is not already in use. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_checkMhsmNameAvailability.json + */ +async function validateAManagedHsmName() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const mhsmName: CheckMhsmNameAvailabilityParameters = { name: "sample-mhsm" }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.checkMhsmNameAvailability(mhsmName); + console.log(result); +} + +async function main() { + validateAManagedHsmName(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCreateOrUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..59c9c15f02b4 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsCreateOrUpdateSample.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { ManagedHsm, KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a managed HSM Pool in the specified subscription. + * + * @summary Create or update a managed HSM Pool in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_CreateOrUpdate.json + */ +async function createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const parameters: ManagedHsm = { + location: "westus", + properties: { + enablePurgeProtection: false, + enableSoftDelete: true, + initialAdminObjectIds: ["00000000-0000-0000-0000-000000000000"], + softDeleteRetentionInDays: 90, + tenantId: "00000000-0000-0000-0000-000000000000" + }, + sku: { name: "Standard_B1", family: "B" }, + tags: { dept: "hsm", environment: "dogfood" } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginCreateOrUpdateAndWait( + resourceGroupName, + name, + parameters + ); + console.log(result); +} + +async function main() { + createANewManagedHsmPoolOrUpdateAnExistingManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsDeleteSample.ts new file mode 100644 index 000000000000..5eecebfd3557 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsDeleteSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified managed HSM Pool. + * + * @summary Deletes the specified managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Delete.json + */ +async function deleteAManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginDeleteAndWait( + resourceGroupName, + name + ); + console.log(result); +} + +async function main() { + deleteAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetDeletedSample.ts new file mode 100644 index 000000000000..9344dffbf5f5 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetDeletedSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified deleted managed HSM. + * + * @summary Gets the specified deleted managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Get.json + */ +async function retrieveADeletedManagedHsm() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const name = "hsm1"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.getDeleted(name, location); + console.log(result); +} + +async function main() { + retrieveADeletedManagedHsm(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetSample.ts new file mode 100644 index 000000000000..7a3ca6e0fdd6 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsGetSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified managed HSM Pool. + * + * @summary Gets the specified managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Get.json + */ +async function retrieveAManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.get(resourceGroupName, name); + console.log(result); +} + +async function main() { + retrieveAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListByResourceGroupSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListByResourceGroupSample.ts new file mode 100644 index 000000000000..e6a36394c66f --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListByResourceGroupSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. + * + * @summary The List operation gets information about the managed HSM Pools associated with the subscription and within the specified resource group. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListByResourceGroup.json + */ +async function listManagedHsmPoolsInAResourceGroup() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsms.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListBySubscriptionSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListBySubscriptionSample.ts new file mode 100644 index 000000000000..26d4b038780b --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListBySubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the managed HSM Pools associated with the subscription. + * + * @summary The List operation gets information about the managed HSM Pools associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListBySubscription.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsms.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListDeletedSample.ts new file mode 100644 index 000000000000..156e074e8ab8 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsListDeletedSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the deleted managed HSMs associated with the subscription. + * + * @summary The List operation gets information about the deleted managed HSMs associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_List.json + */ +async function listDeletedManagedHsMSInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managedHsms.listDeleted()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDeletedManagedHsMSInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsPurgeDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsPurgeDeletedSample.ts new file mode 100644 index 000000000000..d5aa35e64a2d --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsPurgeDeletedSample.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Permanently deletes the specified managed HSM. + * + * @summary Permanently deletes the specified managed HSM. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/DeletedManagedHsm_Purge.json + */ +async function purgeAManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const name = "hsm1"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginPurgeDeletedAndWait( + name, + location + ); + console.log(result); +} + +async function main() { + purgeAManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsUpdateSample.ts new file mode 100644 index 000000000000..cd8f26501638 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/managedHsmsUpdateSample.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { ManagedHsm, KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a managed HSM Pool in the specified subscription. + * + * @summary Update a managed HSM Pool in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_Update.json + */ +async function updateAnExistingManagedHsmPool() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "hsm-group"; + const name = "hsm1"; + const parameters: ManagedHsm = { + tags: { dept: "hsm", environment: "dogfood", slice: "A" } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.managedHsms.beginUpdateAndWait( + resourceGroupName, + name, + parameters + ); + console.log(result); +} + +async function main() { + updateAnExistingManagedHsmPool(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..93840d3c98d0 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsDeleteSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the managed hsm pool. + * + * @summary Deletes the specified private endpoint connection associated with the managed hsm pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_deletePrivateEndpointConnection.json + */ +async function managedHsmDeletePrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + name, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + managedHsmDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..7c51c0d76a7a --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsGetSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the managed HSM Pool. + * + * @summary Gets the specified private endpoint connection associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_getPrivateEndpointConnection.json + */ +async function managedHsmGetPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateEndpointConnections.get( + resourceGroupName, + name, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + managedHsmGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsListByResourceSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsListByResourceSample.ts new file mode 100644 index 000000000000..9ea5ff149a73 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsListByResourceSample.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the private endpoint connections associated with the managed HSM Pool. + * + * @summary The List operation gets information about the private endpoint connections associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.mhsmPrivateEndpointConnections.listByResource( + resourceGroupName, + name + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsPutSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsPutSample.ts new file mode 100644 index 000000000000..32a627c5b1aa --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateEndpointConnectionsPutSample.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + MhsmPrivateEndpointConnection, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates the specified private endpoint connection associated with the managed hsm pool. + * + * @summary Updates the specified private endpoint connection associated with the managed hsm pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_putPrivateEndpointConnection.json + */ +async function managedHsmPutPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const privateEndpointConnectionName = "sample-pec"; + const properties: MhsmPrivateEndpointConnection = { + privateLinkServiceConnectionState: { + description: "My name is Joe and I'm approving this.", + status: "Approved" + } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateEndpointConnections.put( + resourceGroupName, + name, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + managedHsmPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts new file mode 100644 index 000000000000..8042ff4a98f7 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmPrivateLinkResourcesListByMhsmResourceSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the private link resources supported for the managed hsm pool. + * + * @summary Gets the private link resources supported for the managed hsm pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_listPrivateLinkResources.json + */ +async function keyVaultListPrivateLinkResources() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.mhsmPrivateLinkResources.listByMhsmResource( + resourceGroupName, + name + ); + console.log(result); +} + +async function main() { + keyVaultListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmRegionsListByResourceSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmRegionsListByResourceSample.ts new file mode 100644 index 000000000000..73328e7bdf29 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/mhsmRegionsListByResourceSample.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the regions associated with the managed HSM Pool. + * + * @summary The List operation gets information about the regions associated with the managed HSM Pool. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/ManagedHsm_ListRegionsByResource.json + */ +async function listManagedHsmPoolsInASubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const name = "sample-mhsm"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.mhsmRegions.listByResource( + resourceGroupName, + name + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listManagedHsmPoolsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/operationsListSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..391fc0d6fd27 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/operationsListSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all of the available Key Vault Rest API operations. + * + * @summary Lists all of the available Key Vault Rest API operations. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listOperations.json + */ +async function listsAvailableRestApiOperations() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listsAvailableRestApiOperations(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..0735dc74ff4f --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsDeleteSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the key vault. + * + * @summary Deletes the specified private endpoint connection associated with the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deletePrivateEndpointConnection.json + */ +async function keyVaultDeletePrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + vaultName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + keyVaultDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..79ee19a5663b --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsGetSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the key vault. + * + * @summary Gets the specified private endpoint connection associated with the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getPrivateEndpointConnection.json + */ +async function keyVaultGetPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const privateEndpointConnectionName = "sample-pec"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + vaultName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + keyVaultGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsListByResourceSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsListByResourceSample.ts new file mode 100644 index 000000000000..3d145b68aaaf --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsListByResourceSample.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the private endpoint connections associated with the vault. + * + * @summary The List operation gets information about the private endpoint connections associated with the vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateEndpointConnection.json + */ +async function keyVaultListPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.listByResource( + resourceGroupName, + vaultName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + keyVaultListPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsPutSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsPutSample.ts new file mode 100644 index 000000000000..292467782b5d --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateEndpointConnectionsPutSample.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + PrivateEndpointConnection, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates the specified private endpoint connection associated with the key vault. + * + * @summary Updates the specified private endpoint connection associated with the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/putPrivateEndpointConnection.json + */ +async function keyVaultPutPrivateEndpointConnection() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const privateEndpointConnectionName = "sample-pec"; + const properties: PrivateEndpointConnection = { + etag: "", + privateLinkServiceConnectionState: { + description: "My name is Joe and I'm approving this.", + status: "Approved" + } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.put( + resourceGroupName, + vaultName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + keyVaultPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateLinkResourcesListByVaultSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateLinkResourcesListByVaultSample.ts new file mode 100644 index 000000000000..c6f5b46de290 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/privateLinkResourcesListByVaultSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the private link resources supported for the key vault. + * + * @summary Gets the private link resources supported for the key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listPrivateLinkResources.json + */ +async function keyVaultListPrivateLinkResources() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.listByVault( + resourceGroupName, + vaultName + ); + console.log(result); +} + +async function main() { + keyVaultListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsCreateOrUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..23eb3b154ddb --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsCreateOrUpdateSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + SecretCreateOrUpdateParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary Create or update a secret in a key vault in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createSecret.json + */ +async function createASecret() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const secretName = "secret-name"; + const parameters: SecretCreateOrUpdateParameters = { + properties: { value: "secret-value" } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.secrets.createOrUpdate( + resourceGroupName, + vaultName, + secretName, + parameters + ); + console.log(result); +} + +async function main() { + createASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsGetSample.ts new file mode 100644 index 000000000000..c34d89a2bf01 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsGetSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getSecret.json + */ +async function getASecret() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const secretName = "secret-name"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.secrets.get( + resourceGroupName, + vaultName, + secretName + ); + console.log(result); +} + +async function main() { + getASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsListSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsListSample.ts new file mode 100644 index 000000000000..ed4032df492d --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsListSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary The List operation gets information about the secrets in a vault. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listSecrets.json + */ +async function listSecretsInTheVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.secrets.list(resourceGroupName, vaultName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listSecretsInTheVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsUpdateSample.ts new file mode 100644 index 000000000000..30c3658c557a --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/secretsUpdateSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + SecretPatchParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * + * @summary Update a secret in the specified subscription. NOTE: This API is intended for internal use in ARM deployments. Users should use the data-plane REST service for interaction with vault secrets. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateSecret.json + */ +async function updateASecret() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const secretName = "secret-name"; + const parameters: SecretPatchParameters = { + properties: { value: "secret-value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.secrets.update( + resourceGroupName, + vaultName, + secretName, + parameters + ); + console.log(result); +} + +async function main() { + updateASecret(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCheckNameAvailabilitySample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..51f54ce1ae2a --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCheckNameAvailabilitySample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultCheckNameAvailabilityParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks that the vault name is valid and is not already in use. + * + * @summary Checks that the vault name is valid and is not already in use. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/checkVaultNameAvailability.json + */ +async function validateAVaultName() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const vaultName: VaultCheckNameAvailabilityParameters = { + name: "sample-vault", + type: "Microsoft.KeyVault/vaults" + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.checkNameAvailability(vaultName); + console.log(result); +} + +async function main() { + validateAVaultName(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCreateOrUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..a5d5d3a10677 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsCreateOrUpdateSample.ts @@ -0,0 +1,155 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultCreateOrUpdateParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a key vault in the specified subscription. + * + * @summary Create or update a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVault.json + */ +async function createANewVaultOrUpdateAnExistingVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const parameters: VaultCreateOrUpdateParameters = { + location: "westus", + properties: { + accessPolicies: [ + { + objectId: "00000000-0000-0000-0000-000000000000", + permissions: { + certificates: [ + "get", + "list", + "delete", + "create", + "import", + "update", + "managecontacts", + "getissuers", + "listissuers", + "setissuers", + "deleteissuers", + "manageissuers", + "recover", + "purge" + ], + keys: [ + "encrypt", + "decrypt", + "wrapKey", + "unwrapKey", + "sign", + "verify", + "get", + "list", + "create", + "update", + "import", + "delete", + "backup", + "restore", + "recover", + "purge" + ], + secrets: [ + "get", + "list", + "set", + "delete", + "backup", + "restore", + "recover", + "purge" + ] + }, + tenantId: "00000000-0000-0000-0000-000000000000" + } + ], + enabledForDeployment: true, + enabledForDiskEncryption: true, + enabledForTemplateDeployment: true, + publicNetworkAccess: "Enabled", + sku: { name: "standard", family: "A" }, + tenantId: "00000000-0000-0000-0000-000000000000" + } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.beginCreateOrUpdateAndWait( + resourceGroupName, + vaultName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a key vault in the specified subscription. + * + * @summary Create or update a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/createVaultWithNetworkAcls.json + */ +async function createOrUpdateAVaultWithNetworkAcls() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const parameters: VaultCreateOrUpdateParameters = { + location: "westus", + properties: { + enabledForDeployment: true, + enabledForDiskEncryption: true, + enabledForTemplateDeployment: true, + networkAcls: { + bypass: "AzureServices", + defaultAction: "Deny", + ipRules: [{ value: "124.56.78.91" }, { value: "'10.91.4.0/24'" }], + virtualNetworkRules: [ + { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1" + } + ] + }, + sku: { name: "standard", family: "A" }, + tenantId: "00000000-0000-0000-0000-000000000000" + } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.beginCreateOrUpdateAndWait( + resourceGroupName, + vaultName, + parameters + ); + console.log(result); +} + +async function main() { + createANewVaultOrUpdateAnExistingVault(); + createOrUpdateAVaultWithNetworkAcls(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsDeleteSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsDeleteSample.ts new file mode 100644 index 000000000000..6063938d1db3 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsDeleteSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified Azure key vault. + * + * @summary Deletes the specified Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/deleteVault.json + */ +async function deleteAVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.delete(resourceGroupName, vaultName); + console.log(result); +} + +async function main() { + deleteAVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetDeletedSample.ts new file mode 100644 index 000000000000..8bfcbbfd0a93 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetDeletedSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the deleted Azure key vault. + * + * @summary Gets the deleted Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getDeletedVault.json + */ +async function retrieveADeletedVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const vaultName = "sample-vault"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.getDeleted(vaultName, location); + console.log(result); +} + +async function main() { + retrieveADeletedVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetSample.ts new file mode 100644 index 000000000000..5101b5749369 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsGetSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified Azure key vault. + * + * @summary Gets the specified Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/getVault.json + */ +async function retrieveAVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.get(resourceGroupName, vaultName); + console.log(result); +} + +async function main() { + retrieveAVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListByResourceGroupSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListByResourceGroupSample.ts new file mode 100644 index 000000000000..6bd75e33cba5 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListByResourceGroupSample.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultsListByResourceGroupOptionalParams, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription and within the specified resource group. + * + * @summary The List operation gets information about the vaults associated with the subscription and within the specified resource group. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultByResourceGroup.json + */ +async function listVaultsInTheSpecifiedResourceGroup() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const top = 1; + const options: VaultsListByResourceGroupOptionalParams = { top }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.listByResourceGroup( + resourceGroupName, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVaultsInTheSpecifiedResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListBySubscriptionSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListBySubscriptionSample.ts new file mode 100644 index 000000000000..9d3e51523414 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListBySubscriptionSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultsListBySubscriptionOptionalParams, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription. + * + * @summary The List operation gets information about the vaults associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVaultBySubscription.json + */ +async function listVaultsInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const top = 1; + const options: VaultsListBySubscriptionOptionalParams = { top }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.listBySubscription(options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListDeletedSample.ts new file mode 100644 index 000000000000..330f29acb182 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListDeletedSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets information about the deleted vaults in a subscription. + * + * @summary Gets information about the deleted vaults in a subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listDeletedVaults.json + */ +async function listDeletedVaultsInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.listDeleted()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDeletedVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListSample.ts new file mode 100644 index 000000000000..b97fefc3aeed --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsListSample.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultsListOptionalParams, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List operation gets information about the vaults associated with the subscription. + * + * @summary The List operation gets information about the vaults associated with the subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/listVault.json + */ +async function listVaultsInTheSpecifiedSubscription() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const top = 1; + const options: VaultsListOptionalParams = { top }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.vaults.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVaultsInTheSpecifiedSubscription(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsPurgeDeletedSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsPurgeDeletedSample.ts new file mode 100644 index 000000000000..3bbeb6235b87 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsPurgeDeletedSample.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { KeyVaultManagementClient } from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Permanently deletes the specified vault. aka Purges the deleted Azure key vault. + * + * @summary Permanently deletes the specified vault. aka Purges the deleted Azure key vault. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/purgeDeletedVault.json + */ +async function purgeADeletedVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const vaultName = "sample-vault"; + const location = "westus"; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.beginPurgeDeletedAndWait( + vaultName, + location + ); + console.log(result); +} + +async function main() { + purgeADeletedVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateAccessPolicySample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateAccessPolicySample.ts new file mode 100644 index 000000000000..51dfe4bbe3d7 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateAccessPolicySample.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultAccessPolicyParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update access policies in a key vault in the specified subscription. + * + * @summary Update access policies in a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateAccessPoliciesAdd.json + */ +async function addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-group"; + const vaultName = "sample-vault"; + const operationKind = "add"; + const parameters: VaultAccessPolicyParameters = { + properties: { + accessPolicies: [ + { + objectId: "00000000-0000-0000-0000-000000000000", + permissions: { + certificates: ["get"], + keys: ["encrypt"], + secrets: ["get"] + }, + tenantId: "00000000-0000-0000-0000-000000000000" + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.updateAccessPolicy( + resourceGroupName, + vaultName, + operationKind, + parameters + ); + console.log(result); +} + +async function main() { + addAnAccessPolicyOrUpdateAnAccessPolicyWithNewPermissions(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateSample.ts b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateSample.ts new file mode 100644 index 000000000000..ef324f6330ca --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/src/vaultsUpdateSample.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VaultPatchParameters, + KeyVaultManagementClient +} from "@azure/arm-keyvault"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a key vault in the specified subscription. + * + * @summary Update a key vault in the specified subscription. + * x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-02-01/examples/updateVault.json + */ +async function updateAnExistingVault() { + const subscriptionId = + process.env["KEYVAULT_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["KEYVAULT_RESOURCE_GROUP"] || "sample-resource-group"; + const vaultName = "sample-vault"; + const parameters: VaultPatchParameters = { + properties: { + accessPolicies: [ + { + objectId: "00000000-0000-0000-0000-000000000000", + permissions: { + certificates: [ + "get", + "list", + "delete", + "create", + "import", + "update", + "managecontacts", + "getissuers", + "listissuers", + "setissuers", + "deleteissuers", + "manageissuers", + "recover", + "purge" + ], + keys: [ + "encrypt", + "decrypt", + "wrapKey", + "unwrapKey", + "sign", + "verify", + "get", + "list", + "create", + "update", + "import", + "delete", + "backup", + "restore", + "recover", + "purge" + ], + secrets: [ + "get", + "list", + "set", + "delete", + "backup", + "restore", + "recover", + "purge" + ] + }, + tenantId: "00000000-0000-0000-0000-000000000000" + } + ], + enabledForDeployment: true, + enabledForDiskEncryption: true, + enabledForTemplateDeployment: true, + publicNetworkAccess: "Enabled", + sku: { name: "standard", family: "A" }, + tenantId: "00000000-0000-0000-0000-000000000000" + } + }; + const credential = new DefaultAzureCredential(); + const client = new KeyVaultManagementClient(credential, subscriptionId); + const result = await client.vaults.update( + resourceGroupName, + vaultName, + parameters + ); + console.log(result); +} + +async function main() { + updateAnExistingVault(); +} + +main().catch(console.error); diff --git a/sdk/keyvault/arm-keyvault/samples/v3/typescript/tsconfig.json b/sdk/keyvault/arm-keyvault/samples/v3/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/samples/v3/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/keyvault/arm-keyvault/src/keyVaultManagementClient.ts b/sdk/keyvault/arm-keyvault/src/keyVaultManagementClient.ts index 27bbe563e0a3..a7a5c4ba392c 100644 --- a/sdk/keyvault/arm-keyvault/src/keyVaultManagementClient.ts +++ b/sdk/keyvault/arm-keyvault/src/keyVaultManagementClient.ts @@ -16,23 +16,27 @@ import { import * as coreAuth from "@azure/core-auth"; import { KeysImpl, + ManagedHsmKeysImpl, VaultsImpl, PrivateEndpointConnectionsImpl, PrivateLinkResourcesImpl, ManagedHsmsImpl, MhsmPrivateEndpointConnectionsImpl, MhsmPrivateLinkResourcesImpl, + MhsmRegionsImpl, OperationsImpl, SecretsImpl } from "./operations"; import { Keys, + ManagedHsmKeys, Vaults, PrivateEndpointConnections, PrivateLinkResources, ManagedHsms, MhsmPrivateEndpointConnections, MhsmPrivateLinkResources, + MhsmRegions, Operations, Secrets } from "./operationsInterfaces"; @@ -71,7 +75,7 @@ export class KeyVaultManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-keyvault/2.1.0-beta.3`; + const packageDetails = `azsdk-js-arm-keyvault/3.0.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -124,8 +128,9 @@ export class KeyVaultManagementClient extends coreClient.ServiceClient { // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-11-01-preview"; + this.apiVersion = options.apiVersion || "2023-02-01"; this.keys = new KeysImpl(this); + this.managedHsmKeys = new ManagedHsmKeysImpl(this); this.vaults = new VaultsImpl(this); this.privateEndpointConnections = new PrivateEndpointConnectionsImpl(this); this.privateLinkResources = new PrivateLinkResourcesImpl(this); @@ -134,6 +139,7 @@ export class KeyVaultManagementClient extends coreClient.ServiceClient { this ); this.mhsmPrivateLinkResources = new MhsmPrivateLinkResourcesImpl(this); + this.mhsmRegions = new MhsmRegionsImpl(this); this.operations = new OperationsImpl(this); this.secrets = new SecretsImpl(this); this.addCustomApiVersionPolicy(options.apiVersion); @@ -168,12 +174,14 @@ export class KeyVaultManagementClient extends coreClient.ServiceClient { } keys: Keys; + managedHsmKeys: ManagedHsmKeys; vaults: Vaults; privateEndpointConnections: PrivateEndpointConnections; privateLinkResources: PrivateLinkResources; managedHsms: ManagedHsms; mhsmPrivateEndpointConnections: MhsmPrivateEndpointConnections; mhsmPrivateLinkResources: MhsmPrivateLinkResources; + mhsmRegions: MhsmRegions; operations: Operations; secrets: Secrets; } diff --git a/sdk/keyvault/arm-keyvault/src/lroImpl.ts b/sdk/keyvault/arm-keyvault/src/lroImpl.ts index 518d5f053b4e..dd803cd5e28c 100644 --- a/sdk/keyvault/arm-keyvault/src/lroImpl.ts +++ b/sdk/keyvault/arm-keyvault/src/lroImpl.ts @@ -6,29 +6,37 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AbortSignalLike } from "@azure/abort-controller"; import { LongRunningOperation, LroResponse } from "@azure/core-lro"; -export class LroImpl implements LongRunningOperation { - constructor( - private sendOperationFn: (args: any, spec: any) => Promise>, - private args: Record, - private spec: { - readonly requestBody?: unknown; - readonly path?: string; - readonly httpMethod: string; - } & Record, - public requestPath: string = spec.path!, - public requestMethod: string = spec.httpMethod - ) {} - public async sendInitialRequest(): Promise> { - return this.sendOperationFn(this.args, this.spec); - } - public async sendPollRequest(path: string): Promise> { - const { requestBody, ...restSpec } = this.spec; - return this.sendOperationFn(this.args, { - ...restSpec, - path, - httpMethod: "GET" - }); - } +export function createLroSpec(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + const { args, spec, sendOperationFn } = inputs; + return { + requestMethod: spec.httpMethod, + requestPath: spec.path!, + sendInitialRequest: () => sendOperationFn(args, spec), + sendPollRequest: ( + path: string, + options?: { abortSignal?: AbortSignalLike } + ) => { + const { requestBody, ...restSpec } = spec; + return sendOperationFn(args, { + ...restSpec, + httpMethod: "GET", + path, + abortSignal: options?.abortSignal + }); + } + }; } diff --git a/sdk/keyvault/arm-keyvault/src/models/index.ts b/sdk/keyvault/arm-keyvault/src/models/index.ts index ace70e9079e7..d68099bfe8ce 100644 --- a/sdk/keyvault/arm-keyvault/src/models/index.ts +++ b/sdk/keyvault/arm-keyvault/src/models/index.ts @@ -169,6 +169,145 @@ export interface KeyListResult { nextLink?: string; } +/** The parameters used to create a key. */ +export interface ManagedHsmKeyCreateParameters { + /** The tags that will be assigned to the key. */ + tags?: { [propertyName: string]: string }; + /** The properties of the key to be created. */ + properties: ManagedHsmKeyProperties; +} + +/** The properties of the key. */ +export interface ManagedHsmKeyProperties { + /** The attributes of the key. */ + attributes?: ManagedHsmKeyAttributes; + /** The type of the key. For valid values, see JsonWebKeyType. */ + kty?: JsonWebKeyType; + keyOps?: JsonWebKeyOperation[]; + /** The key size in bits. For example: 2048, 3072, or 4096 for RSA. */ + keySize?: number; + /** The elliptic curve name. For valid values, see JsonWebKeyCurveName. */ + curveName?: JsonWebKeyCurveName; + /** + * The URI to retrieve the current version of the key. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly keyUri?: string; + /** + * The URI to retrieve the specific version of the key. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly keyUriWithVersion?: string; + /** Key rotation policy in response. It will be used for both output and input. Omitted if empty */ + rotationPolicy?: ManagedHsmRotationPolicy; + /** Key release policy in response. It will be used for both output and input. Omitted if empty */ + releasePolicy?: ManagedHsmKeyReleasePolicy; +} + +/** The object attributes managed by the Azure Key Vault service. */ +export interface ManagedHsmKeyAttributes { + /** Determines whether or not the object is enabled. */ + enabled?: boolean; + /** Not before date in seconds since 1970-01-01T00:00:00Z. */ + notBefore?: number; + /** Expiry date in seconds since 1970-01-01T00:00:00Z. */ + expires?: number; + /** + * Creation time in seconds since 1970-01-01T00:00:00Z. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly created?: number; + /** + * Last updated time in seconds since 1970-01-01T00:00:00Z. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly updated?: number; + /** + * 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. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly recoveryLevel?: DeletionRecoveryLevel; + /** Indicates if the private key can be exported. */ + exportable?: boolean; +} + +export interface ManagedHsmRotationPolicy { + /** The attributes of key rotation policy. */ + attributes?: ManagedHsmKeyRotationPolicyAttributes; + /** The lifetimeActions for key rotation action. */ + lifetimeActions?: ManagedHsmLifetimeAction[]; +} + +export interface ManagedHsmKeyRotationPolicyAttributes { + /** + * Creation time in seconds since 1970-01-01T00:00:00Z. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly created?: number; + /** + * Last updated time in seconds since 1970-01-01T00:00:00Z. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly updated?: number; + /** The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'. */ + expiryTime?: string; +} + +export interface ManagedHsmLifetimeAction { + /** The trigger of key rotation policy lifetimeAction. */ + trigger?: ManagedHsmTrigger; + /** The action of key rotation policy lifetimeAction. */ + action?: ManagedHsmAction; +} + +export interface ManagedHsmTrigger { + /** 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'. */ + timeAfterCreate?: string; + /** The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. */ + timeBeforeExpiry?: string; +} + +export interface ManagedHsmAction { + /** The type of action. */ + type?: KeyRotationPolicyActionType; +} + +export interface ManagedHsmKeyReleasePolicy { + /** Content type and version of key release policy */ + contentType?: string; + /** Blob encoding the policy rules under which the key can be released. */ + data?: Uint8Array; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface ProxyResourceWithoutSystemData { + /** + * Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The name of the resource + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** Resource tags. */ + tags?: { [propertyName: string]: string }; +} + +/** The page of keys. */ +export interface ManagedHsmKeyListResult { + /** The key resources. */ + value?: ManagedHsmKey[]; + /** The URL to get the next page of keys. */ + nextLink?: string; +} + /** Parameters for creating or updating a vault */ export interface VaultCreateOrUpdateParameters { /** The supported Azure location where the key vault should be created. */ @@ -204,7 +343,7 @@ export interface VaultProperties { enableSoftDelete?: boolean; /** softDelete data retention days. It accepts >=7 and <=90. */ softDeleteRetentionInDays?: number; - /** Property that controls how data actions are authorized. When true, the key vault will use Role Based Access Control (RBAC) for authorization of data actions, and the access policies specified in vault properties will be ignored (warning: this is a preview feature). When false, the key vault will use the access policies specified in vault properties, and any policy stored on Azure Resource Manager will be ignored. If null or not specified, the vault is created with the default value of false. Note that management actions are always authorized with RBAC. */ + /** Property that controls how data actions are authorized. When true, the key vault will use Role Based Access Control (RBAC) for authorization of data actions, and the access policies specified in vault properties will be ignored. When false, the key vault will use the access policies specified in vault properties, and any policy stored on Azure Resource Manager will be ignored. If null or not specified, the vault is created with the default value of false. Note that management actions are always authorized with RBAC. */ enableRbacAuthorization?: boolean; /** The vault's create mode to indicate whether the vault need to be recovered or not. */ createMode?: CreateMode; @@ -384,7 +523,7 @@ export interface VaultPatchProperties { enabledForTemplateDeployment?: boolean; /** Property to specify whether the 'soft delete' functionality is enabled for this key vault. Once set to true, it cannot be reverted to false. */ enableSoftDelete?: boolean; - /** Property that controls how data actions are authorized. When true, the key vault will use Role Based Access Control (RBAC) for authorization of data actions, and the access policies specified in vault properties will be ignored (warning: this is a preview feature). When false, the key vault will use the access policies specified in vault properties, and any policy stored on Azure Resource Manager will be ignored. If null or not specified, the value of this property will not change. */ + /** Property that controls how data actions are authorized. When true, the key vault will use Role Based Access Control (RBAC) for authorization of data actions, and the access policies specified in vault properties will be ignored. When false, the key vault will use the access policies specified in vault properties, and any policy stored on Azure Resource Manager will be ignored. If null or not specified, the value of this property will not change. */ enableRbacAuthorization?: boolean; /** softDelete data retention days. It accepts >=7 and <=90. */ softDeleteRetentionInDays?: number; @@ -581,6 +720,8 @@ export interface ManagedHsmProperties { readonly provisioningState?: ProvisioningState; /** Rules governing the accessibility of the key vault from specific network locations. */ networkAcls?: MhsmNetworkRuleSet; + /** List of all regions associated with the managed hsm pool. */ + regions?: MhsmGeoReplicatedRegion[]; /** * List of private endpoint connections associated with the managed hsm pool. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -593,6 +734,11 @@ export interface ManagedHsmProperties { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly scheduledPurgeDate?: Date; + /** + * Managed HSM security domain properties. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly securityDomainProperties?: ManagedHSMSecurityDomainProperties; } /** A set of rules governing the network accessibility of a managed hsm pool. */ @@ -607,7 +753,7 @@ export interface MhsmNetworkRuleSet { virtualNetworkRules?: MhsmVirtualNetworkRule[]; } -/** A rule governing the accessibility of a managed hsm pool from a specific ip address or ip range. */ +/** A rule governing the accessibility of a managed HSM pool from a specific IP address or IP range. */ export interface MhsmipRule { /** An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) or '124.56.78.0/24' (all addresses that start with 124.56.78). */ value: string; @@ -619,6 +765,19 @@ export interface MhsmVirtualNetworkRule { id: string; } +/** A region that this managed HSM Pool has been extended to. */ +export interface MhsmGeoReplicatedRegion { + /** Name of the geo replicated region. */ + name?: string; + /** + * Provisioning state of the geo replicated region. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: GeoReplicationRegionProvisioningState; + /** A boolean value that indicates whether the region is the primary region or a secondary region. */ + isPrimary?: boolean; +} + /** Private endpoint connection item. */ export interface MhsmPrivateEndpointConnectionItem { /** Id of private endpoint connection. */ @@ -652,6 +811,20 @@ export interface MhsmPrivateLinkServiceConnectionState { actionsRequired?: ActionsRequired; } +/** The security domain properties of the managed hsm. */ +export interface ManagedHSMSecurityDomainProperties { + /** + * Activation Status + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly activationStatus?: ActivationStatus; + /** + * Activation Status Message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly activationStatusMessage?: string; +} + /** Managed HSM resource */ export interface ManagedHsmResource { /** @@ -802,6 +975,39 @@ export interface MhsmPrivateLinkResourceListResult { value?: MhsmPrivateLinkResource[]; } +/** List of regions associated with a managed HSM Pools */ +export interface MhsmRegionsListResult { + /** The region associated with a managed HSM Pools. */ + value?: MhsmGeoReplicatedRegion[]; + /** The URL to get the next set of managed HSM Pools. */ + nextLink?: string; +} + +/** The parameters used to check the availability of the managed hsm name. */ +export interface CheckMhsmNameAvailabilityParameters { + /** The managed hsm name. */ + name: string; +} + +/** The CheckMhsmNameAvailability operation response. */ +export interface CheckMhsmNameAvailabilityResult { + /** + * A boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or is invalid and cannot be used. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nameAvailable?: boolean; + /** + * The reason that a managed hsm name could not be used. The reason element is only returned if NameAvailable is false. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly reason?: Reason; + /** + * An error message explaining the Reason value in more detail. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; +} + /** Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. */ export interface OperationListResult { /** List of Storage operations supported by the Storage resource provider. */ @@ -1025,6 +1231,33 @@ export interface Secret extends Resource { properties: SecretProperties; } +/** The key resource. */ +export interface ManagedHsmKey extends ProxyResourceWithoutSystemData { + /** The attributes of the key. */ + attributes?: ManagedHsmKeyAttributes; + /** The type of the key. For valid values, see JsonWebKeyType. */ + kty?: JsonWebKeyType; + keyOps?: JsonWebKeyOperation[]; + /** The key size in bits. For example: 2048, 3072, or 4096 for RSA. */ + keySize?: number; + /** The elliptic curve name. For valid values, see JsonWebKeyCurveName. */ + curveName?: JsonWebKeyCurveName; + /** + * The URI to retrieve the current version of the key. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly keyUri?: string; + /** + * The URI to retrieve the specific version of the key. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly keyUriWithVersion?: string; + /** Key rotation policy in response. It will be used for both output and input. Omitted if empty */ + rotationPolicy?: ManagedHsmRotationPolicy; + /** Key release policy in response. It will be used for both output and input. Omitted if empty */ + releasePolicy?: ManagedHsmKeyReleasePolicy; +} + /** Resource information with extended details. */ export interface ManagedHsm extends ManagedHsmResource { /** Properties of the managed HSM */ @@ -1078,12 +1311,30 @@ export interface PrivateEndpointConnectionsDeleteHeaders { location?: string; } +/** Defines headers for ManagedHsms_createOrUpdate operation. */ +export interface ManagedHsmsCreateOrUpdateHeaders { + /** The URI to poll for completion status. */ + location?: string; +} + /** Defines headers for ManagedHsms_update operation. */ export interface ManagedHsmsUpdateHeaders { /** The URI to poll for completion status. */ location?: string; } +/** Defines headers for ManagedHsms_delete operation. */ +export interface ManagedHsmsDeleteHeaders { + /** The URI to poll for completion status. */ + location?: string; +} + +/** Defines headers for ManagedHsms_purgeDeleted operation. */ +export interface ManagedHsmsPurgeDeletedHeaders { + /** The URI to poll for completion status. */ + location?: string; +} + /** Defines headers for MhsmPrivateEndpointConnections_put operation. */ export interface MhsmPrivateEndpointConnectionsPutHeaders { /** (specified only if operation does not finish synchronously) The recommended number of seconds to wait before calling the URI specified in Azure-AsyncOperation. */ @@ -1094,8 +1345,6 @@ export interface MhsmPrivateEndpointConnectionsPutHeaders { /** Defines headers for MhsmPrivateEndpointConnections_delete operation. */ export interface MhsmPrivateEndpointConnectionsDeleteHeaders { - /** The recommended number of seconds to wait before calling the URI specified in the location header. */ - retryAfter?: number; /** The URI to poll for completion status. */ location?: string; } @@ -1640,6 +1889,36 @@ export enum KnownProvisioningState { */ export type ProvisioningState = string; +/** Known values of {@link GeoReplicationRegionProvisioningState} that the service accepts. */ +export enum KnownGeoReplicationRegionProvisioningState { + /** Preprovisioning */ + Preprovisioning = "Preprovisioning", + /** Provisioning */ + Provisioning = "Provisioning", + /** Succeeded */ + Succeeded = "Succeeded", + /** Failed */ + Failed = "Failed", + /** Deleting */ + Deleting = "Deleting", + /** Cleanup */ + Cleanup = "Cleanup" +} + +/** + * Defines values for GeoReplicationRegionProvisioningState. \ + * {@link KnownGeoReplicationRegionProvisioningState} can be used interchangeably with GeoReplicationRegionProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Preprovisioning** \ + * **Provisioning** \ + * **Succeeded** \ + * **Failed** \ + * **Deleting** \ + * **Cleanup** + */ +export type GeoReplicationRegionProvisioningState = string; + /** Known values of {@link PublicNetworkAccess} that the service accepts. */ export enum KnownPublicNetworkAccess { /** Enabled */ @@ -1658,6 +1937,30 @@ export enum KnownPublicNetworkAccess { */ export type PublicNetworkAccess = string; +/** Known values of {@link ActivationStatus} that the service accepts. */ +export enum KnownActivationStatus { + /** The managed HSM Pool is active. */ + Active = "Active", + /** The managed HSM Pool is not yet activated. */ + NotActivated = "NotActivated", + /** An unknown error occurred while activating managed hsm. */ + Unknown = "Unknown", + /** Failed to activate managed hsm. */ + Failed = "Failed" +} + +/** + * Defines values for ActivationStatus. \ + * {@link KnownActivationStatus} can be used interchangeably with ActivationStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Active**: The managed HSM Pool is active. \ + * **NotActivated**: The managed HSM Pool is not yet activated. \ + * **Unknown**: An unknown error occurred while activating managed hsm. \ + * **Failed**: Failed to activate managed hsm. + */ +export type ActivationStatus = string; + /** Known values of {@link ManagedHsmSkuFamily} that the service accepts. */ export enum KnownManagedHsmSkuFamily { /** B */ @@ -1732,6 +2035,55 @@ export interface KeysListVersionsNextOptionalParams /** Contains response data for the listVersionsNext operation. */ export type KeysListVersionsNextResponse = KeyListResult; +/** Optional parameters. */ +export interface ManagedHsmKeysCreateIfNotExistOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the createIfNotExist operation. */ +export type ManagedHsmKeysCreateIfNotExistResponse = ManagedHsmKey; + +/** Optional parameters. */ +export interface ManagedHsmKeysGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type ManagedHsmKeysGetResponse = ManagedHsmKey; + +/** Optional parameters. */ +export interface ManagedHsmKeysListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type ManagedHsmKeysListResponse = ManagedHsmKeyListResult; + +/** Optional parameters. */ +export interface ManagedHsmKeysGetVersionOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getVersion operation. */ +export type ManagedHsmKeysGetVersionResponse = ManagedHsmKey; + +/** Optional parameters. */ +export interface ManagedHsmKeysListVersionsOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listVersions operation. */ +export type ManagedHsmKeysListVersionsResponse = ManagedHsmKeyListResult; + +/** Optional parameters. */ +export interface ManagedHsmKeysListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type ManagedHsmKeysListNextResponse = ManagedHsmKeyListResult; + +/** Optional parameters. */ +export interface ManagedHsmKeysListVersionsNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listVersionsNext operation. */ +export type ManagedHsmKeysListVersionsNextResponse = ManagedHsmKeyListResult; + /** Optional parameters. */ export interface VaultsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { @@ -1829,20 +2181,14 @@ export type VaultsCheckNameAvailabilityResponse = CheckNameAvailabilityResult; /** Optional parameters. */ export interface VaultsListByResourceGroupNextOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listByResourceGroupNext operation. */ export type VaultsListByResourceGroupNextResponse = VaultListResult; /** Optional parameters. */ export interface VaultsListBySubscriptionNextOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listBySubscriptionNext operation. */ export type VaultsListBySubscriptionNextResponse = VaultListResult; @@ -1856,10 +2202,7 @@ export type VaultsListDeletedNextResponse = DeletedVaultListResult; /** Optional parameters. */ export interface VaultsListNextOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type VaultsListNextResponse = ResourceListResult; @@ -1995,22 +2338,26 @@ export interface ManagedHsmsPurgeDeletedOptionalParams resumeFrom?: string; } +/** Contains response data for the purgeDeleted operation. */ +export type ManagedHsmsPurgeDeletedResponse = ManagedHsmsPurgeDeletedHeaders; + +/** Optional parameters. */ +export interface ManagedHsmsCheckMhsmNameAvailabilityOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the checkMhsmNameAvailability operation. */ +export type ManagedHsmsCheckMhsmNameAvailabilityResponse = CheckMhsmNameAvailabilityResult; + /** Optional parameters. */ export interface ManagedHsmsListByResourceGroupNextOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listByResourceGroupNext operation. */ export type ManagedHsmsListByResourceGroupNextResponse = ManagedHsmListResult; /** Optional parameters. */ export interface ManagedHsmsListBySubscriptionNextOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listBySubscriptionNext operation. */ export type ManagedHsmsListBySubscriptionNextResponse = ManagedHsmListResult; @@ -2070,6 +2417,20 @@ export interface MhsmPrivateLinkResourcesListByMhsmResourceOptionalParams /** Contains response data for the listByMhsmResource operation. */ export type MhsmPrivateLinkResourcesListByMhsmResourceResponse = MhsmPrivateLinkResourceListResult; +/** Optional parameters. */ +export interface MhsmRegionsListByResourceOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResource operation. */ +export type MhsmRegionsListByResourceResponse = MhsmRegionsListResult; + +/** Optional parameters. */ +export interface MhsmRegionsListByResourceNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceNext operation. */ +export type MhsmRegionsListByResourceNextResponse = MhsmRegionsListResult; + /** Optional parameters. */ export interface OperationsListOptionalParams extends coreClient.OperationOptions {} @@ -2115,10 +2476,7 @@ export type SecretsListResponse = SecretListResult; /** Optional parameters. */ export interface SecretsListNextOptionalParams - extends coreClient.OperationOptions { - /** Maximum number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type SecretsListNextResponse = SecretListResult; diff --git a/sdk/keyvault/arm-keyvault/src/models/mappers.ts b/sdk/keyvault/arm-keyvault/src/models/mappers.ts index f3d6f9cd9ec4..aeba2010bca0 100644 --- a/sdk/keyvault/arm-keyvault/src/models/mappers.ts +++ b/sdk/keyvault/arm-keyvault/src/models/mappers.ts @@ -149,6 +149,7 @@ export const KeyAttributes: coreClient.CompositeMapper = { } }, exportable: { + defaultValue: false, serializedName: "exportable", type: { name: "Boolean" @@ -369,20 +370,373 @@ export const CloudErrorBody: coreClient.CompositeMapper = { name: "String" } }, - message: { - serializedName: "message", + message: { + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const KeyListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "KeyListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Key" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const ManagedHsmKeyCreateParameters: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmKeyCreateParameters", + modelProperties: { + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "ManagedHsmKeyProperties" + } + } + } + } +}; + +export const ManagedHsmKeyProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmKeyProperties", + modelProperties: { + attributes: { + serializedName: "attributes", + type: { + name: "Composite", + className: "ManagedHsmKeyAttributes" + } + }, + kty: { + serializedName: "kty", + type: { + name: "String" + } + }, + keyOps: { + serializedName: "keyOps", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + keySize: { + serializedName: "keySize", + type: { + name: "Number" + } + }, + curveName: { + serializedName: "curveName", + type: { + name: "String" + } + }, + keyUri: { + serializedName: "keyUri", + readOnly: true, + type: { + name: "String" + } + }, + keyUriWithVersion: { + serializedName: "keyUriWithVersion", + readOnly: true, + type: { + name: "String" + } + }, + rotationPolicy: { + serializedName: "rotationPolicy", + type: { + name: "Composite", + className: "ManagedHsmRotationPolicy" + } + }, + releasePolicy: { + serializedName: "release_policy", + type: { + name: "Composite", + className: "ManagedHsmKeyReleasePolicy" + } + } + } + } +}; + +export const ManagedHsmKeyAttributes: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmKeyAttributes", + modelProperties: { + enabled: { + serializedName: "enabled", + type: { + name: "Boolean" + } + }, + notBefore: { + serializedName: "nbf", + type: { + name: "Number" + } + }, + expires: { + serializedName: "exp", + type: { + name: "Number" + } + }, + created: { + serializedName: "created", + readOnly: true, + type: { + name: "Number" + } + }, + updated: { + serializedName: "updated", + readOnly: true, + type: { + name: "Number" + } + }, + recoveryLevel: { + serializedName: "recoveryLevel", + readOnly: true, + type: { + name: "String" + } + }, + exportable: { + serializedName: "exportable", + type: { + name: "Boolean" + } + } + } + } +}; + +export const ManagedHsmRotationPolicy: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmRotationPolicy", + modelProperties: { + attributes: { + serializedName: "attributes", + type: { + name: "Composite", + className: "ManagedHsmKeyRotationPolicyAttributes" + } + }, + lifetimeActions: { + serializedName: "lifetimeActions", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ManagedHsmLifetimeAction" + } + } + } + } + } + } +}; + +export const ManagedHsmKeyRotationPolicyAttributes: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmKeyRotationPolicyAttributes", + modelProperties: { + created: { + serializedName: "created", + readOnly: true, + type: { + name: "Number" + } + }, + updated: { + serializedName: "updated", + readOnly: true, + type: { + name: "Number" + } + }, + expiryTime: { + serializedName: "expiryTime", + type: { + name: "String" + } + } + } + } +}; + +export const ManagedHsmLifetimeAction: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmLifetimeAction", + modelProperties: { + trigger: { + serializedName: "trigger", + type: { + name: "Composite", + className: "ManagedHsmTrigger" + } + }, + action: { + serializedName: "action", + type: { + name: "Composite", + className: "ManagedHsmAction" + } + } + } + } +}; + +export const ManagedHsmTrigger: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmTrigger", + modelProperties: { + timeAfterCreate: { + serializedName: "timeAfterCreate", + type: { + name: "String" + } + }, + timeBeforeExpiry: { + serializedName: "timeBeforeExpiry", + type: { + name: "String" + } + } + } + } +}; + +export const ManagedHsmAction: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmAction", + modelProperties: { + type: { + serializedName: "type", + type: { + name: "Enum", + allowedValues: ["rotate", "notify"] + } + } + } + } +}; + +export const ManagedHsmKeyReleasePolicy: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmKeyReleasePolicy", + modelProperties: { + contentType: { + defaultValue: "application/json; charset=utf-8", + serializedName: "contentType", + type: { + name: "String" + } + }, + data: { + serializedName: "data", + type: { + name: "Base64Url" + } + } + } + } +}; + +export const ProxyResourceWithoutSystemData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ProxyResourceWithoutSystemData", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, type: { name: "String" } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } } } } }; -export const KeyListResult: coreClient.CompositeMapper = { +export const ManagedHsmKeyListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "KeyListResult", + className: "ManagedHsmKeyListResult", modelProperties: { value: { serializedName: "value", @@ -391,7 +745,7 @@ export const KeyListResult: coreClient.CompositeMapper = { element: { type: { name: "Composite", - className: "Key" + className: "ManagedHsmKey" } } } @@ -1487,6 +1841,18 @@ export const ManagedHsmProperties: coreClient.CompositeMapper = { className: "MhsmNetworkRuleSet" } }, + regions: { + serializedName: "regions", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MhsmGeoReplicatedRegion" + } + } + } + }, privateEndpointConnections: { serializedName: "privateEndpointConnections", readOnly: true, @@ -1512,6 +1878,13 @@ export const ManagedHsmProperties: coreClient.CompositeMapper = { type: { name: "DateTime" } + }, + securityDomainProperties: { + serializedName: "securityDomainProperties", + type: { + name: "Composite", + className: "ManagedHSMSecurityDomainProperties" + } } } } @@ -1594,6 +1967,34 @@ export const MhsmVirtualNetworkRule: coreClient.CompositeMapper = { } }; +export const MhsmGeoReplicatedRegion: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "MhsmGeoReplicatedRegion", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + isPrimary: { + serializedName: "isPrimary", + type: { + name: "Boolean" + } + } + } + } +}; + export const MhsmPrivateEndpointConnectionItem: coreClient.CompositeMapper = { type: { name: "Composite", @@ -1678,6 +2079,29 @@ export const MhsmPrivateLinkServiceConnectionState: coreClient.CompositeMapper = } }; +export const ManagedHSMSecurityDomainProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHSMSecurityDomainProperties", + modelProperties: { + activationStatus: { + serializedName: "activationStatus", + readOnly: true, + type: { + name: "String" + } + }, + activationStatusMessage: { + serializedName: "activationStatusMessage", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + export const ManagedHsmResource: coreClient.CompositeMapper = { type: { name: "Composite", @@ -1996,6 +2420,80 @@ export const MhsmPrivateLinkResourceListResult: coreClient.CompositeMapper = { } }; +export const MhsmRegionsListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "MhsmRegionsListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MhsmGeoReplicatedRegion" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const CheckMhsmNameAvailabilityParameters: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckMhsmNameAvailabilityParameters", + modelProperties: { + name: { + serializedName: "name", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const CheckMhsmNameAvailabilityResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckMhsmNameAvailabilityResult", + modelProperties: { + nameAvailable: { + serializedName: "nameAvailable", + readOnly: true, + type: { + name: "Boolean" + } + }, + reason: { + serializedName: "reason", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["AccountNameInvalid", "AlreadyExists"] + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + export const OperationListResult: coreClient.CompositeMapper = { type: { name: "Composite", @@ -2626,6 +3124,80 @@ export const Secret: coreClient.CompositeMapper = { } }; +export const ManagedHsmKey: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmKey", + modelProperties: { + ...ProxyResourceWithoutSystemData.type.modelProperties, + attributes: { + serializedName: "properties.attributes", + type: { + name: "Composite", + className: "ManagedHsmKeyAttributes" + } + }, + kty: { + serializedName: "properties.kty", + type: { + name: "String" + } + }, + keyOps: { + serializedName: "properties.keyOps", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + keySize: { + serializedName: "properties.keySize", + type: { + name: "Number" + } + }, + curveName: { + serializedName: "properties.curveName", + type: { + name: "String" + } + }, + keyUri: { + serializedName: "properties.keyUri", + readOnly: true, + type: { + name: "String" + } + }, + keyUriWithVersion: { + serializedName: "properties.keyUriWithVersion", + readOnly: true, + type: { + name: "String" + } + }, + rotationPolicy: { + serializedName: "properties.rotationPolicy", + type: { + name: "Composite", + className: "ManagedHsmRotationPolicy" + } + }, + releasePolicy: { + serializedName: "properties.release_policy", + type: { + name: "Composite", + className: "ManagedHsmKeyReleasePolicy" + } + } + } + } +}; + export const ManagedHsm: coreClient.CompositeMapper = { type: { name: "Composite", @@ -2771,6 +3343,21 @@ export const PrivateEndpointConnectionsDeleteHeaders: coreClient.CompositeMapper } }; +export const ManagedHsmsCreateOrUpdateHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmsCreateOrUpdateHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; + export const ManagedHsmsUpdateHeaders: coreClient.CompositeMapper = { type: { name: "Composite", @@ -2786,6 +3373,36 @@ export const ManagedHsmsUpdateHeaders: coreClient.CompositeMapper = { } }; +export const ManagedHsmsDeleteHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmsDeleteHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; + +export const ManagedHsmsPurgeDeletedHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedHsmsPurgeDeletedHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; + export const MhsmPrivateEndpointConnectionsPutHeaders: coreClient.CompositeMapper = { type: { name: "Composite", @@ -2812,12 +3429,6 @@ export const MhsmPrivateEndpointConnectionsDeleteHeaders: coreClient.CompositeMa name: "Composite", className: "MhsmPrivateEndpointConnectionsDeleteHeaders", modelProperties: { - retryAfter: { - serializedName: "retry-after", - type: { - name: "Number" - } - }, location: { serializedName: "location", type: { diff --git a/sdk/keyvault/arm-keyvault/src/models/parameters.ts b/sdk/keyvault/arm-keyvault/src/models/parameters.ts index 98abfbf521ff..36d4f476a4e6 100644 --- a/sdk/keyvault/arm-keyvault/src/models/parameters.ts +++ b/sdk/keyvault/arm-keyvault/src/models/parameters.ts @@ -13,12 +13,14 @@ import { } from "@azure/core-client"; import { KeyCreateParameters as KeyCreateParametersMapper, + ManagedHsmKeyCreateParameters as ManagedHsmKeyCreateParametersMapper, VaultCreateOrUpdateParameters as VaultCreateOrUpdateParametersMapper, VaultPatchParameters as VaultPatchParametersMapper, VaultAccessPolicyParameters as VaultAccessPolicyParametersMapper, VaultCheckNameAvailabilityParameters as VaultCheckNameAvailabilityParametersMapper, PrivateEndpointConnection as PrivateEndpointConnectionMapper, ManagedHsm as ManagedHsmMapper, + CheckMhsmNameAvailabilityParameters as CheckMhsmNameAvailabilityParametersMapper, MhsmPrivateEndpointConnection as MhsmPrivateEndpointConnectionMapper, SecretCreateOrUpdateParameters as SecretCreateOrUpdateParametersMapper, SecretPatchParameters as SecretPatchParametersMapper @@ -118,7 +120,7 @@ export const keyName: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-11-01-preview", + defaultValue: "2023-02-01", isConstant: true, serializedName: "api-version", type: { @@ -155,10 +157,46 @@ export const nextLink: OperationURLParameter = { export const parameters1: OperationParameter = { parameterPath: "parameters", - mapper: VaultCreateOrUpdateParametersMapper + mapper: ManagedHsmKeyCreateParametersMapper +}; + +export const resourceGroupName1: OperationURLParameter = { + parameterPath: "resourceGroupName", + mapper: { + constraints: { + MaxLength: 90, + MinLength: 1 + }, + serializedName: "resourceGroupName", + required: true, + type: { + name: "String" + } + } +}; + +export const name: OperationURLParameter = { + parameterPath: "name", + mapper: { + constraints: { + Pattern: new RegExp("^[A-Za-z]([A-Za-z0-9]|\\-[A-Za-z0-9])+$"), + MaxLength: 24, + MinLength: 3 + }, + serializedName: "name", + required: true, + type: { + name: "String" + } + } }; export const parameters2: OperationParameter = { + parameterPath: "parameters", + mapper: VaultCreateOrUpdateParametersMapper +}; + +export const parameters3: OperationParameter = { parameterPath: "parameters", mapper: VaultPatchParametersMapper }; @@ -174,7 +212,7 @@ export const vaultName1: OperationURLParameter = { } }; -export const parameters3: OperationParameter = { +export const parameters4: OperationParameter = { parameterPath: "parameters", mapper: VaultAccessPolicyParametersMapper }; @@ -257,12 +295,12 @@ export const properties: OperationParameter = { mapper: PrivateEndpointConnectionMapper }; -export const parameters4: OperationParameter = { +export const parameters5: OperationParameter = { parameterPath: "parameters", mapper: ManagedHsmMapper }; -export const name: OperationURLParameter = { +export const name1: OperationURLParameter = { parameterPath: "name", mapper: { serializedName: "name", @@ -273,12 +311,17 @@ export const name: OperationURLParameter = { } }; +export const mhsmName: OperationParameter = { + parameterPath: "mhsmName", + mapper: CheckMhsmNameAvailabilityParametersMapper +}; + export const properties1: OperationParameter = { parameterPath: "properties", mapper: MhsmPrivateEndpointConnectionMapper }; -export const parameters5: OperationParameter = { +export const parameters6: OperationParameter = { parameterPath: "parameters", mapper: SecretCreateOrUpdateParametersMapper }; @@ -297,7 +340,7 @@ export const secretName: OperationURLParameter = { } }; -export const parameters6: OperationParameter = { +export const parameters7: OperationParameter = { parameterPath: "parameters", mapper: SecretPatchParametersMapper }; diff --git a/sdk/keyvault/arm-keyvault/src/operations/index.ts b/sdk/keyvault/arm-keyvault/src/operations/index.ts index 7134a8453517..8d69150051f5 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/index.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/index.ts @@ -7,11 +7,13 @@ */ export * from "./keys"; +export * from "./managedHsmKeys"; export * from "./vaults"; export * from "./privateEndpointConnections"; export * from "./privateLinkResources"; export * from "./managedHsms"; export * from "./mhsmPrivateEndpointConnections"; export * from "./mhsmPrivateLinkResources"; +export * from "./mhsmRegions"; export * from "./operations"; export * from "./secrets"; diff --git a/sdk/keyvault/arm-keyvault/src/operations/keys.ts b/sdk/keyvault/arm-keyvault/src/operations/keys.ts index 48f203fa737e..e9be9f3f3079 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/keys.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/keys.ts @@ -220,7 +220,9 @@ export class KeysImpl implements Keys { * versions, and does not update existing keys. * @param resourceGroupName The name of the resource group which contains the specified key vault. * @param vaultName The name of the key vault which contains the key to be created. - * @param keyName The name of the key to be created. + * @param keyName 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. * @param parameters The parameters used to create the specified key. * @param options The options parameters. */ @@ -484,7 +486,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -506,7 +507,6 @@ const listVersionsNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/keyvault/arm-keyvault/src/operations/managedHsmKeys.ts b/sdk/keyvault/arm-keyvault/src/operations/managedHsmKeys.ts new file mode 100644 index 000000000000..516e575c33b6 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/src/operations/managedHsmKeys.ts @@ -0,0 +1,525 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { ManagedHsmKeys } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { KeyVaultManagementClient } from "../keyVaultManagementClient"; +import { + ManagedHsmKey, + ManagedHsmKeysListNextOptionalParams, + ManagedHsmKeysListOptionalParams, + ManagedHsmKeysListResponse, + ManagedHsmKeysListVersionsNextOptionalParams, + ManagedHsmKeysListVersionsOptionalParams, + ManagedHsmKeysListVersionsResponse, + ManagedHsmKeyCreateParameters, + ManagedHsmKeysCreateIfNotExistOptionalParams, + ManagedHsmKeysCreateIfNotExistResponse, + ManagedHsmKeysGetOptionalParams, + ManagedHsmKeysGetResponse, + ManagedHsmKeysGetVersionOptionalParams, + ManagedHsmKeysGetVersionResponse, + ManagedHsmKeysListNextResponse, + ManagedHsmKeysListVersionsNextResponse +} from "../models"; + +/// +/** Class containing ManagedHsmKeys operations. */ +export class ManagedHsmKeysImpl implements ManagedHsmKeys { + private readonly client: KeyVaultManagementClient; + + /** + * Initialize a new instance of the class ManagedHsmKeys class. + * @param client Reference to the service client + */ + constructor(client: KeyVaultManagementClient) { + this.client = client; + } + + /** + * Lists the keys in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param options The options parameters. + */ + public list( + resourceGroupName: string, + name: string, + options?: ManagedHsmKeysListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(resourceGroupName, name, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, name, options, settings); + } + }; + } + + private async *listPagingPage( + resourceGroupName: string, + name: string, + options?: ManagedHsmKeysListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: ManagedHsmKeysListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, name, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext( + resourceGroupName, + name, + continuationToken, + options + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + resourceGroupName: string, + name: string, + options?: ManagedHsmKeysListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage( + resourceGroupName, + name, + options + )) { + yield* page; + } + } + + /** + * Lists the versions of the specified key in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param options The options parameters. + */ + public listVersions( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysListVersionsOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listVersionsPagingAll( + resourceGroupName, + name, + keyName, + options + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listVersionsPagingPage( + resourceGroupName, + name, + keyName, + options, + settings + ); + } + }; + } + + private async *listVersionsPagingPage( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysListVersionsOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: ManagedHsmKeysListVersionsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listVersions( + resourceGroupName, + name, + keyName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listVersionsNext( + resourceGroupName, + name, + keyName, + continuationToken, + options + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listVersionsPagingAll( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysListVersionsOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listVersionsPagingPage( + resourceGroupName, + name, + keyName, + options + )) { + yield* page; + } + } + + /** + * 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. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param parameters The parameters used to create the specified key. + * @param options The options parameters. + */ + createIfNotExist( + resourceGroupName: string, + name: string, + keyName: string, + parameters: ManagedHsmKeyCreateParameters, + options?: ManagedHsmKeysCreateIfNotExistOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, keyName, parameters, options }, + createIfNotExistOperationSpec + ); + } + + /** + * Gets the current version of the specified key from the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, keyName, options }, + getOperationSpec + ); + } + + /** + * Lists the keys in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param options The options parameters. + */ + private _list( + resourceGroupName: string, + name: string, + options?: ManagedHsmKeysListOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, options }, + listOperationSpec + ); + } + + /** + * Gets the specified version of the specified key in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param keyVersion The version of the key to be retrieved. + * @param options The options parameters. + */ + getVersion( + resourceGroupName: string, + name: string, + keyName: string, + keyVersion: string, + options?: ManagedHsmKeysGetVersionOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, keyName, keyVersion, options }, + getVersionOperationSpec + ); + } + + /** + * Lists the versions of the specified key in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param options The options parameters. + */ + private _listVersions( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysListVersionsOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, keyName, options }, + listVersionsOperationSpec + ); + } + + /** + * ListNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + resourceGroupName: string, + name: string, + nextLink: string, + options?: ManagedHsmKeysListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, nextLink, options }, + listNextOperationSpec + ); + } + + /** + * ListVersionsNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param nextLink The nextLink from the previous successful call to the ListVersions method. + * @param options The options parameters. + */ + private _listVersionsNext( + resourceGroupName: string, + name: string, + keyName: string, + nextLink: string, + options?: ManagedHsmKeysListVersionsNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, keyName, nextLink, options }, + listVersionsNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const createIfNotExistOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKey + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + requestBody: Parameters.parameters1, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.keyName, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKey + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.keyName, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.accept], + serializer +}; +const listOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKeyListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.accept], + serializer +}; +const getVersionOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKey + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.keyName, + Parameters.keyVersion, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.accept], + serializer +}; +const listVersionsOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKeyListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.keyName, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKeyListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.nextLink, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.accept], + serializer +}; +const listVersionsNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ManagedHsmKeyListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.keyName, + Parameters.nextLink, + Parameters.resourceGroupName1, + Parameters.name + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/keyvault/arm-keyvault/src/operations/managedHsms.ts b/sdk/keyvault/arm-keyvault/src/operations/managedHsms.ts index 8c80bb16ca8c..bfdce13ca80f 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/managedHsms.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/managedHsms.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { KeyVaultManagementClient } from "../keyVaultManagementClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { ManagedHsm, ManagedHsmsListByResourceGroupNextOptionalParams, @@ -37,6 +41,10 @@ import { ManagedHsmsGetDeletedOptionalParams, ManagedHsmsGetDeletedResponse, ManagedHsmsPurgeDeletedOptionalParams, + ManagedHsmsPurgeDeletedResponse, + CheckMhsmNameAvailabilityParameters, + ManagedHsmsCheckMhsmNameAvailabilityOptionalParams, + ManagedHsmsCheckMhsmNameAvailabilityResponse, ManagedHsmsListByResourceGroupNextResponse, ManagedHsmsListBySubscriptionNextResponse, ManagedHsmsListDeletedNextResponse @@ -246,8 +254,8 @@ export class ManagedHsmsImpl implements ManagedHsms { parameters: ManagedHsm, options?: ManagedHsmsCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, ManagedHsmsCreateOrUpdateResponse > > { @@ -257,7 +265,7 @@ export class ManagedHsmsImpl implements ManagedHsms { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -290,13 +298,16 @@ export class ManagedHsmsImpl implements ManagedHsms { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, name, parameters, options }, - createOrUpdateOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, name, parameters, options }, + spec: createOrUpdateOperationSpec + }); + const poller = await createHttpPoller< + ManagedHsmsCreateOrUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -338,8 +349,8 @@ export class ManagedHsmsImpl implements ManagedHsms { parameters: ManagedHsm, options?: ManagedHsmsUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, ManagedHsmsUpdateResponse > > { @@ -349,7 +360,7 @@ export class ManagedHsmsImpl implements ManagedHsms { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -382,13 +393,16 @@ export class ManagedHsmsImpl implements ManagedHsms { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, name, parameters, options }, - updateOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, name, parameters, options }, + spec: updateOperationSpec + }); + const poller = await createHttpPoller< + ManagedHsmsUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -427,14 +441,14 @@ export class ManagedHsmsImpl implements ManagedHsms { resourceGroupName: string, name: string, options?: ManagedHsmsDeleteOptionalParams - ): Promise, void>> { + ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -467,13 +481,13 @@ export class ManagedHsmsImpl implements ManagedHsms { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, name, options }, - deleteOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, name, options }, + spec: deleteOperationSpec + }); + const poller = await createHttpPoller>(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -581,14 +595,19 @@ export class ManagedHsmsImpl implements ManagedHsms { name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams - ): Promise, void>> { + ): Promise< + SimplePollerLike< + OperationState, + ManagedHsmsPurgeDeletedResponse + > + > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec - ): Promise => { + ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -621,13 +640,16 @@ export class ManagedHsmsImpl implements ManagedHsms { }; }; - const lro = new LroImpl( - sendOperation, - { name, location, options }, - purgeDeletedOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { name, location, options }, + spec: purgeDeletedOperationSpec + }); + const poller = await createHttpPoller< + ManagedHsmsPurgeDeletedResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -644,11 +666,26 @@ export class ManagedHsmsImpl implements ManagedHsms { name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams - ): Promise { + ): Promise { const poller = await this.beginPurgeDeleted(name, location, options); return poller.pollUntilDone(); } + /** + * Checks that the managed hsm name is valid and is not already in use. + * @param mhsmName The name of the managed hsm. + * @param options The options parameters. + */ + checkMhsmNameAvailability( + mhsmName: CheckMhsmNameAvailabilityParameters, + options?: ManagedHsmsCheckMhsmNameAvailabilityOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { mhsmName, options }, + checkMhsmNameAvailabilityOperationSpec + ); + } + /** * ListByResourceGroupNext * @param resourceGroupName Name of the resource group that contains the managed HSM pool. @@ -720,13 +757,13 @@ const createOrUpdateOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ManagedHsmError } }, - requestBody: Parameters.parameters4, + requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", @@ -753,13 +790,13 @@ const updateOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ManagedHsmError } }, - requestBody: Parameters.parameters4, + requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", @@ -783,7 +820,7 @@ const deleteOperationSpec: coreClient.OperationSpec = { Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer @@ -796,7 +833,6 @@ const getOperationSpec: coreClient.OperationSpec = { 200: { bodyMapper: Mappers.ManagedHsm }, - 202: {}, 204: {}, default: { bodyMapper: Mappers.ManagedHsmError @@ -807,7 +843,7 @@ const getOperationSpec: coreClient.OperationSpec = { Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer @@ -884,7 +920,7 @@ const getDeletedOperationSpec: coreClient.OperationSpec = { Parameters.$host, Parameters.subscriptionId, Parameters.location, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer @@ -894,10 +930,18 @@ const purgeDeletedOperationSpec: coreClient.OperationSpec = { "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name}/purge", httpMethod: "POST", responses: { - 200: {}, - 201: {}, - 202: {}, - 204: {}, + 200: { + headersMapper: Mappers.ManagedHsmsPurgeDeletedHeaders + }, + 201: { + headersMapper: Mappers.ManagedHsmsPurgeDeletedHeaders + }, + 202: { + headersMapper: Mappers.ManagedHsmsPurgeDeletedHeaders + }, + 204: { + headersMapper: Mappers.ManagedHsmsPurgeDeletedHeaders + }, default: { bodyMapper: Mappers.ManagedHsmError } @@ -907,11 +951,30 @@ const purgeDeletedOperationSpec: coreClient.OperationSpec = { Parameters.$host, Parameters.subscriptionId, Parameters.location, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer }; +const checkMhsmNameAvailabilityOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkMhsmNameAvailability", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.CheckMhsmNameAvailabilityResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + requestBody: Parameters.mhsmName, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", @@ -923,7 +986,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ManagedHsmError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -944,7 +1006,6 @@ const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ManagedHsmError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -964,7 +1025,6 @@ const listDeletedNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ManagedHsmError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateEndpointConnections.ts b/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateEndpointConnections.ts index 7310a38ac41a..2c0fcdeba965 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateEndpointConnections.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateEndpointConnections.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { KeyVaultManagementClient } from "../keyVaultManagementClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { MhsmPrivateEndpointConnection, MhsmPrivateEndpointConnectionsListByResourceNextOptionalParams, @@ -200,8 +204,8 @@ export class MhsmPrivateEndpointConnectionsImpl privateEndpointConnectionName: string, options?: MhsmPrivateEndpointConnectionsDeleteOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, MhsmPrivateEndpointConnectionsDeleteResponse > > { @@ -211,7 +215,7 @@ export class MhsmPrivateEndpointConnectionsImpl ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -244,13 +248,16 @@ export class MhsmPrivateEndpointConnectionsImpl }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, name, privateEndpointConnectionName, options }, - deleteOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, name, privateEndpointConnectionName, options }, + spec: deleteOperationSpec + }); + const poller = await createHttpPoller< + MhsmPrivateEndpointConnectionsDeleteResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -319,7 +326,7 @@ const listByResourceOperationSpec: coreClient.OperationSpec = { Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer @@ -342,7 +349,7 @@ const getOperationSpec: coreClient.OperationSpec = { Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.privateEndpointConnectionName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer @@ -367,7 +374,7 @@ const putOperationSpec: coreClient.OperationSpec = { Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.privateEndpointConnectionName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", @@ -400,7 +407,7 @@ const deleteOperationSpec: coreClient.OperationSpec = { Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.privateEndpointConnectionName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer @@ -416,13 +423,12 @@ const listByResourceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ManagedHsmError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer diff --git a/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateLinkResources.ts b/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateLinkResources.ts index 4badfbc5ff96..46a89fe310d0 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateLinkResources.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/mhsmPrivateLinkResources.ts @@ -65,7 +65,7 @@ const listByMhsmResourceOperationSpec: coreClient.OperationSpec = { Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, - Parameters.name + Parameters.name1 ], headerParameters: [Parameters.accept], serializer diff --git a/sdk/keyvault/arm-keyvault/src/operations/mhsmRegions.ts b/sdk/keyvault/arm-keyvault/src/operations/mhsmRegions.ts new file mode 100644 index 000000000000..926c3e25dad6 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/src/operations/mhsmRegions.ts @@ -0,0 +1,194 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { MhsmRegions } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { KeyVaultManagementClient } from "../keyVaultManagementClient"; +import { + MhsmGeoReplicatedRegion, + MhsmRegionsListByResourceNextOptionalParams, + MhsmRegionsListByResourceOptionalParams, + MhsmRegionsListByResourceResponse, + MhsmRegionsListByResourceNextResponse +} from "../models"; + +/// +/** Class containing MhsmRegions operations. */ +export class MhsmRegionsImpl implements MhsmRegions { + private readonly client: KeyVaultManagementClient; + + /** + * Initialize a new instance of the class MhsmRegions class. + * @param client Reference to the service client + */ + constructor(client: KeyVaultManagementClient) { + this.client = client; + } + + /** + * The List operation gets information about the regions associated with the managed HSM Pool. + * @param resourceGroupName Name of the resource group that contains the managed HSM pool. + * @param name Name of the managed HSM Pool + * @param options The options parameters. + */ + public listByResource( + resourceGroupName: string, + name: string, + options?: MhsmRegionsListByResourceOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listByResourcePagingAll(resourceGroupName, name, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourcePagingPage( + resourceGroupName, + name, + options, + settings + ); + } + }; + } + + private async *listByResourcePagingPage( + resourceGroupName: string, + name: string, + options?: MhsmRegionsListByResourceOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: MhsmRegionsListByResourceResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResource(resourceGroupName, name, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listByResourceNext( + resourceGroupName, + name, + continuationToken, + options + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listByResourcePagingAll( + resourceGroupName: string, + name: string, + options?: MhsmRegionsListByResourceOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listByResourcePagingPage( + resourceGroupName, + name, + options + )) { + yield* page; + } + } + + /** + * The List operation gets information about the regions associated with the managed HSM Pool. + * @param resourceGroupName Name of the resource group that contains the managed HSM pool. + * @param name Name of the managed HSM Pool + * @param options The options parameters. + */ + private _listByResource( + resourceGroupName: string, + name: string, + options?: MhsmRegionsListByResourceOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, options }, + listByResourceOperationSpec + ); + } + + /** + * ListByResourceNext + * @param resourceGroupName Name of the resource group that contains the managed HSM pool. + * @param name Name of the managed HSM Pool + * @param nextLink The nextLink from the previous successful call to the ListByResource method. + * @param options The options parameters. + */ + private _listByResourceNext( + resourceGroupName: string, + name: string, + nextLink: string, + options?: MhsmRegionsListByResourceNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, name, nextLink, options }, + listByResourceNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listByResourceOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/regions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.MhsmRegionsListResult + }, + default: { + bodyMapper: Mappers.ManagedHsmError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.name1 + ], + headerParameters: [Parameters.accept], + serializer +}; +const listByResourceNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.MhsmRegionsListResult + }, + default: { + bodyMapper: Mappers.ManagedHsmError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.nextLink, + Parameters.name1 + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/keyvault/arm-keyvault/src/operations/operations.ts b/sdk/keyvault/arm-keyvault/src/operations/operations.ts index 6ce75a037500..653bd71bbc8a 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/operations.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/operations.ts @@ -143,7 +143,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/keyvault/arm-keyvault/src/operations/privateEndpointConnections.ts b/sdk/keyvault/arm-keyvault/src/operations/privateEndpointConnections.ts index a9eb66c18fb8..3528a4ff140f 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/privateEndpointConnections.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/privateEndpointConnections.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { KeyVaultManagementClient } from "../keyVaultManagementClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { PrivateEndpointConnection, PrivateEndpointConnectionsListByResourceNextOptionalParams, @@ -190,8 +194,8 @@ export class PrivateEndpointConnectionsImpl privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsDeleteOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, PrivateEndpointConnectionsDeleteResponse > > { @@ -201,7 +205,7 @@ export class PrivateEndpointConnectionsImpl ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -234,13 +238,21 @@ export class PrivateEndpointConnectionsImpl }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, vaultName, privateEndpointConnectionName, options }, - deleteOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { + resourceGroupName, + vaultName, + privateEndpointConnectionName, + options + }, + spec: deleteOperationSpec + }); + const poller = await createHttpPoller< + PrivateEndpointConnectionsDeleteResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -425,7 +437,6 @@ const listByResourceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/keyvault/arm-keyvault/src/operations/secrets.ts b/sdk/keyvault/arm-keyvault/src/operations/secrets.ts index 86c6f42069e1..bea3e5ed65f9 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/secrets.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/secrets.ts @@ -126,7 +126,9 @@ export class SecretsImpl implements Secrets { * with vault secrets. * @param resourceGroupName The name of the Resource Group to which the vault belongs. * @param vaultName Name of the vault - * @param secretName Name of the secret + * @param secretName Name of the secret. 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. * @param parameters Parameters to create or update the secret * @param options The options parameters. */ @@ -241,7 +243,7 @@ const createOrUpdateOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - requestBody: Parameters.parameters5, + requestBody: Parameters.parameters6, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -269,7 +271,7 @@ const updateOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - requestBody: Parameters.parameters6, + requestBody: Parameters.parameters7, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -338,7 +340,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/keyvault/arm-keyvault/src/operations/vaults.ts b/sdk/keyvault/arm-keyvault/src/operations/vaults.ts index cb65a145795e..3727f37224a4 100644 --- a/sdk/keyvault/arm-keyvault/src/operations/vaults.ts +++ b/sdk/keyvault/arm-keyvault/src/operations/vaults.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { KeyVaultManagementClient } from "../keyVaultManagementClient"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { Vault, VaultsListByResourceGroupNextOptionalParams, @@ -314,8 +318,8 @@ export class VaultsImpl implements Vaults { parameters: VaultCreateOrUpdateParameters, options?: VaultsCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, VaultsCreateOrUpdateResponse > > { @@ -325,7 +329,7 @@ export class VaultsImpl implements Vaults { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -358,13 +362,16 @@ export class VaultsImpl implements Vaults { }; }; - const lro = new LroImpl( - sendOperation, - { resourceGroupName, vaultName, parameters, options }, - createOrUpdateOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, vaultName, parameters, options }, + spec: createOrUpdateOperationSpec + }); + const poller = await createHttpPoller< + VaultsCreateOrUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -536,14 +543,14 @@ export class VaultsImpl implements Vaults { vaultName: string, location: string, options?: VaultsPurgeDeletedOptionalParams - ): Promise, void>> { + ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -576,13 +583,13 @@ export class VaultsImpl implements Vaults { }; }; - const lro = new LroImpl( - sendOperation, - { vaultName, location, options }, - purgeDeletedOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { vaultName, location, options }, + spec: purgeDeletedOperationSpec + }); + const poller = await createHttpPoller>(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); @@ -715,7 +722,7 @@ const createOrUpdateOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - requestBody: Parameters.parameters1, + requestBody: Parameters.parameters2, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -742,7 +749,7 @@ const updateOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - requestBody: Parameters.parameters2, + requestBody: Parameters.parameters3, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -812,7 +819,7 @@ const updateAccessPolicyOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - requestBody: Parameters.parameters3, + requestBody: Parameters.parameters4, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -970,7 +977,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -991,7 +997,6 @@ const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -1011,7 +1016,6 @@ const listDeletedNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -1031,7 +1035,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.top, Parameters.filter, Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/index.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/index.ts index 7134a8453517..8d69150051f5 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/index.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/index.ts @@ -7,11 +7,13 @@ */ export * from "./keys"; +export * from "./managedHsmKeys"; export * from "./vaults"; export * from "./privateEndpointConnections"; export * from "./privateLinkResources"; export * from "./managedHsms"; export * from "./mhsmPrivateEndpointConnections"; export * from "./mhsmPrivateLinkResources"; +export * from "./mhsmRegions"; export * from "./operations"; export * from "./secrets"; diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/keys.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/keys.ts index 13d909c3b9bb..9a0328500286 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/keys.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/keys.ts @@ -53,7 +53,9 @@ export interface Keys { * versions, and does not update existing keys. * @param resourceGroupName The name of the resource group which contains the specified key vault. * @param vaultName The name of the key vault which contains the key to be created. - * @param keyName The name of the key to be created. + * @param keyName 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. * @param parameters The parameters used to create the specified key. * @param options The options parameters. */ diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsmKeys.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsmKeys.ts new file mode 100644 index 000000000000..5f902d313524 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsmKeys.ts @@ -0,0 +1,103 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + ManagedHsmKey, + ManagedHsmKeysListOptionalParams, + ManagedHsmKeysListVersionsOptionalParams, + ManagedHsmKeyCreateParameters, + ManagedHsmKeysCreateIfNotExistOptionalParams, + ManagedHsmKeysCreateIfNotExistResponse, + ManagedHsmKeysGetOptionalParams, + ManagedHsmKeysGetResponse, + ManagedHsmKeysGetVersionOptionalParams, + ManagedHsmKeysGetVersionResponse +} from "../models"; + +/// +/** Interface representing a ManagedHsmKeys. */ +export interface ManagedHsmKeys { + /** + * Lists the keys in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param options The options parameters. + */ + list( + resourceGroupName: string, + name: string, + options?: ManagedHsmKeysListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Lists the versions of the specified key in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param options The options parameters. + */ + listVersions( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysListVersionsOptionalParams + ): PagedAsyncIterableIterator; + /** + * 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. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param parameters The parameters used to create the specified key. + * @param options The options parameters. + */ + createIfNotExist( + resourceGroupName: string, + name: string, + keyName: string, + parameters: ManagedHsmKeyCreateParameters, + options?: ManagedHsmKeysCreateIfNotExistOptionalParams + ): Promise; + /** + * Gets the current version of the specified key from the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + name: string, + keyName: string, + options?: ManagedHsmKeysGetOptionalParams + ): Promise; + /** + * Gets the specified version of the specified key in the specified managed HSM. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Managed HSM Pool within the specified resource group. + * @param keyName 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. + * @param keyVersion The version of the key to be retrieved. + * @param options The options parameters. + */ + getVersion( + resourceGroupName: string, + name: string, + keyName: string, + keyVersion: string, + options?: ManagedHsmKeysGetVersionOptionalParams + ): Promise; +} diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsms.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsms.ts index 2d82c3e245a6..f4e93042fd6e 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsms.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/managedHsms.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { ManagedHsm, ManagedHsmsListByResourceGroupOptionalParams, @@ -23,7 +23,11 @@ import { ManagedHsmsGetResponse, ManagedHsmsGetDeletedOptionalParams, ManagedHsmsGetDeletedResponse, - ManagedHsmsPurgeDeletedOptionalParams + ManagedHsmsPurgeDeletedOptionalParams, + ManagedHsmsPurgeDeletedResponse, + CheckMhsmNameAvailabilityParameters, + ManagedHsmsCheckMhsmNameAvailabilityOptionalParams, + ManagedHsmsCheckMhsmNameAvailabilityResponse } from "../models"; /// @@ -66,8 +70,8 @@ export interface ManagedHsms { parameters: ManagedHsm, options?: ManagedHsmsCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, ManagedHsmsCreateOrUpdateResponse > >; @@ -97,8 +101,8 @@ export interface ManagedHsms { parameters: ManagedHsm, options?: ManagedHsmsUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, ManagedHsmsUpdateResponse > >; @@ -125,7 +129,7 @@ export interface ManagedHsms { resourceGroupName: string, name: string, options?: ManagedHsmsDeleteOptionalParams - ): Promise, void>>; + ): Promise, void>>; /** * Deletes the specified managed HSM Pool. * @param resourceGroupName Name of the resource group that contains the managed HSM pool. @@ -169,7 +173,12 @@ export interface ManagedHsms { name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams - ): Promise, void>>; + ): Promise< + SimplePollerLike< + OperationState, + ManagedHsmsPurgeDeletedResponse + > + >; /** * Permanently deletes the specified managed HSM. * @param name The name of the soft-deleted managed HSM. @@ -180,5 +189,14 @@ export interface ManagedHsms { name: string, location: string, options?: ManagedHsmsPurgeDeletedOptionalParams - ): Promise; + ): Promise; + /** + * Checks that the managed hsm name is valid and is not already in use. + * @param mhsmName The name of the managed hsm. + * @param options The options parameters. + */ + checkMhsmNameAvailability( + mhsmName: CheckMhsmNameAvailabilityParameters, + options?: ManagedHsmsCheckMhsmNameAvailabilityOptionalParams + ): Promise; } diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmPrivateEndpointConnections.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmPrivateEndpointConnections.ts index 175bb98e7ff7..7cc4f81d0c1c 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmPrivateEndpointConnections.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmPrivateEndpointConnections.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { MhsmPrivateEndpointConnection, MhsmPrivateEndpointConnectionsListByResourceOptionalParams, @@ -78,8 +78,8 @@ export interface MhsmPrivateEndpointConnections { privateEndpointConnectionName: string, options?: MhsmPrivateEndpointConnectionsDeleteOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, MhsmPrivateEndpointConnectionsDeleteResponse > >; diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmRegions.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmRegions.ts new file mode 100644 index 000000000000..ba14b4405150 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/mhsmRegions.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + MhsmGeoReplicatedRegion, + MhsmRegionsListByResourceOptionalParams +} from "../models"; + +/// +/** Interface representing a MhsmRegions. */ +export interface MhsmRegions { + /** + * The List operation gets information about the regions associated with the managed HSM Pool. + * @param resourceGroupName Name of the resource group that contains the managed HSM pool. + * @param name Name of the managed HSM Pool + * @param options The options parameters. + */ + listByResource( + resourceGroupName: string, + name: string, + options?: MhsmRegionsListByResourceOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/privateEndpointConnections.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/privateEndpointConnections.ts index 7da1bbd06592..ac88c9201e24 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/privateEndpointConnections.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/privateEndpointConnections.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { PrivateEndpointConnection, PrivateEndpointConnectionsListByResourceOptionalParams, @@ -78,8 +78,8 @@ export interface PrivateEndpointConnections { privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsDeleteOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, PrivateEndpointConnectionsDeleteResponse > >; diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/secrets.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/secrets.ts index 7aa4e6e13104..379b92f98dc2 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/secrets.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/secrets.ts @@ -42,7 +42,9 @@ export interface Secrets { * with vault secrets. * @param resourceGroupName The name of the Resource Group to which the vault belongs. * @param vaultName Name of the vault - * @param secretName Name of the secret + * @param secretName Name of the secret. 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. * @param parameters Parameters to create or update the secret * @param options The options parameters. */ diff --git a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/vaults.ts b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/vaults.ts index b693f7e61645..c6943bdbc9d3 100644 --- a/sdk/keyvault/arm-keyvault/src/operationsInterfaces/vaults.ts +++ b/sdk/keyvault/arm-keyvault/src/operationsInterfaces/vaults.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { Vault, VaultsListByResourceGroupOptionalParams, @@ -84,8 +84,8 @@ export interface Vaults { parameters: VaultCreateOrUpdateParameters, options?: VaultsCreateOrUpdateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, VaultsCreateOrUpdateResponse > >; @@ -173,7 +173,7 @@ export interface Vaults { vaultName: string, location: string, options?: VaultsPurgeDeletedOptionalParams - ): Promise, void>>; + ): Promise, void>>; /** * Permanently deletes the specified vault. aka Purges the deleted Azure key vault. * @param vaultName The name of the soft-deleted vault. diff --git a/sdk/keyvault/arm-keyvault/src/pagingHelper.ts b/sdk/keyvault/arm-keyvault/src/pagingHelper.ts index d85fc13bce1e..269a2b9814b5 100644 --- a/sdk/keyvault/arm-keyvault/src/pagingHelper.ts +++ b/sdk/keyvault/arm-keyvault/src/pagingHelper.ts @@ -13,11 +13,11 @@ export interface PageInfo { const pageMap = new WeakMap(); /** - * Given a result page from a pageable operation, returns a - * continuation token that can be used to begin paging from + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from * that point later. - * @param page A result object from calling .byPage() on a paged operation. - * @returns The continuation token that can be passed into byPage(). + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. */ export function getContinuationToken(page: unknown): string | undefined { if (typeof page !== "object" || page === null) { diff --git a/sdk/keyvault/arm-keyvault/test/keyvault_examples.ts b/sdk/keyvault/arm-keyvault/test/keyvault_examples.ts index 39f996079dd5..d042206a9d9a 100644 --- a/sdk/keyvault/arm-keyvault/test/keyvault_examples.ts +++ b/sdk/keyvault/arm-keyvault/test/keyvault_examples.ts @@ -51,7 +51,7 @@ describe("Keyvault test", () => { const credential = createTestCredential(); client = new KeyVaultManagementClient(credential, subscriptionId, recorder.configureClientOptions({})); location = "eastus"; - resourceGroup = "myjstest"; + resourceGroup = "czwjstest"; vaultName = "myvaultzzzz"; }); From 134c7a68a2772288802cc85c31a9586cb0921eb2 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Fri, 21 Apr 2023 17:41:15 +0800 Subject: [PATCH 2/2] update files --- sdk/keyvault/arm-keyvault/assets.json | 6 + .../recording_vaults_create_test.json | 186 ------------------ .../recording_vaults_delete_test.json | 70 ------- .../recording_vaults_get_test.json | 120 ----------- .../recording_vaults_list_test.json | 162 --------------- .../recording_vaults_update_test.json | 185 ----------------- 6 files changed, 6 insertions(+), 723 deletions(-) create mode 100644 sdk/keyvault/arm-keyvault/assets.json delete mode 100644 sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json delete mode 100644 sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json delete mode 100644 sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json delete mode 100644 sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json delete mode 100644 sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json diff --git a/sdk/keyvault/arm-keyvault/assets.json b/sdk/keyvault/arm-keyvault/assets.json new file mode 100644 index 000000000000..8e39b65bab70 --- /dev/null +++ b/sdk/keyvault/arm-keyvault/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "js", + "TagPrefix": "js/keyvault/arm-keyvault", + "Tag": "js/keyvault/arm-keyvault_dda6cf5e5e" +} diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json deleted file mode 100644 index 6386af75ef02..000000000000 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_create_test.json +++ /dev/null @@ -1,186 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", - "RequestMethod": "PUT", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "Content-Length": "761", - "Content-Type": "application/json", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "7dc97de3-ee29-4e47-8061-ff062e34331f" - }, - "RequestBody": { - "location": "eastus", - "properties": { - "tenantId": "88888888-8888-8888-8888-888888888888", - "sku": { - "family": "A", - "name": "standard" - }, - "accessPolicies": [ - { - "tenantId": "88888888-8888-8888-8888-888888888888", - "objectId": "00000000-0000-0000-0000-000000000000", - "permissions": { - "keys": [ - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "sign", - "verify", - "get", - "list", - "create", - "update", - "import", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "secrets": [ - "get", - "list", - "set", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "certificates": [ - "get", - "list", - "delete", - "create", - "import", - "update", - "managecontacts", - "getissuers", - "listissuers", - "setissuers", - "deleteissuers", - "manageissuers", - "recover", - "purge" - ] - } - } - ], - "enabledForDeployment": true, - "enabledForDiskEncryption": true, - "enabledForTemplateDeployment": true - } - }, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 10 Apr 2023 09:25:52 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked", - "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "7dc97de3-ee29-4e47-8061-ff062e34331f", - "x-ms-correlation-request-id": "2ca7a39e-1883-40b7-b56c-d7205b4e1e1b", - "x-ms-keyvault-service-version": "1.5.692.1", - "x-ms-ratelimit-remaining-subscription-writes": "1199", - "x-ms-request-id": "3bff7e0f-4d17-4f66-9ee1-315c2e716b9a", - "x-ms-routing-request-id": "JAPANEAST:20230410T092553Z:2ca7a39e-1883-40b7-b56c-d7205b4e1e1b" - }, - "ResponseBody": { - "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", - "name": "myvaultzzzz", - "type": "Microsoft.KeyVault/vaults", - "location": "eastus", - "tags": {}, - "systemData": { - "createdBy": "azure_client_id", - "createdByType": "Application", - "createdAt": "2023-04-10T09:15:41.477Z", - "lastModifiedBy": "azure_client_id", - "lastModifiedByType": "Application", - "lastModifiedAt": "2023-04-10T09:25:51.652Z" - }, - "properties": { - "sku": { - "family": "A", - "name": "standard" - }, - "tenantId": "88888888-8888-8888-8888-888888888888", - "accessPolicies": [ - { - "tenantId": "88888888-8888-8888-8888-888888888888", - "objectId": "00000000-0000-0000-0000-000000000000", - "permissions": { - "keys": [ - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "sign", - "verify", - "get", - "list", - "create", - "update", - "import", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "secrets": [ - "get", - "list", - "set", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "certificates": [ - "get", - "list", - "delete", - "create", - "import", - "update", - "managecontacts", - "getissuers", - "listissuers", - "setissuers", - "deleteissuers", - "manageissuers", - "recover", - "purge" - ] - } - } - ], - "enabledForDeployment": true, - "enabledForDiskEncryption": true, - "enabledForTemplateDeployment": true, - "enableSoftDelete": true, - "vaultUri": "https://myvaultzzzz.vault.azure.net/", - "provisioningState": "Succeeded", - "publicNetworkAccess": "Enabled" - } - } - } - ], - "Variables": {} -} diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json deleted file mode 100644 index de9305614140..000000000000 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_delete_test.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "df941ad5-0213-45c8-8f67-75de3e69f36a" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Mon, 10 Apr 2023 09:26:03 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "df941ad5-0213-45c8-8f67-75de3e69f36a", - "x-ms-correlation-request-id": "d4540343-ed21-44c9-bf08-38c37a7ca949", - "x-ms-keyvault-service-version": "1.5.692.1", - "x-ms-ratelimit-remaining-subscription-deletes": "14999", - "x-ms-request-id": "3445da3e-9704-4e6b-b00b-45109d530dda", - "x-ms-routing-request-id": "JAPANEAST:20230410T092603Z:d4540343-ed21-44c9-bf08-38c37a7ca949" - }, - "ResponseBody": null - }, - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "ebd08a48-4766-496d-af7f-83f20e01eb98" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Length": "12", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 10 Apr 2023 09:26:03 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Vary": "Accept-Encoding", - "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "efab7c5a-e432-46e8-b121-5018bcdd4b58", - "x-ms-ratelimit-remaining-subscription-reads": "11996", - "x-ms-request-id": "efab7c5a-e432-46e8-b121-5018bcdd4b58", - "x-ms-routing-request-id": "JAPANEAST:20230410T092603Z:efab7c5a-e432-46e8-b121-5018bcdd4b58" - }, - "ResponseBody": { - "value": [] - } - } - ], - "Variables": {} -} diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json deleted file mode 100644 index 8745d6fc37d3..000000000000 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_get_test.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "3560a25a-7afb-4be6-a5d1-64cfd3c760ea" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 10 Apr 2023 09:25:53 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked", - "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "3560a25a-7afb-4be6-a5d1-64cfd3c760ea", - "x-ms-correlation-request-id": "aa464d69-6016-4a20-bba0-9c08efe06804", - "x-ms-keyvault-service-version": "1.5.692.1", - "x-ms-ratelimit-remaining-subscription-reads": "11999", - "x-ms-request-id": "b4dfe27c-1225-4a85-bc8f-833f19e664df", - "x-ms-routing-request-id": "JAPANEAST:20230410T092554Z:aa464d69-6016-4a20-bba0-9c08efe06804" - }, - "ResponseBody": { - "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", - "name": "myvaultzzzz", - "type": "Microsoft.KeyVault/vaults", - "location": "eastus", - "tags": {}, - "systemData": { - "createdBy": "azure_client_id", - "createdByType": "Application", - "createdAt": "2023-04-10T09:15:41.477Z", - "lastModifiedBy": "azure_client_id", - "lastModifiedByType": "Application", - "lastModifiedAt": "2023-04-10T09:25:51.652Z" - }, - "properties": { - "sku": { - "family": "A", - "name": "standard" - }, - "tenantId": "88888888-8888-8888-8888-888888888888", - "accessPolicies": [ - { - "tenantId": "88888888-8888-8888-8888-888888888888", - "objectId": "00000000-0000-0000-0000-000000000000", - "permissions": { - "keys": [ - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "sign", - "verify", - "get", - "list", - "create", - "update", - "import", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "secrets": [ - "get", - "list", - "set", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "certificates": [ - "get", - "list", - "delete", - "create", - "import", - "update", - "managecontacts", - "getissuers", - "listissuers", - "setissuers", - "deleteissuers", - "manageissuers", - "recover", - "purge" - ] - } - } - ], - "enabledForDeployment": true, - "enabledForDiskEncryption": true, - "enabledForTemplateDeployment": true, - "enableSoftDelete": true, - "vaultUri": "https://myvaultzzzz.vault.azure.net/", - "provisioningState": "Succeeded", - "publicNetworkAccess": "Enabled" - } - } - } - ], - "Variables": {} -} diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json deleted file mode 100644 index 7cda3e03db38..000000000000 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_list_test.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "ac7fe413-dd72-4224-bb7a-0154907acd97" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 10 Apr 2023 09:25:54 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked", - "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "ac7fe413-dd72-4224-bb7a-0154907acd97", - "x-ms-correlation-request-id": "6bbbc8ef-548b-46d2-b57c-e9db387166c5", - "x-ms-keyvault-service-version": "1.5.692.1", - "x-ms-ratelimit-remaining-subscription-reads": "11998", - "x-ms-request-id": "7c7d8a98-73be-4aa0-a97a-4adfc85f2b28", - "x-ms-routing-request-id": "JAPANEAST:20230410T092555Z:6bbbc8ef-548b-46d2-b57c-e9db387166c5" - }, - "ResponseBody": { - "value": [ - { - "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", - "name": "myvaultzzzz", - "type": "Microsoft.KeyVault/vaults", - "location": "eastus", - "tags": {}, - "systemData": { - "createdBy": "azure_client_id", - "createdByType": "Application", - "createdAt": "2023-04-10T09:15:41.477Z", - "lastModifiedBy": "azure_client_id", - "lastModifiedByType": "Application", - "lastModifiedAt": "2023-04-10T09:25:51.652Z" - }, - "properties": { - "sku": { - "family": "A", - "name": "standard" - }, - "tenantId": "88888888-8888-8888-8888-888888888888", - "accessPolicies": [ - { - "tenantId": "88888888-8888-8888-8888-888888888888", - "objectId": "00000000-0000-0000-0000-000000000000", - "permissions": { - "keys": [ - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "sign", - "verify", - "get", - "list", - "create", - "update", - "import", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "secrets": [ - "get", - "list", - "set", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "certificates": [ - "get", - "list", - "delete", - "create", - "import", - "update", - "managecontacts", - "getissuers", - "listissuers", - "setissuers", - "deleteissuers", - "manageissuers", - "recover", - "purge" - ] - } - } - ], - "enabledForDeployment": true, - "enabledForDiskEncryption": true, - "enabledForTemplateDeployment": true, - "enableSoftDelete": true, - "vaultUri": "https://myvaultzzzz.vault.azure.net/", - "provisioningState": "Succeeded", - "publicNetworkAccess": "Enabled" - } - } - ], - "nextLink": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01\u0026$skiptoken=bXl2YXVsdHp6eno=" - } - }, - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults?api-version=2023-02-01\u0026$skiptoken=bXl2YXVsdHp6eno=", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "babc6c5b-8049-448f-ba59-87b9b7fb29ff" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 10 Apr 2023 09:25:55 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked", - "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "babc6c5b-8049-448f-ba59-87b9b7fb29ff", - "x-ms-correlation-request-id": "9f2174ce-d317-4d80-9d37-0119663796f9", - "x-ms-keyvault-service-version": "1.5.692.1", - "x-ms-ratelimit-remaining-subscription-reads": "11997", - "x-ms-request-id": "4ddcfea7-990b-453e-8515-d6dc7b805ee0", - "x-ms-routing-request-id": "JAPANEAST:20230410T092556Z:9f2174ce-d317-4d80-9d37-0119663796f9" - }, - "ResponseBody": { - "value": [] - } - } - ], - "Variables": {} -} diff --git a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json b/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json deleted file mode 100644 index ea213f7d1d73..000000000000 --- a/sdk/keyvault/arm-keyvault/recordings/node/keyvault_test/recording_vaults_update_test.json +++ /dev/null @@ -1,185 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://management.azure.com/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz?api-version=2023-02-01", - "RequestMethod": "PATCH", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "Content-Length": "741", - "Content-Type": "application/json", - "User-Agent": "azsdk-js-arm-keyvault/3.0.0 core-rest-pipeline/1.10.4 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", - "x-ms-client-request-id": "6948c5a2-bd32-4b35-af46-073dde26d2af" - }, - "RequestBody": { - "properties": { - "tenantId": "88888888-8888-8888-8888-888888888888", - "sku": { - "family": "A", - "name": "standard" - }, - "accessPolicies": [ - { - "tenantId": "88888888-8888-8888-8888-888888888888", - "objectId": "00000000-0000-0000-0000-000000000000", - "permissions": { - "keys": [ - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "sign", - "verify", - "get", - "list", - "create", - "update", - "import", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "secrets": [ - "get", - "list", - "set", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "certificates": [ - "get", - "list", - "delete", - "create", - "import", - "update", - "managecontacts", - "getissuers", - "listissuers", - "setissuers", - "deleteissuers", - "manageissuers", - "recover", - "purge" - ] - } - } - ], - "enabledForDeployment": true, - "enabledForDiskEncryption": true, - "enabledForTemplateDeployment": true - } - }, - "StatusCode": 200, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Encoding": "gzip", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 10 Apr 2023 09:25:58 GMT", - "Expires": "-1", - "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "Transfer-Encoding": "chunked", - "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "6948c5a2-bd32-4b35-af46-073dde26d2af", - "x-ms-correlation-request-id": "91195ab7-d8c0-4351-8582-4d95599b3c56", - "x-ms-keyvault-service-version": "1.5.692.1", - "x-ms-ratelimit-remaining-subscription-writes": "1198", - "x-ms-request-id": "a257674c-12b0-43bb-bd80-2f4b085e2ef8", - "x-ms-routing-request-id": "JAPANEAST:20230410T092558Z:91195ab7-d8c0-4351-8582-4d95599b3c56" - }, - "ResponseBody": { - "id": "/subscriptions/azure_subscription_id/resourceGroups/czwjstest/providers/Microsoft.KeyVault/vaults/myvaultzzzz", - "name": "myvaultzzzz", - "type": "Microsoft.KeyVault/vaults", - "location": "eastus", - "tags": {}, - "systemData": { - "createdBy": "azure_client_id", - "createdByType": "Application", - "createdAt": "2023-04-10T09:15:41.477Z", - "lastModifiedBy": "azure_client_id", - "lastModifiedByType": "Application", - "lastModifiedAt": "2023-04-10T09:25:57.792Z" - }, - "properties": { - "sku": { - "family": "A", - "name": "standard" - }, - "tenantId": "88888888-8888-8888-8888-888888888888", - "accessPolicies": [ - { - "tenantId": "88888888-8888-8888-8888-888888888888", - "objectId": "00000000-0000-0000-0000-000000000000", - "permissions": { - "keys": [ - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "sign", - "verify", - "get", - "list", - "create", - "update", - "import", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "secrets": [ - "get", - "list", - "set", - "delete", - "backup", - "restore", - "recover", - "purge" - ], - "certificates": [ - "get", - "list", - "delete", - "create", - "import", - "update", - "managecontacts", - "getissuers", - "listissuers", - "setissuers", - "deleteissuers", - "manageissuers", - "recover", - "purge" - ] - } - } - ], - "enabledForDeployment": true, - "enabledForDiskEncryption": true, - "enabledForTemplateDeployment": true, - "enableSoftDelete": true, - "vaultUri": "https://myvaultzzzz.vault.azure.net/", - "provisioningState": "Succeeded", - "publicNetworkAccess": "Enabled" - } - } - } - ], - "Variables": {} -}