diff --git a/lib/services/imagebuilderManagement/LICENSE.txt b/lib/services/imagebuilderManagement/LICENSE.txt new file mode 100644 index 0000000000..8f3d856145 --- /dev/null +++ b/lib/services/imagebuilderManagement/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/imagebuilderManagement/README.md b/lib/services/imagebuilderManagement/README.md new file mode 100644 index 0000000000..e212eec062 --- /dev/null +++ b/lib/services/imagebuilderManagement/README.md @@ -0,0 +1,43 @@ +--- +uid: azure-arm-imagebuilder +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** +## Microsoft Azure SDK for Node.js - ImageBuilderClient + +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-arm-imagebuilder +``` + +### How to use + +#### Authentication, client creation, and list virtualMachineImageTemplates as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const ImageBuilderClient = require("azure-arm-imagebuilder"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new ImageBuilderClient(creds, subscriptionId); + + return client.virtualMachineImageTemplates.list().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); +``` +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/imagebuilderManagement/lib/imageBuilderClient.d.ts b/lib/services/imagebuilderManagement/lib/imageBuilderClient.d.ts new file mode 100644 index 0000000000..04f570265f --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/imageBuilderClient.d.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { ServiceClientCredentials } from 'ms-rest'; +import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class ImageBuilderClient extends AzureServiceClient { + /** + * Initializes a new instance of the ImageBuilderClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @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 + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.acceptLanguage] - The preferred language for the response. + * + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + */ + constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + subscriptionId: string; + + apiVersion: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + virtualMachineImageTemplates: operations.VirtualMachineImageTemplates; + operations: operations.Operations; +} + +export { ImageBuilderClient, models as ImageBuilderModels }; diff --git a/lib/services/imagebuilderManagement/lib/imageBuilderClient.js b/lib/services/imagebuilderManagement/lib/imageBuilderClient.js new file mode 100644 index 0000000000..e33c9916af --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/imageBuilderClient.js @@ -0,0 +1,86 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const ServiceClient = msRestAzure.AzureServiceClient; + +const models = require('./models'); +const operations = require('./operations'); + + +/** Class representing a ImageBuilderClient. */ +class ImageBuilderClient extends ServiceClient { + /** + * Create a ImageBuilderClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @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 + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * @param {string} [options.acceptLanguage] - The preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + */ + constructor(credentials, subscriptionId, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.apiVersion = '2019-02-01-preview'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://management.azure.com'; + } + this.credentials = credentials; + this.subscriptionId = subscriptionId; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { + this.generateClientRequestId = options.generateClientRequestId; + } + this.virtualMachineImageTemplates = new operations.VirtualMachineImageTemplates(this); + this.operations = new operations.Operations(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = ImageBuilderClient; +module.exports['default'] = ImageBuilderClient; +module.exports.ImageBuilderClient = ImageBuilderClient; +module.exports.ImageBuilderModels = models; diff --git a/lib/services/imagebuilderManagement/lib/models/apiError.js b/lib/services/imagebuilderManagement/lib/models/apiError.js new file mode 100644 index 0000000000..2c783f0d2a --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/apiError.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'; + +/** + * Api error. + * + */ +class ApiError { + /** + * Create a ApiError. + * @property {array} [details] The Api error details + * @property {object} [innerError] The Api inner error + * @property {string} [innerError.exceptionType] The exception type. + * @property {string} [innerError.errorDetail] The internal error message or + * exception dump. + * @property {string} [code] The error code. + * @property {string} [target] The target of the particular error. + * @property {string} [message] The error message. + */ + constructor() { + } + + /** + * Defines the metadata of ApiError + * + * @returns {object} metadata of ApiError + * + */ + mapper() { + return { + required: false, + serializedName: 'ApiError', + type: { + name: 'Composite', + className: 'ApiError', + modelProperties: { + details: { + required: false, + serializedName: 'details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ApiErrorBaseElementType', + type: { + name: 'Composite', + className: 'ApiErrorBase' + } + } + } + }, + innerError: { + required: false, + serializedName: 'innerError', + type: { + name: 'Composite', + className: 'InnerError' + } + }, + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + target: { + required: false, + serializedName: 'target', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApiError; diff --git a/lib/services/imagebuilderManagement/lib/models/apiErrorBase.js b/lib/services/imagebuilderManagement/lib/models/apiErrorBase.js new file mode 100644 index 0000000000..a93aabea5b --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/apiErrorBase.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'; + +/** + * Api error base. + * + */ +class ApiErrorBase { + /** + * Create a ApiErrorBase. + * @property {string} [code] The error code. + * @property {string} [target] The target of the particular error. + * @property {string} [message] The error message. + */ + constructor() { + } + + /** + * Defines the metadata of ApiErrorBase + * + * @returns {object} metadata of ApiErrorBase + * + */ + mapper() { + return { + required: false, + serializedName: 'ApiErrorBase', + type: { + name: 'Composite', + className: 'ApiErrorBase', + modelProperties: { + code: { + required: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + target: { + required: false, + serializedName: 'target', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ApiErrorBase; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplate.js b/lib/services/imagebuilderManagement/lib/models/imageTemplate.js new file mode 100644 index 0000000000..f112793e04 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplate.js @@ -0,0 +1,201 @@ +/* + * 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'); + +/** + * Class representing a ImageTemplate. + * @extends models['Resource'] + */ +class ImageTemplate extends models['Resource'] { + /** + * Create a ImageTemplate. + * @property {object} source Specifies the properties used to describe the + * source image. + * @property {string} [source.type] Polymorphic Discriminator + * @property {array} [customize] Specifies the properties used to describe + * the customization steps of the image, like Image source etc + * @property {array} distribute The distribution targets where the image + * output needs to go to. + * @property {string} [provisioningState] Provisioning state of the resource. + * Possible values include: 'Creating', 'Succeeded', 'Failed', 'Deleting' + * @property {object} [provisioningError] Provisioning error, if any + * @property {string} [provisioningError.provisioningErrorCode] Error code of + * the provisioning failure. Possible values include: 'BadSourceType', + * 'BadPIRSource', 'BadISOSource', 'BadManagedImageSource', + * 'BadCustomizerType', 'UnsupportedCustomizerType', 'NoCustomizerScript', + * 'BadDistributeType', 'BadSharedImageDistribute', 'ServerError', 'Other' + * @property {string} [provisioningError.message] Verbose error message about + * the provisioning failure + * @property {object} [lastRunStatus] State of 'run' that is currently + * executing or was last executed. + * @property {date} [lastRunStatus.startTime] Start time of the last run + * (UTC) + * @property {date} [lastRunStatus.endTime] End time of the last run (UTC) + * @property {string} [lastRunStatus.runState] State of the last run. + * Possible values include: 'Running', 'Succeeded', 'PartiallySucceeded', + * 'Failed' + * @property {string} [lastRunStatus.runSubState] Sub-state of the last run. + * Possible values include: 'Queued', 'Building', 'Customizing', + * 'Distributing' + * @property {string} [lastRunStatus.message] Verbose information about the + * last run state + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplate + * + * @returns {object} metadata of ImageTemplate + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplate', + type: { + name: 'Composite', + className: 'ImageTemplate', + 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: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + source: { + required: true, + serializedName: 'properties.source', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateSource', + className: 'ImageTemplateSource' + } + }, + customize: { + required: false, + serializedName: 'properties.customize', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ImageTemplateCustomizerElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateCustomizer', + className: 'ImageTemplateCustomizer' + } + } + } + }, + distribute: { + required: true, + serializedName: 'properties.distribute', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ImageTemplateDistributorElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateDistributor', + className: 'ImageTemplateDistributor' + } + } + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + provisioningError: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningError', + type: { + name: 'Composite', + className: 'ProvisioningError' + } + }, + lastRunStatus: { + required: false, + readOnly: true, + serializedName: 'properties.lastRunStatus', + type: { + name: 'Composite', + className: 'ImageTemplateLastRunStatus' + } + } + } + } + }; + } +} + +module.exports = ImageTemplate; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateCustomizer.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateCustomizer.js new file mode 100644 index 0000000000..75205ba24d --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateCustomizer.js @@ -0,0 +1,66 @@ +/* + * 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'; + +/** + * Class representing a ImageTemplateCustomizer. + */ +class ImageTemplateCustomizer { + /** + * Create a ImageTemplateCustomizer. + * @property {string} [name] Friendly Name to provide context on what this + * customization step does + * @property {string} type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ImageTemplateCustomizer + * + * @returns {object} metadata of ImageTemplateCustomizer + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplateCustomizer', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateCustomizer', + className: 'ImageTemplateCustomizer', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateCustomizer; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateDistributor.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateDistributor.js new file mode 100644 index 0000000000..b32662a593 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateDistributor.js @@ -0,0 +1,86 @@ +/* + * 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'; + +/** + * Generic distribution object + * + */ +class ImageTemplateDistributor { + /** + * Create a ImageTemplateDistributor. + * @property {string} runOutputName The name to be used for the associated + * RunOutput. + * @property {object} [artifactTags] Tags that will be applied to the + * artifact once it has been created/updated by the distributor. + * @property {string} type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ImageTemplateDistributor + * + * @returns {object} metadata of ImageTemplateDistributor + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplateDistributor', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateDistributor', + className: 'ImageTemplateDistributor', + modelProperties: { + runOutputName: { + required: true, + serializedName: 'runOutputName', + constraints: { + Pattern: /^[A-Za-z0-9-_]{1,64}$/ + }, + type: { + name: 'String' + } + }, + artifactTags: { + required: false, + serializedName: 'artifactTags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateDistributor; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateIsoSource.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateIsoSource.js new file mode 100644 index 0000000000..39d4e65c9c --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateIsoSource.js @@ -0,0 +1,80 @@ +/* + * 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'); + +/** + * Describes an image source that is an installation ISO. Currently only + * supports Red Hat Enterprise Linux 7.2-7.5 ISO's. + * + * @extends models['ImageTemplateSource'] + */ +class ImageTemplateIsoSource extends models['ImageTemplateSource'] { + /** + * Create a ImageTemplateIsoSource. + * @property {string} sourceURI URI to get the ISO image. This URI has to be + * accessible to the resource provider at the time of the image template + * creation. + * @property {string} sha256Checksum SHA256 Checksum of the ISO image. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateIsoSource + * + * @returns {object} metadata of ImageTemplateIsoSource + * + */ + mapper() { + return { + required: false, + serializedName: 'ISO', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateSource', + className: 'ImageTemplateIsoSource', + modelProperties: { + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + sourceURI: { + required: true, + serializedName: 'sourceURI', + type: { + name: 'String' + } + }, + sha256Checksum: { + required: true, + serializedName: 'sha256Checksum', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateIsoSource; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateLastRunStatus.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateLastRunStatus.js new file mode 100644 index 0000000000..cd8a6ee615 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateLastRunStatus.js @@ -0,0 +1,85 @@ +/* + * 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'; + +/** + * Class representing a ImageTemplateLastRunStatus. + */ +class ImageTemplateLastRunStatus { + /** + * Create a ImageTemplateLastRunStatus. + * @property {date} [startTime] Start time of the last run (UTC) + * @property {date} [endTime] End time of the last run (UTC) + * @property {string} [runState] State of the last run. Possible values + * include: 'Running', 'Succeeded', 'PartiallySucceeded', 'Failed' + * @property {string} [runSubState] Sub-state of the last run. Possible + * values include: 'Queued', 'Building', 'Customizing', 'Distributing' + * @property {string} [message] Verbose information about the last run state + */ + constructor() { + } + + /** + * Defines the metadata of ImageTemplateLastRunStatus + * + * @returns {object} metadata of ImageTemplateLastRunStatus + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplateLastRunStatus', + type: { + name: 'Composite', + className: 'ImageTemplateLastRunStatus', + modelProperties: { + startTime: { + required: false, + serializedName: 'startTime', + type: { + name: 'DateTime' + } + }, + endTime: { + required: false, + serializedName: 'endTime', + type: { + name: 'DateTime' + } + }, + runState: { + required: false, + serializedName: 'runState', + type: { + name: 'String' + } + }, + runSubState: { + required: false, + serializedName: 'runSubState', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateLastRunStatus; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateListResult.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateListResult.js new file mode 100644 index 0000000000..540f1e214c --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateListResult.js @@ -0,0 +1,67 @@ +/* + * 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'; + +/** + * Class representing a ImageTemplateListResult. + */ +class ImageTemplateListResult extends Array { + /** + * Create a ImageTemplateListResult. + * @property {string} [nextLink] The continuation token. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateListResult + * + * @returns {object} metadata of ImageTemplateListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplateListResult', + type: { + name: 'Composite', + className: 'ImageTemplateListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ImageTemplateElementType', + type: { + name: 'Composite', + className: 'ImageTemplate' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateListResult; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateManagedImageDistributor.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateManagedImageDistributor.js new file mode 100644 index 0000000000..26d7bbb6be --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateManagedImageDistributor.js @@ -0,0 +1,102 @@ +/* + * 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'); + +/** + * Distribute as a Managed Disk Image. + * + * @extends models['ImageTemplateDistributor'] + */ +class ImageTemplateManagedImageDistributor extends models['ImageTemplateDistributor'] { + /** + * Create a ImageTemplateManagedImageDistributor. + * @property {string} imageId Resource Id of the Managed Disk Image + * @property {string} location Azure location for the image, should match if + * image already exists + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateManagedImageDistributor + * + * @returns {object} metadata of ImageTemplateManagedImageDistributor + * + */ + mapper() { + return { + required: false, + serializedName: 'ManagedImage', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateDistributor', + className: 'ImageTemplateManagedImageDistributor', + modelProperties: { + runOutputName: { + required: true, + serializedName: 'runOutputName', + constraints: { + Pattern: /^[A-Za-z0-9-_]{1,64}$/ + }, + type: { + name: 'String' + } + }, + artifactTags: { + required: false, + serializedName: 'artifactTags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + imageId: { + required: true, + serializedName: 'imageId', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateManagedImageDistributor; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateManagedImageSource.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateManagedImageSource.js new file mode 100644 index 0000000000..196f026c50 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateManagedImageSource.js @@ -0,0 +1,70 @@ +/* + * 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'); + +/** + * Describes an image source that is a managed image in customer subscription. + * + * @extends models['ImageTemplateSource'] + */ +class ImageTemplateManagedImageSource extends models['ImageTemplateSource'] { + /** + * Create a ImageTemplateManagedImageSource. + * @property {string} imageId ARM resource id of the managed image in + * customer subscription + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateManagedImageSource + * + * @returns {object} metadata of ImageTemplateManagedImageSource + * + */ + mapper() { + return { + required: false, + serializedName: 'ManagedImage', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateSource', + className: 'ImageTemplateManagedImageSource', + modelProperties: { + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + imageId: { + required: true, + serializedName: 'imageId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateManagedImageSource; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplatePlatformImageSource.js b/lib/services/imagebuilderManagement/lib/models/imageTemplatePlatformImageSource.js new file mode 100644 index 0000000000..157e7f51b0 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplatePlatformImageSource.js @@ -0,0 +1,98 @@ +/* + * 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'); + +/** + * Describes an image source from [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + * + * @extends models['ImageTemplateSource'] + */ +class ImageTemplatePlatformImageSource extends models['ImageTemplateSource'] { + /** + * Create a ImageTemplatePlatformImageSource. + * @property {string} [publisher] Image Publisher in [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + * @property {string} [offer] Image offer from the [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + * @property {string} [sku] Image sku from the [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + * @property {string} [version] Image version from the [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplatePlatformImageSource + * + * @returns {object} metadata of ImageTemplatePlatformImageSource + * + */ + mapper() { + return { + required: false, + serializedName: 'PlatformImage', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateSource', + className: 'ImageTemplatePlatformImageSource', + modelProperties: { + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + publisher: { + required: false, + serializedName: 'publisher', + type: { + name: 'String' + } + }, + offer: { + required: false, + serializedName: 'offer', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'String' + } + }, + version: { + required: false, + serializedName: 'version', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplatePlatformImageSource; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplatePowerShellCustomizer.js b/lib/services/imagebuilderManagement/lib/models/imageTemplatePowerShellCustomizer.js new file mode 100644 index 0000000000..268a0e1dfb --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplatePowerShellCustomizer.js @@ -0,0 +1,93 @@ +/* + * 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'); + +/** + * Runs the specified PowerSehll on the VM (Windows). Corresponds to Packer + * powershell provisioner + * + * @extends models['ImageTemplateCustomizer'] + */ +class ImageTemplatePowerShellCustomizer extends models['ImageTemplateCustomizer'] { + /** + * Create a ImageTemplatePowerShellCustomizer. + * @property {string} [script] The PowerShell script to be run for + * customizing. It can be a github link, SAS URI for Azure Storage, etc + * @property {array} [validExitCodes] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplatePowerShellCustomizer + * + * @returns {object} metadata of ImageTemplatePowerShellCustomizer + * + */ + mapper() { + return { + required: false, + serializedName: 'PowerShell', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateCustomizer', + className: 'ImageTemplatePowerShellCustomizer', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + script: { + required: false, + serializedName: 'script', + type: { + name: 'String' + } + }, + validExitCodes: { + required: false, + serializedName: 'validExitCodes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'NumberElementType', + type: { + name: 'Number' + } + } + } + } + } + } + }; + } +} + +module.exports = ImageTemplatePowerShellCustomizer; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateRestartCustomizer.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateRestartCustomizer.js new file mode 100644 index 0000000000..75103922dc --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateRestartCustomizer.js @@ -0,0 +1,97 @@ +/* + * 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'); + +/** + * Reboots a VM and waits for it to come back online (Windows). Corresponds to + * Packer windows-restart provisioner + * + * @extends models['ImageTemplateCustomizer'] + */ +class ImageTemplateRestartCustomizer extends models['ImageTemplateCustomizer'] { + /** + * Create a ImageTemplateRestartCustomizer. + * @property {string} [restartCommand] Command to execute the restart + * [Default: 'shutdown /r /f /t 0 /c "packer restart"'] + * @property {string} [restartCheckCommand] Command to check if restart + * succeeded [Default: ''] + * @property {string} [restartTimeout] Restart timeout specified as a string + * of magnitude and unit, e.g. '5m' (5 minutes) or '2h' (2 hours) [Default: + * '5m'] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateRestartCustomizer + * + * @returns {object} metadata of ImageTemplateRestartCustomizer + * + */ + mapper() { + return { + required: false, + serializedName: 'WindowsRestart', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateCustomizer', + className: 'ImageTemplateRestartCustomizer', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + restartCommand: { + required: false, + serializedName: 'restartCommand', + type: { + name: 'String' + } + }, + restartCheckCommand: { + required: false, + serializedName: 'restartCheckCommand', + type: { + name: 'String' + } + }, + restartTimeout: { + required: false, + serializedName: 'restartTimeout', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateRestartCustomizer; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateSharedImageDistributor.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateSharedImageDistributor.js new file mode 100644 index 0000000000..0515d9ca0a --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateSharedImageDistributor.js @@ -0,0 +1,109 @@ +/* + * 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'); + +/** + * Distribute via Shared Image Gallery. + * + * @extends models['ImageTemplateDistributor'] + */ +class ImageTemplateSharedImageDistributor extends models['ImageTemplateDistributor'] { + /** + * Create a ImageTemplateSharedImageDistributor. + * @property {string} galleryImageId Resource Id of the Shared Image Gallery + * image + * @property {array} replicationRegions + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateSharedImageDistributor + * + * @returns {object} metadata of ImageTemplateSharedImageDistributor + * + */ + mapper() { + return { + required: false, + serializedName: 'SharedImage', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateDistributor', + className: 'ImageTemplateSharedImageDistributor', + modelProperties: { + runOutputName: { + required: true, + serializedName: 'runOutputName', + constraints: { + Pattern: /^[A-Za-z0-9-_]{1,64}$/ + }, + type: { + name: 'String' + } + }, + artifactTags: { + required: false, + serializedName: 'artifactTags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + galleryImageId: { + required: true, + serializedName: 'galleryImageId', + type: { + name: 'String' + } + }, + replicationRegions: { + required: true, + serializedName: 'replicationRegions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ImageTemplateSharedImageDistributor; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateShellCustomizer.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateShellCustomizer.js new file mode 100644 index 0000000000..ea052e7110 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateShellCustomizer.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'; + +const models = require('./index'); + +/** + * Runs a shell script during the customization phase (Linux) + * + * @extends models['ImageTemplateCustomizer'] + */ +class ImageTemplateShellCustomizer extends models['ImageTemplateCustomizer'] { + /** + * Create a ImageTemplateShellCustomizer. + * @property {string} [script] The shell script to be run for customizing. It + * can be a github link, SAS URI for Azure Storage, etc + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateShellCustomizer + * + * @returns {object} metadata of ImageTemplateShellCustomizer + * + */ + mapper() { + return { + required: false, + serializedName: 'Shell', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateCustomizer', + className: 'ImageTemplateShellCustomizer', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + script: { + required: false, + serializedName: 'script', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateShellCustomizer; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateSource.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateSource.js new file mode 100644 index 0000000000..a11996ecec --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateSource.js @@ -0,0 +1,57 @@ +/* + * 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'; + +/** + * Class representing a ImageTemplateSource. + */ +class ImageTemplateSource { + /** + * Create a ImageTemplateSource. + * @property {string} type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ImageTemplateSource + * + * @returns {object} metadata of ImageTemplateSource + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplateSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateSource', + className: 'ImageTemplateSource', + modelProperties: { + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateSource; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateUpdateParameters.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateUpdateParameters.js new file mode 100644 index 0000000000..de57402ab7 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateUpdateParameters.js @@ -0,0 +1,60 @@ +/* + * 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'; + +/** + * Parameters for updating an image template. + * + */ +class ImageTemplateUpdateParameters { + /** + * Create a ImageTemplateUpdateParameters. + * @property {object} [tags] The user-specified tags associated with the + * image template. + */ + constructor() { + } + + /** + * Defines the metadata of ImageTemplateUpdateParameters + * + * @returns {object} metadata of ImageTemplateUpdateParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'ImageTemplateUpdateParameters', + type: { + name: 'Composite', + className: 'ImageTemplateUpdateParameters', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ImageTemplateUpdateParameters; diff --git a/lib/services/imagebuilderManagement/lib/models/imageTemplateVhdDistributor.js b/lib/services/imagebuilderManagement/lib/models/imageTemplateVhdDistributor.js new file mode 100644 index 0000000000..c6e5151bb1 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/imageTemplateVhdDistributor.js @@ -0,0 +1,85 @@ +/* + * 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'); + +/** + * Distribute via VHD in a storage account. + * + * @extends models['ImageTemplateDistributor'] + */ +class ImageTemplateVhdDistributor extends models['ImageTemplateDistributor'] { + /** + * Create a ImageTemplateVhdDistributor. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ImageTemplateVhdDistributor + * + * @returns {object} metadata of ImageTemplateVhdDistributor + * + */ + mapper() { + return { + required: false, + serializedName: 'VHD', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'type', + clientName: 'type' + }, + uberParent: 'ImageTemplateDistributor', + className: 'ImageTemplateVhdDistributor', + modelProperties: { + runOutputName: { + required: true, + serializedName: 'runOutputName', + constraints: { + Pattern: /^[A-Za-z0-9-_]{1,64}$/ + }, + type: { + name: 'String' + } + }, + artifactTags: { + required: false, + serializedName: 'artifactTags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + type: { + required: true, + serializedName: 'type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ImageTemplateVhdDistributor; diff --git a/lib/services/imagebuilderManagement/lib/models/index.d.ts b/lib/services/imagebuilderManagement/lib/models/index.d.ts new file mode 100644 index 0000000000..8db6496d01 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/index.d.ts @@ -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. + */ + +import { BaseResource, CloudError } from "ms-rest-azure"; +import * as moment from "moment"; + +export { + + BaseResource, + CloudError +}; + +export interface ImageTemplateSource { + /** + * Polymorphic Discriminator + */ + type: string; +} + +export interface ImageTemplateCustomizer { + /** + * Friendly Name to provide context on what this customization step does + */ + name?: string; + /** + * Polymorphic Discriminator + */ + type: string; +} + +/** + * Generic distribution object +*/ +export interface ImageTemplateDistributor { + /** + * The name to be used for the associated RunOutput. + */ + runOutputName: string; + /** + * Tags that will be applied to the artifact once it has been created/updated by the distributor. + */ + artifactTags?: { [propertyName: string]: string }; + /** + * Polymorphic Discriminator + */ + type: string; +} + +export interface ProvisioningError { + /** + * Error code of the provisioning failure. Possible values include: 'BadSourceType', + * 'BadPIRSource', 'BadISOSource', 'BadManagedImageSource', 'BadCustomizerType', + * 'UnsupportedCustomizerType', 'NoCustomizerScript', 'BadDistributeType', + * 'BadSharedImageDistribute', 'ServerError', 'Other' + */ + provisioningErrorCode?: string; + /** + * Verbose error message about the provisioning failure + */ + message?: string; +} + +export interface ImageTemplateLastRunStatus { + /** + * Start time of the last run (UTC) + */ + startTime?: Date; + /** + * End time of the last run (UTC) + */ + endTime?: Date; + /** + * State of the last run. Possible values include: 'Running', 'Succeeded', 'PartiallySucceeded', + * 'Failed' + */ + runState?: string; + /** + * Sub-state of the last run. Possible values include: 'Queued', 'Building', 'Customizing', + * 'Distributing' + */ + runSubState?: string; + /** + * Verbose information about the last run state + */ + message?: string; +} + +/** + * The Resource model definition. +*/ +export interface Resource extends BaseResource { + /** + * Resource Id + */ + readonly id?: string; + /** + * Resource name + */ + readonly name?: string; + /** + * Resource type + */ + readonly type?: string; + /** + * Resource location + */ + location: string; + /** + * Resource tags + */ + tags?: { [propertyName: string]: string }; +} + +export interface ImageTemplate extends Resource { + /** + * Specifies the properties used to describe the source image. + */ + source: ImageTemplateSource; + /** + * Specifies the properties used to describe the customization steps of the image, like Image + * source etc + */ + customize?: ImageTemplateCustomizer[]; + /** + * The distribution targets where the image output needs to go to. + */ + distribute: ImageTemplateDistributor[]; + /** + * Provisioning state of the resource. Possible values include: 'Creating', 'Succeeded', + * 'Failed', 'Deleting' + */ + readonly provisioningState?: string; + /** + * Provisioning error, if any + */ + readonly provisioningError?: ProvisioningError; + /** + * State of 'run' that is currently executing or was last executed. + */ + readonly lastRunStatus?: ImageTemplateLastRunStatus; +} + +/** + * Describes an image source that is an installation ISO. Currently only supports Red Hat + * Enterprise Linux 7.2-7.5 ISO's. +*/ +export interface ImageTemplateIsoSource extends ImageTemplateSource { + /** + * URI to get the ISO image. This URI has to be accessible to the resource provider at the time + * of the image template creation. + */ + sourceURI: string; + /** + * SHA256 Checksum of the ISO image. + */ + sha256Checksum: string; +} + +/** + * Describes an image source from [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). +*/ +export interface ImageTemplatePlatformImageSource extends ImageTemplateSource { + /** + * Image Publisher in [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + */ + publisher?: string; + /** + * Image offer from the [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + */ + offer?: string; + /** + * Image sku from the [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + */ + sku?: string; + /** + * Image version from the [Azure Gallery + * Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + */ + version?: string; +} + +/** + * Describes an image source that is a managed image in customer subscription. +*/ +export interface ImageTemplateManagedImageSource extends ImageTemplateSource { + /** + * ARM resource id of the managed image in customer subscription + */ + imageId: string; +} + +/** + * Runs a shell script during the customization phase (Linux) +*/ +export interface ImageTemplateShellCustomizer extends ImageTemplateCustomizer { + /** + * The shell script to be run for customizing. It can be a github link, SAS URI for Azure + * Storage, etc + */ + script?: string; +} + +/** + * Reboots a VM and waits for it to come back online (Windows). Corresponds to Packer + * windows-restart provisioner +*/ +export interface ImageTemplateRestartCustomizer extends ImageTemplateCustomizer { + /** + * Command to execute the restart [Default: 'shutdown /r /f /t 0 /c "packer restart"'] + */ + restartCommand?: string; + /** + * Command to check if restart succeeded [Default: ''] + */ + restartCheckCommand?: string; + /** + * Restart timeout specified as a string of magnitude and unit, e.g. '5m' (5 minutes) or '2h' (2 + * hours) [Default: '5m'] + */ + restartTimeout?: string; +} + +/** + * Runs the specified PowerSehll on the VM (Windows). Corresponds to Packer powershell provisioner +*/ +export interface ImageTemplatePowerShellCustomizer extends ImageTemplateCustomizer { + /** + * The PowerShell script to be run for customizing. It can be a github link, SAS URI for Azure + * Storage, etc + */ + script?: string; + validExitCodes?: number[]; +} + +/** + * Distribute as a Managed Disk Image. +*/ +export interface ImageTemplateManagedImageDistributor extends ImageTemplateDistributor { + /** + * Resource Id of the Managed Disk Image + */ + imageId: string; + /** + * Azure location for the image, should match if image already exists + */ + location: string; +} + +/** + * Distribute via Shared Image Gallery. +*/ +export interface ImageTemplateSharedImageDistributor extends ImageTemplateDistributor { + /** + * Resource Id of the Shared Image Gallery image + */ + galleryImageId: string; + replicationRegions: string[]; +} + +/** + * Distribute via VHD in a storage account. +*/ +export interface ImageTemplateVhdDistributor extends ImageTemplateDistributor { +} + +/** + * Parameters for updating an image template. +*/ +export interface ImageTemplateUpdateParameters { + /** + * The user-specified tags associated with the image template. + */ + tags?: { [propertyName: string]: string }; +} + +/** + * The Sub Resource model definition. +*/ +export interface SubResource { + /** + * Resource Id + */ + readonly id?: string; + /** + * Resource name + */ + name: string; + /** + * Resource type + */ + readonly type?: string; +} + +/** + * Represents an output that was created by running an image template. +*/ +export interface RunOutput extends SubResource { + /** + * The resource id of the artifact. + */ + artifactId?: string; + /** + * The URL location of the artifact. + */ + artifactLocation?: string; + /** + * Provisioning state of the resource. Possible values include: 'Creating', 'Succeeded', + * 'Failed', 'Deleting' + */ + readonly provisioningState?: string; +} + +/** + * @summary The object that describes the operation. +*/ +export interface OperationDisplay { + /** + * @summary Friendly name of the resource provider. + */ + provider?: string; + /** + * @summary The operation type. + * @description For example: read, write, delete, or listKeys/action + */ + operation?: string; + /** + * @summary The resource type on which the operation is performed. + */ + resource?: string; + /** + * @summary The friendly name of the operation + */ + description?: string; +} + +/** + * @summary A REST API operation +*/ +export interface Operation { + /** + * @summary The operation name. + * @description This is of the format {provider}/{resource}/{operation} + */ + name?: string; + /** + * @summary The object that describes the operation. + */ + display?: OperationDisplay; + /** + * @summary The intended executor of the operation. + */ + origin?: string; + /** + * @summary Properties of the operation. + */ + properties?: any; +} + +/** + * Api error base. +*/ +export interface ApiErrorBase { + /** + * The error code. + */ + code?: string; + /** + * The target of the particular error. + */ + target?: string; + /** + * The error message. + */ + message?: string; +} + +/** + * Inner error details. +*/ +export interface InnerError { + /** + * The exception type. + */ + exceptionType?: string; + /** + * The internal error message or exception dump. + */ + errorDetail?: string; +} + +/** + * Api error. +*/ +export interface ApiError { + /** + * The Api error details + */ + details?: ApiErrorBase[]; + /** + * The Api inner error + */ + innerError?: InnerError; + /** + * The error code. + */ + code?: string; + /** + * The target of the particular error. + */ + target?: string; + /** + * The error message. + */ + message?: string; +} + +export interface ImageTemplateListResult extends Array { + /** + * The continuation token. + */ + nextLink?: string; +} + +export interface RunOutputCollection extends Array { + /** + * The continuation token. + */ + nextLink?: string; +} + +/** + * @summary Result of the request to list REST API operations. It contains a list of operations and + * a URL nextLink to get the next set of results. +*/ +export interface OperationListResult extends Array { + /** + * @summary The URL to get the next set of operation list results if there are any. + */ + nextLink?: string; +} diff --git a/lib/services/imagebuilderManagement/lib/models/index.js b/lib/services/imagebuilderManagement/lib/models/index.js new file mode 100644 index 0000000000..8474e7bd89 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/index.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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var msRestAzure = require('ms-rest-azure'); + +exports.BaseResource = msRestAzure.BaseResource; +exports.CloudError = msRestAzure.CloudError; +exports.ImageTemplateSource = require('./imageTemplateSource'); +exports.ImageTemplateCustomizer = require('./imageTemplateCustomizer'); +exports.ImageTemplateDistributor = require('./imageTemplateDistributor'); +exports.ProvisioningError = require('./provisioningError'); +exports.ImageTemplateLastRunStatus = require('./imageTemplateLastRunStatus'); +exports.Resource = require('./resource'); +exports.ImageTemplate = require('./imageTemplate'); +exports.ImageTemplateIsoSource = require('./imageTemplateIsoSource'); +exports.ImageTemplatePlatformImageSource = require('./imageTemplatePlatformImageSource'); +exports.ImageTemplateManagedImageSource = require('./imageTemplateManagedImageSource'); +exports.ImageTemplateShellCustomizer = require('./imageTemplateShellCustomizer'); +exports.ImageTemplateRestartCustomizer = require('./imageTemplateRestartCustomizer'); +exports.ImageTemplatePowerShellCustomizer = require('./imageTemplatePowerShellCustomizer'); +exports.ImageTemplateManagedImageDistributor = require('./imageTemplateManagedImageDistributor'); +exports.ImageTemplateSharedImageDistributor = require('./imageTemplateSharedImageDistributor'); +exports.ImageTemplateVhdDistributor = require('./imageTemplateVhdDistributor'); +exports.ImageTemplateUpdateParameters = require('./imageTemplateUpdateParameters'); +exports.SubResource = require('./subResource'); +exports.RunOutput = require('./runOutput'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); +exports.ApiErrorBase = require('./apiErrorBase'); +exports.InnerError = require('./innerError'); +exports.ApiError = require('./apiError'); +exports.ImageTemplateListResult = require('./imageTemplateListResult'); +exports.RunOutputCollection = require('./runOutputCollection'); +exports.OperationListResult = require('./operationListResult'); +exports.discriminators = { + 'ImageTemplateSource' : exports.ImageTemplateSource, + 'ImageTemplateCustomizer' : exports.ImageTemplateCustomizer, + 'ImageTemplateDistributor' : exports.ImageTemplateDistributor, + 'ImageTemplateSource.ISO' : exports.ImageTemplateIsoSource, + 'ImageTemplateSource.PlatformImage' : exports.ImageTemplatePlatformImageSource, + 'ImageTemplateSource.ManagedImage' : exports.ImageTemplateManagedImageSource, + 'ImageTemplateCustomizer.Shell' : exports.ImageTemplateShellCustomizer, + 'ImageTemplateCustomizer.WindowsRestart' : exports.ImageTemplateRestartCustomizer, + 'ImageTemplateCustomizer.PowerShell' : exports.ImageTemplatePowerShellCustomizer, + 'ImageTemplateDistributor.ManagedImage' : exports.ImageTemplateManagedImageDistributor, + 'ImageTemplateDistributor.SharedImage' : exports.ImageTemplateSharedImageDistributor, + 'ImageTemplateDistributor.VHD' : exports.ImageTemplateVhdDistributor +}; diff --git a/lib/services/imagebuilderManagement/lib/models/innerError.js b/lib/services/imagebuilderManagement/lib/models/innerError.js new file mode 100644 index 0000000000..1a2b555e35 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/innerError.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'; + +/** + * Inner error details. + * + */ +class InnerError { + /** + * Create a InnerError. + * @property {string} [exceptionType] The exception type. + * @property {string} [errorDetail] The internal error message or exception + * dump. + */ + constructor() { + } + + /** + * Defines the metadata of InnerError + * + * @returns {object} metadata of InnerError + * + */ + mapper() { + return { + required: false, + serializedName: 'InnerError', + type: { + name: 'Composite', + className: 'InnerError', + modelProperties: { + exceptionType: { + required: false, + serializedName: 'exceptionType', + type: { + name: 'String' + } + }, + errorDetail: { + required: false, + serializedName: 'errorDetail', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = InnerError; diff --git a/lib/services/imagebuilderManagement/lib/models/operation.js b/lib/services/imagebuilderManagement/lib/models/operation.js new file mode 100644 index 0000000000..0b79bdacd1 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/operation.js @@ -0,0 +1,83 @@ +/* + * 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'; + +/** + * @summary A REST API operation + * + */ +class Operation { + /** + * Create a Operation. + * @property {string} [name] The operation name. This is of the format + * {provider}/{resource}/{operation} + * @property {object} [display] The object that describes the operation. + * @property {string} [display.provider] + * @property {string} [display.operation] For example: read, write, delete, + * or listKeys/action + * @property {string} [display.resource] + * @property {string} [display.description] + * @property {string} [origin] The intended executor of the operation. + * @property {object} [properties] Properties of the 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' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Object' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/imagebuilderManagement/lib/models/operationDisplay.js b/lib/services/imagebuilderManagement/lib/models/operationDisplay.js new file mode 100644 index 0000000000..bf90f44961 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/operationDisplay.js @@ -0,0 +1,78 @@ +/* + * 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'; + +/** + * @summary The object that describes the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @property {string} [provider] Friendly name of the resource provider. + * @property {string} [operation] The operation type. For example: read, + * write, delete, or listKeys/action + * @property {string} [resource] The resource type on which the operation is + * performed. + * @property {string} [description] The friendly name of the 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' + } + }, + operation: { + required: false, + serializedName: 'operation', + type: { + name: 'String' + } + }, + resource: { + required: false, + serializedName: 'resource', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'description', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/imagebuilderManagement/lib/models/operationListResult.js b/lib/services/imagebuilderManagement/lib/models/operationListResult.js new file mode 100644 index 0000000000..45b95bc658 --- /dev/null +++ b/lib/services/imagebuilderManagement/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'; + +/** + * @summary Result of the request to list REST API operations. It contains a + * list of operations and a URL nextLink to get the next set of results. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @property {string} [nextLink] + */ + 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/imagebuilderManagement/lib/models/provisioningError.js b/lib/services/imagebuilderManagement/lib/models/provisioningError.js new file mode 100644 index 0000000000..eec4b7e8bf --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/provisioningError.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'; + +/** + * Class representing a ProvisioningError. + */ +class ProvisioningError { + /** + * Create a ProvisioningError. + * @property {string} [provisioningErrorCode] Error code of the provisioning + * failure. Possible values include: 'BadSourceType', 'BadPIRSource', + * 'BadISOSource', 'BadManagedImageSource', 'BadCustomizerType', + * 'UnsupportedCustomizerType', 'NoCustomizerScript', 'BadDistributeType', + * 'BadSharedImageDistribute', 'ServerError', 'Other' + * @property {string} [message] Verbose error message about the provisioning + * failure + */ + constructor() { + } + + /** + * Defines the metadata of ProvisioningError + * + * @returns {object} metadata of ProvisioningError + * + */ + mapper() { + return { + required: false, + serializedName: 'ProvisioningError', + type: { + name: 'Composite', + className: 'ProvisioningError', + modelProperties: { + provisioningErrorCode: { + required: false, + serializedName: 'provisioningErrorCode', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProvisioningError; diff --git a/lib/services/imagebuilderManagement/lib/models/resource.js b/lib/services/imagebuilderManagement/lib/models/resource.js new file mode 100644 index 0000000000..8fa3f52687 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/resource.js @@ -0,0 +1,98 @@ +/* + * 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'); + +/** + * The Resource model definition. + * + * @extends models['BaseResource'] + */ +class Resource extends models['BaseResource'] { + /** + * Create a Resource. + * @property {string} [id] Resource Id + * @property {string} [name] Resource name + * @property {string} [type] Resource type + * @property {string} location Resource location + * @property {object} [tags] Resource tags + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Resource + * + * @returns {object} metadata of Resource + * + */ + mapper() { + return { + required: false, + serializedName: 'Resource', + type: { + name: 'Composite', + className: 'Resource', + 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: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = Resource; diff --git a/lib/services/imagebuilderManagement/lib/models/runOutput.js b/lib/services/imagebuilderManagement/lib/models/runOutput.js new file mode 100644 index 0000000000..7f313fd6a3 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/runOutput.js @@ -0,0 +1,97 @@ +/* + * 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'); + +/** + * Represents an output that was created by running an image template. + * + * @extends models['SubResource'] + */ +class RunOutput extends models['SubResource'] { + /** + * Create a RunOutput. + * @property {string} [artifactId] The resource id of the artifact. + * @property {string} [artifactLocation] The URL location of the artifact. + * @property {string} [provisioningState] Provisioning state of the resource. + * Possible values include: 'Creating', 'Succeeded', 'Failed', 'Deleting' + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RunOutput + * + * @returns {object} metadata of RunOutput + * + */ + mapper() { + return { + required: false, + serializedName: 'RunOutput', + type: { + name: 'Composite', + className: 'RunOutput', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + artifactId: { + required: false, + serializedName: 'properties.artifactId', + type: { + name: 'String' + } + }, + artifactLocation: { + required: false, + serializedName: 'properties.artifactLocation', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RunOutput; diff --git a/lib/services/imagebuilderManagement/lib/models/runOutputCollection.js b/lib/services/imagebuilderManagement/lib/models/runOutputCollection.js new file mode 100644 index 0000000000..4bbf6a8f81 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/runOutputCollection.js @@ -0,0 +1,67 @@ +/* + * 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'; + +/** + * Class representing a RunOutputCollection. + */ +class RunOutputCollection extends Array { + /** + * Create a RunOutputCollection. + * @property {string} [nextLink] The continuation token. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RunOutputCollection + * + * @returns {object} metadata of RunOutputCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'RunOutputCollection', + type: { + name: 'Composite', + className: 'RunOutputCollection', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'RunOutputElementType', + type: { + name: 'Composite', + className: 'RunOutput' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RunOutputCollection; diff --git a/lib/services/imagebuilderManagement/lib/models/subResource.js b/lib/services/imagebuilderManagement/lib/models/subResource.js new file mode 100644 index 0000000000..189728b5e0 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/models/subResource.js @@ -0,0 +1,70 @@ +/* + * 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 Sub Resource model definition. + * + */ +class SubResource { + /** + * Create a SubResource. + * @property {string} [id] Resource Id + * @property {string} name Resource name + * @property {string} [type] Resource type + */ + constructor() { + } + + /** + * Defines the metadata of SubResource + * + * @returns {object} metadata of SubResource + * + */ + mapper() { + return { + required: false, + serializedName: 'SubResource', + type: { + name: 'Composite', + className: 'SubResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = SubResource; diff --git a/lib/services/imagebuilderManagement/lib/operations/index.d.ts b/lib/services/imagebuilderManagement/lib/operations/index.d.ts new file mode 100644 index 0000000000..87ccc345e3 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/operations/index.d.ts @@ -0,0 +1,1100 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. +*/ + +import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationResponse } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * VirtualMachineImageTemplates + * __NOTE__: An instance of this class is automatically created for an + * instance of the ImageBuilderClient. + */ +export interface VirtualMachineImageTemplates { + + + /** + * Gets information about the VM image templates associated with the + * subscription. + * + * @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>; + + /** + * Gets information about the VM image templates associated with the + * subscription. + * + * @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 {ImageTemplateListResult} - 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. + * + * {ImageTemplateListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplateListResult} 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; + + + /** + * Gets information about the VM image templates associated with the specified + * resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets information about the VM image templates associated with the specified + * resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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 {ImageTemplateListResult} - 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. + * + * {ImageTemplateListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplateListResult} 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. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + createOrUpdateWithHttpOperationResponse(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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. + * + * {ImageTemplate} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplate} 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. + */ + createOrUpdate(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + createOrUpdate(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update the tags for this Virtual Machine Image Template + * + * @param {object} parameters Additional parameters for Image Template update. + * + * @param {object} [parameters.tags] The user-specified tags associated with + * the image template. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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(parameters: models.ImageTemplateUpdateParameters, resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update the tags for this Virtual Machine Image Template + * + * @param {object} parameters Additional parameters for Image Template update. + * + * @param {object} [parameters.tags] The user-specified tags associated with + * the image template. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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. + * + * {ImageTemplate} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplate} 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(parameters: models.ImageTemplateUpdateParameters, resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(parameters: models.ImageTemplateUpdateParameters, resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + update(parameters: models.ImageTemplateUpdateParameters, resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get information about a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + getWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get information about a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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. + * + * {ImageTemplate} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplate} 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. + */ + get(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + deleteMethod(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + runWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + run(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + run(resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + run(resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List all run outputs for the specified Image Template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + listRunOutputsWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List all run outputs for the specified Image Template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {RunOutputCollection} - 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. + * + * {RunOutputCollection} [result] - The deserialized result object if an error did not occur. + * See {@link RunOutputCollection} 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. + */ + listRunOutputs(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listRunOutputs(resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + listRunOutputs(resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get the specified run output for the specified image template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @param {string} runOutputName The name of the run output + * + * @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. + */ + getRunOutputWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, runOutputName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the specified run output for the specified image template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @param {string} runOutputName The name of the run output + * + * @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 {RunOutput} - 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. + * + * {RunOutput} [result] - The deserialized result object if an error did not occur. + * See {@link RunOutput} 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. + */ + getRunOutput(resourceGroupName: string, imageTemplateName: string, runOutputName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getRunOutput(resourceGroupName: string, imageTemplateName: string, runOutputName: string, callback: ServiceCallback): void; + getRunOutput(resourceGroupName: string, imageTemplateName: string, runOutputName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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. + * + * {ImageTemplate} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplate} 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. + */ + beginCreateOrUpdate(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + beginCreateOrUpdate(parameters: models.ImageTemplate, resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + beginDeleteMethod(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginDeleteMethod(resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + beginDeleteMethod(resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginRunWithHttpOperationResponse(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + beginRun(resourceGroupName: string, imageTemplateName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginRun(resourceGroupName: string, imageTemplateName: string, callback: ServiceCallback): void; + beginRun(resourceGroupName: string, imageTemplateName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets information about the VM image templates 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. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets information about the VM image templates 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 {ImageTemplateListResult} - 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. + * + * {ImageTemplateListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplateListResult} 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; + + + /** + * Gets information about the VM image templates associated with 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 + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets information about the VM image templates associated with 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 {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 {ImageTemplateListResult} - 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. + * + * {ImageTemplateListResult} [result] - The deserialized result object if an error did not occur. + * See {@link ImageTemplateListResult} 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. + */ + listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List all run outputs for the specified Image Template resource + * + * @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. + */ + listRunOutputsNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List all run outputs for the specified Image Template resource + * + * @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 {RunOutputCollection} - 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. + * + * {RunOutputCollection} [result] - The deserialized result object if an error did not occur. + * See {@link RunOutputCollection} 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. + */ + listRunOutputsNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listRunOutputsNext(nextPageLink: string, callback: ServiceCallback): void; + listRunOutputsNext(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 ImageBuilderClient. + */ +export interface Operations { + + + /** + * Lists available operations for the Microsoft.VirtualMachineImages provider + * + * @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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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/imagebuilderManagement/lib/operations/index.js b/lib/services/imagebuilderManagement/lib/operations/index.js new file mode 100644 index 0000000000..ef4f421cb9 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/operations/index.js @@ -0,0 +1,18 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.VirtualMachineImageTemplates = require('./virtualMachineImageTemplates'); +exports.Operations = require('./operations'); diff --git a/lib/services/imagebuilderManagement/lib/operations/operations.js b/lib/services/imagebuilderManagement/lib/operations/operations.js new file mode 100644 index 0000000000..d6d6c319cf --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/operations/operations.js @@ -0,0 +1,451 @@ +/* + * 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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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.VirtualMachineImages/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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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 {ImageBuilderClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists available operations for the Microsoft.VirtualMachineImages provider + * + * @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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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 available operations for the Microsoft.VirtualMachineImages provider + * + * @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/imagebuilderManagement/lib/operations/virtualMachineImageTemplates.js b/lib/services/imagebuilderManagement/lib/operations/virtualMachineImageTemplates.js new file mode 100644 index 0000000000..e7b7f7ab71 --- /dev/null +++ b/lib/services/imagebuilderManagement/lib/operations/virtualMachineImageTemplates.js @@ -0,0 +1,3412 @@ +/* + * 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; + +/** + * Gets information about the VM image templates associated with the + * subscription. + * + * @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 ImageTemplateListResult} 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.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.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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates'; + 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.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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplateListResult']().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 VM image templates associated with the specified + * resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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 ImageTemplateListResult} 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) { + /* 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 (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 (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.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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + 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.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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplateListResult']().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); + }); +} + + +/** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 ImageTemplate} 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 _createOrUpdate(parameters, resourceGroupName, imageTemplateName, 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.beginCreateOrUpdate(parameters, resourceGroupName, imageTemplateName, 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 + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ImageTemplate']().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); + }); + }); +} + +/** + * Update the tags for this Virtual Machine Image Template + * + * @param {object} parameters Additional parameters for Image Template update. + * + * @param {object} [parameters.tags] The user-specified tags associated with + * the image template. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 ImageTemplate} 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 _update(parameters, resourceGroupName, imageTemplateName, 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 (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.'); + } + 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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + 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 = 'PATCH'; + 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]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['ImageTemplateUpdateParameters']().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) { + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplate']().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); + }); +} + +/** + * Get information about a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 ImageTemplate} 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 _get(resourceGroupName, imageTemplateName, 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.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 (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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplate']().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); + }); +} + + +/** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 _deleteMethod(resourceGroupName, imageTemplateName, 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.beginDeleteMethod(resourceGroupName, imageTemplateName, 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); + }); + }); +} + + +/** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 _run(resourceGroupName, imageTemplateName, 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.beginRun(resourceGroupName, imageTemplateName, 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); + }); + }); +} + +/** + * List all run outputs for the specified Image Template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 RunOutputCollection} 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 _listRunOutputs(resourceGroupName, imageTemplateName, 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.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 (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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['RunOutputCollection']().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); + }); +} + +/** + * Get the specified run output for the specified image template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @param {string} runOutputName The name of the run output + * + * @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 RunOutput} 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 _getRunOutput(resourceGroupName, imageTemplateName, runOutputName, 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.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 (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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + if (runOutputName === null || runOutputName === undefined || typeof runOutputName.valueOf() !== 'string') { + throw new Error('runOutputName cannot be null or undefined and it must be of type string.'); + } + if (runOutputName !== null && runOutputName !== undefined) { + if (runOutputName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"runOutputName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + requestUrl = requestUrl.replace('{runOutputName}', encodeURIComponent(runOutputName)); + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['RunOutput']().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); + }); +} + +/** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 ImageTemplate} 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 _beginCreateOrUpdate(parameters, resourceGroupName, imageTemplateName, 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 (parameters === null || parameters === undefined) { + throw new Error('parameters 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 (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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + 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 = 'PUT'; + 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]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['ImageTemplate']().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 && statusCode !== 201) { + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplate']().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['ImageTemplate']().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); + }); +} + +/** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 _beginDeleteMethod(resourceGroupName, imageTemplateName, 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.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 (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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + 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 = 'DELETE'; + 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 && statusCode !== 204) { + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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); + }); +} + +/** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 _beginRun(resourceGroupName, imageTemplateName, 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.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 (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 (imageTemplateName === null || imageTemplateName === undefined || typeof imageTemplateName.valueOf() !== 'string') { + throw new Error('imageTemplateName cannot be null or undefined and it must be of type string.'); + } + if (imageTemplateName !== null && imageTemplateName !== undefined) { + if (imageTemplateName.match(/^[A-Za-z0-9-_]{1,64}$/) === null) + { + throw new Error('"imageTemplateName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9-_]{1,64}$/'); + } + } + 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{imageTemplateName}', encodeURIComponent(imageTemplateName)); + 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 = '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 !== 202 && statusCode !== 204) { + 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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); + }); +} + +/** + * Gets information about the VM image templates 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 ImageTemplateListResult} 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplateListResult']().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 VM image templates associated with 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 ImageTemplateListResult} 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['ImageTemplateListResult']().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); + }); +} + +/** + * List all run outputs for the specified Image Template resource + * + * @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 RunOutputCollection} 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 _listRunOutputsNext(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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ApiError']().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['RunOutputCollection']().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 VirtualMachineImageTemplates. */ +class VirtualMachineImageTemplates { + /** + * Create a VirtualMachineImageTemplates. + * @param {ImageBuilderClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByResourceGroup = _listByResourceGroup; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._run = _run; + this._listRunOutputs = _listRunOutputs; + this._getRunOutput = _getRunOutput; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._beginDeleteMethod = _beginDeleteMethod; + this._beginRun = _beginRun; + this._listNext = _listNext; + this._listByResourceGroupNext = _listByResourceGroupNext; + this._listRunOutputsNext = _listRunOutputsNext; + } + + /** + * Gets information about the VM image templates associated with the + * subscription. + * + * @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; + }); + }); + } + + /** + * Gets information about the VM image templates associated with the + * subscription. + * + * @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 {ImageTemplateListResult} - 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 ImageTemplateListResult} 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); + } + } + + /** + * Gets information about the VM image templates associated with the specified + * resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets information about the VM image templates associated with the specified + * resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @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 {ImageTemplateListResult} - 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 ImageTemplateListResult} 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. + */ + listByResourceGroup(resourceGroupName, 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._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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(parameters, resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(parameters, resourceGroupName, imageTemplateName, 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 virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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 ImageTemplate} 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(parameters, resourceGroupName, imageTemplateName, 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(parameters, resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(parameters, resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Update the tags for this Virtual Machine Image Template + * + * @param {object} parameters Additional parameters for Image Template update. + * + * @param {object} [parameters.tags] The user-specified tags associated with + * the image template. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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(parameters, resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(parameters, resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update the tags for this Virtual Machine Image Template + * + * @param {object} parameters Additional parameters for Image Template update. + * + * @param {object} [parameters.tags] The user-specified tags associated with + * the image template. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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 ImageTemplate} 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(parameters, resourceGroupName, imageTemplateName, 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(parameters, resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(parameters, resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Get information about a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get information about a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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 ImageTemplate} 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, imageTemplateName, 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._get(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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, imageTemplateName, 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, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + runWithHttpOperationResponse(resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._run(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + run(resourceGroupName, imageTemplateName, 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._run(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._run(resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * List all run outputs for the specified Image Template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + listRunOutputsWithHttpOperationResponse(resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listRunOutputs(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List all run outputs for the specified Image Template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {RunOutputCollection} - 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 RunOutputCollection} 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. + */ + listRunOutputs(resourceGroupName, imageTemplateName, 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._listRunOutputs(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listRunOutputs(resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Get the specified run output for the specified image template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @param {string} runOutputName The name of the run output + * + * @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. + */ + getRunOutputWithHttpOperationResponse(resourceGroupName, imageTemplateName, runOutputName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getRunOutput(resourceGroupName, imageTemplateName, runOutputName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get the specified run output for the specified image template resource + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @param {string} runOutputName The name of the run output + * + * @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 {RunOutput} - 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 RunOutput} 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. + */ + getRunOutput(resourceGroupName, imageTemplateName, runOutputName, 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._getRunOutput(resourceGroupName, imageTemplateName, runOutputName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getRunOutput(resourceGroupName, imageTemplateName, runOutputName, options, optionalCallback); + } + } + + /** + * Create or update a virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginCreateOrUpdateWithHttpOperationResponse(parameters, resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(parameters, resourceGroupName, imageTemplateName, 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 virtual machine image template + * + * @param {object} parameters Parameters supplied to the CreateImageTemplate + * operation + * + * @param {object} parameters.source Specifies the properties used to describe + * the source image. + * + * @param {string} parameters.source.type Polymorphic Discriminator + * + * @param {array} [parameters.customize] Specifies the properties used to + * describe the customization steps of the image, like Image source etc + * + * @param {array} parameters.distribute The distribution targets where the + * image output needs to go to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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 {ImageTemplate} - 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 ImageTemplate} 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. + */ + beginCreateOrUpdate(parameters, resourceGroupName, imageTemplateName, 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._beginCreateOrUpdate(parameters, resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(parameters, resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginDeleteMethodWithHttpOperationResponse(resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginDeleteMethod(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete a virtual machine image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginDeleteMethod(resourceGroupName, imageTemplateName, 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._beginDeleteMethod(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginDeleteMethod(resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginRunWithHttpOperationResponse(resourceGroupName, imageTemplateName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginRun(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create artifacts from a existing image template + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} imageTemplateName The name of the image Template + * + * @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. + */ + beginRun(resourceGroupName, imageTemplateName, 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._beginRun(resourceGroupName, imageTemplateName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginRun(resourceGroupName, imageTemplateName, options, optionalCallback); + } + } + + /** + * Gets information about the VM image templates 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. + */ + 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; + }); + }); + } + + /** + * Gets information about the VM image templates 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 {ImageTemplateListResult} - 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 ImageTemplateListResult} 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); + } + } + + /** + * Gets information about the VM image templates associated with 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 + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets information about the VM image templates associated with 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} [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 {ImageTemplateListResult} - 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 ImageTemplateListResult} 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. + */ + listByResourceGroupNext(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._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupNext(nextPageLink, options, optionalCallback); + } + } + + /** + * List all run outputs for the specified Image Template resource + * + * @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. + */ + listRunOutputsNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listRunOutputsNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List all run outputs for the specified Image Template resource + * + * @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 {RunOutputCollection} - 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 RunOutputCollection} 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. + */ + listRunOutputsNext(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._listRunOutputsNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listRunOutputsNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = VirtualMachineImageTemplates; diff --git a/lib/services/imagebuilderManagement/package.json b/lib/services/imagebuilderManagement/package.json new file mode 100644 index 0000000000..95c5d00aa0 --- /dev/null +++ b/lib/services/imagebuilderManagement/package.json @@ -0,0 +1,25 @@ +{ + "name": "azure-arm-imagebuilder", + "author": "Microsoft Corporation", + "description": "ImageBuilderClient Library with typescript type definitions for node", + "version": "1.0.0", + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, + "keywords": [ + "node", + "azure" + ], + "license": "MIT", + "main": "./lib/imageBuilderClient.js", + "types": "./lib/imageBuilderClient.d.ts", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/imagebuilderManagement", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "https://github.com/azure/azure-sdk-for-node/issues" + } +}