diff --git a/sdk/keyvault/keyvault-keys/.eslintignore b/sdk/keyvault/keyvault-keys/.eslintignore deleted file mode 100644 index c92bb15b91ea..000000000000 --- a/sdk/keyvault/keyvault-keys/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignoring the core files since they're auto-generated. Eventually, the auto-generated code will be on par with our current eslint rules, but in the mean time we should ignore them. -src/core diff --git a/sdk/keyvault/keyvault-keys/.eslintrc.json b/sdk/keyvault/keyvault-keys/.eslintrc.json index 4f409a486c3f..57874aa10492 100644 --- a/sdk/keyvault/keyvault-keys/.eslintrc.json +++ b/sdk/keyvault/keyvault-keys/.eslintrc.json @@ -1,7 +1,7 @@ { "plugins": ["@azure/azure-sdk"], "extends": ["plugin:@azure/azure-sdk/azure-sdk-base"], - "ignorePatterns": ["src/core"], + "ignorePatterns": ["src/generated"], "rules": { "@typescript-eslint/no-this-alias": "off", "no-invalid-this": "off", diff --git a/sdk/keyvault/keyvault-keys/.prettierignore b/sdk/keyvault/keyvault-keys/.prettierignore index 656f37824af2..ede107590808 100644 --- a/sdk/keyvault/keyvault-keys/.prettierignore +++ b/sdk/keyvault/keyvault-keys/.prettierignore @@ -1,2 +1 @@ -/src/core/* -!/src/core/challengeBasedAuthenticationPolicy.ts \ No newline at end of file +/src/generated/* diff --git a/sdk/keyvault/keyvault-keys/package.json b/sdk/keyvault/keyvault-keys/package.json index f35234206fe3..52d0588585c7 100644 --- a/sdk/keyvault/keyvault-keys/package.json +++ b/sdk/keyvault/keyvault-keys/package.json @@ -54,7 +54,7 @@ "lint:terminal": "eslint package.json api-extractor.json src test --ext .ts", "pack": "npm pack 2>&1", "prebuild": "npm run clean", - "regenerate": "npx autorest swagger/README.md --typescript", + "regenerate": "npx autorest swagger/README.md --typescript --version=3.0.6267", "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", "test:node": "npm run clean && npm run build:test && npm run unit-test:node", "test": "npm run clean && npm run build:test && npm run unit-test", @@ -64,18 +64,6 @@ "unit-test": "npm run unit-test:node && npm run unit-test:browser" }, "sideEffects": false, - "//metadata": { - "constantPaths": [ - { - "path": "src/core/keyVaultClientContext.ts", - "prefix": "packageVersion" - }, - { - "path": "src/core/utils/constants.ts", - "prefix": "SDK_VERSION" - } - ] - }, "dependencies": { "@azure/core-http": "^1.1.1", "@azure/core-lro": "^1.0.2", diff --git a/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md b/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md index a58c6e4b3d8c..5832b8b60453 100644 --- a/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md +++ b/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md @@ -97,7 +97,7 @@ export interface DeletedKey { } // @public -export type DeletionRecoveryLevel = 'Purgeable' | 'Recoverable+Purgeable' | 'Recoverable' | 'Recoverable+ProtectedSubscription' | 'CustomizedRecoverable+Purgeable' | 'CustomizedRecoverable' | 'CustomizedRecoverable+ProtectedSubscription'; +export type DeletionRecoveryLevel = "Purgeable" | "Recoverable+Purgeable" | "Recoverable" | "Recoverable+ProtectedSubscription" | "CustomizedRecoverable+Purgeable" | "CustomizedRecoverable" | "CustomizedRecoverable+ProtectedSubscription"; // @public export type EncryptionAlgorithm = "RSA-OAEP" | "RSA-OAEP-256" | "RSA1_5"; @@ -210,7 +210,7 @@ export interface KeyProperties { } // @public -export type KeyType = "EC" | "EC-HSM" | "RSA" | "RSA-HSM" | "oct"; +export type KeyType = "EC" | "EC-HSM" | "RSA" | "RSA-HSM" | "oct" | "oct-HSM"; // @public export interface KeyVaultKey { diff --git a/sdk/keyvault/keyvault-keys/src/core/keyVaultClient.ts b/sdk/keyvault/keyvault-keys/src/core/keyVaultClient.ts deleted file mode 100644 index 85cc614abb5a..000000000000 --- a/sdk/keyvault/keyvault-keys/src/core/keyVaultClient.ts +++ /dev/null @@ -1,1398 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as coreHttp from "@azure/core-http"; -import * as Models from "./models"; -import * as Mappers from "./models/mappers"; -import * as Parameters from "./models/parameters"; -import { KeyVaultClientContext } from "./keyVaultClientContext"; - -class KeyVaultClient extends KeyVaultClientContext { - /** - * Initializes a new instance of the KeyVaultClient class. - * @param apiVersion Client API version. - * @param [options] The parameter options - */ - constructor(apiVersion: string, options?: coreHttp.ServiceClientOptions) { - super(apiVersion, options); - } - - /** - * The create key operation can be used to create any key type in Azure Key Vault. If the named key - * already exists, Azure Key Vault creates a new version of the key. It requires the keys/create - * permission. - * @summary Creates a new key, stores it, then returns key parameters and attributes to the client. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new - * key. - * @param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values - * include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' - * @param [options] The optional parameters - * @returns Promise - */ - createKey(vaultBaseUrl: string, keyName: string, kty: Models.JsonWebKeyType, options?: Models.KeyVaultClientCreateKeyOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new - * key. - * @param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values - * include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' - * @param callback The callback - */ - createKey(vaultBaseUrl: string, keyName: string, kty: Models.JsonWebKeyType, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name for the new key. The system will generate the version name for the new - * key. - * @param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values - * include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' - * @param options The optional parameters - * @param callback The callback - */ - createKey(vaultBaseUrl: string, keyName: string, kty: Models.JsonWebKeyType, options: Models.KeyVaultClientCreateKeyOptionalParams, callback: coreHttp.ServiceCallback): void; - createKey(vaultBaseUrl: string, keyName: string, kty: Models.JsonWebKeyType, options?: Models.KeyVaultClientCreateKeyOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - kty, - options - }, - createKeyOperationSpec, - callback) as Promise; - } - - /** - * The import key operation may be used to import any key type into an Azure Key Vault. If the - * named key already exists, Azure Key Vault creates a new version of the key. This operation - * requires the keys/import permission. - * @summary Imports an externally created key, stores it, and returns key parameters and attributes - * to the client. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. - * @param key The Json web key - * @param [options] The optional parameters - * @returns Promise - */ - importKey(vaultBaseUrl: string, keyName: string, key: Models.JsonWebKey, options?: Models.KeyVaultClientImportKeyOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. - * @param key The Json web key - * @param callback The callback - */ - importKey(vaultBaseUrl: string, keyName: string, key: Models.JsonWebKey, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName Name for the imported key. - * @param key The Json web key - * @param options The optional parameters - * @param callback The callback - */ - importKey(vaultBaseUrl: string, keyName: string, key: Models.JsonWebKey, options: Models.KeyVaultClientImportKeyOptionalParams, callback: coreHttp.ServiceCallback): void; - importKey(vaultBaseUrl: string, keyName: string, key: Models.JsonWebKey, options?: Models.KeyVaultClientImportKeyOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - key, - options - }, - importKeyOperationSpec, - callback) as Promise; - } - - /** - * The delete key operation cannot be used to remove individual versions of a key. This operation - * removes the cryptographic material associated with the key, which means the key is not usable - * for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the - * keys/delete permission. - * @summary Deletes a key of any type from storage in Azure Key Vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @param [options] The optional parameters - * @returns Promise - */ - deleteKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @param callback The callback - */ - deleteKey(vaultBaseUrl: string, keyName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to delete. - * @param options The optional parameters - * @param callback The callback - */ - deleteKey(vaultBaseUrl: string, keyName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - deleteKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - options - }, - deleteKeyOperationSpec, - callback) as Promise; - } - - /** - * In order to perform this operation, the key must already exist in the Key Vault. Note: The - * cryptographic material of a key itself cannot be changed. This operation requires the - * keys/update permission. - * @summary The update key operation changes specified attributes of a stored key and can be - * applied to any key type and key version stored in Azure Key Vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param [options] The optional parameters - * @returns Promise - */ - updateKey(vaultBaseUrl: string, keyName: string, keyVersion: string, options?: Models.KeyVaultClientUpdateKeyOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param callback The callback - */ - updateKey(vaultBaseUrl: string, keyName: string, keyVersion: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of key to update. - * @param keyVersion The version of the key to update. - * @param options The optional parameters - * @param callback The callback - */ - updateKey(vaultBaseUrl: string, keyName: string, keyVersion: string, options: Models.KeyVaultClientUpdateKeyOptionalParams, callback: coreHttp.ServiceCallback): void; - updateKey(vaultBaseUrl: string, keyName: string, keyVersion: string, options?: Models.KeyVaultClientUpdateKeyOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - options - }, - updateKeyOperationSpec, - callback) as Promise; - } - - /** - * The get key operation is applicable to all key types. If the requested key is symmetric, then no - * key material is released in the response. This operation requires the keys/get permission. - * @summary Gets the public part of a stored key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI - * fragment is optional. If not specified, the latest version of the key is returned. - * @param [options] The optional parameters - * @returns Promise - */ - getKey(vaultBaseUrl: string, keyName: string, keyVersion: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI - * fragment is optional. If not specified, the latest version of the key is returned. - * @param callback The callback - */ - getKey(vaultBaseUrl: string, keyName: string, keyVersion: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key to get. - * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI - * fragment is optional. If not specified, the latest version of the key is returned. - * @param options The optional parameters - * @param callback The callback - */ - getKey(vaultBaseUrl: string, keyName: string, keyVersion: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - getKey(vaultBaseUrl: string, keyName: string, keyVersion: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - options - }, - getKeyOperationSpec, - callback) as Promise; - } - - /** - * The full key identifier, attributes, and tags are provided in the response. This operation - * requires the keys/list permission. - * @summary Retrieves a list of individual key versions with the same key name. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param [options] The optional parameters - * @returns Promise - */ - getKeyVersions(vaultBaseUrl: string, keyName: string, options?: Models.KeyVaultClientGetKeyVersionsOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param callback The callback - */ - getKeyVersions(vaultBaseUrl: string, keyName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param options The optional parameters - * @param callback The callback - */ - getKeyVersions(vaultBaseUrl: string, keyName: string, options: Models.KeyVaultClientGetKeyVersionsOptionalParams, callback: coreHttp.ServiceCallback): void; - getKeyVersions(vaultBaseUrl: string, keyName: string, options?: Models.KeyVaultClientGetKeyVersionsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - options - }, - getKeyVersionsOperationSpec, - callback) as Promise; - } - - /** - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public - * part of a stored key. The LIST operation is applicable to all key types, however only the base - * key identifier, attributes, and tags are provided in the response. Individual versions of a key - * are not listed in the response. This operation requires the keys/list permission. - * @summary List keys in the specified vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param [options] The optional parameters - * @returns Promise - */ - getKeys(vaultBaseUrl: string, options?: Models.KeyVaultClientGetKeysOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param callback The callback - */ - getKeys(vaultBaseUrl: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param options The optional parameters - * @param callback The callback - */ - getKeys(vaultBaseUrl: string, options: Models.KeyVaultClientGetKeysOptionalParams, callback: coreHttp.ServiceCallback): void; - getKeys(vaultBaseUrl: string, options?: Models.KeyVaultClientGetKeysOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - options - }, - getKeysOperationSpec, - callback) as Promise; - } - - /** - * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this - * operation does NOT return key material in a form that can be used outside the Azure Key Vault - * system, the returned key material is either protected to a Azure Key Vault HSM or to Azure Key - * Vault itself. The intent of this operation is to allow a client to GENERATE a key in one Azure - * Key Vault instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. - * The BACKUP operation may be used to export, in protected form, any key type from Azure Key - * Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed - * within geographical boundaries only; meaning that a BACKUP from one geographical area cannot be - * restored to another geographical area. For example, a backup from the US geographical area - * cannot be restored in an EU geographical area. This operation requires the key/backup - * permission. - * @summary Requests that a backup of the specified key be downloaded to the client. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param [options] The optional parameters - * @returns Promise - */ - backupKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param callback The callback - */ - backupKey(vaultBaseUrl: string, keyName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param options The optional parameters - * @param callback The callback - */ - backupKey(vaultBaseUrl: string, keyName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - backupKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - options - }, - backupKeyOperationSpec, - callback) as Promise; - } - - /** - * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, - * attributes and access control policies. The RESTORE operation may be used to import a previously - * backed up key. Individual versions of a key cannot be restored. The key is restored in its - * entirety with the same key name as it had when it was backed up. If the key name is not - * available in the target Key Vault, the RESTORE operation will be rejected. While the key name is - * retained during restore, the final key identifier will change if the key is restored to a - * different vault. Restore will restore all versions and preserve version identifiers. The RESTORE - * operation is subject to security constraints: The target Key Vault must be owned by the same - * Microsoft Azure Subscription as the source Key Vault The user must have RESTORE permission in - * the target Key Vault. This operation requires the keys/restore permission. - * @summary Restores a backed up key to a vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @param [options] The optional parameters - * @returns Promise - */ - restoreKey(vaultBaseUrl: string, keyBundleBackup: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @param callback The callback - */ - restoreKey(vaultBaseUrl: string, keyBundleBackup: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyBundleBackup The backup blob associated with a key bundle. - * @param options The optional parameters - * @param callback The callback - */ - restoreKey(vaultBaseUrl: string, keyBundleBackup: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - restoreKey(vaultBaseUrl: string, keyBundleBackup: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyBundleBackup, - options - }, - restoreKeyOperationSpec, - callback) as Promise; - } - - /** - * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is - * stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, - * the size of which is dependent on the target key and the encryption algorithm to be used. The - * ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since - * protection with an asymmetric key can be performed using public portion of the key. This - * operation is supported for asymmetric keys as a convenience for callers that have a - * key-reference but do not have access to the public key material. This operation requires the - * keys/encrypt permission. - * @summary Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key - * vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param [options] The optional parameters - * @returns Promise - */ - encrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param callback The callback - */ - encrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param options The optional parameters - * @param callback The callback - */ - encrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - encrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - algorithm, - value, - options - }, - encryptOperationSpec, - callback) as Promise; - } - - /** - * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key - * and specified algorithm. This operation is the reverse of the ENCRYPT operation; only a single - * block of data may be decrypted, the size of this block is dependent on the target key and the - * algorithm to be used. The DECRYPT operation applies to asymmetric and symmetric keys stored in - * Azure Key Vault since it uses the private portion of the key. This operation requires the - * keys/decrypt permission. - * @summary Decrypts a single block of encrypted data. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param [options] The optional parameters - * @returns Promise - */ - decrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param callback The callback - */ - decrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param options The optional parameters - * @param callback The callback - */ - decrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - decrypt(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - algorithm, - value, - options - }, - decryptOperationSpec, - callback) as Promise; - } - - /** - * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault - * since this operation uses the private portion of the key. This operation requires the keys/sign - * permission. - * @summary Creates a signature from a digest using the specified key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible - * algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', - * 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - * @param value - * @param [options] The optional parameters - * @returns Promise - */ - sign(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible - * algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', - * 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - * @param value - * @param callback The callback - */ - sign(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, value: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm identifier. For more information on possible - * algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', - * 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - * @param value - * @param options The optional parameters - * @param callback The callback - */ - sign(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, value: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - sign(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - algorithm, - value, - options - }, - signOperationSpec, - callback) as Promise; - } - - /** - * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not - * strictly necessary for asymmetric keys stored in Azure Key Vault since signature verification - * can be performed using the public portion of the key but this operation is supported as a - * convenience for callers that only have a key-reference and not the public portion of the key. - * This operation requires the keys/verify permission. - * @summary Verifies a signature using a specified key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm - * types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', 'PS512', - * 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @param [options] The optional parameters - * @returns Promise - */ - verify(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, digest: Uint8Array, signature: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm - * types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', 'PS512', - * 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @param callback The callback - */ - verify(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, digest: Uint8Array, signature: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm The signing/verification algorithm. For more information on possible algorithm - * types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', 'PS512', - * 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - * @param digest The digest used for signing. - * @param signature The signature to be verified. - * @param options The optional parameters - * @param callback The callback - */ - verify(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, digest: Uint8Array, signature: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - verify(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeySignatureAlgorithm, digest: Uint8Array, signature: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - algorithm, - digest, - signature, - options - }, - verifyOperationSpec, - callback) as Promise; - } - - /** - * The WRAP operation supports encryption of a symmetric key using a key encryption key that has - * previously been stored in an Azure Key Vault. The WRAP operation is only strictly necessary for - * symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be - * performed using the public portion of the key. This operation is supported for asymmetric keys - * as a convenience for callers that have a key-reference but do not have access to the public key - * material. This operation requires the keys/wrapKey permission. - * @summary Wraps a symmetric key using a specified key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param [options] The optional parameters - * @returns Promise - */ - wrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param callback The callback - */ - wrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param options The optional parameters - * @param callback The callback - */ - wrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - wrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - algorithm, - value, - options - }, - wrapKeyOperationSpec, - callback) as Promise; - } - - /** - * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. - * This operation is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric - * and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This - * operation requires the keys/unwrapKey permission. - * @summary Unwraps a symmetric key using the specified key that was initially used for wrapping - * that key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param [options] The optional parameters - * @returns Promise - */ - unwrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param callback The callback - */ - unwrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param keyVersion The version of the key. - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', - * 'RSA1_5' - * @param value - * @param options The optional parameters - * @param callback The callback - */ - unwrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - unwrapKey(vaultBaseUrl: string, keyName: string, keyVersion: string, algorithm: Models.JsonWebKeyEncryptionAlgorithm, value: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - keyVersion, - algorithm, - value, - options - }, - unwrapKeyOperationSpec, - callback) as Promise; - } - - /** - * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public - * part of a deleted key. This operation includes deletion-specific information. The Get Deleted - * Keys operation is applicable for vaults enabled for soft-delete. While the operation can be - * invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. - * This operation requires the keys/list permission. - * @summary Lists the deleted keys in the specified vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param [options] The optional parameters - * @returns Promise - */ - getDeletedKeys(vaultBaseUrl: string, options?: Models.KeyVaultClientGetDeletedKeysOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param callback The callback - */ - getDeletedKeys(vaultBaseUrl: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param options The optional parameters - * @param callback The callback - */ - getDeletedKeys(vaultBaseUrl: string, options: Models.KeyVaultClientGetDeletedKeysOptionalParams, callback: coreHttp.ServiceCallback): void; - getDeletedKeys(vaultBaseUrl: string, options?: Models.KeyVaultClientGetDeletedKeysOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - options - }, - getDeletedKeysOperationSpec, - callback) as Promise; - } - - /** - * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation - * can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled - * vault. This operation requires the keys/get permission. - * @summary Gets the public part of a deleted key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param [options] The optional parameters - * @returns Promise - */ - getDeletedKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param callback The callback - */ - getDeletedKey(vaultBaseUrl: string, keyName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key. - * @param options The optional parameters - * @param callback The callback - */ - getDeletedKey(vaultBaseUrl: string, keyName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - getDeletedKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - options - }, - getDeletedKeyOperationSpec, - callback) as Promise; - } - - /** - * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the - * operation can be invoked on any vault, it will return an error if invoked on a non soft-delete - * enabled vault. This operation requires the keys/purge permission. - * @summary Permanently deletes the specified key. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key - * @param [options] The optional parameters - * @returns Promise - */ - purgeDeletedKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key - * @param callback The callback - */ - purgeDeletedKey(vaultBaseUrl: string, keyName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the key - * @param options The optional parameters - * @param callback The callback - */ - purgeDeletedKey(vaultBaseUrl: string, keyName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - purgeDeletedKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - options - }, - purgeDeletedKeyOperationSpec, - callback); - } - - /** - * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. - * It recovers the deleted key back to its latest version under /keys. An attempt to recover an - * non-deleted key will return an error. Consider this the inverse of the delete operation on - * soft-delete enabled vaults. This operation requires the keys/recover permission. - * @summary Recovers the deleted key to its latest version. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @param [options] The optional parameters - * @returns Promise - */ - recoverDeletedKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @param callback The callback - */ - recoverDeletedKey(vaultBaseUrl: string, keyName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param keyName The name of the deleted key. - * @param options The optional parameters - * @param callback The callback - */ - recoverDeletedKey(vaultBaseUrl: string, keyName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - recoverDeletedKey(vaultBaseUrl: string, keyName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - keyName, - options - }, - recoverDeletedKeyOperationSpec, - callback) as Promise; - } -} - -// Operation Specifications -const serializer = new coreHttp.Serializer(Mappers); -const createKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/create", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName0 - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - kty: "kty", - keySize: [ - "options", - "keySize" - ], - keyOps: [ - "options", - "keyOps" - ], - keyAttributes: [ - "options", - "keyAttributes" - ], - tags: [ - "options", - "tags" - ], - curve: [ - "options", - "curve" - ] - }, - mapper: { - ...Mappers.KeyCreateParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const importKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "PUT", - path: "keys/{key-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName0 - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - hsm: [ - "options", - "hsm" - ], - key: "key", - keyAttributes: [ - "options", - "keyAttributes" - ], - tags: [ - "options", - "tags" - ] - }, - mapper: { - ...Mappers.KeyImportParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const deleteKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "DELETE", - path: "keys/{key-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.DeletedKeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const updateKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "PATCH", - path: "keys/{key-name}/{key-version}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - keyOps: [ - "options", - "keyOps" - ], - keyAttributes: [ - "options", - "keyAttributes" - ], - tags: [ - "options", - "tags" - ] - }, - mapper: { - ...Mappers.KeyUpdateParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "keys/{key-name}/{key-version}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.KeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getKeyVersionsOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "keys/{key-name}/versions", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1 - ], - queryParameters: [ - Parameters.maxresults, - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.KeyListResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getKeysOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "keys", - urlParameters: [ - Parameters.vaultBaseUrl - ], - queryParameters: [ - Parameters.maxresults, - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.KeyListResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const backupKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/backup", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.BackupKeyResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const restoreKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/restore", - urlParameters: [ - Parameters.vaultBaseUrl - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - keyBundleBackup: "keyBundleBackup" - }, - mapper: { - ...Mappers.KeyRestoreParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const encryptOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/{key-version}/encrypt", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - algorithm: "algorithm", - value: "value" - }, - mapper: { - ...Mappers.KeyOperationsParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyOperationResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const decryptOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/{key-version}/decrypt", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - algorithm: "algorithm", - value: "value" - }, - mapper: { - ...Mappers.KeyOperationsParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyOperationResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const signOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/{key-version}/sign", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - algorithm: "algorithm", - value: "value" - }, - mapper: { - ...Mappers.KeySignParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyOperationResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const verifyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/{key-version}/verify", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - algorithm: "algorithm", - digest: "digest", - signature: "signature" - }, - mapper: { - ...Mappers.KeyVerifyParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyVerifyResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const wrapKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/{key-version}/wrapkey", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - algorithm: "algorithm", - value: "value" - }, - mapper: { - ...Mappers.KeyOperationsParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyOperationResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const unwrapKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "keys/{key-name}/{key-version}/unwrapkey", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1, - Parameters.keyVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - algorithm: "algorithm", - value: "value" - }, - mapper: { - ...Mappers.KeyOperationsParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.KeyOperationResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getDeletedKeysOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "deletedkeys", - urlParameters: [ - Parameters.vaultBaseUrl - ], - queryParameters: [ - Parameters.maxresults, - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.DeletedKeyListResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getDeletedKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "deletedkeys/{key-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.DeletedKeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const purgeDeletedKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "DELETE", - path: "deletedkeys/{key-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 204: {}, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const recoverDeletedKeyOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "deletedkeys/{key-name}/recover", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.keyName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.KeyBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -export { - KeyVaultClient, - KeyVaultClientContext, - Models as KeyVaultModels, - Mappers as KeyVaultMappers -}; diff --git a/sdk/keyvault/keyvault-keys/src/core/keyVaultClientContext.ts b/sdk/keyvault/keyvault-keys/src/core/keyVaultClientContext.ts deleted file mode 100644 index f89deb3b3ccd..000000000000 --- a/sdk/keyvault/keyvault-keys/src/core/keyVaultClientContext.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as coreHttp from "@azure/core-http"; - -const packageName = "@azure/keyvault-keys"; -export const packageVersion = "4.1.0-preview.2"; - -export class KeyVaultClientContext extends coreHttp.ServiceClient { - apiVersion: string; - - /** - * Initializes a new instance of the KeyVaultClientContext class. - * @param apiVersion Client API version. - * @param [options] The parameter options - */ - constructor(apiVersion: string, options?: coreHttp.ServiceClientOptions) { - if (apiVersion == undefined) { - throw new Error("'apiVersion' cannot be null."); - } - - if (!options) { - options = {}; - } - - if (!options.userAgent) { - const defaultUserAgent = coreHttp.getDefaultUserAgentValue(); - options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; - } - - super(undefined, options); - - this.baseUri = "{vaultBaseUrl}"; - this.requestContentType = "application/json; charset=utf-8"; - this.apiVersion = apiVersion; - } -} diff --git a/sdk/keyvault/keyvault-keys/src/core/models/index.ts b/sdk/keyvault/keyvault-keys/src/core/models/index.ts deleted file mode 100644 index 73b49f972c6c..000000000000 --- a/sdk/keyvault/keyvault-keys/src/core/models/index.ts +++ /dev/null @@ -1,965 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - - -import * as coreHttp from "@azure/core-http"; - -/** - * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18 - */ -export interface JsonWebKey { - /** - * Key identifier. - */ - kid?: string; - /** - * JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. Possible values include: - * 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' - */ - kty?: JsonWebKeyType; - keyOps?: string[]; - /** - * RSA modulus. - */ - n?: Uint8Array; - /** - * RSA public exponent. - */ - e?: Uint8Array; - /** - * RSA private exponent, or the D component of an EC private key. - */ - d?: Uint8Array; - /** - * RSA private key parameter. - */ - dp?: Uint8Array; - /** - * RSA private key parameter. - */ - dq?: Uint8Array; - /** - * RSA private key parameter. - */ - qi?: Uint8Array; - /** - * RSA secret prime. - */ - p?: Uint8Array; - /** - * RSA secret prime, with p < q. - */ - q?: Uint8Array; - /** - * Symmetric key. - */ - k?: Uint8Array; - /** - * HSM Token, used with 'Bring Your Own Key'. - */ - t?: Uint8Array; - /** - * Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: - * 'P-256', 'P-384', 'P-521', 'P-256K' - */ - crv?: JsonWebKeyCurveName; - /** - * X component of an EC public key. - */ - x?: Uint8Array; - /** - * Y component of an EC public key. - */ - y?: Uint8Array; -} - -/** - * The object attributes managed by the KeyVault service. - */ -export interface Attributes { - /** - * Determines whether the object is enabled. - */ - enabled?: boolean; - /** - * Not before date in UTC. - */ - notBefore?: Date; - /** - * Expiry date in UTC. - */ - expires?: Date; - /** - * Creation time in UTC. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly created?: Date; - /** - * Last updated time in UTC. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly updated?: Date; -} - -/** - * The attributes of a key managed by the key vault service. - */ -export interface KeyAttributes extends Attributes { - /** - * softDelete data retention days. Value should be >=7 and <=90 when softDelete enabled, - * otherwise 0. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly recoverableDays?: number; - /** - * Reflects the deletion recovery level currently in effect for keys in the current vault. If it - * contains 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only - * the system can purge the key, at the end of the retention interval. Possible values include: - * 'Purgeable', 'Recoverable+Purgeable', 'Recoverable', 'Recoverable+ProtectedSubscription', - * 'CustomizedRecoverable+Purgeable', 'CustomizedRecoverable', - * 'CustomizedRecoverable+ProtectedSubscription' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly recoveryLevel?: DeletionRecoveryLevel; -} - -/** - * A KeyBundle consisting of a WebKey plus its attributes. - */ -export interface KeyBundle { - /** - * The Json web key. - */ - key?: JsonWebKey; - /** - * The key management attributes. - */ - attributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, - * then managed will be true. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly managed?: boolean; -} - -/** - * The key item containing key metadata. - */ -export interface KeyItem { - /** - * Key identifier. - */ - kid?: string; - /** - * The key management attributes. - */ - attributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, - * then managed will be true. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly managed?: boolean; -} - -/** - * A DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info - */ -export interface DeletedKeyBundle extends KeyBundle { - /** - * The url of the recovery object, used to identify and recover the deleted key. - */ - recoveryId?: string; - /** - * The time when the key is scheduled to be purged, in UTC - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly scheduledPurgeDate?: Date; - /** - * The time when the key was deleted, in UTC - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly deletedDate?: Date; -} - -/** - * The deleted key item containing the deleted key metadata and information about deletion. - */ -export interface DeletedKeyItem extends KeyItem { - /** - * The url of the recovery object, used to identify and recover the deleted key. - */ - recoveryId?: string; - /** - * The time when the key is scheduled to be purged, in UTC - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly scheduledPurgeDate?: Date; - /** - * The time when the key was deleted, in UTC - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly deletedDate?: Date; -} - -/** - * Properties of the key pair backing a certificate. - */ -export interface KeyProperties { - /** - * Indicates if the private key can be exported. - */ - exportable?: boolean; - /** - * The type of key pair to be used for the certificate. Possible values include: 'EC', 'EC-HSM', - * 'RSA', 'RSA-HSM', 'oct' - */ - keyType?: JsonWebKeyType; - /** - * The key size in bits. For example: 2048, 3072, or 4096 for RSA. - */ - keySize?: number; - /** - * Indicates if the same key pair will be used on certificate renewal. - */ - reuseKey?: boolean; - /** - * Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: - * 'P-256', 'P-384', 'P-521', 'P-256K' - */ - curve?: JsonWebKeyCurveName; -} - -/** - * The key create parameters. - */ -export interface KeyCreateParameters { - /** - * The type of key to create. For valid values, see JsonWebKeyType. Possible values include: - * 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' - */ - kty: JsonWebKeyType; - /** - * The key size in bits. For example: 2048, 3072, or 4096 for RSA. - */ - keySize?: number; - keyOps?: JsonWebKeyOperation[]; - keyAttributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: - * 'P-256', 'P-384', 'P-521', 'P-256K' - */ - curve?: JsonWebKeyCurveName; -} - -/** - * The key import parameters. - */ -export interface KeyImportParameters { - /** - * Whether to import as a hardware key (HSM) or software key. - */ - hsm?: boolean; - /** - * The Json web key - */ - key: JsonWebKey; - /** - * The key management attributes. - */ - keyAttributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; -} - -/** - * The key operations parameters. - */ -export interface KeyOperationsParameters { - /** - * algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' - */ - algorithm: JsonWebKeyEncryptionAlgorithm; - value: Uint8Array; -} - -/** - * The key operations parameters. - */ -export interface KeySignParameters { - /** - * The signing/verification algorithm identifier. For more information on possible algorithm - * types, see JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', 'PS512', - * 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - */ - algorithm: JsonWebKeySignatureAlgorithm; - value: Uint8Array; -} - -/** - * The key verify parameters. - */ -export interface KeyVerifyParameters { - /** - * The signing/verification algorithm. For more information on possible algorithm types, see - * JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', 'PS384', 'PS512', 'RS256', - * 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ES256K' - */ - algorithm: JsonWebKeySignatureAlgorithm; - /** - * The digest used for signing. - */ - digest: Uint8Array; - /** - * The signature to be verified. - */ - signature: Uint8Array; -} - -/** - * The key update parameters. - */ -export interface KeyUpdateParameters { - /** - * Json web key operations. For more information on possible key operations, see - * JsonWebKeyOperation. - */ - keyOps?: JsonWebKeyOperation[]; - keyAttributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; -} - -/** - * The key restore parameters. - */ -export interface KeyRestoreParameters { - /** - * The backup blob associated with a key bundle. - */ - keyBundleBackup: Uint8Array; -} - -/** - * The key operation result. - */ -export interface KeyOperationResult { - /** - * Key identifier - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly kid?: string; - /** - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly result?: Uint8Array; -} - -/** - * The key verify result. - */ -export interface KeyVerifyResult { - /** - * True if the signature is verified, otherwise false. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: boolean; -} - -/** - * The key list result. - */ -export interface KeyListResult { - /** - * A response message containing a list of keys in the key vault along with a link to the next - * page of keys. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: KeyItem[]; - /** - * The URL to get the next set of keys. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly nextLink?: string; -} - -/** - * A list of keys that have been deleted in this vault. - */ -export interface DeletedKeyListResult { - /** - * A response message containing a list of deleted keys in the vault along with a link to the - * next page of deleted keys - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: DeletedKeyItem[]; - /** - * The URL to get the next set of deleted keys. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly nextLink?: string; -} - -/** - * The backup key result, containing the backup blob. - */ -export interface BackupKeyResult { - /** - * The backup blob containing the backed up key. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: Uint8Array; -} - -/** - * The key vault server error. - */ -export interface ErrorModel { - /** - * The error code. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly code?: string; - /** - * The error message. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly message?: string; - /** - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly innerError?: ErrorModel; -} - -/** - * The key vault error exception. - */ -export interface KeyVaultError { - /** - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly error?: ErrorModel; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientCreateKeyOptionalParams extends coreHttp.RequestOptionsBase { - /** - * The key size in bits. For example: 2048, 3072, or 4096 for RSA. - */ - keySize?: number; - keyOps?: JsonWebKeyOperation[]; - keyAttributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: - * 'P-256', 'P-384', 'P-521', 'P-256K' - */ - curve?: JsonWebKeyCurveName; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientImportKeyOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Whether to import as a hardware key (HSM) or software key. - */ - hsm?: boolean; - /** - * The key management attributes. - */ - keyAttributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientUpdateKeyOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Json web key operations. For more information on possible key operations, see - * JsonWebKeyOperation. - */ - keyOps?: JsonWebKeyOperation[]; - keyAttributes?: KeyAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientGetKeyVersionsOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - */ - maxresults?: number; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientGetKeysOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - */ - maxresults?: number; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientGetDeletedKeysOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - */ - maxresults?: number; -} - -/** - * Defines values for JsonWebKeyType. - * Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' - * @readonly - * @enum {string} - */ -export type JsonWebKeyType = 'EC' | 'EC-HSM' | 'RSA' | 'RSA-HSM' | 'oct'; - -/** - * Defines values for JsonWebKeyCurveName. - * Possible values include: 'P-256', 'P-384', 'P-521', 'P-256K' - * @readonly - * @enum {string} - */ -export type JsonWebKeyCurveName = 'P-256' | 'P-384' | 'P-521' | 'P-256K'; - -/** - * Defines values for DeletionRecoveryLevel. - * Possible values include: 'Purgeable', 'Recoverable+Purgeable', 'Recoverable', - * 'Recoverable+ProtectedSubscription', 'CustomizedRecoverable+Purgeable', 'CustomizedRecoverable', - * 'CustomizedRecoverable+ProtectedSubscription' - * @readonly - * @enum {string} - */ -export type DeletionRecoveryLevel = 'Purgeable' | 'Recoverable+Purgeable' | 'Recoverable' | 'Recoverable+ProtectedSubscription' | 'CustomizedRecoverable+Purgeable' | 'CustomizedRecoverable' | 'CustomizedRecoverable+ProtectedSubscription'; - -/** - * Defines values for JsonWebKeyOperation. - * Possible values include: 'encrypt', 'decrypt', 'sign', 'verify', 'wrapKey', 'unwrapKey', - * 'import' - * @readonly - * @enum {string} - */ -export type JsonWebKeyOperation = 'encrypt' | 'decrypt' | 'sign' | 'verify' | 'wrapKey' | 'unwrapKey' | 'import'; - -/** - * Defines values for JsonWebKeyEncryptionAlgorithm. - * Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' - * @readonly - * @enum {string} - */ -export type JsonWebKeyEncryptionAlgorithm = 'RSA-OAEP' | 'RSA-OAEP-256' | 'RSA1_5'; - -/** - * Defines values for JsonWebKeySignatureAlgorithm. - * Possible values include: 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', - * 'ES256', 'ES384', 'ES512', 'ES256K' - * @readonly - * @enum {string} - */ -export type JsonWebKeySignatureAlgorithm = 'PS256' | 'PS384' | 'PS512' | 'RS256' | 'RS384' | 'RS512' | 'RSNULL' | 'ES256' | 'ES384' | 'ES512' | 'ES256K'; - -/** - * Contains response data for the createKey operation. - */ -export type CreateKeyResponse = KeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyBundle; - }; -}; - -/** - * Contains response data for the importKey operation. - */ -export type ImportKeyResponse = KeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyBundle; - }; -}; - -/** - * Contains response data for the deleteKey operation. - */ -export type DeleteKeyResponse = DeletedKeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: DeletedKeyBundle; - }; -}; - -/** - * Contains response data for the updateKey operation. - */ -export type UpdateKeyResponse = KeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyBundle; - }; -}; - -/** - * Contains response data for the getKey operation. - */ -export type GetKeyResponse = KeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyBundle; - }; -}; - -/** - * Contains response data for the getKeyVersions operation. - */ -export type GetKeyVersionsResponse = KeyListResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyListResult; - }; -}; - -/** - * Contains response data for the getKeys operation. - */ -export type GetKeysResponse = KeyListResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyListResult; - }; -}; - -/** - * Contains response data for the backupKey operation. - */ -export type BackupKeyResponse = BackupKeyResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: BackupKeyResult; - }; -}; - -/** - * Contains response data for the restoreKey operation. - */ -export type RestoreKeyResponse = KeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyBundle; - }; -}; - -/** - * Contains response data for the encrypt operation. - */ -export type EncryptResponse = KeyOperationResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyOperationResult; - }; -}; - -/** - * Contains response data for the decrypt operation. - */ -export type DecryptResponse = KeyOperationResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyOperationResult; - }; -}; - -/** - * Contains response data for the sign operation. - */ -export type SignResponse = KeyOperationResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyOperationResult; - }; -}; - -/** - * Contains response data for the verify operation. - */ -export type VerifyResponse = KeyVerifyResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyVerifyResult; - }; -}; - -/** - * Contains response data for the wrapKey operation. - */ -export type WrapKeyResponse = KeyOperationResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyOperationResult; - }; -}; - -/** - * Contains response data for the unwrapKey operation. - */ -export type UnwrapKeyResponse = KeyOperationResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyOperationResult; - }; -}; - -/** - * Contains response data for the getDeletedKeys operation. - */ -export type GetDeletedKeysResponse = DeletedKeyListResult & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: DeletedKeyListResult; - }; -}; - -/** - * Contains response data for the getDeletedKey operation. - */ -export type GetDeletedKeyResponse = DeletedKeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: DeletedKeyBundle; - }; -}; - -/** - * Contains response data for the recoverDeletedKey operation. - */ -export type RecoverDeletedKeyResponse = KeyBundle & { - /** - * The underlying HTTP response. - */ - _response: coreHttp.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KeyBundle; - }; -}; diff --git a/sdk/keyvault/keyvault-keys/src/core/models/parameters.ts b/sdk/keyvault/keyvault-keys/src/core/models/parameters.ts deleted file mode 100644 index 51c4bea11b39..000000000000 --- a/sdk/keyvault/keyvault-keys/src/core/models/parameters.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as coreHttp from "@azure/core-http"; - -export const apiVersion: coreHttp.OperationQueryParameter = { - parameterPath: "apiVersion", - mapper: { - required: true, - serializedName: "api-version", - type: { - name: "String" - } - } -}; -export const keyName0: coreHttp.OperationURLParameter = { - parameterPath: "keyName", - mapper: { - required: true, - serializedName: "key-name", - constraints: { - Pattern: /^[0-9a-zA-Z-]+$/ - }, - type: { - name: "String" - } - } -}; -export const keyName1: coreHttp.OperationURLParameter = { - parameterPath: "keyName", - mapper: { - required: true, - serializedName: "key-name", - type: { - name: "String" - } - } -}; -export const keyVersion: coreHttp.OperationURLParameter = { - parameterPath: "keyVersion", - mapper: { - required: true, - serializedName: "key-version", - type: { - name: "String" - } - } -}; -export const maxresults: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "maxresults" - ], - mapper: { - serializedName: "maxresults", - constraints: { - InclusiveMaximum: 25, - InclusiveMinimum: 1 - }, - type: { - name: "Number" - } - } -}; -export const vaultBaseUrl: coreHttp.OperationURLParameter = { - parameterPath: "vaultBaseUrl", - mapper: { - required: true, - serializedName: "vaultBaseUrl", - defaultValue: '', - type: { - name: "String" - } - }, - skipEncoding: true -}; diff --git a/sdk/keyvault/keyvault-keys/src/cryptographyClient.ts b/sdk/keyvault/keyvault-keys/src/cryptographyClient.ts index 2c5fd4c14eb1..fdfeca8b19c3 100644 --- a/sdk/keyvault/keyvault-keys/src/cryptographyClient.ts +++ b/sdk/keyvault/keyvault-keys/src/cryptographyClient.ts @@ -23,12 +23,18 @@ import { import { getTracer } from "@azure/core-tracing"; import { Span } from "@opentelemetry/api"; import { logger } from "./log"; -import { parseKeyvaultIdentifier } from "./core/utils"; -import { SDK_VERSION } from "./core/utils/constants"; -import { KeyVaultClient } from "./core/keyVaultClient"; +import { parseKeyvaultIdentifier } from "./generated/utils"; +import { SDK_VERSION } from "./generated/utils/constants"; +import { KeyVaultClient } from "./generated/keyVaultClient"; import { challengeBasedAuthenticationPolicy } from "../../keyvault-common/src"; import { createHash as cryptoCreateHash, createVerify, publicEncrypt } from "crypto"; import * as constants from "constants"; +import { + KeyOperationsParameters, + KeySignParameters, + KeyVerifyParameters, + KeyVaultClientOptionalParams +} from "./generated/models"; /** * A client used to perform cryptographic operations with Azure Key Vault keys. @@ -128,6 +134,11 @@ export class CryptographyClient { } } + const keyOperationParameters: KeyOperationsParameters = { + algorithm, + value: plaintext + }; + // Default to the service let result; try { @@ -135,8 +146,7 @@ export class CryptographyClient { this.vaultUrl, this.name, this.version, - algorithm, - plaintext, + keyOperationParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -167,14 +177,18 @@ export class CryptographyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("decrypt", requestOptions); + const keyOperationParameters: KeyOperationsParameters = { + algorithm, + value: ciphertext + }; + let result; try { result = await this.client.decrypt( this.vaultUrl, this.name, this.version, - algorithm, - ciphertext, + keyOperationParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -246,6 +260,11 @@ export class CryptographyClient { } } + const keyOperationParameters: KeyOperationsParameters = { + algorithm, + value: key + }; + // Default to the service let result; try { @@ -253,8 +272,7 @@ export class CryptographyClient { this.vaultUrl, this.name, this.version, - algorithm, - key, + keyOperationParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -284,14 +302,18 @@ export class CryptographyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("unwrapKey", requestOptions); + const keyOperationParameters: KeyOperationsParameters = { + algorithm, + value: encryptedKey + }; + let result; try { result = await this.client.unwrapKey( this.vaultUrl, this.name, this.version, - algorithm, - encryptedKey, + keyOperationParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -321,14 +343,18 @@ export class CryptographyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("sign", requestOptions); + const keySignParameters: KeySignParameters = { + algorithm, + value: digest + }; + let result; try { result = await this.client.sign( this.vaultUrl, this.name, this.version, - algorithm, - digest, + keySignParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -360,15 +386,19 @@ export class CryptographyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("verify", requestOptions); + const keyVerifyParameters: KeyVerifyParameters = { + algorithm, + digest, + signature + }; + let response; try { response = await this.client.verify( this.vaultUrl, this.name, this.version, - algorithm, - digest, - signature, + keyVerifyParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -427,14 +457,18 @@ export class CryptographyClient { } } + const keySignParameters: KeySignParameters = { + algorithm, + value: digest + }; + let result; try { result = await this.client.sign( this.vaultUrl, this.name, this.version, - algorithm, - digest, + keySignParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -564,15 +598,19 @@ export class CryptographyClient { } } + const keyVerifyParameters: KeyVerifyParameters = { + algorithm, + digest, + signature + }; + let result; try { result = await this.client.verify( this.vaultUrl, this.name, this.version, - algorithm, - digest, - signature, + keyVerifyParameters, this.setParentSpan(span, requestOptions) ); } finally { @@ -708,11 +746,11 @@ export class CryptographyClient { } }; - const pipeline = createPipelineFromOptions(internalPipelineOptions, authPolicy); - this.client = new KeyVaultClient( - pipelineOptions.apiVersion || LATEST_API_VERSION, - pipeline - ); + const optionalParams: KeyVaultClientOptionalParams = { + ...createPipelineFromOptions(internalPipelineOptions, authPolicy), + apiVersion: pipelineOptions.apiVersion || LATEST_API_VERSION + }; + this.client = new KeyVaultClient(optionalParams); let parsed; if (typeof key === "string") { diff --git a/sdk/keyvault/keyvault-keys/src/core/index.ts b/sdk/keyvault/keyvault-keys/src/generated/index.ts similarity index 67% rename from sdk/keyvault/keyvault-keys/src/core/index.ts rename to sdk/keyvault/keyvault-keys/src/generated/index.ts index 5fc2833fbf4d..78f209840bba 100644 --- a/sdk/keyvault/keyvault-keys/src/core/index.ts +++ b/sdk/keyvault/keyvault-keys/src/generated/index.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + /// /// diff --git a/sdk/keyvault/keyvault-keys/src/core/keyVaultBase.ts b/sdk/keyvault/keyvault-keys/src/generated/keyVaultBase.ts similarity index 100% rename from sdk/keyvault/keyvault-keys/src/core/keyVaultBase.ts rename to sdk/keyvault/keyvault-keys/src/generated/keyVaultBase.ts diff --git a/sdk/keyvault/keyvault-keys/src/generated/keyVaultClient.ts b/sdk/keyvault/keyvault-keys/src/generated/keyVaultClient.ts new file mode 100644 index 000000000000..0e244cb2f0c1 --- /dev/null +++ b/sdk/keyvault/keyvault-keys/src/generated/keyVaultClient.ts @@ -0,0 +1,1099 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as coreHttp from "@azure/core-http"; +import * as Parameters from "./models/parameters"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import { KeyVaultClientContext } from "./keyVaultClientContext"; +import { + KeyVaultClientOptionalParams, + KeyCreateParameters, + KeyVaultClientCreateKeyResponse, + KeyImportParameters, + KeyVaultClientImportKeyResponse, + KeyVaultClientDeleteKeyResponse, + KeyUpdateParameters, + KeyVaultClientUpdateKeyResponse, + KeyVaultClientGetKeyResponse, + KeyVaultClientGetKeyVersionsOptionalParams, + KeyVaultClientGetKeyVersionsResponse, + KeyVaultClientGetKeysOptionalParams, + KeyVaultClientGetKeysResponse, + KeyVaultClientBackupKeyResponse, + KeyRestoreParameters, + KeyVaultClientRestoreKeyResponse, + KeyOperationsParameters, + KeyVaultClientEncryptResponse, + KeyVaultClientDecryptResponse, + KeySignParameters, + KeyVaultClientSignResponse, + KeyVerifyParameters, + KeyVaultClientVerifyResponse, + KeyVaultClientWrapKeyResponse, + KeyVaultClientUnwrapKeyResponse, + KeyExportParameters, + KeyVaultClientExportKeyResponse, + KeyVaultClientGetDeletedKeysOptionalParams, + KeyVaultClientGetDeletedKeysResponse, + KeyVaultClientGetDeletedKeyResponse, + KeyVaultClientRecoverDeletedKeyResponse, + KeyVaultClientGetKeyVersionsNextOptionalParams, + KeyVaultClientGetKeyVersionsNextResponse, + KeyVaultClientGetKeysNextOptionalParams, + KeyVaultClientGetKeysNextResponse, + KeyVaultClientGetDeletedKeysNextOptionalParams, + KeyVaultClientGetDeletedKeysNextResponse +} from "./models"; + +class KeyVaultClient extends KeyVaultClientContext { + /** + * Initializes a new instance of the KeyVaultClient class. + * @param options The parameter options + */ + constructor(options?: KeyVaultClientOptionalParams) { + super(options); + } + + /** + * The create key operation can be used to create any key type in Azure Key Vault. If the named key + * already exists, Azure Key Vault creates a new version of the key. It requires the keys/create + * permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param parameters The parameters to create a key. + * @param options The options parameters. + */ + createKey( + vaultBaseUrl: string, + keyName: string, + parameters: KeyCreateParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, parameters, options: operationOptions }, + createKeyOperationSpec + ) as Promise; + } + + /** + * The import key operation may be used to import any key type into an Azure Key Vault. If the named + * key already exists, Azure Key Vault creates a new version of the key. This operation requires the + * keys/import permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. + * @param parameters The parameters to import a key. + * @param options The options parameters. + */ + importKey( + vaultBaseUrl: string, + keyName: string, + parameters: KeyImportParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, parameters, options: operationOptions }, + importKeyOperationSpec + ) as Promise; + } + + /** + * The delete key operation cannot be used to remove individual versions of a key. This operation + * removes the cryptographic material associated with the key, which means the key is not usable for + * Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the keys/delete + * permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to delete. + * @param options The options parameters. + */ + deleteKey( + vaultBaseUrl: string, + keyName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, options: operationOptions }, + deleteKeyOperationSpec + ) as Promise; + } + + /** + * In order to perform this operation, the key must already exist in the Key Vault. Note: The + * cryptographic material of a key itself cannot be changed. This operation requires the keys/update + * permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. + * @param parameters The parameters of the key to update. + * @param options The options parameters. + */ + updateKey( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyUpdateParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + updateKeyOperationSpec + ) as Promise; + } + + /** + * The get key operation is applicable to all key types. If the requested key is symmetric, then no key + * material is released in the response. This operation requires the keys/get permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. This URI + * fragment is optional. If not specified, the latest version of the key is returned. + * @param options The options parameters. + */ + getKey( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, keyVersion, options: operationOptions }, + getKeyOperationSpec + ) as Promise; + } + + /** + * The full key identifier, attributes, and tags are provided in the response. This operation requires + * the keys/list permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param options The options parameters. + */ + getKeyVersions( + vaultBaseUrl: string, + keyName: string, + options?: KeyVaultClientGetKeyVersionsOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, options: operationOptions }, + getKeyVersionsOperationSpec + ) as Promise; + } + + /** + * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public + * part of a stored key. The LIST operation is applicable to all key types, however only the base key + * identifier, attributes, and tags are provided in the response. Individual versions of a key are not + * listed in the response. This operation requires the keys/list permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param options The options parameters. + */ + getKeys( + vaultBaseUrl: string, + options?: KeyVaultClientGetKeysOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, options: operationOptions }, + getKeysOperationSpec + ) as Promise; + } + + /** + * The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this + * operation does NOT return key material in a form that can be used outside the Azure Key Vault + * system, the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault + * itself. The intent of this operation is to allow a client to GENERATE a key in one Azure Key Vault + * instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP + * operation may be used to export, in protected form, any key type from Azure Key Vault. Individual + * versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical + * boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another + * geographical area. For example, a backup from the US geographical area cannot be restored in an EU + * geographical area. This operation requires the key/backup permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param options The options parameters. + */ + backupKey( + vaultBaseUrl: string, + keyName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, options: operationOptions }, + backupKeyOperationSpec + ) as Promise; + } + + /** + * Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, + * attributes and access control policies. The RESTORE operation may be used to import a previously + * backed up key. Individual versions of a key cannot be restored. The key is restored in its entirety + * with the same key name as it had when it was backed up. If the key name is not available in the + * target Key Vault, the RESTORE operation will be rejected. While the key name is retained during + * restore, the final key identifier will change if the key is restored to a different vault. Restore + * will restore all versions and preserve version identifiers. The RESTORE operation is subject to + * security constraints: The target Key Vault must be owned by the same Microsoft Azure Subscription as + * the source Key Vault The user must have RESTORE permission in the target Key Vault. This operation + * requires the keys/restore permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param parameters The parameters to restore the key. + * @param options The options parameters. + */ + restoreKey( + vaultBaseUrl: string, + parameters: KeyRestoreParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, parameters, options: operationOptions }, + restoreKeyOperationSpec + ) as Promise; + } + + /** + * The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored + * in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size + * of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT + * operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection + * with an asymmetric key can be performed using public portion of the key. This operation is supported + * for asymmetric keys as a convenience for callers that have a key-reference but do not have access to + * the public key material. This operation requires the keys/encrypt permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. + * @param parameters The parameters for the encryption operation. + * @param options The options parameters. + */ + encrypt( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyOperationsParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + encryptOperationSpec + ) as Promise; + } + + /** + * The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and + * specified algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of + * data may be decrypted, the size of this block is dependent on the target key and the algorithm to be + * used. The DECRYPT operation applies to asymmetric and symmetric keys stored in Azure Key Vault since + * it uses the private portion of the key. This operation requires the keys/decrypt permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. + * @param parameters The parameters for the decryption operation. + * @param options The options parameters. + */ + decrypt( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyOperationsParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + decryptOperationSpec + ) as Promise; + } + + /** + * The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since + * this operation uses the private portion of the key. This operation requires the keys/sign + * permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. + * @param parameters The parameters for the signing operation. + * @param options The options parameters. + */ + sign( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeySignParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + signOperationSpec + ) as Promise; + } + + /** + * The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not + * strictly necessary for asymmetric keys stored in Azure Key Vault since signature verification can be + * performed using the public portion of the key but this operation is supported as a convenience for + * callers that only have a key-reference and not the public portion of the key. This operation + * requires the keys/verify permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. + * @param parameters The parameters for verify operations. + * @param options The options parameters. + */ + verify( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyVerifyParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + verifyOperationSpec + ) as Promise; + } + + /** + * The WRAP operation supports encryption of a symmetric key using a key encryption key that has + * previously been stored in an Azure Key Vault. The WRAP operation is only strictly necessary for + * symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed + * using the public portion of the key. This operation is supported for asymmetric keys as a + * convenience for callers that have a key-reference but do not have access to the public key material. + * This operation requires the keys/wrapKey permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. + * @param parameters The parameters for wrap operation. + * @param options The options parameters. + */ + wrapKey( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyOperationsParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + wrapKeyOperationSpec + ) as Promise; + } + + /** + * The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. + * This operation is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and + * symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This + * operation requires the keys/unwrapKey permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. + * @param parameters The parameters for the key operation. + * @param options The options parameters. + */ + unwrapKey( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyOperationsParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + unwrapKeyOperationSpec + ) as Promise; + } + + /** + * The export key operation is applicable to all key types. The target key must be marked exportable. + * This operation requires the keys/export permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. + * @param parameters The parameters for the key export operation. + * @param options The options parameters. + */ + exportKey( + vaultBaseUrl: string, + keyName: string, + keyVersion: string, + parameters: KeyExportParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + keyName, + keyVersion, + parameters, + options: operationOptions + }, + exportKeyOperationSpec + ) as Promise; + } + + /** + * Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public + * part of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys + * operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on + * any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation + * requires the keys/list permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param options The options parameters. + */ + getDeletedKeys( + vaultBaseUrl: string, + options?: KeyVaultClientGetDeletedKeysOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, options: operationOptions }, + getDeletedKeysOperationSpec + ) as Promise; + } + + /** + * The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can + * be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This + * operation requires the keys/get permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param options The options parameters. + */ + getDeletedKey( + vaultBaseUrl: string, + keyName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, options: operationOptions }, + getDeletedKeyOperationSpec + ) as Promise; + } + + /** + * The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation + * can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. + * This operation requires the keys/purge permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key + * @param options The options parameters. + */ + purgeDeletedKey( + vaultBaseUrl: string, + keyName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, options: operationOptions }, + purgeDeletedKeyOperationSpec + ) as Promise; + } + + /** + * The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It + * recovers the deleted key back to its latest version under /keys. An attempt to recover an + * non-deleted key will return an error. Consider this the inverse of the delete operation on + * soft-delete enabled vaults. This operation requires the keys/recover permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the deleted key. + * @param options The options parameters. + */ + recoverDeletedKey( + vaultBaseUrl: string, + keyName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, options: operationOptions }, + recoverDeletedKeyOperationSpec + ) as Promise; + } + + /** + * GetKeyVersionsNext + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param nextLink The nextLink from the previous successful call to the GetKeyVersions method. + * @param options The options parameters. + */ + getKeyVersionsNext( + vaultBaseUrl: string, + keyName: string, + nextLink: string, + options?: KeyVaultClientGetKeyVersionsNextOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, keyName, nextLink, options: operationOptions }, + getKeyVersionsNextOperationSpec + ) as Promise; + } + + /** + * GetKeysNext + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param nextLink The nextLink from the previous successful call to the GetKeys method. + * @param options The options parameters. + */ + getKeysNext( + vaultBaseUrl: string, + nextLink: string, + options?: KeyVaultClientGetKeysNextOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, nextLink, options: operationOptions }, + getKeysNextOperationSpec + ) as Promise; + } + + /** + * GetDeletedKeysNext + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param nextLink The nextLink from the previous successful call to the GetDeletedKeys method. + * @param options The options parameters. + */ + getDeletedKeysNext( + vaultBaseUrl: string, + nextLink: string, + options?: KeyVaultClientGetDeletedKeysNextOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, nextLink, options: operationOptions }, + getDeletedKeysNextOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const createKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/create", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const importKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters1, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const deleteKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}", + httpMethod: "DELETE", + responses: { + 200: { + bodyMapper: Mappers.DeletedKeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName1], + serializer +}; +const updateKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters2, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const getKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + serializer +}; +const getKeyVersionsOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/versions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.KeyListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName1], + serializer +}; +const getKeysOperationSpec: coreHttp.OperationSpec = { + path: "/keys", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.KeyListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl], + serializer +}; +const backupKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/backup", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.BackupKeyResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName1], + serializer +}; +const restoreKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/restore", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters3, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const encryptOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/encrypt", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyOperationResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters4, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const decryptOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/decrypt", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyOperationResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters4, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const signOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/sign", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyOperationResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters5, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const verifyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/verify", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyVerifyResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters6, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const wrapKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/wrapkey", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyOperationResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters4, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const unwrapKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/unwrapkey", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyOperationResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters4, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const exportKeyOperationSpec: coreHttp.OperationSpec = { + path: "/keys/{key-name}/{key-version}/export", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters7, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.keyVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const getDeletedKeysOperationSpec: coreHttp.OperationSpec = { + path: "/deletedkeys", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DeletedKeyListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl], + serializer +}; +const getDeletedKeyOperationSpec: coreHttp.OperationSpec = { + path: "/deletedkeys/{key-name}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DeletedKeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName1], + serializer +}; +const purgeDeletedKeyOperationSpec: coreHttp.OperationSpec = { + path: "/deletedkeys/{key-name}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName1], + serializer +}; +const recoverDeletedKeyOperationSpec: coreHttp.OperationSpec = { + path: "/deletedkeys/{key-name}/recover", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.KeyBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName1], + serializer +}; +const getKeyVersionsNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.KeyListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.keyName1, + Parameters.nextLink + ], + serializer +}; +const getKeysNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.KeyListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl, Parameters.nextLink], + serializer +}; +const getDeletedKeysNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DeletedKeyListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl, Parameters.nextLink], + serializer +}; + +// Operation Specifications + +export { + KeyVaultClient, + KeyVaultClientContext, + Models as KeyVaultModels, + Mappers as KeyVaultMappers +}; diff --git a/sdk/keyvault/keyvault-keys/src/generated/keyVaultClientContext.ts b/sdk/keyvault/keyvault-keys/src/generated/keyVaultClientContext.ts new file mode 100644 index 000000000000..3d325035c83f --- /dev/null +++ b/sdk/keyvault/keyvault-keys/src/generated/keyVaultClientContext.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as coreHttp from "@azure/core-http"; +import { KeyVaultClientOptionalParams } from "./models"; + +const packageName = "@azure/keyvault-admin"; +export const packageVersion = "4.1.0-preview.2"; + +export class KeyVaultClientContext extends coreHttp.ServiceClient { + apiVersion: string; + + /** + * Initializes a new instance of the KeyVaultClientContext class. + * @param options The parameter options + */ + constructor(options?: KeyVaultClientOptionalParams) { + // Initializing default values for options + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = coreHttp.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(undefined, options); + + this.requestContentType = "application/json; charset=utf-8"; + + this.baseUri = options.endpoint || "{vaultBaseUrl}"; + + // Assigning values to Constant parameters + this.apiVersion = options.apiVersion || "7.2-preview"; + } +} diff --git a/sdk/keyvault/keyvault-keys/src/generated/models/index.ts b/sdk/keyvault/keyvault-keys/src/generated/models/index.ts new file mode 100644 index 000000000000..09aab7d0f9ab --- /dev/null +++ b/sdk/keyvault/keyvault-keys/src/generated/models/index.ts @@ -0,0 +1,1088 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as coreHttp from "@azure/core-http"; + +/** + * The key create parameters. + */ +export interface KeyCreateParameters { + /** + * The type of key to create. For valid values, see JsonWebKeyType. + */ + kty: JsonWebKeyType; + /** + * The key size in bits. For example: 2048, 3072, or 4096 for RSA. + */ + keySize?: number; + /** + * The public exponent for a RSA key. + */ + publicExponent?: number; + keyOps?: JsonWebKeyOperation[]; + /** + * The attributes of a key managed by the key vault service. + */ + keyAttributes?: KeyAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * Elliptic curve name. For valid values, see JsonWebKeyCurveName. + */ + curve?: JsonWebKeyCurveName; + /** + * The policy rules under which the key can be exported. + */ + releasePolicy?: KeyReleasePolicy; +} + +/** + * The object attributes managed by the KeyVault service. + */ +export interface Attributes { + /** + * Determines whether the object is enabled. + */ + enabled?: boolean; + /** + * Not before date in UTC. + */ + notBefore?: Date; + /** + * Expiry date in UTC. + */ + expires?: Date; + /** + * Creation time in UTC. + */ + readonly created?: Date; + /** + * Last updated time in UTC. + */ + readonly updated?: Date; +} + +/** + * The attributes of a key managed by the key vault service. + */ +export type KeyAttributes = Attributes & { + /** + * softDelete data retention days. Value should be >=7 and <=90 when softDelete enabled, otherwise 0. + */ + readonly recoverableDays?: number; + /** + * Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only the system can purge the key, at the end of the retention interval. + */ + readonly recoveryLevel?: DeletionRecoveryLevel; + /** + * Indicates if the private key can be exported. + */ + exportable?: boolean; +}; + +export interface KeyReleasePolicy { + /** + * key release policy version + */ + version?: "0.2"; + anyOf?: KeyReleaseAuthority[]; +} + +export interface KeyReleaseAuthority { + /** + * Base URL of the attestation service. + */ + authorityURL?: string; + allOf?: KeyReleaseCondition[]; +} + +export interface KeyReleaseCondition { + /** + * claim type name + */ + claimType?: string; + /** + * condition to test + */ + claimCondition?: "equals"; + value?: string; +} + +/** + * A KeyBundle consisting of a WebKey plus its attributes. + */ +export interface KeyBundle { + /** + * The Json web key. + */ + key?: JsonWebKey; + /** + * The key management attributes. + */ + attributes?: KeyAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. + */ + readonly managed?: boolean; + /** + * The policy rules under which the key can be exported. + */ + releasePolicy?: KeyReleasePolicy; +} + +/** + * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18 + */ +export interface JsonWebKey { + /** + * Key identifier. + */ + kid?: string; + /** + * JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. + */ + kty?: JsonWebKeyType; + keyOps?: string[]; + /** + * RSA modulus. + */ + n?: Uint8Array; + /** + * RSA public exponent. + */ + e?: Uint8Array; + /** + * RSA private exponent, or the D component of an EC private key. + */ + d?: Uint8Array; + /** + * RSA private key parameter. + */ + dp?: Uint8Array; + /** + * RSA private key parameter. + */ + dq?: Uint8Array; + /** + * RSA private key parameter. + */ + qi?: Uint8Array; + /** + * RSA secret prime. + */ + p?: Uint8Array; + /** + * RSA secret prime, with p < q. + */ + q?: Uint8Array; + /** + * Symmetric key. + */ + k?: Uint8Array; + /** + * Protected Key, used with 'Bring Your Own Key'. + */ + t?: Uint8Array; + /** + * Elliptic curve name. For valid values, see JsonWebKeyCurveName. + */ + crv?: JsonWebKeyCurveName; + /** + * X component of an EC public key. + */ + x?: Uint8Array; + /** + * Y component of an EC public key. + */ + y?: Uint8Array; +} + +/** + * The key vault error exception. + */ +export interface KeyVaultError { + /** + * The key vault server error. + */ + readonly error?: ErrorModel; +} + +/** + * The key vault server error. + */ +export interface ErrorModel { + /** + * The error code. + */ + readonly code?: string; + /** + * The error message. + */ + readonly message?: string; + /** + * The key vault server error. + */ + readonly innerError?: ErrorModel; +} + +/** + * The key import parameters. + */ +export interface KeyImportParameters { + /** + * Whether to import as a hardware key (HSM) or software key. + */ + hsm?: boolean; + /** + * The Json web key + */ + key: JsonWebKey; + /** + * The key management attributes. + */ + keyAttributes?: KeyAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * The policy rules under which the key can be exported. + */ + releasePolicy?: KeyReleasePolicy; +} + +/** + * A DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info + */ +export type DeletedKeyBundle = KeyBundle & { + /** + * The url of the recovery object, used to identify and recover the deleted key. + */ + recoveryId?: string; + /** + * The time when the key is scheduled to be purged, in UTC + */ + readonly scheduledPurgeDate?: Date; + /** + * The time when the key was deleted, in UTC + */ + readonly deletedDate?: Date; +}; + +/** + * The key update parameters. + */ +export interface KeyUpdateParameters { + /** + * Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + */ + keyOps?: JsonWebKeyOperation[]; + /** + * The attributes of a key managed by the key vault service. + */ + keyAttributes?: KeyAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * The policy rules under which the key can be exported. + */ + releasePolicy?: KeyReleasePolicy; +} + +/** + * The key list result. + */ +export interface KeyListResult { + /** + * A response message containing a list of keys in the key vault along with a link to the next page of keys. + */ + readonly value?: KeyItem[]; + /** + * The URL to get the next set of keys. + */ + readonly nextLink?: string; +} + +/** + * The key item containing key metadata. + */ +export interface KeyItem { + /** + * Key identifier. + */ + kid?: string; + /** + * The key management attributes. + */ + attributes?: KeyAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. + */ + readonly managed?: boolean; +} + +/** + * The backup key result, containing the backup blob. + */ +export interface BackupKeyResult { + /** + * The backup blob containing the backed up key. + */ + readonly value?: Uint8Array; +} + +/** + * The key restore parameters. + */ +export interface KeyRestoreParameters { + /** + * The backup blob associated with a key bundle. + */ + keyBundleBackup: Uint8Array; +} + +/** + * The key operations parameters. + */ +export interface KeyOperationsParameters { + /** + * algorithm identifier + */ + algorithm: JsonWebKeyEncryptionAlgorithm; + value: Uint8Array; + /** + * Initialization vector for symmetric algorithms. + */ + iv?: Uint8Array; + /** + * Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. + */ + aad?: Uint8Array; + /** + * The tag to authenticate when performing decryption with an authenticated algorithm. + */ + tag?: Uint8Array; +} + +/** + * The key operation result. + */ +export interface KeyOperationResult { + /** + * Key identifier + */ + readonly kid?: string; + readonly result?: Uint8Array; +} + +/** + * The key operations parameters. + */ +export interface KeySignParameters { + /** + * The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + */ + algorithm: JsonWebKeySignatureAlgorithm; + value: Uint8Array; +} + +/** + * The key verify parameters. + */ +export interface KeyVerifyParameters { + /** + * The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + */ + algorithm: JsonWebKeySignatureAlgorithm; + /** + * The digest used for signing. + */ + digest: Uint8Array; + /** + * The signature to be verified. + */ + signature: Uint8Array; +} + +/** + * The key verify result. + */ +export interface KeyVerifyResult { + /** + * True if the signature is verified, otherwise false. + */ + readonly value?: boolean; +} + +/** + * The export key parameters. + */ +export interface KeyExportParameters { + /** + * The target environment assertion. + */ + environment: string; +} + +/** + * A list of keys that have been deleted in this vault. + */ +export interface DeletedKeyListResult { + /** + * A response message containing a list of deleted keys in the vault along with a link to the next page of deleted keys + */ + readonly value?: DeletedKeyItem[]; + /** + * The URL to get the next set of deleted keys. + */ + readonly nextLink?: string; +} + +/** + * The deleted key item containing the deleted key metadata and information about deletion. + */ +export type DeletedKeyItem = KeyItem & { + /** + * The url of the recovery object, used to identify and recover the deleted key. + */ + recoveryId?: string; + /** + * The time when the key is scheduled to be purged, in UTC + */ + readonly scheduledPurgeDate?: Date; + /** + * The time when the key was deleted, in UTC + */ + readonly deletedDate?: Date; +}; + +/** + * Properties of the key pair backing a certificate. + */ +export interface KeyProperties { + /** + * Indicates if the private key can be exported. + */ + exportable?: boolean; + /** + * The type of key pair to be used for the certificate. + */ + keyType?: JsonWebKeyType; + /** + * The key size in bits. For example: 2048, 3072, or 4096 for RSA. + */ + keySize?: number; + /** + * Indicates if the same key pair will be used on certificate renewal. + */ + reuseKey?: boolean; + /** + * Elliptic curve name. For valid values, see JsonWebKeyCurveName. + */ + curve?: JsonWebKeyCurveName; +} + +/** + * Defines values for JsonWebKeyType. + */ +export type JsonWebKeyType = + | "EC" + | "EC-HSM" + | "RSA" + | "RSA-HSM" + | "oct" + | "oct-HSM"; +/** + * Defines values for JsonWebKeyOperation. + */ +export type JsonWebKeyOperation = + | "encrypt" + | "decrypt" + | "sign" + | "verify" + | "wrapKey" + | "unwrapKey" + | "import" + | "export"; +/** + * Defines values for DeletionRecoveryLevel. + */ +export type DeletionRecoveryLevel = + | "Purgeable" + | "Recoverable+Purgeable" + | "Recoverable" + | "Recoverable+ProtectedSubscription" + | "CustomizedRecoverable+Purgeable" + | "CustomizedRecoverable" + | "CustomizedRecoverable+ProtectedSubscription"; +/** + * Defines values for JsonWebKeyCurveName. + */ +export type JsonWebKeyCurveName = "P-256" | "P-384" | "P-521" | "P-256K"; +/** + * Defines values for JsonWebKeyEncryptionAlgorithm. + */ +export type JsonWebKeyEncryptionAlgorithm = + | "RSA-OAEP" + | "RSA-OAEP-256" + | "RSA1_5" + | "A128GCM" + | "A192GCM" + | "A256GCM" + | "A128KW" + | "A192KW" + | "A256KW" + | "A128CBC" + | "A192CBC" + | "A256CBC" + | "A128CBCPAD" + | "A192CBCPAD" + | "A256CBCPAD"; +/** + * Defines values for JsonWebKeySignatureAlgorithm. + */ +export type JsonWebKeySignatureAlgorithm = + | "PS256" + | "PS384" + | "PS512" + | "RS256" + | "RS384" + | "RS512" + | "RSNULL" + | "ES256" + | "ES384" + | "ES512" + | "ES256K"; + +/** + * Contains response data for the createKey operation. + */ +export type KeyVaultClientCreateKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Contains response data for the importKey operation. + */ +export type KeyVaultClientImportKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Contains response data for the deleteKey operation. + */ +export type KeyVaultClientDeleteKeyResponse = DeletedKeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: DeletedKeyBundle; + }; +}; + +/** + * Contains response data for the updateKey operation. + */ +export type KeyVaultClientUpdateKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Contains response data for the getKey operation. + */ +export type KeyVaultClientGetKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetKeyVersionsOptionalParams + extends coreHttp.OperationOptions { + /** + * Maximum number of results to return in a page. If not specified the service will return up to 25 results. + */ + maxresults?: number; +} + +/** + * Contains response data for the getKeyVersions operation. + */ +export type KeyVaultClientGetKeyVersionsResponse = KeyListResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetKeysOptionalParams + extends coreHttp.OperationOptions { + /** + * Maximum number of results to return in a page. If not specified the service will return up to 25 results. + */ + maxresults?: number; +} + +/** + * Contains response data for the getKeys operation. + */ +export type KeyVaultClientGetKeysResponse = KeyListResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyListResult; + }; +}; + +/** + * Contains response data for the backupKey operation. + */ +export type KeyVaultClientBackupKeyResponse = BackupKeyResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: BackupKeyResult; + }; +}; + +/** + * Contains response data for the restoreKey operation. + */ +export type KeyVaultClientRestoreKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Contains response data for the encrypt operation. + */ +export type KeyVaultClientEncryptResponse = KeyOperationResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyOperationResult; + }; +}; + +/** + * Contains response data for the decrypt operation. + */ +export type KeyVaultClientDecryptResponse = KeyOperationResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyOperationResult; + }; +}; + +/** + * Contains response data for the sign operation. + */ +export type KeyVaultClientSignResponse = KeyOperationResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyOperationResult; + }; +}; + +/** + * Contains response data for the verify operation. + */ +export type KeyVaultClientVerifyResponse = KeyVerifyResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyVerifyResult; + }; +}; + +/** + * Contains response data for the wrapKey operation. + */ +export type KeyVaultClientWrapKeyResponse = KeyOperationResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyOperationResult; + }; +}; + +/** + * Contains response data for the unwrapKey operation. + */ +export type KeyVaultClientUnwrapKeyResponse = KeyOperationResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyOperationResult; + }; +}; + +/** + * Contains response data for the exportKey operation. + */ +export type KeyVaultClientExportKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetDeletedKeysOptionalParams + extends coreHttp.OperationOptions { + /** + * Maximum number of results to return in a page. If not specified the service will return up to 25 results. + */ + maxresults?: number; +} + +/** + * Contains response data for the getDeletedKeys operation. + */ +export type KeyVaultClientGetDeletedKeysResponse = DeletedKeyListResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: DeletedKeyListResult; + }; +}; + +/** + * Contains response data for the getDeletedKey operation. + */ +export type KeyVaultClientGetDeletedKeyResponse = DeletedKeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: DeletedKeyBundle; + }; +}; + +/** + * Contains response data for the recoverDeletedKey operation. + */ +export type KeyVaultClientRecoverDeletedKeyResponse = KeyBundle & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyBundle; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetKeyVersionsNextOptionalParams + extends coreHttp.OperationOptions { + /** + * Maximum number of results to return in a page. If not specified the service will return up to 25 results. + */ + maxresults?: number; +} + +/** + * Contains response data for the getKeyVersionsNext operation. + */ +export type KeyVaultClientGetKeyVersionsNextResponse = KeyListResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetKeysNextOptionalParams + extends coreHttp.OperationOptions { + /** + * Maximum number of results to return in a page. If not specified the service will return up to 25 results. + */ + maxresults?: number; +} + +/** + * Contains response data for the getKeysNext operation. + */ +export type KeyVaultClientGetKeysNextResponse = KeyListResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KeyListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetDeletedKeysNextOptionalParams + extends coreHttp.OperationOptions { + /** + * Maximum number of results to return in a page. If not specified the service will return up to 25 results. + */ + maxresults?: number; +} + +/** + * Contains response data for the getDeletedKeysNext operation. + */ +export type KeyVaultClientGetDeletedKeysNextResponse = DeletedKeyListResult & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: DeletedKeyListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientOptionalParams + extends coreHttp.ServiceClientOptions { + /** + * Api Version + */ + apiVersion?: string; + /** + * Overrides client endpoint. + */ + endpoint?: string; +} diff --git a/sdk/keyvault/keyvault-keys/src/core/models/mappers.ts b/sdk/keyvault/keyvault-keys/src/generated/models/mappers.ts similarity index 78% rename from sdk/keyvault/keyvault-keys/src/core/models/mappers.ts rename to sdk/keyvault/keyvault-keys/src/generated/models/mappers.ts index 944587ed685b..c7c8d58b6063 100644 --- a/sdk/keyvault/keyvault-keys/src/core/models/mappers.ts +++ b/sdk/keyvault/keyvault-keys/src/generated/models/mappers.ts @@ -1,119 +1,64 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. import * as coreHttp from "@azure/core-http"; - -export const JsonWebKey: coreHttp.CompositeMapper = { - serializedName: "JsonWebKey", +export const KeyCreateParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "JsonWebKey", + className: "KeyCreateParameters", modelProperties: { - kid: { - serializedName: "kid", - type: { - name: "String" - } - }, kty: { serializedName: "kty", + required: true, type: { name: "String" } }, - keyOps: { - serializedName: "key_ops", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - n: { - serializedName: "n", - type: { - name: "Base64Url" - } - }, - e: { - serializedName: "e", - type: { - name: "Base64Url" - } - }, - d: { - serializedName: "d", - type: { - name: "Base64Url" - } - }, - dp: { - serializedName: "dp", - type: { - name: "Base64Url" - } - }, - dq: { - serializedName: "dq", - type: { - name: "Base64Url" - } - }, - qi: { - serializedName: "qi", + keySize: { + serializedName: "key_size", type: { - name: "Base64Url" + name: "Number" } }, - p: { - serializedName: "p", + publicExponent: { + serializedName: "public_exponent", type: { - name: "Base64Url" + name: "Number" } }, - q: { - serializedName: "q", + keyOps: { + serializedName: "key_ops", type: { - name: "Base64Url" + name: "Sequence", + element: { type: { name: "String" } } } }, - k: { - serializedName: "k", + keyAttributes: { + serializedName: "attributes", type: { - name: "Base64Url" + name: "Composite", + className: "KeyAttributes" } }, - t: { - serializedName: "key_hsm", + tags: { + serializedName: "tags", type: { - name: "Base64Url" + name: "Dictionary", + value: { type: { name: "String" } } } }, - crv: { + curve: { serializedName: "crv", type: { name: "String" } }, - x: { - serializedName: "x", + releasePolicy: { + serializedName: "release_policy", type: { - name: "Base64Url" - } - }, - y: { - serializedName: "y", - type: { - name: "Base64Url" + name: "Composite", + className: "KeyReleasePolicy" } } } @@ -121,7 +66,6 @@ export const JsonWebKey: coreHttp.CompositeMapper = { }; export const Attributes: coreHttp.CompositeMapper = { - serializedName: "Attributes", type: { name: "Composite", className: "Attributes", @@ -145,15 +89,15 @@ export const Attributes: coreHttp.CompositeMapper = { } }, created: { - readOnly: true, serializedName: "created", + readOnly: true, type: { name: "UnixTime" } }, updated: { - readOnly: true, serializedName: "updated", + readOnly: true, type: { name: "UnixTime" } @@ -163,23 +107,112 @@ export const Attributes: coreHttp.CompositeMapper = { }; export const KeyAttributes: coreHttp.CompositeMapper = { - serializedName: "KeyAttributes", type: { name: "Composite", className: "KeyAttributes", modelProperties: { ...Attributes.type.modelProperties, recoverableDays: { - readOnly: true, serializedName: "recoverableDays", + readOnly: true, type: { name: "Number" } }, recoveryLevel: { - nullable: false, - readOnly: true, serializedName: "recoveryLevel", + readOnly: true, + type: { + name: "String" + } + }, + exportable: { + serializedName: "exportable", + type: { + name: "Boolean" + } + } + } + } +}; + +export const KeyReleasePolicy: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyReleasePolicy", + modelProperties: { + version: { + defaultValue: "0.2", + isConstant: true, + serializedName: "version", + type: { + name: "String" + } + }, + anyOf: { + serializedName: "anyOf", + type: { + name: "Sequence", + element: { + type: { name: "Composite", className: "KeyReleaseAuthority" } + } + } + } + } + } +}; + +export const KeyReleaseAuthority: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyReleaseAuthority", + modelProperties: { + authorityURL: { + constraints: { + MinLength: 1 + }, + serializedName: "authority", + type: { + name: "String" + } + }, + allOf: { + serializedName: "allOf", + type: { + name: "Sequence", + element: { + type: { name: "Composite", className: "KeyReleaseCondition" } + } + } + } + } + } +}; + +export const KeyReleaseCondition: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyReleaseCondition", + modelProperties: { + claimType: { + constraints: { + MinLength: 1 + }, + serializedName: "claim", + type: { + name: "String" + } + }, + claimCondition: { + defaultValue: "equals", + isConstant: true, + serializedName: "condition", + type: { + name: "String" + } + }, + value: { + serializedName: "value", type: { name: "String" } @@ -189,7 +222,6 @@ export const KeyAttributes: coreHttp.CompositeMapper = { }; export const KeyBundle: coreHttp.CompositeMapper = { - serializedName: "KeyBundle", type: { name: "Composite", className: "KeyBundle", @@ -212,29 +244,31 @@ export const KeyBundle: coreHttp.CompositeMapper = { serializedName: "tags", type: { name: "Dictionary", - value: { - type: { - name: "String" - } - } + value: { type: { name: "String" } } } }, managed: { - readOnly: true, serializedName: "managed", + readOnly: true, type: { name: "Boolean" } + }, + releasePolicy: { + serializedName: "release_policy", + type: { + name: "Composite", + className: "KeyReleasePolicy" + } } } } }; -export const KeyItem: coreHttp.CompositeMapper = { - serializedName: "KeyItem", +export const JsonWebKey: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyItem", + className: "JsonWebKey", modelProperties: { kid: { serializedName: "kid", @@ -242,168 +276,230 @@ export const KeyItem: coreHttp.CompositeMapper = { name: "String" } }, - attributes: { - serializedName: "attributes", + kty: { + serializedName: "kty", type: { - name: "Composite", - className: "KeyAttributes" + name: "String" } }, - tags: { - serializedName: "tags", + keyOps: { + serializedName: "key_ops", type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } + name: "Sequence", + element: { type: { name: "String" } } } }, - managed: { - readOnly: true, - serializedName: "managed", + n: { + serializedName: "n", type: { - name: "Boolean" + name: "Base64Url" + } + }, + e: { + serializedName: "e", + type: { + name: "Base64Url" + } + }, + d: { + serializedName: "d", + type: { + name: "Base64Url" + } + }, + dp: { + serializedName: "dp", + type: { + name: "Base64Url" + } + }, + dq: { + serializedName: "dq", + type: { + name: "Base64Url" + } + }, + qi: { + serializedName: "qi", + type: { + name: "Base64Url" + } + }, + p: { + serializedName: "p", + type: { + name: "Base64Url" + } + }, + q: { + serializedName: "q", + type: { + name: "Base64Url" + } + }, + k: { + serializedName: "k", + type: { + name: "Base64Url" + } + }, + t: { + serializedName: "key_hsm", + type: { + name: "Base64Url" + } + }, + crv: { + serializedName: "crv", + type: { + name: "String" + } + }, + x: { + serializedName: "x", + type: { + name: "Base64Url" + } + }, + y: { + serializedName: "y", + type: { + name: "Base64Url" } } } } }; -export const DeletedKeyBundle: coreHttp.CompositeMapper = { - serializedName: "DeletedKeyBundle", +export const KeyVaultError: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "DeletedKeyBundle", + className: "KeyVaultError", modelProperties: { - ...KeyBundle.type.modelProperties, - recoveryId: { - serializedName: "recoveryId", - type: { - name: "String" - } - }, - scheduledPurgeDate: { - readOnly: true, - serializedName: "scheduledPurgeDate", - type: { - name: "UnixTime" - } - }, - deletedDate: { - readOnly: true, - serializedName: "deletedDate", + error: { + serializedName: "error", type: { - name: "UnixTime" + name: "Composite", + className: "ErrorModel" } } } } }; -export const DeletedKeyItem: coreHttp.CompositeMapper = { - serializedName: "DeletedKeyItem", +export const ErrorModel: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "DeletedKeyItem", + className: "ErrorModel", modelProperties: { - ...KeyItem.type.modelProperties, - recoveryId: { - serializedName: "recoveryId", + code: { + serializedName: "code", + readOnly: true, type: { name: "String" } }, - scheduledPurgeDate: { + message: { + serializedName: "message", readOnly: true, - serializedName: "scheduledPurgeDate", type: { - name: "UnixTime" + name: "String" } }, - deletedDate: { - readOnly: true, - serializedName: "deletedDate", + innerError: { + serializedName: "innererror", type: { - name: "UnixTime" + name: "Composite", + className: "ErrorModel" } } } } }; -export const KeyProperties: coreHttp.CompositeMapper = { - serializedName: "KeyProperties", +export const KeyImportParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyProperties", + className: "KeyImportParameters", modelProperties: { - exportable: { - serializedName: "exportable", + hsm: { + serializedName: "Hsm", type: { name: "Boolean" } }, - keyType: { - serializedName: "kty", + key: { + serializedName: "key", type: { - name: "String" + name: "Composite", + className: "JsonWebKey" } }, - keySize: { - serializedName: "key_size", + keyAttributes: { + serializedName: "attributes", type: { - name: "Number" + name: "Composite", + className: "KeyAttributes" } }, - reuseKey: { - serializedName: "reuse_key", + tags: { + serializedName: "tags", type: { - name: "Boolean" + name: "Dictionary", + value: { type: { name: "String" } } } }, - curve: { - serializedName: "crv", + releasePolicy: { + serializedName: "release_policy", type: { - name: "String" + name: "Composite", + className: "KeyReleasePolicy" } } } } }; -export const KeyCreateParameters: coreHttp.CompositeMapper = { - serializedName: "KeyCreateParameters", +export const DeletedKeyBundle: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyCreateParameters", + className: "DeletedKeyBundle", modelProperties: { - kty: { - required: true, - serializedName: "kty", - constraints: { - MinLength: 1 - }, + ...KeyBundle.type.modelProperties, + recoveryId: { + serializedName: "recoveryId", type: { name: "String" } }, - keySize: { - serializedName: "key_size", + scheduledPurgeDate: { + serializedName: "scheduledPurgeDate", + readOnly: true, type: { - name: "Number" + name: "UnixTime" } }, + deletedDate: { + serializedName: "deletedDate", + readOnly: true, + type: { + name: "UnixTime" + } + } + } + } +}; + +export const KeyUpdateParameters: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyUpdateParameters", + modelProperties: { keyOps: { serializedName: "key_ops", type: { name: "Sequence", - element: { - type: { - name: "String" - } - } + element: { type: { name: "String" } } } }, keyAttributes: { @@ -416,16 +512,37 @@ export const KeyCreateParameters: coreHttp.CompositeMapper = { tags: { serializedName: "tags", type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + releasePolicy: { + serializedName: "release_policy", + type: { + name: "Composite", + className: "KeyReleasePolicy" + } + } + } + } +}; + +export const KeyListResult: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "KeyListResult", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { type: { name: "Composite", className: "KeyItem" } } } }, - curve: { - serializedName: "crv", + nextLink: { + serializedName: "nextLink", + readOnly: true, type: { name: "String" } @@ -434,27 +551,18 @@ export const KeyCreateParameters: coreHttp.CompositeMapper = { } }; -export const KeyImportParameters: coreHttp.CompositeMapper = { - serializedName: "KeyImportParameters", +export const KeyItem: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyImportParameters", + className: "KeyItem", modelProperties: { - hsm: { - serializedName: "Hsm", - type: { - name: "Boolean" - } - }, - key: { - required: true, - serializedName: "key", + kid: { + serializedName: "kid", type: { - name: "Composite", - className: "JsonWebKey" + name: "String" } }, - keyAttributes: { + attributes: { serializedName: "attributes", type: { name: "Composite", @@ -465,36 +573,28 @@ export const KeyImportParameters: coreHttp.CompositeMapper = { serializedName: "tags", type: { name: "Dictionary", - value: { - type: { - name: "String" - } - } + value: { type: { name: "String" } } + } + }, + managed: { + serializedName: "managed", + readOnly: true, + type: { + name: "Boolean" } } } } }; -export const KeyOperationsParameters: coreHttp.CompositeMapper = { - serializedName: "KeyOperationsParameters", +export const BackupKeyResult: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyOperationsParameters", + className: "BackupKeyResult", modelProperties: { - algorithm: { - required: true, - serializedName: "alg", - constraints: { - MinLength: 1 - }, - type: { - name: "String" - } - }, value: { - required: true, serializedName: "value", + readOnly: true, type: { name: "Base64Url" } @@ -503,25 +603,14 @@ export const KeyOperationsParameters: coreHttp.CompositeMapper = { } }; -export const KeySignParameters: coreHttp.CompositeMapper = { - serializedName: "KeySignParameters", +export const KeyRestoreParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeySignParameters", + className: "KeyRestoreParameters", modelProperties: { - algorithm: { - required: true, - serializedName: "alg", - constraints: { - MinLength: 1 - }, - type: { - name: "String" - } - }, - value: { - required: true, + keyBundleBackup: { serializedName: "value", + required: true, type: { name: "Base64Url" } @@ -530,32 +619,39 @@ export const KeySignParameters: coreHttp.CompositeMapper = { } }; -export const KeyVerifyParameters: coreHttp.CompositeMapper = { - serializedName: "KeyVerifyParameters", +export const KeyOperationsParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyVerifyParameters", + className: "KeyOperationsParameters", modelProperties: { algorithm: { - required: true, serializedName: "alg", - constraints: { - MinLength: 1 - }, + required: true, type: { name: "String" } }, - digest: { + value: { + serializedName: "value", required: true, - serializedName: "digest", type: { name: "Base64Url" } }, - signature: { - required: true, - serializedName: "value", + iv: { + serializedName: "iv", + type: { + name: "Base64Url" + } + }, + aad: { + serializedName: "aad", + type: { + name: "Base64Url" + } + }, + tag: { + serializedName: "tag", type: { name: "Base64Url" } @@ -564,54 +660,44 @@ export const KeyVerifyParameters: coreHttp.CompositeMapper = { } }; -export const KeyUpdateParameters: coreHttp.CompositeMapper = { - serializedName: "KeyUpdateParameters", +export const KeyOperationResult: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyUpdateParameters", + className: "KeyOperationResult", modelProperties: { - keyOps: { - serializedName: "key_ops", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - keyAttributes: { - serializedName: "attributes", + kid: { + serializedName: "kid", + readOnly: true, type: { - name: "Composite", - className: "KeyAttributes" + name: "String" } }, - tags: { - serializedName: "tags", + result: { + serializedName: "value", + readOnly: true, type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } + name: "Base64Url" } } } } }; -export const KeyRestoreParameters: coreHttp.CompositeMapper = { - serializedName: "KeyRestoreParameters", +export const KeySignParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyRestoreParameters", + className: "KeySignParameters", modelProperties: { - keyBundleBackup: { + algorithm: { + serializedName: "alg", required: true, + type: { + name: "String" + } + }, + value: { serializedName: "value", + required: true, type: { name: "Base64Url" } @@ -620,22 +706,28 @@ export const KeyRestoreParameters: coreHttp.CompositeMapper = { } }; -export const KeyOperationResult: coreHttp.CompositeMapper = { - serializedName: "KeyOperationResult", +export const KeyVerifyParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyOperationResult", + className: "KeyVerifyParameters", modelProperties: { - kid: { - readOnly: true, - serializedName: "kid", + algorithm: { + serializedName: "alg", + required: true, type: { name: "String" } }, - result: { - readOnly: true, + digest: { + serializedName: "digest", + required: true, + type: { + name: "Base64Url" + } + }, + signature: { serializedName: "value", + required: true, type: { name: "Base64Url" } @@ -645,14 +737,13 @@ export const KeyOperationResult: coreHttp.CompositeMapper = { }; export const KeyVerifyResult: coreHttp.CompositeMapper = { - serializedName: "KeyVerifyResult", type: { name: "Composite", className: "KeyVerifyResult", modelProperties: { value: { - readOnly: true, serializedName: "value", + readOnly: true, type: { name: "Boolean" } @@ -661,28 +752,17 @@ export const KeyVerifyResult: coreHttp.CompositeMapper = { } }; -export const KeyListResult: coreHttp.CompositeMapper = { - serializedName: "KeyListResult", +export const KeyExportParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyListResult", + className: "KeyExportParameters", modelProperties: { - value: { - readOnly: true, - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "KeyItem" - } - } - } - }, - nextLink: { - readOnly: true, - serializedName: "nextLink", + environment: { + constraints: { + MinLength: 1 + }, + serializedName: "env", + required: true, type: { name: "String" } @@ -692,27 +772,21 @@ export const KeyListResult: coreHttp.CompositeMapper = { }; export const DeletedKeyListResult: coreHttp.CompositeMapper = { - serializedName: "DeletedKeyListResult", type: { name: "Composite", className: "DeletedKeyListResult", modelProperties: { value: { - readOnly: true, serializedName: "value", + readOnly: true, type: { name: "Sequence", - element: { - type: { - name: "Composite", - className: "DeletedKeyItem" - } - } + element: { type: { name: "Composite", className: "DeletedKeyItem" } } } }, nextLink: { - readOnly: true, serializedName: "nextLink", + readOnly: true, type: { name: "String" } @@ -721,67 +795,69 @@ export const DeletedKeyListResult: coreHttp.CompositeMapper = { } }; -export const BackupKeyResult: coreHttp.CompositeMapper = { - serializedName: "BackupKeyResult", +export const DeletedKeyItem: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "BackupKeyResult", + className: "DeletedKeyItem", modelProperties: { - value: { + ...KeyItem.type.modelProperties, + recoveryId: { + serializedName: "recoveryId", + type: { + name: "String" + } + }, + scheduledPurgeDate: { + serializedName: "scheduledPurgeDate", readOnly: true, - serializedName: "value", type: { - name: "Base64Url" + name: "UnixTime" + } + }, + deletedDate: { + serializedName: "deletedDate", + readOnly: true, + type: { + name: "UnixTime" } } } } }; -export const ErrorModel: coreHttp.CompositeMapper = { - serializedName: "Error", +export const KeyProperties: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "ErrorModel", + className: "KeyProperties", modelProperties: { - code: { - readOnly: true, - serializedName: "code", + exportable: { + serializedName: "exportable", type: { - name: "String" + name: "Boolean" } }, - message: { - readOnly: true, - serializedName: "message", + keyType: { + serializedName: "kty", type: { name: "String" } }, - innerError: { - readOnly: true, - serializedName: "innererror", + keySize: { + serializedName: "key_size", type: { - name: "Composite", - className: "ErrorModel" + name: "Number" } - } - } - } -}; - -export const KeyVaultError: coreHttp.CompositeMapper = { - serializedName: "KeyVaultError", - type: { - name: "Composite", - className: "KeyVaultError", - modelProperties: { - error: { - readOnly: true, - serializedName: "error", + }, + reuseKey: { + serializedName: "reuse_key", type: { - name: "Composite", - className: "ErrorModel" + name: "Boolean" + } + }, + curve: { + serializedName: "crv", + type: { + name: "String" } } } diff --git a/sdk/keyvault/keyvault-keys/src/generated/models/parameters.ts b/sdk/keyvault/keyvault-keys/src/generated/models/parameters.ts new file mode 100644 index 000000000000..45903eccccf0 --- /dev/null +++ b/sdk/keyvault/keyvault-keys/src/generated/models/parameters.ts @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-http"; +import { + KeyCreateParameters as KeyCreateParametersMapper, + KeyImportParameters as KeyImportParametersMapper, + KeyUpdateParameters as KeyUpdateParametersMapper, + KeyRestoreParameters as KeyRestoreParametersMapper, + KeyOperationsParameters as KeyOperationsParametersMapper, + KeySignParameters as KeySignParametersMapper, + KeyVerifyParameters as KeyVerifyParametersMapper, + KeyExportParameters as KeyExportParametersMapper +} from "../models/mappers"; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const parameters: OperationParameter = { + parameterPath: "parameters", + mapper: KeyCreateParametersMapper +}; + +export const vaultBaseUrl: OperationURLParameter = { + parameterPath: "vaultBaseUrl", + mapper: { + serializedName: "vaultBaseUrl", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const keyName: OperationURLParameter = { + parameterPath: "keyName", + mapper: { + constraints: { + Pattern: new RegExp("^[0-9a-zA-Z-]+$") + }, + serializedName: "key-name", + required: true, + type: { + name: "String" + } + } +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "7.2-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const parameters1: OperationParameter = { + parameterPath: "parameters", + mapper: KeyImportParametersMapper +}; + +export const keyName1: OperationURLParameter = { + parameterPath: "keyName", + mapper: { + serializedName: "key-name", + required: true, + type: { + name: "String" + } + } +}; + +export const parameters2: OperationParameter = { + parameterPath: "parameters", + mapper: KeyUpdateParametersMapper +}; + +export const keyVersion: OperationURLParameter = { + parameterPath: "keyVersion", + mapper: { + serializedName: "key-version", + required: true, + type: { + name: "String" + } + } +}; + +export const maxresults: OperationQueryParameter = { + parameterPath: ["options", "maxresults"], + mapper: { + constraints: { + InclusiveMaximum: 25, + InclusiveMinimum: 1 + }, + serializedName: "maxresults", + type: { + name: "Number" + } + } +}; + +export const parameters3: OperationParameter = { + parameterPath: "parameters", + mapper: KeyRestoreParametersMapper +}; + +export const parameters4: OperationParameter = { + parameterPath: "parameters", + mapper: KeyOperationsParametersMapper +}; + +export const parameters5: OperationParameter = { + parameterPath: "parameters", + mapper: KeySignParametersMapper +}; + +export const parameters6: OperationParameter = { + parameterPath: "parameters", + mapper: KeyVerifyParametersMapper +}; + +export const parameters7: OperationParameter = { + parameterPath: "parameters", + mapper: KeyExportParametersMapper +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; diff --git a/sdk/keyvault/keyvault-keys/src/core/utils.ts b/sdk/keyvault/keyvault-keys/src/generated/utils.ts similarity index 94% rename from sdk/keyvault/keyvault-keys/src/core/utils.ts rename to sdk/keyvault/keyvault-keys/src/generated/utils.ts index d4427e7ccd8c..c9f31c847639 100644 --- a/sdk/keyvault/keyvault-keys/src/core/utils.ts +++ b/sdk/keyvault/keyvault-keys/src/generated/utils.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { ParsedKeyVaultEntityIdentifier } from "./keyVaultBase"; import * as url from "url"; diff --git a/sdk/keyvault/keyvault-keys/src/core/utils/constants.ts b/sdk/keyvault/keyvault-keys/src/generated/utils/constants.ts similarity index 60% rename from sdk/keyvault/keyvault-keys/src/core/utils/constants.ts rename to sdk/keyvault/keyvault-keys/src/generated/utils/constants.ts index 409e169dba81..193666ca942a 100644 --- a/sdk/keyvault/keyvault-keys/src/core/utils/constants.ts +++ b/sdk/keyvault/keyvault-keys/src/generated/utils/constants.ts @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. export const SDK_VERSION: string = "4.1.0-preview.2"; diff --git a/sdk/keyvault/keyvault-keys/src/index.ts b/sdk/keyvault/keyvault-keys/src/index.ts index f5412818a657..139a8c69b4c9 100644 --- a/sdk/keyvault/keyvault-keys/src/index.ts +++ b/sdk/keyvault/keyvault-keys/src/index.ts @@ -22,23 +22,24 @@ import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging"; import { PollerLike, PollOperationState } from "@azure/core-lro"; import { - BackupKeyResponse, - CreateKeyResponse, - DeleteKeyResponse, DeletedKeyBundle, DeletionRecoveryLevel, - GetDeletedKeyResponse, - GetKeyResponse, - ImportKeyResponse, KeyBundle, KeyItem, KeyVaultClientGetKeysOptionalParams, - RecoverDeletedKeyResponse, - RestoreKeyResponse, - UpdateKeyResponse -} from "./core/models"; -import { KeyVaultClient } from "./core/keyVaultClient"; -import { SDK_VERSION } from "./core/utils/constants"; + KeyVaultClientOptionalParams, + KeyVaultClientDeleteKeyResponse, + KeyVaultClientRecoverDeletedKeyResponse, + KeyVaultClientCreateKeyResponse, + KeyVaultClientImportKeyResponse, + KeyVaultClientUpdateKeyResponse, + KeyVaultClientGetKeyResponse, + KeyVaultClientGetDeletedKeyResponse, + KeyVaultClientBackupKeyResponse, + KeyVaultClientRestoreKeyResponse +} from "./generated/models"; +import { KeyVaultClient } from "./generated/keyVaultClient"; +import { SDK_VERSION } from "./generated/utils/constants"; import { challengeBasedAuthenticationPolicy } from "../../keyvault-common/src"; import { DeleteKeyPoller } from "./lro/delete/poller"; @@ -77,7 +78,7 @@ import { LATEST_API_VERSION, CryptographyClientOptions } from "./keysModels"; -import { parseKeyvaultIdentifier as parseKeyvaultEntityIdentifier } from "./core/utils"; +import { parseKeyvaultIdentifier as parseKeyvaultEntityIdentifier } from "./generated/utils"; import { CryptographyClient, @@ -238,11 +239,11 @@ export class KeyClient { } }; - const pipeline = createPipelineFromOptions(internalPipelineOptions, authPolicy); - this.client = new KeyVaultClient( - pipelineOptions.apiVersion || LATEST_API_VERSION, - pipeline - ); + const optionalParams: KeyVaultClientOptionalParams = { + ...createPipelineFromOptions(internalPipelineOptions, authPolicy), + apiVersion: pipelineOptions.apiVersion || LATEST_API_VERSION + }; + this.client = new KeyVaultClient(optionalParams); } /** @@ -257,7 +258,7 @@ export class KeyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("deleteKey", requestOptions); - let response: DeleteKeyResponse; + let response: KeyVaultClientDeleteKeyResponse; try { response = await this.client.deleteKey( this.vaultUrl, @@ -286,7 +287,7 @@ export class KeyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("recoverDeletedKey", requestOptions); - let response: RecoverDeletedKeyResponse; + let response: KeyVaultClientRecoverDeletedKeyResponse; try { response = await this.client.recoverDeletedKey( this.vaultUrl, @@ -335,13 +336,15 @@ export class KeyClient { const span = this.createSpan("createKey", unflattenedOptions); - let response: CreateKeyResponse; + let response: KeyVaultClientCreateKeyResponse; try { response = await this.client.createKey( this.vaultUrl, name, - keyType, + { + kty: keyType + }, this.setParentSpan(span, unflattenedOptions) ); } finally { @@ -349,7 +352,7 @@ export class KeyClient { } return this.getKeyFromKeyBundle(response); } else { - const response = await this.client.createKey(this.vaultUrl, name, keyType, options); + const response = await this.client.createKey(this.vaultUrl, name, { kty: keyType }, options); return this.getKeyFromKeyBundle(response); } } @@ -383,12 +386,14 @@ export class KeyClient { const span = this.createSpan("createEcKey", unflattenedOptions); - let response: CreateKeyResponse; + let response: KeyVaultClientCreateKeyResponse; try { response = await this.client.createKey( this.vaultUrl, name, - options.hsm ? "EC-HSM" : "EC", + { + kty: options.hsm ? "EC-HSM" : "EC" + }, this.setParentSpan(span, unflattenedOptions) ); } finally { @@ -397,7 +402,14 @@ export class KeyClient { return this.getKeyFromKeyBundle(response); } else { - const response = await this.client.createKey(this.vaultUrl, name, "EC", options); + const response = await this.client.createKey( + this.vaultUrl, + name, + { + kty: "EC" + }, + options + ); return this.getKeyFromKeyBundle(response); } } @@ -431,12 +443,14 @@ export class KeyClient { const span = this.createSpan("createRsaKey", unflattenedOptions); - let response: CreateKeyResponse; + let response: KeyVaultClientCreateKeyResponse; try { response = await this.client.createKey( this.vaultUrl, name, - options.hsm ? "RSA-HSM" : "RSA", + { + kty: options.hsm ? "RSA-HSM" : "RSA" + }, this.setParentSpan(span, unflattenedOptions) ); } finally { @@ -445,7 +459,7 @@ export class KeyClient { return this.getKeyFromKeyBundle(response); } else { - const response = await this.client.createKey(this.vaultUrl, name, "RSA", options); + const response = await this.client.createKey(this.vaultUrl, name, { kty: "RSA" }, options); return this.getKeyFromKeyBundle(response); } } @@ -493,12 +507,14 @@ export class KeyClient { const span = this.createSpan("importKey", unflattenedOptions); - let response: ImportKeyResponse; + let response: KeyVaultClientImportKeyResponse; try { response = await this.client.importKey( this.vaultUrl, name, - key, + { + key + }, this.setParentSpan(span, unflattenedOptions) ); } finally { @@ -507,7 +523,7 @@ export class KeyClient { return this.getKeyFromKeyBundle(response); } else { - const response = await this.client.importKey(this.vaultUrl, name, key, options); + const response = await this.client.importKey(this.vaultUrl, name, { key }, options); return this.getKeyFromKeyBundle(response); } } @@ -582,26 +598,26 @@ export class KeyClient { ): Promise { if (options) { const requestOptions = operationOptionsToRequestOptionsBase(options); - const { enabled, notBefore, expiresOn: expires, ...remainingOptions } = requestOptions; - const unflattenedOptions = { - ...remainingOptions, - keyAttributes: { - enabled, - notBefore, - expires - } - }; + const { keyOps, enabled, notBefore, expiresOn, tags } = requestOptions; - const span = this.createSpan("updateKeyProperties", unflattenedOptions); + const span = this.createSpan("updateKeyProperties", requestOptions); - let response: UpdateKeyResponse; + let response: KeyVaultClientUpdateKeyResponse; + const updateKeyParams: UpdateKeyPropertiesOptions = { + keyOps, + enabled, + notBefore, + expiresOn, + tags + }; try { response = await this.client.updateKey( this.vaultUrl, name, keyVersion, - this.setParentSpan(span, unflattenedOptions) + updateKeyParams, + this.setParentSpan(span, requestOptions) ); } finally { span.end(); @@ -609,7 +625,7 @@ export class KeyClient { return this.getKeyFromKeyBundle(response); } else { - const response = await this.client.updateKey(this.vaultUrl, name, keyVersion, options); + const response = await this.client.updateKey(this.vaultUrl, name, keyVersion, {}); return this.getKeyFromKeyBundle(response); } } @@ -631,7 +647,7 @@ export class KeyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("getKey", requestOptions); - let response: GetKeyResponse; + let response: KeyVaultClientGetKeyResponse; try { response = await this.client.getKey( this.vaultUrl, @@ -666,7 +682,7 @@ export class KeyClient { const responseOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("getDeletedKey", responseOptions); - let response: GetDeletedKeyResponse; + let response: KeyVaultClientGetDeletedKeyResponse; try { response = await this.client.getDeletedKey( this.vaultUrl, @@ -778,7 +794,7 @@ export class KeyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("backupKey", requestOptions); - let response: BackupKeyResponse; + let response: KeyVaultClientBackupKeyResponse; try { response = await this.client.backupKey( this.vaultUrl, @@ -814,11 +830,13 @@ export class KeyClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("restoreKeyBackup", requestOptions); - let response: RestoreKeyResponse; + let response: KeyVaultClientRestoreKeyResponse; try { response = await this.client.restoreKey( this.vaultUrl, - backup, + { + keyBundleBackup: backup + }, this.setParentSpan(span, requestOptions) ); } finally { diff --git a/sdk/keyvault/keyvault-keys/src/keysModels.ts b/sdk/keyvault/keyvault-keys/src/keysModels.ts index 0307cd8bc8d9..91432ab71352 100644 --- a/sdk/keyvault/keyvault-keys/src/keysModels.ts +++ b/sdk/keyvault/keyvault-keys/src/keysModels.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import * as coreHttp from "@azure/core-http"; -import { DeletionRecoveryLevel } from "./core/models"; +import { DeletionRecoveryLevel } from "./generated/models"; /** * Defines values for EncryptionAlgorithm. @@ -37,11 +37,11 @@ export type KeyOperation = /** * Defines values for KeyType. - * Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' + * Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct', 'oct-HSM' * @readonly * @enum {string} */ -export type KeyType = "EC" | "EC-HSM" | "RSA" | "RSA-HSM" | "oct"; +export type KeyType = "EC" | "EC-HSM" | "RSA" | "RSA-HSM" | "oct" | "oct-HSM"; /** * @internal diff --git a/sdk/keyvault/keyvault-keys/swagger/README.md b/sdk/keyvault/keyvault-keys/swagger/README.md index ea4fc2cedb7c..4978d4db6a2a 100644 --- a/sdk/keyvault/keyvault-keys/swagger/README.md +++ b/sdk/keyvault/keyvault-keys/swagger/README.md @@ -3,15 +3,14 @@ > see https://aka.ms/autorest ``` yaml -typescript: - package-name: "@azure/keyvault-keys" +package-name: "@azure/keyvault-admin" use-extension: - "@microsoft.azure/autorest.typescript": "~5.0.1" + "@autorest/typescript": "6.0.0-dev.20200623.2" azure-arm: false generate-metadata: false add-credentials: false license-header: MICROSOFT_MIT_NO_VERSION -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.1/keys.json +input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2-preview/keys.json output-folder: ../ -source-code-folder-path: ./src/core +source-code-folder-path: ./src/generated ``` diff --git a/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts b/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts index 6e5a998e6fc8..5dc88fdd1bf7 100644 --- a/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts @@ -3,8 +3,8 @@ import * as assert from "assert"; import { version } from "../../package.json"; -import { SDK_VERSION } from "../../src/core/utils/constants"; -import { packageVersion } from "../../src/core/keyVaultClientContext"; +import { SDK_VERSION } from "../../src/generated/utils/constants"; +import { packageVersion } from "../../src/generated/keyVaultClientContext"; describe("Keys client's user agent", () => { // The tests follow diff --git a/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts b/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts index 7afcc983bbc9..9783884811f6 100644 --- a/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts @@ -6,7 +6,12 @@ import { RestError } from "@azure/core-http"; import { AbortController } from "@azure/abort-controller"; import { env, Recorder } from "@azure/test-utils-recorder"; -import { KeyClient, CreateEcKeyOptions, UpdateKeyPropertiesOptions, GetKeyOptions } from "../../src"; +import { + KeyClient, + CreateEcKeyOptions, + UpdateKeyPropertiesOptions, + GetKeyOptions +} from "../../src"; import { assertThrowsAbortError } from "../utils/utils.common"; import { testPollerProperties } from "../utils/recorderUtils"; import { authenticate } from "../utils/testAuthentication"; diff --git a/sdk/keyvault/keyvault-keys/typedoc.json b/sdk/keyvault/keyvault-keys/typedoc.json index 3cf18e6dd77e..4b9d7ea9ac27 100644 --- a/sdk/keyvault/keyvault-keys/typedoc.json +++ b/sdk/keyvault/keyvault-keys/typedoc.json @@ -3,6 +3,6 @@ "out": "../../../docGen/keyvault-keys", "excludeNotExported": true, "excludePrivate": true, - "exclude": ["node_modules/**/*", "src/core/**/*"], + "exclude": ["node_modules/**/*", "src/generated/**/*"], "ignoreCompilerErrors": true }