UNPKG

@azure/digital-twins-core

Version:
74 lines 3.35 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.AzureDigitalTwinsAPI = void 0; const tslib_1 = require("tslib"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const index_js_1 = require("./operations/index.js"); class AzureDigitalTwinsAPI extends coreClient.ServiceClient { /** * Initializes a new instance of the AzureDigitalTwinsAPI class. * @param options The parameter options */ constructor(options) { var _a, _b; // Initializing default values for options if (!options) { options = {}; } const defaults = { requestContentType: "application/json; charset=utf-8", }; const packageDetails = `azsdk-js-digital-twins-core/2.0.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: { userAgentPrefix, }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://digitaltwins-hostname" }); super(optionsWithDefaults); // Assigning values to Constant parameters this.$host = options.$host || "https://digitaltwins-hostname"; this.apiVersion = options.apiVersion || "2023-10-31"; this.digitalTwinModels = new index_js_1.DigitalTwinModelsImpl(this); this.query = new index_js_1.QueryImpl(this); this.digitalTwins = new index_js_1.DigitalTwinsImpl(this); this.eventRoutes = new index_js_1.EventRoutesImpl(this); this.importJobs = new index_js_1.ImportJobsImpl(this); this.deleteJobs = new index_js_1.DeleteJobsImpl(this); this.addCustomApiVersionPolicy(options.apiVersion); } /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ addCustomApiVersionPolicy(apiVersion) { if (!apiVersion) { return; } const apiVersionPolicy = { name: "CustomApiVersionPolicy", async sendRequest(request, next) { const param = request.url.split("?"); if (param.length > 1) { const newParams = param[1].split("&").map((item) => { if (item.indexOf("api-version") > -1) { return "api-version=" + apiVersion; } else { return item; } }); request.url = param[0] + "?" + newParams.join("&"); } return next(request); }, }; this.pipeline.addPolicy(apiVersionPolicy); } } exports.AzureDigitalTwinsAPI = AzureDigitalTwinsAPI; //# sourceMappingURL=azureDigitalTwinsAPI.js.map