From 82b0239c129a04ddbfc23a7c78def27c0404ee59 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 14 Mar 2018 14:56:47 -0700 Subject: [PATCH] Generated from 0f95ff79bf5626b76d881a3abb35826bf22e2b05 (#2461) Add node config to keyvault for Swagger to SDK --- .../lib/keyVaultManagementClient.d.ts | 3 +- .../lib/keyVaultManagementClient.js | 3 +- .../lib/models/checkNameAvailabilityResult.js | 77 + .../keyVaultManagement/lib/models/index.d.ts | 301 ++- .../keyVaultManagement/lib/models/index.js | 11 + .../lib/models/logSpecification.js | 68 + .../lib/models/operation.js | 89 + .../lib/models/operationDisplay.js | 77 + .../lib/models/operationListResult.js | 68 + .../keyVaultManagement/lib/models/resource.js | 5 +- .../lib/models/resourceListResult.js | 2 +- .../lib/models/serviceSpecification.js | 62 + .../keyVaultManagement/lib/models/vault.js | 19 +- .../lib/models/vaultAccessPolicyParameters.js | 96 + .../lib/models/vaultAccessPolicyProperties.js | 64 + .../vaultCheckNameAvailabilityParameters.js | 61 + .../models/vaultCreateOrUpdateParameters.js | 16 +- .../lib/models/vaultListResult.js | 3 +- .../lib/models/vaultPatchParameters.js | 100 + .../lib/models/vaultPatchProperties.js | 147 ++ .../lib/models/vaultProperties.js | 25 +- .../lib/operations/index.d.ts | 562 ++++- .../lib/operations/index.js | 1 + .../lib/operations/operations.js | 449 ++++ .../lib/operations/vaults.js | 2218 ++++++++++++++--- 25 files changed, 4105 insertions(+), 422 deletions(-) create mode 100644 lib/services/keyVaultManagement/lib/models/checkNameAvailabilityResult.js create mode 100644 lib/services/keyVaultManagement/lib/models/logSpecification.js create mode 100644 lib/services/keyVaultManagement/lib/models/operation.js create mode 100644 lib/services/keyVaultManagement/lib/models/operationDisplay.js create mode 100644 lib/services/keyVaultManagement/lib/models/operationListResult.js create mode 100644 lib/services/keyVaultManagement/lib/models/serviceSpecification.js create mode 100644 lib/services/keyVaultManagement/lib/models/vaultAccessPolicyParameters.js create mode 100644 lib/services/keyVaultManagement/lib/models/vaultAccessPolicyProperties.js create mode 100644 lib/services/keyVaultManagement/lib/models/vaultCheckNameAvailabilityParameters.js create mode 100644 lib/services/keyVaultManagement/lib/models/vaultPatchParameters.js create mode 100644 lib/services/keyVaultManagement/lib/models/vaultPatchProperties.js create mode 100644 lib/services/keyVaultManagement/lib/operations/operations.js diff --git a/lib/services/keyVaultManagement/lib/keyVaultManagementClient.d.ts b/lib/services/keyVaultManagement/lib/keyVaultManagementClient.d.ts index c3375aa9ff..bef5315536 100755 --- a/lib/services/keyVaultManagement/lib/keyVaultManagementClient.d.ts +++ b/lib/services/keyVaultManagement/lib/keyVaultManagementClient.d.ts @@ -20,7 +20,7 @@ declare class KeyVaultManagementClient extends AzureServiceClient { * @class * @param {credentials} credentials - Credentials needed for the client to connect to Azure. * - * @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * @param {string} subscriptionId - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. * * @param {string} [baseUri] - The base URI of the service. * @@ -56,6 +56,7 @@ declare class KeyVaultManagementClient extends AzureServiceClient { // Operation groups vaults: operations.Vaults; + operations: operations.Operations; } export = KeyVaultManagementClient; diff --git a/lib/services/keyVaultManagement/lib/keyVaultManagementClient.js b/lib/services/keyVaultManagement/lib/keyVaultManagementClient.js index 648e8c0410..e889d497ea 100755 --- a/lib/services/keyVaultManagement/lib/keyVaultManagementClient.js +++ b/lib/services/keyVaultManagement/lib/keyVaultManagementClient.js @@ -27,7 +27,7 @@ class KeyVaultManagementClient extends ServiceClient { /** * Create a KeyVaultManagementClient. * @param {credentials} credentials - Credentials needed for the client to connect to Azure. - * @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * @param {string} subscriptionId - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. * @param {string} [baseUri] - The base URI of the service. * @param {object} [options] - The parameter options * @param {Array} [options.filters] - Filters to be added to the request pipeline @@ -73,6 +73,7 @@ class KeyVaultManagementClient extends ServiceClient { this.generateClientRequestId = options.generateClientRequestId; } this.vaults = new operations.Vaults(this); + this.operations = new operations.Operations(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/keyVaultManagement/lib/models/checkNameAvailabilityResult.js b/lib/services/keyVaultManagement/lib/models/checkNameAvailabilityResult.js new file mode 100644 index 0000000000..f6b1d65f94 --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/checkNameAvailabilityResult.js @@ -0,0 +1,77 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The CheckNameAvailability operation response. + * + */ +class CheckNameAvailabilityResult { + /** + * Create a CheckNameAvailabilityResult. + * @member {boolean} [nameAvailable] A boolean value that indicates whether + * the name is available for you to use. If true, the name is available. If + * false, the name has already been taken or is invalid and cannot be used. + * @member {string} [reason] The reason that a vault name could not be used. + * The Reason element is only returned if NameAvailable is false. Possible + * values include: 'AccountNameInvalid', 'AlreadyExists' + * @member {string} [message] An error message explaining the Reason value in + * more detail. + */ + constructor() { + } + + /** + * Defines the metadata of CheckNameAvailabilityResult + * + * @returns {object} metadata of CheckNameAvailabilityResult + * + */ + mapper() { + return { + required: false, + serializedName: 'CheckNameAvailabilityResult', + type: { + name: 'Composite', + className: 'CheckNameAvailabilityResult', + modelProperties: { + nameAvailable: { + required: false, + readOnly: true, + serializedName: 'nameAvailable', + type: { + name: 'Boolean' + } + }, + reason: { + required: false, + readOnly: true, + serializedName: 'reason', + type: { + name: 'Enum', + allowedValues: [ 'AccountNameInvalid', 'AlreadyExists' ] + } + }, + message: { + required: false, + readOnly: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CheckNameAvailabilityResult; diff --git a/lib/services/keyVaultManagement/lib/models/index.d.ts b/lib/services/keyVaultManagement/lib/models/index.d.ts index 6324de8886..50281c0db7 100755 --- a/lib/services/keyVaultManagement/lib/models/index.d.ts +++ b/lib/services/keyVaultManagement/lib/models/index.d.ts @@ -101,12 +101,21 @@ export interface AccessPolicyEntry { * unwrap keys. * @member {boolean} [enabledForTemplateDeployment] Property to specify whether * Azure Resource Manager is permitted to retrieve secrets from the key vault. - * @member {boolean} [enableSoftDelete] Property to specify whether the 'soft - * delete' functionality is enabled for this key vault. It does not accept - * false value. + * @member {boolean} [enableSoftDelete] Property specifying whether recoverable + * deletion is enabled for this key vault. Setting this property to true + * activates the soft delete feature, whereby vaults or vault entities can be + * recovered after deletion. Enabling this functionality is irreversible - that + * is, the property does not accept false as its value. * @member {string} [createMode] The vault's create mode to indicate whether * the vault need to be recovered or not. Possible values include: 'recover', * 'default' + * @member {boolean} [enablePurgeProtection] Property specifying whether + * protection against purge is enabled for this vault. Setting this property to + * true activates protection against purge for this vault and its content - + * only the Key Vault service may initiate a hard, irrecoverable deletion. The + * setting is effective only if soft delete is also enabled. Enabling this + * functionality is irreversible - that is, the property does not accept false + * as its value. */ export interface VaultProperties { tenantId: string; @@ -118,6 +127,67 @@ export interface VaultProperties { enabledForTemplateDeployment?: boolean; enableSoftDelete?: boolean; createMode?: string; + enablePurgeProtection?: boolean; +} + +/** + * @class + * Initializes a new instance of the VaultPatchProperties class. + * @constructor + * Properties of the vault + * + * @member {uuid} [tenantId] The Azure Active Directory tenant ID that should + * be used for authenticating requests to the key vault. + * @member {object} [sku] SKU details + * @member {string} [sku.name] SKU name to specify whether the key vault is a + * standard vault or a premium vault. Possible values include: 'standard', + * 'premium' + * @member {array} [accessPolicies] An array of 0 to 16 identities that have + * access to the key vault. All identities in the array must use the same + * tenant ID as the key vault's tenant ID. + * @member {boolean} [enabledForDeployment] Property to specify whether Azure + * Virtual Machines are permitted to retrieve certificates stored as secrets + * from the key vault. + * @member {boolean} [enabledForDiskEncryption] Property to specify whether + * Azure Disk Encryption is permitted to retrieve secrets from the vault and + * unwrap keys. + * @member {boolean} [enabledForTemplateDeployment] Property to specify whether + * Azure Resource Manager is permitted to retrieve secrets from the key vault. + * @member {boolean} [enableSoftDelete] Property specifying whether recoverable + * deletion ('soft' delete) is enabled for this key vault. The property may not + * be set to false. + * @member {string} [createMode] The vault's create mode to indicate whether + * the vault need to be recovered or not. Possible values include: 'recover', + * 'default' + * @member {boolean} [enablePurgeProtection] Property specifying whether + * protection against purge is enabled for this vault; it is only effective if + * soft delete is also enabled. Once activated, the property may no longer be + * reset to false. + */ +export interface VaultPatchProperties { + tenantId?: string; + sku?: Sku; + accessPolicies?: AccessPolicyEntry[]; + enabledForDeployment?: boolean; + enabledForDiskEncryption?: boolean; + enabledForTemplateDeployment?: boolean; + enableSoftDelete?: boolean; + createMode?: string; + enablePurgeProtection?: boolean; +} + +/** + * @class + * Initializes a new instance of the VaultAccessPolicyProperties class. + * @constructor + * Properties of the vault access policy + * + * @member {array} accessPolicies An array of 0 to 16 identities that have + * access to the key vault. All identities in the array must use the same + * tenant ID as the key vault's tenant ID. + */ +export interface VaultAccessPolicyProperties { + accessPolicies: AccessPolicyEntry[]; } /** @@ -170,12 +240,21 @@ export interface DeletedVaultProperties { * @member {boolean} [properties.enabledForTemplateDeployment] Property to * specify whether Azure Resource Manager is permitted to retrieve secrets from * the key vault. - * @member {boolean} [properties.enableSoftDelete] Property to specify whether - * the 'soft delete' functionality is enabled for this key vault. It does not - * accept false value. + * @member {boolean} [properties.enableSoftDelete] Property specifying whether + * recoverable deletion is enabled for this key vault. Setting this property to + * true activates the soft delete feature, whereby vaults or vault entities can + * be recovered after deletion. Enabling this functionality is irreversible - + * that is, the property does not accept false as its value. * @member {string} [properties.createMode] The vault's create mode to indicate * whether the vault need to be recovered or not. Possible values include: * 'recover', 'default' + * @member {boolean} [properties.enablePurgeProtection] Property specifying + * whether protection against purge is enabled for this vault. Setting this + * property to true activates protection against purge for this vault and its + * content - only the Key Vault service may initiate a hard, irrecoverable + * deletion. The setting is effective only if soft delete is also enabled. + * Enabling this functionality is irreversible - that is, the property does not + * accept false as its value. */ export interface VaultCreateOrUpdateParameters extends BaseResource { location: string; @@ -183,6 +262,71 @@ export interface VaultCreateOrUpdateParameters extends BaseResource { properties: VaultProperties; } +/** + * @class + * Initializes a new instance of the VaultPatchParameters class. + * @constructor + * Parameters for creating or updating a vault + * + * @member {object} [tags] The tags that will be assigned to the key vault. + * @member {object} [properties] Properties of the vault + * @member {uuid} [properties.tenantId] The Azure Active Directory tenant ID + * that should be used for authenticating requests to the key vault. + * @member {object} [properties.sku] SKU details + * @member {string} [properties.sku.name] SKU name to specify whether the key + * vault is a standard vault or a premium vault. Possible values include: + * 'standard', 'premium' + * @member {array} [properties.accessPolicies] An array of 0 to 16 identities + * that have access to the key vault. All identities in the array must use the + * same tenant ID as the key vault's tenant ID. + * @member {boolean} [properties.enabledForDeployment] Property to specify + * whether Azure Virtual Machines are permitted to retrieve certificates stored + * as secrets from the key vault. + * @member {boolean} [properties.enabledForDiskEncryption] Property to specify + * whether Azure Disk Encryption is permitted to retrieve secrets from the + * vault and unwrap keys. + * @member {boolean} [properties.enabledForTemplateDeployment] Property to + * specify whether Azure Resource Manager is permitted to retrieve secrets from + * the key vault. + * @member {boolean} [properties.enableSoftDelete] Property specifying whether + * recoverable deletion ('soft' delete) is enabled for this key vault. The + * property may not be set to false. + * @member {string} [properties.createMode] The vault's create mode to indicate + * whether the vault need to be recovered or not. Possible values include: + * 'recover', 'default' + * @member {boolean} [properties.enablePurgeProtection] Property specifying + * whether protection against purge is enabled for this vault; it is only + * effective if soft delete is also enabled. Once activated, the property may + * no longer be reset to false. + */ +export interface VaultPatchParameters extends BaseResource { + tags?: { [propertyName: string]: string }; + properties?: VaultPatchProperties; +} + +/** + * @class + * Initializes a new instance of the VaultAccessPolicyParameters class. + * @constructor + * Parameters for updating the access policy in a vault + * + * @member {string} [id] The resource id of the access policy. + * @member {string} [name] The resource name of the access policy. + * @member {string} [type] The resource name of the access policy. + * @member {string} [location] The resource type of the the access policy. + * @member {object} properties Properties of the access policy + * @member {array} [properties.accessPolicies] An array of 0 to 16 identities + * that have access to the key vault. All identities in the array must use the + * same tenant ID as the key vault's tenant ID. + */ +export interface VaultAccessPolicyParameters extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + readonly location?: string; + properties: VaultAccessPolicyProperties; +} + /** * @class * Initializes a new instance of the Resource class. @@ -191,7 +335,7 @@ export interface VaultCreateOrUpdateParameters extends BaseResource { * * @member {string} [id] The Azure Resource Manager resource ID for the key * vault. - * @member {string} name The name of the key vault. + * @member {string} [name] The name of the key vault. * @member {string} [type] The resource type of the key vault. * @member {string} location The supported Azure location where the key vault * should be created. @@ -199,7 +343,7 @@ export interface VaultCreateOrUpdateParameters extends BaseResource { */ export interface Resource extends BaseResource { readonly id?: string; - name: string; + readonly name?: string; readonly type?: string; location: string; tags?: { [propertyName: string]: string }; @@ -232,12 +376,21 @@ export interface Resource extends BaseResource { * @member {boolean} [properties.enabledForTemplateDeployment] Property to * specify whether Azure Resource Manager is permitted to retrieve secrets from * the key vault. - * @member {boolean} [properties.enableSoftDelete] Property to specify whether - * the 'soft delete' functionality is enabled for this key vault. It does not - * accept false value. + * @member {boolean} [properties.enableSoftDelete] Property specifying whether + * recoverable deletion is enabled for this key vault. Setting this property to + * true activates the soft delete feature, whereby vaults or vault entities can + * be recovered after deletion. Enabling this functionality is irreversible - + * that is, the property does not accept false as its value. * @member {string} [properties.createMode] The vault's create mode to indicate * whether the vault need to be recovered or not. Possible values include: * 'recover', 'default' + * @member {boolean} [properties.enablePurgeProtection] Property specifying + * whether protection against purge is enabled for this vault. Setting this + * property to true activates protection against purge for this vault and its + * content - only the Key Vault service may initiate a hard, irrecoverable + * deletion. The setting is effective only if soft delete is also enabled. + * Enabling this functionality is irreversible - that is, the property does not + * accept false as its value. */ export interface Vault extends Resource { properties: VaultProperties; @@ -266,6 +419,113 @@ export interface DeletedVault { properties?: DeletedVaultProperties; } +/** + * @class + * Initializes a new instance of the VaultCheckNameAvailabilityParameters class. + * @constructor + * The parameters used to check the availabity of the vault name. + * + * @member {string} name The vault name. + */ +export interface VaultCheckNameAvailabilityParameters { + name: string; +} + +/** + * @class + * Initializes a new instance of the CheckNameAvailabilityResult class. + * @constructor + * The CheckNameAvailability operation response. + * + * @member {boolean} [nameAvailable] A boolean value that indicates whether the + * name is available for you to use. If true, the name is available. If false, + * the name has already been taken or is invalid and cannot be used. + * @member {string} [reason] The reason that a vault name could not be used. + * The Reason element is only returned if NameAvailable is false. Possible + * values include: 'AccountNameInvalid', 'AlreadyExists' + * @member {string} [message] An error message explaining the Reason value in + * more detail. + */ +export interface CheckNameAvailabilityResult { + readonly nameAvailable?: boolean; + readonly reason?: string; + readonly message?: string; +} + +/** + * @class + * Initializes a new instance of the OperationDisplay class. + * @constructor + * Display metadata associated with the operation. + * + * @member {string} [provider] Service provider: Microsoft Key Vault. + * @member {string} [resource] Resource on which the operation is performed + * etc. + * @member {string} [operation] Type of operation: get, read, delete, etc. + * @member {string} [description] Decription of operation. + */ +export interface OperationDisplay { + provider?: string; + resource?: string; + operation?: string; + description?: string; +} + +/** + * @class + * Initializes a new instance of the LogSpecification class. + * @constructor + * Log specification of operation. + * + * @member {string} [name] Name of log specification. + * @member {string} [displayName] Display name of log specification. + * @member {string} [blobDuration] Blob duration of specification. + */ +export interface LogSpecification { + name?: string; + displayName?: string; + blobDuration?: string; +} + +/** + * @class + * Initializes a new instance of the ServiceSpecification class. + * @constructor + * One property of operation, include log specifications. + * + * @member {array} [logSpecifications] Log specifications of operation. + */ +export interface ServiceSpecification { + logSpecifications?: LogSpecification[]; +} + +/** + * @class + * Initializes a new instance of the Operation class. + * @constructor + * Key Vault REST API operation definition. + * + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + * @member {object} [display] Display metadata associated with the operation. + * @member {string} [display.provider] Service provider: Microsoft Key Vault. + * @member {string} [display.resource] Resource on which the operation is + * performed etc. + * @member {string} [display.operation] Type of operation: get, read, delete, + * etc. + * @member {string} [display.description] Decription of operation. + * @member {string} [origin] The origin of operations. + * @member {object} [serviceSpecification] One property of operation, include + * metric specifications. + * @member {array} [serviceSpecification.logSpecifications] Log specifications + * of operation. + */ +export interface Operation { + name?: string; + display?: OperationDisplay; + origin?: string; + serviceSpecification?: ServiceSpecification; +} + /** * @class @@ -273,8 +533,7 @@ export interface DeletedVault { * @constructor * List of vaults * - * @member {string} [nextLink] Gets or sets the URL to get the next set of - * vaults. + * @member {string} [nextLink] The URL to get the next set of vaults. */ export interface VaultListResult extends Array { nextLink?: string; @@ -298,9 +557,21 @@ export interface DeletedVaultListResult extends Array { * @constructor * List of vault resources. * - * @member {string} [nextLink] Gets the URL to get the next set of vault - * resources. + * @member {string} [nextLink] The URL to get the next set of vault resources. */ export interface ResourceListResult extends Array { nextLink?: string; } + +/** + * @class + * Initializes a new instance of the OperationListResult class. + * @constructor + * Result of the request to list Storage operations. It contains a list of + * operations and a URL link to get the next set of results. + * + * @member {string} [nextLink] The URL to get the next set of operations. + */ +export interface OperationListResult extends Array { + nextLink?: string; +} diff --git a/lib/services/keyVaultManagement/lib/models/index.js b/lib/services/keyVaultManagement/lib/models/index.js index 3fd41a88f9..1973f9f005 100755 --- a/lib/services/keyVaultManagement/lib/models/index.js +++ b/lib/services/keyVaultManagement/lib/models/index.js @@ -22,11 +22,22 @@ exports.Sku = require('./sku'); exports.Permissions = require('./permissions'); exports.AccessPolicyEntry = require('./accessPolicyEntry'); exports.VaultProperties = require('./vaultProperties'); +exports.VaultPatchProperties = require('./vaultPatchProperties'); +exports.VaultAccessPolicyProperties = require('./vaultAccessPolicyProperties'); exports.DeletedVaultProperties = require('./deletedVaultProperties'); exports.VaultCreateOrUpdateParameters = require('./vaultCreateOrUpdateParameters'); +exports.VaultPatchParameters = require('./vaultPatchParameters'); +exports.VaultAccessPolicyParameters = require('./vaultAccessPolicyParameters'); exports.Resource = require('./resource'); exports.Vault = require('./vault'); exports.DeletedVault = require('./deletedVault'); +exports.VaultCheckNameAvailabilityParameters = require('./vaultCheckNameAvailabilityParameters'); +exports.CheckNameAvailabilityResult = require('./checkNameAvailabilityResult'); +exports.OperationDisplay = require('./operationDisplay'); +exports.LogSpecification = require('./logSpecification'); +exports.ServiceSpecification = require('./serviceSpecification'); +exports.Operation = require('./operation'); exports.VaultListResult = require('./vaultListResult'); exports.DeletedVaultListResult = require('./deletedVaultListResult'); exports.ResourceListResult = require('./resourceListResult'); +exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/keyVaultManagement/lib/models/logSpecification.js b/lib/services/keyVaultManagement/lib/models/logSpecification.js new file mode 100644 index 0000000000..fbf78a7c07 --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/logSpecification.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Log specification of operation. + * + */ +class LogSpecification { + /** + * Create a LogSpecification. + * @member {string} [name] Name of log specification. + * @member {string} [displayName] Display name of log specification. + * @member {string} [blobDuration] Blob duration of specification. + */ + constructor() { + } + + /** + * Defines the metadata of LogSpecification + * + * @returns {object} metadata of LogSpecification + * + */ + mapper() { + return { + required: false, + serializedName: 'LogSpecification', + type: { + name: 'Composite', + className: 'LogSpecification', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + displayName: { + required: false, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + blobDuration: { + required: false, + serializedName: 'blobDuration', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LogSpecification; diff --git a/lib/services/keyVaultManagement/lib/models/operation.js b/lib/services/keyVaultManagement/lib/models/operation.js new file mode 100644 index 0000000000..7497ee110b --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/operation.js @@ -0,0 +1,89 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Key Vault REST API operation definition. + * + */ +class Operation { + /** + * Create a Operation. + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + * @member {object} [display] Display metadata associated with the operation. + * @member {string} [display.provider] Service provider: Microsoft Key Vault. + * @member {string} [display.resource] Resource on which the operation is + * performed etc. + * @member {string} [display.operation] Type of operation: get, read, delete, + * etc. + * @member {string} [display.description] Decription of operation. + * @member {string} [origin] The origin of operations. + * @member {object} [serviceSpecification] One property of operation, include + * metric specifications. + * @member {array} [serviceSpecification.logSpecifications] Log + * specifications of operation. + */ + constructor() { + } + + /** + * Defines the metadata of Operation + * + * @returns {object} metadata of Operation + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation', + type: { + name: 'Composite', + className: 'Operation', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplay' + } + }, + origin: { + required: false, + serializedName: 'origin', + type: { + name: 'String' + } + }, + serviceSpecification: { + required: false, + serializedName: 'properties.serviceSpecification', + type: { + name: 'Composite', + className: 'ServiceSpecification' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/keyVaultManagement/lib/models/operationDisplay.js b/lib/services/keyVaultManagement/lib/models/operationDisplay.js new file mode 100644 index 0000000000..8cab4a170d --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/operationDisplay.js @@ -0,0 +1,77 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Display metadata associated with the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @member {string} [provider] Service provider: Microsoft Key Vault. + * @member {string} [resource] Resource on which the operation is performed + * etc. + * @member {string} [operation] Type of operation: get, read, delete, etc. + * @member {string} [description] Decription of operation. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplay + * + * @returns {object} metadata of OperationDisplay + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation_display', + type: { + name: 'Composite', + className: 'OperationDisplay', + modelProperties: { + provider: { + required: false, + serializedName: 'provider', + type: { + name: 'String' + } + }, + resource: { + required: false, + serializedName: 'resource', + type: { + name: 'String' + } + }, + operation: { + required: false, + serializedName: 'operation', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'description', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/keyVaultManagement/lib/models/operationListResult.js b/lib/services/keyVaultManagement/lib/models/operationListResult.js new file mode 100644 index 0000000000..f6662b8f6a --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/operationListResult.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Result of the request to list Storage operations. It contains a list of + * operations and a URL link to get the next set of results. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @member {string} [nextLink] The URL to get the next set of operations. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of OperationListResult + * + * @returns {object} metadata of OperationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationListResult', + type: { + name: 'Composite', + className: 'OperationListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationElementType', + type: { + name: 'Composite', + className: 'Operation' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationListResult; diff --git a/lib/services/keyVaultManagement/lib/models/resource.js b/lib/services/keyVaultManagement/lib/models/resource.js index a52bd431b5..e23aafe21b 100755 --- a/lib/services/keyVaultManagement/lib/models/resource.js +++ b/lib/services/keyVaultManagement/lib/models/resource.js @@ -22,7 +22,7 @@ class Resource extends models['BaseResource'] { * Create a Resource. * @member {string} [id] The Azure Resource Manager resource ID for the key * vault. - * @member {string} name The name of the key vault. + * @member {string} [name] The name of the key vault. * @member {string} [type] The resource type of the key vault. * @member {string} location The supported Azure location where the key vault * should be created. @@ -55,7 +55,8 @@ class Resource extends models['BaseResource'] { } }, name: { - required: true, + required: false, + readOnly: true, serializedName: 'name', type: { name: 'String' diff --git a/lib/services/keyVaultManagement/lib/models/resourceListResult.js b/lib/services/keyVaultManagement/lib/models/resourceListResult.js index e2654f559e..9d094338fb 100755 --- a/lib/services/keyVaultManagement/lib/models/resourceListResult.js +++ b/lib/services/keyVaultManagement/lib/models/resourceListResult.js @@ -16,7 +16,7 @@ class ResourceListResult extends Array { /** * Create a ResourceListResult. - * @member {string} [nextLink] Gets the URL to get the next set of vault + * @member {string} [nextLink] The URL to get the next set of vault * resources. */ constructor() { diff --git a/lib/services/keyVaultManagement/lib/models/serviceSpecification.js b/lib/services/keyVaultManagement/lib/models/serviceSpecification.js new file mode 100644 index 0000000000..185445842d --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/serviceSpecification.js @@ -0,0 +1,62 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * One property of operation, include log specifications. + * + */ +class ServiceSpecification { + /** + * Create a ServiceSpecification. + * @member {array} [logSpecifications] Log specifications of operation. + */ + constructor() { + } + + /** + * Defines the metadata of ServiceSpecification + * + * @returns {object} metadata of ServiceSpecification + * + */ + mapper() { + return { + required: false, + serializedName: 'ServiceSpecification', + type: { + name: 'Composite', + className: 'ServiceSpecification', + modelProperties: { + logSpecifications: { + required: false, + serializedName: 'logSpecifications', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LogSpecificationElementType', + type: { + name: 'Composite', + className: 'LogSpecification' + } + } + } + } + } + } + }; + } +} + +module.exports = ServiceSpecification; diff --git a/lib/services/keyVaultManagement/lib/models/vault.js b/lib/services/keyVaultManagement/lib/models/vault.js index aabc17d1c5..ceaa7304d4 100755 --- a/lib/services/keyVaultManagement/lib/models/vault.js +++ b/lib/services/keyVaultManagement/lib/models/vault.js @@ -41,12 +41,22 @@ class Vault extends models['Resource'] { * @member {boolean} [properties.enabledForTemplateDeployment] Property to * specify whether Azure Resource Manager is permitted to retrieve secrets * from the key vault. - * @member {boolean} [properties.enableSoftDelete] Property to specify - * whether the 'soft delete' functionality is enabled for this key vault. It - * does not accept false value. + * @member {boolean} [properties.enableSoftDelete] Property specifying + * whether recoverable deletion is enabled for this key vault. Setting this + * property to true activates the soft delete feature, whereby vaults or + * vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept + * false as its value. * @member {string} [properties.createMode] The vault's create mode to * indicate whether the vault need to be recovered or not. Possible values * include: 'recover', 'default' + * @member {boolean} [properties.enablePurgeProtection] Property specifying + * whether protection against purge is enabled for this vault. Setting this + * property to true activates protection against purge for this vault and its + * content - only the Key Vault service may initiate a hard, irrecoverable + * deletion. The setting is effective only if soft delete is also enabled. + * Enabling this functionality is irreversible - that is, the property does + * not accept false as its value. */ constructor() { super(); @@ -75,7 +85,8 @@ class Vault extends models['Resource'] { } }, name: { - required: true, + required: false, + readOnly: true, serializedName: 'name', type: { name: 'String' diff --git a/lib/services/keyVaultManagement/lib/models/vaultAccessPolicyParameters.js b/lib/services/keyVaultManagement/lib/models/vaultAccessPolicyParameters.js new file mode 100644 index 0000000000..ab1f52c76e --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/vaultAccessPolicyParameters.js @@ -0,0 +1,96 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Parameters for updating the access policy in a vault + * + * @extends models['BaseResource'] + */ +class VaultAccessPolicyParameters extends models['BaseResource'] { + /** + * Create a VaultAccessPolicyParameters. + * @member {string} [id] The resource id of the access policy. + * @member {string} [name] The resource name of the access policy. + * @member {string} [type] The resource name of the access policy. + * @member {string} [location] The resource type of the the access policy. + * @member {object} properties Properties of the access policy + * @member {array} [properties.accessPolicies] An array of 0 to 16 identities + * that have access to the key vault. All identities in the array must use + * the same tenant ID as the key vault's tenant ID. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of VaultAccessPolicyParameters + * + * @returns {object} metadata of VaultAccessPolicyParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'VaultAccessPolicyParameters', + type: { + name: 'Composite', + className: 'VaultAccessPolicyParameters', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + properties: { + required: true, + serializedName: 'properties', + type: { + name: 'Composite', + className: 'VaultAccessPolicyProperties' + } + } + } + } + }; + } +} + +module.exports = VaultAccessPolicyParameters; diff --git a/lib/services/keyVaultManagement/lib/models/vaultAccessPolicyProperties.js b/lib/services/keyVaultManagement/lib/models/vaultAccessPolicyProperties.js new file mode 100644 index 0000000000..7250127fd6 --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/vaultAccessPolicyProperties.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Properties of the vault access policy + * + */ +class VaultAccessPolicyProperties { + /** + * Create a VaultAccessPolicyProperties. + * @member {array} accessPolicies An array of 0 to 16 identities that have + * access to the key vault. All identities in the array must use the same + * tenant ID as the key vault's tenant ID. + */ + constructor() { + } + + /** + * Defines the metadata of VaultAccessPolicyProperties + * + * @returns {object} metadata of VaultAccessPolicyProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'VaultAccessPolicyProperties', + type: { + name: 'Composite', + className: 'VaultAccessPolicyProperties', + modelProperties: { + accessPolicies: { + required: true, + serializedName: 'accessPolicies', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AccessPolicyEntryElementType', + type: { + name: 'Composite', + className: 'AccessPolicyEntry' + } + } + } + } + } + } + }; + } +} + +module.exports = VaultAccessPolicyProperties; diff --git a/lib/services/keyVaultManagement/lib/models/vaultCheckNameAvailabilityParameters.js b/lib/services/keyVaultManagement/lib/models/vaultCheckNameAvailabilityParameters.js new file mode 100644 index 0000000000..e8aaa893d7 --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/vaultCheckNameAvailabilityParameters.js @@ -0,0 +1,61 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The parameters used to check the availabity of the vault name. + * + */ +class VaultCheckNameAvailabilityParameters { + /** + * Create a VaultCheckNameAvailabilityParameters. + * @member {string} name The vault name. + */ + constructor() { + } + + /** + * Defines the metadata of VaultCheckNameAvailabilityParameters + * + * @returns {object} metadata of VaultCheckNameAvailabilityParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'VaultCheckNameAvailabilityParameters', + type: { + name: 'Composite', + className: 'VaultCheckNameAvailabilityParameters', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + isConstant: true, + serializedName: 'type', + defaultValue: 'Microsoft.KeyVault/vaults', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = VaultCheckNameAvailabilityParameters; diff --git a/lib/services/keyVaultManagement/lib/models/vaultCreateOrUpdateParameters.js b/lib/services/keyVaultManagement/lib/models/vaultCreateOrUpdateParameters.js index 9873640528..0adb1a6e40 100755 --- a/lib/services/keyVaultManagement/lib/models/vaultCreateOrUpdateParameters.js +++ b/lib/services/keyVaultManagement/lib/models/vaultCreateOrUpdateParameters.js @@ -44,12 +44,22 @@ class VaultCreateOrUpdateParameters extends models['BaseResource'] { * @member {boolean} [properties.enabledForTemplateDeployment] Property to * specify whether Azure Resource Manager is permitted to retrieve secrets * from the key vault. - * @member {boolean} [properties.enableSoftDelete] Property to specify - * whether the 'soft delete' functionality is enabled for this key vault. It - * does not accept false value. + * @member {boolean} [properties.enableSoftDelete] Property specifying + * whether recoverable deletion is enabled for this key vault. Setting this + * property to true activates the soft delete feature, whereby vaults or + * vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept + * false as its value. * @member {string} [properties.createMode] The vault's create mode to * indicate whether the vault need to be recovered or not. Possible values * include: 'recover', 'default' + * @member {boolean} [properties.enablePurgeProtection] Property specifying + * whether protection against purge is enabled for this vault. Setting this + * property to true activates protection against purge for this vault and its + * content - only the Key Vault service may initiate a hard, irrecoverable + * deletion. The setting is effective only if soft delete is also enabled. + * Enabling this functionality is irreversible - that is, the property does + * not accept false as its value. */ constructor() { super(); diff --git a/lib/services/keyVaultManagement/lib/models/vaultListResult.js b/lib/services/keyVaultManagement/lib/models/vaultListResult.js index 3fed784ff3..00ded6fd06 100755 --- a/lib/services/keyVaultManagement/lib/models/vaultListResult.js +++ b/lib/services/keyVaultManagement/lib/models/vaultListResult.js @@ -16,8 +16,7 @@ class VaultListResult extends Array { /** * Create a VaultListResult. - * @member {string} [nextLink] Gets or sets the URL to get the next set of - * vaults. + * @member {string} [nextLink] The URL to get the next set of vaults. */ constructor() { super(); diff --git a/lib/services/keyVaultManagement/lib/models/vaultPatchParameters.js b/lib/services/keyVaultManagement/lib/models/vaultPatchParameters.js new file mode 100644 index 0000000000..fe9e2c5bc0 --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/vaultPatchParameters.js @@ -0,0 +1,100 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Parameters for creating or updating a vault + * + * @extends models['BaseResource'] + */ +class VaultPatchParameters extends models['BaseResource'] { + /** + * Create a VaultPatchParameters. + * @member {object} [tags] The tags that will be assigned to the key vault. + * @member {object} [properties] Properties of the vault + * @member {uuid} [properties.tenantId] The Azure Active Directory tenant ID + * that should be used for authenticating requests to the key vault. + * @member {object} [properties.sku] SKU details + * @member {string} [properties.sku.name] SKU name to specify whether the key + * vault is a standard vault or a premium vault. Possible values include: + * 'standard', 'premium' + * @member {array} [properties.accessPolicies] An array of 0 to 16 identities + * that have access to the key vault. All identities in the array must use + * the same tenant ID as the key vault's tenant ID. + * @member {boolean} [properties.enabledForDeployment] Property to specify + * whether Azure Virtual Machines are permitted to retrieve certificates + * stored as secrets from the key vault. + * @member {boolean} [properties.enabledForDiskEncryption] Property to + * specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * @member {boolean} [properties.enabledForTemplateDeployment] Property to + * specify whether Azure Resource Manager is permitted to retrieve secrets + * from the key vault. + * @member {boolean} [properties.enableSoftDelete] Property specifying + * whether recoverable deletion ('soft' delete) is enabled for this key + * vault. The property may not be set to false. + * @member {string} [properties.createMode] The vault's create mode to + * indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * @member {boolean} [properties.enablePurgeProtection] Property specifying + * whether protection against purge is enabled for this vault; it is only + * effective if soft delete is also enabled. Once activated, the property may + * no longer be reset to false. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of VaultPatchParameters + * + * @returns {object} metadata of VaultPatchParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'VaultPatchParameters', + type: { + name: 'Composite', + className: 'VaultPatchParameters', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Composite', + className: 'VaultPatchProperties' + } + } + } + } + }; + } +} + +module.exports = VaultPatchParameters; diff --git a/lib/services/keyVaultManagement/lib/models/vaultPatchProperties.js b/lib/services/keyVaultManagement/lib/models/vaultPatchProperties.js new file mode 100644 index 0000000000..6b8c793c44 --- /dev/null +++ b/lib/services/keyVaultManagement/lib/models/vaultPatchProperties.js @@ -0,0 +1,147 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Properties of the vault + * + */ +class VaultPatchProperties { + /** + * Create a VaultPatchProperties. + * @member {uuid} [tenantId] The Azure Active Directory tenant ID that should + * be used for authenticating requests to the key vault. + * @member {object} [sku] SKU details + * @member {string} [sku.name] SKU name to specify whether the key vault is a + * standard vault or a premium vault. Possible values include: 'standard', + * 'premium' + * @member {array} [accessPolicies] An array of 0 to 16 identities that have + * access to the key vault. All identities in the array must use the same + * tenant ID as the key vault's tenant ID. + * @member {boolean} [enabledForDeployment] Property to specify whether Azure + * Virtual Machines are permitted to retrieve certificates stored as secrets + * from the key vault. + * @member {boolean} [enabledForDiskEncryption] Property to specify whether + * Azure Disk Encryption is permitted to retrieve secrets from the vault and + * unwrap keys. + * @member {boolean} [enabledForTemplateDeployment] Property to specify + * whether Azure Resource Manager is permitted to retrieve secrets from the + * key vault. + * @member {boolean} [enableSoftDelete] Property specifying whether + * recoverable deletion ('soft' delete) is enabled for this key vault. The + * property may not be set to false. + * @member {string} [createMode] The vault's create mode to indicate whether + * the vault need to be recovered or not. Possible values include: 'recover', + * 'default' + * @member {boolean} [enablePurgeProtection] Property specifying whether + * protection against purge is enabled for this vault; it is only effective + * if soft delete is also enabled. Once activated, the property may no longer + * be reset to false. + */ + constructor() { + } + + /** + * Defines the metadata of VaultPatchProperties + * + * @returns {object} metadata of VaultPatchProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'VaultPatchProperties', + type: { + name: 'Composite', + className: 'VaultPatchProperties', + modelProperties: { + tenantId: { + required: false, + serializedName: 'tenantId', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'Sku' + } + }, + accessPolicies: { + required: false, + serializedName: 'accessPolicies', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AccessPolicyEntryElementType', + type: { + name: 'Composite', + className: 'AccessPolicyEntry' + } + } + } + }, + enabledForDeployment: { + required: false, + serializedName: 'enabledForDeployment', + type: { + name: 'Boolean' + } + }, + enabledForDiskEncryption: { + required: false, + serializedName: 'enabledForDiskEncryption', + type: { + name: 'Boolean' + } + }, + enabledForTemplateDeployment: { + required: false, + serializedName: 'enabledForTemplateDeployment', + type: { + name: 'Boolean' + } + }, + enableSoftDelete: { + required: false, + serializedName: 'enableSoftDelete', + type: { + name: 'Boolean' + } + }, + createMode: { + required: false, + serializedName: 'createMode', + type: { + name: 'Enum', + allowedValues: [ 'recover', 'default' ] + } + }, + enablePurgeProtection: { + required: false, + serializedName: 'enablePurgeProtection', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = VaultPatchProperties; diff --git a/lib/services/keyVaultManagement/lib/models/vaultProperties.js b/lib/services/keyVaultManagement/lib/models/vaultProperties.js index f03e4c0fa2..ab195918b4 100755 --- a/lib/services/keyVaultManagement/lib/models/vaultProperties.js +++ b/lib/services/keyVaultManagement/lib/models/vaultProperties.js @@ -39,12 +39,21 @@ class VaultProperties { * @member {boolean} [enabledForTemplateDeployment] Property to specify * whether Azure Resource Manager is permitted to retrieve secrets from the * key vault. - * @member {boolean} [enableSoftDelete] Property to specify whether the 'soft - * delete' functionality is enabled for this key vault. It does not accept - * false value. + * @member {boolean} [enableSoftDelete] Property specifying whether + * recoverable deletion is enabled for this key vault. Setting this property + * to true activates the soft delete feature, whereby vaults or vault + * entities can be recovered after deletion. Enabling this functionality is + * irreversible - that is, the property does not accept false as its value. * @member {string} [createMode] The vault's create mode to indicate whether * the vault need to be recovered or not. Possible values include: 'recover', * 'default' + * @member {boolean} [enablePurgeProtection] Property specifying whether + * protection against purge is enabled for this vault. Setting this property + * to true activates protection against purge for this vault and its content + * - only the Key Vault service may initiate a hard, irrecoverable deletion. + * The setting is effective only if soft delete is also enabled. Enabling + * this functionality is irreversible - that is, the property does not accept + * false as its value. */ constructor() { } @@ -82,9 +91,6 @@ class VaultProperties { accessPolicies: { required: false, serializedName: 'accessPolicies', - constraints: { - MaxItems: 16 - }, type: { name: 'Sequence', element: { @@ -139,6 +145,13 @@ class VaultProperties { name: 'Enum', allowedValues: [ 'recover', 'default' ] } + }, + enablePurgeProtection: { + required: false, + serializedName: 'enablePurgeProtection', + type: { + name: 'Boolean' + } } } } diff --git a/lib/services/keyVaultManagement/lib/operations/index.d.ts b/lib/services/keyVaultManagement/lib/operations/index.d.ts index af0820e409..feb10f768b 100755 --- a/lib/services/keyVaultManagement/lib/operations/index.d.ts +++ b/lib/services/keyVaultManagement/lib/operations/index.d.ts @@ -67,14 +67,25 @@ export interface Vaults { * Property to specify whether Azure Resource Manager is permitted to retrieve * secrets from the key vault. * - * @param {boolean} [parameters.properties.enableSoftDelete] Property to - * specify whether the 'soft delete' functionality is enabled for this key - * vault. It does not accept false value. + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion is enabled for this key vault. + * Setting this property to true activates the soft delete feature, whereby + * vaults or vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept false + * as its value. * * @param {string} [parameters.properties.createMode] The vault's create mode * to indicate whether the vault need to be recovered or not. Possible values * include: 'recover', 'default' * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault. + * Setting this property to true activates protection against purge for this + * vault and its content - only the Key Vault service may initiate a hard, + * irrecoverable deletion. The setting is effective only if soft delete is also + * enabled. Enabling this functionality is irreversible - that is, the property + * does not accept false as its value. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -134,14 +145,25 @@ export interface Vaults { * Property to specify whether Azure Resource Manager is permitted to retrieve * secrets from the key vault. * - * @param {boolean} [parameters.properties.enableSoftDelete] Property to - * specify whether the 'soft delete' functionality is enabled for this key - * vault. It does not accept false value. + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion is enabled for this key vault. + * Setting this property to true activates the soft delete feature, whereby + * vaults or vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept false + * as its value. * * @param {string} [parameters.properties.createMode] The vault's create mode * to indicate whether the vault need to be recovered or not. Possible values * include: 'recover', 'default' * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault. + * Setting this property to true activates protection against purge for this + * vault and its content - only the Key Vault service may initiate a hard, + * irrecoverable deletion. The setting is effective only if soft delete is also + * enabled. Enabling this functionality is irreversible - that is, the property + * does not accept false as its value. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -174,6 +196,157 @@ export interface Vaults { createOrUpdate(resourceGroupName: string, vaultName: string, parameters: models.VaultCreateOrUpdateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Update a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the server belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to patch the vault + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} [parameters.properties] Properties of the vault + * + * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} [parameters.properties.sku] SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve + * certificates stored as secrets from the key vault. + * + * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property + * to specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * + * @param {boolean} [parameters.properties.enabledForTemplateDeployment] + * Property to specify whether Azure Resource Manager is permitted to retrieve + * secrets from the key vault. + * + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion ('soft' delete) is enabled for this + * key vault. The property may not be set to false. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault; it is + * only effective if soft delete is also enabled. Once activated, the property + * may no longer be reset to false. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, vaultName: string, parameters: models.VaultPatchParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the server belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to patch the vault + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} [parameters.properties] Properties of the vault + * + * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} [parameters.properties.sku] SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve + * certificates stored as secrets from the key vault. + * + * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property + * to specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * + * @param {boolean} [parameters.properties.enabledForTemplateDeployment] + * Property to specify whether Azure Resource Manager is permitted to retrieve + * secrets from the key vault. + * + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion ('soft' delete) is enabled for this + * key vault. The property may not be set to false. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault; it is + * only effective if soft delete is also enabled. Once activated, the property + * may no longer be reset to false. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Vault} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Vault} [result] - The deserialized result object if an error did not occur. + * See {@link Vault} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, vaultName: string, parameters: models.VaultPatchParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, vaultName: string, parameters: models.VaultPatchParameters, callback: ServiceCallback): void; + update(resourceGroupName: string, vaultName: string, parameters: models.VaultPatchParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Deletes the specified Azure key vault. * @@ -295,6 +468,90 @@ export interface Vaults { get(resourceGroupName: string, vaultName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Update access policies in a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {string} operationKind Name of the operation. Possible values + * include: 'add', 'replace', 'remove' + * + * @param {object} parameters Access policy to merge into the vault + * + * @param {object} parameters.properties Properties of the access policy + * + * @param {array} parameters.properties.accessPolicies An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateAccessPolicyWithHttpOperationResponse(resourceGroupName: string, vaultName: string, operationKind: string, parameters: models.VaultAccessPolicyParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update access policies in a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {string} operationKind Name of the operation. Possible values + * include: 'add', 'replace', 'remove' + * + * @param {object} parameters Access policy to merge into the vault + * + * @param {object} parameters.properties Properties of the access policy + * + * @param {array} parameters.properties.accessPolicies An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {VaultAccessPolicyParameters} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {VaultAccessPolicyParameters} [result] - The deserialized result object if an error did not occur. + * See {@link VaultAccessPolicyParameters} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + updateAccessPolicy(resourceGroupName: string, vaultName: string, operationKind: string, parameters: models.VaultAccessPolicyParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + updateAccessPolicy(resourceGroupName: string, vaultName: string, operationKind: string, parameters: models.VaultAccessPolicyParameters, callback: ServiceCallback): void; + updateAccessPolicy(resourceGroupName: string, vaultName: string, operationKind: string, parameters: models.VaultAccessPolicyParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * The List operation gets information about the vaults associated with the * subscription and within the specified resource group. @@ -358,6 +615,63 @@ export interface Vaults { listByResourceGroup(resourceGroupName: string, options: { top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {number} [options.top] Maximum number of results to return. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options?: { top? : number, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {number} [options.top] Maximum number of results to return. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {VaultListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {VaultListResult} [result] - The deserialized result object if an error did not occur. + * See {@link VaultListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options?: { top? : number, customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscription(callback: ServiceCallback): void; + listBySubscription(options: { top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets information about the deleted vaults in a subscription. * @@ -586,6 +900,66 @@ export interface Vaults { list(options: { top? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Checks that the vault name is valid and is not already in use. + * + * @param {object} vaultName The name of the vault. + * + * @param {string} vaultName.name The vault name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + checkNameAvailabilityWithHttpOperationResponse(vaultName: models.VaultCheckNameAvailabilityParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Checks that the vault name is valid and is not already in use. + * + * @param {object} vaultName The name of the vault. + * + * @param {string} vaultName.name The vault name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CheckNameAvailabilityResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CheckNameAvailabilityResult} [result] - The deserialized result object if an error did not occur. + * See {@link CheckNameAvailabilityResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + checkNameAvailability(vaultName: models.VaultCheckNameAvailabilityParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + checkNameAvailability(vaultName: models.VaultCheckNameAvailabilityParameters, callback: ServiceCallback): void; + checkNameAvailability(vaultName: models.VaultCheckNameAvailabilityParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Permanently deletes the specified vault. aka Purges the deleted Azure key * vault. @@ -705,6 +1079,65 @@ export interface Vaults { listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {VaultListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {VaultListResult} [result] - The deserialized result object if an error did not occur. + * See {@link VaultListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscriptionNext(nextPageLink: string, callback: ServiceCallback): void; + listBySubscriptionNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets information about the deleted vaults in a subscription. * @@ -821,3 +1254,120 @@ export interface Vaults { listNext(nextPageLink: string, callback: ServiceCallback): void; listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } + +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the KeyVaultManagementClient. + */ +export interface Operations { + + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/keyVaultManagement/lib/operations/index.js b/lib/services/keyVaultManagement/lib/operations/index.js index 63640a1f27..d279f112bb 100755 --- a/lib/services/keyVaultManagement/lib/operations/index.js +++ b/lib/services/keyVaultManagement/lib/operations/index.js @@ -15,3 +15,4 @@ 'use strict'; exports.Vaults = require('./vaults'); +exports.Operations = require('./operations'); diff --git a/lib/services/keyVaultManagement/lib/operations/operations.js b/lib/services/keyVaultManagement/lib/operations/operations.js new file mode 100644 index 0000000000..dd417b2efa --- /dev/null +++ b/lib/services/keyVaultManagement/lib/operations/operations.js @@ -0,0 +1,449 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the available Key Vault Rest API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.KeyVault/operations'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the available Key Vault Rest API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Operations. */ +class Operations { + /** + * Create a Operations. + * @param {KeyVaultManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available Key Vault Rest API operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/keyVaultManagement/lib/operations/vaults.js b/lib/services/keyVaultManagement/lib/operations/vaults.js index f89d9f468f..897a628092 100755 --- a/lib/services/keyVaultManagement/lib/operations/vaults.js +++ b/lib/services/keyVaultManagement/lib/operations/vaults.js @@ -60,14 +60,25 @@ const WebResource = msRest.WebResource; * Property to specify whether Azure Resource Manager is permitted to retrieve * secrets from the key vault. * - * @param {boolean} [parameters.properties.enableSoftDelete] Property to - * specify whether the 'soft delete' functionality is enabled for this key - * vault. It does not accept false value. + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion is enabled for this key vault. + * Setting this property to true activates the soft delete feature, whereby + * vaults or vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept false + * as its value. * * @param {string} [parameters.properties.createMode] The vault's create mode * to indicate whether the vault need to be recovered or not. Possible values * include: 'recover', 'default' * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault. + * Setting this property to true activates protection against purge for this + * vault and its content - only the Key Vault service may initiate a hard, + * irrecoverable deletion. The setting is effective only if soft delete is also + * enabled. Enabling this functionality is irreversible - that is, the property + * does not accept false as its value. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -183,7 +194,7 @@ function _createOrUpdate(resourceGroupName, vaultName, parameters, options, call return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 201 && statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -212,7 +223,7 @@ function _createOrUpdate(resourceGroupName, vaultName, parameters, options, call let result = null; if (responseBody === '') responseBody = null; // Deserialize Response - if (statusCode === 201) { + if (statusCode === 200) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); @@ -229,7 +240,7 @@ function _createOrUpdate(resourceGroupName, vaultName, parameters, options, call } } // Deserialize Response - if (statusCode === 200) { + if (statusCode === 201) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); @@ -251,12 +262,57 @@ function _createOrUpdate(resourceGroupName, vaultName, parameters, options, call } /** - * Deletes the specified Azure key vault. + * Update a key vault in the specified subscription. * * @param {string} resourceGroupName The name of the Resource Group to which - * the vault belongs. + * the server belongs. * - * @param {string} vaultName The name of the vault to delete + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to patch the vault + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} [parameters.properties] Properties of the vault + * + * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} [parameters.properties.sku] SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve + * certificates stored as secrets from the key vault. + * + * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property + * to specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * + * @param {boolean} [parameters.properties.enabledForTemplateDeployment] + * Property to specify whether Azure Resource Manager is permitted to retrieve + * secrets from the key vault. + * + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion ('soft' delete) is enabled for this + * key vault. The property may not be set to false. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault; it is + * only effective if soft delete is also enabled. Once activated, the property + * may no longer be reset to false. * * @param {object} [options] Optional Parameters. * @@ -269,13 +325,14 @@ function _createOrUpdate(resourceGroupName, vaultName, parameters, options, call * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Vault} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _deleteMethod(resourceGroupName, vaultName, options, callback) { +function _update(resourceGroupName, vaultName, parameters, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -285,6 +342,10 @@ function _deleteMethod(resourceGroupName, vaultName, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + if (parameters === null || parameters === undefined) + { + parameters = {}; + } // Validate try { if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { @@ -293,9 +354,18 @@ function _deleteMethod(resourceGroupName, vaultName, options, callback) { if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { throw new Error('vaultName cannot be null or undefined and it must be of type string.'); } + if (vaultName !== null && vaultName !== undefined) { + if (vaultName.match(/^[a-zA-Z0-9-]{3,24}$/) === null) + { + throw new Error('"vaultName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9-]{3,24}$/'); + } + } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } @@ -320,7 +390,7 @@ function _deleteMethod(resourceGroupName, vaultName, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'DELETE'; + httpRequest.method = 'PATCH'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -338,14 +408,28 @@ function _deleteMethod(resourceGroupName, vaultName, options, callback) { } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['VaultPatchParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -373,18 +457,52 @@ function _deleteMethod(resourceGroupName, vaultName, options, callback) { // Create Result let result = null; if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Vault']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Vault']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } return callback(null, result, httpRequest, response); }); } /** - * Gets the specified Azure key vault. + * Deletes the specified Azure key vault. * * @param {string} resourceGroupName The name of the Resource Group to which * the vault belongs. * - * @param {string} vaultName The name of the vault. + * @param {string} vaultName The name of the vault to delete * * @param {object} [options] Optional Parameters. * @@ -397,14 +515,13 @@ function _deleteMethod(resourceGroupName, vaultName, options, callback) { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link Vault} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _get(resourceGroupName, vaultName, options, callback) { +function _deleteMethod(resourceGroupName, vaultName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -449,7 +566,7 @@ function _get(resourceGroupName, vaultName, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'GET'; + httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -502,38 +619,20 @@ function _get(resourceGroupName, vaultName, options, callback) { // Create Result let result = null; if (responseBody === '') responseBody = null; - // Deserialize Response - if (statusCode === 200) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['Vault']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } return callback(null, result, httpRequest, response); }); } /** - * The List operation gets information about the vaults associated with the - * subscription and within the specified resource group. + * Gets the specified Azure key vault. * * @param {string} resourceGroupName The name of the Resource Group to which * the vault belongs. * - * @param {object} [options] Optional Parameters. + * @param {string} vaultName The name of the vault. * - * @param {number} [options.top] Maximum number of results to return. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -545,13 +644,13 @@ function _get(resourceGroupName, vaultName, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link VaultListResult} for more information. + * See {@link Vault} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listByResourceGroup(resourceGroupName, options, callback) { +function _get(resourceGroupName, vaultName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -561,14 +660,13 @@ function _listByResourceGroup(resourceGroupName, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let top = (options && options.top !== undefined) ? options.top : undefined; // Validate try { if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } - if (top !== null && top !== undefined && typeof top !== 'number') { - throw new Error('top must be of type number.'); + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); @@ -585,13 +683,11 @@ function _listByResourceGroup(resourceGroupName, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; - if (top !== null && top !== undefined) { - queryParameters.push('$top=' + encodeURIComponent(top.toString())); - } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -659,7 +755,7 @@ function _listByResourceGroup(resourceGroupName, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['VaultListResult']().mapper(); + let resultMapper = new client.models['Vault']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -675,7 +771,23 @@ function _listByResourceGroup(resourceGroupName, options, callback) { } /** - * Gets information about the deleted vaults in a subscription. + * Update access policies in a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {string} operationKind Name of the operation. Possible values + * include: 'add', 'replace', 'remove' + * + * @param {object} parameters Access policy to merge into the vault + * + * @param {object} parameters.properties Properties of the access policy + * + * @param {array} parameters.properties.accessPolicies An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. * * @param {object} [options] Optional Parameters. * @@ -689,14 +801,14 @@ function _listByResourceGroup(resourceGroupName, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link DeletedVaultListResult} for more + * See {@link VaultAccessPolicyParameters} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listDeleted(options, callback) { +function _updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -708,9 +820,32 @@ function _listDeleted(options, callback) { } // Validate try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); + } + if (vaultName !== null && vaultName !== undefined) { + if (vaultName.match(/^[a-zA-Z0-9-]{3,24}$/) === null) + { + throw new Error('"vaultName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9-]{3,24}$/'); + } + } + if (operationKind) { + let allowedValues = [ 'add', 'replace', 'remove' ]; + if (!allowedValues.some( function(item) { return item === operationKind; })) { + throw new Error(operationKind + ' is not a valid value. The valid values are: ' + allowedValues); + } + } else { + throw new Error('operationKind cannot be null or undefined.'); + } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } @@ -723,7 +858,10 @@ function _listDeleted(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/accessPolicies/{operationKind}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); + requestUrl = requestUrl.replace('{operationKind}', encodeURIComponent(operationKind)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); @@ -733,7 +871,7 @@ function _listDeleted(options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'GET'; + httpRequest.method = 'PUT'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -751,14 +889,28 @@ function _listDeleted(options, callback) { } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['VaultAccessPolicyParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -793,7 +945,7 @@ function _listDeleted(options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['DeletedVaultListResult']().mapper(); + let resultMapper = new client.models['VaultAccessPolicyParameters']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -803,20 +955,39 @@ function _listDeleted(options, callback) { return callback(deserializationError); } } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['VaultAccessPolicyParameters']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } return callback(null, result, httpRequest, response); }); } /** - * Gets the deleted Azure key vault. - * - * @param {string} vaultName The name of the vault. + * The List operation gets information about the vaults associated with the + * subscription and within the specified resource group. * - * @param {string} location The location of the deleted vault. + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. * * @param {object} [options] Optional Parameters. * + * @param {number} [options.top] Maximum number of results to return. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -827,13 +998,13 @@ function _listDeleted(options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link DeletedVault} for more information. + * See {@link VaultListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _getDeleted(vaultName, location, options, callback) { +function _listByResourceGroup(resourceGroupName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -843,13 +1014,14 @@ function _getDeleted(vaultName, location, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let top = (options && options.top !== undefined) ? options.top : undefined; // Validate try { - if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { - throw new Error('vaultName cannot be null or undefined and it must be of type string.'); - } - if (location === null || location === undefined || typeof location.valueOf() !== 'string') { - throw new Error('location cannot be null or undefined and it must be of type string.'); + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); @@ -866,11 +1038,13 @@ function _getDeleted(vaultName, location, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}'; - requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); - requestUrl = requestUrl.replace('{location}', encodeURIComponent(location)); + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -938,7 +1112,7 @@ function _getDeleted(vaultName, location, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['DeletedVault']().mapper(); + let resultMapper = new client.models['VaultListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -953,70 +1127,6 @@ function _getDeleted(vaultName, location, options, callback) { }); } - -/** - * Permanently deletes the specified vault. aka Purges the deleted Azure key - * vault. - * - * @param {string} vaultName The name of the soft-deleted vault. - * - * @param {string} location The location of the soft-deleted vault. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _purgeDeleted(vaultName, location, options, callback) { - /* jshint validthis: true */ - let client = this.client; - if(!callback && typeof options === 'function') { - callback = options; - options = null; - } - - if (!callback) { - throw new Error('callback cannot be null.'); - } - - // Send request - this.beginPurgeDeleted(vaultName, location, options, (err, parsedResult, httpRequest, response) => { - if (err) return callback(err); - - let initialResult = new msRest.HttpOperationResponse(); - initialResult.request = httpRequest; - initialResult.response = response; - initialResult.body = response.body; - client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { - if (err) return callback(err); - - // Create Result - let result = null; - - httpRequest = pollingResult.request; - response = pollingResult.response; - let responseBody = pollingResult.body; - if (responseBody === '') responseBody = null; - - // Deserialize Response - - return callback(null, result, httpRequest, response); - }); - }); -} - /** * The List operation gets information about the vaults associated with the * subscription. @@ -1035,13 +1145,13 @@ function _purgeDeleted(vaultName, location, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ResourceListResult} for more information. + * See {@link VaultListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _list(options, callback) { +function _listBySubscription(options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1052,13 +1162,14 @@ function _list(options, callback) { throw new Error('callback cannot be null.'); } let top = (options && options.top !== undefined) ? options.top : undefined; - let filter = 'resourceType eq \'Microsoft.KeyVault/vaults\''; - let apiVersion = '2015-11-01'; // Validate try { if (top !== null && top !== undefined && typeof top !== 'number') { throw new Error('top must be of type number.'); } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } @@ -1071,14 +1182,13 @@ function _list(options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resources'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/vaults'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; - queryParameters.push('$filter=' + encodeURIComponent(filter)); if (top !== null && top !== undefined) { queryParameters.push('$top=' + encodeURIComponent(top.toString())); } - queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -1145,7 +1255,7 @@ function _list(options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['ResourceListResult']().mapper(); + let resultMapper = new client.models['VaultListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1161,12 +1271,7 @@ function _list(options, callback) { } /** - * Permanently deletes the specified vault. aka Purges the deleted Azure key - * vault. - * - * @param {string} vaultName The name of the soft-deleted vault. - * - * @param {string} location The location of the soft-deleted vault. + * Gets information about the deleted vaults in a subscription. * * @param {object} [options] Optional Parameters. * @@ -1179,13 +1284,15 @@ function _list(options, callback) { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DeletedVaultListResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _beginPurgeDeleted(vaultName, location, options, callback) { +function _listDeleted(options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1197,12 +1304,6 @@ function _beginPurgeDeleted(vaultName, location, options, callback) { } // Validate try { - if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { - throw new Error('vaultName cannot be null or undefined and it must be of type string.'); - } - if (location === null || location === undefined || typeof location.valueOf() !== 'string') { - throw new Error('location cannot be null or undefined and it must be of type string.'); - } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } @@ -1218,9 +1319,7 @@ function _beginPurgeDeleted(vaultName, location, options, callback) { // Construct URL let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge'; - requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); - requestUrl = requestUrl.replace('{location}', encodeURIComponent(location)); + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults'; requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); @@ -1230,7 +1329,7 @@ function _beginPurgeDeleted(vaultName, location, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'POST'; + httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -1255,7 +1354,7 @@ function _beginPurgeDeleted(vaultName, location, options, callback) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 202) { + if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -1283,17 +1382,34 @@ function _beginPurgeDeleted(vaultName, location, options, callback) { // Create Result let result = null; if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DeletedVaultListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } return callback(null, result, httpRequest, response); }); } /** - * The List operation gets information about the vaults associated with the - * subscription and within the specified resource group. + * Gets the deleted Azure key vault. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} vaultName The name of the vault. + * + * @param {string} location The location of the deleted vault. * * @param {object} [options] Optional Parameters. * @@ -1307,13 +1423,13 @@ function _beginPurgeDeleted(vaultName, location, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link VaultListResult} for more information. + * See {@link DeletedVault} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listByResourceGroupNext(nextPageLink, options, callback) { +function _getDeleted(vaultName, location, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1325,8 +1441,17 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { } // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); + } + if (location === null || location === undefined || typeof location.valueOf() !== 'string') { + throw new Error('location cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -1336,8 +1461,16 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}'; + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); + requestUrl = requestUrl.replace('{location}', encodeURIComponent(location)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -1401,7 +1534,7 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['VaultListResult']().mapper(); + let resultMapper = new client.models['DeletedVault']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1416,14 +1549,78 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { }); } + /** - * Gets information about the deleted vaults in a subscription. + * Permanently deletes the specified vault. aka Purges the deleted Azure key + * vault. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} vaultName The name of the soft-deleted vault. + * + * @param {string} location The location of the soft-deleted vault. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _purgeDeleted(vaultName, location, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginPurgeDeleted(vaultName, location, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * The List operation gets information about the vaults associated with the + * subscription. * * @param {object} [options] Optional Parameters. * + * @param {number} [options.top] Maximum number of results to return. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1434,14 +1631,13 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link DeletedVaultListResult} for more - * information. + * See {@link ResourceListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listDeletedNext(nextPageLink, options, callback) { +function _list(options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1451,10 +1647,16 @@ function _listDeletedNext(nextPageLink, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let top = (options && options.top !== undefined) ? options.top : undefined; + let filter = 'resourceType eq \'Microsoft.KeyVault/vaults\''; + let apiVersion = '2015-11-01'; // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (top !== null && top !== undefined && typeof top !== 'number') { + throw new Error('top must be of type number.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -1464,8 +1666,18 @@ function _listDeletedNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resources'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('$filter=' + encodeURIComponent(filter)); + if (top !== null && top !== undefined) { + queryParameters.push('$top=' + encodeURIComponent(top.toString())); + } + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -1529,7 +1741,7 @@ function _listDeletedNext(nextPageLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['DeletedVaultListResult']().mapper(); + let resultMapper = new client.models['ResourceListResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1545,11 +1757,11 @@ function _listDeletedNext(nextPageLink, options, callback) { } /** - * The List operation gets information about the vaults associated with the - * subscription. + * Checks that the vault name is valid and is not already in use. * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {object} vaultName The name of the vault. + * + * @param {string} vaultName.name The vault name. * * @param {object} [options] Optional Parameters. * @@ -1563,13 +1775,14 @@ function _listDeletedNext(nextPageLink, options, callback) { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ResourceListResult} for more information. + * See {@link CheckNameAvailabilityResult} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _listNext(nextPageLink, options, callback) { +function _checkNameAvailability(vaultName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -1579,10 +1792,20 @@ function _listNext(nextPageLink, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + if (vaultName === null || vaultName === undefined) + { + vaultName = {}; + } // Validate try { - if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { - throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + if (vaultName === null || vaultName === undefined) { + throw new Error('vaultName cannot be null or undefined.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -1592,12 +1815,18 @@ function _listNext(nextPageLink, options, callback) { } // Construct URL - let requestUrl = '{nextLink}'; - requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkNameAvailability'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'GET'; + httpRequest.method = 'POST'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -1615,7 +1844,21 @@ function _listNext(nextPageLink, options, callback) { } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (vaultName !== null && vaultName !== undefined) { + let requestModelMapper = new client.models['VaultCheckNameAvailabilityParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, vaultName, 'vaultName'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(vaultName, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { @@ -1657,7 +1900,7 @@ function _listNext(nextPageLink, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['ResourceListResult']().mapper(); + let resultMapper = new client.models['CheckNameAvailabilityResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1672,143 +1915,983 @@ function _listNext(nextPageLink, options, callback) { }); } -/** Class representing a Vaults. */ -class Vaults { - /** - * Create a Vaults. - * @param {KeyVaultManagementClient} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._createOrUpdate = _createOrUpdate; - this._deleteMethod = _deleteMethod; - this._get = _get; - this._listByResourceGroup = _listByResourceGroup; - this._listDeleted = _listDeleted; - this._getDeleted = _getDeleted; - this._purgeDeleted = _purgeDeleted; - this._list = _list; - this._beginPurgeDeleted = _beginPurgeDeleted; - this._listByResourceGroupNext = _listByResourceGroupNext; - this._listDeletedNext = _listDeletedNext; - this._listNext = _listNext; +/** + * Permanently deletes the specified vault. aka Purges the deleted Azure key + * vault. + * + * @param {string} vaultName The name of the soft-deleted vault. + * + * @param {string} location The location of the soft-deleted vault. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginPurgeDeleted(vaultName, location, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); + } + if (location === null || location === undefined || typeof location.valueOf() !== 'string') { + throw new Error('location cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); } - /** - * Create or update a key vault in the specified subscription. - * - * @param {string} resourceGroupName The name of the Resource Group to which - * the server belongs. - * - * @param {string} vaultName Name of the vault - * - * @param {object} parameters Parameters to create or update the vault - * - * @param {string} parameters.location The supported Azure location where the - * key vault should be created. - * - * @param {object} [parameters.tags] The tags that will be assigned to the key - * vault. - * - * @param {object} parameters.properties Properties of the vault - * - * @param {uuid} parameters.properties.tenantId The Azure Active Directory - * tenant ID that should be used for authenticating requests to the key vault. - * - * @param {object} parameters.properties.sku SKU details - * - * @param {string} parameters.properties.sku.name SKU name to specify whether - * the key vault is a standard vault or a premium vault. Possible values - * include: 'standard', 'premium' - * - * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 - * identities that have access to the key vault. All identities in the array - * must use the same tenant ID as the key vault's tenant ID. - * - * @param {string} [parameters.properties.vaultUri] The URI of the vault for - * performing operations on keys and secrets. - * - * @param {boolean} [parameters.properties.enabledForDeployment] Property to - * specify whether Azure Virtual Machines are permitted to retrieve - * certificates stored as secrets from the key vault. - * - * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property - * to specify whether Azure Disk Encryption is permitted to retrieve secrets - * from the vault and unwrap keys. - * - * @param {boolean} [parameters.properties.enabledForTemplateDeployment] - * Property to specify whether Azure Resource Manager is permitted to retrieve - * secrets from the key vault. - * - * @param {boolean} [parameters.properties.enableSoftDelete] Property to - * specify whether the 'soft delete' functionality is enabled for this key - * vault. It does not accept false value. - * - * @param {string} [parameters.properties.createMode] The vault's create mode - * to indicate whether the vault need to be recovered or not. Possible values - * include: 'recover', 'default' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - createOrUpdateWithHttpOperationResponse(resourceGroupName, vaultName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._createOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge'; + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); + requestUrl = requestUrl.replace('{location}', encodeURIComponent(location)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); } - /** - * Create or update a key vault in the specified subscription. - * - * @param {string} resourceGroupName The name of the Resource Group to which - * the server belongs. - * - * @param {string} vaultName Name of the vault - * - * @param {object} parameters Parameters to create or update the vault - * - * @param {string} parameters.location The supported Azure location where the - * key vault should be created. - * - * @param {object} [parameters.tags] The tags that will be assigned to the key - * vault. - * - * @param {object} parameters.properties Properties of the vault - * - * @param {uuid} parameters.properties.tenantId The Azure Active Directory - * tenant ID that should be used for authenticating requests to the key vault. - * - * @param {object} parameters.properties.sku SKU details - * - * @param {string} parameters.properties.sku.name SKU name to specify whether - * the key vault is a standard vault or a premium vault. Possible values - * include: 'standard', 'premium' - * - * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 - * identities that have access to the key vault. All identities in the array - * must use the same tenant ID as the key vault's tenant ID. - * - * @param {string} [parameters.properties.vaultUri] The URI of the vault for - * performing operations on keys and secrets. - * - * @param {boolean} [parameters.properties.enabledForDeployment] Property to - * specify whether Azure Virtual Machines are permitted to retrieve + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The List operation gets information about the vaults associated with the + * subscription and within the specified resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link VaultListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroupNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['VaultListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link VaultListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscriptionNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['VaultListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets information about the deleted vaults in a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DeletedVaultListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listDeletedNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DeletedVaultListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ResourceListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ResourceListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Vaults. */ +class Vaults { + /** + * Create a Vaults. + * @param {KeyVaultManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._updateAccessPolicy = _updateAccessPolicy; + this._listByResourceGroup = _listByResourceGroup; + this._listBySubscription = _listBySubscription; + this._listDeleted = _listDeleted; + this._getDeleted = _getDeleted; + this._purgeDeleted = _purgeDeleted; + this._list = _list; + this._checkNameAvailability = _checkNameAvailability; + this._beginPurgeDeleted = _beginPurgeDeleted; + this._listByResourceGroupNext = _listByResourceGroupNext; + this._listBySubscriptionNext = _listBySubscriptionNext; + this._listDeletedNext = _listDeletedNext; + this._listNext = _listNext; + } + + /** + * Create or update a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the server belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to create or update the vault + * + * @param {string} parameters.location The supported Azure location where the + * key vault should be created. + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} parameters.properties Properties of the vault + * + * @param {uuid} parameters.properties.tenantId The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} parameters.properties.sku SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {string} [parameters.properties.vaultUri] The URI of the vault for + * performing operations on keys and secrets. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve + * certificates stored as secrets from the key vault. + * + * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property + * to specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * + * @param {boolean} [parameters.properties.enabledForTemplateDeployment] + * Property to specify whether Azure Resource Manager is permitted to retrieve + * secrets from the key vault. + * + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion is enabled for this key vault. + * Setting this property to true activates the soft delete feature, whereby + * vaults or vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept false + * as its value. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault. + * Setting this property to true activates protection against purge for this + * vault and its content - only the Key Vault service may initiate a hard, + * irrecoverable deletion. The setting is effective only if soft delete is also + * enabled. Enabling this functionality is irreversible - that is, the property + * does not accept false as its value. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, vaultName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create or update a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the server belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to create or update the vault + * + * @param {string} parameters.location The supported Azure location where the + * key vault should be created. + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} parameters.properties Properties of the vault + * + * @param {uuid} parameters.properties.tenantId The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} parameters.properties.sku SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {string} [parameters.properties.vaultUri] The URI of the vault for + * performing operations on keys and secrets. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve + * certificates stored as secrets from the key vault. + * + * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property + * to specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * + * @param {boolean} [parameters.properties.enabledForTemplateDeployment] + * Property to specify whether Azure Resource Manager is permitted to retrieve + * secrets from the key vault. + * + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion is enabled for this key vault. + * Setting this property to true activates the soft delete feature, whereby + * vaults or vault entities can be recovered after deletion. Enabling this + * functionality is irreversible - that is, the property does not accept false + * as its value. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault. + * Setting this property to true activates protection against purge for this + * vault and its content - only the Key Vault service may initiate a hard, + * irrecoverable deletion. The setting is effective only if soft delete is also + * enabled. Enabling this functionality is irreversible - that is, the property + * does not accept false as its value. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Vault} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Vault} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback); + } + } + + /** + * Update a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the server belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to patch the vault + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} [parameters.properties] Properties of the vault + * + * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} [parameters.properties.sku] SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve + * certificates stored as secrets from the key vault. + * + * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property + * to specify whether Azure Disk Encryption is permitted to retrieve secrets + * from the vault and unwrap keys. + * + * @param {boolean} [parameters.properties.enabledForTemplateDeployment] + * Property to specify whether Azure Resource Manager is permitted to retrieve + * secrets from the key vault. + * + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion ('soft' delete) is enabled for this + * key vault. The property may not be set to false. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault; it is + * only effective if soft delete is also enabled. Once activated, the property + * may no longer be reset to false. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, vaultName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update a key vault in the specified subscription. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the server belongs. + * + * @param {string} vaultName Name of the vault + * + * @param {object} parameters Parameters to patch the vault + * + * @param {object} [parameters.tags] The tags that will be assigned to the key + * vault. + * + * @param {object} [parameters.properties] Properties of the vault + * + * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory + * tenant ID that should be used for authenticating requests to the key vault. + * + * @param {object} [parameters.properties.sku] SKU details + * + * @param {string} parameters.properties.sku.name SKU name to specify whether + * the key vault is a standard vault or a premium vault. Possible values + * include: 'standard', 'premium' + * + * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. + * + * @param {boolean} [parameters.properties.enabledForDeployment] Property to + * specify whether Azure Virtual Machines are permitted to retrieve * certificates stored as secrets from the key vault. * * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property @@ -1819,13 +2902,193 @@ class Vaults { * Property to specify whether Azure Resource Manager is permitted to retrieve * secrets from the key vault. * - * @param {boolean} [parameters.properties.enableSoftDelete] Property to - * specify whether the 'soft delete' functionality is enabled for this key - * vault. It does not accept false value. + * @param {boolean} [parameters.properties.enableSoftDelete] Property + * specifying whether recoverable deletion ('soft' delete) is enabled for this + * key vault. The property may not be set to false. + * + * @param {string} [parameters.properties.createMode] The vault's create mode + * to indicate whether the vault need to be recovered or not. Possible values + * include: 'recover', 'default' + * + * @param {boolean} [parameters.properties.enablePurgeProtection] Property + * specifying whether protection against purge is enabled for this vault; it is + * only effective if soft delete is also enabled. Once activated, the property + * may no longer be reset to false. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Vault} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Vault} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, vaultName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, vaultName, parameters, options, optionalCallback); + } + } + + /** + * Deletes the specified Azure key vault. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. + * + * @param {string} vaultName The name of the vault to delete + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, vaultName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, vaultName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the specified Azure key vault. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. + * + * @param {string} vaultName The name of the vault to delete + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, vaultName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, vaultName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, vaultName, options, optionalCallback); + } + } + + /** + * Gets the specified Azure key vault. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. + * + * @param {string} vaultName The name of the vault. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, vaultName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, vaultName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the specified Azure key vault. + * + * @param {string} resourceGroupName The name of the Resource Group to which + * the vault belongs. * - * @param {string} [parameters.properties.createMode] The vault's create mode - * to indicate whether the vault need to be recovered or not. Possible values - * include: 'recover', 'default' + * @param {string} vaultName The name of the vault. * * @param {object} [options] Optional Parameters. * @@ -1854,7 +3117,7 @@ class Vaults { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback) { + get(resourceGroupName, vaultName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1863,24 +3126,35 @@ class Vaults { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._createOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => { + self._get(resourceGroupName, vaultName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._createOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback); + return self._get(resourceGroupName, vaultName, options, optionalCallback); } } /** - * Deletes the specified Azure key vault. + * Update access policies in a key vault in the specified subscription. * * @param {string} resourceGroupName The name of the Resource Group to which * the vault belongs. * - * @param {string} vaultName The name of the vault to delete + * @param {string} vaultName Name of the vault + * + * @param {string} operationKind Name of the operation. Possible values + * include: 'add', 'replace', 'remove' + * + * @param {object} parameters Access policy to merge into the vault + * + * @param {object} parameters.properties Properties of the access policy + * + * @param {array} parameters.properties.accessPolicies An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. * * @param {object} [options] Optional Parameters. * @@ -1889,15 +3163,15 @@ class Vaults { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - deleteMethodWithHttpOperationResponse(resourceGroupName, vaultName, options) { + updateAccessPolicyWithHttpOperationResponse(resourceGroupName, vaultName, operationKind, parameters, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._deleteMethod(resourceGroupName, vaultName, options, (err, result, request, response) => { + self._updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1908,12 +3182,23 @@ class Vaults { } /** - * Deletes the specified Azure key vault. + * Update access policies in a key vault in the specified subscription. * * @param {string} resourceGroupName The name of the Resource Group to which * the vault belongs. * - * @param {string} vaultName The name of the vault to delete + * @param {string} vaultName Name of the vault + * + * @param {string} operationKind Name of the operation. Possible values + * include: 'add', 'replace', 'remove' + * + * @param {object} parameters Access policy to merge into the vault + * + * @param {object} parameters.properties Properties of the access policy + * + * @param {array} parameters.properties.accessPolicies An array of 0 to 16 + * identities that have access to the key vault. All identities in the array + * must use the same tenant ID as the key vault's tenant ID. * * @param {object} [options] Optional Parameters. * @@ -1927,7 +3212,7 @@ class Vaults { * * {Promise} A promise is returned * - * @resolve {null} - The deserialized result object. + * @resolve {VaultAccessPolicyParameters} - The deserialized result object. * * @reject {Error} - The error object. * @@ -1935,13 +3220,15 @@ class Vaults { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link VaultAccessPolicyParameters} for more + * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - deleteMethod(resourceGroupName, vaultName, options, optionalCallback) { + updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1950,41 +3237,42 @@ class Vaults { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._deleteMethod(resourceGroupName, vaultName, options, (err, result, request, response) => { + self._updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._deleteMethod(resourceGroupName, vaultName, options, optionalCallback); + return self._updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, optionalCallback); } } /** - * Gets the specified Azure key vault. + * The List operation gets information about the vaults associated with the + * subscription and within the specified resource group. * * @param {string} resourceGroupName The name of the Resource Group to which * the vault belongs. * - * @param {string} vaultName The name of the vault. - * * @param {object} [options] Optional Parameters. * + * @param {number} [options.top] Maximum number of results to return. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - getWithHttpOperationResponse(resourceGroupName, vaultName, options) { + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._get(resourceGroupName, vaultName, options, (err, result, request, response) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1995,15 +3283,16 @@ class Vaults { } /** - * Gets the specified Azure key vault. + * The List operation gets information about the vaults associated with the + * subscription and within the specified resource group. * * @param {string} resourceGroupName The name of the Resource Group to which * the vault belongs. * - * @param {string} vaultName The name of the vault. - * * @param {object} [options] Optional Parameters. * + * @param {number} [options.top] Maximum number of results to return. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2014,7 +3303,7 @@ class Vaults { * * {Promise} A promise is returned * - * @resolve {Vault} - The deserialized result object. + * @resolve {VaultListResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2023,13 +3312,13 @@ class Vaults { * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. - * See {@link Vault} for more information. + * See {@link VaultListResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - get(resourceGroupName, vaultName, options, optionalCallback) { + listByResourceGroup(resourceGroupName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2038,23 +3327,20 @@ class Vaults { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._get(resourceGroupName, vaultName, options, (err, result, request, response) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._get(resourceGroupName, vaultName, options, optionalCallback); + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); } } /** * The List operation gets information about the vaults associated with the - * subscription and within the specified resource group. - * - * @param {string} resourceGroupName The name of the Resource Group to which - * the vault belongs. + * subscription. * * @param {object} [options] Optional Parameters. * @@ -2069,11 +3355,11 @@ class Vaults { * * @reject {Error} - The error object. */ - listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + listBySubscriptionWithHttpOperationResponse(options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + self._listBySubscription(options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2085,10 +3371,7 @@ class Vaults { /** * The List operation gets information about the vaults associated with the - * subscription and within the specified resource group. - * - * @param {string} resourceGroupName The name of the Resource Group to which - * the vault belongs. + * subscription. * * @param {object} [options] Optional Parameters. * @@ -2119,7 +3402,7 @@ class Vaults { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - listByResourceGroup(resourceGroupName, options, optionalCallback) { + listBySubscription(options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2128,14 +3411,14 @@ class Vaults { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + self._listBySubscription(options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + return self._listBySubscription(options, optionalCallback); } } @@ -2475,6 +3758,93 @@ class Vaults { } } + /** + * Checks that the vault name is valid and is not already in use. + * + * @param {object} vaultName The name of the vault. + * + * @param {string} vaultName.name The vault name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + checkNameAvailabilityWithHttpOperationResponse(vaultName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._checkNameAvailability(vaultName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Checks that the vault name is valid and is not already in use. + * + * @param {object} vaultName The name of the vault. + * + * @param {string} vaultName.name The vault name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CheckNameAvailabilityResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CheckNameAvailabilityResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + checkNameAvailability(vaultName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._checkNameAvailability(vaultName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._checkNameAvailability(vaultName, options, optionalCallback); + } + } + /** * Permanently deletes the specified vault. aka Purges the deleted Azure key * vault. @@ -2648,6 +4018,92 @@ class Vaults { } } + /** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * The List operation gets information about the vaults associated with the + * subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {VaultListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link VaultListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscriptionNext(nextPageLink, options, optionalCallback); + } + } + /** * Gets information about the deleted vaults in a subscription. *