diff --git a/lib/services/containerinstanceManagement/LICENSE.txt b/lib/services/containerinstanceManagement/LICENSE.txt index 0313a903d7..5431ba98b9 100644 --- a/lib/services/containerinstanceManagement/LICENSE.txt +++ b/lib/services/containerinstanceManagement/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2017 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. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) 2018 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/containerinstanceManagement/README.md b/lib/services/containerinstanceManagement/README.md index cf3181a086..62ef791bc7 100644 --- a/lib/services/containerinstanceManagement/README.md +++ b/lib/services/containerinstanceManagement/README.md @@ -1,38 +1,40 @@ -# Microsoft Azure SDK for Node.js - ContainerInstanceManagement - -This project provides a Node.js package for accessing the Azure PAS. Right now it supports: -- **Node.js version: 6.x.x or higher** - -## How to Install - -```bash -npm install azure-arm-containerinstance -``` - -## How to Use - -### Authentication, client creation and listing containerGroups as an example - - ```javascript - var msRestAzure = require('ms-rest-azure'); - var ContainerInstanceManagementClient = require("azure-arm-containerinstance"); - - // Interactive Login - // It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, - // the user will get a DeviceTokenCredentials object. - msRestAzure.interactiveLogin(function(err, credentials) { - let client = new ContainerInstanceManagementClient(credentials, 'your-subscription-id'); - client.containerGroups.list().then((containerGroups) => { - console.log('List of containerGroups:'); - console.dir(containerGroups, {depth: null, colors: true}); - }); - }).catch((err) => { - console.log('An error ocurred'); - console.dir(err, {depth: null, colors: true}); - }); -}); -``` - -## Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) +--- +uid: azure-arm-containerinstance +summary: *content + +--- +# Microsoft Azure SDK for Node.js - ContainerInstanceManagementClient +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-containerinstance +``` + +## How to use + +### Authentication, client creation and list containerGroups as an example. + +```javascript +const msRestAzure = require("ms-rest-azure"); +const ContainerInstanceManagementClient = require("azure-arm-containerinstance"); +msRestAzure.interactiveLogin().then((creds) => { + const subscriptionId = ""; + const client = new ContainerInstanceManagementClient(creds, subscriptionId); + return client.containerGroups.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/containerinstanceManagement/lib/containerInstanceManagementClient.d.ts b/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.d.ts index b3b046db74..312ef4d3e0 100644 --- a/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.d.ts +++ b/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.d.ts @@ -10,9 +10,10 @@ import { ServiceClientCredentials } from 'ms-rest'; import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; import * as operations from "./operations"; -declare class ContainerInstanceManagementClient extends AzureServiceClient { +export default class ContainerInstanceManagementClient extends AzureServiceClient { /** * Initializes a new instance of the ContainerInstanceManagementClient class. * @constructor @@ -59,6 +60,7 @@ declare class ContainerInstanceManagementClient extends AzureServiceClient { operations: operations.Operations; containerGroupUsage: operations.ContainerGroupUsage; containerLogs: operations.ContainerLogs; + startContainer: operations.StartContainer; } -export = ContainerInstanceManagementClient; +export { ContainerInstanceManagementClient, models as ContainerInstanceManagementModels }; diff --git a/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.js b/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.js index 85109d61de..3e972eeefb 100644 --- a/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.js +++ b/lib/services/containerinstanceManagement/lib/containerInstanceManagementClient.js @@ -50,7 +50,7 @@ class ContainerInstanceManagementClient extends ServiceClient { super(credentials, options); - this.apiVersion = '2018-02-01-preview'; + this.apiVersion = '2018-06-01'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -76,6 +76,7 @@ class ContainerInstanceManagementClient extends ServiceClient { this.operations = new operations.Operations(this); this.containerGroupUsage = new operations.ContainerGroupUsage(this); this.containerLogs = new operations.ContainerLogs(this); + this.startContainer = new operations.StartContainer(this); this.models = models; msRest.addSerializationMixin(this); } @@ -83,3 +84,6 @@ class ContainerInstanceManagementClient extends ServiceClient { } module.exports = ContainerInstanceManagementClient; +module.exports['default'] = ContainerInstanceManagementClient; +module.exports.ContainerInstanceManagementClient = ContainerInstanceManagementClient; +module.exports.ContainerInstanceManagementModels = models; diff --git a/lib/services/containerinstanceManagement/lib/models/container.js b/lib/services/containerinstanceManagement/lib/models/container.js index 6be2cf2c66..c19c40d47e 100644 --- a/lib/services/containerinstanceManagement/lib/models/container.js +++ b/lib/services/containerinstanceManagement/lib/models/container.js @@ -73,6 +73,36 @@ class Container { * instance. * @member {array} [volumeMounts] The volume mounts available to the * container instance. + * @member {object} [livenessProbe] The liveness probe. + * @member {object} [livenessProbe.exec] The execution command to probe + * @member {array} [livenessProbe.exec.command] The commands to execute + * within the container. + * @member {object} [livenessProbe.httpGet] The Http Get settings to probe + * @member {string} [livenessProbe.httpGet.path] The path to probe. + * @member {number} [livenessProbe.httpGet.port] The port number to probe. + * @member {string} [livenessProbe.httpGet.scheme] The scheme. Possible + * values include: 'http', 'https' + * @member {number} [livenessProbe.initialDelaySeconds] The initial delay + * seconds. + * @member {number} [livenessProbe.periodSeconds] The period seconds. + * @member {number} [livenessProbe.failureThreshold] The failure threshold. + * @member {number} [livenessProbe.successThreshold] The success threshold. + * @member {number} [livenessProbe.timeoutSeconds] The timeout seconds. + * @member {object} [readinessProbe] The readiness probe. + * @member {object} [readinessProbe.exec] The execution command to probe + * @member {array} [readinessProbe.exec.command] The commands to execute + * within the container. + * @member {object} [readinessProbe.httpGet] The Http Get settings to probe + * @member {string} [readinessProbe.httpGet.path] The path to probe. + * @member {number} [readinessProbe.httpGet.port] The port number to probe. + * @member {string} [readinessProbe.httpGet.scheme] The scheme. Possible + * values include: 'http', 'https' + * @member {number} [readinessProbe.initialDelaySeconds] The initial delay + * seconds. + * @member {number} [readinessProbe.periodSeconds] The period seconds. + * @member {number} [readinessProbe.failureThreshold] The failure threshold. + * @member {number} [readinessProbe.successThreshold] The success threshold. + * @member {number} [readinessProbe.timeoutSeconds] The timeout seconds. */ constructor() { } @@ -180,6 +210,22 @@ class Container { } } } + }, + livenessProbe: { + required: false, + serializedName: 'properties.livenessProbe', + type: { + name: 'Composite', + className: 'ContainerProbe' + } + }, + readinessProbe: { + required: false, + serializedName: 'properties.readinessProbe', + type: { + name: 'Composite', + className: 'ContainerProbe' + } } } } diff --git a/lib/services/containerinstanceManagement/lib/models/containerExec.js b/lib/services/containerinstanceManagement/lib/models/containerExec.js new file mode 100644 index 0000000000..dbc3a1b3fa --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerExec.js @@ -0,0 +1,59 @@ +/* + * 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 container execution command, for liveness or readiness probe + * + */ +class ContainerExec { + /** + * Create a ContainerExec. + * @member {array} [command] The commands to execute within the container. + */ + constructor() { + } + + /** + * Defines the metadata of ContainerExec + * + * @returns {object} metadata of ContainerExec + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerExec', + type: { + name: 'Composite', + className: 'ContainerExec', + modelProperties: { + command: { + required: false, + serializedName: 'command', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ContainerExec; diff --git a/lib/services/containerinstanceManagement/lib/models/containerExecRequest.js b/lib/services/containerinstanceManagement/lib/models/containerExecRequest.js new file mode 100644 index 0000000000..1f1ce32c55 --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerExecRequest.js @@ -0,0 +1,65 @@ +/* + * 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 start container exec request. + * + */ +class ContainerExecRequest { + /** + * Create a ContainerExecRequest. + * @member {string} [command] The command to be executed. + * @member {object} [terminalSize] The size of the terminal. + * @member {number} [terminalSize.row] The row size of the terminal + * @member {number} [terminalSize.column] The column size of the terminal + */ + constructor() { + } + + /** + * Defines the metadata of ContainerExecRequest + * + * @returns {object} metadata of ContainerExecRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerExecRequest', + type: { + name: 'Composite', + className: 'ContainerExecRequest', + modelProperties: { + command: { + required: false, + serializedName: 'command', + type: { + name: 'String' + } + }, + terminalSize: { + required: false, + serializedName: 'terminalSize', + type: { + name: 'Composite', + className: 'ContainerExecRequestTerminalSize' + } + } + } + } + }; + } +} + +module.exports = ContainerExecRequest; diff --git a/lib/services/containerinstanceManagement/lib/models/containerExecRequestTerminalSize.js b/lib/services/containerinstanceManagement/lib/models/containerExecRequestTerminalSize.js new file mode 100644 index 0000000000..9c5895472f --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerExecRequestTerminalSize.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'; + +/** + * The size of the terminal. + * + */ +class ContainerExecRequestTerminalSize { + /** + * Create a ContainerExecRequestTerminalSize. + * @member {number} [row] The row size of the terminal + * @member {number} [column] The column size of the terminal + */ + constructor() { + } + + /** + * Defines the metadata of ContainerExecRequestTerminalSize + * + * @returns {object} metadata of ContainerExecRequestTerminalSize + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerExecRequest_terminalSize', + type: { + name: 'Composite', + className: 'ContainerExecRequestTerminalSize', + modelProperties: { + row: { + required: false, + serializedName: 'row', + type: { + name: 'Number' + } + }, + column: { + required: false, + serializedName: 'column', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ContainerExecRequestTerminalSize; diff --git a/lib/services/containerinstanceManagement/lib/models/containerExecResponse.js b/lib/services/containerinstanceManagement/lib/models/containerExecResponse.js new file mode 100644 index 0000000000..59ab75a459 --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerExecResponse.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'; + +/** + * The information for the container exec command. + * + */ +class ContainerExecResponse { + /** + * Create a ContainerExecResponse. + * @member {string} [webSocketUri] The uri for the exec websocket. + * @member {string} [password] The password to start the exec command. + */ + constructor() { + } + + /** + * Defines the metadata of ContainerExecResponse + * + * @returns {object} metadata of ContainerExecResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerExecResponse', + type: { + name: 'Composite', + className: 'ContainerExecResponse', + modelProperties: { + webSocketUri: { + required: false, + serializedName: 'webSocketUri', + type: { + name: 'String' + } + }, + password: { + required: false, + serializedName: 'password', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ContainerExecResponse; diff --git a/lib/services/containerinstanceManagement/lib/models/containerGroup.js b/lib/services/containerinstanceManagement/lib/models/containerGroup.js index 6f677f4e09..2ca1792baf 100644 --- a/lib/services/containerinstanceManagement/lib/models/containerGroup.js +++ b/lib/services/containerinstanceManagement/lib/models/containerGroup.js @@ -47,6 +47,14 @@ class ContainerGroup extends models['Resource'] { * @member {array} [instanceView.events] The events of this container group. * @member {string} [instanceView.state] The state of the container group. * Only valid in response. + * @member {object} [diagnostics] The diagnostic information for a container + * group. + * @member {object} [diagnostics.logAnalytics] Container group log analytics + * information. + * @member {string} [diagnostics.logAnalytics.workspaceId] The workspace id + * for log analytics + * @member {string} [diagnostics.logAnalytics.workspaceKey] The workspace key + * for log analytics */ constructor() { super(); @@ -194,6 +202,14 @@ class ContainerGroup extends models['Resource'] { name: 'Composite', className: 'ContainerGroupPropertiesInstanceView' } + }, + diagnostics: { + required: false, + serializedName: 'properties.diagnostics', + type: { + name: 'Composite', + className: 'ContainerGroupDiagnostics' + } } } } diff --git a/lib/services/containerinstanceManagement/lib/models/containerGroupDiagnostics.js b/lib/services/containerinstanceManagement/lib/models/containerGroupDiagnostics.js new file mode 100644 index 0000000000..2afcbedd98 --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerGroupDiagnostics.js @@ -0,0 +1,59 @@ +/* + * 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'); + +/** + * Container group diagnostic information. + * + */ +class ContainerGroupDiagnostics { + /** + * Create a ContainerGroupDiagnostics. + * @member {object} [logAnalytics] Container group log analytics information. + * @member {string} [logAnalytics.workspaceId] The workspace id for log + * analytics + * @member {string} [logAnalytics.workspaceKey] The workspace key for log + * analytics + */ + constructor() { + } + + /** + * Defines the metadata of ContainerGroupDiagnostics + * + * @returns {object} metadata of ContainerGroupDiagnostics + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerGroupDiagnostics', + type: { + name: 'Composite', + className: 'ContainerGroupDiagnostics', + modelProperties: { + logAnalytics: { + required: false, + serializedName: 'logAnalytics', + type: { + name: 'Composite', + className: 'LogAnalytics' + } + } + } + } + }; + } +} + +module.exports = ContainerGroupDiagnostics; diff --git a/lib/services/containerinstanceManagement/lib/models/containerHttpGet.js b/lib/services/containerinstanceManagement/lib/models/containerHttpGet.js new file mode 100644 index 0000000000..e0f3619d8f --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerHttpGet.js @@ -0,0 +1,69 @@ +/* + * 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 container Http Get settings, for liveness or readiness probe + * + */ +class ContainerHttpGet { + /** + * Create a ContainerHttpGet. + * @member {string} [path] The path to probe. + * @member {number} port The port number to probe. + * @member {string} [scheme] The scheme. Possible values include: 'http', + * 'https' + */ + constructor() { + } + + /** + * Defines the metadata of ContainerHttpGet + * + * @returns {object} metadata of ContainerHttpGet + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerHttpGet', + type: { + name: 'Composite', + className: 'ContainerHttpGet', + modelProperties: { + path: { + required: false, + serializedName: 'path', + type: { + name: 'String' + } + }, + port: { + required: true, + serializedName: 'port', + type: { + name: 'Number' + } + }, + scheme: { + required: false, + serializedName: 'scheme', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ContainerHttpGet; diff --git a/lib/services/containerinstanceManagement/lib/models/containerProbe.js b/lib/services/containerinstanceManagement/lib/models/containerProbe.js new file mode 100644 index 0000000000..2b15756e09 --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/containerProbe.js @@ -0,0 +1,110 @@ +/* + * 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 container probe, for liveness or readiness + * + */ +class ContainerProbe { + /** + * Create a ContainerProbe. + * @member {object} [exec] The execution command to probe + * @member {array} [exec.command] The commands to execute within the + * container. + * @member {object} [httpGet] The Http Get settings to probe + * @member {string} [httpGet.path] The path to probe. + * @member {number} [httpGet.port] The port number to probe. + * @member {string} [httpGet.scheme] The scheme. Possible values include: + * 'http', 'https' + * @member {number} [initialDelaySeconds] The initial delay seconds. + * @member {number} [periodSeconds] The period seconds. + * @member {number} [failureThreshold] The failure threshold. + * @member {number} [successThreshold] The success threshold. + * @member {number} [timeoutSeconds] The timeout seconds. + */ + constructor() { + } + + /** + * Defines the metadata of ContainerProbe + * + * @returns {object} metadata of ContainerProbe + * + */ + mapper() { + return { + required: false, + serializedName: 'ContainerProbe', + type: { + name: 'Composite', + className: 'ContainerProbe', + modelProperties: { + exec: { + required: false, + serializedName: 'exec', + type: { + name: 'Composite', + className: 'ContainerExec' + } + }, + httpGet: { + required: false, + serializedName: 'httpGet', + type: { + name: 'Composite', + className: 'ContainerHttpGet' + } + }, + initialDelaySeconds: { + required: false, + serializedName: 'initialDelaySeconds', + type: { + name: 'Number' + } + }, + periodSeconds: { + required: false, + serializedName: 'periodSeconds', + type: { + name: 'Number' + } + }, + failureThreshold: { + required: false, + serializedName: 'failureThreshold', + type: { + name: 'Number' + } + }, + successThreshold: { + required: false, + serializedName: 'successThreshold', + type: { + name: 'Number' + } + }, + timeoutSeconds: { + required: false, + serializedName: 'timeoutSeconds', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = ContainerProbe; diff --git a/lib/services/containerinstanceManagement/lib/models/environmentVariable.js b/lib/services/containerinstanceManagement/lib/models/environmentVariable.js index dad63b4b37..d6f65b5536 100644 --- a/lib/services/containerinstanceManagement/lib/models/environmentVariable.js +++ b/lib/services/containerinstanceManagement/lib/models/environmentVariable.js @@ -18,7 +18,9 @@ class EnvironmentVariable { /** * Create a EnvironmentVariable. * @member {string} name The name of the environment variable. - * @member {string} value The value of the environment variable. + * @member {string} [value] The value of the environment variable. + * @member {string} [secureValue] The value of the secure environment + * variable. */ constructor() { } @@ -45,11 +47,18 @@ class EnvironmentVariable { } }, value: { - required: true, + required: false, serializedName: 'value', type: { name: 'String' } + }, + secureValue: { + required: false, + serializedName: 'secureValue', + type: { + name: 'String' + } } } } diff --git a/lib/services/containerinstanceManagement/lib/models/index.d.ts b/lib/services/containerinstanceManagement/lib/models/index.d.ts index e2ac11e109..83c603156f 100644 --- a/lib/services/containerinstanceManagement/lib/models/index.d.ts +++ b/lib/services/containerinstanceManagement/lib/models/index.d.ts @@ -38,11 +38,13 @@ export interface ContainerPort { * The environment variable to set within the container instance. * * @member {string} name The name of the environment variable. - * @member {string} value The value of the environment variable. + * @member {string} [value] The value of the environment variable. + * @member {string} [secureValue] The value of the secure environment variable. */ export interface EnvironmentVariable { name: string; - value: string; + value?: string; + secureValue?: string; } /** @@ -196,6 +198,64 @@ export interface VolumeMount { readOnly?: boolean; } +/** + * @class + * Initializes a new instance of the ContainerExec class. + * @constructor + * The container execution command, for liveness or readiness probe + * + * @member {array} [command] The commands to execute within the container. + */ +export interface ContainerExec { + command?: string[]; +} + +/** + * @class + * Initializes a new instance of the ContainerHttpGet class. + * @constructor + * The container Http Get settings, for liveness or readiness probe + * + * @member {string} [path] The path to probe. + * @member {number} port The port number to probe. + * @member {string} [scheme] The scheme. Possible values include: 'http', + * 'https' + */ +export interface ContainerHttpGet { + path?: string; + port: number; + scheme?: string; +} + +/** + * @class + * Initializes a new instance of the ContainerProbe class. + * @constructor + * The container probe, for liveness or readiness + * + * @member {object} [exec] The execution command to probe + * @member {array} [exec.command] The commands to execute within the container. + * @member {object} [httpGet] The Http Get settings to probe + * @member {string} [httpGet.path] The path to probe. + * @member {number} [httpGet.port] The port number to probe. + * @member {string} [httpGet.scheme] The scheme. Possible values include: + * 'http', 'https' + * @member {number} [initialDelaySeconds] The initial delay seconds. + * @member {number} [periodSeconds] The period seconds. + * @member {number} [failureThreshold] The failure threshold. + * @member {number} [successThreshold] The success threshold. + * @member {number} [timeoutSeconds] The timeout seconds. + */ +export interface ContainerProbe { + exec?: ContainerExec; + httpGet?: ContainerHttpGet; + initialDelaySeconds?: number; + periodSeconds?: number; + failureThreshold?: number; + successThreshold?: number; + timeoutSeconds?: number; +} + /** * @class * Initializes a new instance of the Container class. @@ -255,6 +315,36 @@ export interface VolumeMount { * instance. * @member {array} [volumeMounts] The volume mounts available to the container * instance. + * @member {object} [livenessProbe] The liveness probe. + * @member {object} [livenessProbe.exec] The execution command to probe + * @member {array} [livenessProbe.exec.command] The commands to execute within + * the container. + * @member {object} [livenessProbe.httpGet] The Http Get settings to probe + * @member {string} [livenessProbe.httpGet.path] The path to probe. + * @member {number} [livenessProbe.httpGet.port] The port number to probe. + * @member {string} [livenessProbe.httpGet.scheme] The scheme. Possible values + * include: 'http', 'https' + * @member {number} [livenessProbe.initialDelaySeconds] The initial delay + * seconds. + * @member {number} [livenessProbe.periodSeconds] The period seconds. + * @member {number} [livenessProbe.failureThreshold] The failure threshold. + * @member {number} [livenessProbe.successThreshold] The success threshold. + * @member {number} [livenessProbe.timeoutSeconds] The timeout seconds. + * @member {object} [readinessProbe] The readiness probe. + * @member {object} [readinessProbe.exec] The execution command to probe + * @member {array} [readinessProbe.exec.command] The commands to execute within + * the container. + * @member {object} [readinessProbe.httpGet] The Http Get settings to probe + * @member {string} [readinessProbe.httpGet.path] The path to probe. + * @member {number} [readinessProbe.httpGet.port] The port number to probe. + * @member {string} [readinessProbe.httpGet.scheme] The scheme. Possible values + * include: 'http', 'https' + * @member {number} [readinessProbe.initialDelaySeconds] The initial delay + * seconds. + * @member {number} [readinessProbe.periodSeconds] The period seconds. + * @member {number} [readinessProbe.failureThreshold] The failure threshold. + * @member {number} [readinessProbe.successThreshold] The success threshold. + * @member {number} [readinessProbe.timeoutSeconds] The timeout seconds. */ export interface Container { name: string; @@ -265,6 +355,8 @@ export interface Container { readonly instanceView?: ContainerPropertiesInstanceView; resources: ResourceRequirements; volumeMounts?: VolumeMount[]; + livenessProbe?: ContainerProbe; + readinessProbe?: ContainerProbe; } /** @@ -408,6 +500,36 @@ export interface ContainerGroupPropertiesInstanceView { readonly state?: string; } +/** + * @class + * Initializes a new instance of the LogAnalytics class. + * @constructor + * Container group log analytics information. + * + * @member {string} workspaceId The workspace id for log analytics + * @member {string} workspaceKey The workspace key for log analytics + */ +export interface LogAnalytics { + workspaceId: string; + workspaceKey: string; +} + +/** + * @class + * Initializes a new instance of the ContainerGroupDiagnostics class. + * @constructor + * Container group diagnostic information. + * + * @member {object} [logAnalytics] Container group log analytics information. + * @member {string} [logAnalytics.workspaceId] The workspace id for log + * analytics + * @member {string} [logAnalytics.workspaceKey] The workspace key for log + * analytics + */ +export interface ContainerGroupDiagnostics { + logAnalytics?: LogAnalytics; +} + /** * @class * Initializes a new instance of the Resource class. @@ -460,6 +582,14 @@ export interface Resource extends BaseResource { * @member {array} [instanceView.events] The events of this container group. * @member {string} [instanceView.state] The state of the container group. Only * valid in response. + * @member {object} [diagnostics] The diagnostic information for a container + * group. + * @member {object} [diagnostics.logAnalytics] Container group log analytics + * information. + * @member {string} [diagnostics.logAnalytics.workspaceId] The workspace id for + * log analytics + * @member {string} [diagnostics.logAnalytics.workspaceKey] The workspace key + * for log analytics */ export interface ContainerGroup extends Resource { readonly provisioningState?: string; @@ -470,6 +600,7 @@ export interface ContainerGroup extends Resource { osType: string; volumes?: Volume[]; readonly instanceView?: ContainerGroupPropertiesInstanceView; + diagnostics?: ContainerGroupDiagnostics; } /** @@ -586,6 +717,50 @@ export interface Logs { content?: string; } +/** + * @class + * Initializes a new instance of the ContainerExecRequestTerminalSize class. + * @constructor + * The size of the terminal. + * + * @member {number} [row] The row size of the terminal + * @member {number} [column] The column size of the terminal + */ +export interface ContainerExecRequestTerminalSize { + row?: number; + column?: number; +} + +/** + * @class + * Initializes a new instance of the ContainerExecRequest class. + * @constructor + * The start container exec request. + * + * @member {string} [command] The command to be executed. + * @member {object} [terminalSize] The size of the terminal. + * @member {number} [terminalSize.row] The row size of the terminal + * @member {number} [terminalSize.column] The column size of the terminal + */ +export interface ContainerExecRequest { + command?: string; + terminalSize?: ContainerExecRequestTerminalSize; +} + +/** + * @class + * Initializes a new instance of the ContainerExecResponse class. + * @constructor + * The information for the container exec command. + * + * @member {string} [webSocketUri] The uri for the exec websocket. + * @member {string} [password] The password to start the exec command. + */ +export interface ContainerExecResponse { + webSocketUri?: string; + password?: string; +} + /** * @class diff --git a/lib/services/containerinstanceManagement/lib/models/index.js b/lib/services/containerinstanceManagement/lib/models/index.js index efacdfd418..763e039049 100644 --- a/lib/services/containerinstanceManagement/lib/models/index.js +++ b/lib/services/containerinstanceManagement/lib/models/index.js @@ -27,6 +27,9 @@ exports.ResourceRequests = require('./resourceRequests'); exports.ResourceLimits = require('./resourceLimits'); exports.ResourceRequirements = require('./resourceRequirements'); exports.VolumeMount = require('./volumeMount'); +exports.ContainerExec = require('./containerExec'); +exports.ContainerHttpGet = require('./containerHttpGet'); +exports.ContainerProbe = require('./containerProbe'); exports.Container = require('./container'); exports.AzureFileVolume = require('./azureFileVolume'); exports.GitRepoVolume = require('./gitRepoVolume'); @@ -35,6 +38,8 @@ exports.ImageRegistryCredential = require('./imageRegistryCredential'); exports.Port = require('./port'); exports.IpAddress = require('./ipAddress'); exports.ContainerGroupPropertiesInstanceView = require('./containerGroupPropertiesInstanceView'); +exports.LogAnalytics = require('./logAnalytics'); +exports.ContainerGroupDiagnostics = require('./containerGroupDiagnostics'); exports.Resource = require('./resource'); exports.ContainerGroup = require('./containerGroup'); exports.OperationDisplay = require('./operationDisplay'); @@ -44,4 +49,7 @@ exports.UsageName = require('./usageName'); exports.Usage = require('./usage'); exports.UsageListResult = require('./usageListResult'); exports.Logs = require('./logs'); +exports.ContainerExecRequestTerminalSize = require('./containerExecRequestTerminalSize'); +exports.ContainerExecRequest = require('./containerExecRequest'); +exports.ContainerExecResponse = require('./containerExecResponse'); exports.ContainerGroupListResult = require('./containerGroupListResult'); diff --git a/lib/services/containerinstanceManagement/lib/models/logAnalytics.js b/lib/services/containerinstanceManagement/lib/models/logAnalytics.js new file mode 100644 index 0000000000..ef5fea633a --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/models/logAnalytics.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'; + +/** + * Container group log analytics information. + * + */ +class LogAnalytics { + /** + * Create a LogAnalytics. + * @member {string} workspaceId The workspace id for log analytics + * @member {string} workspaceKey The workspace key for log analytics + */ + constructor() { + } + + /** + * Defines the metadata of LogAnalytics + * + * @returns {object} metadata of LogAnalytics + * + */ + mapper() { + return { + required: false, + serializedName: 'LogAnalytics', + type: { + name: 'Composite', + className: 'LogAnalytics', + modelProperties: { + workspaceId: { + required: true, + serializedName: 'workspaceId', + type: { + name: 'String' + } + }, + workspaceKey: { + required: true, + serializedName: 'workspaceKey', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LogAnalytics; diff --git a/lib/services/containerinstanceManagement/lib/operations/containerGroups.js b/lib/services/containerinstanceManagement/lib/operations/containerGroups.js index 9e7675fb18..a9826d53d8 100644 --- a/lib/services/containerinstanceManagement/lib/operations/containerGroups.js +++ b/lib/services/containerinstanceManagement/lib/operations/containerGroups.js @@ -449,6 +449,7 @@ function _get(resourceGroupName, containerGroupName, options, callback) { }); } + /** * @summary Create or update container groups. * @@ -493,6 +494,18 @@ function _get(resourceGroupName, containerGroupName, options, callback) { * @param {array} [containerGroup.volumes] The list of volumes that can be * mounted by containers in this container group. * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * * @param {string} [containerGroup.location] The resource location. * * @param {object} [containerGroup.tags] The resource tags. @@ -522,12 +535,94 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, callback = options; options = null; } + if (!callback) { throw new Error('callback cannot be null.'); } - if (containerGroup === null || containerGroup === undefined) - { - containerGroup = {}; + + // Send request + this.beginCreateOrUpdate(resourceGroupName, containerGroupName, containerGroup, 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['ContainerGroup']().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); + }); + }); +} + +/** + * @summary Update container groups. + * + * Updates container group tags with specified values. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {object} resource The container group resource with just the tags to + * be updated. + * + * @param {string} [resource.location] The resource location. + * + * @param {object} [resource.tags] The resource tags. + * + * @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 ContainerGroup} 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(resourceGroupName, containerGroupName, resource, 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 { @@ -543,8 +638,8 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, if (containerGroupName === null || containerGroupName === undefined || typeof containerGroupName.valueOf() !== 'string') { throw new Error('containerGroupName cannot be null or undefined and it must be of type string.'); } - if (containerGroup === null || containerGroup === undefined) { - throw new Error('containerGroup cannot be null or undefined.'); + if (resource === null || resource === undefined) { + throw new Error('resource cannot be null or undefined.'); } 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.'); @@ -567,7 +662,7 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'PUT'; + httpRequest.method = 'PATCH'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -589,14 +684,14 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, let requestContent = null; let requestModel = null; try { - if (containerGroup !== null && containerGroup !== undefined) { - let requestModelMapper = new client.models['ContainerGroup']().mapper(); - requestModel = client.serialize(requestModelMapper, containerGroup, 'containerGroup'); + if (resource !== null && resource !== undefined) { + let requestModelMapper = new client.models['Resource']().mapper(); + requestModel = client.serialize(requestModelMapper, resource, 'resource'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(containerGroup, null, 2)}.`); + `payload - ${JSON.stringify(resource, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -606,7 +701,7 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 201) { + if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -651,32 +746,17 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, 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['ContainerGroup']().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); }); } /** - * @summary Update container groups. + * @summary Delete the specified container group. * - * Updates container group tags with specified values. + * Delete the specified container group in the specified subscription and + * resource group. The operation does not delete other resources provided by + * the user, such as volumes. * * @param {string} resourceGroupName The name of the resource group. * @@ -684,13 +764,6 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, * * @param {object} [options] Optional Parameters. * - * @param {object} [options.resource] The container group resource with just - * the tags to be updated. - * - * @param {string} [options.resource.location] The resource location. - * - * @param {object} [options.resource.tags] The resource tags. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -707,7 +780,7 @@ function _createOrUpdate(resourceGroupName, containerGroupName, containerGroup, * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _update(resourceGroupName, containerGroupName, options, callback) { +function _deleteMethod(resourceGroupName, containerGroupName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -717,7 +790,6 @@ function _update(resourceGroupName, containerGroupName, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let resource = (options && options.resource !== undefined) ? options.resource : undefined; // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { @@ -753,7 +825,7 @@ function _update(resourceGroupName, containerGroupName, options, callback) { // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'PATCH'; + httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -771,28 +843,14 @@ function _update(resourceGroupName, containerGroupName, options, callback) { } } } - // Serialize Request - let requestContent = null; - let requestModel = null; - try { - if (resource !== null && resource !== undefined) { - let requestModelMapper = new client.models['Resource']().mapper(); - requestModel = client.serialize(requestModelMapper, resource, 'resource'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(resource, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; + httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 200 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -843,16 +901,65 @@ function _update(resourceGroupName, containerGroupName, options, callback) { } /** - * @summary Delete the specified container group. + * @summary Create or update container groups. * - * Delete the specified container group in the specified subscription and - * resource group. The operation does not delete other resources provided by - * the user, such as volumes. + * Create or update container groups with specified configurations. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} containerGroupName The name of the container group. * + * @param {object} containerGroup The properties of the container group to be + * created or updated. + * + * @param {array} containerGroup.containers The containers within the container + * group. + * + * @param {array} [containerGroup.imageRegistryCredentials] The image registry + * credentials by which the container group is created from. + * + * @param {string} [containerGroup.restartPolicy] Restart policy for all + * containers within the container group. + * - `Always` Always restart + * - `OnFailure` Restart on failure + * - `Never` Never restart + * . Possible values include: 'Always', 'OnFailure', 'Never' + * + * @param {object} [containerGroup.ipAddress] The IP address type of the + * container group. + * + * @param {array} containerGroup.ipAddress.ports The list of ports exposed on + * the container group. + * + * @param {string} [containerGroup.ipAddress.ip] The IP exposed to the public + * internet. + * + * @param {string} [containerGroup.ipAddress.dnsNameLabel] The Dns name label + * for the IP. + * + * @param {string} containerGroup.osType The operating system type required by + * the containers in the container group. Possible values include: 'Windows', + * 'Linux' + * + * @param {array} [containerGroup.volumes] The list of volumes that can be + * mounted by containers in this container group. + * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * + * @param {string} [containerGroup.location] The resource location. + * + * @param {object} [containerGroup.tags] The resource tags. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -871,7 +978,7 @@ function _update(resourceGroupName, containerGroupName, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _deleteMethod(resourceGroupName, containerGroupName, options, callback) { +function _beginCreateOrUpdate(resourceGroupName, containerGroupName, containerGroup, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -881,6 +988,10 @@ function _deleteMethod(resourceGroupName, containerGroupName, options, callback) if (!callback) { throw new Error('callback cannot be null.'); } + if (containerGroup === null || containerGroup === undefined) + { + containerGroup = {}; + } // Validate try { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { @@ -895,6 +1006,9 @@ function _deleteMethod(resourceGroupName, containerGroupName, options, callback) if (containerGroupName === null || containerGroupName === undefined || typeof containerGroupName.valueOf() !== 'string') { throw new Error('containerGroupName cannot be null or undefined and it must be of type string.'); } + if (containerGroup === null || containerGroup === undefined) { + throw new Error('containerGroup cannot be null or undefined.'); + } 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.'); } @@ -916,7 +1030,7 @@ function _deleteMethod(resourceGroupName, containerGroupName, options, callback) // Create HTTP transport objects let httpRequest = new WebResource(); - httpRequest.method = 'DELETE'; + httpRequest.method = 'PUT'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -934,14 +1048,28 @@ function _deleteMethod(resourceGroupName, containerGroupName, options, callback) } } } - httpRequest.body = null; + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (containerGroup !== null && containerGroup !== undefined) { + let requestModelMapper = new client.models['ContainerGroup']().mapper(); + requestModel = client.serialize(requestModelMapper, containerGroup, 'containerGroup'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(containerGroup, 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 !== 204) { + if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -986,6 +1114,23 @@ function _deleteMethod(resourceGroupName, containerGroupName, options, callback) return callback(deserializationError); } } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ContainerGroup']().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); }); @@ -1272,6 +1417,7 @@ class ContainerGroups { this._createOrUpdate = _createOrUpdate; this._update = _update; this._deleteMethod = _deleteMethod; + this._beginCreateOrUpdate = _beginCreateOrUpdate; this._listNext = _listNext; this._listByResourceGroupNext = _listByResourceGroupNext; } @@ -1600,6 +1746,18 @@ class ContainerGroups { * @param {array} [containerGroup.volumes] The list of volumes that can be * mounted by containers in this container group. * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * * @param {string} [containerGroup.location] The resource location. * * @param {object} [containerGroup.tags] The resource tags. @@ -1673,6 +1831,18 @@ class ContainerGroups { * @param {array} [containerGroup.volumes] The list of volumes that can be * mounted by containers in this container group. * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * * @param {string} [containerGroup.location] The resource location. * * @param {object} [containerGroup.tags] The resource tags. @@ -1733,14 +1903,14 @@ class ContainerGroups { * * @param {string} containerGroupName The name of the container group. * - * @param {object} [options] Optional Parameters. + * @param {object} resource The container group resource with just the tags to + * be updated. * - * @param {object} [options.resource] The container group resource with just - * the tags to be updated. + * @param {string} [resource.location] The resource location. * - * @param {string} [options.resource.location] The resource location. + * @param {object} [resource.tags] The resource tags. * - * @param {object} [options.resource.tags] The resource tags. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1751,11 +1921,11 @@ class ContainerGroups { * * @reject {Error} - The error object. */ - updateWithHttpOperationResponse(resourceGroupName, containerGroupName, options) { + updateWithHttpOperationResponse(resourceGroupName, containerGroupName, resource, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._update(resourceGroupName, containerGroupName, options, (err, result, request, response) => { + self._update(resourceGroupName, containerGroupName, resource, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1774,14 +1944,14 @@ class ContainerGroups { * * @param {string} containerGroupName The name of the container group. * - * @param {object} [options] Optional Parameters. + * @param {object} resource The container group resource with just the tags to + * be updated. * - * @param {object} [options.resource] The container group resource with just - * the tags to be updated. + * @param {string} [resource.location] The resource location. * - * @param {string} [options.resource.location] The resource location. + * @param {object} [resource.tags] The resource tags. * - * @param {object} [options.resource.tags] The resource tags. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1808,7 +1978,7 @@ class ContainerGroups { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - update(resourceGroupName, containerGroupName, options, optionalCallback) { + update(resourceGroupName, containerGroupName, resource, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1817,14 +1987,14 @@ class ContainerGroups { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._update(resourceGroupName, containerGroupName, options, (err, result, request, response) => { + self._update(resourceGroupName, containerGroupName, resource, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._update(resourceGroupName, containerGroupName, options, optionalCallback); + return self._update(resourceGroupName, containerGroupName, resource, options, optionalCallback); } } @@ -1922,6 +2092,198 @@ class ContainerGroups { } } + /** + * @summary Create or update container groups. + * + * Create or update container groups with specified configurations. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {object} containerGroup The properties of the container group to be + * created or updated. + * + * @param {array} containerGroup.containers The containers within the container + * group. + * + * @param {array} [containerGroup.imageRegistryCredentials] The image registry + * credentials by which the container group is created from. + * + * @param {string} [containerGroup.restartPolicy] Restart policy for all + * containers within the container group. + * - `Always` Always restart + * - `OnFailure` Restart on failure + * - `Never` Never restart + * . Possible values include: 'Always', 'OnFailure', 'Never' + * + * @param {object} [containerGroup.ipAddress] The IP address type of the + * container group. + * + * @param {array} containerGroup.ipAddress.ports The list of ports exposed on + * the container group. + * + * @param {string} [containerGroup.ipAddress.ip] The IP exposed to the public + * internet. + * + * @param {string} [containerGroup.ipAddress.dnsNameLabel] The Dns name label + * for the IP. + * + * @param {string} containerGroup.osType The operating system type required by + * the containers in the container group. Possible values include: 'Windows', + * 'Linux' + * + * @param {array} [containerGroup.volumes] The list of volumes that can be + * mounted by containers in this container group. + * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * + * @param {string} [containerGroup.location] The resource location. + * + * @param {object} [containerGroup.tags] The resource tags. + * + * @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(resourceGroupName, containerGroupName, containerGroup, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, containerGroupName, containerGroup, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Create or update container groups. + * + * Create or update container groups with specified configurations. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {object} containerGroup The properties of the container group to be + * created or updated. + * + * @param {array} containerGroup.containers The containers within the container + * group. + * + * @param {array} [containerGroup.imageRegistryCredentials] The image registry + * credentials by which the container group is created from. + * + * @param {string} [containerGroup.restartPolicy] Restart policy for all + * containers within the container group. + * - `Always` Always restart + * - `OnFailure` Restart on failure + * - `Never` Never restart + * . Possible values include: 'Always', 'OnFailure', 'Never' + * + * @param {object} [containerGroup.ipAddress] The IP address type of the + * container group. + * + * @param {array} containerGroup.ipAddress.ports The list of ports exposed on + * the container group. + * + * @param {string} [containerGroup.ipAddress.ip] The IP exposed to the public + * internet. + * + * @param {string} [containerGroup.ipAddress.dnsNameLabel] The Dns name label + * for the IP. + * + * @param {string} containerGroup.osType The operating system type required by + * the containers in the container group. Possible values include: 'Windows', + * 'Linux' + * + * @param {array} [containerGroup.volumes] The list of volumes that can be + * mounted by containers in this container group. + * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * + * @param {string} [containerGroup.location] The resource location. + * + * @param {object} [containerGroup.tags] The resource tags. + * + * @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 {ContainerGroup} - 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 ContainerGroup} 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(resourceGroupName, containerGroupName, containerGroup, 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(resourceGroupName, containerGroupName, containerGroup, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, containerGroupName, containerGroup, options, optionalCallback); + } + } + /** * @summary Get a list of container groups in the specified subscription. * diff --git a/lib/services/containerinstanceManagement/lib/operations/index.d.ts b/lib/services/containerinstanceManagement/lib/operations/index.d.ts index c555289661..c5d5e1deda 100644 --- a/lib/services/containerinstanceManagement/lib/operations/index.d.ts +++ b/lib/services/containerinstanceManagement/lib/operations/index.d.ts @@ -264,6 +264,18 @@ export interface ContainerGroups { * @param {array} [containerGroup.volumes] The list of volumes that can be * mounted by containers in this container group. * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * * @param {string} [containerGroup.location] The resource location. * * @param {object} [containerGroup.tags] The resource tags. @@ -325,6 +337,18 @@ export interface ContainerGroups { * @param {array} [containerGroup.volumes] The list of volumes that can be * mounted by containers in this container group. * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * * @param {string} [containerGroup.location] The resource location. * * @param {object} [containerGroup.tags] The resource tags. @@ -370,14 +394,14 @@ export interface ContainerGroups { * * @param {string} containerGroupName The name of the container group. * - * @param {object} [options] Optional Parameters. + * @param {object} resource The container group resource with just the tags to + * be updated. * - * @param {object} [options.resource] The container group resource with just - * the tags to be updated. + * @param {string} [resource.location] The resource location. * - * @param {string} [options.resource.location] The resource location. + * @param {object} [resource.tags] The resource tags. * - * @param {object} [options.resource.tags] The resource tags. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -388,7 +412,7 @@ export interface ContainerGroups { * * @reject {Error|ServiceError} - The error object. */ - updateWithHttpOperationResponse(resourceGroupName: string, containerGroupName: string, options?: { resource? : models.Resource, customHeaders? : { [headerName: string]: string; } }): Promise>; + updateWithHttpOperationResponse(resourceGroupName: string, containerGroupName: string, resource: models.Resource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * @summary Update container groups. @@ -399,14 +423,14 @@ export interface ContainerGroups { * * @param {string} containerGroupName The name of the container group. * - * @param {object} [options] Optional Parameters. + * @param {object} resource The container group resource with just the tags to + * be updated. * - * @param {object} [options.resource] The container group resource with just - * the tags to be updated. + * @param {string} [resource.location] The resource location. * - * @param {string} [options.resource.location] The resource location. + * @param {object} [resource.tags] The resource tags. * - * @param {object} [options.resource.tags] The resource tags. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -433,9 +457,9 @@ export interface ContainerGroups { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - update(resourceGroupName: string, containerGroupName: string, options?: { resource? : models.Resource, customHeaders? : { [headerName: string]: string; } }): Promise; - update(resourceGroupName: string, containerGroupName: string, callback: ServiceCallback): void; - update(resourceGroupName: string, containerGroupName: string, options: { resource? : models.Resource, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + update(resourceGroupName: string, containerGroupName: string, resource: models.Resource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, containerGroupName: string, resource: models.Resource, callback: ServiceCallback): void; + update(resourceGroupName: string, containerGroupName: string, resource: models.Resource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -505,6 +529,171 @@ export interface ContainerGroups { deleteMethod(resourceGroupName: string, containerGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * @summary Create or update container groups. + * + * Create or update container groups with specified configurations. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {object} containerGroup The properties of the container group to be + * created or updated. + * + * @param {array} containerGroup.containers The containers within the container + * group. + * + * @param {array} [containerGroup.imageRegistryCredentials] The image registry + * credentials by which the container group is created from. + * + * @param {string} [containerGroup.restartPolicy] Restart policy for all + * containers within the container group. + * - `Always` Always restart + * - `OnFailure` Restart on failure + * - `Never` Never restart + * . Possible values include: 'Always', 'OnFailure', 'Never' + * + * @param {object} [containerGroup.ipAddress] The IP address type of the + * container group. + * + * @param {array} containerGroup.ipAddress.ports The list of ports exposed on + * the container group. + * + * @param {string} [containerGroup.ipAddress.ip] The IP exposed to the public + * internet. + * + * @param {string} [containerGroup.ipAddress.dnsNameLabel] The Dns name label + * for the IP. + * + * @param {string} containerGroup.osType The operating system type required by + * the containers in the container group. Possible values include: 'Windows', + * 'Linux' + * + * @param {array} [containerGroup.volumes] The list of volumes that can be + * mounted by containers in this container group. + * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * + * @param {string} [containerGroup.location] The resource location. + * + * @param {object} [containerGroup.tags] The resource tags. + * + * @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(resourceGroupName: string, containerGroupName: string, containerGroup: models.ContainerGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Create or update container groups. + * + * Create or update container groups with specified configurations. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {object} containerGroup The properties of the container group to be + * created or updated. + * + * @param {array} containerGroup.containers The containers within the container + * group. + * + * @param {array} [containerGroup.imageRegistryCredentials] The image registry + * credentials by which the container group is created from. + * + * @param {string} [containerGroup.restartPolicy] Restart policy for all + * containers within the container group. + * - `Always` Always restart + * - `OnFailure` Restart on failure + * - `Never` Never restart + * . Possible values include: 'Always', 'OnFailure', 'Never' + * + * @param {object} [containerGroup.ipAddress] The IP address type of the + * container group. + * + * @param {array} containerGroup.ipAddress.ports The list of ports exposed on + * the container group. + * + * @param {string} [containerGroup.ipAddress.ip] The IP exposed to the public + * internet. + * + * @param {string} [containerGroup.ipAddress.dnsNameLabel] The Dns name label + * for the IP. + * + * @param {string} containerGroup.osType The operating system type required by + * the containers in the container group. Possible values include: 'Windows', + * 'Linux' + * + * @param {array} [containerGroup.volumes] The list of volumes that can be + * mounted by containers in this container group. + * + * @param {object} [containerGroup.diagnostics] The diagnostic information for + * a container group. + * + * @param {object} [containerGroup.diagnostics.logAnalytics] Container group + * log analytics information. + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceId The + * workspace id for log analytics + * + * @param {string} containerGroup.diagnostics.logAnalytics.workspaceKey The + * workspace key for log analytics + * + * @param {string} [containerGroup.location] The resource location. + * + * @param {object} [containerGroup.tags] The resource tags. + * + * @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 {ContainerGroup} - 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. + * + * {ContainerGroup} [result] - The deserialized result object if an error did not occur. + * See {@link ContainerGroup} 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(resourceGroupName: string, containerGroupName: string, containerGroup: models.ContainerGroup, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, containerGroupName: string, containerGroup: models.ContainerGroup, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, containerGroupName: string, containerGroup: models.ContainerGroup, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * @summary Get a list of container groups in the specified subscription. * @@ -852,3 +1041,107 @@ export interface ContainerLogs { list(resourceGroupName: string, containerGroupName: string, containerName: string, callback: ServiceCallback): void; list(resourceGroupName: string, containerGroupName: string, containerName: string, options: { tail? : number, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } + +/** + * @class + * StartContainer + * __NOTE__: An instance of this class is automatically created for an + * instance of the ContainerInstanceManagementClient. + */ +export interface StartContainer { + + + /** + * @summary Starts the exec command for a specific container instance. + * + * Starts the exec command for a specified container instance in a specified + * resource group and container group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {string} containerName The name of the container instance. + * + * @param {object} containerExecRequest The request for the exec command. + * + * @param {string} [containerExecRequest.command] The command to be executed. + * + * @param {object} [containerExecRequest.terminalSize] The size of the + * terminal. + * + * @param {number} [containerExecRequest.terminalSize.row] The row size of the + * terminal + * + * @param {number} [containerExecRequest.terminalSize.column] The column size + * of the terminal + * + * @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. + */ + launchExecWithHttpOperationResponse(resourceGroupName: string, containerGroupName: string, containerName: string, containerExecRequest: models.ContainerExecRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Starts the exec command for a specific container instance. + * + * Starts the exec command for a specified container instance in a specified + * resource group and container group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {string} containerName The name of the container instance. + * + * @param {object} containerExecRequest The request for the exec command. + * + * @param {string} [containerExecRequest.command] The command to be executed. + * + * @param {object} [containerExecRequest.terminalSize] The size of the + * terminal. + * + * @param {number} [containerExecRequest.terminalSize.row] The row size of the + * terminal + * + * @param {number} [containerExecRequest.terminalSize.column] The column size + * of the terminal + * + * @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 {ContainerExecResponse} - 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. + * + * {ContainerExecResponse} [result] - The deserialized result object if an error did not occur. + * See {@link ContainerExecResponse} 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. + */ + launchExec(resourceGroupName: string, containerGroupName: string, containerName: string, containerExecRequest: models.ContainerExecRequest, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + launchExec(resourceGroupName: string, containerGroupName: string, containerName: string, containerExecRequest: models.ContainerExecRequest, callback: ServiceCallback): void; + launchExec(resourceGroupName: string, containerGroupName: string, containerName: string, containerExecRequest: models.ContainerExecRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/containerinstanceManagement/lib/operations/index.js b/lib/services/containerinstanceManagement/lib/operations/index.js index edad80cc9c..5c83ae4e33 100644 --- a/lib/services/containerinstanceManagement/lib/operations/index.js +++ b/lib/services/containerinstanceManagement/lib/operations/index.js @@ -18,3 +18,4 @@ exports.ContainerGroups = require('./containerGroups'); exports.Operations = require('./operations'); exports.ContainerGroupUsage = require('./containerGroupUsage'); exports.ContainerLogs = require('./containerLogs'); +exports.StartContainer = require('./startContainer'); diff --git a/lib/services/containerinstanceManagement/lib/operations/startContainer.js b/lib/services/containerinstanceManagement/lib/operations/startContainer.js new file mode 100644 index 0000000000..173c58eaf3 --- /dev/null +++ b/lib/services/containerinstanceManagement/lib/operations/startContainer.js @@ -0,0 +1,336 @@ +/* + * 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; + +/** + * @summary Starts the exec command for a specific container instance. + * + * Starts the exec command for a specified container instance in a specified + * resource group and container group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {string} containerName The name of the container instance. + * + * @param {object} containerExecRequest The request for the exec command. + * + * @param {string} [containerExecRequest.command] The command to be executed. + * + * @param {object} [containerExecRequest.terminalSize] The size of the + * terminal. + * + * @param {number} [containerExecRequest.terminalSize.row] The row size of the + * terminal + * + * @param {number} [containerExecRequest.terminalSize.column] The column size + * of the terminal + * + * @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 ContainerExecResponse} 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 _launchExec(resourceGroupName, containerGroupName, containerName, containerExecRequest, 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 (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 (containerGroupName === null || containerGroupName === undefined || typeof containerGroupName.valueOf() !== 'string') { + throw new Error('containerGroupName cannot be null or undefined and it must be of type string.'); + } + if (containerName === null || containerName === undefined || typeof containerName.valueOf() !== 'string') { + throw new Error('containerName cannot be null or undefined and it must be of type string.'); + } + if (containerExecRequest === null || containerExecRequest === undefined) { + throw new Error('containerExecRequest cannot be null or undefined.'); + } + 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.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{containerGroupName}', encodeURIComponent(containerGroupName)); + requestUrl = requestUrl.replace('{containerName}', encodeURIComponent(containerName)); + 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]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (containerExecRequest !== null && containerExecRequest !== undefined) { + let requestModelMapper = new client.models['ContainerExecRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, containerExecRequest, 'containerExecRequest'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(containerExecRequest, 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ContainerExecResponse']().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 StartContainer. */ +class StartContainer { + /** + * Create a StartContainer. + * @param {ContainerInstanceManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._launchExec = _launchExec; + } + + /** + * @summary Starts the exec command for a specific container instance. + * + * Starts the exec command for a specified container instance in a specified + * resource group and container group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {string} containerName The name of the container instance. + * + * @param {object} containerExecRequest The request for the exec command. + * + * @param {string} [containerExecRequest.command] The command to be executed. + * + * @param {object} [containerExecRequest.terminalSize] The size of the + * terminal. + * + * @param {number} [containerExecRequest.terminalSize.row] The row size of the + * terminal + * + * @param {number} [containerExecRequest.terminalSize.column] The column size + * of the terminal + * + * @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. + */ + launchExecWithHttpOperationResponse(resourceGroupName, containerGroupName, containerName, containerExecRequest, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._launchExec(resourceGroupName, containerGroupName, containerName, containerExecRequest, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Starts the exec command for a specific container instance. + * + * Starts the exec command for a specified container instance in a specified + * resource group and container group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} containerGroupName The name of the container group. + * + * @param {string} containerName The name of the container instance. + * + * @param {object} containerExecRequest The request for the exec command. + * + * @param {string} [containerExecRequest.command] The command to be executed. + * + * @param {object} [containerExecRequest.terminalSize] The size of the + * terminal. + * + * @param {number} [containerExecRequest.terminalSize.row] The row size of the + * terminal + * + * @param {number} [containerExecRequest.terminalSize.column] The column size + * of the terminal + * + * @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 {ContainerExecResponse} - 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 ContainerExecResponse} 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. + */ + launchExec(resourceGroupName, containerGroupName, containerName, containerExecRequest, 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._launchExec(resourceGroupName, containerGroupName, containerName, containerExecRequest, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._launchExec(resourceGroupName, containerGroupName, containerName, containerExecRequest, options, optionalCallback); + } + } + +} + +module.exports = StartContainer; diff --git a/lib/services/containerinstanceManagement/package.json b/lib/services/containerinstanceManagement/package.json index 1b5af4ff21..9c80596d98 100644 --- a/lib/services/containerinstanceManagement/package.json +++ b/lib/services/containerinstanceManagement/package.json @@ -1,35 +1,25 @@ { "name": "azure-arm-containerinstance", "author": "Microsoft Corporation", - "contributors": [ - "Zavery, Amar " - ], + "description": "ContainerInstanceManagementClient Library with typescript type definitions for node", "version": "1.2.0-preview", - "description": "Microsoft Azure ContainerInstance Management Client Library for node", - "tags": [ - "azure", - "sdk" - ], + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, "keywords": [ "node", "azure" ], + "license": "MIT", "main": "./lib/containerInstanceManagementClient.js", "types": "./lib/containerInstanceManagementClient.d.ts", - "license": "MIT", - "dependencies": { - "ms-rest": "^2.3.0", - "ms-rest-azure": "^2.5.2" - }, - "homepage": "http://github.com/Azure/azure-sdk-for-node", + "homepage": "http://github.com/azure/azure-sdk-for-node", "repository": { "type": "git", - "url": "git@github.com:Azure/azure-sdk-for-node.git" + "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { "url": "http://github.com/Azure/azure-sdk-for-node/issues" - }, - "scripts": { - "test": "npm -s run-script jshint" } -} \ No newline at end of file +}