diff --git a/sdk/resourcegraph/arm-resourcegraph/LICENSE.txt b/sdk/resourcegraph/arm-resourcegraph/LICENSE.txt new file mode 100644 index 000000000000..b73b4a1293c3 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/resourcegraph/arm-resourcegraph/README.md b/sdk/resourcegraph/arm-resourcegraph/README.md new file mode 100644 index 000000000000..6e73f65c9e6b --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/README.md @@ -0,0 +1,96 @@ +## Azure ResourceGraphClient SDK for JavaScript + +This package contains an isomorphic SDK for ResourceGraphClient. + +### Currently supported environments + +- Node.js version 6.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/arm-resourcegraph +``` + +### How to use + +#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +```bash +npm install @azure/ms-rest-nodeauth +``` + +##### Sample code + +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-azure-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { ResourceGraphClient, ResourceGraphModels, ResourceGraphMappers } from "@azure/arm-resourcegraph"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new ResourceGraphClient(creds, subscriptionId); + client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); +``` + +#### browser - Authentication, client creation and list operations as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` + +##### Sample code + +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. + +- index.html +```html + + + + @azure/arm-resourcegraph sample + + + + + + + + +``` + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/models/index.ts b/sdk/resourcegraph/arm-resourcegraph/lib/models/index.ts new file mode 100644 index 000000000000..2a0670cce111 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/models/index.ts @@ -0,0 +1,461 @@ +/* + * 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 { BaseResource, CloudError, AzureServiceClientOptions } from "@azure/ms-rest-azure-js"; +import * as msRest from "@azure/ms-rest-js"; + +export { BaseResource, CloudError }; + + +/** + * @interface + * An interface representing QueryRequestOptions. + * The options for query evaluation + * + */ +export interface QueryRequestOptions { + /** + * @member {string} [skipToken] Continuation token for pagination, capturing + * the next page size and offset, as well as the context of the query. + */ + skipToken?: string; + /** + * @member {number} [top] The maximum number of rows that the query should + * return. Overrides the page size when ```$skipToken``` property is present. + */ + top?: number; + /** + * @member {number} [skip] The number of rows to skip from the beginning of + * the results. Overrides the next page offset when ```$skipToken``` property + * is present. + */ + skip?: number; +} + +/** + * @interface + * An interface representing FacetRequestOptions. + * The options for facet evaluation + * + */ +export interface FacetRequestOptions { + /** + * @member {string} [sortBy] The column name or query expression to sort on. + * Defaults to count if not present. + */ + sortBy?: string; + /** + * @member {FacetSortOrder} [sortOrder] The sorting order by the selected + * column (count by default). Possible values include: 'asc', 'desc'. Default + * value: 'desc' . + */ + sortOrder?: FacetSortOrder; + /** + * @member {string} [filter] Specifies the filter condition for the 'where' + * clause which will be run on main query's result, just before the actual + * faceting. + */ + filter?: string; + /** + * @member {number} [top] The maximum number of facet rows that should be + * returned. + */ + top?: number; +} + +/** + * @interface + * An interface representing FacetRequest. + * A request to compute additional statistics (facets) over the query results. + * + */ +export interface FacetRequest { + /** + * @member {string} expression The column or list of columns to summarize by + */ + expression: string; + /** + * @member {FacetRequestOptions} [options] The options for facet evaluation + */ + options?: FacetRequestOptions; +} + +/** + * @interface + * An interface representing QueryRequest. + * Describes a query to be executed. + * + */ +export interface QueryRequest { + /** + * @member {string[]} subscriptions Azure subscriptions against which to + * execute the query. + */ + subscriptions: string[]; + /** + * @member {string} query The resources query. + */ + query: string; + /** + * @member {QueryRequestOptions} [options] The query evaluation options + */ + options?: QueryRequestOptions; + /** + * @member {FacetRequest[]} [facets] An array of facet requests to be + * computed against the query result. + */ + facets?: FacetRequest[]; +} + +/** + * @interface + * An interface representing Column. + * Query result column descriptor. + * + */ +export interface Column { + /** + * @member {string} name Column name. + */ + name: string; + /** + * @member {ColumnDataType} type Column data type. Possible values include: + * 'string', 'integer', 'number', 'boolean', 'object' + */ + type: ColumnDataType; +} + +/** + * @interface + * An interface representing Table. + * Query output in tabular format. + * + */ +export interface Table { + /** + * @member {Column[]} columns Query result column descriptors. + */ + columns: Column[]; + /** + * @member {any[][]} rows Query result rows. + */ + rows: any[][]; +} + +/** + * Contains the possible cases for Facet. + */ +export type FacetUnion = Facet | FacetResult | FacetError; + +/** + * @interface + * An interface representing Facet. + * A facet containing additional statistics on the response of a query. Can be + * either FacetResult or FacetError. + * + */ +export interface Facet { + /** + * @member {string} resultType Polymorphic Discriminator + */ + resultType: "Facet"; + /** + * @member {string} expression Facet expression, same as in the corresponding + * facet request. + */ + expression: string; +} + +/** + * @interface + * An interface representing QueryResponse. + * Query result. + * + */ +export interface QueryResponse { + /** + * @member {number} totalRecords Number of total records matching the query. + */ + totalRecords: number; + /** + * @member {number} count Number of records returned in the current response. + * In the case of paging, this is the number of records in the current page. + */ + count: number; + /** + * @member {ResultTruncated} resultTruncated Indicates whether the query + * results are truncated. Possible values include: 'true', 'false' + */ + resultTruncated: ResultTruncated; + /** + * @member {string} [skipToken] When present, the value can be passed to a + * subsequent query call (together with the same query and subscriptions used + * in the current request) to retrieve the next page of data. + */ + skipToken?: string; + /** + * @member {Table} data Query output in tabular format. + */ + data: Table; + /** + * @member {FacetUnion[]} [facets] Query facets. + */ + facets?: FacetUnion[]; +} + +/** + * @interface + * An interface representing FacetResult. + * Successfully executed facet containing additional statistics on the response + * of a query. + * + */ +export interface FacetResult { + /** + * @member {string} resultType Polymorphic Discriminator + */ + resultType: "FacetResult"; + /** + * @member {string} expression Facet expression, same as in the corresponding + * facet request. + */ + expression: string; + /** + * @member {number} totalRecords Number of total records in the facet + * results. + */ + totalRecords: number; + /** + * @member {number} count Number of records returned in the facet response. + */ + count: number; + /** + * @member {Table} data A table containing the desired facets. Only present + * if the facet is valid. + */ + data: Table; +} + +/** + * @interface + * An interface representing ErrorDetails. + * @summary Error details. + * + */ +export interface ErrorDetails { + /** + * @member {string} code Error code identifying the specific error. + */ + code: string; + /** + * @member {string} message A human readable error message. + */ + message: string; + /** + * @property Describes unknown properties. The value of an unknown property + * can be of "any" type. + */ + [property: string]: any; +} + +/** + * @interface + * An interface representing FacetError. + * A facet whose execution resulted in an error. + * + */ +export interface FacetError { + /** + * @member {string} resultType Polymorphic Discriminator + */ + resultType: "FacetError"; + /** + * @member {string} expression Facet expression, same as in the corresponding + * facet request. + */ + expression: string; + /** + * @member {ErrorDetails[]} errors An array containing detected facet errors + * with details. + */ + errors: ErrorDetails[]; +} + +/** + * @interface + * An interface representing ErrorModel. + * @summary Error info. + * + * Error details. + * + */ +export interface ErrorModel { + /** + * @member {string} code Error code identifying the specific error. + */ + code: string; + /** + * @member {string} message A human readable error message. + */ + message: string; + /** + * @member {ErrorDetails[]} [details] Error details + */ + details?: ErrorDetails[]; +} + +/** + * @interface + * An interface representing ErrorResponse. + * @summary Error response. + * + * An error response from the API. + * + */ +export interface ErrorResponse { + /** + * @member {ErrorModel} error Error information. + */ + error: ErrorModel; +} + +/** + * @interface + * An interface representing OperationDisplay. + * Display metadata associated with the operation. + * + */ +export interface OperationDisplay { + /** + * @member {string} [provider] Service provider: Microsoft Resource Graph. + */ + provider?: string; + /** + * @member {string} [resource] Resource on which the operation is performed + * etc. + */ + resource?: string; + /** + * @member {string} [operation] Type of operation: get, read, delete, etc. + */ + operation?: string; + /** + * @member {string} [description] Description for the operation. + */ + description?: string; +} + +/** + * @interface + * An interface representing Operation. + * Resource Graph REST API operation definition. + * + */ +export interface Operation { + /** + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + */ + name?: string; + /** + * @member {OperationDisplay} [display] Display metadata associated with the + * operation. + */ + display?: OperationDisplay; + /** + * @member {string} [origin] The origin of operations. + */ + origin?: string; +} + +/** + * @interface + * An interface representing ResourceGraphClientOptions. + * @extends AzureServiceClientOptions + */ +export interface ResourceGraphClientOptions extends AzureServiceClientOptions { + /** + * @member {string} [baseUri] + */ + baseUri?: string; +} + + +/** + * @interface + * An interface representing the OperationListResult. + * Result of the request to list Resource Graph operations. It contains a list + * of operations and a URL link to get the next set of results. + * + * @extends Array + */ +export interface OperationListResult extends Array { +} + +/** + * Defines values for FacetSortOrder. + * Possible values include: 'asc', 'desc' + * @readonly + * @enum {string} + */ +export type FacetSortOrder = 'asc' | 'desc'; + +/** + * Defines values for ResultTruncated. + * Possible values include: 'true', 'false' + * @readonly + * @enum {string} + */ +export type ResultTruncated = 'true' | 'false'; + +/** + * Defines values for ColumnDataType. + * Possible values include: 'string', 'integer', 'number', 'boolean', 'object' + * @readonly + * @enum {string} + */ +export type ColumnDataType = 'string' | 'integer' | 'number' | 'boolean' | 'object'; + +/** + * Contains response data for the resources operation. + */ +export type ResourcesResponse = QueryResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: QueryResponse; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type OperationsListResponse = OperationListResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: OperationListResult; + }; +}; diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/models/mappers.ts b/sdk/resourcegraph/arm-resourcegraph/lib/models/mappers.ts new file mode 100644 index 000000000000..acb0922a6c77 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/models/mappers.ts @@ -0,0 +1,571 @@ +/* + * 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 { CloudErrorMapper, BaseResourceMapper } from "@azure/ms-rest-azure-js"; +import * as msRest from "@azure/ms-rest-js"; + +export const CloudError = CloudErrorMapper; +export const BaseResource = BaseResourceMapper; + +export const QueryRequestOptions: msRest.CompositeMapper = { + serializedName: "QueryRequestOptions", + type: { + name: "Composite", + className: "QueryRequestOptions", + modelProperties: { + skipToken: { + serializedName: "$skipToken", + type: { + name: "String" + } + }, + top: { + serializedName: "$top", + constraints: { + InclusiveMaximum: 1000, + InclusiveMinimum: 1 + }, + type: { + name: "Number" + } + }, + skip: { + serializedName: "$skip", + constraints: { + InclusiveMinimum: 0 + }, + type: { + name: "Number" + } + } + } + } +}; + +export const FacetRequestOptions: msRest.CompositeMapper = { + serializedName: "FacetRequestOptions", + type: { + name: "Composite", + className: "FacetRequestOptions", + modelProperties: { + sortBy: { + serializedName: "sortBy", + type: { + name: "String" + } + }, + sortOrder: { + serializedName: "sortOrder", + defaultValue: 'desc', + type: { + name: "Enum", + allowedValues: [ + "asc", + "desc" + ] + } + }, + filter: { + serializedName: "filter", + type: { + name: "String" + } + }, + top: { + serializedName: "$top", + constraints: { + InclusiveMaximum: 1000, + InclusiveMinimum: 1 + }, + type: { + name: "Number" + } + } + } + } +}; + +export const FacetRequest: msRest.CompositeMapper = { + serializedName: "FacetRequest", + type: { + name: "Composite", + className: "FacetRequest", + modelProperties: { + expression: { + required: true, + serializedName: "expression", + type: { + name: "String" + } + }, + options: { + serializedName: "options", + type: { + name: "Composite", + className: "FacetRequestOptions" + } + } + } + } +}; + +export const QueryRequest: msRest.CompositeMapper = { + serializedName: "QueryRequest", + type: { + name: "Composite", + className: "QueryRequest", + modelProperties: { + subscriptions: { + required: true, + serializedName: "subscriptions", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + query: { + required: true, + serializedName: "query", + type: { + name: "String" + } + }, + options: { + serializedName: "options", + type: { + name: "Composite", + className: "QueryRequestOptions" + } + }, + facets: { + serializedName: "facets", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "FacetRequest" + } + } + } + } + } + } +}; + +export const Column: msRest.CompositeMapper = { + serializedName: "Column", + type: { + name: "Composite", + className: "Column", + modelProperties: { + name: { + required: true, + serializedName: "name", + type: { + name: "String" + } + }, + type: { + required: true, + serializedName: "type", + type: { + name: "Enum", + allowedValues: [ + "string", + "integer", + "number", + "boolean", + "object" + ] + } + } + } + } +}; + +export const Table: msRest.CompositeMapper = { + serializedName: "Table", + type: { + name: "Composite", + className: "Table", + modelProperties: { + columns: { + required: true, + serializedName: "columns", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Column" + } + } + } + }, + rows: { + required: true, + serializedName: "rows", + type: { + name: "Sequence", + element: { + type: { + name: "Sequence", + element: { + type: { + name: "Object" + } + } + } + } + } + } + } + } +}; + +export const Facet: msRest.CompositeMapper = { + serializedName: "Facet", + type: { + name: "Composite", + polymorphicDiscriminator: { + serializedName: "resultType", + clientName: "resultType" + }, + uberParent: "Facet", + className: "Facet", + modelProperties: { + expression: { + required: true, + serializedName: "expression", + type: { + name: "String" + } + }, + resultType: { + required: true, + serializedName: "resultType", + type: { + name: "String" + } + } + } + } +}; + +export const QueryResponse: msRest.CompositeMapper = { + serializedName: "QueryResponse", + type: { + name: "Composite", + className: "QueryResponse", + modelProperties: { + totalRecords: { + required: true, + serializedName: "totalRecords", + type: { + name: "Number" + } + }, + count: { + required: true, + serializedName: "count", + type: { + name: "Number" + } + }, + resultTruncated: { + required: true, + serializedName: "resultTruncated", + type: { + name: "Enum", + allowedValues: [ + "true", + "false" + ] + } + }, + skipToken: { + serializedName: "$skipToken", + type: { + name: "String" + } + }, + data: { + required: true, + serializedName: "data", + type: { + name: "Composite", + className: "Table" + } + }, + facets: { + serializedName: "facets", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Facet" + } + } + } + } + } + } +}; + +export const FacetResult: msRest.CompositeMapper = { + serializedName: "FacetResult", + type: { + name: "Composite", + polymorphicDiscriminator: Facet.type.polymorphicDiscriminator, + uberParent: "Facet", + className: "FacetResult", + modelProperties: { + ...Facet.type.modelProperties, + totalRecords: { + required: true, + serializedName: "totalRecords", + type: { + name: "Number" + } + }, + count: { + required: true, + serializedName: "count", + type: { + name: "Number" + } + }, + data: { + required: true, + serializedName: "data", + type: { + name: "Composite", + className: "Table" + } + } + } + } +}; + +export const ErrorDetails: msRest.CompositeMapper = { + serializedName: "ErrorDetails", + type: { + name: "Composite", + className: "ErrorDetails", + modelProperties: { + code: { + required: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + required: true, + serializedName: "message", + type: { + name: "String" + } + } + }, + additionalProperties: { + type: { + name: "Object" + } + } + } +}; + +export const FacetError: msRest.CompositeMapper = { + serializedName: "FacetError", + type: { + name: "Composite", + polymorphicDiscriminator: Facet.type.polymorphicDiscriminator, + uberParent: "Facet", + className: "FacetError", + modelProperties: { + ...Facet.type.modelProperties, + errors: { + required: true, + serializedName: "errors", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetails", + additionalProperties: { + type: { + name: "Object" + } + } + } + } + } + } + } + } +}; + +export const ErrorModel: msRest.CompositeMapper = { + serializedName: "Error", + type: { + name: "Composite", + className: "ErrorModel", + modelProperties: { + code: { + required: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + required: true, + serializedName: "message", + type: { + name: "String" + } + }, + details: { + serializedName: "details", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetails", + additionalProperties: { + type: { + name: "Object" + } + } + } + } + } + } + } + } +}; + +export const ErrorResponse: msRest.CompositeMapper = { + serializedName: "ErrorResponse", + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + required: true, + serializedName: "error", + type: { + name: "Composite", + className: "ErrorModel" + } + } + } + } +}; + +export const OperationDisplay: msRest.CompositeMapper = { + serializedName: "Operation_display", + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", + type: { + name: "String" + } + }, + operation: { + serializedName: "operation", + type: { + name: "String" + } + }, + description: { + serializedName: "description", + type: { + name: "String" + } + } + } + } +}; + +export const Operation: msRest.CompositeMapper = { + serializedName: "Operation", + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + }, + origin: { + serializedName: "origin", + type: { + name: "String" + } + } + } + } +}; + +export const OperationListResult: msRest.CompositeMapper = { + serializedName: "OperationListResult", + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } + } + } + } + } +}; + +export const discriminators = { + 'Facet' : Facet, + 'Facet.FacetResult' : FacetResult, + 'Facet.FacetError' : FacetError +}; diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/models/operationsMappers.ts b/sdk/resourcegraph/arm-resourcegraph/lib/models/operationsMappers.ts new file mode 100644 index 000000000000..19f09b391246 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/models/operationsMappers.ts @@ -0,0 +1,18 @@ +/* + * 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. + */ + +export { + discriminators, + OperationListResult, + Operation, + OperationDisplay, + CloudError +} from "../models/mappers"; + diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/models/parameters.ts b/sdk/resourcegraph/arm-resourcegraph/lib/models/parameters.ts new file mode 100644 index 000000000000..0d109216640f --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/models/parameters.ts @@ -0,0 +1,32 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; + +export const acceptLanguage: msRest.OperationParameter = { + parameterPath: "acceptLanguage", + mapper: { + serializedName: "accept-language", + defaultValue: 'en-US', + type: { + name: "String" + } + } +}; +export const apiVersion: msRest.OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + required: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/operations/index.ts b/sdk/resourcegraph/arm-resourcegraph/lib/operations/index.ts new file mode 100644 index 000000000000..8a723d22b1d6 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/operations/index.ts @@ -0,0 +1,11 @@ +/* + * 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. + */ + +export * from "./operations"; diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/operations/operations.ts b/sdk/resourcegraph/arm-resourcegraph/lib/operations/operations.ts new file mode 100644 index 000000000000..e49fe973def2 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/operations/operations.ts @@ -0,0 +1,74 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/operationsMappers"; +import * as Parameters from "../models/parameters"; +import { ResourceGraphClientContext } from "../resourceGraphClientContext"; + +/** Class representing a Operations. */ +export class Operations { + private readonly client: ResourceGraphClientContext; + + /** + * Create a Operations. + * @param {ResourceGraphClientContext} client Reference to the service client. + */ + constructor(client: ResourceGraphClientContext) { + this.client = client; + } + + /** + * Lists all of the available REST API operations. + * @param [options] The optional parameters + * @returns Promise + */ + list(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + list(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "providers/Microsoft.ResourceGraph/operations", + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/resourceGraphClient.ts b/sdk/resourcegraph/arm-resourcegraph/lib/resourceGraphClient.ts new file mode 100644 index 000000000000..903e6857e059 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/resourceGraphClient.ts @@ -0,0 +1,98 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as Parameters from "./models/parameters"; +import * as operations from "./operations"; +import { ResourceGraphClientContext } from "./resourceGraphClientContext"; + + +class ResourceGraphClient extends ResourceGraphClientContext { + // Operation groups + operations: operations.Operations; + + /** + * Initializes a new instance of the ResourceGraphClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, options?: Models.ResourceGraphClientOptions) { + super(credentials, options); + this.operations = new operations.Operations(this); + } + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the + * request. + * @param query Request specifying query and its options. + * @param [options] The optional parameters + * @returns Promise + */ + resources(query: Models.QueryRequest, options?: msRest.RequestOptionsBase): Promise; + /** + * @param query Request specifying query and its options. + * @param callback The callback + */ + resources(query: Models.QueryRequest, callback: msRest.ServiceCallback): void; + /** + * @param query Request specifying query and its options. + * @param options The optional parameters + * @param callback The callback + */ + resources(query: Models.QueryRequest, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + resources(query: Models.QueryRequest, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + query, + options + }, + resourcesOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const resourcesOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "providers/Microsoft.ResourceGraph/resources", + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "query", + mapper: { + ...Mappers.QueryRequest, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.QueryResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +export { + ResourceGraphClient, + ResourceGraphClientContext, + Models as ResourceGraphModels, + Mappers as ResourceGraphMappers +}; +export * from "./operations"; diff --git a/sdk/resourcegraph/arm-resourcegraph/lib/resourceGraphClientContext.ts b/sdk/resourcegraph/arm-resourcegraph/lib/resourceGraphClientContext.ts new file mode 100644 index 000000000000..7947599b3da4 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/lib/resourceGraphClientContext.ts @@ -0,0 +1,56 @@ +/* + * 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 Models from "./models"; +import * as msRest from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-azure-js"; + +const packageName = "@azure/arm-resourcegraph"; +const packageVersion = "1.0.0"; + +export class ResourceGraphClientContext extends msRestAzure.AzureServiceClient { + credentials: msRest.ServiceClientCredentials; + apiVersion?: string; + + /** + * Initializes a new instance of the ResourceGraphClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, options?: Models.ResourceGraphClientOptions) { + if (credentials == undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) { + options = {}; + } + if(!options.userAgent) { + const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.apiVersion = '2019-04-01'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com"; + this.requestContentType = "application/json; charset=utf-8"; + this.credentials = credentials; + + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + } +} diff --git a/sdk/resourcegraph/arm-resourcegraph/package.json b/sdk/resourcegraph/arm-resourcegraph/package.json new file mode 100644 index 000000000000..969e2d7f06b8 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/package.json @@ -0,0 +1,56 @@ +{ + "name": "@azure/arm-resourcegraph", + "author": "Microsoft Corporation", + "description": "ResourceGraphClient Library with typescript type definitions for node.js and browser.", + "version": "1.0.0", + "dependencies": { + "@azure/ms-rest-azure-js": "^1.2.0", + "@azure/ms-rest-js": "^1.2.0", + "tslib": "^1.9.3" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/arm-resourcegraph.js", + "module": "./esm/resourceGraphClient.js", + "types": "./esm/resourceGraphClient.d.ts", + "devDependencies": { + "typescript": "^3.1.1", + "rollup": "^0.66.2", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.4.9" + }, + "homepage": "https://github.com/azure/azure-sdk-for-js", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "esm/**/*.js", + "esm/**/*.js.map", + "esm/**/*.d.ts", + "esm/**/*.d.ts.map", + "lib/**/*.ts", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/arm-resourcegraph.js.map'\" -o ./dist/arm-resourcegraph.min.js ./dist/arm-resourcegraph.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false +} diff --git a/sdk/resourcegraph/arm-resourcegraph/rollup.config.js b/sdk/resourcegraph/arm-resourcegraph/rollup.config.js new file mode 100644 index 000000000000..b2e2e088daec --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/rollup.config.js @@ -0,0 +1,37 @@ +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/resourceGraphClient.js", + external: [ + "@azure/ms-rest-js", + "@azure/ms-rest-azure-js" + ], + output: { + file: "./dist/arm-resourcegraph.js", + format: "umd", + name: "Azure.ArmResourcegraph", + sourcemap: true, + globals: { + "@azure/ms-rest-js": "msRest", + "@azure/ms-rest-azure-js": "msRestAzure" + }, + banner: `/* + * 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. + */` + }, + plugins: [ + nodeResolve({ module: true }), + sourcemaps() + ] +}; + +export default config; diff --git a/sdk/resourcegraph/arm-resourcegraph/tsconfig.json b/sdk/resourcegraph/arm-resourcegraph/tsconfig.json new file mode 100644 index 000000000000..51ea90961ce5 --- /dev/null +++ b/sdk/resourcegraph/arm-resourcegraph/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es5", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./lib/**/*.ts"], + "exclude": ["node_modules"] +}