diff --git a/lib/services/loganalytics/lib/logAnalyticsClient.d.ts b/lib/services/loganalytics/lib/logAnalyticsClient.d.ts new file mode 100644 index 0000000000..c2f3bbbdca --- /dev/null +++ b/lib/services/loganalytics/lib/logAnalyticsClient.d.ts @@ -0,0 +1,130 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { ServiceClient, ServiceClientOptions, ServiceCallback, HttpOperationResponse, ServiceClientCredentials } from 'ms-rest'; +import * as models from "./models"; + +export default class LogAnalyticsClient extends ServiceClient { + /** + * @class + * Initializes a new instance of the LogAnalyticsClient class. + * @constructor + * + * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. + * + * @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 + * + */ + constructor(credentials: ServiceClientCredentials, baseUri?: string, options?: ServiceClientOptions); + + credentials: ServiceClientCredentials; + + + /** + * @summary Execute an Analytics query + * + * Executes an Analytics query for data. + * [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an + * example for using POST with an Analytics query. + * + * @param {string} workspaceId ID of the workspace. This is Workspace ID from + * the Properties blade in the Azure portal. + * + * @param {object} body The Analytics query. Learn more about the [Analytics + * query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + * @param {string} body.query The query to execute. + * + * @param {string} [body.timespan] Optional. The timespan over which to query + * data. This is an ISO8601 time period value. This timespan is applied in + * addition to any that are specified in the query expression. + * + * @param {array} [body.workspaces] A list of workspaces that are included in + * the query. + * + * @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} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + queryWithHttpOperationResponse(workspaceId: string, body: models.QueryBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Execute an Analytics query + * + * Executes an Analytics query for data. + * [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an + * example for using POST with an Analytics query. + * + * @param {string} workspaceId ID of the workspace. This is Workspace ID from + * the Properties blade in the Azure portal. + * + * @param {object} body The Analytics query. Learn more about the [Analytics + * query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + * @param {string} body.query The query to execute. + * + * @param {string} [body.timespan] Optional. The timespan over which to query + * data. This is an ISO8601 time period value. This timespan is applied in + * addition to any that are specified in the query expression. + * + * @param {array} [body.workspaces] A list of workspaces that are included in + * the query. + * + * @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 {QueryResults} - 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. + * + * {QueryResults} [result] - The deserialized result object if an error did not occur. + * See {@link QueryResults} 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. + */ + query(workspaceId: string, body: models.QueryBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + query(workspaceId: string, body: models.QueryBody, callback: ServiceCallback): void; + query(workspaceId: string, body: models.QueryBody, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +export { LogAnalyticsClient, models as LogAnalyticsModels }; diff --git a/lib/services/loganalytics/lib/logAnalyticsClient.js b/lib/services/loganalytics/lib/logAnalyticsClient.js new file mode 100644 index 0000000000..14336cacbe --- /dev/null +++ b/lib/services/loganalytics/lib/logAnalyticsClient.js @@ -0,0 +1,335 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const ServiceClient = msRest.ServiceClient; +const WebResource = msRest.WebResource; + +const models = require('./models'); + + +/** + * @summary Execute an Analytics query + * + * Executes an Analytics query for data. + * [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an + * example for using POST with an Analytics query. + * + * @param {string} workspaceId ID of the workspace. This is Workspace ID from + * the Properties blade in the Azure portal. + * + * @param {object} body The Analytics query. Learn more about the [Analytics + * query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + * @param {string} body.query The query to execute. + * + * @param {string} [body.timespan] Optional. The timespan over which to query + * data. This is an ISO8601 time period value. This timespan is applied in + * addition to any that are specified in the query expression. + * + * @param {array} [body.workspaces] A list of workspaces that are included in + * the query. + * + * @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 QueryResults} 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 _query(workspaceId, body, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + 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 (body === null || body === undefined) { + throw new Error('body cannot be null or undefined.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'workspaces/{workspaceId}/query'; + requestUrl = requestUrl.replace('{workspaceId}', encodeURIComponent(workspaceId)); + + // 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(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (body !== null && body !== undefined) { + let requestModelMapper = new client.models['QueryBody']().mapper(); + requestModel = client.serialize(requestModelMapper, body, 'body'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(body, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // 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) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().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['QueryResults']().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); + }); +} + +/** Class representing a LogAnalyticsClient. */ +class LogAnalyticsClient extends ServiceClient { + /** + * Create a LogAnalyticsClient. + * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. + * @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 + */ + constructor(credentials, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://api.loganalytics.io/v1'; + } + this.credentials = credentials; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + this.models = models; + this._query = _query; + msRest.addSerializationMixin(this); + } + + /** + * @summary Execute an Analytics query + * + * Executes an Analytics query for data. + * [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an + * example for using POST with an Analytics query. + * + * @param {string} workspaceId ID of the workspace. This is Workspace ID from + * the Properties blade in the Azure portal. + * + * @param {object} body The Analytics query. Learn more about the [Analytics + * query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + * @param {string} body.query The query to execute. + * + * @param {string} [body.timespan] Optional. The timespan over which to query + * data. This is an ISO8601 time period value. This timespan is applied in + * addition to any that are specified in the query expression. + * + * @param {array} [body.workspaces] A list of workspaces that are included in + * the query. + * + * @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} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + queryWithHttpOperationResponse(workspaceId, body, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._query(workspaceId, body, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Execute an Analytics query + * + * Executes an Analytics query for data. + * [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an + * example for using POST with an Analytics query. + * + * @param {string} workspaceId ID of the workspace. This is Workspace ID from + * the Properties blade in the Azure portal. + * + * @param {object} body The Analytics query. Learn more about the [Analytics + * query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + * @param {string} body.query The query to execute. + * + * @param {string} [body.timespan] Optional. The timespan over which to query + * data. This is an ISO8601 time period value. This timespan is applied in + * addition to any that are specified in the query expression. + * + * @param {array} [body.workspaces] A list of workspaces that are included in + * the query. + * + * @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 {QueryResults} - 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 QueryResults} 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. + */ + query(workspaceId, body, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._query(workspaceId, body, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._query(workspaceId, body, options, optionalCallback); + } + } + +} + +module.exports = LogAnalyticsClient; +module.exports['default'] = LogAnalyticsClient; +module.exports.LogAnalyticsClient = LogAnalyticsClient; +module.exports.LogAnalyticsModels = models; diff --git a/lib/services/loganalytics/lib/models/column.js b/lib/services/loganalytics/lib/models/column.js new file mode 100644 index 0000000000..3c72bc8b6a --- /dev/null +++ b/lib/services/loganalytics/lib/models/column.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * @summary A table column. + * + * A column in a table. + * + */ +class Column { + /** + * Create a Column. + * @member {string} [name] The name of this column. + * @member {string} [type] The data type of this column. + */ + constructor() { + } + + /** + * Defines the metadata of Column + * + * @returns {object} metadata of Column + * + */ + mapper() { + return { + required: false, + serializedName: 'column', + type: { + name: 'Composite', + className: 'Column', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Column; diff --git a/lib/services/loganalytics/lib/models/errorDetail.js b/lib/services/loganalytics/lib/models/errorDetail.js new file mode 100644 index 0000000000..26f46cf12e --- /dev/null +++ b/lib/services/loganalytics/lib/models/errorDetail.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * @summary Error details. + * + */ +class ErrorDetail { + /** + * Create a ErrorDetail. + * @member {string} code The error's code. + * @member {string} message A human readable error message. + * @member {string} [target] Indicates which property in the request is + * responsible for the error. + * @member {string} [value] Indicates which value in 'target' is responsible + * for the error. + * @member {array} [resources] Indicates resources which were responsible for + * the error. + * @member {object} [additionalProperties] + */ + constructor() { + } + + /** + * Defines the metadata of ErrorDetail + * + * @returns {object} metadata of ErrorDetail + * + */ + mapper() { + return { + required: false, + serializedName: 'errorDetail', + type: { + name: 'Composite', + className: 'ErrorDetail', + modelProperties: { + code: { + required: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: true, + serializedName: 'message', + type: { + name: 'String' + } + }, + target: { + required: false, + serializedName: 'target', + type: { + name: 'String' + } + }, + value: { + required: false, + serializedName: 'value', + type: { + name: 'String' + } + }, + resources: { + required: false, + serializedName: 'resources', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + additionalProperties: { + required: false, + serializedName: 'additionalProperties', + type: { + name: 'Object' + } + } + } + } + }; + } +} + +module.exports = ErrorDetail; diff --git a/lib/services/loganalytics/lib/models/errorInfo.js b/lib/services/loganalytics/lib/models/errorInfo.js new file mode 100644 index 0000000000..af069b78af --- /dev/null +++ b/lib/services/loganalytics/lib/models/errorInfo.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * @summary The code and message for an error. + * + */ +class ErrorInfo { + /** + * Create a ErrorInfo. + * @member {string} code A machine readable error code. + * @member {string} message A human readable error message. + * @member {array} [details] error details. + * @member {object} [innererror] Inner error details if they exist. + * @member {object} [additionalProperties] + */ + constructor() { + } + + /** + * Defines the metadata of ErrorInfo + * + * @returns {object} metadata of ErrorInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'errorInfo', + type: { + name: 'Composite', + className: 'ErrorInfo', + modelProperties: { + code: { + required: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: true, + serializedName: 'message', + type: { + name: 'String' + } + }, + details: { + required: false, + serializedName: 'details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorDetailElementType', + type: { + name: 'Composite', + className: 'ErrorDetail' + } + } + } + }, + innererror: { + required: false, + serializedName: 'innererror', + type: { + name: 'Composite', + className: 'ErrorInfo' + } + }, + additionalProperties: { + required: false, + serializedName: 'additionalProperties', + type: { + name: 'Object' + } + } + } + } + }; + } +} + +module.exports = ErrorInfo; diff --git a/lib/services/loganalytics/lib/models/errorResponse.js b/lib/services/loganalytics/lib/models/errorResponse.js new file mode 100644 index 0000000000..f36cdce5de --- /dev/null +++ b/lib/services/loganalytics/lib/models/errorResponse.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * @summary Error details. + * + * Contains details when the response code indicates an error. + * + */ +class ErrorResponse { + /** + * Create a ErrorResponse. + * @member {object} error The error details. + * @member {string} [error.code] A machine readable error code. + * @member {string} [error.message] A human readable error message. + * @member {array} [error.details] error details. + * @member {object} [error.innererror] Inner error details if they exist. + * @member {object} [error.additionalProperties] + */ + constructor() { + } + + /** + * Defines the metadata of ErrorResponse + * + * @returns {object} metadata of ErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'errorResponse', + type: { + name: 'Composite', + className: 'ErrorResponse', + modelProperties: { + error: { + required: true, + serializedName: 'error', + type: { + name: 'Composite', + className: 'ErrorInfo' + } + } + } + } + }; + } +} + +module.exports = ErrorResponse; diff --git a/lib/services/loganalytics/lib/models/index.d.ts b/lib/services/loganalytics/lib/models/index.d.ts new file mode 100644 index 0000000000..afbfad40aa --- /dev/null +++ b/lib/services/loganalytics/lib/models/index.d.ts @@ -0,0 +1,144 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as moment from "moment"; + + +/** + * @class + * Initializes a new instance of the QueryBody class. + * @constructor + * The Analytics query. Learn more about the [Analytics query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + * @member {string} query The query to execute. + * @member {string} [timespan] Optional. The timespan over which to query data. + * This is an ISO8601 time period value. This timespan is applied in addition + * to any that are specified in the query expression. + * @member {array} [workspaces] A list of workspaces that are included in the + * query. + */ +export interface QueryBody { + query: string; + timespan?: string; + workspaces?: string[]; +} + +/** + * @class + * Initializes a new instance of the Column class. + * @constructor + * @summary A table column. + * + * A column in a table. + * + * @member {string} [name] The name of this column. + * @member {string} [type] The data type of this column. + */ +export interface Column { + name?: string; + type?: string; +} + +/** + * @class + * Initializes a new instance of the Table class. + * @constructor + * @summary A query response table. + * + * Contains the columns and rows for one table in a query response. + * + * @member {string} name The name of the table. + * @member {array} columns The list of columns in this table. + * @member {array} rows The resulting rows from this query. + */ +export interface Table { + name: string; + columns: Column[]; + rows: string[][]; +} + +/** + * @class + * Initializes a new instance of the QueryResults class. + * @constructor + * @summary A query response. + * + * Contains the tables, columns & rows resulting from a query. + * + * @member {array} tables The list of tables, columns and rows. + */ +export interface QueryResults { + tables: Table[]; +} + +/** + * @class + * Initializes a new instance of the ErrorDetail class. + * @constructor + * @summary Error details. + * + * @member {string} code The error's code. + * @member {string} message A human readable error message. + * @member {string} [target] Indicates which property in the request is + * responsible for the error. + * @member {string} [value] Indicates which value in 'target' is responsible + * for the error. + * @member {array} [resources] Indicates resources which were responsible for + * the error. + * @member {object} [additionalProperties] + */ +export interface ErrorDetail { + code: string; + message: string; + target?: string; + value?: string; + resources?: string[]; + additionalProperties?: any; +} + +/** + * @class + * Initializes a new instance of the ErrorInfo class. + * @constructor + * @summary The code and message for an error. + * + * @member {string} code A machine readable error code. + * @member {string} message A human readable error message. + * @member {array} [details] error details. + * @member {object} [innererror] Inner error details if they exist. + * @member {object} [additionalProperties] + */ +export interface ErrorInfo { + code: string; + message: string; + details?: ErrorDetail[]; + innererror?: ErrorInfo; + additionalProperties?: any; +} + +/** + * @class + * Initializes a new instance of the ErrorResponse class. + * @constructor + * @summary Error details. + * + * Contains details when the response code indicates an error. + * + * @member {object} error The error details. + * @member {string} [error.code] A machine readable error code. + * @member {string} [error.message] A human readable error message. + * @member {array} [error.details] error details. + * @member {object} [error.innererror] Inner error details if they exist. + * @member {object} [error.additionalProperties] + */ +export interface ErrorResponse { + error: ErrorInfo; +} diff --git a/lib/services/loganalytics/lib/models/index.js b/lib/services/loganalytics/lib/models/index.js new file mode 100644 index 0000000000..f9643030a3 --- /dev/null +++ b/lib/services/loganalytics/lib/models/index.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.QueryBody = require('./queryBody'); +exports.Column = require('./column'); +exports.Table = require('./table'); +exports.QueryResults = require('./queryResults'); +exports.ErrorDetail = require('./errorDetail'); +exports.ErrorInfo = require('./errorInfo'); +exports.ErrorResponse = require('./errorResponse'); diff --git a/lib/services/loganalytics/lib/models/queryBody.js b/lib/services/loganalytics/lib/models/queryBody.js new file mode 100644 index 0000000000..c479a846f1 --- /dev/null +++ b/lib/services/loganalytics/lib/models/queryBody.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The Analytics query. Learn more about the [Analytics query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * + */ +class QueryBody { + /** + * Create a QueryBody. + * @member {string} query The query to execute. + * @member {string} [timespan] Optional. The timespan over which to query + * data. This is an ISO8601 time period value. This timespan is applied in + * addition to any that are specified in the query expression. + * @member {array} [workspaces] A list of workspaces that are included in the + * query. + */ + constructor() { + } + + /** + * Defines the metadata of QueryBody + * + * @returns {object} metadata of QueryBody + * + */ + mapper() { + return { + required: false, + serializedName: 'queryBody', + type: { + name: 'Composite', + className: 'QueryBody', + modelProperties: { + query: { + required: true, + serializedName: 'query', + type: { + name: 'String' + } + }, + timespan: { + required: false, + serializedName: 'timespan', + type: { + name: 'String' + } + }, + workspaces: { + required: false, + serializedName: 'workspaces', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = QueryBody; diff --git a/lib/services/loganalytics/lib/models/queryResults.js b/lib/services/loganalytics/lib/models/queryResults.js new file mode 100644 index 0000000000..29dd562d4b --- /dev/null +++ b/lib/services/loganalytics/lib/models/queryResults.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * @summary A query response. + * + * Contains the tables, columns & rows resulting from a query. + * + */ +class QueryResults { + /** + * Create a QueryResults. + * @member {array} tables The list of tables, columns and rows. + */ + constructor() { + } + + /** + * Defines the metadata of QueryResults + * + * @returns {object} metadata of QueryResults + * + */ + mapper() { + return { + required: false, + serializedName: 'queryResults', + type: { + name: 'Composite', + className: 'QueryResults', + modelProperties: { + tables: { + required: true, + serializedName: 'tables', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'TableElementType', + type: { + name: 'Composite', + className: 'Table' + } + } + } + } + } + } + }; + } +} + +module.exports = QueryResults; diff --git a/lib/services/loganalytics/lib/models/table.js b/lib/services/loganalytics/lib/models/table.js new file mode 100644 index 0000000000..d33f864b8a --- /dev/null +++ b/lib/services/loganalytics/lib/models/table.js @@ -0,0 +1,94 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * @summary A query response table. + * + * Contains the columns and rows for one table in a query response. + * + */ +class Table { + /** + * Create a Table. + * @member {string} name The name of the table. + * @member {array} columns The list of columns in this table. + * @member {array} rows The resulting rows from this query. + */ + constructor() { + } + + /** + * Defines the metadata of Table + * + * @returns {object} metadata of Table + * + */ + mapper() { + return { + required: false, + serializedName: 'table', + type: { + name: 'Composite', + className: 'Table', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + columns: { + required: true, + serializedName: 'columns', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ColumnElementType', + type: { + name: 'Composite', + className: 'Column' + } + } + } + }, + rows: { + required: true, + serializedName: 'rows', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ArrayElementType', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + } + } + }; + } +} + +module.exports = Table;