Skip to content

Commit

Permalink
remove ms-rest-js in tools
Browse files Browse the repository at this point in the history
  • Loading branch information
JhontSouth committed Oct 30, 2023
1 parent 8e022c1 commit 42ffbbf
Show file tree
Hide file tree
Showing 8 changed files with 633 additions and 738 deletions.
116 changes: 58 additions & 58 deletions tools/framework/suite-base.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

'use strict';

const msRest = require('@azure/ms-rest-js');
const { stripRequest, stripResponse, WebResource } = require("@azure/core-http");
const uuid = require('uuid');
const WebResource = msRest.WebResource;

/**
* Gets a deployments operation.
Expand Down Expand Up @@ -43,9 +42,9 @@ const WebResource = msRest.WebResource;
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _get(resourceGroupName, deploymentName, operationId, options, callback) {
/* jshint validthis: true */
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
if (!callback && typeof options === 'function') {
callback = options;
options = null;
}
Expand All @@ -58,33 +57,27 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback)
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName !== null && resourceGroupName !== undefined) {
if (resourceGroupName.length > 90)
{
if (resourceGroupName.length > 90) {
throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
}
if (resourceGroupName.length < 1)
{
if (resourceGroupName.length < 1) {
throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
}
if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
{
if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) {
throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
}
}
if (deploymentName === null || deploymentName === undefined || typeof deploymentName.valueOf() !== 'string') {
throw new Error('deploymentName cannot be null or undefined and it must be of type string.');
}
if (deploymentName !== null && deploymentName !== undefined) {
if (deploymentName.length > 64)
{
if (deploymentName.length > 64) {
throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64');
}
if (deploymentName.length < 1)
{
if (deploymentName.length < 1) {
throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1');
}
if (deploymentName.match(/^[-\w\._\(\)]+$/) === null)
{
if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) {
throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
}
}
Expand Down Expand Up @@ -125,13 +118,13 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback)
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = uuid.v4();
httpRequest.headers['x-ms-client-request-id'] = uuid.v4();
}
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) {
for (let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
Expand All @@ -147,8 +140,8 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback)
if (statusCode !== 200) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
error.request = stripRequest(httpRequest);
error.response = stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
Expand All @@ -164,7 +157,7 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback)
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
Expand All @@ -184,8 +177,8 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback)
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
deserializationError.request = stripRequest(httpRequest);
deserializationError.response = stripResponse(response);
return callback(deserializationError);
}
}
Expand Down Expand Up @@ -225,9 +218,9 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback)
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _list(resourceGroupName, deploymentName, options, callback) {
/* jshint validthis: true */
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
if (!callback && typeof options === 'function') {
callback = options;
options = null;
}
Expand All @@ -241,33 +234,27 @@ function _list(resourceGroupName, deploymentName, options, callback) {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName !== null && resourceGroupName !== undefined) {
if (resourceGroupName.length > 90)
{
if (resourceGroupName.length > 90) {
throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
}
if (resourceGroupName.length < 1)
{
if (resourceGroupName.length < 1) {
throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
}
if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
{
if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) {
throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
}
}
if (deploymentName === null || deploymentName === undefined || typeof deploymentName.valueOf() !== 'string') {
throw new Error('deploymentName cannot be null or undefined and it must be of type string.');
}
if (deploymentName !== null && deploymentName !== undefined) {
if (deploymentName.length > 64)
{
if (deploymentName.length > 64) {
throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64');
}
if (deploymentName.length < 1)
{
if (deploymentName.length < 1) {
throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1');
}
if (deploymentName.match(/^[-\w\._\(\)]+$/) === null)
{
if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) {
throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
}
}
Expand Down Expand Up @@ -310,13 +297,13 @@ function _list(resourceGroupName, deploymentName, options, callback) {
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = uuid.v4();
httpRequest.headers['x-ms-client-request-id'] = uuid.v4();
}
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) {
for (let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
Expand All @@ -332,8 +319,8 @@ function _list(resourceGroupName, deploymentName, options, callback) {
if (statusCode !== 200) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
error.request = stripRequest(httpRequest);
error.response = stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
Expand All @@ -349,7 +336,7 @@ function _list(resourceGroupName, deploymentName, options, callback) {
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
Expand All @@ -369,8 +356,8 @@ function _list(resourceGroupName, deploymentName, options, callback) {
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
deserializationError.request = stripRequest(httpRequest);
deserializationError.response = stripResponse(response);
return callback(deserializationError);
}
}
Expand Down Expand Up @@ -405,9 +392,9 @@ function _list(resourceGroupName, deploymentName, options, callback) {
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _listNext(nextPageLink, options, callback) {
/* jshint validthis: true */
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
if (!callback && typeof options === 'function') {
callback = options;
options = null;
}
Expand Down Expand Up @@ -438,13 +425,13 @@ function _listNext(nextPageLink, options, callback) {
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = uuid.v4();
httpRequest.headers['x-ms-client-request-id'] = uuid.v4();
}
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) {
for (let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
Expand All @@ -460,8 +447,8 @@ function _listNext(nextPageLink, options, callback) {
if (statusCode !== 200) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
error.request = stripRequest(httpRequest);
error.response = stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
Expand All @@ -477,7 +464,7 @@ function _listNext(nextPageLink, options, callback) {
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
Expand All @@ -497,8 +484,8 @@ function _listNext(nextPageLink, options, callback) {
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
deserializationError.request = stripRequest(httpRequest);
deserializationError.response = stripResponse(response);
return callback(deserializationError);
}
}
Expand Down
Loading

0 comments on commit 42ffbbf

Please sign in to comment.