From 521f9905677366d9dcb661fa6a67c4e0f10ce2dd Mon Sep 17 00:00:00 2001 From: Ruoxuan Wang <52271048+ruowan@users.noreply.github.com> Date: Thu, 26 Sep 2019 16:50:22 +0800 Subject: [PATCH 1/2] release azure peering service 2019-08-01 (#5259) --- packages.md | 1 + sdk/peering/arm-peering/LICENSE.txt | 21 + sdk/peering/arm-peering/README.md | 103 ++ sdk/peering/arm-peering/package.json | 58 + sdk/peering/arm-peering/rollup.config.js | 37 + sdk/peering/arm-peering/src/models/index.ts | 1561 +++++++++++++++++ .../src/models/legacyPeeringsMappers.ts | 34 + sdk/peering/arm-peering/src/models/mappers.ts | 1189 +++++++++++++ .../src/models/operationsMappers.ts | 14 + .../arm-peering/src/models/parameters.ts | 135 ++ .../arm-peering/src/models/peerAsnsMappers.ts | 34 + .../src/models/peeringLocationsMappers.ts | 34 + .../models/peeringServiceLocationsMappers.ts | 34 + .../models/peeringServicePrefixesMappers.ts | 33 + .../models/peeringServiceProvidersMappers.ts | 34 + .../src/models/peeringServicesMappers.ts | 35 + .../arm-peering/src/models/peeringsMappers.ts | 35 + .../arm-peering/src/models/prefixesMappers.ts | 34 + .../arm-peering/src/operations/index.ts | 20 + .../src/operations/legacyPeerings.ts | 138 ++ .../arm-peering/src/operations/operations.ts | 123 ++ .../arm-peering/src/operations/peerAsns.ts | 296 ++++ .../src/operations/peeringLocations.ts | 132 ++ .../src/operations/peeringServiceLocations.ts | 126 ++ .../src/operations/peeringServicePrefixes.ts | 229 +++ .../src/operations/peeringServiceProviders.ts | 126 ++ .../src/operations/peeringServices.ts | 484 +++++ .../arm-peering/src/operations/peerings.ts | 484 +++++ .../arm-peering/src/operations/prefixes.ts | 136 ++ .../src/peeringManagementClient.ts | 129 ++ .../src/peeringManagementClientContext.ts | 62 + sdk/peering/arm-peering/tsconfig.json | 19 + 32 files changed, 5930 insertions(+) create mode 100644 sdk/peering/arm-peering/LICENSE.txt create mode 100644 sdk/peering/arm-peering/README.md create mode 100644 sdk/peering/arm-peering/package.json create mode 100644 sdk/peering/arm-peering/rollup.config.js create mode 100644 sdk/peering/arm-peering/src/models/index.ts create mode 100644 sdk/peering/arm-peering/src/models/legacyPeeringsMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/mappers.ts create mode 100644 sdk/peering/arm-peering/src/models/operationsMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/parameters.ts create mode 100644 sdk/peering/arm-peering/src/models/peerAsnsMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/peeringLocationsMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/peeringServiceLocationsMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/peeringServicePrefixesMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/peeringServiceProvidersMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/peeringServicesMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/peeringsMappers.ts create mode 100644 sdk/peering/arm-peering/src/models/prefixesMappers.ts create mode 100644 sdk/peering/arm-peering/src/operations/index.ts create mode 100644 sdk/peering/arm-peering/src/operations/legacyPeerings.ts create mode 100644 sdk/peering/arm-peering/src/operations/operations.ts create mode 100644 sdk/peering/arm-peering/src/operations/peerAsns.ts create mode 100644 sdk/peering/arm-peering/src/operations/peeringLocations.ts create mode 100644 sdk/peering/arm-peering/src/operations/peeringServiceLocations.ts create mode 100644 sdk/peering/arm-peering/src/operations/peeringServicePrefixes.ts create mode 100644 sdk/peering/arm-peering/src/operations/peeringServiceProviders.ts create mode 100644 sdk/peering/arm-peering/src/operations/peeringServices.ts create mode 100644 sdk/peering/arm-peering/src/operations/peerings.ts create mode 100644 sdk/peering/arm-peering/src/operations/prefixes.ts create mode 100644 sdk/peering/arm-peering/src/peeringManagementClient.ts create mode 100644 sdk/peering/arm-peering/src/peeringManagementClientContext.ts create mode 100644 sdk/peering/arm-peering/tsconfig.json diff --git a/packages.md b/packages.md index 4d58220896c9..f2f6876148e6 100644 --- a/packages.md +++ b/packages.md @@ -124,6 +124,7 @@ | [`@azure/arm-visualstudio`]( sdk/visualstudio/arm-visualstudio/package.json )| [Readme](sdk/visualstudio/arm-visualstudio/README.md) | N/A | N/A | | [`@azure/arm-webservices`]( sdk/machinelearning/arm-webservices/package.json )| [Readme](sdk/machinelearning/arm-webservices/README.md) | N/A | N/A | | [`@azure/arm-workspaces`]( sdk/machinelearning/arm-workspaces/package.json )| [Readme](sdk/machinelearning/arm-workspaces/README.md) | N/A | N/A | +| [`@azure/arm-peering`]( sdk/peering/arm-peering/package.json )| [Readme](sdk/peering/arm-peering/README.md) | N/A | N/A | | [`@azure/batch`]( sdk/batch/batch/package.json )| [Readme](sdk/batch/batch/README.md) | N/A | N/A | | [`@azure/cognitiveservices-anomalydetector`]( sdk/cognitiveservices/cognitiveservices-anomalydetector/package.json )| [Readme](sdk/cognitiveservices/cognitiveservices-anomalydetector/README.md) | N/A | N/A | | [`@azure/cognitiveservices-autosuggest`]( sdk/cognitiveservices/cognitiveservices-autosuggest/package.json )| [Readme](sdk/cognitiveservices/cognitiveservices-autosuggest/README.md) | N/A | N/A | diff --git a/sdk/peering/arm-peering/LICENSE.txt b/sdk/peering/arm-peering/LICENSE.txt new file mode 100644 index 000000000000..b73b4a1293c3 --- /dev/null +++ b/sdk/peering/arm-peering/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/peering/arm-peering/README.md b/sdk/peering/arm-peering/README.md new file mode 100644 index 000000000000..9359df25c682 --- /dev/null +++ b/sdk/peering/arm-peering/README.md @@ -0,0 +1,103 @@ +## Azure PeeringManagementClient SDK for JavaScript + +This package contains an isomorphic SDK for PeeringManagementClient. + +### Currently supported environments + +- Node.js version 6.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/arm-peering +``` + +### How to use + +#### nodejs - Authentication, client creation and list legacyPeerings as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. +```bash +npm install @azure/ms-rest-nodeauth@"^3.0.0" +``` + +##### 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 { PeeringManagementClient, PeeringManagementModels, PeeringManagementMappers } from "@azure/arm-peering"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new PeeringManagementClient(creds, subscriptionId); + const peeringLocation = "testpeeringLocation"; + const kind = "Direct"; + client.legacyPeerings.list(peeringLocation, kind).then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); +``` + +#### browser - Authentication, client creation and list legacyPeerings 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-peering sample + + + + + + + + +``` + +## 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/sdk/peering/arm-peering/README.png) diff --git a/sdk/peering/arm-peering/package.json b/sdk/peering/arm-peering/package.json new file mode 100644 index 000000000000..d0ceacd60a82 --- /dev/null +++ b/sdk/peering/arm-peering/package.json @@ -0,0 +1,58 @@ +{ + "name": "@azure/arm-peering", + "author": "Microsoft Corporation", + "description": "PeeringManagementClient Library with typescript type definitions for node.js and browser.", + "version": "1.0.0", + "dependencies": { + "@azure/ms-rest-azure-js": "^2.0.1", + "@azure/ms-rest-js": "^2.0.4", + "tslib": "^1.10.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/arm-peering.js", + "module": "./esm/peeringManagementClient.js", + "types": "./esm/peeringManagementClient.d.ts", + "devDependencies": { + "typescript": "^3.5.3", + "rollup": "^1.18.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.6.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/peering/arm-peering", + "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", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/arm-peering.js.map'\" -o ./dist/arm-peering.min.js ./dist/arm-peering.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false, + "autoPublish": true +} diff --git a/sdk/peering/arm-peering/rollup.config.js b/sdk/peering/arm-peering/rollup.config.js new file mode 100644 index 000000000000..6115b0630086 --- /dev/null +++ b/sdk/peering/arm-peering/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/peeringManagementClient.js", + external: [ + "@azure/ms-rest-js", + "@azure/ms-rest-azure-js" + ], + output: { + file: "./dist/arm-peering.js", + format: "umd", + name: "Azure.ArmPeering", + 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({ mainFields: ['module', 'main'] }), + sourcemaps() + ] +}; + +export default config; diff --git a/sdk/peering/arm-peering/src/models/index.ts b/sdk/peering/arm-peering/src/models/index.ts new file mode 100644 index 000000000000..fd1be10962e1 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/index.ts @@ -0,0 +1,1561 @@ +/* + * 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 }; + +/** + * Class for CheckServiceProviderAvailabilityInput + */ +export interface CheckServiceProviderAvailabilityInput { + /** + * Gets or sets the PeeringServiceLocation + */ + peeringServiceLocation?: string; + /** + * Gets or sets the PeeringServiceProvider + */ + peeringServiceProvider?: string; +} + +/** + * The SKU that defines the tier and kind of the peering. + */ +export interface PeeringSku { + /** + * The name of the peering SKU. Possible values include: 'Basic_Exchange_Free', + * 'Basic_Direct_Free', 'Premium_Direct_Free', 'Premium_Exchange_Metered', + * 'Premium_Direct_Metered', 'Premium_Direct_Unlimited' + */ + name?: Name; + /** + * The tier of the peering SKU. Possible values include: 'Basic', 'Premium' + */ + tier?: Tier; + /** + * The family of the peering SKU. Possible values include: 'Direct', 'Exchange' + */ + family?: Family; + /** + * The size of the peering SKU. Possible values include: 'Free', 'Metered', 'Unlimited' + */ + size?: Size; +} + +/** + * The properties that define a BGP session. + */ +export interface BgpSession { + /** + * The IPv4 prefix that contains both ends' IPv4 addresses. + */ + sessionPrefixV4?: string; + /** + * The IPv6 prefix that contains both ends' IPv6 addresses. + */ + sessionPrefixV6?: string; + /** + * The IPv4 session address on Microsoft's end. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly microsoftSessionIPv4Address?: string; + /** + * The IPv6 session address on Microsoft's end. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly microsoftSessionIPv6Address?: string; + /** + * The IPv4 session address on peer's end. + */ + peerSessionIPv4Address?: string; + /** + * The IPv6 session address on peer's end. + */ + peerSessionIPv6Address?: string; + /** + * The state of the IPv4 session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'OpenReceived', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly sessionStateV4?: SessionStateV4; + /** + * The state of the IPv6 session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'OpenReceived', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly sessionStateV6?: SessionStateV6; + /** + * The maximum number of prefixes advertised over the IPv4 session. + */ + maxPrefixesAdvertisedV4?: number; + /** + * The maximum number of prefixes advertised over the IPv6 session. + */ + maxPrefixesAdvertisedV6?: number; + /** + * The MD5 authentication key of the session. + */ + md5AuthenticationKey?: string; +} + +/** + * The properties that define a direct connection. + */ +export interface DirectConnection { + /** + * The bandwidth of the connection. + */ + bandwidthInMbps?: number; + /** + * The bandwidth that is actually provisioned. + */ + provisionedBandwidthInMbps?: number; + /** + * The field indicating if Microsoft provides session ip addresses. Possible values include: + * 'Microsoft', 'Peer' + */ + sessionAddressProvider?: SessionAddressProvider; + /** + * The flag that indicates whether or not the connection is used for peering service. + */ + useForPeeringService?: boolean; + /** + * The PeeringDB.com ID of the facility at which the connection has to be set up. + */ + peeringDBFacilityId?: number; + /** + * The state of the connection. Possible values include: 'None', 'PendingApproval', 'Approved', + * 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly connectionState?: ConnectionState; + /** + * The BGP session associated with the connection. + */ + bgpSession?: BgpSession; + /** + * The unique identifier (GUID) for the connection. + */ + connectionIdentifier?: string; +} + +/** + * The sub resource. + */ +export interface SubResource { + /** + * The identifier of the referenced resource. + */ + id?: string; +} + +/** + * The properties that define a direct peering. + */ +export interface PeeringPropertiesDirect { + /** + * The set of connections that constitute a direct peering. + */ + connections?: DirectConnection[]; + /** + * The flag that indicates whether or not the peering is used for peering service. + */ + useForPeeringService?: boolean; + /** + * The reference of the peer ASN. + */ + peerAsn?: SubResource; + /** + * The type of direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + */ + directPeeringType?: DirectPeeringType; +} + +/** + * The properties that define an exchange connection. + */ +export interface ExchangeConnection { + /** + * The PeeringDB.com ID of the facility at which the connection has to be set up. + */ + peeringDBFacilityId?: number; + /** + * The state of the connection. Possible values include: 'None', 'PendingApproval', 'Approved', + * 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly connectionState?: ConnectionState; + /** + * The BGP session associated with the connection. + */ + bgpSession?: BgpSession; + /** + * The unique identifier (GUID) for the connection. + */ + connectionIdentifier?: string; +} + +/** + * The properties that define an exchange peering. + */ +export interface PeeringPropertiesExchange { + /** + * The set of connections that constitute an exchange peering. + */ + connections?: ExchangeConnection[]; + /** + * The reference of the peer ASN. + */ + peerAsn?: SubResource; +} + +/** + * The ARM resource class. + */ +export interface Resource extends BaseResource { + /** + * The name of the resource. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly name?: string; + /** + * The ID of the resource. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly id?: string; + /** + * The type of the resource. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly type?: string; +} + +/** + * Peering is a logical representation of a set of connections to the Microsoft Cloud Edge at a + * location. + */ +export interface Peering extends Resource { + /** + * The SKU that defines the tier and kind of the peering. + */ + sku: PeeringSku; + /** + * The kind of the peering. Possible values include: 'Direct', 'Exchange' + */ + kind: Kind; + /** + * The properties that define a direct peering. + */ + direct?: PeeringPropertiesDirect; + /** + * The properties that define an exchange peering. + */ + exchange?: PeeringPropertiesExchange; + /** + * The location of the peering. + */ + peeringLocation?: string; + /** + * The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', + * 'Deleting', 'Failed' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly provisioningState?: ProvisioningState; + /** + * The location of the resource. + */ + location: string; + /** + * The resource tags. + */ + tags?: { [propertyName: string]: string }; +} + +/** + * The information related to the operation. + */ +export interface OperationDisplayInfo { + /** + * The name of the resource provider. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly provider?: string; + /** + * The type of the resource. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly resource?: string; + /** + * The name of the operation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly operation?: string; + /** + * The description of the operation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly description?: string; +} + +/** + * The peering API operation. + */ +export interface Operation { + /** + * The name of the operation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly name?: string; + /** + * The information related to the operation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly display?: OperationDisplayInfo; + /** + * The flag that indicates whether the operation applies to data plane. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly isDataAction?: boolean; +} + +/** + * The contact information of the peer. + */ +export interface ContactInfo { + /** + * The list of email addresses. + */ + emails?: string[]; + /** + * The list of contact numbers. + */ + phone?: string[]; +} + +/** + * The essential information related to the peer's ASN. + */ +export interface PeerAsn extends Resource { + /** + * The Autonomous System Number (ASN) of the peer. + */ + peerAsn?: number; + /** + * The contact information of the peer. + */ + peerContactInfo?: ContactInfo; + /** + * The name of the peer. + */ + peerName?: string; + /** + * The validation state of the ASN associated with the peer. Possible values include: 'None', + * 'Pending', 'Approved', 'Failed' + */ + validationState?: ValidationState; +} + +/** + * The properties that define a direct peering facility. + */ +export interface DirectPeeringFacility { + /** + * The address of the direct peering facility. + */ + address?: string; + /** + * The type of the direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + */ + directPeeringType?: DirectPeeringType; + /** + * The PeeringDB.com ID of the facility. + */ + peeringDBFacilityId?: number; + /** + * The PeeringDB.com URL of the facility. + */ + peeringDBFacilityLink?: string; +} + +/** + * The properties that define a peering bandwidth offer. + */ +export interface PeeringBandwidthOffer { + /** + * The name of the bandwidth offer. + */ + offerName?: string; + /** + * The value of the bandwidth offer in Mbps. + */ + valueInMbps?: number; +} + +/** + * The properties that define a direct peering location. + */ +export interface PeeringLocationPropertiesDirect { + /** + * The list of direct peering facilities at the peering location. + */ + peeringFacilities?: DirectPeeringFacility[]; + /** + * The list of bandwidth offers available at the peering location. + */ + bandwidthOffers?: PeeringBandwidthOffer[]; +} + +/** + * The properties that define an exchange peering facility. + */ +export interface ExchangePeeringFacility { + /** + * The name of the exchange peering facility. + */ + exchangeName?: string; + /** + * The bandwidth of the connection between Microsoft and the exchange peering facility. + */ + bandwidthInMbps?: number; + /** + * The IPv4 address of Microsoft at the exchange peering facility. + */ + microsoftIPv4Address?: string; + /** + * The IPv6 address of Microsoft at the exchange peering facility. + */ + microsoftIPv6Address?: string; + /** + * The IPv4 prefixes associated with the exchange peering facility. + */ + facilityIPv4Prefix?: string; + /** + * The IPv6 prefixes associated with the exchange peering facility. + */ + facilityIPv6Prefix?: string; + /** + * The PeeringDB.com ID of the facility. + */ + peeringDBFacilityId?: number; + /** + * The PeeringDB.com URL of the facility. + */ + peeringDBFacilityLink?: string; +} + +/** + * The properties that define an exchange peering location. + */ +export interface PeeringLocationPropertiesExchange { + /** + * The list of exchange peering facilities at the peering location. + */ + peeringFacilities?: ExchangePeeringFacility[]; +} + +/** + * Peering location is where connectivity could be established to the Microsoft Cloud Edge. + */ +export interface PeeringLocation extends Resource { + /** + * The kind of peering that the peering location supports. Possible values include: 'Direct', + * 'Exchange' + */ + kind?: Kind; + /** + * The properties that define a direct peering location. + */ + direct?: PeeringLocationPropertiesDirect; + /** + * The properties that define an exchange peering location. + */ + exchange?: PeeringLocationPropertiesExchange; + /** + * The name of the peering location. + */ + peeringLocation?: string; + /** + * The country in which the peering location exists. + */ + country?: string; + /** + * The Azure region associated with the peering location. + */ + azureRegion?: string; +} + +/** + * The resource tags. + */ +export interface ResourceTags { + /** + * Gets or sets the tags, a dictionary of descriptors arm object + */ + tags?: { [propertyName: string]: string }; +} + +/** + * PeeringService location + */ +export interface PeeringServiceLocation extends Resource { + /** + * Country of the customer + */ + country?: string; + /** + * State of the customer + */ + state?: string; + /** + * Azure region for the location + */ + azureRegion?: string; +} + +/** + * The peering service prefix class. + */ +export interface PeeringServicePrefix extends Resource { + /** + * Valid route prefix + */ + prefix?: string; + /** + * The prefix validation state. Possible values include: 'None', 'Invalid', 'Verified', 'Failed', + * 'Pending', 'Unknown' + */ + prefixValidationState?: PrefixValidationState; + /** + * The prefix learned type. Possible values include: 'None', 'ViaPartner', 'ViaSession' + */ + learnedType?: LearnedType; + /** + * The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', + * 'Deleting', 'Failed' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly provisioningState?: ProvisioningState; +} + +/** + * PeeringService provider + */ +export interface PeeringServiceProvider extends Resource { + /** + * The name of the service provider. + */ + serviceProviderName?: string; +} + +/** + * Peering Service + */ +export interface PeeringService extends Resource { + /** + * The PeeringServiceLocation of the Customer. + */ + peeringServiceLocation?: string; + /** + * The MAPS Provider Name. + */ + peeringServiceProvider?: string; + /** + * The provisioning state of the resource. Possible values include: 'Succeeded', 'Updating', + * 'Deleting', 'Failed' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly provisioningState?: ProvisioningState; + /** + * The location of the resource. + */ + location: string; + /** + * The resource tags. + */ + tags?: { [propertyName: string]: string }; +} + +/** + * The error response that indicates why an operation has failed. + */ +export interface ErrorResponse { + /** + * The error code. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly code?: string; + /** + * The error message. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly message?: string; +} + +/** + * Optional Parameters. + */ +export interface PeeringManagementClientCheckServiceProviderAvailabilityOptionalParams extends msRest.RequestOptionsBase { + /** + * Gets or sets the PeeringServiceLocation + */ + peeringServiceLocation?: string; + /** + * Gets or sets the PeeringServiceProvider + */ + peeringServiceProvider?: string; +} + +/** + * Optional Parameters. + */ +export interface PeeringLocationsListOptionalParams extends msRest.RequestOptionsBase { + /** + * The type of direct peering. Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + */ + directPeeringType?: DirectPeeringType1; +} + +/** + * Optional Parameters. + */ +export interface PeeringsUpdateOptionalParams extends msRest.RequestOptionsBase { + /** + * Gets or sets the tags, a dictionary of descriptors arm object + */ + tags?: { [propertyName: string]: string }; +} + +/** + * Optional Parameters. + */ +export interface PeeringServicesUpdateOptionalParams extends msRest.RequestOptionsBase { + /** + * Gets or sets the tags, a dictionary of descriptors arm object + */ + tags?: { [propertyName: string]: string }; +} + +/** + * An interface representing PeeringManagementClientOptions. + */ +export interface PeeringManagementClientOptions extends AzureServiceClientOptions { + baseUri?: string; +} + +/** + * @interface + * The paginated list of peerings. + * @extends Array + */ +export interface PeeringListResult extends Array { + /** + * The link to fetch the next page of peerings. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of peering API operations. + * @extends Array + */ +export interface OperationListResult extends Array { + /** + * The link to fetch the next page of peering API operations. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of peer ASNs. + * @extends Array + */ +export interface PeerAsnListResult extends Array { + /** + * The link to fetch the next page of peer ASNs. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of peering locations. + * @extends Array + */ +export interface PeeringLocationListResult extends Array { + /** + * The link to fetch the next page of peering locations. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of peering service locations. + * @extends Array + */ +export interface PeeringServiceLocationListResult extends Array { + /** + * The link to fetch the next page of peering service locations. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of [T]. + * @extends Array + */ +export interface PeeringServicePrefixListResult extends Array { + /** + * The link to fetch the next page of [T]. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of peering service providers. + * @extends Array + */ +export interface PeeringServiceProviderListResult extends Array { + /** + * The link to fetch the next page of peering service providers. + */ + nextLink?: string; +} + +/** + * @interface + * The paginated list of peering services. + * @extends Array + */ +export interface PeeringServiceListResult extends Array { + /** + * The link to fetch the next page of peering services. + */ + nextLink?: string; +} + +/** + * Defines values for Name. + * Possible values include: 'Basic_Exchange_Free', 'Basic_Direct_Free', 'Premium_Direct_Free', + * 'Premium_Exchange_Metered', 'Premium_Direct_Metered', 'Premium_Direct_Unlimited' + * @readonly + * @enum {string} + */ +export type Name = 'Basic_Exchange_Free' | 'Basic_Direct_Free' | 'Premium_Direct_Free' | 'Premium_Exchange_Metered' | 'Premium_Direct_Metered' | 'Premium_Direct_Unlimited'; + +/** + * Defines values for Tier. + * Possible values include: 'Basic', 'Premium' + * @readonly + * @enum {string} + */ +export type Tier = 'Basic' | 'Premium'; + +/** + * Defines values for Family. + * Possible values include: 'Direct', 'Exchange' + * @readonly + * @enum {string} + */ +export type Family = 'Direct' | 'Exchange'; + +/** + * Defines values for Size. + * Possible values include: 'Free', 'Metered', 'Unlimited' + * @readonly + * @enum {string} + */ +export type Size = 'Free' | 'Metered' | 'Unlimited'; + +/** + * Defines values for Kind. + * Possible values include: 'Direct', 'Exchange' + * @readonly + * @enum {string} + */ +export type Kind = 'Direct' | 'Exchange'; + +/** + * Defines values for SessionAddressProvider. + * Possible values include: 'Microsoft', 'Peer' + * @readonly + * @enum {string} + */ +export type SessionAddressProvider = 'Microsoft' | 'Peer'; + +/** + * Defines values for ConnectionState. + * Possible values include: 'None', 'PendingApproval', 'Approved', 'ProvisioningStarted', + * 'ProvisioningFailed', 'ProvisioningCompleted', 'Validating', 'Active' + * @readonly + * @enum {string} + */ +export type ConnectionState = 'None' | 'PendingApproval' | 'Approved' | 'ProvisioningStarted' | 'ProvisioningFailed' | 'ProvisioningCompleted' | 'Validating' | 'Active'; + +/** + * Defines values for SessionStateV4. + * Possible values include: 'None', 'Idle', 'Connect', 'Active', 'OpenSent', 'OpenConfirm', + * 'OpenReceived', 'Established', 'PendingAdd', 'PendingUpdate', 'PendingRemove' + * @readonly + * @enum {string} + */ +export type SessionStateV4 = 'None' | 'Idle' | 'Connect' | 'Active' | 'OpenSent' | 'OpenConfirm' | 'OpenReceived' | 'Established' | 'PendingAdd' | 'PendingUpdate' | 'PendingRemove'; + +/** + * Defines values for SessionStateV6. + * Possible values include: 'None', 'Idle', 'Connect', 'Active', 'OpenSent', 'OpenConfirm', + * 'OpenReceived', 'Established', 'PendingAdd', 'PendingUpdate', 'PendingRemove' + * @readonly + * @enum {string} + */ +export type SessionStateV6 = 'None' | 'Idle' | 'Connect' | 'Active' | 'OpenSent' | 'OpenConfirm' | 'OpenReceived' | 'Established' | 'PendingAdd' | 'PendingUpdate' | 'PendingRemove'; + +/** + * Defines values for DirectPeeringType. + * Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + * @readonly + * @enum {string} + */ +export type DirectPeeringType = 'Edge' | 'Transit' | 'Cdn' | 'Internal'; + +/** + * Defines values for ProvisioningState. + * Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed' + * @readonly + * @enum {string} + */ +export type ProvisioningState = 'Succeeded' | 'Updating' | 'Deleting' | 'Failed'; + +/** + * Defines values for ValidationState. + * Possible values include: 'None', 'Pending', 'Approved', 'Failed' + * @readonly + * @enum {string} + */ +export type ValidationState = 'None' | 'Pending' | 'Approved' | 'Failed'; + +/** + * Defines values for PrefixValidationState. + * Possible values include: 'None', 'Invalid', 'Verified', 'Failed', 'Pending', 'Unknown' + * @readonly + * @enum {string} + */ +export type PrefixValidationState = 'None' | 'Invalid' | 'Verified' | 'Failed' | 'Pending' | 'Unknown'; + +/** + * Defines values for LearnedType. + * Possible values include: 'None', 'ViaPartner', 'ViaSession' + * @readonly + * @enum {string} + */ +export type LearnedType = 'None' | 'ViaPartner' | 'ViaSession'; + +/** + * Defines values for DirectPeeringType1. + * Possible values include: 'Edge', 'Transit', 'Cdn', 'Internal' + * @readonly + * @enum {string} + */ +export type DirectPeeringType1 = 'Edge' | 'Transit' | 'Cdn' | 'Internal'; + +/** + * Defines values for CheckServiceProviderAvailabilityOKResponse. + * Possible values include: 'Available', 'UnAvailable' + * @readonly + * @enum {string} + */ +export type CheckServiceProviderAvailabilityOKResponse = 'Available' | 'UnAvailable'; + +/** + * Defines values for Kind1. + * Possible values include: 'Direct', 'Exchange' + * @readonly + * @enum {string} + */ +export type Kind1 = 'Direct' | 'Exchange'; + +/** + * Defines values for Kind2. + * Possible values include: 'Direct', 'Exchange' + * @readonly + * @enum {string} + */ +export type Kind2 = 'Direct' | 'Exchange'; + +/** + * Contains response data for the checkServiceProviderAvailability operation. + */ +export type CheckServiceProviderAvailabilityResponse = { + /** + * The parsed response body. + */ + body: CheckServiceProviderAvailabilityOKResponse; + + /** + * 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: CheckServiceProviderAvailabilityOKResponse; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type LegacyPeeringsListResponse = PeeringListResult & { + /** + * 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: PeeringListResult; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type LegacyPeeringsListNextResponse = PeeringListResult & { + /** + * 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: PeeringListResult; + }; +}; + +/** + * 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; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type OperationsListNextResponse = 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; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type PeerAsnsGetResponse = PeerAsn & { + /** + * 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: PeerAsn; + }; +}; + +/** + * Contains response data for the createOrUpdate operation. + */ +export type PeerAsnsCreateOrUpdateResponse = PeerAsn & { + /** + * 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: PeerAsn; + }; +}; + +/** + * Contains response data for the listBySubscription operation. + */ +export type PeerAsnsListBySubscriptionResponse = PeerAsnListResult & { + /** + * 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: PeerAsnListResult; + }; +}; + +/** + * Contains response data for the listBySubscriptionNext operation. + */ +export type PeerAsnsListBySubscriptionNextResponse = PeerAsnListResult & { + /** + * 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: PeerAsnListResult; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type PeeringLocationsListResponse = PeeringLocationListResult & { + /** + * 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: PeeringLocationListResult; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type PeeringLocationsListNextResponse = PeeringLocationListResult & { + /** + * 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: PeeringLocationListResult; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type PeeringsGetResponse = Peering & { + /** + * 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: Peering; + }; +}; + +/** + * Contains response data for the createOrUpdate operation. + */ +export type PeeringsCreateOrUpdateResponse = Peering & { + /** + * 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: Peering; + }; +}; + +/** + * Contains response data for the update operation. + */ +export type PeeringsUpdateResponse = Peering & { + /** + * 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: Peering; + }; +}; + +/** + * Contains response data for the listByResourceGroup operation. + */ +export type PeeringsListByResourceGroupResponse = PeeringListResult & { + /** + * 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: PeeringListResult; + }; +}; + +/** + * Contains response data for the listBySubscription operation. + */ +export type PeeringsListBySubscriptionResponse = PeeringListResult & { + /** + * 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: PeeringListResult; + }; +}; + +/** + * Contains response data for the listByResourceGroupNext operation. + */ +export type PeeringsListByResourceGroupNextResponse = PeeringListResult & { + /** + * 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: PeeringListResult; + }; +}; + +/** + * Contains response data for the listBySubscriptionNext operation. + */ +export type PeeringsListBySubscriptionNextResponse = PeeringListResult & { + /** + * 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: PeeringListResult; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type PeeringServiceLocationsListResponse = PeeringServiceLocationListResult & { + /** + * 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: PeeringServiceLocationListResult; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type PeeringServiceLocationsListNextResponse = PeeringServiceLocationListResult & { + /** + * 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: PeeringServiceLocationListResult; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type PeeringServicePrefixesGetResponse = PeeringServicePrefix & { + /** + * 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: PeeringServicePrefix; + }; +}; + +/** + * Contains response data for the createOrUpdate operation. + */ +export type PeeringServicePrefixesCreateOrUpdateResponse = PeeringServicePrefix & { + /** + * 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: PeeringServicePrefix; + }; +}; + +/** + * Contains response data for the listByPeeringService operation. + */ +export type PrefixesListByPeeringServiceResponse = PeeringServicePrefixListResult & { + /** + * 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: PeeringServicePrefixListResult; + }; +}; + +/** + * Contains response data for the listByPeeringServiceNext operation. + */ +export type PrefixesListByPeeringServiceNextResponse = PeeringServicePrefixListResult & { + /** + * 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: PeeringServicePrefixListResult; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type PeeringServiceProvidersListResponse = PeeringServiceProviderListResult & { + /** + * 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: PeeringServiceProviderListResult; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type PeeringServiceProvidersListNextResponse = PeeringServiceProviderListResult & { + /** + * 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: PeeringServiceProviderListResult; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type PeeringServicesGetResponse = PeeringService & { + /** + * 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: PeeringService; + }; +}; + +/** + * Contains response data for the createOrUpdate operation. + */ +export type PeeringServicesCreateOrUpdateResponse = PeeringService & { + /** + * 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: PeeringService; + }; +}; + +/** + * Contains response data for the update operation. + */ +export type PeeringServicesUpdateResponse = PeeringService & { + /** + * 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: PeeringService; + }; +}; + +/** + * Contains response data for the listByResourceGroup operation. + */ +export type PeeringServicesListByResourceGroupResponse = PeeringServiceListResult & { + /** + * 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: PeeringServiceListResult; + }; +}; + +/** + * Contains response data for the listBySubscription operation. + */ +export type PeeringServicesListBySubscriptionResponse = PeeringServiceListResult & { + /** + * 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: PeeringServiceListResult; + }; +}; + +/** + * Contains response data for the listByResourceGroupNext operation. + */ +export type PeeringServicesListByResourceGroupNextResponse = PeeringServiceListResult & { + /** + * 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: PeeringServiceListResult; + }; +}; + +/** + * Contains response data for the listBySubscriptionNext operation. + */ +export type PeeringServicesListBySubscriptionNextResponse = PeeringServiceListResult & { + /** + * 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: PeeringServiceListResult; + }; +}; diff --git a/sdk/peering/arm-peering/src/models/legacyPeeringsMappers.ts b/sdk/peering/arm-peering/src/models/legacyPeeringsMappers.ts new file mode 100644 index 000000000000..147e9d528f40 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/legacyPeeringsMappers.ts @@ -0,0 +1,34 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringListResult, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/mappers.ts b/sdk/peering/arm-peering/src/models/mappers.ts new file mode 100644 index 000000000000..534d6d8012e8 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/mappers.ts @@ -0,0 +1,1189 @@ +/* + * 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 CheckServiceProviderAvailabilityInput: msRest.CompositeMapper = { + serializedName: "CheckServiceProviderAvailabilityInput", + type: { + name: "Composite", + className: "CheckServiceProviderAvailabilityInput", + modelProperties: { + peeringServiceLocation: { + serializedName: "peeringServiceLocation", + type: { + name: "String" + } + }, + peeringServiceProvider: { + serializedName: "peeringServiceProvider", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringSku: msRest.CompositeMapper = { + serializedName: "PeeringSku", + type: { + name: "Composite", + className: "PeeringSku", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + tier: { + serializedName: "tier", + type: { + name: "String" + } + }, + family: { + serializedName: "family", + type: { + name: "String" + } + }, + size: { + serializedName: "size", + type: { + name: "String" + } + } + } + } +}; + +export const BgpSession: msRest.CompositeMapper = { + serializedName: "BgpSession", + type: { + name: "Composite", + className: "BgpSession", + modelProperties: { + sessionPrefixV4: { + serializedName: "sessionPrefixV4", + type: { + name: "String" + } + }, + sessionPrefixV6: { + serializedName: "sessionPrefixV6", + type: { + name: "String" + } + }, + microsoftSessionIPv4Address: { + readOnly: true, + serializedName: "microsoftSessionIPv4Address", + type: { + name: "String" + } + }, + microsoftSessionIPv6Address: { + readOnly: true, + serializedName: "microsoftSessionIPv6Address", + type: { + name: "String" + } + }, + peerSessionIPv4Address: { + serializedName: "peerSessionIPv4Address", + type: { + name: "String" + } + }, + peerSessionIPv6Address: { + serializedName: "peerSessionIPv6Address", + type: { + name: "String" + } + }, + sessionStateV4: { + readOnly: true, + serializedName: "sessionStateV4", + type: { + name: "String" + } + }, + sessionStateV6: { + readOnly: true, + serializedName: "sessionStateV6", + type: { + name: "String" + } + }, + maxPrefixesAdvertisedV4: { + serializedName: "maxPrefixesAdvertisedV4", + type: { + name: "Number" + } + }, + maxPrefixesAdvertisedV6: { + serializedName: "maxPrefixesAdvertisedV6", + type: { + name: "Number" + } + }, + md5AuthenticationKey: { + serializedName: "md5AuthenticationKey", + type: { + name: "String" + } + } + } + } +}; + +export const DirectConnection: msRest.CompositeMapper = { + serializedName: "DirectConnection", + type: { + name: "Composite", + className: "DirectConnection", + modelProperties: { + bandwidthInMbps: { + serializedName: "bandwidthInMbps", + type: { + name: "Number" + } + }, + provisionedBandwidthInMbps: { + serializedName: "provisionedBandwidthInMbps", + type: { + name: "Number" + } + }, + sessionAddressProvider: { + serializedName: "sessionAddressProvider", + type: { + name: "String" + } + }, + useForPeeringService: { + serializedName: "useForPeeringService", + type: { + name: "Boolean" + } + }, + peeringDBFacilityId: { + serializedName: "peeringDBFacilityId", + type: { + name: "Number" + } + }, + connectionState: { + readOnly: true, + serializedName: "connectionState", + type: { + name: "String" + } + }, + bgpSession: { + serializedName: "bgpSession", + type: { + name: "Composite", + className: "BgpSession" + } + }, + connectionIdentifier: { + serializedName: "connectionIdentifier", + type: { + name: "String" + } + } + } + } +}; + +export const SubResource: msRest.CompositeMapper = { + serializedName: "SubResource", + type: { + name: "Composite", + className: "SubResource", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringPropertiesDirect: msRest.CompositeMapper = { + serializedName: "PeeringPropertiesDirect", + type: { + name: "Composite", + className: "PeeringPropertiesDirect", + modelProperties: { + connections: { + serializedName: "connections", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DirectConnection" + } + } + } + }, + useForPeeringService: { + serializedName: "useForPeeringService", + type: { + name: "Boolean" + } + }, + peerAsn: { + serializedName: "peerAsn", + type: { + name: "Composite", + className: "SubResource" + } + }, + directPeeringType: { + serializedName: "directPeeringType", + type: { + name: "String" + } + } + } + } +}; + +export const ExchangeConnection: msRest.CompositeMapper = { + serializedName: "ExchangeConnection", + type: { + name: "Composite", + className: "ExchangeConnection", + modelProperties: { + peeringDBFacilityId: { + serializedName: "peeringDBFacilityId", + type: { + name: "Number" + } + }, + connectionState: { + readOnly: true, + serializedName: "connectionState", + type: { + name: "String" + } + }, + bgpSession: { + serializedName: "bgpSession", + type: { + name: "Composite", + className: "BgpSession" + } + }, + connectionIdentifier: { + serializedName: "connectionIdentifier", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringPropertiesExchange: msRest.CompositeMapper = { + serializedName: "PeeringPropertiesExchange", + type: { + name: "Composite", + className: "PeeringPropertiesExchange", + modelProperties: { + connections: { + serializedName: "connections", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ExchangeConnection" + } + } + } + }, + peerAsn: { + serializedName: "peerAsn", + type: { + name: "Composite", + className: "SubResource" + } + } + } + } +}; + +export const Resource: msRest.CompositeMapper = { + serializedName: "Resource", + type: { + name: "Composite", + className: "Resource", + modelProperties: { + name: { + readOnly: true, + serializedName: "name", + type: { + name: "String" + } + }, + id: { + readOnly: true, + serializedName: "id", + type: { + name: "String" + } + }, + type: { + readOnly: true, + serializedName: "type", + type: { + name: "String" + } + } + } + } +}; + +export const Peering: msRest.CompositeMapper = { + serializedName: "Peering", + type: { + name: "Composite", + className: "Peering", + modelProperties: { + ...Resource.type.modelProperties, + sku: { + required: true, + serializedName: "sku", + type: { + name: "Composite", + className: "PeeringSku" + } + }, + kind: { + required: true, + serializedName: "kind", + type: { + name: "String" + } + }, + direct: { + serializedName: "properties.direct", + type: { + name: "Composite", + className: "PeeringPropertiesDirect" + } + }, + exchange: { + serializedName: "properties.exchange", + type: { + name: "Composite", + className: "PeeringPropertiesExchange" + } + }, + peeringLocation: { + serializedName: "properties.peeringLocation", + type: { + name: "String" + } + }, + provisioningState: { + readOnly: true, + serializedName: "properties.provisioningState", + type: { + name: "String" + } + }, + location: { + required: true, + serializedName: "location", + type: { + name: "String" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const OperationDisplayInfo: msRest.CompositeMapper = { + serializedName: "OperationDisplayInfo", + type: { + name: "Composite", + className: "OperationDisplayInfo", + modelProperties: { + provider: { + readOnly: true, + serializedName: "provider", + type: { + name: "String" + } + }, + resource: { + readOnly: true, + serializedName: "resource", + type: { + name: "String" + } + }, + operation: { + readOnly: true, + serializedName: "operation", + type: { + name: "String" + } + }, + description: { + readOnly: true, + serializedName: "description", + type: { + name: "String" + } + } + } + } +}; + +export const Operation: msRest.CompositeMapper = { + serializedName: "Operation", + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + readOnly: true, + serializedName: "name", + type: { + name: "String" + } + }, + display: { + readOnly: true, + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplayInfo" + } + }, + isDataAction: { + readOnly: true, + serializedName: "isDataAction", + type: { + name: "Boolean" + } + } + } + } +}; + +export const ContactInfo: msRest.CompositeMapper = { + serializedName: "ContactInfo", + type: { + name: "Composite", + className: "ContactInfo", + modelProperties: { + emails: { + serializedName: "emails", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + phone: { + serializedName: "phone", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const PeerAsn: msRest.CompositeMapper = { + serializedName: "PeerAsn", + type: { + name: "Composite", + className: "PeerAsn", + modelProperties: { + ...Resource.type.modelProperties, + peerAsn: { + serializedName: "properties.peerAsn", + type: { + name: "Number" + } + }, + peerContactInfo: { + serializedName: "properties.peerContactInfo", + type: { + name: "Composite", + className: "ContactInfo" + } + }, + peerName: { + serializedName: "properties.peerName", + type: { + name: "String" + } + }, + validationState: { + serializedName: "properties.validationState", + type: { + name: "String" + } + } + } + } +}; + +export const DirectPeeringFacility: msRest.CompositeMapper = { + serializedName: "DirectPeeringFacility", + type: { + name: "Composite", + className: "DirectPeeringFacility", + modelProperties: { + address: { + serializedName: "address", + type: { + name: "String" + } + }, + directPeeringType: { + serializedName: "directPeeringType", + type: { + name: "String" + } + }, + peeringDBFacilityId: { + serializedName: "peeringDBFacilityId", + type: { + name: "Number" + } + }, + peeringDBFacilityLink: { + serializedName: "peeringDBFacilityLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringBandwidthOffer: msRest.CompositeMapper = { + serializedName: "PeeringBandwidthOffer", + type: { + name: "Composite", + className: "PeeringBandwidthOffer", + modelProperties: { + offerName: { + serializedName: "offerName", + type: { + name: "String" + } + }, + valueInMbps: { + serializedName: "valueInMbps", + type: { + name: "Number" + } + } + } + } +}; + +export const PeeringLocationPropertiesDirect: msRest.CompositeMapper = { + serializedName: "PeeringLocationPropertiesDirect", + type: { + name: "Composite", + className: "PeeringLocationPropertiesDirect", + modelProperties: { + peeringFacilities: { + serializedName: "peeringFacilities", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DirectPeeringFacility" + } + } + } + }, + bandwidthOffers: { + serializedName: "bandwidthOffers", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeeringBandwidthOffer" + } + } + } + } + } + } +}; + +export const ExchangePeeringFacility: msRest.CompositeMapper = { + serializedName: "ExchangePeeringFacility", + type: { + name: "Composite", + className: "ExchangePeeringFacility", + modelProperties: { + exchangeName: { + serializedName: "exchangeName", + type: { + name: "String" + } + }, + bandwidthInMbps: { + serializedName: "bandwidthInMbps", + type: { + name: "Number" + } + }, + microsoftIPv4Address: { + serializedName: "microsoftIPv4Address", + type: { + name: "String" + } + }, + microsoftIPv6Address: { + serializedName: "microsoftIPv6Address", + type: { + name: "String" + } + }, + facilityIPv4Prefix: { + serializedName: "facilityIPv4Prefix", + type: { + name: "String" + } + }, + facilityIPv6Prefix: { + serializedName: "facilityIPv6Prefix", + type: { + name: "String" + } + }, + peeringDBFacilityId: { + serializedName: "peeringDBFacilityId", + type: { + name: "Number" + } + }, + peeringDBFacilityLink: { + serializedName: "peeringDBFacilityLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringLocationPropertiesExchange: msRest.CompositeMapper = { + serializedName: "PeeringLocationPropertiesExchange", + type: { + name: "Composite", + className: "PeeringLocationPropertiesExchange", + modelProperties: { + peeringFacilities: { + serializedName: "peeringFacilities", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ExchangePeeringFacility" + } + } + } + } + } + } +}; + +export const PeeringLocation: msRest.CompositeMapper = { + serializedName: "PeeringLocation", + type: { + name: "Composite", + className: "PeeringLocation", + modelProperties: { + ...Resource.type.modelProperties, + kind: { + serializedName: "kind", + type: { + name: "String" + } + }, + direct: { + serializedName: "properties.direct", + type: { + name: "Composite", + className: "PeeringLocationPropertiesDirect" + } + }, + exchange: { + serializedName: "properties.exchange", + type: { + name: "Composite", + className: "PeeringLocationPropertiesExchange" + } + }, + peeringLocation: { + serializedName: "properties.peeringLocation", + type: { + name: "String" + } + }, + country: { + serializedName: "properties.country", + type: { + name: "String" + } + }, + azureRegion: { + serializedName: "properties.azureRegion", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceTags: msRest.CompositeMapper = { + serializedName: "ResourceTags", + type: { + name: "Composite", + className: "ResourceTags", + modelProperties: { + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const PeeringServiceLocation: msRest.CompositeMapper = { + serializedName: "PeeringServiceLocation", + type: { + name: "Composite", + className: "PeeringServiceLocation", + modelProperties: { + ...Resource.type.modelProperties, + country: { + serializedName: "properties.country", + type: { + name: "String" + } + }, + state: { + serializedName: "properties.state", + type: { + name: "String" + } + }, + azureRegion: { + serializedName: "properties.azureRegion", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringServicePrefix: msRest.CompositeMapper = { + serializedName: "PeeringServicePrefix", + type: { + name: "Composite", + className: "PeeringServicePrefix", + modelProperties: { + ...Resource.type.modelProperties, + prefix: { + serializedName: "properties.prefix", + type: { + name: "String" + } + }, + prefixValidationState: { + serializedName: "properties.prefixValidationState", + type: { + name: "String" + } + }, + learnedType: { + serializedName: "properties.learnedType", + type: { + name: "String" + } + }, + provisioningState: { + readOnly: true, + serializedName: "properties.provisioningState", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringServiceProvider: msRest.CompositeMapper = { + serializedName: "PeeringServiceProvider", + type: { + name: "Composite", + className: "PeeringServiceProvider", + modelProperties: { + ...Resource.type.modelProperties, + serviceProviderName: { + serializedName: "properties.serviceProviderName", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringService: msRest.CompositeMapper = { + serializedName: "PeeringService", + type: { + name: "Composite", + className: "PeeringService", + modelProperties: { + ...Resource.type.modelProperties, + peeringServiceLocation: { + serializedName: "properties.peeringServiceLocation", + type: { + name: "String" + } + }, + peeringServiceProvider: { + serializedName: "properties.peeringServiceProvider", + type: { + name: "String" + } + }, + provisioningState: { + readOnly: true, + serializedName: "properties.provisioningState", + type: { + name: "String" + } + }, + location: { + required: true, + serializedName: "location", + type: { + name: "String" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const ErrorResponse: msRest.CompositeMapper = { + serializedName: "ErrorResponse", + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + code: { + readOnly: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + readOnly: true, + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringListResult: msRest.CompositeMapper = { + serializedName: "PeeringListResult", + type: { + name: "Composite", + className: "PeeringListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Peering" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + 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" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeerAsnListResult: msRest.CompositeMapper = { + serializedName: "PeerAsnListResult", + type: { + name: "Composite", + className: "PeerAsnListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeerAsn" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringLocationListResult: msRest.CompositeMapper = { + serializedName: "PeeringLocationListResult", + type: { + name: "Composite", + className: "PeeringLocationListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeeringLocation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringServiceLocationListResult: msRest.CompositeMapper = { + serializedName: "PeeringServiceLocationListResult", + type: { + name: "Composite", + className: "PeeringServiceLocationListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeeringServiceLocation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringServicePrefixListResult: msRest.CompositeMapper = { + serializedName: "PeeringServicePrefixListResult", + type: { + name: "Composite", + className: "PeeringServicePrefixListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeeringServicePrefix" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringServiceProviderListResult: msRest.CompositeMapper = { + serializedName: "PeeringServiceProviderListResult", + type: { + name: "Composite", + className: "PeeringServiceProviderListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeeringServiceProvider" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const PeeringServiceListResult: msRest.CompositeMapper = { + serializedName: "PeeringServiceListResult", + type: { + name: "Composite", + className: "PeeringServiceListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PeeringService" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/peering/arm-peering/src/models/operationsMappers.ts b/sdk/peering/arm-peering/src/models/operationsMappers.ts new file mode 100644 index 000000000000..41b000418950 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/operationsMappers.ts @@ -0,0 +1,14 @@ +/* + * 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 { + ErrorResponse, + Operation, + OperationDisplayInfo, + OperationListResult +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/parameters.ts b/sdk/peering/arm-peering/src/models/parameters.ts new file mode 100644 index 000000000000..e9e0cef438b5 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/parameters.ts @@ -0,0 +1,135 @@ +/* + * 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" + } + } +}; +export const directPeeringType: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "directPeeringType" + ], + mapper: { + serializedName: "directPeeringType", + type: { + name: "String" + } + } +}; +export const kind: msRest.OperationQueryParameter = { + parameterPath: "kind", + mapper: { + required: true, + serializedName: "kind", + type: { + name: "String" + } + } +}; +export const nextPageLink: msRest.OperationURLParameter = { + parameterPath: "nextPageLink", + mapper: { + required: true, + serializedName: "nextLink", + type: { + name: "String" + } + }, + skipEncoding: true +}; +export const peerAsnName: msRest.OperationURLParameter = { + parameterPath: "peerAsnName", + mapper: { + required: true, + serializedName: "peerAsnName", + type: { + name: "String" + } + } +}; +export const peeringLocation: msRest.OperationQueryParameter = { + parameterPath: "peeringLocation", + mapper: { + required: true, + serializedName: "peeringLocation", + type: { + name: "String" + } + } +}; +export const peeringName: msRest.OperationURLParameter = { + parameterPath: "peeringName", + mapper: { + required: true, + serializedName: "peeringName", + type: { + name: "String" + } + } +}; +export const peeringServiceName: msRest.OperationURLParameter = { + parameterPath: "peeringServiceName", + mapper: { + required: true, + serializedName: "peeringServiceName", + type: { + name: "String" + } + } +}; +export const prefixName: msRest.OperationURLParameter = { + parameterPath: "prefixName", + mapper: { + required: true, + serializedName: "prefixName", + type: { + name: "String" + } + } +}; +export const resourceGroupName: msRest.OperationURLParameter = { + parameterPath: "resourceGroupName", + mapper: { + required: true, + serializedName: "resourceGroupName", + type: { + name: "String" + } + } +}; +export const subscriptionId: msRest.OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + required: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + } +}; diff --git a/sdk/peering/arm-peering/src/models/peerAsnsMappers.ts b/sdk/peering/arm-peering/src/models/peerAsnsMappers.ts new file mode 100644 index 000000000000..da3cdc4561cd --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peerAsnsMappers.ts @@ -0,0 +1,34 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + PeerAsnListResult, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/peeringLocationsMappers.ts b/sdk/peering/arm-peering/src/models/peeringLocationsMappers.ts new file mode 100644 index 000000000000..7e3205ea330a --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peeringLocationsMappers.ts @@ -0,0 +1,34 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationListResult, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/peeringServiceLocationsMappers.ts b/sdk/peering/arm-peering/src/models/peeringServiceLocationsMappers.ts new file mode 100644 index 000000000000..c41b232f2c04 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peeringServiceLocationsMappers.ts @@ -0,0 +1,34 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServiceLocationListResult, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/peeringServicePrefixesMappers.ts b/sdk/peering/arm-peering/src/models/peeringServicePrefixesMappers.ts new file mode 100644 index 000000000000..3750ca36a206 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peeringServicePrefixesMappers.ts @@ -0,0 +1,33 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/peeringServiceProvidersMappers.ts b/sdk/peering/arm-peering/src/models/peeringServiceProvidersMappers.ts new file mode 100644 index 000000000000..b9729dc9379f --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peeringServiceProvidersMappers.ts @@ -0,0 +1,34 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringServiceProviderListResult, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/peeringServicesMappers.ts b/sdk/peering/arm-peering/src/models/peeringServicesMappers.ts new file mode 100644 index 000000000000..ddc9ffdfb198 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peeringServicesMappers.ts @@ -0,0 +1,35 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceListResult, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + ResourceTags, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/peeringsMappers.ts b/sdk/peering/arm-peering/src/models/peeringsMappers.ts new file mode 100644 index 000000000000..736ac14d0a85 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/peeringsMappers.ts @@ -0,0 +1,35 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringListResult, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServiceProvider, + PeeringSku, + Resource, + ResourceTags, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/models/prefixesMappers.ts b/sdk/peering/arm-peering/src/models/prefixesMappers.ts new file mode 100644 index 000000000000..880f11ef7879 --- /dev/null +++ b/sdk/peering/arm-peering/src/models/prefixesMappers.ts @@ -0,0 +1,34 @@ +/* + * 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 { + BaseResource, + BgpSession, + ContactInfo, + DirectConnection, + DirectPeeringFacility, + ErrorResponse, + ExchangeConnection, + ExchangePeeringFacility, + PeerAsn, + Peering, + PeeringBandwidthOffer, + PeeringLocation, + PeeringLocationPropertiesDirect, + PeeringLocationPropertiesExchange, + PeeringPropertiesDirect, + PeeringPropertiesExchange, + PeeringService, + PeeringServiceLocation, + PeeringServicePrefix, + PeeringServicePrefixListResult, + PeeringServiceProvider, + PeeringSku, + Resource, + SubResource +} from "../models/mappers"; diff --git a/sdk/peering/arm-peering/src/operations/index.ts b/sdk/peering/arm-peering/src/operations/index.ts new file mode 100644 index 000000000000..62dc0305012e --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/index.ts @@ -0,0 +1,20 @@ +/* + * 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 "./legacyPeerings"; +export * from "./operations"; +export * from "./peerAsns"; +export * from "./peeringLocations"; +export * from "./peerings"; +export * from "./peeringServiceLocations"; +export * from "./peeringServicePrefixes"; +export * from "./prefixes"; +export * from "./peeringServiceProviders"; +export * from "./peeringServices"; diff --git a/sdk/peering/arm-peering/src/operations/legacyPeerings.ts b/sdk/peering/arm-peering/src/operations/legacyPeerings.ts new file mode 100644 index 000000000000..552e26a56c06 --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/legacyPeerings.ts @@ -0,0 +1,138 @@ +/* + * 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/legacyPeeringsMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a LegacyPeerings. */ +export class LegacyPeerings { + private readonly client: PeeringManagementClientContext; + + /** + * Create a LegacyPeerings. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Lists all of the legacy peerings under the given subscription matching the specified kind and + * location. + * @param peeringLocation The location of the peering. + * @param kind The kind of the peering. Possible values include: 'Direct', 'Exchange' + * @param [options] The optional parameters + * @returns Promise + */ + list(peeringLocation: string, kind: Models.Kind1, options?: msRest.RequestOptionsBase): Promise; + /** + * @param peeringLocation The location of the peering. + * @param kind The kind of the peering. Possible values include: 'Direct', 'Exchange' + * @param callback The callback + */ + list(peeringLocation: string, kind: Models.Kind1, callback: msRest.ServiceCallback): void; + /** + * @param peeringLocation The location of the peering. + * @param kind The kind of the peering. Possible values include: 'Direct', 'Exchange' + * @param options The optional parameters + * @param callback The callback + */ + list(peeringLocation: string, kind: Models.Kind1, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + list(peeringLocation: string, kind: Models.Kind1, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + peeringLocation, + kind, + options + }, + listOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the legacy peerings under the given subscription matching the specified kind and + * location. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/legacyPeerings", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.peeringLocation, + Parameters.kind, + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/operations.ts b/sdk/peering/arm-peering/src/operations/operations.ts new file mode 100644 index 000000000000..ea8c2e65bb8d --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/operations.ts @@ -0,0 +1,123 @@ +/* + * 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 { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a Operations. */ +export class Operations { + private readonly client: PeeringManagementClientContext; + + /** + * Create a Operations. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Lists all of the available API operations for peering resources. + * @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; + } + + /** + * Lists all of the available API operations for peering resources. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "providers/Microsoft.Peering/operations", + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peerAsns.ts b/sdk/peering/arm-peering/src/operations/peerAsns.ts new file mode 100644 index 000000000000..c07c4c937eee --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peerAsns.ts @@ -0,0 +1,296 @@ +/* + * 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/peerAsnsMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a PeerAsns. */ +export class PeerAsns { + private readonly client: PeeringManagementClientContext; + + /** + * Create a PeerAsns. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Gets the peer ASN with the specified name under the given subscription. + * @param peerAsnName The peer ASN name. + * @param [options] The optional parameters + * @returns Promise + */ + get(peerAsnName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param peerAsnName The peer ASN name. + * @param callback The callback + */ + get(peerAsnName: string, callback: msRest.ServiceCallback): void; + /** + * @param peerAsnName The peer ASN name. + * @param options The optional parameters + * @param callback The callback + */ + get(peerAsnName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(peerAsnName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + peerAsnName, + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Creates a new peer ASN or updates an existing peer ASN with the specified name under the given + * subscription. + * @param peerAsnName The peer ASN name. + * @param peerAsn The peer ASN. + * @param [options] The optional parameters + * @returns Promise + */ + createOrUpdate(peerAsnName: string, peerAsn: Models.PeerAsn, options?: msRest.RequestOptionsBase): Promise; + /** + * @param peerAsnName The peer ASN name. + * @param peerAsn The peer ASN. + * @param callback The callback + */ + createOrUpdate(peerAsnName: string, peerAsn: Models.PeerAsn, callback: msRest.ServiceCallback): void; + /** + * @param peerAsnName The peer ASN name. + * @param peerAsn The peer ASN. + * @param options The optional parameters + * @param callback The callback + */ + createOrUpdate(peerAsnName: string, peerAsn: Models.PeerAsn, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + createOrUpdate(peerAsnName: string, peerAsn: Models.PeerAsn, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + peerAsnName, + peerAsn, + options + }, + createOrUpdateOperationSpec, + callback) as Promise; + } + + /** + * Deletes an existing peer ASN with the specified name under the given subscription. + * @param peerAsnName The peer ASN name. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(peerAsnName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param peerAsnName The peer ASN name. + * @param callback The callback + */ + deleteMethod(peerAsnName: string, callback: msRest.ServiceCallback): void; + /** + * @param peerAsnName The peer ASN name. + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(peerAsnName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(peerAsnName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + peerAsnName, + options + }, + deleteMethodOperationSpec, + callback); + } + + /** + * Lists all of the peer ASNs under the given subscription. + * @param [options] The optional parameters + * @returns Promise + */ + listBySubscription(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + listBySubscription(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listBySubscription(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listBySubscription(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listBySubscriptionOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peer ASNs under the given subscription. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listBySubscriptionNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listBySubscriptionNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listBySubscriptionNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", + urlParameters: [ + Parameters.peerAsnName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeerAsn + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const createOrUpdateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", + urlParameters: [ + Parameters.peerAsnName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "peerAsn", + mapper: { + ...Mappers.PeerAsn, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PeerAsn + }, + 201: { + bodyMapper: Mappers.PeerAsn + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", + urlParameters: [ + Parameters.peerAsnName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listBySubscriptionOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeerAsnListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listBySubscriptionNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeerAsnListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peeringLocations.ts b/sdk/peering/arm-peering/src/operations/peeringLocations.ts new file mode 100644 index 000000000000..759ff1c75516 --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peeringLocations.ts @@ -0,0 +1,132 @@ +/* + * 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/peeringLocationsMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a PeeringLocations. */ +export class PeeringLocations { + private readonly client: PeeringManagementClientContext; + + /** + * Create a PeeringLocations. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Lists all of the available peering locations for the specified kind of peering. + * @param kind The kind of the peering. Possible values include: 'Direct', 'Exchange' + * @param [options] The optional parameters + * @returns Promise + */ + list(kind: Models.Kind2, options?: Models.PeeringLocationsListOptionalParams): Promise; + /** + * @param kind The kind of the peering. Possible values include: 'Direct', 'Exchange' + * @param callback The callback + */ + list(kind: Models.Kind2, callback: msRest.ServiceCallback): void; + /** + * @param kind The kind of the peering. Possible values include: 'Direct', 'Exchange' + * @param options The optional parameters + * @param callback The callback + */ + list(kind: Models.Kind2, options: Models.PeeringLocationsListOptionalParams, callback: msRest.ServiceCallback): void; + list(kind: Models.Kind2, options?: Models.PeeringLocationsListOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kind, + options + }, + listOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the available peering locations for the specified kind of peering. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringLocations", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.kind, + Parameters.directPeeringType, + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringLocationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringLocationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peeringServiceLocations.ts b/sdk/peering/arm-peering/src/operations/peeringServiceLocations.ts new file mode 100644 index 000000000000..dd0262656860 --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peeringServiceLocations.ts @@ -0,0 +1,126 @@ +/* + * 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/peeringServiceLocationsMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a PeeringServiceLocations. */ +export class PeeringServiceLocations { + private readonly client: PeeringManagementClientContext; + + /** + * Create a PeeringServiceLocations. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Lists all of the available peering service locations for the specified kind of peering. + * @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; + } + + /** + * Lists all of the available peering service locations for the specified kind of peering. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceLocations", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceLocationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceLocationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peeringServicePrefixes.ts b/sdk/peering/arm-peering/src/operations/peeringServicePrefixes.ts new file mode 100644 index 000000000000..be55a7d444d9 --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peeringServicePrefixes.ts @@ -0,0 +1,229 @@ +/* + * 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/peeringServicePrefixesMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a PeeringServicePrefixes. */ +export class PeeringServicePrefixes { + private readonly client: PeeringManagementClientContext; + + /** + * Create a PeeringServicePrefixes. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Gets the peering service prefix. + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name. + * @param [options] The optional parameters + * @returns Promise + */ + get(resourceGroupName: string, peeringServiceName: string, prefixName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name. + * @param callback The callback + */ + get(resourceGroupName: string, peeringServiceName: string, prefixName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name. + * @param options The optional parameters + * @param callback The callback + */ + get(resourceGroupName: string, peeringServiceName: string, prefixName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(resourceGroupName: string, peeringServiceName: string, prefixName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + prefixName, + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Creates or updates the peering prefix. + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name + * @param peeringServicePrefix The IP prefix for an peering + * @param [options] The optional parameters + * @returns Promise + */ + createOrUpdate(resourceGroupName: string, peeringServiceName: string, prefixName: string, peeringServicePrefix: Models.PeeringServicePrefix, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name + * @param peeringServicePrefix The IP prefix for an peering + * @param callback The callback + */ + createOrUpdate(resourceGroupName: string, peeringServiceName: string, prefixName: string, peeringServicePrefix: Models.PeeringServicePrefix, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name + * @param peeringServicePrefix The IP prefix for an peering + * @param options The optional parameters + * @param callback The callback + */ + createOrUpdate(resourceGroupName: string, peeringServiceName: string, prefixName: string, peeringServicePrefix: Models.PeeringServicePrefix, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + createOrUpdate(resourceGroupName: string, peeringServiceName: string, prefixName: string, peeringServicePrefix: Models.PeeringServicePrefix, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + prefixName, + peeringServicePrefix, + options + }, + createOrUpdateOperationSpec, + callback) as Promise; + } + + /** + * removes the peering prefix. + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(resourceGroupName: string, peeringServiceName: string, prefixName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name + * @param callback The callback + */ + deleteMethod(resourceGroupName: string, peeringServiceName: string, prefixName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param prefixName The prefix name + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(resourceGroupName: string, peeringServiceName: string, prefixName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(resourceGroupName: string, peeringServiceName: string, prefixName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + prefixName, + options + }, + deleteMethodOperationSpec, + callback); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.prefixName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServicePrefix + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const createOrUpdateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.prefixName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "peeringServicePrefix", + mapper: { + ...Mappers.PeeringServicePrefix, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PeeringServicePrefix + }, + 201: { + bodyMapper: Mappers.PeeringServicePrefix + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes/{prefixName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.prefixName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peeringServiceProviders.ts b/sdk/peering/arm-peering/src/operations/peeringServiceProviders.ts new file mode 100644 index 000000000000..edbad85b30c6 --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peeringServiceProviders.ts @@ -0,0 +1,126 @@ +/* + * 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/peeringServiceProvidersMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a PeeringServiceProviders. */ +export class PeeringServiceProviders { + private readonly client: PeeringManagementClientContext; + + /** + * Create a PeeringServiceProviders. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Lists all of the available peering service locations for the specified kind of peering. + * @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; + } + + /** + * Lists all of the available peering service locations for the specified kind of peering. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServiceProviders", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceProviderListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceProviderListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peeringServices.ts b/sdk/peering/arm-peering/src/operations/peeringServices.ts new file mode 100644 index 000000000000..46b91d13e22d --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peeringServices.ts @@ -0,0 +1,484 @@ +/* + * 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/peeringServicesMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a PeeringServices. */ +export class PeeringServices { + private readonly client: PeeringManagementClientContext; + + /** + * Create a PeeringServices. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Gets an existing peering service with the specified name under the given subscription and + * resource group. + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering. + * @param [options] The optional parameters + * @returns Promise + */ + get(resourceGroupName: string, peeringServiceName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering. + * @param callback The callback + */ + get(resourceGroupName: string, peeringServiceName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering. + * @param options The optional parameters + * @param callback The callback + */ + get(resourceGroupName: string, peeringServiceName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(resourceGroupName: string, peeringServiceName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Creates a new peering service or updates an existing peering with the specified name under the + * given subscription and resource group. + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param peeringService The properties needed to create or update a peering service. + * @param [options] The optional parameters + * @returns Promise + */ + createOrUpdate(resourceGroupName: string, peeringServiceName: string, peeringService: Models.PeeringService, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param peeringService The properties needed to create or update a peering service. + * @param callback The callback + */ + createOrUpdate(resourceGroupName: string, peeringServiceName: string, peeringService: Models.PeeringService, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param peeringService The properties needed to create or update a peering service. + * @param options The optional parameters + * @param callback The callback + */ + createOrUpdate(resourceGroupName: string, peeringServiceName: string, peeringService: Models.PeeringService, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + createOrUpdate(resourceGroupName: string, peeringServiceName: string, peeringService: Models.PeeringService, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + peeringService, + options + }, + createOrUpdateOperationSpec, + callback) as Promise; + } + + /** + * Deletes an existing peering service with the specified name under the given subscription and + * resource group. + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(resourceGroupName: string, peeringServiceName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param callback The callback + */ + deleteMethod(resourceGroupName: string, peeringServiceName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(resourceGroupName: string, peeringServiceName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(resourceGroupName: string, peeringServiceName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + options + }, + deleteMethodOperationSpec, + callback); + } + + /** + * Updates tags for a peering service with the specified name under the given subscription and + * resource group. + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param [options] The optional parameters + * @returns Promise + */ + update(resourceGroupName: string, peeringServiceName: string, options?: Models.PeeringServicesUpdateOptionalParams): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param callback The callback + */ + update(resourceGroupName: string, peeringServiceName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringServiceName The name of the peering service. + * @param options The optional parameters + * @param callback The callback + */ + update(resourceGroupName: string, peeringServiceName: string, options: Models.PeeringServicesUpdateOptionalParams, callback: msRest.ServiceCallback): void; + update(resourceGroupName: string, peeringServiceName: string, options?: Models.PeeringServicesUpdateOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + options + }, + updateOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peering services under the given subscription and resource group. + * @param resourceGroupName The name of the resource group. + * @param [options] The optional parameters + * @returns Promise + */ + listByResourceGroup(resourceGroupName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param callback The callback + */ + listByResourceGroup(resourceGroupName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param options The optional parameters + * @param callback The callback + */ + listByResourceGroup(resourceGroupName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + options + }, + listByResourceGroupOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peerings under the given subscription. + * @param [options] The optional parameters + * @returns Promise + */ + listBySubscription(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + listBySubscription(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listBySubscription(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listBySubscription(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listBySubscriptionOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peering services under the given subscription and resource group. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listByResourceGroupNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listByResourceGroupNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listByResourceGroupNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listByResourceGroupNextOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peerings under the given subscription. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listBySubscriptionNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listBySubscriptionNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listBySubscriptionNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringService + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const createOrUpdateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "peeringService", + mapper: { + ...Mappers.PeeringService, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PeeringService + }, + 201: { + bodyMapper: Mappers.PeeringService + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const updateOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: { + tags: [ + "options", + "tags" + ] + }, + mapper: { + ...Mappers.ResourceTags, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PeeringService + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listByResourceGroupOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listBySubscriptionOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringServices", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listByResourceGroupNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listBySubscriptionNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServiceListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/peerings.ts b/sdk/peering/arm-peering/src/operations/peerings.ts new file mode 100644 index 000000000000..5ae8d6aac042 --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/peerings.ts @@ -0,0 +1,484 @@ +/* + * 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/peeringsMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a Peerings. */ +export class Peerings { + private readonly client: PeeringManagementClientContext; + + /** + * Create a Peerings. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Gets an existing peering with the specified name under the given subscription and resource + * group. + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param [options] The optional parameters + * @returns Promise + */ + get(resourceGroupName: string, peeringName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param callback The callback + */ + get(resourceGroupName: string, peeringName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param options The optional parameters + * @param callback The callback + */ + get(resourceGroupName: string, peeringName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(resourceGroupName: string, peeringName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringName, + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Creates a new peering or updates an existing peering with the specified name under the given + * subscription and resource group. + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param peering The properties needed to create or update a peering. + * @param [options] The optional parameters + * @returns Promise + */ + createOrUpdate(resourceGroupName: string, peeringName: string, peering: Models.Peering, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param peering The properties needed to create or update a peering. + * @param callback The callback + */ + createOrUpdate(resourceGroupName: string, peeringName: string, peering: Models.Peering, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param peering The properties needed to create or update a peering. + * @param options The optional parameters + * @param callback The callback + */ + createOrUpdate(resourceGroupName: string, peeringName: string, peering: Models.Peering, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + createOrUpdate(resourceGroupName: string, peeringName: string, peering: Models.Peering, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringName, + peering, + options + }, + createOrUpdateOperationSpec, + callback) as Promise; + } + + /** + * Deletes an existing peering with the specified name under the given subscription and resource + * group. + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(resourceGroupName: string, peeringName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param callback The callback + */ + deleteMethod(resourceGroupName: string, peeringName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(resourceGroupName: string, peeringName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(resourceGroupName: string, peeringName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringName, + options + }, + deleteMethodOperationSpec, + callback); + } + + /** + * Updates tags for a peering with the specified name under the given subscription and resource + * group. + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param [options] The optional parameters + * @returns Promise + */ + update(resourceGroupName: string, peeringName: string, options?: Models.PeeringsUpdateOptionalParams): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param callback The callback + */ + update(resourceGroupName: string, peeringName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param peeringName The name of the peering. + * @param options The optional parameters + * @param callback The callback + */ + update(resourceGroupName: string, peeringName: string, options: Models.PeeringsUpdateOptionalParams, callback: msRest.ServiceCallback): void; + update(resourceGroupName: string, peeringName: string, options?: Models.PeeringsUpdateOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringName, + options + }, + updateOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peerings under the given subscription and resource group. + * @param resourceGroupName The name of the resource group. + * @param [options] The optional parameters + * @returns Promise + */ + listByResourceGroup(resourceGroupName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group. + * @param callback The callback + */ + listByResourceGroup(resourceGroupName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group. + * @param options The optional parameters + * @param callback The callback + */ + listByResourceGroup(resourceGroupName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + options + }, + listByResourceGroupOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peerings under the given subscription. + * @param [options] The optional parameters + * @returns Promise + */ + listBySubscription(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + listBySubscription(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listBySubscription(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listBySubscription(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listBySubscriptionOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peerings under the given subscription and resource group. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listByResourceGroupNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listByResourceGroupNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listByResourceGroupNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listByResourceGroupNextOperationSpec, + callback) as Promise; + } + + /** + * Lists all of the peerings under the given subscription. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listBySubscriptionNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listBySubscriptionNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listBySubscriptionNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.Peering + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const createOrUpdateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "peering", + mapper: { + ...Mappers.Peering, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.Peering + }, + 201: { + bodyMapper: Mappers.Peering + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const updateOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: { + tags: [ + "options", + "tags" + ] + }, + mapper: { + ...Mappers.ResourceTags, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.Peering + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listByResourceGroupOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listBySubscriptionOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerings", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listByResourceGroupNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listBySubscriptionNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/operations/prefixes.ts b/sdk/peering/arm-peering/src/operations/prefixes.ts new file mode 100644 index 000000000000..ae39a7f70bce --- /dev/null +++ b/sdk/peering/arm-peering/src/operations/prefixes.ts @@ -0,0 +1,136 @@ +/* + * 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/prefixesMappers"; +import * as Parameters from "../models/parameters"; +import { PeeringManagementClientContext } from "../peeringManagementClientContext"; + +/** Class representing a Prefixes. */ +export class Prefixes { + private readonly client: PeeringManagementClientContext; + + /** + * Create a Prefixes. + * @param {PeeringManagementClientContext} client Reference to the service client. + */ + constructor(client: PeeringManagementClientContext) { + this.client = client; + } + + /** + * Lists the peerings prefix in the resource group. + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param [options] The optional parameters + * @returns Promise + */ + listByPeeringService(resourceGroupName: string, peeringServiceName: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param callback The callback + */ + listByPeeringService(resourceGroupName: string, peeringServiceName: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The resource group name. + * @param peeringServiceName The peering service name. + * @param options The optional parameters + * @param callback The callback + */ + listByPeeringService(resourceGroupName: string, peeringServiceName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listByPeeringService(resourceGroupName: string, peeringServiceName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + resourceGroupName, + peeringServiceName, + options + }, + listByPeeringServiceOperationSpec, + callback) as Promise; + } + + /** + * Lists the peerings prefix in the resource group. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listByPeeringServiceNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listByPeeringServiceNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listByPeeringServiceNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listByPeeringServiceNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listByPeeringServiceNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listByPeeringServiceOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peeringServices/{peeringServiceName}/prefixes", + urlParameters: [ + Parameters.resourceGroupName, + Parameters.peeringServiceName, + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServicePrefixListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const listByPeeringServiceNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.PeeringServicePrefixListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/peering/arm-peering/src/peeringManagementClient.ts b/sdk/peering/arm-peering/src/peeringManagementClient.ts new file mode 100644 index 000000000000..bacf9dc4aabe --- /dev/null +++ b/sdk/peering/arm-peering/src/peeringManagementClient.ts @@ -0,0 +1,129 @@ +/* + * 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 { PeeringManagementClientContext } from "./peeringManagementClientContext"; + + +class PeeringManagementClient extends PeeringManagementClientContext { + // Operation groups + legacyPeerings: operations.LegacyPeerings; + operations: operations.Operations; + peerAsns: operations.PeerAsns; + peeringLocations: operations.PeeringLocations; + peerings: operations.Peerings; + peeringServiceLocations: operations.PeeringServiceLocations; + peeringServicePrefixes: operations.PeeringServicePrefixes; + prefixes: operations.Prefixes; + peeringServiceProviders: operations.PeeringServiceProviders; + peeringServices: operations.PeeringServices; + + /** + * Initializes a new instance of the PeeringManagementClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param subscriptionId The Azure subscription ID. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.PeeringManagementClientOptions) { + super(credentials, subscriptionId, options); + this.legacyPeerings = new operations.LegacyPeerings(this); + this.operations = new operations.Operations(this); + this.peerAsns = new operations.PeerAsns(this); + this.peeringLocations = new operations.PeeringLocations(this); + this.peerings = new operations.Peerings(this); + this.peeringServiceLocations = new operations.PeeringServiceLocations(this); + this.peeringServicePrefixes = new operations.PeeringServicePrefixes(this); + this.prefixes = new operations.Prefixes(this); + this.peeringServiceProviders = new operations.PeeringServiceProviders(this); + this.peeringServices = new operations.PeeringServices(this); + } + + /** + * Checks if the peering service provider is present within 1000 miles of customer's location + * @param [options] The optional parameters + * @returns Promise + */ + checkServiceProviderAvailability(options?: Models.PeeringManagementClientCheckServiceProviderAvailabilityOptionalParams): Promise; + /** + * @param callback The callback + */ + checkServiceProviderAvailability(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + checkServiceProviderAvailability(options: Models.PeeringManagementClientCheckServiceProviderAvailabilityOptionalParams, callback: msRest.ServiceCallback): void; + checkServiceProviderAvailability(options?: Models.PeeringManagementClientCheckServiceProviderAvailabilityOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + options + }, + checkServiceProviderAvailabilityOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const checkServiceProviderAvailabilityOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Peering/CheckServiceProviderAvailability", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: { + peeringServiceLocation: [ + "options", + "peeringServiceLocation" + ], + peeringServiceProvider: [ + "options", + "peeringServiceProvider" + ] + }, + mapper: { + ...Mappers.CheckServiceProviderAvailabilityInput, + required: true + } + }, + responses: { + 200: { + bodyMapper: { + serializedName: "parsedResponse", + type: { + name: "String" + } + } + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +export { + PeeringManagementClient, + PeeringManagementClientContext, + Models as PeeringManagementModels, + Mappers as PeeringManagementMappers +}; +export * from "./operations"; diff --git a/sdk/peering/arm-peering/src/peeringManagementClientContext.ts b/sdk/peering/arm-peering/src/peeringManagementClientContext.ts new file mode 100644 index 000000000000..33fd6ae85bd7 --- /dev/null +++ b/sdk/peering/arm-peering/src/peeringManagementClientContext.ts @@ -0,0 +1,62 @@ +/* + * 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-peering"; +const packageVersion = "1.0.0"; + +export class PeeringManagementClientContext extends msRestAzure.AzureServiceClient { + credentials: msRest.ServiceClientCredentials; + subscriptionId: string; + apiVersion?: string; + + /** + * Initializes a new instance of the PeeringManagementClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param subscriptionId The Azure subscription ID. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.PeeringManagementClientOptions) { + if (credentials == undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId == undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) { + options = {}; + } + if(!options.userAgent) { + const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.apiVersion = '2019-08-01-preview'; + 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; + this.subscriptionId = subscriptionId; + + 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/peering/arm-peering/tsconfig.json b/sdk/peering/arm-peering/tsconfig.json new file mode 100644 index 000000000000..422b584abd5e --- /dev/null +++ b/sdk/peering/arm-peering/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"] +} From 530310240f62a8b56950506066dd23f523d7504c Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Thu, 26 Sep 2019 09:38:13 -0700 Subject: [PATCH 2/2] Cleanup some patterns in core-tracing (#5233) * Add in type information from OpenCensus to catch issues in our wrapper layer to make it work with OpenTelemetry. * Simplify our NoOp implementations and finish fleshing them out. * Clean up TelemetryProxy to be a proper module rather than a static class. * Remove the necessity for a "Plugin" class interface that extends OpenTelemetry's Tracer. * Fixes #5190 in keyvault libraries. * Clean up some bad async patterns in keyvault libraries. --- common/config/rush/pnpm-lock.yaml | 57 ++- sdk/core/core-http/lib/webResource.ts | 23 +- .../test/policies/tracingPolicyTests.ts | 170 ++++--- .../lib/implementations/noop/spanNoOpImpl.ts | 35 -- .../implementations/noop/tracerNoOpImpl.ts | 35 -- sdk/core/core-tracing/lib/index.ts | 35 +- .../core-tracing/lib/interfaces/TimedEvent.ts | 3 + .../core-tracing/lib/interfaces/attributes.ts | 3 + .../core-tracing/lib/interfaces/plugin.ts | 13 - .../lib/plugins/noop/noOpSpanPlugin.ts | 57 --- .../lib/plugins/noop/noOpTracePlugin.ts | 45 -- .../opencensus/openCensusSpanPlugin.ts | 83 ---- .../opencensus/openCensusTracePlugin.ts | 48 -- sdk/core/core-tracing/lib/tracerProxy.ts | 48 +- .../lib/utils/supportedPlugins.ts | 6 - .../lib/wrappers/noop/noOpBinaryFormat.ts | 23 + .../lib/wrappers/noop/noOpHttpTextFormat.ts | 26 ++ .../lib/wrappers/noop/noOpSpan.ts | 89 ++++ .../lib/wrappers/noop/noOpTracer.ts | 76 +++ .../opencensus/openCensusSpanWrapper.ts | 133 ++++++ .../openCensusTraceStateWrapper.ts} | 2 +- .../opencensus/openCensusTracerWrapper.ts | 87 ++++ sdk/core/core-tracing/package.json | 1 + .../core-tracing/review/core-tracing.api.md | 173 ++----- .../review/keyvault-certificates.api.md | 3 - .../keyvault-certificates/src/index.ts | 439 ++++++++++-------- .../keyvault-keys/review/keyvault-keys.api.md | 3 - sdk/keyvault/keyvault-keys/src/index.ts | 272 ++++++----- .../review/keyvault-secrets.api.md | 5 +- sdk/keyvault/keyvault-secrets/src/index.ts | 220 +++++---- .../test/recoverBackupRestore.test.ts | 18 +- 31 files changed, 1178 insertions(+), 1053 deletions(-) delete mode 100644 sdk/core/core-tracing/lib/implementations/noop/spanNoOpImpl.ts delete mode 100644 sdk/core/core-tracing/lib/implementations/noop/tracerNoOpImpl.ts delete mode 100644 sdk/core/core-tracing/lib/interfaces/plugin.ts delete mode 100644 sdk/core/core-tracing/lib/plugins/noop/noOpSpanPlugin.ts delete mode 100644 sdk/core/core-tracing/lib/plugins/noop/noOpTracePlugin.ts delete mode 100644 sdk/core/core-tracing/lib/plugins/opencensus/openCensusSpanPlugin.ts delete mode 100644 sdk/core/core-tracing/lib/plugins/opencensus/openCensusTracePlugin.ts delete mode 100644 sdk/core/core-tracing/lib/utils/supportedPlugins.ts create mode 100644 sdk/core/core-tracing/lib/wrappers/noop/noOpBinaryFormat.ts create mode 100644 sdk/core/core-tracing/lib/wrappers/noop/noOpHttpTextFormat.ts create mode 100644 sdk/core/core-tracing/lib/wrappers/noop/noOpSpan.ts create mode 100644 sdk/core/core-tracing/lib/wrappers/noop/noOpTracer.ts create mode 100644 sdk/core/core-tracing/lib/wrappers/opencensus/openCensusSpanWrapper.ts rename sdk/core/core-tracing/lib/{plugins/opencensus/openCensusTraceStatePlugin.ts => wrappers/opencensus/openCensusTraceStateWrapper.ts} (90%) create mode 100644 sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTracerWrapper.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index f8487a6fbb35..ba2352f84798 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -10,6 +10,7 @@ dependencies: '@azure/ms-rest-nodeauth': 0.9.3 '@azure/storage-blob': 12.0.0-preview.3 '@microsoft/api-extractor': 7.3.8 + '@opencensus/web-types': 0.0.7 '@rush-temp/abort-controller': 'file:projects/abort-controller.tgz' '@rush-temp/app-configuration': 'file:projects/app-configuration.tgz' '@rush-temp/core-amqp': 'file:projects/core-amqp.tgz' @@ -582,6 +583,12 @@ packages: dev: false resolution: integrity: sha512-518yewjSga1jLdiLrcmpMFlaba5P+50b0TWNFUpC+SL9Yzf0kMi57qw+bMl+rQ08cGqH1vLx4eg9YFUbZXgZ0Q== + /@opencensus/web-types/0.0.7: + dev: false + engines: + node: '>=6.0' + resolution: + integrity: sha512-xB+w7ZDAu3YBzqH44rCmG9/RlrOmFuDPt/bpf17eJr8eZSrLt7nc7LnWdxM9Mmoj/YKMHpxRg28txu3TcpiL+g== /@sinonjs/commons/1.6.0: dependencies: type-detect: 4.0.8 @@ -10824,7 +10831,7 @@ packages: dev: false name: '@rush-temp/abort-controller' resolution: - integrity: sha512-vDcC9ZxFHAZ1GK8i63eC7rnBVBbGN6JKPNgMETz4CGHji31lXhMdMMx0sjZNiDN1HMv9lojK3KtW+mhsZmEfZQ== + integrity: sha512-YwhAi/dV8QU4uVvddHEEchoJUG07D7QbKuQVf5jyvD5oklm8BnoIR5ONWo24G1jQnlIEaFrsFjYbboAt1Xl3bQ== tarball: 'file:projects/abort-controller.tgz' version: 0.0.0 'file:projects/app-configuration.tgz': @@ -10855,7 +10862,7 @@ packages: dev: false name: '@rush-temp/app-configuration' resolution: - integrity: sha512-E7iNSp6sfIjCXmpK7lNDqAY00UoMz+ZZ4zgIO5v32Y78tx0D9dq+UrreQEytDR14GUwPyh3uLesptZMwADKlNg== + integrity: sha512-yL3UwTRBJ5d8zUsqH8wVabgwENM4R1knOIDeWV0OdEkeSYsJ3QJMC0sE8QVSsUwVmUu8/PXIcSMeixdjMUETtw== tarball: 'file:projects/app-configuration.tgz' version: 0.0.0 'file:projects/core-amqp.tgz': @@ -10924,7 +10931,7 @@ packages: dev: false name: '@rush-temp/core-amqp' resolution: - integrity: sha512-DasjGL3VvHyphyi0JX91olVAdiOce2XvrjiDAfj9ubz1GkolMFvaNr4zh2MAW/KRzpk4RjJxbHSJcr3NnJxUvg== + integrity: sha512-O8f70NJBk7/6mhI083dWNWnXFzNOvCGoQWSs+6d/FYbSDNiCRSwgTnZ6ZeEUAL7FbPWOCcEfeqlZsDz9CSE4zA== tarball: 'file:projects/core-amqp.tgz' version: 0.0.0 'file:projects/core-arm.tgz': @@ -10959,7 +10966,7 @@ packages: dev: false name: '@rush-temp/core-arm' resolution: - integrity: sha512-CUyFXyNU8RXwK7x40YPYiqbXLI++JBNuUBKUvLtGOaoe53QhyCr8ehLXWdgPmoz689vNApf0JLcyxFVlthNzbA== + integrity: sha512-YLO+Lu8+QdbGXNectrQzC9OCK5HlWogISjARKZSp+sU5/qxtkPpogIJUOctgReTgx3yK4bh/wNBegLsYeXVxvg== tarball: 'file:projects/core-arm.tgz' version: 0.0.0 'file:projects/core-asynciterator-polyfill.tgz': @@ -10977,7 +10984,7 @@ packages: dev: false name: '@rush-temp/core-asynciterator-polyfill' resolution: - integrity: sha512-hp2FjyoaLo9iJIGV0Aq7UI8oGzIr29OewVSFfuckKI+2aDUrh6Kamlg/hw/HrZ/a3ybccP3oqGjwA2uze4DoAg== + integrity: sha512-X2qR67x/Wgwcs8VjH/m3EA7HFB22mL2sf9YJCvpdIUXvz5ENGH54U4TC8IAc2AxcqlKjOi1pwFUAf9yBf4nAJQ== tarball: 'file:projects/core-asynciterator-polyfill.tgz' version: 0.0.0 'file:projects/core-auth.tgz': @@ -11016,7 +11023,7 @@ packages: dev: false name: '@rush-temp/core-auth' resolution: - integrity: sha512-OP2+mfrkgls9JxdoKEagMyvsoOujHFoTpzMYpMEsezWb5UgOIkl4et7bu+pR+/rffT8kwI+0KKBy2t+tyWqk/A== + integrity: sha512-fGVgepFqWjAN5Jxlf/YAE7xElRuGy+mDk84yEv/crX+dj98rAbn9QF/tNdY7/06xHwTI1E5cLvPjNISYrLbb4g== tarball: 'file:projects/core-auth.tgz' version: 0.0.0 'file:projects/core-http.tgz': @@ -11100,7 +11107,7 @@ packages: dev: false name: '@rush-temp/core-http' resolution: - integrity: sha512-q5149bZS7h72W5USm3WrFB+QgNYWsFkMScREv3O+KKyWlmVFO6Ok5jssD/aCSfxsn42YPO8S0KlDS7EcTtK1iQ== + integrity: sha512-jt66TiGDt85L2XM2Y2Q+vDtH/blz78d9VJUdh69a978GE3/vX+ihg1K+8Aways3d92reH48ksAbQU7RvyprgWA== tarball: 'file:projects/core-http.tgz' version: 0.0.0 'file:projects/core-paging.tgz': @@ -11119,13 +11126,14 @@ packages: dev: false name: '@rush-temp/core-paging' resolution: - integrity: sha512-rorSx6Oeq/VsKWv3L8qwnHYihYjPZS/PiCZZrIlGt7WfSH8iS60XFPxRrAiP+zIhosvd1hDlSmQ8k30iIB10QA== + integrity: sha512-/l5SA2u/jUrYjvQBf24YFdaoYW4GAdU3iDoGDekLbjH2fSP8wOt/3oDlBM8pxGD54TB7s06Oi4OjBsQN6F5tgw== tarball: 'file:projects/core-paging.tgz' version: 0.0.0 'file:projects/core-tracing.tgz': dependencies: '@azure/eslint-plugin-azure-sdk': 2.0.1_9e8391ca70fb0408a9da4393803aa477 '@microsoft/api-extractor': 7.3.8 + '@opencensus/web-types': 0.0.7 '@types/mocha': 5.2.7 '@types/node': 8.10.52 '@typescript-eslint/eslint-plugin': 2.0.0_3cafee28902d96627d4743e014bc28ff @@ -11158,7 +11166,7 @@ packages: dev: false name: '@rush-temp/core-tracing' resolution: - integrity: sha512-tJ58I97IAcVA5vJsvMt2Oqze5/2n5B1dXGuPEhiySXgry2kGNeOF64ZVUlGHPPT2Zsvpst+f9K/Y0SXusToWPg== + integrity: sha512-ojfEOrDyO28XqPLPsjFRR/XgiI56Ud1b9ne+DwGE8j54pEVZAMR8vMfk392tNuFqzYnwb2tYl3dZ/ILBDZNVZA== tarball: 'file:projects/core-tracing.tgz' version: 0.0.0 'file:projects/cosmos.tgz_webpack@4.39.2': @@ -11234,7 +11242,7 @@ packages: peerDependencies: webpack: '*' resolution: - integrity: sha512-hJJjJj86BUBSS228e9VU4XteZDdYMSqrPOGC+woAZvpX6dfwyZbZSfKAscourcyo9RaWeFZjP9aPCeibqmuzqA== + integrity: sha512-ZwEE+b0Q+iECvIe11mgtneZ3N4YBla/dWW9WYTtHP2AIwUfc7CIVtRLhwHi/KW5tzJHGK54qvDUnz4pXXJOPHQ== tarball: 'file:projects/cosmos.tgz' version: 0.0.0 'file:projects/event-hubs.tgz': @@ -11311,7 +11319,7 @@ packages: dev: false name: '@rush-temp/event-hubs' resolution: - integrity: sha512-j/OY8KHU0zD+bWlRhK5yp711OcS7oQYsRNmELlYAeishEnoPeWE+2mm104Ck2osCQa1w2HcYIqs9NJD9TSQzqA== + integrity: sha512-q+ihScahg5y1w7biapQHL6AYHh90dSPR85HcgxJBykkNQtHCPdJ2p7h0nnQmq5pKrovtJ/ufFpYF7H63+Sl13A== tarball: 'file:projects/event-hubs.tgz' version: 0.0.0 'file:projects/event-processor-host.tgz': @@ -11369,7 +11377,7 @@ packages: dev: false name: '@rush-temp/event-processor-host' resolution: - integrity: sha512-7Qk5AOasHTZrxBj7bDBlChwSFImEDSYG2yQJ4m6kdAKG6Byxg1OtL0ojBzf74UK1R4A+Bqz66pjBnhbI0MT6kA== + integrity: sha512-W3yvQ/XpiLD0NxwDCHy8iuOnHcMAQDH0f9g336udX3pgtjhcxwjRVcUzuOK+u5e1At95pTE/LMFJoDFeJGvIrQ== tarball: 'file:projects/event-processor-host.tgz' version: 0.0.0 'file:projects/eventhubs-checkpointstore-blob.tgz': @@ -11432,7 +11440,7 @@ packages: dev: false name: '@rush-temp/eventhubs-checkpointstore-blob' resolution: - integrity: sha512-hoS0oalZm7WOQ3YNGBakiuzU+zGVjAJHAaUSR5RiazFPaBMYmnbwr4epZXQRFi0FOEz5oDw+fhaoCZVi9rJYLQ== + integrity: sha512-fA1airUTMv4LAmlMLTyvSHSkMnWeuQ5u9d4AHuE2RSNEILob7WG5sF09RjNikbJkYMKNLNXO9cZHxEKlrCkm4w== tarball: 'file:projects/eventhubs-checkpointstore-blob.tgz' version: 0.0.0 'file:projects/identity.tgz': @@ -11484,7 +11492,7 @@ packages: dev: false name: '@rush-temp/identity' resolution: - integrity: sha512-bVFvN9S6o3c3YHXwiTDfwRhXIIYxh3i5qvYhPOJlLVTsmHgsmmQjx0hiF3cE4JayFN91MHtMDJw3pu5BmkovNw== + integrity: sha512-yITMvnD9EnzaWxVx7KrQhQ7BftiFe8/i3ykh/ZUi5V8TBOcIhMEYwd3vFoahVqO1TJdo7TCv5KW9+WpKRAByYA== tarball: 'file:projects/identity.tgz' version: 0.0.0 'file:projects/keyvault-certificates.tgz': @@ -11553,7 +11561,7 @@ packages: dev: false name: '@rush-temp/keyvault-certificates' resolution: - integrity: sha512-0VO+0a4YgpvmpSb4BjjcBTCmjwg7j22kHrasZWWnbeKbQp9CzguDgknIYwd5l4gh9fRMjFWtPS9b7UuB4Wx4lw== + integrity: sha512-EFiXgxOsM7nzGDpo24dwAFj3NB9iVcnlYLg2zRasrIHdgnMyvvg2X0RD2yOMQyL/q26nqnS+9CWjbREXFsOvGQ== tarball: 'file:projects/keyvault-certificates.tgz' version: 0.0.0 'file:projects/keyvault-keys.tgz': @@ -11622,7 +11630,7 @@ packages: dev: false name: '@rush-temp/keyvault-keys' resolution: - integrity: sha512-UJmV8ySBuvZ9KrQDtZrIxojC5d7P41qemrY9ichk08lXfmBc5bRJFlcMLE+Sld32FX4AKaSjPXZt4wCgzT1dww== + integrity: sha512-+TRnDu0gtivqdc1ccO+PD/1IaljLNQe7v7WsnE5c1Mvl2Bvd1kiCswQpdBPrjTtJBLCfMCfDzelUh4e9FdyNnA== tarball: 'file:projects/keyvault-keys.tgz' version: 0.0.0 'file:projects/keyvault-secrets.tgz': @@ -11690,7 +11698,7 @@ packages: dev: false name: '@rush-temp/keyvault-secrets' resolution: - integrity: sha512-VfTsDKuJ1iaGdchDP4rF/1HXNW/g4QtjWNhoVvA6rlJetUn6Teyh5Eb5E52Vauqte57kS6m7qLYP/k92UfwGGA== + integrity: sha512-BqXds/rjlQUgSVasBkrSTvio8GOQlFlhqQH8wM42OThTLBZvIkdnjoO3wg2+A1geTLQIhhir5dnysg2Xy1oDzQ== tarball: 'file:projects/keyvault-secrets.tgz' version: 0.0.0 'file:projects/service-bus.tgz': @@ -11768,7 +11776,7 @@ packages: dev: false name: '@rush-temp/service-bus' resolution: - integrity: sha512-WK1TJTyv7aW0B14SCUbdDtgvrRYbV6zAyT63ZjEPJlezoFP6iYdKxRveDwpHkfHldBbZbgqf883PoVhLhsOJ5Q== + integrity: sha512-ryJ2md8Uy9qpyw/Wwh7Uj2TdODtlj/+6siOqLM2alXJfm8xmqM7pURTR6iVwBiEHY/azhaYFfiMOfZYd3QEKow== tarball: 'file:projects/service-bus.tgz' version: 0.0.0 'file:projects/storage-blob.tgz': @@ -11838,7 +11846,7 @@ packages: dev: false name: '@rush-temp/storage-blob' resolution: - integrity: sha512-76kxW4mT5QbNSGd1oOkcZxqa2ZoZYn5E8LSoui/rWtH3tX1i0lCT/FJhSgcnOQXYMM56Gdno8AqEI5CT9dFRmg== + integrity: sha512-6JJFDGUj5AY8R/wStkv05OdRkLSE05ZPbX03uIJefY4QTxdtaqyCi5s+2lrxbuxE9UGduVSnlB3qh0tgdH2Jhw== tarball: 'file:projects/storage-blob.tgz' version: 0.0.0 'file:projects/storage-file.tgz': @@ -11908,7 +11916,7 @@ packages: dev: false name: '@rush-temp/storage-file' resolution: - integrity: sha512-1vuu96rlT8OLbWybGYkV7wXK2iRYEAg9JBdTFS2VbcYWztw2/L5gXM/HrRrnDN891SpDW1KsHNng0oj880UL/Q== + integrity: sha512-Ss14Pm4zCFh4fqOHc2QzsbpTFHkuqkZo+qVXASJvsE7sqzuqFg+W09M2D+uT23k45l44d+x5G5D1dyg1OWmjwA== tarball: 'file:projects/storage-file.tgz' version: 0.0.0 'file:projects/storage-queue.tgz': @@ -11977,7 +11985,7 @@ packages: dev: false name: '@rush-temp/storage-queue' resolution: - integrity: sha512-Sva5UkbRrEXShOKLaZ4ALhk/2RdGETd4oKVAmgRmeo1CACidcSPDvHQC/MJhEgdmM/47YJLMOyKkP/mVSgZqjw== + integrity: sha512-xOXI5NLw/G1ylX0iLrbEsmmANf7/8l1yoKhZ9rcpcFVHj5Jnz0bXEU9RNHK12mAGYRanQ/AJK1HBOJoeNQk9CA== tarball: 'file:projects/storage-queue.tgz' version: 0.0.0 'file:projects/template.tgz': @@ -12027,7 +12035,7 @@ packages: dev: false name: '@rush-temp/template' resolution: - integrity: sha512-kVQvLrvxsA1WMbSQpOpcTQTIN0HwJKD9PvpY7ZONaZIKwgWTuUM2u0euzQMU4qYBkfvqrAiPSviNf99s2pFjQQ== + integrity: sha512-Mr5kH/fT37U2+FhWBOOteBh5HPN07yLkRD2MlYGQ1Y3z6sVRO9H9ruwnSeZXg5xxWvUNsQW77YVOqbgFRzavLQ== tarball: 'file:projects/template.tgz' version: 0.0.0 'file:projects/test-utils-recorder.tgz': @@ -12055,7 +12063,7 @@ packages: dev: false name: '@rush-temp/test-utils-recorder' resolution: - integrity: sha512-SJjlxlVlW3QPkHFCP+M3QSAgrlVC50hl/ePd/Xmfixx8pl4uiLwm/ZOMmzQ59IfM1zryQw55BNPv2qu5/1hJXA== + integrity: sha512-5X0CLSRbJrplwH5JFkcDlSfzxzFeT/veoYhb9NB+q2hTDd9rXRjwePn76IWcVBtUzq2siSgvgrSsioDYiXMUsw== tarball: 'file:projects/test-utils-recorder.tgz' version: 0.0.0 'file:projects/testhub.tgz': @@ -12076,7 +12084,7 @@ packages: dev: false name: '@rush-temp/testhub' resolution: - integrity: sha512-XZB/wnNqz04DCZBqyhzkkYG8c/XduwpKK8uJbRcnJrvTthx844ix8Cn3nDHaoLlxODmoxP4xosiCiKTIn7EuBw== + integrity: sha512-RkYcAmpRKuAXwbssMJGmc8uzm3LoQikdGvIqdwioQqURgLagimtd01yH+757XDMvMyOfVwejTTSCZHpqa2Bf6Q== tarball: 'file:projects/testhub.tgz' version: 0.0.0 registry: '' @@ -12092,6 +12100,7 @@ specifiers: '@azure/ms-rest-nodeauth': ^0.9.2 '@azure/storage-blob': 12.0.0-preview.3 '@microsoft/api-extractor': ^7.1.5 + '@opencensus/web-types': 0.0.7 '@rush-temp/abort-controller': 'file:./projects/abort-controller.tgz' '@rush-temp/app-configuration': 'file:./projects/app-configuration.tgz' '@rush-temp/core-amqp': 'file:./projects/core-amqp.tgz' diff --git a/sdk/core/core-http/lib/webResource.ts b/sdk/core/core-http/lib/webResource.ts index 3688eb2adbb2..78fda083bab8 100644 --- a/sdk/core/core-http/lib/webResource.ts +++ b/sdk/core/core-http/lib/webResource.ts @@ -9,6 +9,7 @@ import { HttpOperationResponse } from "./httpOperationResponse"; import { OperationResponse } from "./operationResponse"; import { ProxySettings } from "./serviceClient"; import { AbortSignalLike } from "@azure/abort-controller"; +import { SpanOptions } from "@azure/core-tracing"; export type HttpMethods = | "GET" @@ -86,7 +87,7 @@ export class WebResource { /** * Options used to create a span when tracing is enabled. */ - spanOptions?: any; + spanOptions?: SpanOptions; constructor( url?: string, @@ -174,9 +175,9 @@ export class WebResource { if (validMethods.indexOf(options.method.toUpperCase()) === -1) { throw new Error( 'The provided method "' + - options.method + - '" is invalid. Supported HTTP methods are: ' + - JSON.stringify(validMethods) + options.method + + '" is invalid. Supported HTTP methods are: ' + + JSON.stringify(validMethods) ); } } @@ -203,7 +204,7 @@ export class WebResource { `pathTemplate: ${pathTemplate} has been provided. Hence, options.pathParameters must also be provided.` ); } - segments.forEach(function(item) { + segments.forEach(function (item) { const pathParamName = item.slice(1, -1); const pathParam = (pathParameters as { [key: string]: any })[pathParamName]; if ( @@ -214,9 +215,9 @@ export class WebResource { const stringifiedPathParameters = JSON.stringify(pathParameters, undefined, 2); throw new Error( `pathTemplate: ${pathTemplate} contains the path parameter ${pathParamName}` + - ` however, it is not present in parameters: ${stringifiedPathParameters}.` + - `The value of the path parameter can either be a "string" of the form { ${pathParamName}: "some sample value" } or ` + - `it can be an "object" of the form { "${pathParamName}": { value: "some sample value", skipUrlEncoding: true } }.` + ` however, it is not present in parameters: ${stringifiedPathParameters}.` + + `The value of the path parameter can either be a "string" of the form { ${pathParamName}: "some sample value" } or ` + + `it can be an "object" of the form { "${pathParamName}": { value: "some sample value", skipUrlEncoding: true } }.` ); } @@ -247,8 +248,8 @@ export class WebResource { if (typeof queryParameters !== "object") { throw new Error( `options.queryParameters must be of type object. It should be a JSON object ` + - `of "query-parameter-name" as the key and the "query-parameter-value" as the value. ` + - `The "query-parameter-value" may be fo type "string" or an "object" of the form { value: "query-parameter-value", skipUrlEncoding: true }.` + `of "query-parameter-name" as the key and the "query-parameter-value" as the value. ` + + `The "query-parameter-value" may be fo type "string" or an "object" of the form { value: "query-parameter-value", skipUrlEncoding: true }.` ); } // append question mark if it is not present in the url @@ -511,7 +512,7 @@ export interface RequestOptionsBase { /** * Options used to create a span when tracing is enabled. */ - spanOptions?: any; + spanOptions?: SpanOptions; [key: string]: any; } diff --git a/sdk/core/core-http/test/policies/tracingPolicyTests.ts b/sdk/core/core-http/test/policies/tracingPolicyTests.ts index 3cb6bd6ca4f3..3a110889b44c 100644 --- a/sdk/core/core-http/test/policies/tracingPolicyTests.ts +++ b/sdk/core/core-http/test/policies/tracingPolicyTests.ts @@ -2,68 +2,75 @@ // Licensed under the MIT License. import { assert } from "chai"; -import sinon from "sinon"; -import { RequestPolicy, WebResource, HttpOperationResponse, HttpHeaders, Plugin, Span, TracerProxy, RequestPolicyOptions, TraceFlags, NoOpTracePlugin, TracerNoOpImpl } from "../../lib/coreHttp"; +import { RequestPolicy, WebResource, HttpOperationResponse, HttpHeaders, TracerProxy, RequestPolicyOptions, TraceFlags, NoOpTracer, SpanOptions, SpanContext, NoOpSpan } from "../../lib/coreHttp"; import { tracingPolicy } from "../../lib/policies/tracingPolicy"; -interface MockTracer extends Plugin { - getStartedSpans(): any[]; - startSpanCalled(): boolean; -} +class MockSpan extends NoOpSpan { + private _endCalled = false; -describe("tracingPolicy", function () { - function mockTracerFactory( - traceId?: string, - spanId?: string, - flags?: TraceFlags, - state?: string - ): MockTracer { - let startedSpan = false; - const spans: any[] = []; + constructor(private traceId: string, private spanId: string, private flags: TraceFlags, private state: string) { + super(); + } + + didEnd() { + return this._endCalled; + } + + end() { + this._endCalled = true; + } + + context(): SpanContext { + const state = this.state; return { - // helper method for testing - getStartedSpans() { - return spans; - }, - // helper method for testing - startSpanCalled() { - return startedSpan; - }, - startSpan() { - startedSpan = true; - let ended = false; - const mockSpan = { - didEnd() { - return ended; - }, - end() { - ended = true; - }, - context() { - return { - traceId, - spanId, - traceFlags: flags, - traceState: { - set(_key: string, _value: string) { - }, - unset(_key: string) { - }, - get(_key: string): string | undefined { - return; - }, - serialize() { - return state; - } - } - } - } - }; - spans.push(mockSpan); - return mockSpan as Partial; + traceId: this.traceId, + spanId: this.spanId, + traceFlags: this.flags, + traceState: { + set(_key: string, _value: string) { + }, + unset(_key: string) { + }, + get(_key: string): string | undefined { + return; + }, + serialize() { + return state; + } } - } as any; + } } +} + +class MockTracer extends NoOpTracer { + + private spans: MockSpan[] = []; + private _startSpanCalled = false; + + constructor(private traceId = "", private spanId = "", private flags = TraceFlags.UNSAMPLED, private state = "") { + super(); + } + + getStartedSpans() { + return this.spans; + } + + startSpanCalled() { + return this._startSpanCalled; + } + + startSpan(_name: string, _options?: SpanOptions): MockSpan { + this._startSpanCalled = true; + const span = new MockSpan(this.traceId, this.spanId, this.flags, this.state); + this.spans.push(span); + return span; + } +} + +const ROOT_SPAN = new MockSpan("root", "root", TraceFlags.SAMPLED, ""); + +describe("tracingPolicy", function () { + const mockPolicy: RequestPolicy = { sendRequest(request: WebResource): Promise { return Promise.resolve({ @@ -74,17 +81,9 @@ describe("tracingPolicy", function () { } }; - afterEach(function () { - if (typeof (TracerProxy.getTracer as sinon.SinonStub).restore === "function") { - (TracerProxy.getTracer as sinon.SinonStub).restore(); - } - }); - it("will not create a span if spanOptions are missing", async () => { - const mockTracer = mockTracerFactory(); - sinon.stub(TracerProxy, "getTracer").callsFake(() => { - return mockTracer; - }); + const mockTracer = new MockTracer(); + TracerProxy.setTracer(mockTracer); const request = new WebResource(); const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions()); await policy.sendRequest(request); @@ -95,13 +94,11 @@ describe("tracingPolicy", function () { it("will create a span and correctly set trace headers if spanOptions are available", async () => { const mockTraceId = "11111111111111111111111111111111"; const mockSpanId = "2222222222222222"; - const mockTracer = mockTracerFactory(mockTraceId, mockSpanId, TraceFlags.SAMPLED); - sinon.stub(TracerProxy, "getTracer").callsFake(() => { - return mockTracer; - }); + const mockTracer = new MockTracer(mockTraceId, mockSpanId, TraceFlags.SAMPLED); + TracerProxy.setTracer(mockTracer); const request = new WebResource(); request.spanOptions = { - parent: {} // stub a parent since we aren't testing the startSpan method + parent: ROOT_SPAN }; const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions()); await policy.sendRequest(request); @@ -119,13 +116,11 @@ describe("tracingPolicy", function () { const mockTraceId = "11111111111111111111111111111111"; const mockSpanId = "2222222222222222"; // leave out the TraceOptions - const mockTracer = mockTracerFactory(mockTraceId, mockSpanId); - sinon.stub(TracerProxy, "getTracer").callsFake(() => { - return mockTracer; - }); + const mockTracer = new MockTracer(mockTraceId, mockSpanId); + TracerProxy.setTracer(mockTracer); const request = new WebResource(); request.spanOptions = { - parent: {} // stub a parent since we aren't testing the startSpan method + parent: ROOT_SPAN }; const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions()); await policy.sendRequest(request); @@ -143,13 +138,11 @@ describe("tracingPolicy", function () { const mockTraceId = "11111111111111111111111111111111"; const mockSpanId = "2222222222222222"; const mockTraceState = "foo=bar"; - const mockTracer = mockTracerFactory(mockTraceId, mockSpanId, TraceFlags.SAMPLED, mockTraceState); - sinon.stub(TracerProxy, "getTracer").callsFake(() => { - return mockTracer; - }); + const mockTracer = new MockTracer(mockTraceId, mockSpanId, TraceFlags.SAMPLED, mockTraceState); + TracerProxy.setTracer(mockTracer); const request = new WebResource(); request.spanOptions = { - parent: {} // stub a parent since we aren't testing the startSpan method + parent: ROOT_SPAN }; const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions()); await policy.sendRequest(request); @@ -167,13 +160,11 @@ describe("tracingPolicy", function () { const mockTraceId = "11111111111111111111111111111111"; const mockSpanId = "2222222222222222"; const mockTraceState = "foo=bar"; - const mockTracer = mockTracerFactory(mockTraceId, mockSpanId, TraceFlags.SAMPLED, mockTraceState); - sinon.stub(TracerProxy, "getTracer").callsFake(() => { - return mockTracer; - }); + const mockTracer = new MockTracer(mockTraceId, mockSpanId, TraceFlags.SAMPLED, mockTraceState); + TracerProxy.setTracer(mockTracer); const request = new WebResource(); request.spanOptions = { - parent: {} // stub a parent since we aren't testing the startSpan method + parent: ROOT_SPAN }; const policy = tracingPolicy().create({ sendRequest(request: WebResource): Promise { @@ -200,13 +191,10 @@ describe("tracingPolicy", function () { }); it("will not set headers if span is a NoOpSpan", async () => { - sinon.stub(TracerProxy, "getTracer").callsFake(() => { - return new NoOpTracePlugin(new TracerNoOpImpl()); - }); - + TracerProxy.setTracer(new NoOpTracer()); const request = new WebResource(); request.spanOptions = { - parent: {} // stub a parent since we aren't testing the startSpan method + parent: ROOT_SPAN }; const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions()); await policy.sendRequest(request); diff --git a/sdk/core/core-tracing/lib/implementations/noop/spanNoOpImpl.ts b/sdk/core/core-tracing/lib/implementations/noop/spanNoOpImpl.ts deleted file mode 100644 index 999134e1f394..000000000000 --- a/sdk/core/core-tracing/lib/implementations/noop/spanNoOpImpl.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -import { Span } from "../../interfaces/span"; -import { SpanContext } from "../../interfaces/span_context"; -import { Attributes } from "../../interfaces/attributes"; -import { Status } from "../../interfaces/status"; - -export class SpanNoOpImpl implements Span { - context(): SpanContext { - throw new Error("Method not implemented."); - } - setAttribute(key: string, value: unknown): this { - throw new Error("Method not implemented."); - } - setAttributes(attributes: Attributes): this { - throw new Error("Method not implemented."); - } - addEvent(name: string, attributes?: Attributes | undefined): this { - throw new Error("Method not implemented."); - } - addLink(spanContext: SpanContext, attributes?: Attributes | undefined): this { - throw new Error("Method not implemented."); - } - setStatus(status: Status): this { - throw new Error("Method not implemented."); - } - updateName(name: string): this { - throw new Error("Method not implemented."); - } - start(startTime?: number): void { } - end(endTime?: number): void { } - isRecordingEvents(): boolean { - throw new Error("Method not implemented."); - } -} diff --git a/sdk/core/core-tracing/lib/implementations/noop/tracerNoOpImpl.ts b/sdk/core/core-tracing/lib/implementations/noop/tracerNoOpImpl.ts deleted file mode 100644 index e528b1ee8b14..000000000000 --- a/sdk/core/core-tracing/lib/implementations/noop/tracerNoOpImpl.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -import { Tracer } from "../../interfaces/tracer"; -import { SpanOptions } from "../../interfaces/SpanOptions"; -import { Span } from "../../interfaces/span"; -import { SpanNoOpImpl } from "./spanNoOpImpl"; -import { SupportedPlugins } from '../../utils/supportedPlugins'; -import { BinaryFormat } from "../../interfaces/BinaryFormat"; -import { HttpTextFormat } from "../../interfaces/HttpTextFormat"; - -export class TracerNoOpImpl implements Tracer { - public readonly pluginType = SupportedPlugins.NOOP; - - getCurrentSpan(): Span { - throw new Error("Method not implemented."); - } - startSpan(name: string, options?: SpanOptions | undefined): Span { - return new SpanNoOpImpl(); - } - withSpan unknown>(span: Span, fn: T): ReturnType { - throw new Error("Method not implemented."); - } - bind(target: T, span?: Span): T { - throw new Error("Method not implemented."); - } - recordSpanData(span: Span): void { - throw new Error("Method not implemented."); - } - getBinaryFormat(): BinaryFormat { - throw new Error("Method not implemented."); - } - getHttpTextFormat(): HttpTextFormat { - throw new Error("Method not implemented."); - } -} diff --git a/sdk/core/core-tracing/lib/index.ts b/sdk/core/core-tracing/lib/index.ts index 9e7823a910d5..99a4a5ae3d5c 100644 --- a/sdk/core/core-tracing/lib/index.ts +++ b/sdk/core/core-tracing/lib/index.ts @@ -1,19 +1,23 @@ + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -export { TracerProxy } from "./tracerProxy"; - -// Utils -export { SupportedPlugins } from "./utils/supportedPlugins"; -// Plugins -export { NoOpSpanPlugin } from "./plugins/noop/noOpSpanPlugin"; -export { NoOpTracePlugin } from "./plugins/noop/noOpTracePlugin"; -export { OpenCensusSpanPlugin } from "./plugins/opencensus/openCensusSpanPlugin"; -export { OpenCensusTracePlugin } from "./plugins/opencensus/openCensusTracePlugin"; +import { getTracer, setTracer, ITracerProxy } from "./tracerProxy"; +/** + * A global registry for the active OpenTelemtry Tracer. + * Clients inside the Azure SDK will use this Tracer for all trace logging. + */ +const TracerProxy: ITracerProxy = { + getTracer, + setTracer, +}; +export { TracerProxy, ITracerProxy }; -// Implementations -export { SpanNoOpImpl } from "./implementations/noop/spanNoOpImpl"; -export { TracerNoOpImpl } from "./implementations/noop/tracerNoOpImpl"; +// Wrappers +export { NoOpSpan } from "./wrappers/noop/noOpSpan"; +export { NoOpTracer } from "./wrappers/noop/noOpTracer"; +export { OpenCensusSpanWrapper } from "./wrappers/opencensus/openCensusSpanWrapper"; +export { OpenCensusTracerWrapper } from "./wrappers/opencensus/openCensusTracerWrapper"; // Interfaces export { Attributes } from "./interfaces/attributes"; @@ -21,7 +25,6 @@ export { BinaryFormat } from "./interfaces/BinaryFormat"; export { Event } from "./interfaces/Event"; export { HttpTextFormat } from "./interfaces/HttpTextFormat"; export { Link } from "./interfaces/link"; -export { Plugin } from "./interfaces/plugin"; export { Sampler } from "./interfaces/Sampler"; export { SpanContext } from "./interfaces/span_context"; export { SpanKind } from "./interfaces/span_kind"; @@ -33,3 +36,9 @@ export { TimedEvent } from "./interfaces/TimedEvent"; export { TraceFlags } from "./interfaces/trace_flags"; export { TraceState } from "./interfaces/trace_state"; export { Tracer } from "./interfaces/tracer"; + +// OpenCensus Interfaces +export { + Tracer as OpenCensusTracer, + Span as OpenCensusSpan, +} from "@opencensus/web-types"; diff --git a/sdk/core/core-tracing/lib/interfaces/TimedEvent.ts b/sdk/core/core-tracing/lib/interfaces/TimedEvent.ts index f87f607d363c..71ac3ed46b9d 100644 --- a/sdk/core/core-tracing/lib/interfaces/TimedEvent.ts +++ b/sdk/core/core-tracing/lib/interfaces/TimedEvent.ts @@ -22,5 +22,8 @@ import { HrTime } from './Time'; * A timed event is an event with a timestamp. */ export interface TimedEvent extends Event { + /** + * High resolution timestamp. + */ time: HrTime; } diff --git a/sdk/core/core-tracing/lib/interfaces/attributes.ts b/sdk/core/core-tracing/lib/interfaces/attributes.ts index 188b1e574a15..67fdc4c96498 100644 --- a/sdk/core/core-tracing/lib/interfaces/attributes.ts +++ b/sdk/core/core-tracing/lib/interfaces/attributes.ts @@ -16,5 +16,8 @@ /** Defines a attributes interface. */ export interface Attributes { + /** + * Known attributes. + */ [attributeKey: string]: unknown; } diff --git a/sdk/core/core-tracing/lib/interfaces/plugin.ts b/sdk/core/core-tracing/lib/interfaces/plugin.ts deleted file mode 100644 index 5794e471373c..000000000000 --- a/sdk/core/core-tracing/lib/interfaces/plugin.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { Tracer } from "./tracer"; -import { SupportedPlugins } from "../utils/supportedPlugins"; - -export interface Plugin extends Tracer { - /** - * Returns the type of the plugin being used by the tracer. - * @returns the type of the plugin being used by the tracer. - */ - readonly pluginType: SupportedPlugins; -} diff --git a/sdk/core/core-tracing/lib/plugins/noop/noOpSpanPlugin.ts b/sdk/core/core-tracing/lib/plugins/noop/noOpSpanPlugin.ts deleted file mode 100644 index a6b88239ae2f..000000000000 --- a/sdk/core/core-tracing/lib/plugins/noop/noOpSpanPlugin.ts +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -import { Span } from "../../interfaces/span"; -import { SpanContext } from "../../interfaces/span_context"; -import { Attributes } from "../../interfaces/attributes"; -import { Status } from "../../interfaces/status"; - -export class NoOpSpanPlugin implements Span { - private _span: any; - - constructor(span: any) { - this._span = span; - } - - context(): SpanContext { - return { - spanId: "", - traceId: "" - }; - } - - end(endTime?: number): void { - this._span.end(endTime); - } - - start(startTime?: number): void { - this._span.start(startTime); - } - - setAttribute(key: string, value: unknown): this { - throw new Error("Method not implemented."); - } - - setAttributes(attributes: Attributes): this { - throw new Error("Method not implemented."); - } - - addEvent(name: string, attributes?: Attributes): this { - throw new Error("Method not implemented."); - } - - addLink(spanContext: SpanContext, attributes?: Attributes): this { - throw new Error("Method not implemented."); - } - - setStatus(status: Status): this { - throw new Error("Method not implemented."); - } - - updateName(name: string): this { - throw new Error("Method not implemented."); - } - - isRecordingEvents(): boolean { - throw new Error("Method not implemented."); - } -} diff --git a/sdk/core/core-tracing/lib/plugins/noop/noOpTracePlugin.ts b/sdk/core/core-tracing/lib/plugins/noop/noOpTracePlugin.ts deleted file mode 100644 index 465070dee17c..000000000000 --- a/sdk/core/core-tracing/lib/plugins/noop/noOpTracePlugin.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -import { Tracer } from "../../interfaces/tracer"; -import { Span } from "../../interfaces/span"; -import { SpanOptions } from "../../interfaces/SpanOptions"; -import { NoOpSpanPlugin } from "./noOpSpanPlugin"; -import { SpanNoOpImpl } from "../../implementations/noop/spanNoOpImpl"; -import { SupportedPlugins } from '../../utils/supportedPlugins'; -import { BinaryFormat } from "../../interfaces/BinaryFormat"; -import { HttpTextFormat } from "../../interfaces/HttpTextFormat"; - -export class NoOpTracePlugin implements Tracer { - private _tracer: any; - - public constructor(tracer: any) { - this._tracer = tracer; - } - - public readonly pluginType = SupportedPlugins.NOOP; - - startSpan(name: string, options?: SpanOptions): Span { - const span = new SpanNoOpImpl(); - const noOpSpanPlugin = new NoOpSpanPlugin(span); - return noOpSpanPlugin; - } - - getCurrentSpan(): Span { - throw new Error("Method not implemented."); - } - withSpan unknown>(span: Span, fn: T): ReturnType { - throw new Error("Method not implemented."); - } - bind(target: T, span?: Span): T { - throw new Error("Method not implemented."); - } - recordSpanData(span: Span): void { - throw new Error("Method not implemented."); - } - getBinaryFormat(): BinaryFormat { - throw new Error("Method not implemented."); - } - getHttpTextFormat(): HttpTextFormat { - throw new Error("Method not implemented."); - } -} diff --git a/sdk/core/core-tracing/lib/plugins/opencensus/openCensusSpanPlugin.ts b/sdk/core/core-tracing/lib/plugins/opencensus/openCensusSpanPlugin.ts deleted file mode 100644 index c7ec291cdb23..000000000000 --- a/sdk/core/core-tracing/lib/plugins/opencensus/openCensusSpanPlugin.ts +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -import { Span } from "../../interfaces/span"; -import { SpanContext } from "../../interfaces/span_context"; -import { Attributes } from "../../interfaces/attributes"; -import { Status } from "../../interfaces/status"; -import { OpenCensusTraceStatePlugin } from "./openCensusTraceStatePlugin"; -import { SpanOptions } from "../../interfaces/SpanOptions"; -import { OpenCensusTracePlugin } from "./openCensusTracePlugin"; - -function isWrappedSpan(span: Span | SpanContext): span is OpenCensusSpanPlugin { - return (span as OpenCensusSpanPlugin).getWrappedSpan !== undefined; -} - -export class OpenCensusSpanPlugin implements Span { - private _span: any; - - public getWrappedSpan() { - return this._span; - } - - constructor(tracer: OpenCensusTracePlugin, name: string, options: SpanOptions = {}) { - const parent = options.parent - ? isWrappedSpan(options.parent) - ? options.parent.getWrappedSpan() - : options.parent - : undefined; - - this._span = tracer.getWrappedTracer().startChildSpan({ - name: name, - childOf: parent - }); - this._span.start(options.startTime); - } - - end(endTime?: number): void { - this._span.end(endTime); - } - - context(): SpanContext { - const openCensusSpanContext = this._span.spanContext; - - return { - spanId: openCensusSpanContext.spanId, - traceId: openCensusSpanContext.traceId, - traceFlags: openCensusSpanContext.options, - traceState: new OpenCensusTraceStatePlugin(openCensusSpanContext.traceState) - }; - } - - setAttribute(key: string, value: unknown): this { - this._span.addAttribute(key, value); - return this; - } - - setAttributes(attributes: Attributes): this { - throw new Error("Method not implemented."); - } - - addEvent(name: string, attributes?: Attributes): this { - throw new Error("Method not implemented."); - } - - addLink(spanContext: SpanContext, attributes?: Attributes): this { - // Since there is no way to specify the link relationship - // It is set as Unspecified = 0 - this._span.addLink(spanContext.traceId, spanContext.spanId, 0, attributes); - return this; - } - - setStatus(status: Status): this { - this._span.setStatus(status.code, status.message); - return this; - } - - updateName(name: string): this { - throw new Error("Method not implemented."); - } - - isRecordingEvents(): boolean { - throw new Error("Method not implemented."); - } -} diff --git a/sdk/core/core-tracing/lib/plugins/opencensus/openCensusTracePlugin.ts b/sdk/core/core-tracing/lib/plugins/opencensus/openCensusTracePlugin.ts deleted file mode 100644 index dd51970e6dca..000000000000 --- a/sdk/core/core-tracing/lib/plugins/opencensus/openCensusTracePlugin.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -import { Tracer } from "../../interfaces/tracer"; -import { SpanOptions } from "../../interfaces/SpanOptions"; -import { Span } from "../../interfaces/span"; -import { OpenCensusSpanPlugin } from "../opencensus/openCensusSpanPlugin"; -import { SupportedPlugins } from '../../utils/supportedPlugins'; -import { BinaryFormat } from "../../interfaces/BinaryFormat"; -import { HttpTextFormat } from "../../interfaces/HttpTextFormat"; - -export class OpenCensusTracePlugin implements Tracer { - private _tracer: any; - - public getWrappedTracer() { - return this._tracer; - } - - public constructor(tracer: any) { - this._tracer = tracer; - } - - public readonly pluginType = SupportedPlugins.OPENCENSUS; - - startSpan(name: string, options?: SpanOptions): Span { - const openCensusSpanPlugin = new OpenCensusSpanPlugin(this, name, options); - return openCensusSpanPlugin; - } - - getCurrentSpan(): Span { - throw new Error("Method not implemented."); - } - - withSpan unknown>(span: Span, fn: T): ReturnType { - throw new Error("Method not implemented."); - } - bind(target: T, span?: Span): T { - throw new Error("Method not implemented."); - } - recordSpanData(span: Span): void { - throw new Error("Method not implemented."); - } - getBinaryFormat(): BinaryFormat { - throw new Error("Method not implemented."); - } - getHttpTextFormat(): HttpTextFormat { - throw new Error("Method not implemented."); - } -} diff --git a/sdk/core/core-tracing/lib/tracerProxy.ts b/sdk/core/core-tracing/lib/tracerProxy.ts index 0f572f67156c..23b960fef228 100644 --- a/sdk/core/core-tracing/lib/tracerProxy.ts +++ b/sdk/core/core-tracing/lib/tracerProxy.ts @@ -1,28 +1,36 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { SupportedPlugins } from "./utils/supportedPlugins"; -import { OpenCensusTracePlugin } from "./plugins/opencensus/openCensusTracePlugin"; -import { NoOpTracePlugin } from "./plugins/noop/noOpTracePlugin"; -import { TracerNoOpImpl } from "./implementations/noop/tracerNoOpImpl"; -import { Plugin } from "./interfaces/plugin"; -export class TracerProxy { - private static _tracerPlugin: Plugin; +import { NoOpTracer } from "./wrappers/noop/noOpTracer"; +import { Tracer } from "./interfaces/tracer"; - private constructor() { } - public static setTracer(tracer: any, tracerPluginType: SupportedPlugins) { - if (tracerPluginType === SupportedPlugins.OPENCENSUS) { - TracerProxy._tracerPlugin = new OpenCensusTracePlugin(tracer); - } else { - TracerProxy._tracerPlugin = new NoOpTracePlugin(tracer); - } - } +let _tracerPlugin: Tracer; + +/** + * A global registry for the active OpenTelemtry Tracer. + * Clients inside the Azure SDK will use this Tracer for all trace logging. + */ +export interface ITracerProxy { + /** + * Sets the global tracer, enabling tracing. + * @param tracer An OpenTelemetry Tracer instance. + */ + setTracer(tracer: Tracer): void; + /** + * Retrieves the active tracer, or returns a + * no-op implementation if one is not set. + */ + getTracer(): Tracer; +} + +export function setTracer(tracer: Tracer) { + _tracerPlugin = tracer; +} - public static getTracer() { - if (!TracerProxy._tracerPlugin) { - TracerProxy._tracerPlugin = new NoOpTracePlugin(new TracerNoOpImpl()); - } - return TracerProxy._tracerPlugin; +export function getTracer() { + if (!_tracerPlugin) { + _tracerPlugin = new NoOpTracer(); } + return _tracerPlugin; } diff --git a/sdk/core/core-tracing/lib/utils/supportedPlugins.ts b/sdk/core/core-tracing/lib/utils/supportedPlugins.ts deleted file mode 100644 index 250262bffd66..000000000000 --- a/sdk/core/core-tracing/lib/utils/supportedPlugins.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -export enum SupportedPlugins { - OPENCENSUS, - NOOP -} diff --git a/sdk/core/core-tracing/lib/wrappers/noop/noOpBinaryFormat.ts b/sdk/core/core-tracing/lib/wrappers/noop/noOpBinaryFormat.ts new file mode 100644 index 000000000000..d35e6890ba23 --- /dev/null +++ b/sdk/core/core-tracing/lib/wrappers/noop/noOpBinaryFormat.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { BinaryFormat } from "../../interfaces/BinaryFormat"; +import { SpanContext } from "../../interfaces/span_context"; + +/** + * A no-op implementation of BinaryFormat to be used when tracing is disabled. + */ +export class NoOpBinaryFormat implements BinaryFormat { + /** Serialize the given SpanContext to a buffer */ + toBytes(_spanContext: SpanContext): ArrayBuffer { + return new ArrayBuffer(0); + } + + /** + * Deserialize a SpanContext from binary encoding. + * Returns null if the buffer does not contain a valid SpanContext. + */ + fromBytes(_buffer: ArrayBuffer): SpanContext | null { + return null; + } +} diff --git a/sdk/core/core-tracing/lib/wrappers/noop/noOpHttpTextFormat.ts b/sdk/core/core-tracing/lib/wrappers/noop/noOpHttpTextFormat.ts new file mode 100644 index 000000000000..e7288affbb94 --- /dev/null +++ b/sdk/core/core-tracing/lib/wrappers/noop/noOpHttpTextFormat.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { HttpTextFormat } from "../../interfaces/HttpTextFormat"; +import { SpanContext } from "../../interfaces/span_context"; + +/** + * A no-op implementation of HttpTextFormat to be used when tracing is disabled. + */ +export class NoOpHttpTextFormat implements HttpTextFormat { + /** + * Injects the given SpanContext for transmitting to a remote server. + * @param _spanContext The SpanContext to transmit + * @param _format The format of the carrier + * @param _carrier The carrier to propagate through, e.g. an HTTP request + */ + inject(_spanContext: SpanContext, _format: string, _carrier: unknown): void { } + /** + * Returns a SpanContext intance extracted from the carrier. + * @param _format the format of the carrier + * @param _carrier The carrier being used for propagation, e.g. an HTTP request + */ + extract(_format: string, _carrier: unknown): SpanContext | null { + return null; + } +} diff --git a/sdk/core/core-tracing/lib/wrappers/noop/noOpSpan.ts b/sdk/core/core-tracing/lib/wrappers/noop/noOpSpan.ts new file mode 100644 index 000000000000..7a53c1c673f6 --- /dev/null +++ b/sdk/core/core-tracing/lib/wrappers/noop/noOpSpan.ts @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { Span } from "../../interfaces/span"; +import { SpanContext } from "../../interfaces/span_context"; +import { Attributes } from "../../interfaces/attributes"; +import { Status } from "../../interfaces/status"; + +/** + * A no-op implementation of Span that can safely be used without side-effects. + */ +export class NoOpSpan implements Span { + + /** + * Returns the SpanContext associated with this Span. + */ + context(): SpanContext { + return { + spanId: "", + traceId: "" + }; + } + + /** + * Marks the end of Span execution. + * @param _endTime The time to use as the Span's end time. Defaults to + * the current time. + */ + end(_endTime?: number): void { + /* Noop */ + } + + /** + * Sets an attribute on the Span + * @param _key the attribute key + * @param _value the attribute value + */ + setAttribute(_key: string, _value: unknown): this { + return this; + } + + /** + * Sets attributes on the Span + * @param _attributes the attributes to add + */ + setAttributes(_attributes: Attributes): this { + return this; + } + + /** + * Adds an event to the Span + * @param _name The name of the event + * @param _attributes The associated attributes to add for this event + */ + addEvent(_name: string, _attributes?: Attributes): this { + return this; + } + + /** + * Adds a link to the Span. + * @param _spanContext the context of the linked span + * @param _attributes attributes to be added that are associated with the link + */ + addLink(_spanContext: SpanContext, _attributes?: Attributes): this { + return this; + } + + /** + * Sets a status on the span. Overrides the default of CanonicalCode.OK. + * @param _status The status to set. + */ + setStatus(_status: Status): this { + return this; + } + + /** + * Updates the name of the Span + * @param _name the new Span name + */ + updateName(_name: string): this { + return this; + } + + /** + * Returns whether this span will be recorded + */ + isRecordingEvents(): boolean { + return false; + } +} diff --git a/sdk/core/core-tracing/lib/wrappers/noop/noOpTracer.ts b/sdk/core/core-tracing/lib/wrappers/noop/noOpTracer.ts new file mode 100644 index 000000000000..e7fb4665ae91 --- /dev/null +++ b/sdk/core/core-tracing/lib/wrappers/noop/noOpTracer.ts @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { Tracer } from "../../interfaces/tracer"; +import { Span } from "../../interfaces/span"; +import { SpanOptions } from "../../interfaces/SpanOptions"; +import { NoOpSpan } from "./noOpSpan"; +import { BinaryFormat } from "../../interfaces/BinaryFormat"; +import { HttpTextFormat } from "../../interfaces/HttpTextFormat"; +import { NoOpBinaryFormat } from "./noOpBinaryFormat"; +import { NoOpHttpTextFormat } from "./noOpHttpTextFormat"; + +/** + * A no-op implementation of Tracer that can be used when tracing + * is disabled. + */ +export class NoOpTracer implements Tracer { + + /** + * Starts a new Span. + * @param _name The name of the span. + * @param _options The SpanOptions used during Span creation. + */ + startSpan(_name: string, _options?: SpanOptions): Span { + return new NoOpSpan(); + } + + /** + * Returns the current Span from the current context, if available. + */ + getCurrentSpan(): Span { + return new NoOpSpan(); + } + + /** + * Executes the given function within the context provided by a Span. + * @param _span The span that provides the context. + * @param fn The function to be executed. + */ + withSpan ReturnType>( + _span: Span, + fn: T + ): ReturnType { + return fn(); + } + + /** + * Bind a Span as the target's scope + * @param target An object to bind the scope. + * @param _span A specific Span to use. Otherwise, use the current one. + */ + bind(target: T, _span?: Span): T { + return target; + } + + /** + * Send a pre-populated Span object to the exporter. + * @param _span The span to pass along. + */ + recordSpanData(_span: Span): void { + /* NOOP */ + } + + /** + * Returns the BinaryFormat interface for serializing/deserializing Spans. + */ + getBinaryFormat(): BinaryFormat { + return new NoOpBinaryFormat(); + } + + /** + * Returns the HttpTextFormat interface for injecting/extracting Spans. + */ + getHttpTextFormat(): HttpTextFormat { + return new NoOpHttpTextFormat(); + } +} diff --git a/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusSpanWrapper.ts b/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusSpanWrapper.ts new file mode 100644 index 000000000000..c16ee64deda3 --- /dev/null +++ b/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusSpanWrapper.ts @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { Span } from "../../interfaces/span"; +import { SpanContext } from "../../interfaces/span_context"; +import { Attributes } from "../../interfaces/attributes"; +import { Status } from "../../interfaces/status"; +import { OpenCensusTraceStateWrapper } from "./openCensusTraceStateWrapper"; +import { SpanOptions } from "../../interfaces/SpanOptions"; +import { OpenCensusTracerWrapper } from "./openCensusTracerWrapper"; +import { Attributes as OpenCensusAttributes, Span as OpenCensusSpan, LinkType } from "@opencensus/web-types"; + +function isWrappedSpan(span?: Span | SpanContext): span is OpenCensusSpanWrapper { + return !!span && (span as OpenCensusSpanWrapper).getWrappedSpan !== undefined; +} + +/** + * An implementation of OpenTelemetry Span that wraps an OpenCensus Span. + */ +export class OpenCensusSpanWrapper implements Span { + private _span: OpenCensusSpan; + + /** + * The underlying OpenCensus Span + */ + public getWrappedSpan() { + return this._span; + } + + /** + * Create a new OpenCensus span and wrap it. + * @param tracer The OpenCensus tracer that has been wrapped in OpenCensusTracerWrapper + * @param name The name of the Span + * @param options Options for the Span + */ + constructor(tracer: OpenCensusTracerWrapper, name: string, options: SpanOptions = {}) { + const parent = isWrappedSpan(options.parent) ? options.parent.getWrappedSpan() : undefined; + + this._span = tracer.getWrappedTracer().startChildSpan({ + name, + childOf: parent + }); + this._span.start(); + } + + /** + * Marks the end of Span execution. + * @param endTime The time to use as the Span's end time. Defaults to + * the current time. + */ + end(_endTime?: number): void { + this._span.end(); + } + + /** + * Returns the SpanContext associated with this Span. + */ + context(): SpanContext { + const openCensusSpanContext = this._span.spanContext; + + return { + spanId: openCensusSpanContext.spanId, + traceId: openCensusSpanContext.traceId, + traceFlags: openCensusSpanContext.options, + traceState: new OpenCensusTraceStateWrapper(openCensusSpanContext.traceState) + }; + } + + /** + * Sets an attribute on the Span + * @param key the attribute key + * @param value the attribute value + */ + setAttribute(key: string, value: unknown): this { + this._span.addAttribute(key, value as any); + return this; + } + + /** + * Sets attributes on the Span + * @param attributes the attributes to add + */ + setAttributes(attributes: Attributes): this { + this._span.attributes = attributes as OpenCensusAttributes; + return this; + } + + /** + * Adds an event to the Span + * @param name The name of the event + * @param attributes The associated attributes to add for this event + */ + addEvent(name: string, attributes?: Attributes): this { + throw new Error("Method not implemented."); + } + + /** + * Adds a link to the Span. + * @param spanContext the context of the linked span + * @param attributes attributes to be added that are associated with the link + */ + addLink(spanContext: SpanContext, attributes?: Attributes): this { + // Since there is no way to specify the link relationship + // It is set as Unspecified = 0 + this._span.addLink(spanContext.traceId, spanContext.spanId, LinkType.UNSPECIFIED, attributes as OpenCensusAttributes); + return this; + } + + /** + * Sets a status on the span. Overrides the default of CanonicalCode.OK. + * @param status The status to set. + */ + setStatus(status: Status): this { + this._span.setStatus(status.code, status.message); + return this; + } + + /** + * Updates the name of the Span + * @param name the new Span name + */ + updateName(name: string): this { + this._span.name = name; + return this; + } + + /** + * Returns whether this span will be recorded + */ + isRecordingEvents(): boolean { + // NoRecordSpans have an empty traceId + return !!this._span.traceId; + } +} diff --git a/sdk/core/core-tracing/lib/plugins/opencensus/openCensusTraceStatePlugin.ts b/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTraceStateWrapper.ts similarity index 90% rename from sdk/core/core-tracing/lib/plugins/opencensus/openCensusTraceStatePlugin.ts rename to sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTraceStateWrapper.ts index f7d22ba98e92..c66217846e06 100644 --- a/sdk/core/core-tracing/lib/plugins/opencensus/openCensusTraceStatePlugin.ts +++ b/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTraceStateWrapper.ts @@ -7,7 +7,7 @@ import { TraceState } from "../../interfaces/trace_state"; * @ignore * @internal */ -export class OpenCensusTraceStatePlugin implements TraceState { +export class OpenCensusTraceStateWrapper implements TraceState { private readonly _state?: string; constructor(state?: string) { diff --git a/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTracerWrapper.ts b/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTracerWrapper.ts new file mode 100644 index 000000000000..f2d9533a9c05 --- /dev/null +++ b/sdk/core/core-tracing/lib/wrappers/opencensus/openCensusTracerWrapper.ts @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { Tracer } from "../../interfaces/tracer"; +import { SpanOptions } from "../../interfaces/SpanOptions"; +import { Span } from "../../interfaces/span"; +import { OpenCensusSpanWrapper } from "./openCensusSpanWrapper"; +import { BinaryFormat } from "../../interfaces/BinaryFormat"; +import { HttpTextFormat } from "../../interfaces/HttpTextFormat"; +import { Tracer as OpenCensusTracer } from "@opencensus/web-types"; + +/** + * An implementation of OpenTelemetry Tracer that wraps an OpenCensus Tracer. + */ +export class OpenCensusTracerWrapper implements Tracer { + private _tracer: OpenCensusTracer; + + /** + * The wrapped OpenCensus Tracer + */ + public getWrappedTracer() { + return this._tracer; + } + + /** + * Create a new wrapper around a given OpenCensus Tracer. + * @param tracer The OpenCensus Tracer to wrap. + */ + public constructor(tracer: OpenCensusTracer) { + this._tracer = tracer; + } + + /** + * Starts a new Span. + * @param name The name of the span. + * @param options The SpanOptions used during Span creation. + */ + startSpan(name: string, options?: SpanOptions): Span { + return new OpenCensusSpanWrapper(this, name, options); + } + + /** + * Returns the current Span from the current context, if available. + */ + getCurrentSpan(): Span | null { + return null; + } + + /** + * Executes the given function within the context provided by a Span. + * @param span The span that provides the context. + * @param fn The function to be executed. + */ + withSpan unknown>(span: Span, fn: T): ReturnType { + throw new Error("Method not implemented."); + } + + /** + * Bind a Span as the target's scope + * @param target An object to bind the scope. + * @param span A specific Span to use. Otherwise, use the current one. + */ + bind(target: T, span?: Span): T { + throw new Error("Method not implemented."); + } + + /** + * Send a pre-populated Span object to the exporter. + * @param span The span to pass along. + */ + recordSpanData(span: Span): void { + throw new Error("Method not implemented."); + } + + /** + * Returns the BinaryFormat interface for serializing/deserializing Spans. + */ + getBinaryFormat(): BinaryFormat { + throw new Error("Method not implemented."); + } + + /** + * Returns the HttpTextFormat interface for injecting/extracting Spans. + */ + getHttpTextFormat(): HttpTextFormat { + throw new Error("Method not implemented."); + } +} diff --git a/sdk/core/core-tracing/package.json b/sdk/core/core-tracing/package.json index 40241d8c44a4..519bdb2d4eed 100644 --- a/sdk/core/core-tracing/package.json +++ b/sdk/core/core-tracing/package.json @@ -58,6 +58,7 @@ "homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/sdk/core/core-tracing", "sideEffects": false, "dependencies": { + "@opencensus/web-types": "0.0.7", "tslib": "^1.9.3" }, "devDependencies": { diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index 1d51af8b1514..96813e31f9e8 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -4,9 +4,11 @@ ```ts +import { Span as OpenCensusSpan } from '@opencensus/web-types'; +import { Tracer as OpenCensusTracer } from '@opencensus/web-types'; + // @public export interface Attributes { - // (undocumented) [attributeKey: string]: unknown; } @@ -52,111 +54,74 @@ export interface HttpTextFormat { inject(spanContext: SpanContext, format: string, carrier: unknown): void; } +// @public +export interface ITracerProxy { + getTracer(): Tracer; + setTracer(tracer: Tracer): void; +} + // @public export interface Link { attributes?: Attributes; spanContext: SpanContext; } -// @public (undocumented) -export class NoOpSpanPlugin implements Span { - constructor(span: any); - // (undocumented) - addEvent(name: string, attributes?: Attributes): this; - // (undocumented) - addLink(spanContext: SpanContext, attributes?: Attributes): this; - // (undocumented) +// @public +export class NoOpSpan implements Span { + addEvent(_name: string, _attributes?: Attributes): this; + addLink(_spanContext: SpanContext, _attributes?: Attributes): this; context(): SpanContext; - // (undocumented) - end(endTime?: number): void; - // (undocumented) + end(_endTime?: number): void; isRecordingEvents(): boolean; - // (undocumented) - setAttribute(key: string, value: unknown): this; - // (undocumented) - setAttributes(attributes: Attributes): this; - // (undocumented) - setStatus(status: Status): this; - // (undocumented) - start(startTime?: number): void; - // (undocumented) - updateName(name: string): this; + setAttribute(_key: string, _value: unknown): this; + setAttributes(_attributes: Attributes): this; + setStatus(_status: Status): this; + updateName(_name: string): this; } -// @public (undocumented) -export class NoOpTracePlugin implements Tracer { - constructor(tracer: any); - // (undocumented) - bind(target: T, span?: Span): T; - // (undocumented) +// @public +export class NoOpTracer implements Tracer { + bind(target: T, _span?: Span): T; getBinaryFormat(): BinaryFormat; - // (undocumented) getCurrentSpan(): Span; - // (undocumented) getHttpTextFormat(): HttpTextFormat; - // (undocumented) - readonly pluginType = SupportedPlugins.NOOP; - // (undocumented) - recordSpanData(span: Span): void; - // (undocumented) - startSpan(name: string, options?: SpanOptions): Span; - // (undocumented) - withSpan unknown>(span: Span, fn: T): ReturnType; + recordSpanData(_span: Span): void; + startSpan(_name: string, _options?: SpanOptions): Span; + withSpan ReturnType>(_span: Span, fn: T): ReturnType; } -// @public (undocumented) -export class OpenCensusSpanPlugin implements Span { - constructor(tracer: OpenCensusTracePlugin, name: string, options?: SpanOptions); - // (undocumented) +export { OpenCensusSpan } + +// @public +export class OpenCensusSpanWrapper implements Span { + constructor(tracer: OpenCensusTracerWrapper, name: string, options?: SpanOptions); addEvent(name: string, attributes?: Attributes): this; - // (undocumented) addLink(spanContext: SpanContext, attributes?: Attributes): this; - // (undocumented) context(): SpanContext; - // (undocumented) - end(endTime?: number): void; - // (undocumented) - getWrappedSpan(): any; - // (undocumented) + end(_endTime?: number): void; + getWrappedSpan(): OpenCensusSpan; isRecordingEvents(): boolean; - // (undocumented) setAttribute(key: string, value: unknown): this; - // (undocumented) setAttributes(attributes: Attributes): this; - // (undocumented) setStatus(status: Status): this; - // (undocumented) updateName(name: string): this; } -// @public (undocumented) -export class OpenCensusTracePlugin implements Tracer { - constructor(tracer: any); - // (undocumented) +export { OpenCensusTracer } + +// @public +export class OpenCensusTracerWrapper implements Tracer { + constructor(tracer: OpenCensusTracer); bind(target: T, span?: Span): T; - // (undocumented) getBinaryFormat(): BinaryFormat; - // (undocumented) - getCurrentSpan(): Span; - // (undocumented) + getCurrentSpan(): Span | null; getHttpTextFormat(): HttpTextFormat; - // (undocumented) - getWrappedTracer(): any; - // (undocumented) - readonly pluginType = SupportedPlugins.OPENCENSUS; - // (undocumented) + getWrappedTracer(): OpenCensusTracer; recordSpanData(span: Span): void; - // (undocumented) startSpan(name: string, options?: SpanOptions): Span; - // (undocumented) withSpan unknown>(span: Span, fn: T): ReturnType; } -// @public (undocumented) -export interface Plugin extends Tracer { - readonly pluginType: SupportedPlugins; -} - // @public export interface Sampler { shouldSample(parentContext?: SpanContext): boolean; @@ -193,30 +158,6 @@ export enum SpanKind { SERVER = 1 } -// @public (undocumented) -export class SpanNoOpImpl implements Span { - // (undocumented) - addEvent(name: string, attributes?: Attributes | undefined): this; - // (undocumented) - addLink(spanContext: SpanContext, attributes?: Attributes | undefined): this; - // (undocumented) - context(): SpanContext; - // (undocumented) - end(endTime?: number): void; - // (undocumented) - isRecordingEvents(): boolean; - // (undocumented) - setAttribute(key: string, value: unknown): this; - // (undocumented) - setAttributes(attributes: Attributes): this; - // (undocumented) - setStatus(status: Status): this; - // (undocumented) - start(startTime?: number): void; - // (undocumented) - updateName(name: string): this; -} - // @public export interface SpanOptions { attributes?: Attributes; @@ -232,17 +173,8 @@ export interface Status { message?: string; } -// @public (undocumented) -export enum SupportedPlugins { - // (undocumented) - NOOP = 1, - // (undocumented) - OPENCENSUS = 0 -} - // @public export interface TimedEvent extends Event { - // (undocumented) time: HrTime; } @@ -266,33 +198,8 @@ export interface Tracer { withSpan ReturnType>(span: Span, fn: T): ReturnType; } -// @public (undocumented) -export class TracerNoOpImpl implements Tracer { - // (undocumented) - bind(target: T, span?: Span): T; - // (undocumented) - getBinaryFormat(): BinaryFormat; - // (undocumented) - getCurrentSpan(): Span; - // (undocumented) - getHttpTextFormat(): HttpTextFormat; - // (undocumented) - readonly pluginType = SupportedPlugins.NOOP; - // (undocumented) - recordSpanData(span: Span): void; - // (undocumented) - startSpan(name: string, options?: SpanOptions | undefined): Span; - // (undocumented) - withSpan unknown>(span: Span, fn: T): ReturnType; -} - -// @public (undocumented) -export class TracerProxy { - // (undocumented) - static getTracer(): Plugin; - // (undocumented) - static setTracer(tracer: any, tracerPluginType: SupportedPlugins): void; - } +// @public +export const TracerProxy: ITracerProxy; // @public export interface TraceState { diff --git a/sdk/keyvault/keyvault-certificates/review/keyvault-certificates.api.md b/sdk/keyvault/keyvault-certificates/review/keyvault-certificates.api.md index 13c949c2d289..1e05d25b0fbc 100644 --- a/sdk/keyvault/keyvault-certificates/review/keyvault-certificates.api.md +++ b/sdk/keyvault/keyvault-certificates/review/keyvault-certificates.api.md @@ -10,7 +10,6 @@ import { HttpPipelineLogger } from '@azure/core-http'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { RequestOptionsBase } from '@azure/core-http'; import { ServiceClientOptions } from '@azure/core-http'; -import { SupportedPlugins } from '@azure/core-http'; import { TokenCredential } from '@azure/core-http'; import { TracerProxy } from '@azure/core-http'; @@ -261,8 +260,6 @@ export interface SecretProperties { contentType?: string; } -export { SupportedPlugins } - // @public (undocumented) export interface TelemetryOptions { // (undocumented) diff --git a/sdk/keyvault/keyvault-certificates/src/index.ts b/sdk/keyvault/keyvault-certificates/src/index.ts index db491b69f959..5db3266a8eb4 100644 --- a/sdk/keyvault/keyvault-certificates/src/index.ts +++ b/sdk/keyvault/keyvault-certificates/src/index.ts @@ -17,8 +17,7 @@ import { RequestOptionsBase, tracingPolicy, TracerProxy, - Span, - SupportedPlugins + Span } from "@azure/core-http"; import { @@ -63,7 +62,29 @@ import { LifetimeAction, OrganizationDetails, SecretProperties, - X509CertificateProperties + X509CertificateProperties, + DeleteCertificateResponse, + DeleteCertificateContactsResponse, + SetCertificateContactsResponse, + GetCertificateContactsResponse, + SetCertificateIssuerResponse, + UpdateCertificateIssuerResponse, + GetCertificateIssuerResponse, + DeleteCertificateIssuerResponse, + CreateCertificateResponse, + GetCertificateResponse, + ImportCertificateResponse, + GetCertificatePolicyResponse, + UpdateCertificatePolicyResponse, + UpdateCertificateResponse, + UpdateCertificateOperationResponse, + GetCertificateOperationResponse, + DeleteCertificateOperationResponse, + MergeCertificateResponse, + BackupCertificateResponse, + RestoreCertificateResponse, + GetDeletedCertificateResponse, + RecoverDeletedCertificateResponse } from "./core/models"; import { KeyVaultClient } from "./core/keyVaultClient"; import { ProxyOptions, RetryOptions } from "./core"; @@ -101,7 +122,7 @@ export { X509CertificateProperties }; -export { ProxyOptions, RetryOptions, SupportedPlugins, TracerProxy, TelemetryOptions }; +export { ProxyOptions, RetryOptions, TracerProxy, TelemetryOptions }; /** * The client to interact with the KeyVault certificates functionality @@ -284,8 +305,9 @@ export class CertificatesClient { options?: RequestOptionsBase ): PagedAsyncIterableIterator { const span = this.createSpan("listCertificates", options); + const updatedOptions = this.setParentSpan(span, options); - const iter = this.listCertificatesAll(options); + const iter = this.listCertificatesAll(updatedOptions); span.end(); let result = { @@ -295,7 +317,7 @@ export class CertificatesClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listCertificatesPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listCertificatesPage(settings, updatedOptions) }; return result; @@ -363,8 +385,9 @@ export class CertificatesClient { options?: RequestOptionsBase ): PagedAsyncIterableIterator { const span = this.createSpan("listCertificateVersions", options); + const updatedOptions = this.setParentSpan(span, options); - const iter = this.listCertificateVersionsAll(name, options); + const iter = this.listCertificateVersionsAll(name, updatedOptions); span.end(); let result = { @@ -375,7 +398,7 @@ export class CertificatesClient { return this; }, byPage: (settings: PageSettings = {}) => - this.listCertificateVersionsPage(name, settings, options) + this.listCertificateVersionsPage(name, settings, updatedOptions) }; return result; @@ -405,14 +428,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("deleteCertificate", options); - const response = await this.client - .deleteCertificate(this.vaultBaseUrl, certificateName, options) - .catch((err) => { - span.end(); - throw err; - }); + let response: DeleteCertificateResponse; + try { + response = await this.client + .deleteCertificate(this.vaultBaseUrl, certificateName, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(response); } @@ -436,14 +459,15 @@ export class CertificatesClient { public async deleteCertificateContacts(options?: RequestOptionsBase): Promise { const span = this.createSpan("deleteCertificateContacts", options); - let result = await this.client - .deleteCertificateContacts(this.vaultBaseUrl, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: DeleteCertificateContactsResponse; + + try { + result = await this.client + .deleteCertificateContacts(this.vaultBaseUrl, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -470,14 +494,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("setCertificateContacts", options); - let result = await this.client - .setCertificateContacts(this.vaultBaseUrl, { contactList: contacts }, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: SetCertificateContactsResponse; - span.end(); + try { + result = await this.client + .setCertificateContacts(this.vaultBaseUrl, { contactList: contacts }, this.setParentSpan(span, options)); + } finally { + span.end(); + } return result._response.parsedBody; } @@ -502,14 +526,14 @@ export class CertificatesClient { public async getCertificateContacts(options?: RequestOptionsBase): Promise { const span = this.createSpan("getCertificateContacts", options); - let result = await this.client - .getCertificateContacts(this.vaultBaseUrl, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetCertificateContactsResponse; + try { + result = await this.client + .getCertificateContacts(this.vaultBaseUrl, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -577,8 +601,9 @@ export class CertificatesClient { options?: KeyVaultClientGetCertificateIssuersOptionalParams ): PagedAsyncIterableIterator { const span = this.createSpan("listCertificateIssuers", options); + const updatedOptions = this.setParentSpan(span, options); - const iter = this.listCertificateIssuersAll(options); + const iter = this.listCertificateIssuersAll(updatedOptions); span.end(); let result = { @@ -588,7 +613,7 @@ export class CertificatesClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listCertificateIssuersPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listCertificateIssuersPage(settings, updatedOptions) }; return result; @@ -616,14 +641,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("setCertificateIssuer", options); - let result = await this.client - .setCertificateIssuer(this.vaultBaseUrl, issuerName, provider, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: SetCertificateIssuerResponse; - span.end(); + try { + result = await this.client + .setCertificateIssuer(this.vaultBaseUrl, issuerName, provider, this.setParentSpan(span, options)); + } finally { + span.end(); + } return result._response.parsedBody; } @@ -650,14 +675,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("updateCertificateIssuer", options); - let result = await this.client - .updateCertificateIssuer(this.vaultBaseUrl, issuerName, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: UpdateCertificateIssuerResponse; + + try { + result = await this.client + .updateCertificateIssuer(this.vaultBaseUrl, issuerName, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -684,14 +710,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("getCertificateIssuer", options); - let result = await this.client - .getCertificateIssuer(this.vaultBaseUrl, issuerName, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetCertificateIssuerResponse; - span.end(); + try { + result = await this.client + .getCertificateIssuer(this.vaultBaseUrl, issuerName, this.setParentSpan(span, options)); + } finally { + span.end(); + } return result._response.parsedBody; } @@ -716,14 +742,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("deleteCertificateIssuer", options); - let result = await this.client - .deleteCertificateIssuer(this.vaultBaseUrl, issuerName, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: DeleteCertificateIssuerResponse; + + try { + result = await this.client + .deleteCertificateIssuer(this.vaultBaseUrl, issuerName, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -755,21 +782,22 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("createCertificate", options); - let result = await this.client - .createCertificate(this.vaultBaseUrl, name, { - ...options, - certificateAttributes: { - enabled - }, - tags, - certificatePolicy - }) - .catch((err) => { - span.end(); - throw err; - }); + let result: CreateCertificateResponse; + + try { + result = await this.client + .createCertificate(this.vaultBaseUrl, name, { + ...this.setParentSpan(span, options), + certificateAttributes: { + enabled + }, + tags, + certificatePolicy + }); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result); } @@ -797,14 +825,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("getCertificateWithPolicy", options); - let result = await this.client - .getCertificate(this.vaultBaseUrl, name, "", options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetCertificateResponse; + + try { + result = await this.client + .getCertificate(this.vaultBaseUrl, name, "", this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result); } @@ -839,14 +868,15 @@ export class CertificatesClient { const span = this.createSpan("getCertificate", options); - let result = await this.client - .getCertificate(this.vaultBaseUrl, name, version, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetCertificateResponse; + + try { + result = await this.client + .getCertificate(this.vaultBaseUrl, name, version, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result); } @@ -874,14 +904,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("importCertificate", options); - let result = await this.client - .importCertificate(this.vaultBaseUrl, name, base64EncodedCertificate, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: ImportCertificateResponse; + + try { + result = await this.client + .importCertificate(this.vaultBaseUrl, name, base64EncodedCertificate, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result); } @@ -909,14 +940,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("getCertificatePolicy", options); - let result = await this.client - .getCertificatePolicy(this.vaultBaseUrl, name, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetCertificatePolicyResponse; + + try { + result = await this.client + .getCertificatePolicy(this.vaultBaseUrl, name, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -935,14 +967,13 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("updateCertificatePolicy", options); - let result = await this.client - .updateCertificatePolicy(this.vaultBaseUrl, name, policy, options) - .catch((err) => { - span.end(); - throw err; - }); - - span.end(); + let result: UpdateCertificatePolicyResponse; + try { + result = await this.client + .updateCertificatePolicy(this.vaultBaseUrl, name, policy, this.setParentSpan(span, options)); + } finally { + span.end(); + } return result._response.parsedBody; } @@ -976,14 +1007,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("updateCertificate", options); - let result = await this.client - .updateCertificate(this.vaultBaseUrl, name, version, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: UpdateCertificateResponse; + + try { + result = await this.client + .updateCertificate(this.vaultBaseUrl, name, version, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result._response.parsedBody); } @@ -1011,14 +1043,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("cancelCertificateOperation", options); - let result = await this.client - .updateCertificateOperation(this.vaultBaseUrl, name, true, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: UpdateCertificateOperationResponse; + try { + result = await this.client + .updateCertificateOperation(this.vaultBaseUrl, name, true, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -1046,14 +1078,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("getCertificateOperation", options); - let result = await this.client - .getCertificateOperation(this.vaultBaseUrl, name, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetCertificateOperationResponse; + + try { + result = await this.client + .getCertificateOperation(this.vaultBaseUrl, name, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -1082,14 +1115,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("deleteCertificateOperation", options); - let result = await this.client - .deleteCertificateOperation(this.vaultBaseUrl, name, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: DeleteCertificateOperationResponse; + + try { + result = await this.client + .deleteCertificateOperation(this.vaultBaseUrl, name, this.setParentSpan(span, options)) + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -1132,14 +1166,14 @@ export class CertificatesClient { options?: RequestOptionsBase ): Promise { const span = this.createSpan("mergeCertificate", options); - let result = await this.client - .mergeCertificate(this.vaultBaseUrl, name, x509Certificates, options) - .catch((err) => { - span.end(); - throw err; - }); - span.end(); + let result: MergeCertificateResponse; + try { + result = await this.client + .mergeCertificate(this.vaultBaseUrl, name, x509Certificates, this.setParentSpan(span, options)); + } finally { + span.end(); + } return this.getCertificateFromCertificateBundle(result._response.parsedBody); } @@ -1167,14 +1201,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("backupCertificate", options); - let result = await this.client - .backupCertificate(this.vaultBaseUrl, name, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: BackupCertificateResponse; + try { + result = await this.client + .backupCertificate(this.vaultBaseUrl, name, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return result._response.parsedBody; } @@ -1204,14 +1238,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("restoreCertificate", options); - let result = await this.client - .restoreCertificate(this.vaultBaseUrl, certificateBackup, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: RestoreCertificateResponse; + + try { + result = await this.client + .restoreCertificate(this.vaultBaseUrl, certificateBackup, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result._response.parsedBody); } @@ -1277,8 +1312,9 @@ export class CertificatesClient { options?: KeyVaultClientGetDeletedCertificatesOptionalParams ): PagedAsyncIterableIterator { const span = this.createSpan("listDeletedCertificates", options); + const updatedOptions = this.setParentSpan(span, options); - const iter = this.listDeletedCertificatesAll(options); + const iter = this.listDeletedCertificatesAll(updatedOptions); span.end(); let result = { @@ -1288,7 +1324,7 @@ export class CertificatesClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listDeletedCertificatesPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listDeletedCertificatesPage(settings, updatedOptions) }; return result; @@ -1314,14 +1350,14 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("getDeletedCertificate", options); - let result = await this.client - .getDeletedCertificate(this.vaultBaseUrl, name, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: GetDeletedCertificateResponse; + try { + result = await this.client + .getDeletedCertificate(this.vaultBaseUrl, name, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getDeletedCertificateFromDeletedCertificateBundle(result._response.parsedBody); } @@ -1343,12 +1379,12 @@ export class CertificatesClient { public async purgeDeletedCertificate(name: string, options?: RequestOptionsBase): Promise { const span = this.createSpan("purgeDeletedCertificate", options); - await this.client.purgeDeletedCertificate(this.vaultBaseUrl, name, options).catch((err) => { + try { + await this.client.purgeDeletedCertificate(this.vaultBaseUrl, name, this.setParentSpan(span, options)); + } finally { span.end(); - throw err; - }); + } - span.end(); return null; } @@ -1374,14 +1410,15 @@ export class CertificatesClient { ): Promise { const span = this.createSpan("recoverDeletedCertificate", options); - let result = await this.client - .recoverDeletedCertificate(this.vaultBaseUrl, name, options) - .catch((err) => { - span.end(); - throw err; - }); + let result: RecoverDeletedCertificateResponse; + + try { + result = await this.client + .recoverDeletedCertificate(this.vaultBaseUrl, name, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getCertificateFromCertificateBundle(result._response.parsedBody); } @@ -1459,20 +1496,30 @@ export class CertificatesClient { /** * Creates a span using the tracer that was set by the user * @param methodName The name of the method for which the span is being created. - * @param requestOptions The options for the underlying http request. This will be - * updated to use the newly created span as the "parent" so that any new spans created - * after this point gets the right parent. + * @param requestOptions The options for the underlying http request. */ private createSpan(methodName: string, requestOptions?: RequestOptionsBase): Span { const tracer = TracerProxy.getTracer(); - const options = requestOptions || {}; - const span = tracer.startSpan(methodName, options.spanOptions); - if ( - tracer.pluginType !== SupportedPlugins.NOOP && - (options.spanOptions && options.spanOptions.parent) - ) { - options.spanOptions = { ...options.spanOptions, parent: span }; + return tracer.startSpan(methodName, requestOptions && requestOptions.spanOptions); + } + + /** + * Returns updated HTTP options with the given span as the parent of future spans, + * if applicable. + * @param span The span for the current operation + * @param options The options for the underlying http request + */ + private setParentSpan(span: Span, options: RequestOptionsBase = {}): RequestOptionsBase { + if (span.isRecordingEvents()) { + return { + ...options, + spanOptions: { + ...options.spanOptions, + parent: span, + } + } + } else { + return options; } - return span; } } diff --git a/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md b/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md index a804f81a60d1..fa3937260eba 100644 --- a/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md +++ b/sdk/keyvault/keyvault-keys/review/keyvault-keys.api.md @@ -11,7 +11,6 @@ import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { PageSettings } from '@azure/core-paging'; import { ServiceClientCredentials } from '@azure/core-http'; import { ServiceClientOptions } from '@azure/core-http'; -import { SupportedPlugins } from '@azure/core-http'; import { TokenCredential } from '@azure/core-http'; import { TracerProxy } from '@azure/core-http'; @@ -244,8 +243,6 @@ export interface SignResult { result: Uint8Array; } -export { SupportedPlugins } - // @public (undocumented) export interface TelemetryOptions { // (undocumented) diff --git a/sdk/keyvault/keyvault-keys/src/index.ts b/sdk/keyvault/keyvault-keys/src/index.ts index 5c7edd13ffd3..d7a1898c48ef 100644 --- a/sdk/keyvault/keyvault-keys/src/index.ts +++ b/sdk/keyvault/keyvault-keys/src/index.ts @@ -21,8 +21,7 @@ import { RequestOptionsBase, tracingPolicy, TracerProxy, - Span, - SupportedPlugins + Span } from "@azure/core-http"; import "@azure/core-paging"; @@ -38,7 +37,16 @@ import { JsonWebKeyCurveName, KeyItem, DeletionRecoveryLevel, - KeyVaultClientGetKeysOptionalParams + KeyVaultClientGetKeysOptionalParams, + CreateKeyResponse, + ImportKeyResponse, + DeleteKeyResponse, + UpdateKeyResponse, + GetKeyResponse, + GetDeletedKeyResponse, + RecoverDeletedKeyResponse, + BackupKeyResponse, + RestoreKeyResponse } from "./core/models"; import { KeyVaultClient } from "./core/keyVaultClient"; import { RetryConstants, SDK_VERSION } from "./core/utils/constants"; @@ -114,7 +122,7 @@ export { export { ProxyOptions, TelemetryOptions, RetryOptions }; -export { TracerProxy, SupportedPlugins } from "@azure/core-http"; +export { TracerProxy } from "@azure/core-http"; /** * The client to interact with the KeyVault keys functionality @@ -286,14 +294,14 @@ export class KeysClient { const span = this.createSpan("createKey", unflattenedOptions); - const response = await this.client - .createKey(this.vaultBaseUrl, name, keyType, unflattenedOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: CreateKeyResponse; - span.end(); + try { + response = await this.client + .createKey(this.vaultBaseUrl, name, keyType, this.setParentSpan(span, unflattenedOptions)); + } finally { + span.end(); + } return this.getKeyFromKeyBundle(response); } else { const response = await this.client.createKey(this.vaultBaseUrl, name, keyType, options); @@ -337,14 +345,14 @@ export class KeysClient { const span = this.createSpan("createEcKey", unflattenedOptions); - const response = await this.client - .createKey(this.vaultBaseUrl, name, options.hsm ? "EC-HSM" : "EC", unflattenedOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: CreateKeyResponse; + try { + response = await this.client + .createKey(this.vaultBaseUrl, name, options.hsm ? "EC-HSM" : "EC", this.setParentSpan(span, unflattenedOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } else { const response = await this.client.createKey(this.vaultBaseUrl, name, "EC", options); @@ -388,14 +396,14 @@ export class KeysClient { const span = this.createSpan("createRsaKey", unflattenedOptions); - const response = await this.client - .createKey(this.vaultBaseUrl, name, options.hsm ? "RSA-HSM" : "RSA", unflattenedOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: CreateKeyResponse; + try { + response = await this.client + .createKey(this.vaultBaseUrl, name, options.hsm ? "RSA-HSM" : "RSA", this.setParentSpan(span, unflattenedOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } else { const response = await this.client.createKey(this.vaultBaseUrl, name, "RSA", options); @@ -439,14 +447,14 @@ export class KeysClient { const span = this.createSpan("importKey", unflattenedOptions); - const response = await this.client - .importKey(this.vaultBaseUrl, name, key, unflattenedOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: ImportKeyResponse; + try { + response = await this.client + .importKey(this.vaultBaseUrl, name, key, this.setParentSpan(span, unflattenedOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } else { const response = await this.client.importKey(this.vaultBaseUrl, name, key, options); @@ -473,14 +481,14 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("deleteKey", requestOptions); - const response = await this.client - .deleteKey(this.vaultBaseUrl, name, requestOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: DeleteKeyResponse; + try { + response = await this.client + .deleteKey(this.vaultBaseUrl, name, this.setParentSpan(span, requestOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } @@ -525,14 +533,15 @@ export class KeysClient { const span = this.createSpan("updateKey", unflattenedOptions); - const response = await this.client - .updateKey(this.vaultBaseUrl, name, keyVersion, unflattenedOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: UpdateKeyResponse; + + try { + response = await this.client + .updateKey(this.vaultBaseUrl, name, keyVersion, this.setParentSpan(span, unflattenedOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } else { const response = await this.client.updateKey(this.vaultBaseUrl, name, keyVersion, options); @@ -558,19 +567,18 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("getKey", requestOptions); - const response = await this.client - .getKey( - this.vaultBaseUrl, - name, - options && options.version ? options.version : "", - requestOptions - ) - .catch((err) => { - span.end(); - throw err; - }); - - span.end(); + let response: GetKeyResponse; + try { + response = await this.client + .getKey( + this.vaultBaseUrl, + name, + options && options.version ? options.version : "", + this.setParentSpan(span, requestOptions) + ); + } finally { + span.end(); + } return this.getKeyFromKeyBundle(response); } @@ -593,14 +601,14 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("getDeletedKey", requestOptions); - const response = await this.client - .getDeletedKey(this.vaultBaseUrl, name, requestOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: GetDeletedKeyResponse; + try { + response = await this.client + .getDeletedKey(this.vaultBaseUrl, name, this.setParentSpan(span, requestOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } @@ -625,12 +633,12 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("purgeDeletedKey", requestOptions); - await this.client.purgeDeletedKey(this.vaultBaseUrl, name, requestOptions).catch((err) => { + try { + await this.client.purgeDeletedKey(this.vaultBaseUrl, name, this.setParentSpan(span, requestOptions)); + } finally { span.end(); - throw err; - }); + } - span.end(); } /** @@ -653,14 +661,14 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("recoverDeletedKey", requestOptions); - const response = await this.client - .recoverDeletedKey(this.vaultBaseUrl, name, requestOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: RecoverDeletedKeyResponse; + try { + response = await this.client + .recoverDeletedKey(this.vaultBaseUrl, name, this.setParentSpan(span, requestOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } @@ -682,14 +690,14 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("backupKey", requestOptions); - const response = await this.client - .backupKey(this.vaultBaseUrl, name, requestOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: BackupKeyResponse; + try { + response = await this.client + .backupKey(this.vaultBaseUrl, name, this.setParentSpan(span, requestOptions)); + } finally { + span.end(); + } - span.end(); return response.value; } @@ -713,14 +721,14 @@ export class KeysClient { const requestOptions = (options && options.requestOptions) || {}; const span = this.createSpan("restoreKey", requestOptions); - const response = await this.client - .restoreKey(this.vaultBaseUrl, backup, requestOptions) - .catch((err) => { - span.end(); - throw err; - }); + let response: RestoreKeyResponse; + try { + response = await this.client + .restoreKey(this.vaultBaseUrl, backup, this.setParentSpan(span, requestOptions)); + } finally { + span.end(); + } - span.end(); return this.getKeyFromKeyBundle(response); } @@ -783,17 +791,15 @@ export class KeysClient { */ public listKeyVersions( name: string, - options?: ListKeysOptions + options: ListKeysOptions = {} ): PagedAsyncIterableIterator { - if (!options) { - options = {}; - } - if (!options.requestOptions) { - options.requestOptions = {}; - } const span = this.createSpan("listKeyVersions", options.requestOptions); + const updatedOptions: ListKeysOptions = { + ...options, + requestOptions: this.setParentSpan(span, options.requestOptions) + }; - const iter = this.listKeyVersionsAll(name, options); + const iter = this.listKeyVersionsAll(name, updatedOptions); span.end(); return { @@ -803,7 +809,7 @@ export class KeysClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listKeyVersionsPage(name, settings, options) + byPage: (settings: PageSettings = {}) => this.listKeyVersionsPage(name, settings, updatedOptions) }; } @@ -857,17 +863,15 @@ export class KeysClient { * @returns PagedAsyncIterableIterator */ public listKeys( - options?: ListKeysOptions + options: ListKeysOptions = {} ): PagedAsyncIterableIterator { - if (!options) { - options = {}; - } - if (!options.requestOptions) { - options.requestOptions = {}; - } const span = this.createSpan("listKeys", options.requestOptions); + const updatedOptions: ListKeysOptions = { + ...options, + requestOptions: this.setParentSpan(span, options.requestOptions) + }; - const iter = this.listKeysAll(options); + const iter = this.listKeysAll(updatedOptions); span.end(); return { @@ -877,7 +881,7 @@ export class KeysClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listKeysPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listKeysPage(settings, updatedOptions) }; } @@ -936,17 +940,16 @@ export class KeysClient { * @returns PagedAsyncIterableIterator */ public listDeletedKeys( - options?: ListKeysOptions + options: ListKeysOptions = {} ): PagedAsyncIterableIterator { - if (!options) { - options = {}; - } - if (!options.requestOptions) { - options.requestOptions = {}; - } const span = this.createSpan("listDeletedKeys", options.requestOptions); - const iter = this.listDeletedKeysAll(options); + const updatedOptions: ListKeysOptions = { + ...options, + requestOptions: this.setParentSpan(span, options.requestOptions) + }; + + const iter = this.listDeletedKeysAll(updatedOptions); span.end(); return { @@ -956,7 +959,7 @@ export class KeysClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listDeletedKeysPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listDeletedKeysPage(settings, updatedOptions) }; } @@ -1010,19 +1013,30 @@ export class KeysClient { /** * Creates a span using the tracer that was set by the user * @param methodName The name of the method for which the span is being created. - * @param requestOptions The options for the underlying http request. This will be - * updated to use the newly created span as the "parent" so that any new spans created - * after this point gets the right parent. + * @param requestOptions The options for the underlying http request. */ - private createSpan(methodName: string, requestOptions: RequestOptionsBase): Span { + private createSpan(methodName: string, requestOptions?: RequestOptionsBase): Span { const tracer = TracerProxy.getTracer(); - const span = tracer.startSpan(methodName, requestOptions.spanOptions); - if ( - tracer.pluginType !== SupportedPlugins.NOOP && - (requestOptions.spanOptions && requestOptions.spanOptions.parent) - ) { - requestOptions.spanOptions = { ...requestOptions.spanOptions, parent: span }; + return tracer.startSpan(methodName, requestOptions && requestOptions.spanOptions); + } + + /** + * Returns updated HTTP options with the given span as the parent of future spans, + * if applicable. + * @param span The span for the current operation + * @param options The options for the underlying http request + */ + private setParentSpan(span: Span, options: RequestOptionsBase = {}): RequestOptionsBase { + if (span.isRecordingEvents()) { + return { + ...options, + spanOptions: { + ...options.spanOptions, + parent: span, + } + } + } else { + return options; } - return span; } } diff --git a/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md b/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md index ecb80720db86..a2ac6e91485f 100644 --- a/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md +++ b/sdk/keyvault/keyvault-secrets/review/keyvault-secrets.api.md @@ -11,7 +11,6 @@ import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { PageSettings } from '@azure/core-paging'; import { RequestOptionsBase } from '@azure/core-http'; import { ServiceClientOptions } from '@azure/core-http'; -import { SupportedPlugins } from '@azure/core-http'; import { TokenCredential } from '@azure/core-http'; import { TracerProxy } from '@azure/core-http'; @@ -98,7 +97,7 @@ export interface SecretAttributes extends ParsedKeyVaultEntityIdentifier { // @public export class SecretsClient { constructor(url: string, credential: TokenCredential, pipelineOrOptions?: ServiceClientOptions | NewPipelineOptions); - backupSecret(secretName: string, options?: RequestOptionsBase): Promise; + backupSecret(secretName: string, options?: RequestOptionsBase): Promise; protected readonly credential: TokenCredential; deleteSecret(secretName: string, options?: RequestOptionsBase): Promise; static getDefaultPipeline(credential: TokenCredential, pipelineOptions?: NewPipelineOptions): ServiceClientOptions; @@ -128,8 +127,6 @@ export interface SetSecretOptions { }; } -export { SupportedPlugins } - // @public (undocumented) export interface TelemetryOptions { // (undocumented) diff --git a/sdk/keyvault/keyvault-secrets/src/index.ts b/sdk/keyvault/keyvault-secrets/src/index.ts index 053f9f8a1eb3..0e8f465d7f14 100644 --- a/sdk/keyvault/keyvault-secrets/src/index.ts +++ b/sdk/keyvault/keyvault-secrets/src/index.ts @@ -21,8 +21,7 @@ import { userAgentPolicy, tracingPolicy, TracerProxy, - Span, - SupportedPlugins + Span } from "@azure/core-http"; import "@azure/core-paging"; @@ -31,7 +30,15 @@ import { SecretBundle, DeletedSecretBundle, DeletionRecoveryLevel, - KeyVaultClientGetSecretsOptionalParams + KeyVaultClientGetSecretsOptionalParams, + SetSecretResponse, + DeleteSecretResponse, + UpdateSecretResponse, + GetSecretResponse, + GetDeletedSecretResponse, + RecoverDeletedSecretResponse, + BackupSecretResponse, + RestoreSecretResponse } from "./core/models"; import { KeyVaultClient } from "./core/keyVaultClient"; import { RetryConstants, SDK_VERSION } from "./core/utils/constants"; @@ -73,7 +80,6 @@ export { export { ProxyOptions, RetryOptions, - SupportedPlugins, TracerProxy, TelemetryOptions }; @@ -243,17 +249,18 @@ export class SecretsClient { const span = this.createSpan("setSecret", unflattenedOptions); - const response = await this.client.setSecret( - this.vaultBaseUrl, - secretName, - value, - unflattenedOptions - ).catch((err) => { + let response: SetSecretResponse; + try { + response = await this.client.setSecret( + this.vaultBaseUrl, + secretName, + value, + this.setParentSpan(span, unflattenedOptions) + ); + } finally { span.end(); - throw err; - }); + } - span.end(); return this.getSecretFromSecretBundle(response); } else { const response = await this.client.setSecret(this.vaultBaseUrl, secretName, value, options); @@ -282,13 +289,13 @@ export class SecretsClient { ): Promise { const span = this.createSpan("deleteSecret", options); - const response = await this.client.deleteSecret(this.vaultBaseUrl, secretName, options) - .catch((err) => { - span.end(); - throw err; - }); + let response: DeleteSecretResponse; + try { + response = await this.client.deleteSecret(this.vaultBaseUrl, secretName, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getDeletedSecretFromDeletedSecretBundle(response); } @@ -333,18 +340,19 @@ export class SecretsClient { const span = this.createSpan("updateSecretAttributes", unflattenedOptions); - const response = await this.client.updateSecret( - this.vaultBaseUrl, - secretName, - secretVersion, - unflattenedOptions - ) - .catch((err) => { - span.end(); - throw err; - }); + let response: UpdateSecretResponse; + + try { + response = await this.client.updateSecret( + this.vaultBaseUrl, + secretName, + secretVersion, + this.setParentSpan(span, unflattenedOptions) + ); + } finally { + span.end(); + } - span.end(); return this.getSecretFromSecretBundle(response); } else { const response = await this.client.updateSecret( @@ -373,19 +381,20 @@ export class SecretsClient { */ public async getSecret(secretName: string, options?: GetSecretOptions): Promise { const span = this.createSpan("getSecret", options && options.requestOptions); + const requestOptions = this.setParentSpan(span, options && options.requestOptions); - const response = await this.client.getSecret( - this.vaultBaseUrl, - secretName, - options && options.version ? options.version : "", - options ? options.requestOptions : undefined - ) - .catch((err) => { - span.end(); - throw err; - }); + let response: GetSecretResponse; + try { + response = await this.client.getSecret( + this.vaultBaseUrl, + secretName, + options && options.version ? options.version : "", + requestOptions + ); + } finally { + span.end(); + } - span.end(); return this.getSecretFromSecretBundle(response); } @@ -409,13 +418,14 @@ export class SecretsClient { ): Promise { const span = this.createSpan("getDeletedSecret", options); - const response = await this.client.getDeletedSecret(this.vaultBaseUrl, secretName, options) - .catch((err) => { - span.end(); - throw err; - }); + let response: GetDeletedSecretResponse; + + try { + response = await this.client.getDeletedSecret(this.vaultBaseUrl, secretName, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getSecretFromSecretBundle(response); } @@ -438,13 +448,11 @@ export class SecretsClient { public async purgeDeletedSecret(secretName: string, options?: RequestOptionsBase): Promise { const span = this.createSpan("purgeDeletedSecret", options); - await this.client.purgeDeletedSecret(this.vaultBaseUrl, secretName, options) - .catch((err) => { - span.end(); - throw err; - }); - - span.end(); + try { + await this.client.purgeDeletedSecret(this.vaultBaseUrl, secretName, this.setParentSpan(span, options)); + } finally { + span.end(); + } } /** @@ -468,13 +476,14 @@ export class SecretsClient { ): Promise { const span = this.createSpan("recoverDeletedSecret", options); - const response = await this.client.recoverDeletedSecret(this.vaultBaseUrl, secretName, options) - .catch((err) => { - span.end(); - throw err; - }); + let response: RecoverDeletedSecretResponse; + + try { + response = await this.client.recoverDeletedSecret(this.vaultBaseUrl, secretName, this.setParentSpan(span, options)); + } finally { + span.end(); + } - span.end(); return this.getSecretFromSecretBundle(response); } @@ -492,16 +501,16 @@ export class SecretsClient { * @param [options] The optional parameters * @returns Promise */ - public async backupSecret(secretName: string, options?: RequestOptionsBase): Promise { + public async backupSecret(secretName: string, options?: RequestOptionsBase): Promise { const span = this.createSpan("backupSecret", options); - const response: any = await this.client.backupSecret(this.vaultBaseUrl, secretName, options) - .catch((err) => { - span.end(); - throw err; - }); + let response: BackupSecretResponse; - span.end(); + try { + response = await this.client.backupSecret(this.vaultBaseUrl, secretName, this.setParentSpan(span, options)); + } finally { + span.end(); + } return response.value; } @@ -527,17 +536,18 @@ export class SecretsClient { ): Promise { const span = this.createSpan("restoreSecret", options); - const response = await this.client.restoreSecret( - this.vaultBaseUrl, - secretBundleBackup, - options - ) - .catch((err) => { - span.end(); - throw err; - }); + let response: RestoreSecretResponse; + + try { + response = await this.client.restoreSecret( + this.vaultBaseUrl, + secretBundleBackup, + this.setParentSpan(span, options) + ); + } finally { + span.end(); + } - span.end(); return this.getSecretFromSecretBundle(response); } @@ -603,8 +613,12 @@ export class SecretsClient { options?: ListSecretsOptions ): PagedAsyncIterableIterator { const span = this.createSpan("listSecretVersions", options && options.requestOptions); + const updatedOptions: ListSecretsOptions = { + ...options, + requestOptions: this.setParentSpan(span, options && options.requestOptions) + }; - const iter = this.listSecretVersionsAll(secretName, options); + const iter = this.listSecretVersionsAll(secretName, updatedOptions); span.end(); return { @@ -615,7 +629,7 @@ export class SecretsClient { return this; }, byPage: (settings: PageSettings = {}) => - this.listSecretVersionsPage(secretName, settings, options) + this.listSecretVersionsPage(secretName, settings, updatedOptions) }; } @@ -674,8 +688,12 @@ export class SecretsClient { options?: ListSecretsOptions ): PagedAsyncIterableIterator { const span = this.createSpan("listSecrets", options && options.requestOptions); + const updatedOptions: ListSecretsOptions = { + ...options, + requestOptions: this.setParentSpan(span, options && options.requestOptions) + }; - const iter = this.listSecretsAll(options); + const iter = this.listSecretsAll(updatedOptions); span.end(); return { @@ -685,7 +703,7 @@ export class SecretsClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listSecretsPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listSecretsPage(settings, updatedOptions) }; } @@ -747,8 +765,12 @@ export class SecretsClient { options?: ListSecretsOptions ): PagedAsyncIterableIterator { const span = this.createSpan("listDeletedSecrets", options && options.requestOptions); + const updatedOptions: ListSecretsOptions = { + ...options, + requestOptions: this.setParentSpan(span, options && options.requestOptions) + }; - const iter = this.listDeletedSecretsAll(options); + const iter = this.listDeletedSecretsAll(updatedOptions); span.end(); return { @@ -758,7 +780,7 @@ export class SecretsClient { [Symbol.asyncIterator]() { return this; }, - byPage: (settings: PageSettings = {}) => this.listDeletedSecretsPage(settings, options) + byPage: (settings: PageSettings = {}) => this.listDeletedSecretsPage(settings, updatedOptions) }; } @@ -809,20 +831,30 @@ export class SecretsClient { /** * Creates a span using the tracer that was set by the user * @param methodName The name of the method for which the span is being created. - * @param requestOptions The options for the underlying http request. This will be - * updated to use the newly created span as the "parent" so that any new spans created - * after this point gets the right parent. + * @param requestOptions The options for the underlying http request. */ private createSpan(methodName: string, requestOptions?: RequestOptionsBase): Span { const tracer = TracerProxy.getTracer(); - const options = requestOptions || {}; - const span = tracer.startSpan(methodName, options.spanOptions); - if ( - tracer.pluginType !== SupportedPlugins.NOOP && - (options.spanOptions && options.spanOptions.parent) - ) { - options.spanOptions = { ...options.spanOptions, parent: span }; + return tracer.startSpan(methodName, requestOptions && requestOptions.spanOptions); + } + + /** + * Returns updated HTTP options with the given span as the parent of future spans, + * if applicable. + * @param span The span for the current operation + * @param options The options for the underlying http request + */ + private setParentSpan(span: Span, options: RequestOptionsBase = {}): RequestOptionsBase { + if (span.isRecordingEvents()) { + return { + ...options, + spanOptions: { + ...options.spanOptions, + parent: span, + } + } + } else { + return options; } - return span; } } diff --git a/sdk/keyvault/keyvault-secrets/test/recoverBackupRestore.test.ts b/sdk/keyvault/keyvault-secrets/test/recoverBackupRestore.test.ts index a89a25a3e0c2..253bea01225f 100644 --- a/sdk/keyvault/keyvault-secrets/test/recoverBackupRestore.test.ts +++ b/sdk/keyvault/keyvault-secrets/test/recoverBackupRestore.test.ts @@ -16,7 +16,7 @@ describe("Secret client - restore secrets and recover backups", () => { let testClient: TestClient; let recorder: any; - before(async function() { + before(async function () { const authentication = await authenticate(this); secretSuffix = authentication.secretSuffix; client = authentication.client; @@ -24,13 +24,13 @@ describe("Secret client - restore secrets and recover backups", () => { recorder = authentication.recorder; }); - after(async function() { + after(async function () { recorder.stop(); }); // The tests follow - it("can recover a deleted secret", async function() { + it("can recover a deleted secret", async function () { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -48,7 +48,7 @@ describe("Secret client - restore secrets and recover backups", () => { await testClient.flushSecret(secretName); }); - it("can recover a deleted secret (non existing)", async function() { + it("can recover a deleted secret (non existing)", async function () { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -62,7 +62,7 @@ describe("Secret client - restore secrets and recover backups", () => { assert.equal(error.message, `Secret not found: ${secretName}`); }); - it("can backup a secret", async function() { + it("can backup a secret", async function () { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -75,12 +75,12 @@ describe("Secret client - restore secrets and recover backups", () => { } assert.ok( result!.length > 0, - `Unexpected length (${result.length}) of buffer from backupSecret()` + `Unexpected length (${result!.length}) of buffer from backupSecret()` ); await testClient.flushSecret(secretName); }); - it("can backup a secret (non existing)", async function() { + it("can backup a secret (non existing)", async function () { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -94,7 +94,7 @@ describe("Secret client - restore secrets and recover backups", () => { assert.equal(error.message, `Secret not found: ${secretName}`); }); - it("can restore a secret", async function() { + it("can restore a secret", async function () { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -107,7 +107,7 @@ describe("Secret client - restore secrets and recover backups", () => { await testClient.flushSecret(secretName); }); - it("can restore a secret (Malformed Backup Bytes)", async function() { + it("can restore a secret (Malformed Backup Bytes)", async function () { const backup = new Uint8Array(4728); let error; try {