generate code from shared swagger file
This commit is contained in:
Родитель
495c263e4a
Коммит
aba99ef5b0
|
@ -3,7 +3,7 @@ setlocal
|
|||
set scriptfolder=%~dp0
|
||||
set outfolder=%scriptfolder%lib\autorest
|
||||
rmdir /s /q %outfolder%
|
||||
AutoRest.exe -CodeGenerator NodeJS -Modeler Swagger -Input swagger.json -Namespace powerbi -output %outfolder% -name PowerBIClient -AddCredentials true
|
||||
AutoRest.exe -CodeGenerator NodeJS -Modeler Swagger -Input https://raw.githubusercontent.com/Microsoft/powerbi-rest-api-specs/master/swagger.json -Namespace powerbi -output %outfolder% -name PowerBIClient -AddCredentials true
|
||||
|
||||
echo "If ServiceClientCredentials is removed from lib/autorest/PowerBIClient.d.ts, revert this change. It is a bug in AutoRest"
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ var util = require('util');
|
|||
*
|
||||
* @member {array} [datasources] The datasources associated with this dataset
|
||||
*
|
||||
* @member {string} [defaultMode] The dataset mode or type. Possible values
|
||||
* include: 'AsAzure', 'AsOnPrem', 'Push', 'Streaming', 'PushStreaming'
|
||||
*
|
||||
*/
|
||||
function Dataset() {
|
||||
}
|
||||
|
@ -103,6 +106,13 @@ Dataset.prototype.mapper = function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
defaultMode: {
|
||||
required: false,
|
||||
serializedName: 'defaultMode',
|
||||
type: {
|
||||
name: 'String'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ export interface Report {
|
|||
*
|
||||
* @member {array} [datasources] The datasources associated with this dataset
|
||||
*
|
||||
* @member {string} [defaultMode] The dataset mode or type. Possible values
|
||||
* include: 'AsAzure', 'AsOnPrem', 'Push', 'Streaming', 'PushStreaming'
|
||||
*
|
||||
*/
|
||||
export interface Dataset {
|
||||
id?: string;
|
||||
|
@ -76,6 +79,7 @@ export interface Dataset {
|
|||
tables: Table[];
|
||||
webUrl?: string;
|
||||
datasources?: Datasource[];
|
||||
defaultMode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -170,6 +170,9 @@ Datasets.prototype.getDatasets = function (collectionName, workspaceId, options,
|
|||
* @param {array} [dataset.datasources] The datasources associated with this
|
||||
* dataset
|
||||
*
|
||||
* @param {string} [dataset.defaultMode] The dataset mode or type. Possible
|
||||
* values include: 'AsAzure', 'AsOnPrem', 'Push', 'Streaming', 'PushStreaming'
|
||||
*
|
||||
* @param {object} [options] Optional Parameters.
|
||||
*
|
||||
* @param {object} [options.customHeaders] Headers that will be added to the
|
||||
|
|
|
@ -57,6 +57,9 @@ export interface Datasets {
|
|||
* @param {array} [dataset.datasources] The datasources associated with this
|
||||
* dataset
|
||||
*
|
||||
* @param {string} [dataset.defaultMode] The dataset mode or type. Possible
|
||||
* values include: 'AsAzure', 'AsOnPrem', 'Push', 'Streaming', 'PushStreaming'
|
||||
*
|
||||
* @param {object} [options] Optional Parameters.
|
||||
*
|
||||
* @param {object} [options.customHeaders] Headers that will be added to the
|
||||
|
@ -471,6 +474,26 @@ export interface Reports {
|
|||
cloneReport(collectionName: string, workspaceId: string, reportKey: string, requestParameters: models.CloneReportRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.Report>): void;
|
||||
cloneReport(collectionName: string, workspaceId: string, reportKey: string, requestParameters: models.CloneReportRequest, callback: ServiceCallback<models.Report>): void;
|
||||
|
||||
/**
|
||||
* @summary Deletes the specified report
|
||||
*
|
||||
* @param {string} collectionName The workspace collection name
|
||||
*
|
||||
* @param {string} workspaceId The workspace id
|
||||
*
|
||||
* @param {string} reportKey The report id
|
||||
*
|
||||
* @param {object} [options] Optional Parameters.
|
||||
*
|
||||
* @param {object} [options.customHeaders] Headers that will be added to the
|
||||
* request
|
||||
*
|
||||
* @param {ServiceCallback} [callback] callback function; see ServiceCallback
|
||||
* doc in ms-rest index.d.ts for details
|
||||
*/
|
||||
deleteReport(collectionName: string, workspaceId: string, reportKey: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<any>): void;
|
||||
deleteReport(collectionName: string, workspaceId: string, reportKey: string, callback: ServiceCallback<any>): void;
|
||||
|
||||
/**
|
||||
* @summary Rebinds the specified report to requested dataset id
|
||||
*
|
||||
|
|
|
@ -302,6 +302,139 @@ Reports.prototype.cloneReport = function (collectionName, workspaceId, reportKey
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Deletes the specified report
|
||||
*
|
||||
* @param {string} collectionName The workspace collection name
|
||||
*
|
||||
* @param {string} workspaceId The workspace id
|
||||
*
|
||||
* @param {string} reportKey The report id
|
||||
*
|
||||
* @param {object} [options] Optional Parameters.
|
||||
*
|
||||
* @param {object} [options.customHeaders] Headers that will be added to the
|
||||
* request
|
||||
*
|
||||
* @param {function} 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.
|
||||
*
|
||||
* {object} [request] - The HTTP Request object if an error did not occur.
|
||||
*
|
||||
* {stream} [response] - The HTTP Response stream if an error did not occur.
|
||||
*/
|
||||
Reports.prototype.deleteReport = function (collectionName, workspaceId, reportKey, options, callback) {
|
||||
var client = this.client;
|
||||
if(!callback && typeof options === 'function') {
|
||||
callback = options;
|
||||
options = null;
|
||||
}
|
||||
if (!callback) {
|
||||
throw new Error('callback cannot be null.');
|
||||
}
|
||||
// Validate
|
||||
try {
|
||||
if (collectionName === null || collectionName === undefined || typeof collectionName.valueOf() !== 'string') {
|
||||
throw new Error('collectionName cannot be null or undefined and it must be of type string.');
|
||||
}
|
||||
if (workspaceId === null || workspaceId === undefined || typeof workspaceId.valueOf() !== 'string') {
|
||||
throw new Error('workspaceId cannot be null or undefined and it must be of type string.');
|
||||
}
|
||||
if (reportKey === null || reportKey === undefined || typeof reportKey.valueOf() !== 'string') {
|
||||
throw new Error('reportKey cannot be null or undefined and it must be of type string.');
|
||||
}
|
||||
} catch (error) {
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
// Construct URL
|
||||
var requestUrl = this.client.baseUri +
|
||||
'//v1.0/collections/{collectionName}/workspaces/{workspaceId}/reports/{reportKey}';
|
||||
requestUrl = requestUrl.replace('{collectionName}', encodeURIComponent(collectionName));
|
||||
requestUrl = requestUrl.replace('{workspaceId}', encodeURIComponent(workspaceId));
|
||||
requestUrl = requestUrl.replace('{reportKey}', encodeURIComponent(reportKey));
|
||||
// trim all duplicate forward slashes in the url
|
||||
var regex = /([^:]\/)\/+/gi;
|
||||
requestUrl = requestUrl.replace(regex, '$1');
|
||||
|
||||
// Create HTTP transport objects
|
||||
var httpRequest = new WebResource();
|
||||
httpRequest.method = 'DELETE';
|
||||
httpRequest.headers = {};
|
||||
httpRequest.url = requestUrl;
|
||||
// Set Headers
|
||||
if(options) {
|
||||
for(var headerName in options['customHeaders']) {
|
||||
if (options['customHeaders'].hasOwnProperty(headerName)) {
|
||||
httpRequest.headers[headerName] = options['customHeaders'][headerName];
|
||||
}
|
||||
}
|
||||
}
|
||||
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
|
||||
httpRequest.body = null;
|
||||
// Send Request
|
||||
return client.pipeline(httpRequest, function (err, response, responseBody) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var statusCode = response.statusCode;
|
||||
if (statusCode !== 200) {
|
||||
var error = new Error(responseBody);
|
||||
error.statusCode = response.statusCode;
|
||||
error.request = msRest.stripRequest(httpRequest);
|
||||
error.response = msRest.stripResponse(response);
|
||||
if (responseBody === '') responseBody = null;
|
||||
var 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;
|
||||
}
|
||||
} catch (defaultError) {
|
||||
error.message = util.format('Error "%s" occurred in deserializing the responseBody ' +
|
||||
'- "%s" for the default response.', defaultError.message, responseBody);
|
||||
return callback(error);
|
||||
}
|
||||
return callback(error);
|
||||
}
|
||||
// Create Result
|
||||
var result = null;
|
||||
if (responseBody === '') responseBody = null;
|
||||
// Deserialize Response
|
||||
if (statusCode === 200) {
|
||||
var parsedResponse = null;
|
||||
try {
|
||||
parsedResponse = JSON.parse(responseBody);
|
||||
result = JSON.parse(responseBody);
|
||||
if (parsedResponse !== null && parsedResponse !== undefined) {
|
||||
var resultMapper = {
|
||||
required: false,
|
||||
serializedName: 'parsedResponse',
|
||||
type: {
|
||||
name: 'Object'
|
||||
}
|
||||
};
|
||||
result = client.deserialize(resultMapper, parsedResponse, 'result');
|
||||
}
|
||||
} catch (error) {
|
||||
var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
|
||||
deserializationError.request = msRest.stripRequest(httpRequest);
|
||||
deserializationError.response = msRest.stripResponse(response);
|
||||
return callback(deserializationError);
|
||||
}
|
||||
}
|
||||
|
||||
return callback(null, result, httpRequest, response);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Rebinds the specified report to requested dataset id
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче