UNPKG

@azure/digital-twins-core

Version:
232 lines 8.39 kB
"use strict"; /* * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.EventRoutesImpl = void 0; const tslib_1 = require("tslib"); const pagingHelper_js_1 = require("../pagingHelper.js"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const Mappers = tslib_1.__importStar(require("../models/mappers.js")); const Parameters = tslib_1.__importStar(require("../models/parameters.js")); /// <reference lib="esnext.asynciterable" /> /** Class containing EventRoutes operations. */ class EventRoutesImpl { /** * Initialize a new instance of the class EventRoutes class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Retrieves all event routes. * Status codes: * * 200 OK * @param options The options parameters. */ list(options) { const iter = this.listPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listPagingPage(options, settings); }, }; } listPagingPage(options, settings) { return tslib_1.__asyncGenerator(this, arguments, function* listPagingPage_1() { let result; let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken; if (!continuationToken) { result = yield tslib_1.__await(this._list(options)); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield yield tslib_1.__await(page); } while (continuationToken) { result = yield tslib_1.__await(this._listNext(continuationToken, options)); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield yield tslib_1.__await(page); } }); } listPagingAll(options) { return tslib_1.__asyncGenerator(this, arguments, function* listPagingAll_1() { var _a, e_1, _b, _c; try { for (var _d = true, _e = tslib_1.__asyncValues(this.listPagingPage(options)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const page = _c; yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e)); } finally { if (e_1) throw e_1.error; } } }); } /** * Retrieves all event routes. * Status codes: * * 200 OK * @param options The options parameters. */ _list(options) { return this.client.sendOperationRequest({ options }, listOperationSpec); } /** * Retrieves an event route. * Status codes: * * 200 OK * * 404 Not Found * * EventRouteNotFound - The event route was not found. * @param id The id for an event route. The id is unique within event routes and case sensitive. * @param options The options parameters. */ getById(id, options) { return this.client.sendOperationRequest({ id, options }, getByIdOperationSpec); } /** * Adds or replaces an event route. * Status codes: * * 204 No Content * * 400 Bad Request * * EventRouteEndpointInvalid - The endpoint provided does not exist or is not active. * * EventRouteFilterInvalid - The event route filter is invalid. * * EventRouteIdInvalid - The event route id is invalid. * * LimitExceeded - The maximum number of event routes allowed has been reached. * @param id The id for an event route. The id is unique within event routes and case sensitive. * @param eventRoute The event route data * @param options The options parameters. */ add(id, eventRoute, options) { return this.client.sendOperationRequest({ id, eventRoute, options }, addOperationSpec); } /** * Deletes an event route. * Status codes: * * 204 No Content * * 404 Not Found * * EventRouteNotFound - The event route was not found. * @param id The id for an event route. The id is unique within event routes and case sensitive. * @param options The options parameters. */ delete(id, options) { return this.client.sendOperationRequest({ id, options }, deleteOperationSpec); } /** * ListNext * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ _listNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec); } } exports.EventRoutesImpl = EventRoutesImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listOperationSpec = { path: "/eventroutes", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.EventRouteCollection, }, default: { bodyMapper: Mappers.ErrorResponse, headersMapper: Mappers.EventRoutesListExceptionHeaders, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept, Parameters.resultsPerPage], serializer, }; const getByIdOperationSpec = { path: "/eventroutes/{id}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.EventRoute, }, default: { bodyMapper: Mappers.ErrorResponse, headersMapper: Mappers.EventRoutesGetByIdExceptionHeaders, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.id], headerParameters: [Parameters.accept], serializer, }; const addOperationSpec = { path: "/eventroutes/{id}", httpMethod: "PUT", responses: { 204: {}, default: { bodyMapper: Mappers.ErrorResponse, headersMapper: Mappers.EventRoutesAddExceptionHeaders, }, }, requestBody: Parameters.eventRoute, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.id], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/eventroutes/{id}", httpMethod: "DELETE", responses: { 204: {}, default: { bodyMapper: Mappers.ErrorResponse, headersMapper: Mappers.EventRoutesDeleteExceptionHeaders, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.id], headerParameters: [Parameters.accept], serializer, }; const listNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.EventRouteCollection, }, default: { bodyMapper: Mappers.ErrorResponse, headersMapper: Mappers.EventRoutesListNextExceptionHeaders, }, }, urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept, Parameters.resultsPerPage], serializer, }; //# sourceMappingURL=eventRoutes.js.map