diff --git a/sdk/keyvault/keyvault-secrets/.eslintrc.json b/sdk/keyvault/keyvault-secrets/.eslintrc.json index 4f409a486c3f..57874aa10492 100644 --- a/sdk/keyvault/keyvault-secrets/.eslintrc.json +++ b/sdk/keyvault/keyvault-secrets/.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-secrets/.prettierignore b/sdk/keyvault/keyvault-secrets/.prettierignore index 656f37824af2..6aa9def3bca0 100644 --- a/sdk/keyvault/keyvault-secrets/.prettierignore +++ b/sdk/keyvault/keyvault-secrets/.prettierignore @@ -1,2 +1 @@ -/src/core/* -!/src/core/challengeBasedAuthenticationPolicy.ts \ No newline at end of file +/src/generated/* \ No newline at end of file diff --git a/sdk/keyvault/keyvault-secrets/package.json b/sdk/keyvault/keyvault-secrets/package.json index 131b077da480..dc4a752e876c 100644 --- a/sdk/keyvault/keyvault-secrets/package.json +++ b/sdk/keyvault/keyvault-secrets/package.json @@ -65,7 +65,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", @@ -75,18 +75,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/abort-controller": "^1.0.0", "@azure/core-http": "^1.1.1", diff --git a/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md b/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md index 46304b991c7f..19b6c4ae593f 100644 --- a/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md +++ b/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md @@ -36,7 +36,7 @@ export interface DeletedSecret { } // @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 interface GetDeletedSecretOptions extends coreHttp.OperationOptions { diff --git a/sdk/keyvault/keyvault-secrets/src/core/keyVaultClient.ts b/sdk/keyvault/keyvault-secrets/src/core/keyVaultClient.ts deleted file mode 100644 index 3fa19da31748..000000000000 --- a/sdk/keyvault/keyvault-secrets/src/core/keyVaultClient.ts +++ /dev/null @@ -1,756 +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 SET operation adds a secret to the Azure Key Vault. If the named secret already exists, - * Azure Key Vault creates a new version of that secret. This operation requires the secrets/set - * permission. - * @summary Sets a secret in a specified key vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param value The value of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - setSecret(vaultBaseUrl: string, secretName: string, value: string, options?: Models.KeyVaultClientSetSecretOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param value The value of the secret. - * @param callback The callback - */ - setSecret(vaultBaseUrl: string, secretName: string, value: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param value The value of the secret. - * @param options The optional parameters - * @param callback The callback - */ - setSecret(vaultBaseUrl: string, secretName: string, value: string, options: Models.KeyVaultClientSetSecretOptionalParams, callback: coreHttp.ServiceCallback): void; - setSecret(vaultBaseUrl: string, secretName: string, value: string, options?: Models.KeyVaultClientSetSecretOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - value, - options - }, - setSecretOperationSpec, - callback) as Promise; - } - - /** - * The DELETE operation applies to any secret stored in Azure Key Vault. DELETE cannot be applied - * to an individual version of a secret. This operation requires the secrets/delete permission. - * @summary Deletes a secret from a specified key vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - deleteSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param callback The callback - */ - deleteSecret(vaultBaseUrl: string, secretName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param options The optional parameters - * @param callback The callback - */ - deleteSecret(vaultBaseUrl: string, secretName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - deleteSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - options - }, - deleteSecretOperationSpec, - callback) as Promise; - } - - /** - * The UPDATE operation changes specified attributes of an existing stored secret. Attributes that - * are not specified in the request are left unchanged. The value of a secret itself cannot be - * changed. This operation requires the secrets/set permission. - * @summary Updates the attributes associated with a specified secret in a given key vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param secretVersion The version of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - updateSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, options?: Models.KeyVaultClientUpdateSecretOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param secretVersion The version of the secret. - * @param callback The callback - */ - updateSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param secretVersion The version of the secret. - * @param options The optional parameters - * @param callback The callback - */ - updateSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, options: Models.KeyVaultClientUpdateSecretOptionalParams, callback: coreHttp.ServiceCallback): void; - updateSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, options?: Models.KeyVaultClientUpdateSecretOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - secretVersion, - options - }, - updateSecretOperationSpec, - callback) as Promise; - } - - /** - * The GET operation is applicable to any secret stored in Azure Key Vault. This operation requires - * the secrets/get permission. - * @summary Get a specified secret from a given key vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param secretVersion The version of the secret. This URI fragment is optional. If not specified, - * the latest version of the secret is returned. - * @param [options] The optional parameters - * @returns Promise - */ - getSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param secretVersion The version of the secret. This URI fragment is optional. If not specified, - * the latest version of the secret is returned. - * @param callback The callback - */ - getSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param secretVersion The version of the secret. This URI fragment is optional. If not specified, - * the latest version of the secret is returned. - * @param options The optional parameters - * @param callback The callback - */ - getSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - getSecret(vaultBaseUrl: string, secretName: string, secretVersion: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - secretVersion, - options - }, - getSecretOperationSpec, - callback) as Promise; - } - - /** - * The Get Secrets operation is applicable to the entire vault. However, only the base secret - * identifier and its attributes are provided in the response. Individual secret versions are not - * listed in the response. This operation requires the secrets/list permission. - * @summary List secrets in a specified key vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param [options] The optional parameters - * @returns Promise - */ - getSecrets(vaultBaseUrl: string, options?: Models.KeyVaultClientGetSecretsOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param callback The callback - */ - getSecrets(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 - */ - getSecrets(vaultBaseUrl: string, options: Models.KeyVaultClientGetSecretsOptionalParams, callback: coreHttp.ServiceCallback): void; - getSecrets(vaultBaseUrl: string, options?: Models.KeyVaultClientGetSecretsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - options - }, - getSecretsOperationSpec, - callback) as Promise; - } - - /** - * The full secret identifier and attributes are provided in the response. No values are returned - * for the secrets. This operations requires the secrets/list permission. - * @summary List all versions of the specified secret. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - getSecretVersions(vaultBaseUrl: string, secretName: string, options?: Models.KeyVaultClientGetSecretVersionsOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param callback The callback - */ - getSecretVersions(vaultBaseUrl: string, secretName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param options The optional parameters - * @param callback The callback - */ - getSecretVersions(vaultBaseUrl: string, secretName: string, options: Models.KeyVaultClientGetSecretVersionsOptionalParams, callback: coreHttp.ServiceCallback): void; - getSecretVersions(vaultBaseUrl: string, secretName: string, options?: Models.KeyVaultClientGetSecretVersionsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - options - }, - getSecretVersionsOperationSpec, - callback) as Promise; - } - - /** - * The Get Deleted Secrets operation returns the secrets that have been deleted for a vault enabled - * for soft-delete. This operation requires the secrets/list permission. - * @summary Lists deleted secrets for the specified vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param [options] The optional parameters - * @returns Promise - */ - getDeletedSecrets(vaultBaseUrl: string, options?: Models.KeyVaultClientGetDeletedSecretsOptionalParams): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param callback The callback - */ - getDeletedSecrets(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 - */ - getDeletedSecrets(vaultBaseUrl: string, options: Models.KeyVaultClientGetDeletedSecretsOptionalParams, callback: coreHttp.ServiceCallback): void; - getDeletedSecrets(vaultBaseUrl: string, options?: Models.KeyVaultClientGetDeletedSecretsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - options - }, - getDeletedSecretsOperationSpec, - callback) as Promise; - } - - /** - * The Get Deleted Secret operation returns the specified deleted secret along with its attributes. - * This operation requires the secrets/get permission. - * @summary Gets the specified deleted secret. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - getDeletedSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param callback The callback - */ - getDeletedSecret(vaultBaseUrl: string, secretName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param options The optional parameters - * @param callback The callback - */ - getDeletedSecret(vaultBaseUrl: string, secretName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - getDeletedSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - options - }, - getDeletedSecretOperationSpec, - callback) as Promise; - } - - /** - * The purge deleted secret operation removes the secret permanently, without the possibility of - * recovery. This operation can only be enabled on a soft-delete enabled vault. This operation - * requires the secrets/purge permission. - * @summary Permanently deletes the specified secret. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - purgeDeletedSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param callback The callback - */ - purgeDeletedSecret(vaultBaseUrl: string, secretName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param options The optional parameters - * @param callback The callback - */ - purgeDeletedSecret(vaultBaseUrl: string, secretName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - purgeDeletedSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - options - }, - purgeDeletedSecretOperationSpec, - callback); - } - - /** - * Recovers the deleted secret in the specified vault. This operation can only be performed on a - * soft-delete enabled vault. This operation requires the secrets/recover permission. - * @summary Recovers the deleted secret to the latest version. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the deleted secret. - * @param [options] The optional parameters - * @returns Promise - */ - recoverDeletedSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the deleted secret. - * @param callback The callback - */ - recoverDeletedSecret(vaultBaseUrl: string, secretName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the deleted secret. - * @param options The optional parameters - * @param callback The callback - */ - recoverDeletedSecret(vaultBaseUrl: string, secretName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - recoverDeletedSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - options - }, - recoverDeletedSecretOperationSpec, - callback) as Promise; - } - - /** - * Requests that a backup of the specified secret be downloaded to the client. All versions of the - * secret will be downloaded. This operation requires the secrets/backup permission. - * @summary Backs up the specified secret. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param [options] The optional parameters - * @returns Promise - */ - backupSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param callback The callback - */ - backupSecret(vaultBaseUrl: string, secretName: string, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretName The name of the secret. - * @param options The optional parameters - * @param callback The callback - */ - backupSecret(vaultBaseUrl: string, secretName: string, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - backupSecret(vaultBaseUrl: string, secretName: string, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretName, - options - }, - backupSecretOperationSpec, - callback) as Promise; - } - - /** - * Restores a backed up secret, and all its versions, to a vault. This operation requires the - * secrets/restore permission. - * @summary Restores a backed up secret to a vault. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretBundleBackup The backup blob associated with a secret bundle. - * @param [options] The optional parameters - * @returns Promise - */ - restoreSecret(vaultBaseUrl: string, secretBundleBackup: Uint8Array, options?: coreHttp.RequestOptionsBase): Promise; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretBundleBackup The backup blob associated with a secret bundle. - * @param callback The callback - */ - restoreSecret(vaultBaseUrl: string, secretBundleBackup: Uint8Array, callback: coreHttp.ServiceCallback): void; - /** - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param secretBundleBackup The backup blob associated with a secret bundle. - * @param options The optional parameters - * @param callback The callback - */ - restoreSecret(vaultBaseUrl: string, secretBundleBackup: Uint8Array, options: coreHttp.RequestOptionsBase, callback: coreHttp.ServiceCallback): void; - restoreSecret(vaultBaseUrl: string, secretBundleBackup: Uint8Array, options?: coreHttp.RequestOptionsBase | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { - return this.sendOperationRequest( - { - vaultBaseUrl, - secretBundleBackup, - options - }, - restoreSecretOperationSpec, - callback) as Promise; - } -} - -// Operation Specifications -const serializer = new coreHttp.Serializer(Mappers); -const setSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "PUT", - path: "secrets/{secret-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName0 - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - value: "value", - tags: [ - "options", - "tags" - ], - contentType: [ - "options", - "contentType" - ], - secretAttributes: [ - "options", - "secretAttributes" - ] - }, - mapper: { - ...Mappers.SecretSetParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.SecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const deleteSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "DELETE", - path: "secrets/{secret-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.DeletedSecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const updateSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "PATCH", - path: "secrets/{secret-name}/{secret-version}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1, - Parameters.secretVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - contentType: [ - "options", - "contentType" - ], - secretAttributes: [ - "options", - "secretAttributes" - ], - tags: [ - "options", - "tags" - ] - }, - mapper: { - ...Mappers.SecretUpdateParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.SecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "secrets/{secret-name}/{secret-version}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1, - Parameters.secretVersion - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.SecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getSecretsOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "secrets", - urlParameters: [ - Parameters.vaultBaseUrl - ], - queryParameters: [ - Parameters.maxresults, - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.SecretListResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getSecretVersionsOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "secrets/{secret-name}/versions", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1 - ], - queryParameters: [ - Parameters.maxresults, - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.SecretListResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getDeletedSecretsOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "deletedsecrets", - urlParameters: [ - Parameters.vaultBaseUrl - ], - queryParameters: [ - Parameters.maxresults, - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.DeletedSecretListResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const getDeletedSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "GET", - path: "deletedsecrets/{secret-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.DeletedSecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const purgeDeletedSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "DELETE", - path: "deletedsecrets/{secret-name}", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 204: {}, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const recoverDeletedSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "deletedsecrets/{secret-name}/recover", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.SecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const backupSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "secrets/{secret-name}/backup", - urlParameters: [ - Parameters.vaultBaseUrl, - Parameters.secretName1 - ], - queryParameters: [ - Parameters.apiVersion - ], - responses: { - 200: { - bodyMapper: Mappers.BackupSecretResult - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -const restoreSecretOperationSpec: coreHttp.OperationSpec = { - httpMethod: "POST", - path: "secrets/restore", - urlParameters: [ - Parameters.vaultBaseUrl - ], - queryParameters: [ - Parameters.apiVersion - ], - requestBody: { - parameterPath: { - secretBundleBackup: "secretBundleBackup" - }, - mapper: { - ...Mappers.SecretRestoreParameters, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.SecretBundle - }, - default: { - bodyMapper: Mappers.KeyVaultError - } - }, - serializer -}; - -export { - KeyVaultClient, - KeyVaultClientContext, - Models as KeyVaultModels, - Mappers as KeyVaultMappers -}; diff --git a/sdk/keyvault/keyvault-secrets/src/core/models/index.ts b/sdk/keyvault/keyvault-secrets/src/core/models/index.ts deleted file mode 100644 index c3a68b89563a..000000000000 --- a/sdk/keyvault/keyvault-secrets/src/core/models/index.ts +++ /dev/null @@ -1,601 +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"; - -/** - * 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 secret management attributes. - */ -export interface SecretAttributes 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 secrets in the current vault. If - * it contains 'Purgeable', the secret can be permanently deleted by a privileged user; - * otherwise, only the system can purge the secret, 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 secret consisting of a value, id and its attributes. - */ -export interface SecretBundle { - /** - * The secret value. - */ - value?: string; - /** - * The secret id. - */ - id?: string; - /** - * The content type of the secret. - */ - contentType?: string; - /** - * The secret management attributes. - */ - attributes?: SecretAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * If this is a secret backing a KV certificate, then this field specifies the corresponding key - * backing the KV certificate. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly kid?: string; - /** - * True if the secret's lifetime is managed by key vault. If this is a secret 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 secret item containing secret metadata. - */ -export interface SecretItem { - /** - * Secret identifier. - */ - id?: string; - /** - * The secret management attributes. - */ - attributes?: SecretAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * Type of the secret value such as a password. - */ - contentType?: string; - /** - * True if the secret'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 Deleted Secret consisting of its previous id, attributes and its tags, as well as information - * on when it will be purged. - */ -export interface DeletedSecretBundle extends SecretBundle { - /** - * The url of the recovery object, used to identify and recover the deleted secret. - */ - recoveryId?: string; - /** - * The time when the secret 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 secret was deleted, in UTC - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly deletedDate?: Date; -} - -/** - * The deleted secret item containing metadata about the deleted secret. - */ -export interface DeletedSecretItem extends SecretItem { - /** - * The url of the recovery object, used to identify and recover the deleted secret. - */ - recoveryId?: string; - /** - * The time when the secret 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 secret was deleted, in UTC - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly deletedDate?: Date; -} - -/** - * The secret restore parameters. - */ -export interface SecretRestoreParameters { - /** - * The backup blob associated with a secret bundle. - */ - secretBundleBackup: Uint8Array; -} - -/** - * Properties of the key backing a certificate. - */ -export interface SecretProperties { - /** - * The media type (MIME type). - */ - contentType?: string; -} - -/** - * The secret set parameters. - */ -export interface SecretSetParameters { - /** - * The value of the secret. - */ - value: string; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * Type of the secret value such as a password. - */ - contentType?: string; - /** - * The secret management attributes. - */ - secretAttributes?: SecretAttributes; -} - -/** - * The secret update parameters. - */ -export interface SecretUpdateParameters { - /** - * Type of the secret value such as a password. - */ - contentType?: string; - /** - * The secret management attributes. - */ - secretAttributes?: SecretAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; -} - -/** - * The secret list result. - */ -export interface SecretListResult { - /** - * A response message containing a list of secrets in the key vault along with a link to the next - * page of secrets. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: SecretItem[]; - /** - * The URL to get the next set of secrets. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly nextLink?: string; -} - -/** - * The deleted secret list result - */ -export interface DeletedSecretListResult { - /** - * A response message containing a list of the deleted secrets in the vault along with a link to - * the next page of deleted secrets - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: DeletedSecretItem[]; - /** - * The URL to get the next set of deleted secrets. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly nextLink?: string; -} - -/** - * The backup secret result, containing the backup blob. - */ -export interface BackupSecretResult { - /** - * The backup blob containing the backed up secret. - * **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 KeyVaultClientSetSecretOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; - /** - * Type of the secret value such as a password. - */ - contentType?: string; - /** - * The secret management attributes. - */ - secretAttributes?: SecretAttributes; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientUpdateSecretOptionalParams extends coreHttp.RequestOptionsBase { - /** - * Type of the secret value such as a password. - */ - contentType?: string; - /** - * The secret management attributes. - */ - secretAttributes?: SecretAttributes; - /** - * Application specific metadata in the form of key-value pairs. - */ - tags?: { [propertyName: string]: string }; -} - -/** - * Optional Parameters. - */ -export interface KeyVaultClientGetSecretsOptionalParams 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 KeyVaultClientGetSecretVersionsOptionalParams 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 KeyVaultClientGetDeletedSecretsOptionalParams 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 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'; - -/** - * Contains response data for the setSecret operation. - */ -export type SetSecretResponse = SecretBundle & { - /** - * 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: SecretBundle; - }; -}; - -/** - * Contains response data for the deleteSecret operation. - */ -export type DeleteSecretResponse = DeletedSecretBundle & { - /** - * 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: DeletedSecretBundle; - }; -}; - -/** - * Contains response data for the updateSecret operation. - */ -export type UpdateSecretResponse = SecretBundle & { - /** - * 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: SecretBundle; - }; -}; - -/** - * Contains response data for the getSecret operation. - */ -export type GetSecretResponse = SecretBundle & { - /** - * 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: SecretBundle; - }; -}; - -/** - * Contains response data for the getSecrets operation. - */ -export type GetSecretsResponse = SecretListResult & { - /** - * 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: SecretListResult; - }; -}; - -/** - * Contains response data for the getSecretVersions operation. - */ -export type GetSecretVersionsResponse = SecretListResult & { - /** - * 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: SecretListResult; - }; -}; - -/** - * Contains response data for the getDeletedSecrets operation. - */ -export type GetDeletedSecretsResponse = DeletedSecretListResult & { - /** - * 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: DeletedSecretListResult; - }; -}; - -/** - * Contains response data for the getDeletedSecret operation. - */ -export type GetDeletedSecretResponse = DeletedSecretBundle & { - /** - * 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: DeletedSecretBundle; - }; -}; - -/** - * Contains response data for the recoverDeletedSecret operation. - */ -export type RecoverDeletedSecretResponse = SecretBundle & { - /** - * 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: SecretBundle; - }; -}; - -/** - * Contains response data for the backupSecret operation. - */ -export type BackupSecretResponse = BackupSecretResult & { - /** - * 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: BackupSecretResult; - }; -}; - -/** - * Contains response data for the restoreSecret operation. - */ -export type RestoreSecretResponse = SecretBundle & { - /** - * 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: SecretBundle; - }; -}; diff --git a/sdk/keyvault/keyvault-secrets/src/core/models/parameters.ts b/sdk/keyvault/keyvault-secrets/src/core/models/parameters.ts deleted file mode 100644 index fffe35999a9d..000000000000 --- a/sdk/keyvault/keyvault-secrets/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 maxresults: coreHttp.OperationQueryParameter = { - parameterPath: [ - "options", - "maxresults" - ], - mapper: { - serializedName: "maxresults", - constraints: { - InclusiveMaximum: 25, - InclusiveMinimum: 1 - }, - type: { - name: "Number" - } - } -}; -export const secretName0: coreHttp.OperationURLParameter = { - parameterPath: "secretName", - mapper: { - required: true, - serializedName: "secret-name", - constraints: { - Pattern: /^[0-9a-zA-Z-]+$/ - }, - type: { - name: "String" - } - } -}; -export const secretName1: coreHttp.OperationURLParameter = { - parameterPath: "secretName", - mapper: { - required: true, - serializedName: "secret-name", - type: { - name: "String" - } - } -}; -export const secretVersion: coreHttp.OperationURLParameter = { - parameterPath: "secretVersion", - mapper: { - required: true, - serializedName: "secret-version", - type: { - name: "String" - } - } -}; -export const vaultBaseUrl: coreHttp.OperationURLParameter = { - parameterPath: "vaultBaseUrl", - mapper: { - required: true, - serializedName: "vaultBaseUrl", - defaultValue: '', - type: { - name: "String" - } - }, - skipEncoding: true -}; diff --git a/sdk/keyvault/keyvault-secrets/src/core/index.ts b/sdk/keyvault/keyvault-secrets/src/generated/index.ts similarity index 100% rename from sdk/keyvault/keyvault-secrets/src/core/index.ts rename to sdk/keyvault/keyvault-secrets/src/generated/index.ts diff --git a/sdk/keyvault/keyvault-secrets/src/core/keyVaultBase.ts b/sdk/keyvault/keyvault-secrets/src/generated/keyVaultBase.ts similarity index 100% rename from sdk/keyvault/keyvault-secrets/src/core/keyVaultBase.ts rename to sdk/keyvault/keyvault-secrets/src/generated/keyVaultBase.ts diff --git a/sdk/keyvault/keyvault-secrets/src/generated/keyVaultClient.ts b/sdk/keyvault/keyvault-secrets/src/generated/keyVaultClient.ts new file mode 100644 index 000000000000..58ec83585a1d --- /dev/null +++ b/sdk/keyvault/keyvault-secrets/src/generated/keyVaultClient.ts @@ -0,0 +1,634 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * 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, + SecretSetParameters, + KeyVaultClientSetSecretResponse, + KeyVaultClientDeleteSecretResponse, + SecretUpdateParameters, + KeyVaultClientUpdateSecretResponse, + KeyVaultClientGetSecretResponse, + KeyVaultClientGetSecretsOptionalParams, + KeyVaultClientGetSecretsResponse, + KeyVaultClientGetSecretVersionsOptionalParams, + KeyVaultClientGetSecretVersionsResponse, + KeyVaultClientGetDeletedSecretsOptionalParams, + KeyVaultClientGetDeletedSecretsResponse, + KeyVaultClientGetDeletedSecretResponse, + KeyVaultClientRecoverDeletedSecretResponse, + KeyVaultClientBackupSecretResponse, + SecretRestoreParameters, + KeyVaultClientRestoreSecretResponse, + KeyVaultClientGetSecretsNextOptionalParams, + KeyVaultClientGetSecretsNextResponse, + KeyVaultClientGetSecretVersionsNextOptionalParams, + KeyVaultClientGetSecretVersionsNextResponse, + KeyVaultClientGetDeletedSecretsNextOptionalParams, + KeyVaultClientGetDeletedSecretsNextResponse +} 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 SET operation adds a secret to the Azure Key Vault. If the named secret already exists, Azure + * Key Vault creates a new version of that secret. This operation requires the secrets/set permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param parameters The parameters for setting the secret. + * @param options The options parameters. + */ + setSecret( + vaultBaseUrl: string, + secretName: string, + parameters: SecretSetParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, parameters, options: operationOptions }, + setSecretOperationSpec + ) as Promise; + } + + /** + * The DELETE operation applies to any secret stored in Azure Key Vault. DELETE cannot be applied to an + * individual version of a secret. This operation requires the secrets/delete permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param options The options parameters. + */ + deleteSecret( + vaultBaseUrl: string, + secretName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, options: operationOptions }, + deleteSecretOperationSpec + ) as Promise; + } + + /** + * The UPDATE operation changes specified attributes of an existing stored secret. Attributes that are + * not specified in the request are left unchanged. The value of a secret itself cannot be changed. + * This operation requires the secrets/set permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. + * @param parameters The parameters for update secret operation. + * @param options The options parameters. + */ + updateSecret( + vaultBaseUrl: string, + secretName: string, + secretVersion: string, + parameters: SecretUpdateParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { + vaultBaseUrl, + secretName, + secretVersion, + parameters, + options: operationOptions + }, + updateSecretOperationSpec + ) as Promise; + } + + /** + * The GET operation is applicable to any secret stored in Azure Key Vault. This operation requires the + * secrets/get permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. This URI fragment is optional. If not specified, the + * latest version of the secret is returned. + * @param options The options parameters. + */ + getSecret( + vaultBaseUrl: string, + secretName: string, + secretVersion: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, secretVersion, options: operationOptions }, + getSecretOperationSpec + ) as Promise; + } + + /** + * The Get Secrets operation is applicable to the entire vault. However, only the base secret + * identifier and its attributes are provided in the response. Individual secret versions are not + * listed in the response. This operation requires the secrets/list permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param options The options parameters. + */ + getSecrets( + vaultBaseUrl: string, + options?: KeyVaultClientGetSecretsOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, options: operationOptions }, + getSecretsOperationSpec + ) as Promise; + } + + /** + * The full secret identifier and attributes are provided in the response. No values are returned for + * the secrets. This operations requires the secrets/list permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param options The options parameters. + */ + getSecretVersions( + vaultBaseUrl: string, + secretName: string, + options?: KeyVaultClientGetSecretVersionsOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, options: operationOptions }, + getSecretVersionsOperationSpec + ) as Promise; + } + + /** + * The Get Deleted Secrets operation returns the secrets that have been deleted for a vault enabled for + * soft-delete. This operation requires the secrets/list permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param options The options parameters. + */ + getDeletedSecrets( + vaultBaseUrl: string, + options?: KeyVaultClientGetDeletedSecretsOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, options: operationOptions }, + getDeletedSecretsOperationSpec + ) as Promise; + } + + /** + * The Get Deleted Secret operation returns the specified deleted secret along with its attributes. + * This operation requires the secrets/get permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param options The options parameters. + */ + getDeletedSecret( + vaultBaseUrl: string, + secretName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, options: operationOptions }, + getDeletedSecretOperationSpec + ) as Promise; + } + + /** + * The purge deleted secret operation removes the secret permanently, without the possibility of + * recovery. This operation can only be enabled on a soft-delete enabled vault. This operation requires + * the secrets/purge permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param options The options parameters. + */ + purgeDeletedSecret( + vaultBaseUrl: string, + secretName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, options: operationOptions }, + purgeDeletedSecretOperationSpec + ) as Promise; + } + + /** + * Recovers the deleted secret in the specified vault. This operation can only be performed on a + * soft-delete enabled vault. This operation requires the secrets/recover permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the deleted secret. + * @param options The options parameters. + */ + recoverDeletedSecret( + vaultBaseUrl: string, + secretName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, options: operationOptions }, + recoverDeletedSecretOperationSpec + ) as Promise; + } + + /** + * Requests that a backup of the specified secret be downloaded to the client. All versions of the + * secret will be downloaded. This operation requires the secrets/backup permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param options The options parameters. + */ + backupSecret( + vaultBaseUrl: string, + secretName: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, options: operationOptions }, + backupSecretOperationSpec + ) as Promise; + } + + /** + * Restores a backed up secret, and all its versions, to a vault. This operation requires the + * secrets/restore permission. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param parameters The parameters to restore the secret. + * @param options The options parameters. + */ + restoreSecret( + vaultBaseUrl: string, + parameters: SecretRestoreParameters, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, parameters, options: operationOptions }, + restoreSecretOperationSpec + ) as Promise; + } + + /** + * GetSecretsNext + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param nextLink The nextLink from the previous successful call to the GetSecrets method. + * @param options The options parameters. + */ + getSecretsNext( + vaultBaseUrl: string, + nextLink: string, + options?: KeyVaultClientGetSecretsNextOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, nextLink, options: operationOptions }, + getSecretsNextOperationSpec + ) as Promise; + } + + /** + * GetSecretVersionsNext + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param nextLink The nextLink from the previous successful call to the GetSecretVersions method. + * @param options The options parameters. + */ + getSecretVersionsNext( + vaultBaseUrl: string, + secretName: string, + nextLink: string, + options?: KeyVaultClientGetSecretVersionsNextOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, secretName, nextLink, options: operationOptions }, + getSecretVersionsNextOperationSpec + ) as Promise; + } + + /** + * GetDeletedSecretsNext + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param nextLink The nextLink from the previous successful call to the GetDeletedSecrets method. + * @param options The options parameters. + */ + getDeletedSecretsNext( + vaultBaseUrl: string, + nextLink: string, + options?: KeyVaultClientGetDeletedSecretsNextOptionalParams + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.sendOperationRequest( + { vaultBaseUrl, nextLink, options: operationOptions }, + getDeletedSecretsNextOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const setSecretOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/{secret-name}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.SecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const deleteSecretOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/{secret-name}", + httpMethod: "DELETE", + responses: { + 200: { + bodyMapper: Mappers.DeletedSecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName1], + serializer +}; +const updateSecretOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/{secret-name}/{secret-version}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.SecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters1, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.secretName1, + Parameters.secretVersion + ], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const getSecretOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/{secret-name}/{secret-version}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.secretName1, + Parameters.secretVersion + ], + serializer +}; +const getSecretsOperationSpec: coreHttp.OperationSpec = { + path: "/secrets", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SecretListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl], + serializer +}; +const getSecretVersionsOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/{secret-name}/versions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SecretListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName1], + serializer +}; +const getDeletedSecretsOperationSpec: coreHttp.OperationSpec = { + path: "/deletedsecrets", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DeletedSecretListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl], + serializer +}; +const getDeletedSecretOperationSpec: coreHttp.OperationSpec = { + path: "/deletedsecrets/{secret-name}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DeletedSecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName1], + serializer +}; +const purgeDeletedSecretOperationSpec: coreHttp.OperationSpec = { + path: "/deletedsecrets/{secret-name}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName1], + serializer +}; +const recoverDeletedSecretOperationSpec: coreHttp.OperationSpec = { + path: "/deletedsecrets/{secret-name}/recover", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.SecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName1], + serializer +}; +const backupSecretOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/{secret-name}/backup", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.BackupSecretResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl, Parameters.secretName1], + serializer +}; +const restoreSecretOperationSpec: coreHttp.OperationSpec = { + path: "/secrets/restore", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.SecretBundle + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + requestBody: Parameters.parameters2, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.vaultBaseUrl], + headerParameters: [Parameters.contentType], + mediaType: "json", + serializer +}; +const getSecretsNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SecretListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [Parameters.vaultBaseUrl, Parameters.nextLink], + serializer +}; +const getSecretVersionsNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SecretListResult + }, + default: { + bodyMapper: Mappers.KeyVaultError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.maxresults], + urlParameters: [ + Parameters.vaultBaseUrl, + Parameters.secretName1, + Parameters.nextLink + ], + serializer +}; +const getDeletedSecretsNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DeletedSecretListResult + }, + 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-secrets/src/core/keyVaultClientContext.ts b/sdk/keyvault/keyvault-secrets/src/generated/keyVaultClientContext.ts similarity index 60% rename from sdk/keyvault/keyvault-secrets/src/core/keyVaultClientContext.ts rename to sdk/keyvault/keyvault-secrets/src/generated/keyVaultClientContext.ts index ac83bb2f98ce..ab4756464d7b 100644 --- a/sdk/keyvault/keyvault-secrets/src/core/keyVaultClientContext.ts +++ b/sdk/keyvault/keyvault-secrets/src/generated/keyVaultClientContext.ts @@ -1,14 +1,13 @@ /* - * 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. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import * as coreHttp from "@azure/core-http"; +import { KeyVaultClientOptionalParams } from "./models"; const packageName = "@azure/keyvault-secrets"; export const packageVersion = "4.1.0-preview.2"; @@ -18,14 +17,10 @@ export class KeyVaultClientContext extends coreHttp.ServiceClient { /** * Initializes a new instance of the KeyVaultClientContext class. - * @param apiVersion Client API version. - * @param [options] The parameter options + * @param options The parameter options */ - constructor(apiVersion: string, options?: coreHttp.ServiceClientOptions) { - if (apiVersion == undefined) { - throw new Error("'apiVersion' cannot be null."); - } - + constructor(options?: KeyVaultClientOptionalParams) { + // Initializing default values for options if (!options) { options = {}; } @@ -37,8 +32,11 @@ export class KeyVaultClientContext extends coreHttp.ServiceClient { super(undefined, options); - this.baseUri = "{vaultBaseUrl}"; this.requestContentType = "application/json; charset=utf-8"; - this.apiVersion = apiVersion; + + this.baseUri = options.endpoint || "{vaultBaseUrl}"; + + // Assigning values to Constant parameters + this.apiVersion = options.apiVersion || "7.2-preview"; } } diff --git a/sdk/keyvault/keyvault-secrets/src/generated/models/index.ts b/sdk/keyvault/keyvault-secrets/src/generated/models/index.ts new file mode 100644 index 000000000000..94bff45ff05e --- /dev/null +++ b/sdk/keyvault/keyvault-secrets/src/generated/models/index.ts @@ -0,0 +1,644 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; + +/** + * The secret set parameters. + */ +export interface SecretSetParameters { + /** + * The value of the secret. + */ + value: string; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * Type of the secret value such as a password. + */ + contentType?: string; + /** + * The secret management attributes. + */ + secretAttributes?: SecretAttributes; +} + +/** + * 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 secret management attributes. + */ +export type SecretAttributes = 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 secrets in the current vault. If it contains 'Purgeable', the secret can be permanently deleted by a privileged user; otherwise, only the system can purge the secret, at the end of the retention interval. + */ + readonly recoveryLevel?: DeletionRecoveryLevel; +}; + +/** + * A secret consisting of a value, id and its attributes. + */ +export interface SecretBundle { + /** + * The secret value. + */ + value?: string; + /** + * The secret id. + */ + id?: string; + /** + * The content type of the secret. + */ + contentType?: string; + /** + * The secret management attributes. + */ + attributes?: SecretAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * If this is a secret backing a KV certificate, then this field specifies the corresponding key backing the KV certificate. + */ + readonly kid?: string; + /** + * True if the secret's lifetime is managed by key vault. If this is a secret backing a certificate, then managed will be true. + */ + readonly managed?: boolean; +} + +/** + * 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; +} + +/** + * A Deleted Secret consisting of its previous id, attributes and its tags, as well as information on when it will be purged. + */ +export type DeletedSecretBundle = SecretBundle & { + /** + * The url of the recovery object, used to identify and recover the deleted secret. + */ + recoveryId?: string; + /** + * The time when the secret is scheduled to be purged, in UTC + */ + readonly scheduledPurgeDate?: Date; + /** + * The time when the secret was deleted, in UTC + */ + readonly deletedDate?: Date; +}; + +/** + * The secret update parameters. + */ +export interface SecretUpdateParameters { + /** + * Type of the secret value such as a password. + */ + contentType?: string; + /** + * The secret management attributes. + */ + secretAttributes?: SecretAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; +} + +/** + * The secret list result. + */ +export interface SecretListResult { + /** + * A response message containing a list of secrets in the key vault along with a link to the next page of secrets. + */ + readonly value?: SecretItem[]; + /** + * The URL to get the next set of secrets. + */ + readonly nextLink?: string; +} + +/** + * The secret item containing secret metadata. + */ +export interface SecretItem { + /** + * Secret identifier. + */ + id?: string; + /** + * The secret management attributes. + */ + attributes?: SecretAttributes; + /** + * Application specific metadata in the form of key-value pairs. + */ + tags?: { [propertyName: string]: string }; + /** + * Type of the secret value such as a password. + */ + contentType?: string; + /** + * True if the secret's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. + */ + readonly managed?: boolean; +} + +/** + * The deleted secret list result + */ +export interface DeletedSecretListResult { + /** + * A response message containing a list of the deleted secrets in the vault along with a link to the next page of deleted secrets + */ + readonly value?: DeletedSecretItem[]; + /** + * The URL to get the next set of deleted secrets. + */ + readonly nextLink?: string; +} + +/** + * The deleted secret item containing metadata about the deleted secret. + */ +export type DeletedSecretItem = SecretItem & { + /** + * The url of the recovery object, used to identify and recover the deleted secret. + */ + recoveryId?: string; + /** + * The time when the secret is scheduled to be purged, in UTC + */ + readonly scheduledPurgeDate?: Date; + /** + * The time when the secret was deleted, in UTC + */ + readonly deletedDate?: Date; +}; + +/** + * The backup secret result, containing the backup blob. + */ +export interface BackupSecretResult { + /** + * The backup blob containing the backed up secret. + */ + readonly value?: Uint8Array; +} + +/** + * The secret restore parameters. + */ +export interface SecretRestoreParameters { + /** + * The backup blob associated with a secret bundle. + */ + secretBundleBackup: Uint8Array; +} + +/** + * Properties of the key backing a certificate. + */ +export interface SecretProperties { + /** + * The media type (MIME type). + */ + contentType?: string; +} + +/** + * Defines values for DeletionRecoveryLevel. + */ +export type DeletionRecoveryLevel = + | "Purgeable" + | "Recoverable+Purgeable" + | "Recoverable" + | "Recoverable+ProtectedSubscription" + | "CustomizedRecoverable+Purgeable" + | "CustomizedRecoverable" + | "CustomizedRecoverable+ProtectedSubscription"; + +/** + * Contains response data for the setSecret operation. + */ +export type KeyVaultClientSetSecretResponse = SecretBundle & { + /** + * 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: SecretBundle; + }; +}; + +/** + * Contains response data for the deleteSecret operation. + */ +export type KeyVaultClientDeleteSecretResponse = DeletedSecretBundle & { + /** + * 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: DeletedSecretBundle; + }; +}; + +/** + * Contains response data for the updateSecret operation. + */ +export type KeyVaultClientUpdateSecretResponse = SecretBundle & { + /** + * 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: SecretBundle; + }; +}; + +/** + * Contains response data for the getSecret operation. + */ +export type KeyVaultClientGetSecretResponse = SecretBundle & { + /** + * 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: SecretBundle; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetSecretsOptionalParams + 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 getSecrets operation. + */ +export type KeyVaultClientGetSecretsResponse = SecretListResult & { + /** + * 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: SecretListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetSecretVersionsOptionalParams + 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 getSecretVersions operation. + */ +export type KeyVaultClientGetSecretVersionsResponse = SecretListResult & { + /** + * 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: SecretListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetDeletedSecretsOptionalParams + 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 getDeletedSecrets operation. + */ +export type KeyVaultClientGetDeletedSecretsResponse = DeletedSecretListResult & { + /** + * 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: DeletedSecretListResult; + }; +}; + +/** + * Contains response data for the getDeletedSecret operation. + */ +export type KeyVaultClientGetDeletedSecretResponse = DeletedSecretBundle & { + /** + * 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: DeletedSecretBundle; + }; +}; + +/** + * Contains response data for the recoverDeletedSecret operation. + */ +export type KeyVaultClientRecoverDeletedSecretResponse = SecretBundle & { + /** + * 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: SecretBundle; + }; +}; + +/** + * Contains response data for the backupSecret operation. + */ +export type KeyVaultClientBackupSecretResponse = BackupSecretResult & { + /** + * 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: BackupSecretResult; + }; +}; + +/** + * Contains response data for the restoreSecret operation. + */ +export type KeyVaultClientRestoreSecretResponse = SecretBundle & { + /** + * 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: SecretBundle; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetSecretsNextOptionalParams + 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 getSecretsNext operation. + */ +export type KeyVaultClientGetSecretsNextResponse = SecretListResult & { + /** + * 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: SecretListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetSecretVersionsNextOptionalParams + 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 getSecretVersionsNext operation. + */ +export type KeyVaultClientGetSecretVersionsNextResponse = SecretListResult & { + /** + * 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: SecretListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientGetDeletedSecretsNextOptionalParams + 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 getDeletedSecretsNext operation. + */ +export type KeyVaultClientGetDeletedSecretsNextResponse = DeletedSecretListResult & { + /** + * 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: DeletedSecretListResult; + }; +}; + +/** + * Optional parameters. + */ +export interface KeyVaultClientOptionalParams + extends coreHttp.ServiceClientOptions { + /** + * Api Version + */ + apiVersion?: string; + /** + * Overrides client endpoint. + */ + endpoint?: string; +} diff --git a/sdk/keyvault/keyvault-secrets/src/core/models/mappers.ts b/sdk/keyvault/keyvault-secrets/src/generated/models/mappers.ts similarity index 85% rename from sdk/keyvault/keyvault-secrets/src/core/models/mappers.ts rename to sdk/keyvault/keyvault-secrets/src/generated/models/mappers.ts index db7d99e7e08d..697f835016d2 100644 --- a/sdk/keyvault/keyvault-secrets/src/core/models/mappers.ts +++ b/sdk/keyvault/keyvault-secrets/src/generated/models/mappers.ts @@ -1,6 +1,6 @@ /* - * 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. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. @@ -8,9 +8,43 @@ import * as coreHttp from "@azure/core-http"; +export const SecretSetParameters: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SecretSetParameters", + modelProperties: { + value: { + serializedName: "value", + required: true, + type: { + name: "String" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + contentType: { + serializedName: "contentType", + type: { + name: "String" + } + }, + secretAttributes: { + serializedName: "attributes", + type: { + name: "Composite", + className: "SecretAttributes" + } + } + } + } +}; export const Attributes: coreHttp.CompositeMapper = { - serializedName: "Attributes", type: { name: "Composite", className: "Attributes", @@ -34,15 +68,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" } @@ -52,23 +86,21 @@ export const Attributes: coreHttp.CompositeMapper = { }; export const SecretAttributes: coreHttp.CompositeMapper = { - serializedName: "SecretAttributes", type: { name: "Composite", className: "SecretAttributes", 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" } @@ -78,7 +110,6 @@ export const SecretAttributes: coreHttp.CompositeMapper = { }; export const SecretBundle: coreHttp.CompositeMapper = { - serializedName: "SecretBundle", type: { name: "Composite", className: "SecretBundle", @@ -112,23 +143,19 @@ export const SecretBundle: coreHttp.CompositeMapper = { serializedName: "tags", type: { name: "Dictionary", - value: { - type: { - name: "String" - } - } + value: { type: { name: "String" } } } }, kid: { - readOnly: true, serializedName: "kid", + readOnly: true, type: { name: "String" } }, managed: { - readOnly: true, serializedName: "managed", + readOnly: true, type: { name: "Boolean" } @@ -137,91 +164,58 @@ export const SecretBundle: coreHttp.CompositeMapper = { } }; -export const SecretItem: coreHttp.CompositeMapper = { - serializedName: "SecretItem", +export const KeyVaultError: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "SecretItem", + className: "KeyVaultError", modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - attributes: { - serializedName: "attributes", + error: { + serializedName: "error", type: { name: "Composite", - className: "SecretAttributes" - } - }, - tags: { - serializedName: "tags", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } - } - }, - contentType: { - serializedName: "contentType", - type: { - name: "String" - } - }, - managed: { - readOnly: true, - serializedName: "managed", - type: { - name: "Boolean" + className: "ErrorModel" } } } } }; -export const DeletedSecretBundle: coreHttp.CompositeMapper = { - serializedName: "DeletedSecretBundle", +export const ErrorModel: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "DeletedSecretBundle", + className: "ErrorModel", modelProperties: { - ...SecretBundle.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 DeletedSecretItem: coreHttp.CompositeMapper = { - serializedName: "DeletedSecretItem", +export const DeletedSecretBundle: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "DeletedSecretItem", + className: "DeletedSecretBundle", modelProperties: { - ...SecretItem.type.modelProperties, + ...SecretBundle.type.modelProperties, recoveryId: { serializedName: "recoveryId", type: { @@ -229,15 +223,15 @@ export const DeletedSecretItem: coreHttp.CompositeMapper = { } }, scheduledPurgeDate: { - readOnly: true, serializedName: "scheduledPurgeDate", + readOnly: true, type: { name: "UnixTime" } }, deletedDate: { - readOnly: true, serializedName: "deletedDate", + readOnly: true, type: { name: "UnixTime" } @@ -246,93 +240,71 @@ export const DeletedSecretItem: coreHttp.CompositeMapper = { } }; -export const SecretRestoreParameters: coreHttp.CompositeMapper = { - serializedName: "SecretRestoreParameters", - type: { - name: "Composite", - className: "SecretRestoreParameters", - modelProperties: { - secretBundleBackup: { - required: true, - serializedName: "value", - type: { - name: "Base64Url" - } - } - } - } -}; - -export const SecretProperties: coreHttp.CompositeMapper = { - serializedName: "SecretProperties", +export const SecretUpdateParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "SecretProperties", + className: "SecretUpdateParameters", modelProperties: { contentType: { serializedName: "contentType", type: { name: "String" } + }, + secretAttributes: { + serializedName: "attributes", + type: { + name: "Composite", + className: "SecretAttributes" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } } } } }; -export const SecretSetParameters: coreHttp.CompositeMapper = { - serializedName: "SecretSetParameters", +export const SecretListResult: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "SecretSetParameters", + className: "SecretListResult", modelProperties: { value: { - required: true, serializedName: "value", + readOnly: true, type: { - name: "String" - } - }, - tags: { - serializedName: "tags", - type: { - name: "Dictionary", - value: { - type: { - name: "String" - } - } + name: "Sequence", + element: { type: { name: "Composite", className: "SecretItem" } } } }, - contentType: { - serializedName: "contentType", + nextLink: { + serializedName: "nextLink", + readOnly: true, type: { name: "String" } - }, - secretAttributes: { - serializedName: "attributes", - type: { - name: "Composite", - className: "SecretAttributes" - } } } } }; -export const SecretUpdateParameters: coreHttp.CompositeMapper = { - serializedName: "SecretUpdateParameters", +export const SecretItem: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "SecretUpdateParameters", + className: "SecretItem", modelProperties: { - contentType: { - serializedName: "contentType", + id: { + serializedName: "id", type: { name: "String" } }, - secretAttributes: { + attributes: { serializedName: "attributes", type: { name: "Composite", @@ -343,39 +315,44 @@ export const SecretUpdateParameters: coreHttp.CompositeMapper = { serializedName: "tags", type: { name: "Dictionary", - value: { - type: { - name: "String" - } - } + value: { type: { name: "String" } } + } + }, + contentType: { + serializedName: "contentType", + type: { + name: "String" + } + }, + managed: { + serializedName: "managed", + readOnly: true, + type: { + name: "Boolean" } } } } }; -export const SecretListResult: coreHttp.CompositeMapper = { - serializedName: "SecretListResult", +export const DeletedSecretListResult: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "SecretListResult", + className: "DeletedSecretListResult", modelProperties: { value: { - readOnly: true, serializedName: "value", + readOnly: true, type: { name: "Sequence", element: { - type: { - name: "Composite", - className: "SecretItem" - } + type: { name: "Composite", className: "DeletedSecretItem" } } } }, nextLink: { - readOnly: true, serializedName: "nextLink", + readOnly: true, type: { name: "String" } @@ -384,30 +361,30 @@ export const SecretListResult: coreHttp.CompositeMapper = { } }; -export const DeletedSecretListResult: coreHttp.CompositeMapper = { - serializedName: "DeletedSecretListResult", +export const DeletedSecretItem: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "DeletedSecretListResult", + className: "DeletedSecretItem", modelProperties: { - value: { + ...SecretItem.type.modelProperties, + recoveryId: { + serializedName: "recoveryId", + type: { + name: "String" + } + }, + scheduledPurgeDate: { + serializedName: "scheduledPurgeDate", readOnly: true, - serializedName: "value", type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "DeletedSecretItem" - } - } + name: "UnixTime" } }, - nextLink: { + deletedDate: { + serializedName: "deletedDate", readOnly: true, - serializedName: "nextLink", type: { - name: "String" + name: "UnixTime" } } } @@ -415,14 +392,13 @@ export const DeletedSecretListResult: coreHttp.CompositeMapper = { }; export const BackupSecretResult: coreHttp.CompositeMapper = { - serializedName: "BackupSecretResult", type: { name: "Composite", className: "BackupSecretResult", modelProperties: { value: { - readOnly: true, serializedName: "value", + readOnly: true, type: { name: "Base64Url" } @@ -431,50 +407,31 @@ export const BackupSecretResult: coreHttp.CompositeMapper = { } }; -export const ErrorModel: coreHttp.CompositeMapper = { - serializedName: "Error", +export const SecretRestoreParameters: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "ErrorModel", + className: "SecretRestoreParameters", modelProperties: { - code: { - readOnly: true, - serializedName: "code", - type: { - name: "String" - } - }, - message: { - readOnly: true, - serializedName: "message", - type: { - name: "String" - } - }, - innerError: { - readOnly: true, - serializedName: "innererror", + secretBundleBackup: { + serializedName: "value", + required: true, type: { - name: "Composite", - className: "ErrorModel" + name: "Base64Url" } } } } }; -export const KeyVaultError: coreHttp.CompositeMapper = { - serializedName: "KeyVaultError", +export const SecretProperties: coreHttp.CompositeMapper = { type: { name: "Composite", - className: "KeyVaultError", + className: "SecretProperties", modelProperties: { - error: { - readOnly: true, - serializedName: "error", + contentType: { + serializedName: "contentType", type: { - name: "Composite", - className: "ErrorModel" + name: "String" } } } diff --git a/sdk/keyvault/keyvault-secrets/src/generated/models/parameters.ts b/sdk/keyvault/keyvault-secrets/src/generated/models/parameters.ts new file mode 100644 index 000000000000..997b1b44d0c1 --- /dev/null +++ b/sdk/keyvault/keyvault-secrets/src/generated/models/parameters.ts @@ -0,0 +1,131 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-http"; +import { + SecretSetParameters as SecretSetParametersMapper, + SecretUpdateParameters as SecretUpdateParametersMapper, + SecretRestoreParameters as SecretRestoreParametersMapper +} 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: SecretSetParametersMapper +}; + +export const vaultBaseUrl: OperationURLParameter = { + parameterPath: "vaultBaseUrl", + mapper: { + serializedName: "vaultBaseUrl", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const secretName: OperationURLParameter = { + parameterPath: "secretName", + mapper: { + constraints: { + Pattern: new RegExp("^[0-9a-zA-Z-]+$") + }, + serializedName: "secret-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 secretName1: OperationURLParameter = { + parameterPath: "secretName", + mapper: { + serializedName: "secret-name", + required: true, + type: { + name: "String" + } + } +}; + +export const parameters1: OperationParameter = { + parameterPath: "parameters", + mapper: SecretUpdateParametersMapper +}; + +export const secretVersion: OperationURLParameter = { + parameterPath: "secretVersion", + mapper: { + serializedName: "secret-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 parameters2: OperationParameter = { + parameterPath: "parameters", + mapper: SecretRestoreParametersMapper +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; diff --git a/sdk/keyvault/keyvault-secrets/src/core/utils.ts b/sdk/keyvault/keyvault-secrets/src/generated/utils.ts similarity index 100% rename from sdk/keyvault/keyvault-secrets/src/core/utils.ts rename to sdk/keyvault/keyvault-secrets/src/generated/utils.ts diff --git a/sdk/keyvault/keyvault-secrets/src/core/utils/constants.ts b/sdk/keyvault/keyvault-secrets/src/generated/utils/constants.ts similarity index 100% rename from sdk/keyvault/keyvault-secrets/src/core/utils/constants.ts rename to sdk/keyvault/keyvault-secrets/src/generated/utils/constants.ts diff --git a/sdk/keyvault/keyvault-secrets/src/index.ts b/sdk/keyvault/keyvault-secrets/src/index.ts index a89829b7cc43..462e1f472e4a 100644 --- a/sdk/keyvault/keyvault-secrets/src/index.ts +++ b/sdk/keyvault/keyvault-secrets/src/index.ts @@ -25,16 +25,18 @@ import { DeletedSecretBundle, DeletionRecoveryLevel, KeyVaultClientGetSecretsOptionalParams, - SetSecretResponse, - DeleteSecretResponse, - UpdateSecretResponse, - GetSecretResponse, - GetDeletedSecretResponse, - BackupSecretResponse, - RestoreSecretResponse -} from "./core/models"; -import { KeyVaultClient } from "./core/keyVaultClient"; -import { SDK_VERSION } from "./core/utils/constants"; + KeyVaultClientSetSecretResponse, + KeyVaultClientDeleteSecretResponse, + KeyVaultClientUpdateSecretResponse, + KeyVaultClientGetSecretResponse, + KeyVaultClientGetDeletedSecretResponse, + KeyVaultClientBackupSecretResponse, + KeyVaultClientRestoreSecretResponse, + KeyVaultClientOptionalParams, + SecretUpdateParameters +} from "./generated/models"; +import { KeyVaultClient } from "./generated/keyVaultClient"; +import { SDK_VERSION } from "./generated/utils/constants"; import { challengeBasedAuthenticationPolicy } from "../../keyvault-common/src"; import { DeleteSecretPoller } from "./lro/delete/poller"; @@ -63,7 +65,7 @@ import { SecretClientOptions, LATEST_API_VERSION } from "./secretsModels"; -import { parseKeyvaultIdentifier as parseKeyvaultEntityIdentifier } from "./core/utils"; +import { parseKeyvaultIdentifier as parseKeyvaultEntityIdentifier } from "./generated/utils"; export { SecretClientOptions, @@ -183,10 +185,11 @@ export class SecretClient { }; const pipeline = createPipelineFromOptions(internalPipelineOptions, authPolicy); - this.client = new KeyVaultClient( - pipelineOptions.apiVersion || LATEST_API_VERSION, - pipeline - ); + const optionalParams: KeyVaultClientOptionalParams = { + ...pipeline, + apiVersion: pipelineOptions.apiVersion || LATEST_API_VERSION + }; + this.client = new KeyVaultClient(optionalParams); } /** @@ -224,12 +227,12 @@ export class SecretClient { const span = this.createSpan("setSecret", unflattenedOptions); - let response: SetSecretResponse; + let response: KeyVaultClientSetSecretResponse; try { response = await this.client.setSecret( this.vaultUrl, secretName, - value, + { value }, this.setParentSpan(span, unflattenedOptions) ); } finally { @@ -241,7 +244,7 @@ export class SecretClient { const response = await this.client.setSecret( this.vaultUrl, secretName, - value, + { value }, requestOptions ); return this.getSecretFromSecretBundle(response); @@ -316,9 +319,12 @@ export class SecretClient { const requestOptions = operationOptionsToRequestOptionsBase(options); if (requestOptions) { - const { enabled, notBefore, expiresOn: expires, ...remainingOptions } = requestOptions; - const unflattenedOptions = { - ...remainingOptions, + const { enabled, notBefore, expiresOn: expires } = requestOptions; + + const span = this.createSpan("updateSecretProperties", requestOptions); + const optionalParams: SecretUpdateParameters = { + contentType: options.contentType, + tags: options.tags, secretAttributes: { enabled, notBefore, @@ -326,16 +332,14 @@ export class SecretClient { } }; - const span = this.createSpan("updateSecretProperties", unflattenedOptions); - - let response: UpdateSecretResponse; - + let response: KeyVaultClientUpdateSecretResponse; try { response = await this.client.updateSecret( this.vaultUrl, secretName, secretVersion, - this.setParentSpan(span, unflattenedOptions) + optionalParams, + this.setParentSpan(span, requestOptions) ); } finally { span.end(); @@ -373,7 +377,7 @@ export class SecretClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("getSecret", requestOptions); - let response: GetSecretResponse; + let response: KeyVaultClientGetSecretResponse; try { response = await this.client.getSecret( this.vaultUrl, @@ -408,7 +412,7 @@ export class SecretClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("getDeletedSecret", requestOptions); - let response: GetDeletedSecretResponse; + let response: KeyVaultClientGetDeletedSecretResponse; try { response = await this.client.getDeletedSecret( @@ -525,7 +529,7 @@ export class SecretClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("backupSecret", requestOptions); - let response: BackupSecretResponse; + let response: KeyVaultClientBackupSecretResponse; try { response = await this.client.backupSecret( @@ -552,7 +556,7 @@ export class SecretClient { * ``` * @summary Restores a backed up secret to a vault. * @param {Uint8Array} secretBundleBackup The backup blob associated with a secret bundle. - * @param {RestoreSecretResponse} [options] The optional parameters. + * @param {KeyVaultClientRestoreSecretResponse} [options] The optional parameters. */ public async restoreSecretBackup( secretBundleBackup: Uint8Array, @@ -561,12 +565,12 @@ export class SecretClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("restoreSecretBackup", requestOptions); - let response: RestoreSecretResponse; + let response: KeyVaultClientRestoreSecretResponse; try { response = await this.client.restoreSecret( this.vaultUrl, - secretBundleBackup, + { secretBundleBackup }, this.setParentSpan(span, requestOptions) ); } finally { @@ -591,7 +595,7 @@ export class SecretClient { const requestOptions = operationOptionsToRequestOptionsBase(options); const span = this.createSpan("deleteSecret", requestOptions); - let response: DeleteSecretResponse; + let response: KeyVaultClientDeleteSecretResponse; try { response = await this.client.deleteSecret( this.vaultUrl, diff --git a/sdk/keyvault/keyvault-secrets/src/secretsModels.ts b/sdk/keyvault/keyvault-secrets/src/secretsModels.ts index 223e3a929c59..2e5d48d7dd93 100644 --- a/sdk/keyvault/keyvault-secrets/src/secretsModels.ts +++ b/sdk/keyvault/keyvault-secrets/src/secretsModels.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"; /** * @internal diff --git a/sdk/keyvault/keyvault-secrets/swagger/README.md b/sdk/keyvault/keyvault-secrets/swagger/README.md index 8189dce45882..72e0e942b086 100644 --- a/sdk/keyvault/keyvault-secrets/swagger/README.md +++ b/sdk/keyvault/keyvault-secrets/swagger/README.md @@ -3,15 +3,14 @@ > see https://aka.ms/autorest ``` yaml -typescript: - package-name: "@azure/keyvault-secrets" +package-name: "@azure/keyvault-secrets" 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/secrets.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2-preview/secrets.json output-folder: ../ -source-code-folder-path: ./src/core +source-code-folder-path: ./src/generated ``` diff --git a/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts b/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts index a4455589c5b6..841861a29ade 100644 --- a/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts +++ b/sdk/keyvault/keyvault-secrets/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("Secrets client's user agent", () => { // The tests follow diff --git a/sdk/keyvault/keyvault-secrets/typedoc.json b/sdk/keyvault/keyvault-secrets/typedoc.json index 16778297ea8c..f0b700bd872a 100644 --- a/sdk/keyvault/keyvault-secrets/typedoc.json +++ b/sdk/keyvault/keyvault-secrets/typedoc.json @@ -3,6 +3,6 @@ "out": "../../../docGen/keyvault-secrets", "excludeNotExported": true, "excludePrivate": true, - "exclude": ["node_modules/**/*", "src/core/**/*"], + "exclude": ["node_modules/**/*", "src/generated/**/*"], "ignoreCompilerErrors": true }