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
2 changes: 1 addition & 1 deletion lib/services/hanaonazureManagement/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Microsoft
Copyright (c) 2019 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
151 changes: 150 additions & 1 deletion lib/services/hanaonazureManagement/lib/operations/hanaInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ function _update(resourceGroupName, hanaInstanceName, tagsParameter, options, ca
});
}


/**
* The operation to restart a SAP HANA instance.
*
Expand Down Expand Up @@ -649,6 +650,68 @@ function _restart(resourceGroupName, hanaInstanceName, options, callback) {
callback = options;
options = null;
}

if (!callback) {
throw new Error('callback cannot be null.');
}

// Send request
this.beginRestart(resourceGroupName, hanaInstanceName, options, (err, parsedResult, httpRequest, response) => {
if (err) return callback(err);

let initialResult = new msRest.HttpOperationResponse();
initialResult.request = httpRequest;
initialResult.response = response;
initialResult.body = response.body;
client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
if (err) return callback(err);

// Create Result
let result = null;

httpRequest = pollingResult.request;
response = pollingResult.response;
let responseBody = pollingResult.body;
if (responseBody === '') responseBody = null;

// Deserialize Response

return callback(null, result, httpRequest, response);
});
});
}

/**
* The operation to restart a SAP HANA instance.
*
* @param {string} resourceGroupName Name of the resource group.
*
* @param {string} hanaInstanceName Name of the SAP HANA on Azure instance.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} callback - The callback.
*
* @returns {function} callback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {null} [result] - The deserialized result object if an error did not occur.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _beginRestart(resourceGroupName, hanaInstanceName, 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.');
}
Expand Down Expand Up @@ -712,7 +775,7 @@ function _restart(resourceGroupName, hanaInstanceName, options, callback) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 202) {
if (statusCode !== 200 && statusCode !== 202) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
Expand Down Expand Up @@ -1024,6 +1087,7 @@ class HanaInstances {
this._get = _get;
this._update = _update;
this._restart = _restart;
this._beginRestart = _beginRestart;
this._listNext = _listNext;
this._listByResourceGroupNext = _listByResourceGroupNext;
}
Expand Down Expand Up @@ -1485,6 +1549,91 @@ class HanaInstances {
}
}

/**
* The operation to restart a SAP HANA instance.
*
* @param {string} resourceGroupName Name of the resource group.
*
* @param {string} hanaInstanceName Name of the SAP HANA on Azure instance.
*
* @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<null>} - The deserialized result object.
*
* @reject {Error} - The error object.
*/
beginRestartWithHttpOperationResponse(resourceGroupName, hanaInstanceName, options) {
let client = this.client;
let self = this;
return new Promise((resolve, reject) => {
self._beginRestart(resourceGroupName, hanaInstanceName, options, (err, result, request, response) => {
let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
httpOperationResponse.body = result;
if (err) { reject(err); }
else { resolve(httpOperationResponse); }
return;
});
});
}

/**
* The operation to restart a SAP HANA instance.
*
* @param {string} resourceGroupName Name of the resource group.
*
* @param {string} hanaInstanceName Name of the SAP HANA on Azure instance.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {function} [optionalCallback] - The optional callback.
*
* @returns {function|Promise} If a callback was passed as the last parameter
* then it returns the callback else returns a Promise.
*
* {Promise} A promise is returned
*
* @resolve {null} - The deserialized result object.
*
* @reject {Error} - The error object.
*
* {function} optionalCallback(err, result, request, response)
*
* {Error} err - The Error object if an error occurred, null otherwise.
*
* {null} [result] - The deserialized result object if an error did not occur.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
beginRestart(resourceGroupName, hanaInstanceName, 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._beginRestart(resourceGroupName, hanaInstanceName, options, (err, result, request, response) => {
if (err) { reject(err); }
else { resolve(result); }
return;
});
});
} else {
return self._beginRestart(resourceGroupName, hanaInstanceName, options, optionalCallback);
}
}

/**
* @summary Gets a list of SAP HANA instances in the specified subscription.
*
Expand Down
58 changes: 58 additions & 0 deletions lib/services/hanaonazureManagement/lib/operations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,64 @@ export interface HanaInstances {
restart(resourceGroupName: string, hanaInstanceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<void>): void;


/**
* The operation to restart a SAP HANA instance.
*
* @param {string} resourceGroupName Name of the resource group.
*
* @param {string} hanaInstanceName Name of the SAP HANA on Azure instance.
*
* @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<null>} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*/
beginRestartWithHttpOperationResponse(resourceGroupName: string, hanaInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<void>>;

/**
* The operation to restart a SAP HANA instance.
*
* @param {string} resourceGroupName Name of the resource group.
*
* @param {string} hanaInstanceName Name of the SAP HANA on Azure instance.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [optionalCallback] - The optional callback.
*
* @returns {ServiceCallback|Promise} If a callback was passed as the last
* parameter then it returns the callback else returns a Promise.
*
* {Promise} A promise is returned.
*
* @resolve {null} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*
* {ServiceCallback} optionalCallback(err, result, request, response)
*
* {Error|ServiceError} err - The Error object if an error occurred, null otherwise.
*
* {null} [result] - The deserialized result object if an error did not occur.
*
* {WebResource} [request] - The HTTP Request object if an error did not occur.
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
beginRestart(resourceGroupName: string, hanaInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<void>;
beginRestart(resourceGroupName: string, hanaInstanceName: string, callback: ServiceCallback<void>): void;
beginRestart(resourceGroupName: string, hanaInstanceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<void>): void;


/**
* @summary Gets a list of SAP HANA instances in the specified subscription.
*
Expand Down