Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions lib/services/automationManagement/lib/automationClient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,6 @@ import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure';
import * as models from "./models";
import * as operations from "./operations";

/**
* AutomationClientOptions for AutomationClient.
*/
declare interface AutomationClientOptions extends AzureServiceClientOptions {
/**
* @property {string} [clientRequestId] - Identifies this specific client request.
*/
clientRequestId?: string;
/**
* @property {string} [acceptLanguage] - Gets or sets the preferred language for the response.
*/
acceptLanguage?: string;
/**
* @property {number} [longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.
*/
longRunningOperationRetryTimeout?: number;
/**
* @property {boolean} [generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.
*/
generateClientRequestId?: boolean;
}

export default class AutomationClient extends AzureServiceClient {
/**
* Initializes a new instance of the AutomationClient class.
Expand All @@ -45,10 +23,6 @@ export default class AutomationClient extends AzureServiceClient {
*
* @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
*
* @param {string} resourceGroupName - The resource group name.
*
* @param {string} automationAccountName - The name of the automation account.
*
* @param {string} [baseUri] - The base URI of the service.
*
* @param {object} [options] - The parameter options
Expand All @@ -60,27 +34,19 @@ export default class AutomationClient extends AzureServiceClient {
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
* @param {string} [options.clientRequestId] - Identifies this specific client request.
*
* @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response.
*
* @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.
*
* @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.
*
*/
constructor(credentials: ServiceClientCredentials, subscriptionId: string, resourceGroupName: string, automationAccountName: string, baseUri?: string, options?: AutomationClientOptions);
constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is abreaking change but a good change. If the package was published before then major version should be bumped by 1.


credentials: ServiceClientCredentials;

subscriptionId: string;

resourceGroupName: string;

clientRequestId: string;

automationAccountName: string;

acceptLanguage: string;

longRunningOperationRetryTimeout: number;
Expand Down
16 changes: 1 addition & 15 deletions lib/services/automationManagement/lib/automationClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,23 @@ class AutomationClient extends ServiceClient {
* Create a AutomationClient.
* @param {credentials} credentials - Credentials needed for the client to connect to Azure.
* @param {string} subscriptionId - Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
* @param {string} resourceGroupName - The resource group name.
* @param {string} automationAccountName - The name of the automation account.
* @param {string} [baseUri] - The base URI of the service.
* @param {object} [options] - The parameter options
* @param {Array} [options.filters] - Filters to be added to the request pipeline
* @param {object} [options.requestOptions] - Options for the underlying request object
* {@link https://github.com/request/request#requestoptions-callback Options doc}
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
* @param {string} [options.clientRequestId] - Identifies this specific client request.
* @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response.
* @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.
* @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.
*/
constructor(credentials, subscriptionId, resourceGroupName, automationAccountName, baseUri, options) {
constructor(credentials, subscriptionId, baseUri, options) {
if (credentials === null || credentials === undefined) {
throw new Error('\'credentials\' cannot be null.');
}
if (subscriptionId === null || subscriptionId === undefined) {
throw new Error('\'subscriptionId\' cannot be null.');
}
if (resourceGroupName === null || resourceGroupName === undefined) {
throw new Error('\'resourceGroupName\' cannot be null.');
}
if (automationAccountName === null || automationAccountName === undefined) {
throw new Error('\'automationAccountName\' cannot be null.');
}

if (!options) options = {};

Expand All @@ -68,14 +59,9 @@ class AutomationClient extends ServiceClient {
}
this.credentials = credentials;
this.subscriptionId = subscriptionId;
this.resourceGroupName = resourceGroupName;
this.automationAccountName = automationAccountName;

let packageInfo = this.getPackageJsonInfo(__dirname);
this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`);
if(options.clientRequestId !== null && options.clientRequestId !== undefined) {
this.clientRequestId = options.clientRequestId;
}
if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
this.acceptLanguage = options.acceptLanguage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const WebResource = msRest.WebResource;
* Retrieve the activity in the module identified by module name and activity
* name.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} automationAccountName The automation account name.
*
* @param {string} moduleName The name of module.
Expand All @@ -42,7 +44,7 @@ const WebResource = msRest.WebResource;
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _get(automationAccountName, moduleName, activityName, options, callback) {
function _get(resourceGroupName, automationAccountName, moduleName, activityName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
Expand All @@ -55,13 +57,13 @@ function _get(automationAccountName, moduleName, activityName, options, callback
let apiVersion = '2015-10-31';
// Validate
try {
if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
throw new Error('this.client.resourceGroupName 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 (this.client.resourceGroupName !== null && this.client.resourceGroupName !== undefined) {
if (this.client.resourceGroupName.match(/^[-\w\._]+$/) === null)
if (resourceGroupName !== null && resourceGroupName !== undefined) {
if (resourceGroupName.match(/^[-\w\._]+$/) === null)
{
throw new Error('"this.client.resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
}
}
if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
Expand All @@ -86,7 +88,7 @@ function _get(automationAccountName, moduleName, activityName, options, callback
// Construct URL
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}';
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{automationAccountName}', encodeURIComponent(automationAccountName));
requestUrl = requestUrl.replace('{moduleName}', encodeURIComponent(moduleName));
requestUrl = requestUrl.replace('{activityName}', encodeURIComponent(activityName));
Expand Down Expand Up @@ -178,6 +180,8 @@ function _get(automationAccountName, moduleName, activityName, options, callback
/**
* Retrieve a list of activities in the module identified by module name.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} automationAccountName The automation account name.
*
* @param {string} moduleName The name of module.
Expand All @@ -200,7 +204,7 @@ function _get(automationAccountName, moduleName, activityName, options, callback
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _listByModule(automationAccountName, moduleName, options, callback) {
function _listByModule(resourceGroupName, automationAccountName, moduleName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
Expand All @@ -213,13 +217,13 @@ function _listByModule(automationAccountName, moduleName, options, callback) {
let apiVersion = '2015-10-31';
// Validate
try {
if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
throw new Error('this.client.resourceGroupName 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 (this.client.resourceGroupName !== null && this.client.resourceGroupName !== undefined) {
if (this.client.resourceGroupName.match(/^[-\w\._]+$/) === null)
if (resourceGroupName !== null && resourceGroupName !== undefined) {
if (resourceGroupName.match(/^[-\w\._]+$/) === null)
{
throw new Error('"this.client.resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
}
}
if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
Expand All @@ -241,7 +245,7 @@ function _listByModule(automationAccountName, moduleName, options, callback) {
// Construct URL
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities';
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{automationAccountName}', encodeURIComponent(automationAccountName));
requestUrl = requestUrl.replace('{moduleName}', encodeURIComponent(moduleName));
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
Expand Down Expand Up @@ -474,6 +478,8 @@ class ActivityOperations {
* Retrieve the activity in the module identified by module name and activity
* name.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} automationAccountName The automation account name.
*
* @param {string} moduleName The name of module.
Expand All @@ -491,11 +497,11 @@ class ActivityOperations {
*
* @reject {Error} - The error object.
*/
getWithHttpOperationResponse(automationAccountName, moduleName, activityName, options) {
getWithHttpOperationResponse(resourceGroupName, automationAccountName, moduleName, activityName, options) {
let client = this.client;
let self = this;
return new Promise((resolve, reject) => {
self._get(automationAccountName, moduleName, activityName, options, (err, result, request, response) => {
self._get(resourceGroupName, automationAccountName, moduleName, activityName, options, (err, result, request, response) => {
let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
httpOperationResponse.body = result;
if (err) { reject(err); }
Expand All @@ -509,6 +515,8 @@ class ActivityOperations {
* Retrieve the activity in the module identified by module name and activity
* name.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} automationAccountName The automation account name.
*
* @param {string} moduleName The name of module.
Expand Down Expand Up @@ -542,7 +550,7 @@ class ActivityOperations {
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
get(automationAccountName, moduleName, activityName, options, optionalCallback) {
get(resourceGroupName, automationAccountName, moduleName, activityName, options, optionalCallback) {
let client = this.client;
let self = this;
if (!optionalCallback && typeof options === 'function') {
Expand All @@ -551,20 +559,22 @@ class ActivityOperations {
}
if (!optionalCallback) {
return new Promise((resolve, reject) => {
self._get(automationAccountName, moduleName, activityName, options, (err, result, request, response) => {
self._get(resourceGroupName, automationAccountName, moduleName, activityName, options, (err, result, request, response) => {
if (err) { reject(err); }
else { resolve(result); }
return;
});
});
} else {
return self._get(automationAccountName, moduleName, activityName, options, optionalCallback);
return self._get(resourceGroupName, automationAccountName, moduleName, activityName, options, optionalCallback);
}
}

/**
* Retrieve a list of activities in the module identified by module name.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} automationAccountName The automation account name.
*
* @param {string} moduleName The name of module.
Expand All @@ -580,11 +590,11 @@ class ActivityOperations {
*
* @reject {Error} - The error object.
*/
listByModuleWithHttpOperationResponse(automationAccountName, moduleName, options) {
listByModuleWithHttpOperationResponse(resourceGroupName, automationAccountName, moduleName, options) {
let client = this.client;
let self = this;
return new Promise((resolve, reject) => {
self._listByModule(automationAccountName, moduleName, options, (err, result, request, response) => {
self._listByModule(resourceGroupName, automationAccountName, moduleName, options, (err, result, request, response) => {
let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
httpOperationResponse.body = result;
if (err) { reject(err); }
Expand All @@ -597,6 +607,8 @@ class ActivityOperations {
/**
* Retrieve a list of activities in the module identified by module name.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} automationAccountName The automation account name.
*
* @param {string} moduleName The name of module.
Expand Down Expand Up @@ -628,7 +640,7 @@ class ActivityOperations {
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
listByModule(automationAccountName, moduleName, options, optionalCallback) {
listByModule(resourceGroupName, automationAccountName, moduleName, options, optionalCallback) {
let client = this.client;
let self = this;
if (!optionalCallback && typeof options === 'function') {
Expand All @@ -637,14 +649,14 @@ class ActivityOperations {
}
if (!optionalCallback) {
return new Promise((resolve, reject) => {
self._listByModule(automationAccountName, moduleName, options, (err, result, request, response) => {
self._listByModule(resourceGroupName, automationAccountName, moduleName, options, (err, result, request, response) => {
if (err) { reject(err); }
else { resolve(result); }
return;
});
});
} else {
return self._listByModule(automationAccountName, moduleName, options, optionalCallback);
return self._listByModule(resourceGroupName, automationAccountName, moduleName, options, optionalCallback);
}
}

Expand Down
Loading