@azure/quantum-jobs
Version:
An isomorphic client library for Azure Quantum
182 lines • 6.97 kB
JavaScript
/*
* 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 { __asyncDelegator, __asyncGenerator, __asyncValues, __await, __generator, __values } from "tslib";
import * as coreHttp from "@azure/core-http";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
/** Class representing a Providers. */
var Providers = /** @class */ (function () {
/**
* Initialize a new instance of the class Providers class.
* @param client Reference to the service client
*/
function Providers(client) {
this.client = client;
}
/**
* Get provider status.
* @param options The options parameters.
*/
Providers.prototype.listStatus = function (options) {
var _a;
var _this = this;
var iter = this.getStatusPagingAll(options);
return _a = {
next: function () {
return iter.next();
}
},
_a[Symbol.asyncIterator] = function () {
return this;
},
_a.byPage = function () {
return _this.getStatusPagingPage(options);
},
_a;
};
Providers.prototype.getStatusPagingPage = function (options) {
return __asyncGenerator(this, arguments, function getStatusPagingPage_1() {
var result, continuationToken;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, __await(this._getStatus(options))];
case 1:
result = _a.sent();
return [4 /*yield*/, __await(result.value || [])];
case 2: return [4 /*yield*/, _a.sent()];
case 3:
_a.sent();
continuationToken = result.nextLink;
_a.label = 4;
case 4:
if (!continuationToken) return [3 /*break*/, 8];
return [4 /*yield*/, __await(this._getStatusNext(continuationToken, options))];
case 5:
result = _a.sent();
continuationToken = result.nextLink;
return [4 /*yield*/, __await(result.value || [])];
case 6: return [4 /*yield*/, _a.sent()];
case 7:
_a.sent();
return [3 /*break*/, 4];
case 8: return [2 /*return*/];
}
});
});
};
Providers.prototype.getStatusPagingAll = function (options) {
return __asyncGenerator(this, arguments, function getStatusPagingAll_1() {
var _a, _b, page, e_1_1;
var e_1, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_d.trys.push([0, 7, 8, 13]);
_a = __asyncValues(this.getStatusPagingPage(options));
_d.label = 1;
case 1: return [4 /*yield*/, __await(_a.next())];
case 2:
if (!(_b = _d.sent(), !_b.done)) return [3 /*break*/, 6];
page = _b.value;
return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(page)))];
case 3: return [4 /*yield*/, __await.apply(void 0, [_d.sent()])];
case 4:
_d.sent();
_d.label = 5;
case 5: return [3 /*break*/, 1];
case 6: return [3 /*break*/, 13];
case 7:
e_1_1 = _d.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 13];
case 8:
_d.trys.push([8, , 11, 12]);
if (!(_b && !_b.done && (_c = _a.return))) return [3 /*break*/, 10];
return [4 /*yield*/, __await(_c.call(_a))];
case 9:
_d.sent();
_d.label = 10;
case 10: return [3 /*break*/, 12];
case 11:
if (e_1) throw e_1.error;
return [7 /*endfinally*/];
case 12: return [7 /*endfinally*/];
case 13: return [2 /*return*/];
}
});
});
};
/**
* Get provider status.
* @param options The options parameters.
*/
Providers.prototype._getStatus = function (options) {
var operationArguments = {
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(operationArguments, getStatusOperationSpec);
};
/**
* GetStatusNext
* @param nextLink The nextLink from the previous successful call to the GetStatus method.
* @param options The options parameters.
*/
Providers.prototype._getStatusNext = function (nextLink, options) {
var operationArguments = {
nextLink: nextLink,
options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
};
return this.client.sendOperationRequest(operationArguments, getStatusNextOperationSpec);
};
return Providers;
}());
export { Providers };
// Operation Specifications
var serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);
var getStatusOperationSpec = {
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: serializer
};
var getStatusNextOperationSpec = {
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: serializer
};
//# sourceMappingURL=providers.js.map