diff --git a/sdk/quantum/.gitignore b/sdk/quantum/.gitignore new file mode 100644 index 000000000000..f7047c249240 --- /dev/null +++ b/sdk/quantum/.gitignore @@ -0,0 +1,3 @@ +# Temp files used to auto-generate code +temp/ + diff --git a/sdk/quantum/quantum-client/LICENSE.txt b/sdk/quantum/quantum-client/LICENSE.txt new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/quantum/quantum-client/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 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. \ No newline at end of file diff --git a/sdk/quantum/quantum-client/README.md b/sdk/quantum/quantum-client/README.md new file mode 100644 index 000000000000..ec8abd1086f1 --- /dev/null +++ b/sdk/quantum/quantum-client/README.md @@ -0,0 +1,27 @@ +## Azure QuantumClient SDK for JavaScript + +This package contains an isomorphic SDK for QuantumClient. + +### Currently supported environments + +- Node.js version 8.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/quantum-client +``` + +### How to use + +#### Sample code + +Refer the sample code in the [azure-sdk-for-js-samples](https://github.com/Azure/azure-sdk-for-js-samples) repository. + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcdn%2Farm-cdn%2FREADME.png) \ No newline at end of file diff --git a/sdk/quantum/quantum-client/api-extractor.json b/sdk/quantum/quantum-client/api-extractor.json new file mode 100644 index 000000000000..5fb5b21b56f2 --- /dev/null +++ b/sdk/quantum/quantum-client/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./esm/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./esm/index.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/quantum/quantum-client/package.json b/sdk/quantum/quantum-client/package.json new file mode 100644 index 000000000000..2d7c5d02914b --- /dev/null +++ b/sdk/quantum/quantum-client/package.json @@ -0,0 +1,48 @@ +{ + "name": "@azure/quantum-client", + "author": "Microsoft Corporation", + "description": "Azure Quantum REST API client", + "version": "1.0.0", + "dependencies": { "@azure/core-http": "^1.1.4", "tslib": "^1.9.3" }, + "keywords": ["node", "azure", "typescript", "browser", "isomorphic"], + "license": "MIT", + "main": "./dist/quantum-client.js", + "module": "./esm/index.js", + "types": "./esm/index.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", + "@microsoft/api-extractor": "7.9.10" + }, + "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", + "src/**/*.ts", + "README.md", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/quantum-client.js.map'\" -o ./dist/quantum-client.min.js ./dist/quantum-client.js", + "prepack": "npm install && npm run build", + "extract-api": "api-extractor run --local" + }, + "sideEffects": false, + "autoPublish": true +} diff --git a/sdk/quantum/quantum-client/rollup.config.js b/sdk/quantum/quantum-client/rollup.config.js new file mode 100644 index 000000000000..aea8707403f3 --- /dev/null +++ b/sdk/quantum/quantum-client/rollup.config.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/quantumClient.js", + external: ["@azure/core-http", "@azure/core-arm"], + output: { + file: "./dist/quantum-client.js", + format: "umd", + name: "Azure.QuantumClient", + sourcemap: true, + globals: { + "@azure/core-http": "coreHttp", + "@azure/core-arm": "coreArm" + }, + 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/quantum/quantum-client/src/index.ts b/sdk/quantum/quantum-client/src/index.ts new file mode 100644 index 000000000000..96cd37e29b3e --- /dev/null +++ b/sdk/quantum/quantum-client/src/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./models"; +export { QuantumClient } from "./quantumClient"; +export { QuantumClientContext } from "./quantumClientContext"; diff --git a/sdk/quantum/quantum-client/src/models/index.ts b/sdk/quantum/quantum-client/src/models/index.ts new file mode 100644 index 000000000000..fa4758ce9c2a --- /dev/null +++ b/sdk/quantum/quantum-client/src/models/index.ts @@ -0,0 +1,496 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; + +/** + * List of job details. + */ +export interface JobDetailsList { + /** + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: JobDetails[]; + /** + * Total records count number. + */ + count?: number; + /** + * Link to the next page of results. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** + * Job details. + */ +export interface JobDetails { + /** + * The job id. + */ + id?: string; + /** + * The job name. Is not required for the name to be unique and it's only used for display purposes. + */ + name?: string; + /** + * The blob container SAS uri, the container is used to host job data. + */ + containerUri: string; + /** + * The input blob SAS uri, if specified, it will override the default input blob in the container. + */ + inputDataUri?: string; + /** + * The format of the input data. + */ + inputDataFormat: string; + /** + * The input parameters for the job. JSON object used by the target solver. It is expected that the size of this object is small and only used to specify parameters for the execution target, not the input data. + */ + inputParams?: any; + /** + * The unique identifier for the provider. + */ + providerId: string; + /** + * The target identifier to run the job. + */ + target: string; + /** + * The job metadata. Metadata provides client the ability to store client-specific information + */ + metadata?: { [propertyName: string]: string }; + /** + * The output blob SAS uri. When a job finishes successfully, results will be uploaded to this blob. + */ + outputDataUri?: string; + /** + * The format of the output data. + */ + outputDataFormat?: string; + /** + * The job status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly status?: JobStatus; + /** + * The creation time of the job. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly creationTime?: Date; + /** + * The time when the job began execution. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly beginExecutionTime?: Date; + /** + * The time when the job finished execution. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly endExecutionTime?: Date; + /** + * The time when a job was successfully cancelled. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly cancellationTime?: Date; + /** + * The error data for the job. This is expected only when Status 'Failed'. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly errorData?: ErrorData; +} + +/** + * An error response from Azure. + */ +export interface ErrorData { + /** + * An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + */ + code?: string; + /** + * A message describing the error, intended to be suitable for displaying in a user interface. + */ + message?: string; +} + +/** + * Error information returned by the API + */ +export interface RestError { + /** + * An error response from Azure. + */ + error?: ErrorData; +} + +/** + * Providers status. + */ +export interface ProviderStatusList { + /** + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: ProviderStatus[]; + /** + * Link to the next page of results. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** + * Providers status. + */ +export interface ProviderStatus { + /** + * Provider id. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Provider availability. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly currentAvailability?: ProviderAvailability; + /** + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly targets?: TargetStatus[]; +} + +/** + * Target status. + */ +export interface TargetStatus { + /** + * Target id. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Target availability. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly currentAvailability?: TargetAvailability; + /** + * Average queue time in seconds. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly averageQueueTime?: number; + /** + * A page with detailed status of the provider. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly statusPage?: string; +} + +/** + * Blob details. + */ +export interface BlobDetails { + /** + * The container name. + */ + containerName: string; + /** + * The blob name. + */ + blobName?: string; +} + +/** + * Get SAS URL operation response. + */ +export interface SasUriResponse { + /** + * A URL with a SAS token to upload a blob for execution in the given workspace. + */ + sasUri?: string; +} + +/** + * List of quotas. + */ +export interface QuotaList { + /** + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: Quota[]; + /** + * Link to the next page of results. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** + * Quota information. + */ +export interface Quota { + /** + * The name of the dimension associated with the quota. + */ + dimension?: string; + /** + * The scope at which the quota is applied. + */ + scope?: DimensionScope; + /** + * The unique identifier for the provider. + */ + providerId?: string; + /** + * The amount of the usage that has been applied for the current period. + */ + utilization?: number; + /** + * The amount of the usage that has been reserved but not applied for the current period. + */ + holds?: number; + /** + * The maximum amount of usage allowed for the current period. + */ + limit?: number; + /** + * The time period in which the quota's underlying meter is accumulated. Based on calendar year. 'None' is used for concurrent quotas. + */ + period?: MeterPeriod; +} + +/** + * Defines values for JobStatus. + */ +export type JobStatus = + | "Waiting" + | "Executing" + | "Succeeded" + | "Failed" + | "Cancelled" + | string; +/** + * Defines values for ProviderAvailability. + */ +export type ProviderAvailability = + | "Available" + | "Degraded" + | "Unavailable" + | string; +/** + * Defines values for TargetAvailability. + */ +export type TargetAvailability = + | "Available" + | "Degraded" + | "Unavailable" + | string; +/** + * Defines values for DimensionScope. + */ +export type DimensionScope = "Workspace" | "Subscription" | string; +/** + * Defines values for MeterPeriod. + */ +export type MeterPeriod = "None" | "Monthly" | string; + +/** + * Contains response data for the list operation. + */ +export type JobsListResponse = JobDetailsList & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: JobDetailsList; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type JobsGetResponse = JobDetails & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: JobDetails; + }; +}; + +/** + * Contains response data for the create operation. + */ +export type JobsCreateResponse = JobDetails & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: JobDetails; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type JobsListNextResponse = JobDetailsList & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: JobDetailsList; + }; +}; + +/** + * Contains response data for the getStatus operation. + */ +export type ProvidersGetStatusResponse = ProviderStatusList & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ProviderStatusList; + }; +}; + +/** + * Contains response data for the getStatusNext operation. + */ +export type ProvidersGetStatusNextResponse = ProviderStatusList & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ProviderStatusList; + }; +}; + +/** + * Contains response data for the sasUri operation. + */ +export type StorageSasUriResponse = SasUriResponse & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: SasUriResponse; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type QuotasListResponse = QuotaList & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: QuotaList; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type QuotasListNextResponse = QuotaList & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: QuotaList; + }; +}; + +/** + * Optional parameters. + */ +export interface QuantumClientOptionalParams + extends coreHttp.ServiceClientOptions { + /** + * server parameter + */ + $host?: string; + /** + * Overrides client endpoint. + */ + endpoint?: string; +} diff --git a/sdk/quantum/quantum-client/src/models/mappers.ts b/sdk/quantum/quantum-client/src/models/mappers.ts new file mode 100644 index 000000000000..e92c94c4dee0 --- /dev/null +++ b/sdk/quantum/quantum-client/src/models/mappers.ts @@ -0,0 +1,422 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; + +export const JobDetailsList: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "JobDetailsList", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "JobDetails" + } + } + } + }, + count: { + serializedName: "count", + type: { + name: "Number" + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const JobDetails: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "JobDetails", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + containerUri: { + serializedName: "containerUri", + required: true, + type: { + name: "String" + } + }, + inputDataUri: { + serializedName: "inputDataUri", + type: { + name: "String" + } + }, + inputDataFormat: { + serializedName: "inputDataFormat", + required: true, + type: { + name: "String" + } + }, + inputParams: { + serializedName: "inputParams", + type: { + name: "any" + } + }, + providerId: { + serializedName: "providerId", + required: true, + type: { + name: "String" + } + }, + target: { + serializedName: "target", + required: true, + type: { + name: "String" + } + }, + metadata: { + serializedName: "metadata", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + outputDataUri: { + serializedName: "outputDataUri", + type: { + name: "String" + } + }, + outputDataFormat: { + serializedName: "outputDataFormat", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + readOnly: true, + type: { + name: "String" + } + }, + creationTime: { + serializedName: "creationTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + beginExecutionTime: { + serializedName: "beginExecutionTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + endExecutionTime: { + serializedName: "endExecutionTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + cancellationTime: { + serializedName: "cancellationTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + errorData: { + serializedName: "errorData", + type: { + name: "Composite", + className: "ErrorData" + } + } + } + } +}; + +export const ErrorData: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorData", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const RestError: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "RestError", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorData" + } + } + } + } +}; + +export const ProviderStatusList: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ProviderStatusList", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ProviderStatus" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ProviderStatus: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "ProviderStatus", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + currentAvailability: { + serializedName: "currentAvailability", + readOnly: true, + type: { + name: "String" + } + }, + targets: { + serializedName: "targets", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TargetStatus" + } + } + } + } + } + } +}; + +export const TargetStatus: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "TargetStatus", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + currentAvailability: { + serializedName: "currentAvailability", + readOnly: true, + type: { + name: "String" + } + }, + averageQueueTime: { + serializedName: "averageQueueTime", + readOnly: true, + type: { + name: "Number" + } + }, + statusPage: { + serializedName: "statusPage", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const BlobDetails: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "BlobDetails", + modelProperties: { + containerName: { + serializedName: "containerName", + required: true, + type: { + name: "String" + } + }, + blobName: { + serializedName: "blobName", + type: { + name: "String" + } + } + } + } +}; + +export const SasUriResponse: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "SasUriResponse", + modelProperties: { + sasUri: { + serializedName: "sasUri", + type: { + name: "String" + } + } + } + } +}; + +export const QuotaList: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaList", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Quota" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Quota: coreHttp.CompositeMapper = { + type: { + name: "Composite", + className: "Quota", + modelProperties: { + dimension: { + serializedName: "dimension", + type: { + name: "String" + } + }, + scope: { + serializedName: "scope", + type: { + name: "String" + } + }, + providerId: { + serializedName: "providerId", + type: { + name: "String" + } + }, + utilization: { + serializedName: "utilization", + type: { + name: "Number" + } + }, + holds: { + serializedName: "holds", + type: { + name: "Number" + } + }, + limit: { + serializedName: "limit", + type: { + name: "Number" + } + }, + period: { + serializedName: "period", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/quantum/quantum-client/src/models/parameters.ts b/sdk/quantum/quantum-client/src/models/parameters.ts new file mode 100644 index 000000000000..8fb87af9e8d4 --- /dev/null +++ b/sdk/quantum/quantum-client/src/models/parameters.ts @@ -0,0 +1,127 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { OperationParameter, OperationURLParameter } from "@azure/core-http"; +import { + JobDetails as JobDetailsMapper, + BlobDetails as BlobDetailsMapper +} from "../models/mappers"; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const $host: OperationURLParameter = { + parameterPath: "$host", + mapper: { + serializedName: "$host", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + serializedName: "subscriptionId", + required: true, + type: { + name: "String" + } + } +}; + +export const resourceGroupName: OperationURLParameter = { + parameterPath: "resourceGroupName", + mapper: { + serializedName: "resourceGroupName", + required: true, + type: { + name: "String" + } + } +}; + +export const workspaceName: OperationURLParameter = { + parameterPath: "workspaceName", + mapper: { + serializedName: "workspaceName", + required: true, + type: { + name: "String" + } + } +}; + +export const jobId: OperationURLParameter = { + parameterPath: "jobId", + mapper: { + serializedName: "jobId", + required: true, + type: { + name: "String" + } + } +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const job: OperationParameter = { + parameterPath: "job", + mapper: JobDetailsMapper +}; + +export const accept1: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const blobDetails: OperationParameter = { + parameterPath: "blobDetails", + mapper: BlobDetailsMapper +}; diff --git a/sdk/quantum/quantum-client/src/operations/index.ts b/sdk/quantum/quantum-client/src/operations/index.ts new file mode 100644 index 000000000000..8b016cdcb134 --- /dev/null +++ b/sdk/quantum/quantum-client/src/operations/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./jobs"; +export * from "./providers"; +export * from "./storage"; +export * from "./quotas"; diff --git a/sdk/quantum/quantum-client/src/operations/jobs.ts b/sdk/quantum/quantum-client/src/operations/jobs.ts new file mode 100644 index 000000000000..bbb557c69104 --- /dev/null +++ b/sdk/quantum/quantum-client/src/operations/jobs.ts @@ -0,0 +1,231 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { QuantumClient } from "../quantumClient"; +import { + JobsListResponse, + JobsGetResponse, + JobDetails, + JobsCreateResponse, + JobsListNextResponse +} from "../models"; + +/** + * Class representing a Jobs. + */ +export class Jobs { + private readonly client: QuantumClient; + + /** + * Initialize a new instance of the class Jobs class. + * @param client Reference to the service client + */ + constructor(client: QuantumClient) { + this.client = client; + } + + /** + * List jobs. + * @param options The options parameters. + */ + list(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { options: operationOptions }, + listOperationSpec + ) as Promise; + } + + /** + * Get job by id + * @param jobId Id of the job. + * @param options The options parameters. + */ + get( + jobId: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { jobId, options: operationOptions }, + getOperationSpec + ) as Promise; + } + + /** + * Create a job. + * @param jobId Id of the job. + * @param job The complete metadata of the job to submit. + * @param options The options parameters. + */ + create( + jobId: string, + job: JobDetails, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { jobId, job, options: operationOptions }, + createOperationSpec + ) as Promise; + } + + /** + * Cancel a job. + * @param jobId Id of the job. + * @param options The options parameters. + */ + cancel( + jobId: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { jobId, options: operationOptions }, + cancelOperationSpec + ) as Promise; + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + listNext( + nextLink: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { nextLink, options: operationOptions }, + listNextOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.JobDetailsList + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const getOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.JobDetails + }, + default: { + bodyMapper: Mappers.RestError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName, + Parameters.jobId + ], + headerParameters: [Parameters.accept], + serializer +}; +const createOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.JobDetails + }, + 201: { + bodyMapper: Mappers.JobDetails + }, + default: { + bodyMapper: Mappers.RestError + } + }, + requestBody: Parameters.job, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName, + Parameters.jobId + ], + headerParameters: [Parameters.contentType, Parameters.accept1], + mediaType: "json", + serializer +}; +const cancelOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.RestError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName, + Parameters.jobId + ], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.JobDetailsList + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quantum/quantum-client/src/operations/providers.ts b/sdk/quantum/quantum-client/src/operations/providers.ts new file mode 100644 index 000000000000..b4f9ba6ab645 --- /dev/null +++ b/sdk/quantum/quantum-client/src/operations/providers.ts @@ -0,0 +1,111 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { QuantumClient } from "../quantumClient"; +import { + ProvidersGetStatusResponse, + ProvidersGetStatusNextResponse +} from "../models"; + +/** + * Class representing a Providers. + */ +export class Providers { + private readonly client: QuantumClient; + + /** + * Initialize a new instance of the class Providers class. + * @param client Reference to the service client + */ + constructor(client: QuantumClient) { + this.client = client; + } + + /** + * Get provider status. + * @param options The options parameters. + */ + getStatus( + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { options: operationOptions }, + getStatusOperationSpec + ) as Promise; + } + + /** + * GetStatusNext + * @param nextLink The nextLink from the previous successful call to the GetStatus method. + * @param options The options parameters. + */ + getStatusNext( + nextLink: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { nextLink, options: operationOptions }, + getStatusNextOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const getStatusOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/providerStatus", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ProviderStatusList + }, + default: { + bodyMapper: Mappers.RestError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const getStatusNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ProviderStatusList + }, + default: { + bodyMapper: Mappers.RestError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quantum/quantum-client/src/operations/quotas.ts b/sdk/quantum/quantum-client/src/operations/quotas.ts new file mode 100644 index 000000000000..d7ac34907f67 --- /dev/null +++ b/sdk/quantum/quantum-client/src/operations/quotas.ts @@ -0,0 +1,106 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { QuantumClient } from "../quantumClient"; +import { QuotasListResponse, QuotasListNextResponse } from "../models"; + +/** + * Class representing a Quotas. + */ +export class Quotas { + private readonly client: QuantumClient; + + /** + * Initialize a new instance of the class Quotas class. + * @param client Reference to the service client + */ + constructor(client: QuantumClient) { + this.client = client; + } + + /** + * List quotas for the given workspace. + * @param options The options parameters. + */ + list(options?: coreHttp.OperationOptions): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { options: operationOptions }, + listOperationSpec + ) as Promise; + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + listNext( + nextLink: string, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { nextLink, options: operationOptions }, + listNextOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/quotas", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaList + }, + default: { + bodyMapper: Mappers.RestError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreHttp.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaList + }, + default: { + bodyMapper: Mappers.RestError + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quantum/quantum-client/src/operations/storage.ts b/sdk/quantum/quantum-client/src/operations/storage.ts new file mode 100644 index 000000000000..7314594691da --- /dev/null +++ b/sdk/quantum/quantum-client/src/operations/storage.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { QuantumClient } from "../quantumClient"; +import { BlobDetails, StorageSasUriResponse } from "../models"; + +/** + * Class representing a Storage. + */ +export class Storage { + private readonly client: QuantumClient; + + /** + * Initialize a new instance of the class Storage class. + * @param client Reference to the service client + */ + constructor(client: QuantumClient) { + this.client = client; + } + + /** + * Gets a URL with SAS token for a container/blob in the storage account associated with the workspace. + * The SAS URL can be used to upload job input and/or download job output. + * @param blobDetails The details (name and container) of the blob to store or download data. + * @param options The options parameters. + */ + sasUri( + blobDetails: BlobDetails, + options?: coreHttp.OperationOptions + ): Promise { + const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase( + options || {} + ); + return this.client.sendOperationRequest( + { blobDetails, options: operationOptions }, + sasUriOperationSpec + ) as Promise; + } +} +// Operation Specifications + +const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false); + +const sasUriOperationSpec: coreHttp.OperationSpec = { + path: + "/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/storage/sasUri", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.SasUriResponse + }, + default: { + bodyMapper: Mappers.RestError + } + }, + requestBody: Parameters.blobDetails, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.workspaceName + ], + headerParameters: [Parameters.contentType, Parameters.accept1], + mediaType: "json", + serializer +}; diff --git a/sdk/quantum/quantum-client/src/quantumClient.ts b/sdk/quantum/quantum-client/src/quantumClient.ts new file mode 100644 index 000000000000..06d432028b0c --- /dev/null +++ b/sdk/quantum/quantum-client/src/quantumClient.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import { Jobs, Providers, Storage, Quotas } from "./operations"; +import { QuantumClientContext } from "./quantumClientContext"; +import { QuantumClientOptionalParams } from "./models"; + +export class QuantumClient extends QuantumClientContext { + /** + * Initializes a new instance of the QuantumClient class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param subscriptionId The Azure subscription ID. This is a GUID-formatted string (e.g. + * 00000000-0000-0000-0000-000000000000) + * @param resourceGroupName Name of an Azure resource group. + * @param workspaceName Name of the workspace. + * @param options The parameter options + */ + constructor( + credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, + subscriptionId: string, + resourceGroupName: string, + workspaceName: string, + options?: QuantumClientOptionalParams + ) { + super( + credentials, + subscriptionId, + resourceGroupName, + workspaceName, + options + ); + this.jobs = new Jobs(this); + this.providers = new Providers(this); + this.storage = new Storage(this); + this.quotas = new Quotas(this); + } + + jobs: Jobs; + providers: Providers; + storage: Storage; + quotas: Quotas; +} diff --git a/sdk/quantum/quantum-client/src/quantumClientContext.ts b/sdk/quantum/quantum-client/src/quantumClientContext.ts new file mode 100644 index 000000000000..0655d465e0b6 --- /dev/null +++ b/sdk/quantum/quantum-client/src/quantumClientContext.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import { QuantumClientOptionalParams } from "./models"; + +const packageName = "@azure/quantum-client"; +const packageVersion = "1.0.0"; + +export class QuantumClientContext extends coreHttp.ServiceClient { + $host: string; + subscriptionId: string; + resourceGroupName: string; + workspaceName: string; + + /** + * Initializes a new instance of the QuantumClientContext class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param subscriptionId The Azure subscription ID. This is a GUID-formatted string (e.g. + * 00000000-0000-0000-0000-000000000000) + * @param resourceGroupName Name of an Azure resource group. + * @param workspaceName Name of the workspace. + * @param options The parameter options + */ + constructor( + credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, + subscriptionId: string, + resourceGroupName: string, + workspaceName: string, + options?: QuantumClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); + } + if (resourceGroupName === undefined) { + throw new Error("'resourceGroupName' cannot be null"); + } + if (workspaceName === undefined) { + throw new Error("'workspaceName' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = coreHttp.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.requestContentType = "application/json; charset=utf-8"; + + this.baseUri = options.endpoint || "https://quantum.azure.com"; + + // Parameter assignments + this.subscriptionId = subscriptionId; + this.resourceGroupName = resourceGroupName; + this.workspaceName = workspaceName; + + // Assigning values to Constant parameters + this.$host = options.$host || "https://quantum.azure.com"; + } +} diff --git a/sdk/quantum/quantum-client/tsconfig.json b/sdk/quantum/quantum-client/tsconfig.json new file mode 100644 index 000000000000..422b584abd5e --- /dev/null +++ b/sdk/quantum/quantum-client/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", "dom"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./src/**/*.ts"], + "exclude": ["node_modules"] +}