Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

[AutoPR containerservices/resource-manager] [AKS] add POST endpoint for fetching accessProfiles #2876

Merged
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
76 changes: 73 additions & 3 deletions lib/services/containerservicesManagement/lib/operations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ export interface ManagedClusters {


/**
* @summary Gets access profile of a managed cluster.
* @summary Gets an access profile of a managed cluster.
*
* Gets the accessProfile for the specified role name of the managed cluster
* with a specified resource group and name.
Expand All @@ -1571,10 +1571,10 @@ export interface ManagedClusters {
*
* @reject {Error|ServiceError} - The error object.
*/
getAccessProfilesWithHttpOperationResponse(resourceGroupName: string, resourceName: string, roleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ManagedClusterAccessProfile>>;
getAccessProfileWithHttpOperationResponse(resourceGroupName: string, resourceName: string, roleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ManagedClusterAccessProfile>>;

/**
* @summary Gets access profile of a managed cluster.
* @summary Gets an access profile of a managed cluster.
*
* Gets the accessProfile for the specified role name of the managed cluster
* with a specified resource group and name.
Expand Down Expand Up @@ -1614,6 +1614,76 @@ export interface ManagedClusters {
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
getAccessProfile(resourceGroupName: string, resourceName: string, roleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<models.ManagedClusterAccessProfile>;
getAccessProfile(resourceGroupName: string, resourceName: string, roleName: string, callback: ServiceCallback<models.ManagedClusterAccessProfile>): void;
getAccessProfile(resourceGroupName: string, resourceName: string, roleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ManagedClusterAccessProfile>): void;


/**
* @summary Gets access profile of a managed cluster.
*
* Use ManagedClusters_GetAccessProfile instead.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} resourceName The name of the managed cluster resource.
*
* @param {string} roleName The name of the role for managed cluster
* accessProfile resource.
*
* @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<ManagedClusterAccessProfile>} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*/
getAccessProfilesWithHttpOperationResponse(resourceGroupName: string, resourceName: string, roleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.ManagedClusterAccessProfile>>;

/**
* @summary Gets access profile of a managed cluster.
*
* Use ManagedClusters_GetAccessProfile instead.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} resourceName The name of the managed cluster resource.
*
* @param {string} roleName The name of the role for managed cluster
* accessProfile resource.
*
* @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 {ManagedClusterAccessProfile} - 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.
*
* {ManagedClusterAccessProfile} [result] - The deserialized result object if an error did not occur.
* See {@link ManagedClusterAccessProfile} 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.
*/
getAccessProfiles(resourceGroupName: string, resourceName: string, roleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<models.ManagedClusterAccessProfile>;
getAccessProfiles(resourceGroupName: string, resourceName: string, roleName: string, callback: ServiceCallback<models.ManagedClusterAccessProfile>): void;
getAccessProfiles(resourceGroupName: string, resourceName: string, roleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.ManagedClusterAccessProfile>): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function _getUpgradeProfile(resourceGroupName, resourceName, options, callback)
}

/**
* @summary Gets access profile of a managed cluster.
* @summary Gets an access profile of a managed cluster.
*
* Gets the accessProfile for the specified role name of the managed cluster
* with a specified resource group and name.
Expand Down Expand Up @@ -470,6 +470,159 @@ function _getUpgradeProfile(resourceGroupName, resourceName, options, callback)
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _getAccessProfile(resourceGroupName, resourceName, roleName, 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.');
}
let apiVersion = '2017-08-31';
// 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 (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 (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') {
throw new Error('resourceName cannot be null or undefined and it must be of type string.');
}
if (roleName === null || roleName === undefined || typeof roleName.valueOf() !== 'string') {
throw new Error('roleName cannot be null or undefined and it must be of type string.');
}
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
} catch (error) {
return callback(error);
}

// Construct URL
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/accessProfiles/{roleName}/listCredential';
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName));
requestUrl = requestUrl.replace('{roleName}', encodeURIComponent(roleName));
let queryParameters = [];
queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}

// Create HTTP transport objects
let httpRequest = new WebResource();
httpRequest.method = 'POST';
httpRequest.url = requestUrl;
httpRequest.headers = {};
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
httpRequest.body = null;
// Send Request
return client.pipeline(httpRequest, (err, response, responseBody) => {
if (err) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 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['ManagedClusterAccessProfile']().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 Gets access profile of a managed cluster.
*
* Use ManagedClusters_GetAccessProfile instead.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} resourceName The name of the managed cluster resource.
*
* @param {string} roleName The name of the role for managed cluster
* accessProfile resource.
*
* @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 ManagedClusterAccessProfile} 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 _getAccessProfiles(resourceGroupName, resourceName, roleName, options, callback) {
/* jshint validthis: true */
let client = this.client;
Expand Down Expand Up @@ -1569,6 +1722,7 @@ class ManagedClusters {
this._list = _list;
this._listByResourceGroup = _listByResourceGroup;
this._getUpgradeProfile = _getUpgradeProfile;
this._getAccessProfile = _getAccessProfile;
this._getAccessProfiles = _getAccessProfiles;
this._get = _get;
this._createOrUpdate = _createOrUpdate;
Expand Down Expand Up @@ -1849,7 +2003,45 @@ class ManagedClusters {
}

/**
* @summary Gets access profile of a managed cluster.
* @summary Gets an access profile of a managed cluster.
*
* Gets the accessProfile for the specified role name of the managed cluster
* with a specified resource group and name.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} resourceName The name of the managed cluster resource.
*
* @param {string} roleName The name of the role for managed cluster
* accessProfile resource.
*
* @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<ManagedClusterAccessProfile>} - The deserialized result object.
*
* @reject {Error} - The error object.
*/
getAccessProfileWithHttpOperationResponse(resourceGroupName, resourceName, roleName, options) {
let client = this.client;
let self = this;
return new Promise((resolve, reject) => {
self._getAccessProfile(resourceGroupName, resourceName, roleName, options, (err, result, request, response) => {
let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
httpOperationResponse.body = result;
if (err) { reject(err); }
else { resolve(httpOperationResponse); }
return;
});
});
}

/**
* @summary Gets an access profile of a managed cluster.
*
* Gets the accessProfile for the specified role name of the managed cluster
* with a specified resource group and name.
Expand All @@ -1866,6 +2058,66 @@ class ManagedClusters {
* @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 {ManagedClusterAccessProfile} - 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 ManagedClusterAccessProfile} 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.
*/
getAccessProfile(resourceGroupName, resourceName, roleName, 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._getAccessProfile(resourceGroupName, resourceName, roleName, options, (err, result, request, response) => {
if (err) { reject(err); }
else { resolve(result); }
return;
});
});
} else {
return self._getAccessProfile(resourceGroupName, resourceName, roleName, options, optionalCallback);
}
}

/**
* @summary Gets access profile of a managed cluster.
*
* Use ManagedClusters_GetAccessProfile instead.
*
* @param {string} resourceGroupName The name of the resource group.
*
* @param {string} resourceName The name of the managed cluster resource.
*
* @param {string} roleName The name of the role for managed cluster
* accessProfile resource.
*
* @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<ManagedClusterAccessProfile>} - The deserialized result object.
Expand All @@ -1889,8 +2141,7 @@ class ManagedClusters {
/**
* @summary Gets access profile of a managed cluster.
*
* Gets the accessProfile for the specified role name of the managed cluster
* with a specified resource group and name.
* Use ManagedClusters_GetAccessProfile instead.
*
* @param {string} resourceGroupName The name of the resource group.
*
Expand Down