From 1e938586e6b8015c67d89c1b830d4e6cdac6a7a6 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 14 Mar 2019 18:59:36 +0000 Subject: [PATCH] Generated from f908a393b3bf0589dcb06453efa3feb334565a64 fixing PR comments --- lib/services/peeringManagement/LICENSE.txt | 21 + .../lib/models/bgpSession.js | 151 ++ .../lib/models/contactInfo.js | 74 + .../lib/models/directConnection.js | 118 + .../lib/models/directPeeringFacility.js | 70 + .../lib/models/errorResponse.js | 62 + .../lib/models/exchangeConnection.js | 101 + .../lib/models/exchangePeeringFacility.js | 116 + .../peeringManagement/lib/models/index.d.ts | 489 ++++ .../peeringManagement/lib/models/index.js | 42 + .../peeringManagement/lib/models/operation.js | 77 + .../lib/models/operationDisplayInfo.js | 80 + .../lib/models/operationListResult.js | 68 + .../peeringManagement/lib/models/peerInfo.js | 82 + .../peeringManagement/lib/models/peering.js | 175 ++ .../lib/models/peeringBandwidthOffer.js | 60 + .../lib/models/peeringListResult.js | 67 + .../lib/models/peeringLocation.js | 133 ++ .../lib/models/peeringLocationListResult.js | 68 + .../models/peeringLocationPropertiesDirect.js | 78 + .../peeringLocationPropertiesExchange.js | 61 + .../lib/models/peeringPropertiesDirect.js | 79 + .../lib/models/peeringPropertiesExchange.js | 70 + .../lib/models/peeringSku.js | 81 + .../lib/models/resourceTags.js | 60 + .../lib/operations/index.d.ts | 964 ++++++++ .../peeringManagement/lib/operations/index.js | 20 + .../lib/operations/legacyPeerings.js | 484 ++++ .../lib/operations/operations.js | 451 ++++ .../lib/operations/peeringLocations.js | 478 ++++ .../lib/operations/peerings.js | 2030 +++++++++++++++++ .../lib/peeringManagementClient.d.ts | 169 ++ .../lib/peeringManagementClient.js | 573 +++++ lib/services/peeringManagement/package.json | 25 + 34 files changed, 7677 insertions(+) create mode 100644 lib/services/peeringManagement/LICENSE.txt create mode 100644 lib/services/peeringManagement/lib/models/bgpSession.js create mode 100644 lib/services/peeringManagement/lib/models/contactInfo.js create mode 100644 lib/services/peeringManagement/lib/models/directConnection.js create mode 100644 lib/services/peeringManagement/lib/models/directPeeringFacility.js create mode 100644 lib/services/peeringManagement/lib/models/errorResponse.js create mode 100644 lib/services/peeringManagement/lib/models/exchangeConnection.js create mode 100644 lib/services/peeringManagement/lib/models/exchangePeeringFacility.js create mode 100644 lib/services/peeringManagement/lib/models/index.d.ts create mode 100644 lib/services/peeringManagement/lib/models/index.js create mode 100644 lib/services/peeringManagement/lib/models/operation.js create mode 100644 lib/services/peeringManagement/lib/models/operationDisplayInfo.js create mode 100644 lib/services/peeringManagement/lib/models/operationListResult.js create mode 100644 lib/services/peeringManagement/lib/models/peerInfo.js create mode 100644 lib/services/peeringManagement/lib/models/peering.js create mode 100644 lib/services/peeringManagement/lib/models/peeringBandwidthOffer.js create mode 100644 lib/services/peeringManagement/lib/models/peeringListResult.js create mode 100644 lib/services/peeringManagement/lib/models/peeringLocation.js create mode 100644 lib/services/peeringManagement/lib/models/peeringLocationListResult.js create mode 100644 lib/services/peeringManagement/lib/models/peeringLocationPropertiesDirect.js create mode 100644 lib/services/peeringManagement/lib/models/peeringLocationPropertiesExchange.js create mode 100644 lib/services/peeringManagement/lib/models/peeringPropertiesDirect.js create mode 100644 lib/services/peeringManagement/lib/models/peeringPropertiesExchange.js create mode 100644 lib/services/peeringManagement/lib/models/peeringSku.js create mode 100644 lib/services/peeringManagement/lib/models/resourceTags.js create mode 100644 lib/services/peeringManagement/lib/operations/index.d.ts create mode 100644 lib/services/peeringManagement/lib/operations/index.js create mode 100644 lib/services/peeringManagement/lib/operations/legacyPeerings.js create mode 100644 lib/services/peeringManagement/lib/operations/operations.js create mode 100644 lib/services/peeringManagement/lib/operations/peeringLocations.js create mode 100644 lib/services/peeringManagement/lib/operations/peerings.js create mode 100644 lib/services/peeringManagement/lib/peeringManagementClient.d.ts create mode 100644 lib/services/peeringManagement/lib/peeringManagementClient.js create mode 100644 lib/services/peeringManagement/package.json diff --git a/lib/services/peeringManagement/LICENSE.txt b/lib/services/peeringManagement/LICENSE.txt new file mode 100644 index 0000000000..8f3d856145 --- /dev/null +++ b/lib/services/peeringManagement/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/lib/services/peeringManagement/lib/models/bgpSession.js b/lib/services/peeringManagement/lib/models/bgpSession.js new file mode 100644 index 0000000000..a6d285a0a2 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/bgpSession.js @@ -0,0 +1,151 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define a BGP session. + * + */ +class BgpSession { + /** + * Create a BgpSession. + * @property {string} [sessionPrefixV4] The IPv4 prefix that contains both + * ends' IPv4 addresses. + * @property {string} [sessionPrefixV6] The IPv6 prefix that contains both + * ends' IPv6 addresses. + * @property {string} [microsoftSessionIPv4Address] The IPv4 session address + * on Microsoft's end. + * @property {string} [microsoftSessionIPv6Address] The IPv6 session address + * on Microsoft's end. + * @property {string} [peerSessionIPv4Address] The IPv4 session address on + * peer's end. + * @property {string} [peerSessionIPv6Address] The IPv6 session address on + * peer's end. + * @property {string} [sessionStateV4] The state of the IPv4 session. + * Possible values include: 'None', 'Idle', 'Connect', 'Active', 'OpenSent', + * 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * @property {string} [sessionStateV6] The state of the IPv6 session. + * Possible values include: 'None', 'Idle', 'Connect', 'Active', 'OpenSent', + * 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * @property {number} [maxPrefixesAdvertisedV4] The maximum number of + * prefixes advertised over the IPv4 session. + * @property {number} [maxPrefixesAdvertisedV6] The maximum number of + * prefixes advertised over the IPv6 session. + * @property {string} [md5AuthenticationKey] The MD5 authentication key of + * the session. + */ + constructor() { + } + + /** + * Defines the metadata of BgpSession + * + * @returns {object} metadata of BgpSession + * + */ + mapper() { + return { + required: false, + serializedName: 'BgpSession', + type: { + name: 'Composite', + className: 'BgpSession', + modelProperties: { + sessionPrefixV4: { + required: false, + serializedName: 'sessionPrefixV4', + type: { + name: 'String' + } + }, + sessionPrefixV6: { + required: false, + serializedName: 'sessionPrefixV6', + type: { + name: 'String' + } + }, + microsoftSessionIPv4Address: { + required: false, + readOnly: true, + serializedName: 'microsoftSessionIPv4Address', + type: { + name: 'String' + } + }, + microsoftSessionIPv6Address: { + required: false, + readOnly: true, + serializedName: 'microsoftSessionIPv6Address', + type: { + name: 'String' + } + }, + peerSessionIPv4Address: { + required: false, + serializedName: 'peerSessionIPv4Address', + type: { + name: 'String' + } + }, + peerSessionIPv6Address: { + required: false, + serializedName: 'peerSessionIPv6Address', + type: { + name: 'String' + } + }, + sessionStateV4: { + required: false, + readOnly: true, + serializedName: 'sessionStateV4', + type: { + name: 'String' + } + }, + sessionStateV6: { + required: false, + readOnly: true, + serializedName: 'sessionStateV6', + type: { + name: 'String' + } + }, + maxPrefixesAdvertisedV4: { + required: false, + serializedName: 'maxPrefixesAdvertisedV4', + type: { + name: 'Number' + } + }, + maxPrefixesAdvertisedV6: { + required: false, + serializedName: 'maxPrefixesAdvertisedV6', + type: { + name: 'Number' + } + }, + md5AuthenticationKey: { + required: false, + serializedName: 'md5AuthenticationKey', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BgpSession; diff --git a/lib/services/peeringManagement/lib/models/contactInfo.js b/lib/services/peeringManagement/lib/models/contactInfo.js new file mode 100644 index 0000000000..f66daa41b5 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/contactInfo.js @@ -0,0 +1,74 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The contact information of the peer. + * + */ +class ContactInfo { + /** + * Create a ContactInfo. + * @property {array} [emails] The list of email addresses. + * @property {array} [phone] The list of contact numbers. + */ + constructor() { + } + + /** + * Defines the metadata of ContactInfo + * + * @returns {object} metadata of ContactInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'ContactInfo', + type: { + name: 'Composite', + className: 'ContactInfo', + modelProperties: { + emails: { + required: false, + serializedName: 'emails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + phone: { + required: false, + serializedName: 'phone', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ContactInfo; diff --git a/lib/services/peeringManagement/lib/models/directConnection.js b/lib/services/peeringManagement/lib/models/directConnection.js new file mode 100644 index 0000000000..ea239c7959 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/directConnection.js @@ -0,0 +1,118 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define a direct connection. + * + */ +class DirectConnection { + /** + * Create a DirectConnection. + * @property {number} [bandwidthInMbps] The bandwidth of the connection. + * @property {number} [provisionedBandwidthInMbps] The bandwidth that is + * actually provisioned. + * @property {number} [peeringDBFacilityId] The PeeringDB.com ID of the + * facility at which the connection has to be set up. + * @property {string} [connectionState] The state of the connection. Possible + * values include: 'None', 'PendingApproval', 'Approved', + * 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', + * 'Validating', 'Active' + * @property {object} [bgpSession] The BGP session associated with the + * connection. + * @property {string} [bgpSession.sessionPrefixV4] The IPv4 prefix that + * contains both ends' IPv4 addresses. + * @property {string} [bgpSession.sessionPrefixV6] The IPv6 prefix that + * contains both ends' IPv6 addresses. + * @property {string} [bgpSession.microsoftSessionIPv4Address] The IPv4 + * session address on Microsoft's end. + * @property {string} [bgpSession.microsoftSessionIPv6Address] The IPv6 + * session address on Microsoft's end. + * @property {string} [bgpSession.peerSessionIPv4Address] The IPv4 session + * address on peer's end. + * @property {string} [bgpSession.peerSessionIPv6Address] The IPv6 session + * address on peer's end. + * @property {string} [bgpSession.sessionStateV4] The state of the IPv4 + * session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * @property {string} [bgpSession.sessionStateV6] The state of the IPv6 + * session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * @property {number} [bgpSession.maxPrefixesAdvertisedV4] The maximum number + * of prefixes advertised over the IPv4 session. + * @property {number} [bgpSession.maxPrefixesAdvertisedV6] The maximum number + * of prefixes advertised over the IPv6 session. + * @property {string} [bgpSession.md5AuthenticationKey] The MD5 + * authentication key of the session. + */ + constructor() { + } + + /** + * Defines the metadata of DirectConnection + * + * @returns {object} metadata of DirectConnection + * + */ + mapper() { + return { + required: false, + serializedName: 'DirectConnection', + type: { + name: 'Composite', + className: 'DirectConnection', + modelProperties: { + bandwidthInMbps: { + required: false, + serializedName: 'bandwidthInMbps', + type: { + name: 'Number' + } + }, + provisionedBandwidthInMbps: { + required: false, + serializedName: 'provisionedBandwidthInMbps', + type: { + name: 'Number' + } + }, + peeringDBFacilityId: { + required: false, + serializedName: 'peeringDBFacilityId', + type: { + name: 'Number' + } + }, + connectionState: { + required: false, + readOnly: true, + serializedName: 'connectionState', + type: { + name: 'String' + } + }, + bgpSession: { + required: false, + serializedName: 'bgpSession', + type: { + name: 'Composite', + className: 'BgpSession' + } + } + } + } + }; + } +} + +module.exports = DirectConnection; diff --git a/lib/services/peeringManagement/lib/models/directPeeringFacility.js b/lib/services/peeringManagement/lib/models/directPeeringFacility.js new file mode 100644 index 0000000000..c69e3edd88 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/directPeeringFacility.js @@ -0,0 +1,70 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define a direct peering facility. + * + */ +class DirectPeeringFacility { + /** + * Create a DirectPeeringFacility. + * @property {string} [address] The address of the direct peering facility. + * @property {number} [peeringDBFacilityId] The PeeringDB.com ID of the + * facility. + * @property {string} [peeringDBFacilityLink] The PeeringDB.com URL of the + * facility. + */ + constructor() { + } + + /** + * Defines the metadata of DirectPeeringFacility + * + * @returns {object} metadata of DirectPeeringFacility + * + */ + mapper() { + return { + required: false, + serializedName: 'DirectPeeringFacility', + type: { + name: 'Composite', + className: 'DirectPeeringFacility', + modelProperties: { + address: { + required: false, + serializedName: 'address', + type: { + name: 'String' + } + }, + peeringDBFacilityId: { + required: false, + serializedName: 'peeringDBFacilityId', + type: { + name: 'Number' + } + }, + peeringDBFacilityLink: { + required: false, + serializedName: 'peeringDBFacilityLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DirectPeeringFacility; diff --git a/lib/services/peeringManagement/lib/models/errorResponse.js b/lib/services/peeringManagement/lib/models/errorResponse.js new file mode 100644 index 0000000000..cee654e420 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/errorResponse.js @@ -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. + */ + +'use strict'; + +/** + * The error response that indicates why an operation has failed. + * + */ +class ErrorResponse { + /** + * Create a ErrorResponse. + * @property {string} [code] The error code. + * @property {string} [message] The error message. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorResponse + * + * @returns {object} metadata of ErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorResponse', + type: { + name: 'Composite', + className: 'ErrorResponse', + modelProperties: { + code: { + required: false, + readOnly: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + readOnly: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorResponse; diff --git a/lib/services/peeringManagement/lib/models/exchangeConnection.js b/lib/services/peeringManagement/lib/models/exchangeConnection.js new file mode 100644 index 0000000000..652ab3131d --- /dev/null +++ b/lib/services/peeringManagement/lib/models/exchangeConnection.js @@ -0,0 +1,101 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define an exchange connection. + * + */ +class ExchangeConnection { + /** + * Create a ExchangeConnection. + * @property {number} [peeringDBFacilityId] The PeeringDB.com ID of the + * facility at which the connection has to be set up. + * @property {string} [connectionState] The state of the connection. Possible + * values include: 'None', 'PendingApproval', 'Approved', + * 'ProvisioningStarted', 'ProvisioningFailed', 'ProvisioningCompleted', + * 'Validating', 'Active' + * @property {object} [bgpSession] The BGP session associated with the + * connection. + * @property {string} [bgpSession.sessionPrefixV4] The IPv4 prefix that + * contains both ends' IPv4 addresses. + * @property {string} [bgpSession.sessionPrefixV6] The IPv6 prefix that + * contains both ends' IPv6 addresses. + * @property {string} [bgpSession.microsoftSessionIPv4Address] The IPv4 + * session address on Microsoft's end. + * @property {string} [bgpSession.microsoftSessionIPv6Address] The IPv6 + * session address on Microsoft's end. + * @property {string} [bgpSession.peerSessionIPv4Address] The IPv4 session + * address on peer's end. + * @property {string} [bgpSession.peerSessionIPv6Address] The IPv6 session + * address on peer's end. + * @property {string} [bgpSession.sessionStateV4] The state of the IPv4 + * session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * @property {string} [bgpSession.sessionStateV6] The state of the IPv6 + * session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', + * 'PendingRemove' + * @property {number} [bgpSession.maxPrefixesAdvertisedV4] The maximum number + * of prefixes advertised over the IPv4 session. + * @property {number} [bgpSession.maxPrefixesAdvertisedV6] The maximum number + * of prefixes advertised over the IPv6 session. + * @property {string} [bgpSession.md5AuthenticationKey] The MD5 + * authentication key of the session. + */ + constructor() { + } + + /** + * Defines the metadata of ExchangeConnection + * + * @returns {object} metadata of ExchangeConnection + * + */ + mapper() { + return { + required: false, + serializedName: 'ExchangeConnection', + type: { + name: 'Composite', + className: 'ExchangeConnection', + modelProperties: { + peeringDBFacilityId: { + required: false, + serializedName: 'peeringDBFacilityId', + type: { + name: 'Number' + } + }, + connectionState: { + required: false, + readOnly: true, + serializedName: 'connectionState', + type: { + name: 'String' + } + }, + bgpSession: { + required: false, + serializedName: 'bgpSession', + type: { + name: 'Composite', + className: 'BgpSession' + } + } + } + } + }; + } +} + +module.exports = ExchangeConnection; diff --git a/lib/services/peeringManagement/lib/models/exchangePeeringFacility.js b/lib/services/peeringManagement/lib/models/exchangePeeringFacility.js new file mode 100644 index 0000000000..03a2155621 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/exchangePeeringFacility.js @@ -0,0 +1,116 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define an exchange peering facility. + * + */ +class ExchangePeeringFacility { + /** + * Create a ExchangePeeringFacility. + * @property {string} [exchangeName] The name of the exchange peering + * facility. + * @property {number} [bandwidthInMbps] The bandwidth of the connection + * between Microsoft and the exchange peering facility. + * @property {string} [microsoftIPv4Address] The IPv4 address of Microsoft at + * the exchange peering facility. + * @property {string} [microsoftIPv6Address] The IPv6 address of Microsoft at + * the exchange peering facility. + * @property {string} [facilityIPv4Prefix] The IPv4 prefixes associated with + * the exchange peering facility. + * @property {string} [facilityIPv6Prefix] The IPv6 prefixes associated with + * the exchange peering facility. + * @property {number} [peeringDBFacilityId] The PeeringDB.com ID of the + * facility. + * @property {string} [peeringDBFacilityLink] The PeeringDB.com URL of the + * facility. + */ + constructor() { + } + + /** + * Defines the metadata of ExchangePeeringFacility + * + * @returns {object} metadata of ExchangePeeringFacility + * + */ + mapper() { + return { + required: false, + serializedName: 'ExchangePeeringFacility', + type: { + name: 'Composite', + className: 'ExchangePeeringFacility', + modelProperties: { + exchangeName: { + required: false, + serializedName: 'exchangeName', + type: { + name: 'String' + } + }, + bandwidthInMbps: { + required: false, + serializedName: 'bandwidthInMbps', + type: { + name: 'Number' + } + }, + microsoftIPv4Address: { + required: false, + serializedName: 'microsoftIPv4Address', + type: { + name: 'String' + } + }, + microsoftIPv6Address: { + required: false, + serializedName: 'microsoftIPv6Address', + type: { + name: 'String' + } + }, + facilityIPv4Prefix: { + required: false, + serializedName: 'facilityIPv4Prefix', + type: { + name: 'String' + } + }, + facilityIPv6Prefix: { + required: false, + serializedName: 'facilityIPv6Prefix', + type: { + name: 'String' + } + }, + peeringDBFacilityId: { + required: false, + serializedName: 'peeringDBFacilityId', + type: { + name: 'Number' + } + }, + peeringDBFacilityLink: { + required: false, + serializedName: 'peeringDBFacilityLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ExchangePeeringFacility; diff --git a/lib/services/peeringManagement/lib/models/index.d.ts b/lib/services/peeringManagement/lib/models/index.d.ts new file mode 100644 index 0000000000..2c13929801 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/index.d.ts @@ -0,0 +1,489 @@ +/* + * 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 } from "ms-rest-azure"; +import * as moment from "moment"; + +export { + + BaseResource, + CloudError +}; + +/** + * 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' + */ + name?: string; + /** + * The tier of the peering SKU. Possible values include: 'Basic', 'Premium' + */ + tier?: string; + /** + * The family of the peering SKU. Possible values include: 'Direct', 'Exchange' + */ + family?: string; + /** + * The size of the peering SKU. Possible values include: 'Free', 'Metered', 'Unlimited' + */ + size?: string; +} + +/** + * 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. + */ + readonly microsoftSessionIPv4Address?: string; + /** + * The IPv6 session address on Microsoft's end. + */ + 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', 'Established', 'PendingAdd', 'PendingUpdate', 'PendingRemove' + */ + readonly sessionStateV4?: string; + /** + * The state of the IPv6 session. Possible values include: 'None', 'Idle', 'Connect', 'Active', + * 'OpenSent', 'OpenConfirm', 'Established', 'PendingAdd', 'PendingUpdate', 'PendingRemove' + */ + readonly sessionStateV6?: string; + /** + * 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 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' + */ + readonly connectionState?: string; + /** + * The BGP session associated with the connection. + */ + bgpSession?: BgpSession; +} + +/** + * The properties that define a direct peering. + */ +export interface PeeringPropertiesDirect { + /** + * The set of connections that constitute a direct peering. + */ + connections?: DirectConnection[]; + /** + * The Autonomous System Number (ASN) associated with the peering. + */ + peerAsn?: number; + /** + * The flag that indicates whether or not the peering is used for peering service. + */ + useForPeeringService?: boolean; +} + +/** + * 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' + */ + readonly connectionState?: string; + /** + * The BGP session associated with the connection. + */ + bgpSession?: BgpSession; +} + +/** + * The properties that define an exchange peering. + */ +export interface PeeringPropertiesExchange { + /** + * The set of connections that constitute an exchange peering. + */ + connections?: ExchangeConnection[]; + /** + * The Autonomous System Number (ASN) associated with the peering. + */ + peerAsn?: number; +} + +/** + * Peering is a logical representation of a set of connections to the Microsoft Cloud Edge at a + * location. + */ +export interface Peering extends BaseResource { + /** + * The SKU that defines the tier and kind of the peering. + */ + sku: PeeringSku; + /** + * The kind of the peering. Possible values include: 'Direct', 'Exchange' + */ + kind: string; + /** + * 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' + */ + readonly provisioningState?: string; + /** + * The location of the resource. + */ + location: string; + /** + * The resource tags. + */ + tags?: { [propertyName: string]: string }; + /** + * The name of the resource. + */ + readonly name?: string; + /** + * The ID of the resource. + */ + readonly id?: string; + /** + * The type of the resource. + */ + readonly type?: string; +} + +/** + * The error response that indicates why an operation has failed. + */ +export interface ErrorResponse { + /** + * The error code. + */ + readonly code?: string; + /** + * The error message. + */ + readonly message?: string; +} + +/** + * The information related to the operation. + */ +export interface OperationDisplayInfo { + /** + * The name of the resource provider. + */ + readonly provider?: string; + /** + * The type of the resource. + */ + readonly resource?: string; + /** + * The name of the operation. + */ + readonly operation?: string; + /** + * The description of the operation. + */ + readonly description?: string; +} + +/** + * The peering API operation. + */ +export interface Operation { + /** + * The name of the operation. + */ + readonly name?: string; + /** + * The information related to the operation. + */ + readonly display?: OperationDisplayInfo; + /** + * The flag that indicates whether the operation applies to data plane. + */ + 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. + */ +export interface PeerInfo { + /** + * 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?: string; +} + +/** + * The properties that define a direct peering facility. + */ +export interface DirectPeeringFacility { + /** + * The address of the direct peering facility. + */ + address?: string; + /** + * 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 { + /** + * The kind of peering that the peering location supports. Possible values include: 'Direct', + * 'Exchange' + */ + kind?: string; + /** + * 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 name of the resource. + */ + readonly name?: string; + /** + * The ID of the resource. + */ + readonly id?: string; + /** + * The type of the resource. + */ + readonly type?: string; +} + +/** + * The resource tags. + */ +export interface ResourceTags { + /** + * Gets or sets the tags, a dictionary of descriptors arm object + */ + tags?: { [propertyName: string]: string }; +} + +/** + * The paginated list of peerings. + */ +export interface PeeringListResult extends Array { + /** + * The link to fetch the next page of peerings. + */ + nextLink?: string; +} + +/** + * The paginated list of peering API operations. + */ +export interface OperationListResult extends Array { + /** + * The link to fetch the next page of peering API operations. + */ + nextLink?: string; +} + +/** + * The paginated list of peering locations. + */ +export interface PeeringLocationListResult extends Array { + /** + * The link to fetch the next page of peering locations. + */ + nextLink?: string; +} diff --git a/lib/services/peeringManagement/lib/models/index.js b/lib/services/peeringManagement/lib/models/index.js new file mode 100644 index 0000000000..b713667484 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/index.js @@ -0,0 +1,42 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var msRestAzure = require('ms-rest-azure'); + +exports.BaseResource = msRestAzure.BaseResource; +exports.CloudError = msRestAzure.CloudError; +exports.PeeringSku = require('./peeringSku'); +exports.BgpSession = require('./bgpSession'); +exports.DirectConnection = require('./directConnection'); +exports.PeeringPropertiesDirect = require('./peeringPropertiesDirect'); +exports.ExchangeConnection = require('./exchangeConnection'); +exports.PeeringPropertiesExchange = require('./peeringPropertiesExchange'); +exports.Peering = require('./peering'); +exports.ErrorResponse = require('./errorResponse'); +exports.OperationDisplayInfo = require('./operationDisplayInfo'); +exports.Operation = require('./operation'); +exports.ContactInfo = require('./contactInfo'); +exports.PeerInfo = require('./peerInfo'); +exports.DirectPeeringFacility = require('./directPeeringFacility'); +exports.PeeringBandwidthOffer = require('./peeringBandwidthOffer'); +exports.PeeringLocationPropertiesDirect = require('./peeringLocationPropertiesDirect'); +exports.ExchangePeeringFacility = require('./exchangePeeringFacility'); +exports.PeeringLocationPropertiesExchange = require('./peeringLocationPropertiesExchange'); +exports.PeeringLocation = require('./peeringLocation'); +exports.ResourceTags = require('./resourceTags'); +exports.PeeringListResult = require('./peeringListResult'); +exports.OperationListResult = require('./operationListResult'); +exports.PeeringLocationListResult = require('./peeringLocationListResult'); diff --git a/lib/services/peeringManagement/lib/models/operation.js b/lib/services/peeringManagement/lib/models/operation.js new file mode 100644 index 0000000000..a37f3c1bca --- /dev/null +++ b/lib/services/peeringManagement/lib/models/operation.js @@ -0,0 +1,77 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The peering API operation. + * + */ +class Operation { + /** + * Create a Operation. + * @property {string} [name] The name of the operation. + * @property {object} [display] The information related to the operation. + * @property {string} [display.provider] The name of the resource provider. + * @property {string} [display.resource] The type of the resource. + * @property {string} [display.operation] The name of the operation. + * @property {string} [display.description] The description of the operation. + * @property {boolean} [isDataAction] The flag that indicates whether the + * operation applies to data plane. + */ + constructor() { + } + + /** + * Defines the metadata of Operation + * + * @returns {object} metadata of Operation + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation', + type: { + name: 'Composite', + className: 'Operation', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + readOnly: true, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplayInfo' + } + }, + isDataAction: { + required: false, + readOnly: true, + serializedName: 'isDataAction', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/peeringManagement/lib/models/operationDisplayInfo.js b/lib/services/peeringManagement/lib/models/operationDisplayInfo.js new file mode 100644 index 0000000000..b46c3c47a7 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/operationDisplayInfo.js @@ -0,0 +1,80 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The information related to the operation. + * + */ +class OperationDisplayInfo { + /** + * Create a OperationDisplayInfo. + * @property {string} [provider] The name of the resource provider. + * @property {string} [resource] The type of the resource. + * @property {string} [operation] The name of the operation. + * @property {string} [description] The description of the operation. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplayInfo + * + * @returns {object} metadata of OperationDisplayInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationDisplayInfo', + type: { + name: 'Composite', + className: 'OperationDisplayInfo', + modelProperties: { + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'String' + } + }, + resource: { + required: false, + readOnly: true, + serializedName: 'resource', + type: { + name: 'String' + } + }, + operation: { + required: false, + readOnly: true, + serializedName: 'operation', + type: { + name: 'String' + } + }, + description: { + required: false, + readOnly: true, + serializedName: 'description', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplayInfo; diff --git a/lib/services/peeringManagement/lib/models/operationListResult.js b/lib/services/peeringManagement/lib/models/operationListResult.js new file mode 100644 index 0000000000..94e23ef23a --- /dev/null +++ b/lib/services/peeringManagement/lib/models/operationListResult.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The paginated list of peering API operations. + */ +class OperationListResult extends Array { + /** + * Create a OperationListResult. + * @property {string} [nextLink] The link to fetch the next page of peering + * API operations. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of OperationListResult + * + * @returns {object} metadata of OperationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationListResult', + type: { + name: 'Composite', + className: 'OperationListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationElementType', + type: { + name: 'Composite', + className: 'Operation' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationListResult; diff --git a/lib/services/peeringManagement/lib/models/peerInfo.js b/lib/services/peeringManagement/lib/models/peerInfo.js new file mode 100644 index 0000000000..5aa47d9ebe --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peerInfo.js @@ -0,0 +1,82 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The essential information related to the peer. + * + */ +class PeerInfo { + /** + * Create a PeerInfo. + * @property {number} [peerAsn] The Autonomous System Number (ASN) of the + * peer. + * @property {object} [peerContactInfo] The contact information of the peer. + * @property {array} [peerContactInfo.emails] The list of email addresses. + * @property {array} [peerContactInfo.phone] The list of contact numbers. + * @property {string} [peerName] The name of the peer. + * @property {string} [validationState] The validation state of the ASN + * associated with the peer. Possible values include: 'None', 'Pending', + * 'Approved', 'Failed' + */ + constructor() { + } + + /** + * Defines the metadata of PeerInfo + * + * @returns {object} metadata of PeerInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'PeerInfo', + type: { + name: 'Composite', + className: 'PeerInfo', + modelProperties: { + peerAsn: { + required: false, + serializedName: 'peerAsn', + type: { + name: 'Number' + } + }, + peerContactInfo: { + required: false, + serializedName: 'peerContactInfo', + type: { + name: 'Composite', + className: 'ContactInfo' + } + }, + peerName: { + required: false, + serializedName: 'peerName', + type: { + name: 'String' + } + }, + validationState: { + required: false, + serializedName: 'validationState', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PeerInfo; diff --git a/lib/services/peeringManagement/lib/models/peering.js b/lib/services/peeringManagement/lib/models/peering.js new file mode 100644 index 0000000000..0c4d448966 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peering.js @@ -0,0 +1,175 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Peering is a logical representation of a set of connections to the Microsoft + * Cloud Edge at a location. + * + * @extends models['BaseResource'] + */ +class Peering extends models['BaseResource'] { + /** + * Create a Peering. + * @property {object} sku The SKU that defines the tier and kind of the + * peering. + * @property {string} [sku.name] The name of the peering SKU. Possible values + * include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * @property {string} [sku.tier] The tier of the peering SKU. Possible values + * include: 'Basic', 'Premium' + * @property {string} [sku.family] The family of the peering SKU. Possible + * values include: 'Direct', 'Exchange' + * @property {string} [sku.size] The size of the peering SKU. Possible values + * include: 'Free', 'Metered', 'Unlimited' + * @property {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * @property {object} [direct] The properties that define a direct peering. + * @property {array} [direct.connections] The set of connections that + * constitute a direct peering. + * @property {number} [direct.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * @property {boolean} [direct.useForPeeringService] The flag that indicates + * whether or not the peering is used for peering service. + * @property {object} [exchange] The properties that define an exchange + * peering. + * @property {array} [exchange.connections] The set of connections that + * constitute an exchange peering. + * @property {number} [exchange.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * @property {string} [peeringLocation] The location of the peering. + * @property {string} [provisioningState] The provisioning state of the + * resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', + * 'Failed' + * @property {string} location The location of the resource. + * @property {object} [tags] The resource tags. + * @property {string} [name] The name of the resource. + * @property {string} [id] The ID of the resource. + * @property {string} [type] The type of the resource. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Peering + * + * @returns {object} metadata of Peering + * + */ + mapper() { + return { + required: false, + serializedName: 'Peering', + type: { + name: 'Composite', + className: 'Peering', + modelProperties: { + sku: { + required: true, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'PeeringSku' + } + }, + kind: { + required: true, + serializedName: 'kind', + type: { + name: 'String' + } + }, + direct: { + required: false, + serializedName: 'properties.direct', + type: { + name: 'Composite', + className: 'PeeringPropertiesDirect' + } + }, + exchange: { + required: false, + serializedName: 'properties.exchange', + type: { + name: 'Composite', + className: 'PeeringPropertiesExchange' + } + }, + peeringLocation: { + required: false, + serializedName: 'properties.peeringLocation', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Peering; diff --git a/lib/services/peeringManagement/lib/models/peeringBandwidthOffer.js b/lib/services/peeringManagement/lib/models/peeringBandwidthOffer.js new file mode 100644 index 0000000000..9f22a31bd7 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringBandwidthOffer.js @@ -0,0 +1,60 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define a peering bandwidth offer. + * + */ +class PeeringBandwidthOffer { + /** + * Create a PeeringBandwidthOffer. + * @property {string} [offerName] The name of the bandwidth offer. + * @property {number} [valueInMbps] The value of the bandwidth offer in Mbps. + */ + constructor() { + } + + /** + * Defines the metadata of PeeringBandwidthOffer + * + * @returns {object} metadata of PeeringBandwidthOffer + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringBandwidthOffer', + type: { + name: 'Composite', + className: 'PeeringBandwidthOffer', + modelProperties: { + offerName: { + required: false, + serializedName: 'offerName', + type: { + name: 'String' + } + }, + valueInMbps: { + required: false, + serializedName: 'valueInMbps', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = PeeringBandwidthOffer; diff --git a/lib/services/peeringManagement/lib/models/peeringListResult.js b/lib/services/peeringManagement/lib/models/peeringListResult.js new file mode 100644 index 0000000000..dc80ece1e4 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringListResult.js @@ -0,0 +1,67 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The paginated list of peerings. + */ +class PeeringListResult extends Array { + /** + * Create a PeeringListResult. + * @property {string} [nextLink] The link to fetch the next page of peerings. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of PeeringListResult + * + * @returns {object} metadata of PeeringListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringListResult', + type: { + name: 'Composite', + className: 'PeeringListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PeeringElementType', + type: { + name: 'Composite', + className: 'Peering' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PeeringListResult; diff --git a/lib/services/peeringManagement/lib/models/peeringLocation.js b/lib/services/peeringManagement/lib/models/peeringLocation.js new file mode 100644 index 0000000000..5166cac80d --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringLocation.js @@ -0,0 +1,133 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Peering location is where connectivity could be established to the Microsoft + * Cloud Edge. + * + */ +class PeeringLocation { + /** + * Create a PeeringLocation. + * @property {string} [kind] The kind of peering that the peering location + * supports. Possible values include: 'Direct', 'Exchange' + * @property {object} [direct] The properties that define a direct peering + * location. + * @property {array} [direct.peeringFacilities] The list of direct peering + * facilities at the peering location. + * @property {array} [direct.bandwidthOffers] The list of bandwidth offers + * available at the peering location. + * @property {object} [exchange] The properties that define an exchange + * peering location. + * @property {array} [exchange.peeringFacilities] The list of exchange + * peering facilities at the peering location. + * @property {string} [peeringLocation] The name of the peering location. + * @property {string} [country] The country in which the peering location + * exists. + * @property {string} [azureRegion] The Azure region associated with the + * peering location. + * @property {string} [name] The name of the resource. + * @property {string} [id] The ID of the resource. + * @property {string} [type] The type of the resource. + */ + constructor() { + } + + /** + * Defines the metadata of PeeringLocation + * + * @returns {object} metadata of PeeringLocation + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringLocation', + type: { + name: 'Composite', + className: 'PeeringLocation', + modelProperties: { + kind: { + required: false, + serializedName: 'kind', + type: { + name: 'String' + } + }, + direct: { + required: false, + serializedName: 'properties.direct', + type: { + name: 'Composite', + className: 'PeeringLocationPropertiesDirect' + } + }, + exchange: { + required: false, + serializedName: 'properties.exchange', + type: { + name: 'Composite', + className: 'PeeringLocationPropertiesExchange' + } + }, + peeringLocation: { + required: false, + serializedName: 'properties.peeringLocation', + type: { + name: 'String' + } + }, + country: { + required: false, + serializedName: 'properties.country', + type: { + name: 'String' + } + }, + azureRegion: { + required: false, + serializedName: 'properties.azureRegion', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PeeringLocation; diff --git a/lib/services/peeringManagement/lib/models/peeringLocationListResult.js b/lib/services/peeringManagement/lib/models/peeringLocationListResult.js new file mode 100644 index 0000000000..4839999de8 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringLocationListResult.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The paginated list of peering locations. + */ +class PeeringLocationListResult extends Array { + /** + * Create a PeeringLocationListResult. + * @property {string} [nextLink] The link to fetch the next page of peering + * locations. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of PeeringLocationListResult + * + * @returns {object} metadata of PeeringLocationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringLocationListResult', + type: { + name: 'Composite', + className: 'PeeringLocationListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PeeringLocationElementType', + type: { + name: 'Composite', + className: 'PeeringLocation' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PeeringLocationListResult; diff --git a/lib/services/peeringManagement/lib/models/peeringLocationPropertiesDirect.js b/lib/services/peeringManagement/lib/models/peeringLocationPropertiesDirect.js new file mode 100644 index 0000000000..d3f11baf1b --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringLocationPropertiesDirect.js @@ -0,0 +1,78 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define a direct peering location. + * + */ +class PeeringLocationPropertiesDirect { + /** + * Create a PeeringLocationPropertiesDirect. + * @property {array} [peeringFacilities] The list of direct peering + * facilities at the peering location. + * @property {array} [bandwidthOffers] The list of bandwidth offers available + * at the peering location. + */ + constructor() { + } + + /** + * Defines the metadata of PeeringLocationPropertiesDirect + * + * @returns {object} metadata of PeeringLocationPropertiesDirect + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringLocationPropertiesDirect', + type: { + name: 'Composite', + className: 'PeeringLocationPropertiesDirect', + modelProperties: { + peeringFacilities: { + required: false, + serializedName: 'peeringFacilities', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DirectPeeringFacilityElementType', + type: { + name: 'Composite', + className: 'DirectPeeringFacility' + } + } + } + }, + bandwidthOffers: { + required: false, + serializedName: 'bandwidthOffers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PeeringBandwidthOfferElementType', + type: { + name: 'Composite', + className: 'PeeringBandwidthOffer' + } + } + } + } + } + } + }; + } +} + +module.exports = PeeringLocationPropertiesDirect; diff --git a/lib/services/peeringManagement/lib/models/peeringLocationPropertiesExchange.js b/lib/services/peeringManagement/lib/models/peeringLocationPropertiesExchange.js new file mode 100644 index 0000000000..824ce190e6 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringLocationPropertiesExchange.js @@ -0,0 +1,61 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define an exchange peering location. + * + */ +class PeeringLocationPropertiesExchange { + /** + * Create a PeeringLocationPropertiesExchange. + * @property {array} [peeringFacilities] The list of exchange peering + * facilities at the peering location. + */ + constructor() { + } + + /** + * Defines the metadata of PeeringLocationPropertiesExchange + * + * @returns {object} metadata of PeeringLocationPropertiesExchange + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringLocationPropertiesExchange', + type: { + name: 'Composite', + className: 'PeeringLocationPropertiesExchange', + modelProperties: { + peeringFacilities: { + required: false, + serializedName: 'peeringFacilities', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ExchangePeeringFacilityElementType', + type: { + name: 'Composite', + className: 'ExchangePeeringFacility' + } + } + } + } + } + } + }; + } +} + +module.exports = PeeringLocationPropertiesExchange; diff --git a/lib/services/peeringManagement/lib/models/peeringPropertiesDirect.js b/lib/services/peeringManagement/lib/models/peeringPropertiesDirect.js new file mode 100644 index 0000000000..c33cf9cad7 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringPropertiesDirect.js @@ -0,0 +1,79 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define a direct peering. + * + */ +class PeeringPropertiesDirect { + /** + * Create a PeeringPropertiesDirect. + * @property {array} [connections] The set of connections that constitute a + * direct peering. + * @property {number} [peerAsn] The Autonomous System Number (ASN) associated + * with the peering. + * @property {boolean} [useForPeeringService] The flag that indicates whether + * or not the peering is used for peering service. + */ + constructor() { + } + + /** + * Defines the metadata of PeeringPropertiesDirect + * + * @returns {object} metadata of PeeringPropertiesDirect + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringPropertiesDirect', + type: { + name: 'Composite', + className: 'PeeringPropertiesDirect', + modelProperties: { + connections: { + required: false, + serializedName: 'connections', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DirectConnectionElementType', + type: { + name: 'Composite', + className: 'DirectConnection' + } + } + } + }, + peerAsn: { + required: false, + serializedName: 'peerAsn', + type: { + name: 'Number' + } + }, + useForPeeringService: { + required: false, + serializedName: 'useForPeeringService', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = PeeringPropertiesDirect; diff --git a/lib/services/peeringManagement/lib/models/peeringPropertiesExchange.js b/lib/services/peeringManagement/lib/models/peeringPropertiesExchange.js new file mode 100644 index 0000000000..5cbb73f7b4 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringPropertiesExchange.js @@ -0,0 +1,70 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The properties that define an exchange peering. + * + */ +class PeeringPropertiesExchange { + /** + * Create a PeeringPropertiesExchange. + * @property {array} [connections] The set of connections that constitute an + * exchange peering. + * @property {number} [peerAsn] The Autonomous System Number (ASN) associated + * with the peering. + */ + constructor() { + } + + /** + * Defines the metadata of PeeringPropertiesExchange + * + * @returns {object} metadata of PeeringPropertiesExchange + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringPropertiesExchange', + type: { + name: 'Composite', + className: 'PeeringPropertiesExchange', + modelProperties: { + connections: { + required: false, + serializedName: 'connections', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ExchangeConnectionElementType', + type: { + name: 'Composite', + className: 'ExchangeConnection' + } + } + } + }, + peerAsn: { + required: false, + serializedName: 'peerAsn', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = PeeringPropertiesExchange; diff --git a/lib/services/peeringManagement/lib/models/peeringSku.js b/lib/services/peeringManagement/lib/models/peeringSku.js new file mode 100644 index 0000000000..1c6d2b14d3 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/peeringSku.js @@ -0,0 +1,81 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The SKU that defines the tier and kind of the peering. + * + */ +class PeeringSku { + /** + * Create a PeeringSku. + * @property {string} [name] The name of the peering SKU. Possible values + * include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * @property {string} [tier] The tier of the peering SKU. Possible values + * include: 'Basic', 'Premium' + * @property {string} [family] The family of the peering SKU. Possible values + * include: 'Direct', 'Exchange' + * @property {string} [size] The size of the peering SKU. Possible values + * include: 'Free', 'Metered', 'Unlimited' + */ + constructor() { + } + + /** + * Defines the metadata of PeeringSku + * + * @returns {object} metadata of PeeringSku + * + */ + mapper() { + return { + required: false, + serializedName: 'PeeringSku', + type: { + name: 'Composite', + className: 'PeeringSku', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + tier: { + required: false, + serializedName: 'tier', + type: { + name: 'String' + } + }, + family: { + required: false, + serializedName: 'family', + type: { + name: 'String' + } + }, + size: { + required: false, + serializedName: 'size', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PeeringSku; diff --git a/lib/services/peeringManagement/lib/models/resourceTags.js b/lib/services/peeringManagement/lib/models/resourceTags.js new file mode 100644 index 0000000000..a2b3805067 --- /dev/null +++ b/lib/services/peeringManagement/lib/models/resourceTags.js @@ -0,0 +1,60 @@ +/* + * 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. + */ + +'use strict'; + +/** + * The resource tags. + * + */ +class ResourceTags { + /** + * Create a ResourceTags. + * @property {object} [tags] Gets or sets the tags, a dictionary of + * descriptors arm object + */ + constructor() { + } + + /** + * Defines the metadata of ResourceTags + * + * @returns {object} metadata of ResourceTags + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceTags', + type: { + name: 'Composite', + className: 'ResourceTags', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ResourceTags; diff --git a/lib/services/peeringManagement/lib/operations/index.d.ts b/lib/services/peeringManagement/lib/operations/index.d.ts new file mode 100644 index 0000000000..fda6e8f7cf --- /dev/null +++ b/lib/services/peeringManagement/lib/operations/index.d.ts @@ -0,0 +1,964 @@ +/* + * 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 { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationResponse } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * LegacyPeerings + * __NOTE__: An instance of this class is automatically created for an + * instance of the PeeringManagementClient. + */ +export interface LegacyPeerings { + + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} peeringLocation The location of the peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(peeringLocation: string, kind: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} peeringLocation The location of the peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(peeringLocation: string, kind: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(peeringLocation: string, kind: string, callback: ServiceCallback): void; + list(peeringLocation: string, kind: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the PeeringManagementClient. + */ +export interface Operations { + + + /** + * Lists all of the available API operations for peering resources. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available API operations for peering resources. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the available API operations for peering resources. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available API operations for peering resources. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * PeeringLocations + * __NOTE__: An instance of this class is automatically created for an + * instance of the PeeringManagementClient. + */ +export interface PeeringLocations { + + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(kind: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringLocationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringLocationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringLocationListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(kind: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(kind: string, callback: ServiceCallback): void; + list(kind: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringLocationListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringLocationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringLocationListResult} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Peerings + * __NOTE__: An instance of this class is automatically created for an + * instance of the PeeringManagementClient. + */ +export interface Peerings { + + + /** + * Gets an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, peeringName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Peering} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Peering} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, peeringName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, peeringName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, peeringName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates a new peering or updates an existing peering with the specified name + * under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} peering The properties needed to create or update a peering. + * + * @param {object} peering.sku The SKU that defines the tier and kind of the + * peering. + * + * @param {string} [peering.sku.name] The name of the peering SKU. Possible + * values include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * + * @param {string} [peering.sku.tier] The tier of the peering SKU. Possible + * values include: 'Basic', 'Premium' + * + * @param {string} [peering.sku.family] The family of the peering SKU. Possible + * values include: 'Direct', 'Exchange' + * + * @param {string} [peering.sku.size] The size of the peering SKU. Possible + * values include: 'Free', 'Metered', 'Unlimited' + * + * @param {string} peering.kind The kind of the peering. Possible values + * include: 'Direct', 'Exchange' + * + * @param {object} [peering.direct] The properties that define a direct + * peering. + * + * @param {array} [peering.direct.connections] The set of connections that + * constitute a direct peering. + * + * @param {number} [peering.direct.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * + * @param {boolean} [peering.direct.useForPeeringService] The flag that + * indicates whether or not the peering is used for peering service. + * + * @param {object} [peering.exchange] The properties that define an exchange + * peering. + * + * @param {array} [peering.exchange.connections] The set of connections that + * constitute an exchange peering. + * + * @param {number} [peering.exchange.peerAsn] The Autonomous System Number + * (ASN) associated with the peering. + * + * @param {string} [peering.peeringLocation] The location of the peering. + * + * @param {string} peering.location The location of the resource. + * + * @param {object} [peering.tags] The resource tags. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, peeringName: string, peering: models.Peering, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates a new peering or updates an existing peering with the specified name + * under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} peering The properties needed to create or update a peering. + * + * @param {object} peering.sku The SKU that defines the tier and kind of the + * peering. + * + * @param {string} [peering.sku.name] The name of the peering SKU. Possible + * values include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * + * @param {string} [peering.sku.tier] The tier of the peering SKU. Possible + * values include: 'Basic', 'Premium' + * + * @param {string} [peering.sku.family] The family of the peering SKU. Possible + * values include: 'Direct', 'Exchange' + * + * @param {string} [peering.sku.size] The size of the peering SKU. Possible + * values include: 'Free', 'Metered', 'Unlimited' + * + * @param {string} peering.kind The kind of the peering. Possible values + * include: 'Direct', 'Exchange' + * + * @param {object} [peering.direct] The properties that define a direct + * peering. + * + * @param {array} [peering.direct.connections] The set of connections that + * constitute a direct peering. + * + * @param {number} [peering.direct.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * + * @param {boolean} [peering.direct.useForPeeringService] The flag that + * indicates whether or not the peering is used for peering service. + * + * @param {object} [peering.exchange] The properties that define an exchange + * peering. + * + * @param {array} [peering.exchange.connections] The set of connections that + * constitute an exchange peering. + * + * @param {number} [peering.exchange.peerAsn] The Autonomous System Number + * (ASN) associated with the peering. + * + * @param {string} [peering.peeringLocation] The location of the peering. + * + * @param {string} peering.location The location of the resource. + * + * @param {object} [peering.tags] The resource tags. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Peering} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Peering} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, peeringName: string, peering: models.Peering, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, peeringName: string, peering: models.Peering, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, peeringName: string, peering: models.Peering, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, peeringName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, peeringName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, peeringName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, peeringName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates tags for a peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.tags] Gets or sets the tags, a dictionary of + * descriptors arm object + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, peeringName: string, options?: { tags? : { [propertyName: string]: string }, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates tags for a peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.tags] Gets or sets the tags, a dictionary of + * descriptors arm object + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Peering} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Peering} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, peeringName: string, options?: { tags? : { [propertyName: string]: string }, customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, peeringName: string, callback: ServiceCallback): void; + update(resourceGroupName: string, peeringName: string, options: { tags? : { [propertyName: string]: string }, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the peerings under the given subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the peerings under the given subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscription(callback: ServiceCallback): void; + listBySubscription(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all of the peerings under the given subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all of the peerings under the given subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {PeeringListResult} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscriptionNext(nextPageLink: string, callback: ServiceCallback): void; + listBySubscriptionNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/peeringManagement/lib/operations/index.js b/lib/services/peeringManagement/lib/operations/index.js new file mode 100644 index 0000000000..b67a757a60 --- /dev/null +++ b/lib/services/peeringManagement/lib/operations/index.js @@ -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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.LegacyPeerings = require('./legacyPeerings'); +exports.Operations = require('./operations'); +exports.PeeringLocations = require('./peeringLocations'); +exports.Peerings = require('./peerings'); diff --git a/lib/services/peeringManagement/lib/operations/legacyPeerings.js b/lib/services/peeringManagement/lib/operations/legacyPeerings.js new file mode 100644 index 0000000000..9a78f164bf --- /dev/null +++ b/lib/services/peeringManagement/lib/operations/legacyPeerings.js @@ -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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} peeringLocation The location of the peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(peeringLocation, kind, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (peeringLocation === null || peeringLocation === undefined || typeof peeringLocation.valueOf() !== 'string') { + throw new Error('peeringLocation cannot be null or undefined and it must be of type string.'); + } + if (kind === null || kind === undefined || typeof kind.valueOf() !== 'string') { + throw new Error('kind cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Peering/legacyPeerings'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('peeringLocation=' + encodeURIComponent(peeringLocation)); + queryParameters.push('kind=' + encodeURIComponent(kind)); + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a LegacyPeerings. */ +class LegacyPeerings { + /** + * Create a LegacyPeerings. + * @param {PeeringManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} peeringLocation The location of the peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(peeringLocation, kind, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(peeringLocation, kind, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} peeringLocation The location of the peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(peeringLocation, kind, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(peeringLocation, kind, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(peeringLocation, kind, options, optionalCallback); + } + } + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the legacy peerings under the given subscription matching the + * specified kind and location. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = LegacyPeerings; diff --git a/lib/services/peeringManagement/lib/operations/operations.js b/lib/services/peeringManagement/lib/operations/operations.js new file mode 100644 index 0000000000..6a00962f2f --- /dev/null +++ b/lib/services/peeringManagement/lib/operations/operations.js @@ -0,0 +1,451 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the available API operations for peering resources. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/Microsoft.Peering/operations'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the available API operations for peering resources. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Operations. */ +class Operations { + /** + * Create a Operations. + * @param {PeeringManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all of the available API operations for peering resources. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available API operations for peering resources. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists all of the available API operations for peering resources. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available API operations for peering resources. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/peeringManagement/lib/operations/peeringLocations.js b/lib/services/peeringManagement/lib/operations/peeringLocations.js new file mode 100644 index 0000000000..38a84d72a6 --- /dev/null +++ b/lib/services/peeringManagement/lib/operations/peeringLocations.js @@ -0,0 +1,478 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringLocationListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(kind, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (kind === null || kind === undefined || typeof kind.valueOf() !== 'string') { + throw new Error('kind cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Peering/peeringLocations'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('kind=' + encodeURIComponent(kind)); + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringLocationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringLocationListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringLocationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a PeeringLocations. */ +class PeeringLocations { + /** + * Create a PeeringLocations. + * @param {PeeringManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(kind, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(kind, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} kind The kind of the peering. Possible values include: + * 'Direct', 'Exchange' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringLocationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringLocationListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(kind, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(kind, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(kind, options, optionalCallback); + } + } + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available peering locations for the specified kind of + * peering. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringLocationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringLocationListResult} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = PeeringLocations; diff --git a/lib/services/peeringManagement/lib/operations/peerings.js b/lib/services/peeringManagement/lib/operations/peerings.js new file mode 100644 index 0000000000..3bc0c855ad --- /dev/null +++ b/lib/services/peeringManagement/lib/operations/peerings.js @@ -0,0 +1,2030 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, peeringName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (peeringName === null || peeringName === undefined || typeof peeringName.valueOf() !== 'string') { + throw new Error('peeringName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{peeringName}', encodeURIComponent(peeringName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Peering']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates a new peering or updates an existing peering with the specified name + * under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} peering The properties needed to create or update a peering. + * + * @param {object} peering.sku The SKU that defines the tier and kind of the + * peering. + * + * @param {string} [peering.sku.name] The name of the peering SKU. Possible + * values include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * + * @param {string} [peering.sku.tier] The tier of the peering SKU. Possible + * values include: 'Basic', 'Premium' + * + * @param {string} [peering.sku.family] The family of the peering SKU. Possible + * values include: 'Direct', 'Exchange' + * + * @param {string} [peering.sku.size] The size of the peering SKU. Possible + * values include: 'Free', 'Metered', 'Unlimited' + * + * @param {string} peering.kind The kind of the peering. Possible values + * include: 'Direct', 'Exchange' + * + * @param {object} [peering.direct] The properties that define a direct + * peering. + * + * @param {array} [peering.direct.connections] The set of connections that + * constitute a direct peering. + * + * @param {number} [peering.direct.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * + * @param {boolean} [peering.direct.useForPeeringService] The flag that + * indicates whether or not the peering is used for peering service. + * + * @param {object} [peering.exchange] The properties that define an exchange + * peering. + * + * @param {array} [peering.exchange.connections] The set of connections that + * constitute an exchange peering. + * + * @param {number} [peering.exchange.peerAsn] The Autonomous System Number + * (ASN) associated with the peering. + * + * @param {string} [peering.peeringLocation] The location of the peering. + * + * @param {string} peering.location The location of the resource. + * + * @param {object} [peering.tags] The resource tags. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, peeringName, peering, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (peeringName === null || peeringName === undefined || typeof peeringName.valueOf() !== 'string') { + throw new Error('peeringName cannot be null or undefined and it must be of type string.'); + } + if (peering === null || peering === undefined) { + throw new Error('peering cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{peeringName}', encodeURIComponent(peeringName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (peering !== null && peering !== undefined) { + let requestModelMapper = new client.models['Peering']().mapper(); + requestModel = client.serialize(requestModelMapper, peering, 'peering'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(peering, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Peering']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Peering']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, peeringName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (peeringName === null || peeringName === undefined || typeof peeringName.valueOf() !== 'string') { + throw new Error('peeringName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{peeringName}', encodeURIComponent(peeringName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates tags for a peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.tags] Gets or sets the tags, a dictionary of + * descriptors arm object + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, peeringName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let tags = (options && options.tags !== undefined) ? options.tags : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (peeringName === null || peeringName === undefined || typeof peeringName.valueOf() !== 'string') { + throw new Error('peeringName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (tags && typeof tags === 'object') { + for(let valueElement in tags) { + if (tags[valueElement] !== null && tags[valueElement] !== undefined && typeof tags[valueElement].valueOf() !== 'string') { + throw new Error('tags[valueElement] must be of type string.'); + } + } + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let tags1; + if (tags !== null && tags !== undefined) { + tags1 = new client.models['ResourceTags'](); + tags1.tags = tags; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings/{peeringName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{peeringName}', encodeURIComponent(peeringName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (tags1 !== null && tags1 !== undefined) { + let requestModelMapper = new client.models['ResourceTags']().mapper(); + requestModel = client.serialize(requestModelMapper, tags1, 'tags1'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(tags1, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Peering']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Peering/peerings'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the peerings under the given subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscription(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerings'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroupNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists all of the peerings under the given subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscriptionNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['PeeringListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Peerings. */ +class Peerings { + /** + * Create a Peerings. + * @param {PeeringManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._update = _update; + this._listByResourceGroup = _listByResourceGroup; + this._listBySubscription = _listBySubscription; + this._listByResourceGroupNext = _listByResourceGroupNext; + this._listBySubscriptionNext = _listBySubscriptionNext; + } + + /** + * Gets an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, peeringName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, peeringName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Peering} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, peeringName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, peeringName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, peeringName, options, optionalCallback); + } + } + + /** + * Creates a new peering or updates an existing peering with the specified name + * under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} peering The properties needed to create or update a peering. + * + * @param {object} peering.sku The SKU that defines the tier and kind of the + * peering. + * + * @param {string} [peering.sku.name] The name of the peering SKU. Possible + * values include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * + * @param {string} [peering.sku.tier] The tier of the peering SKU. Possible + * values include: 'Basic', 'Premium' + * + * @param {string} [peering.sku.family] The family of the peering SKU. Possible + * values include: 'Direct', 'Exchange' + * + * @param {string} [peering.sku.size] The size of the peering SKU. Possible + * values include: 'Free', 'Metered', 'Unlimited' + * + * @param {string} peering.kind The kind of the peering. Possible values + * include: 'Direct', 'Exchange' + * + * @param {object} [peering.direct] The properties that define a direct + * peering. + * + * @param {array} [peering.direct.connections] The set of connections that + * constitute a direct peering. + * + * @param {number} [peering.direct.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * + * @param {boolean} [peering.direct.useForPeeringService] The flag that + * indicates whether or not the peering is used for peering service. + * + * @param {object} [peering.exchange] The properties that define an exchange + * peering. + * + * @param {array} [peering.exchange.connections] The set of connections that + * constitute an exchange peering. + * + * @param {number} [peering.exchange.peerAsn] The Autonomous System Number + * (ASN) associated with the peering. + * + * @param {string} [peering.peeringLocation] The location of the peering. + * + * @param {string} peering.location The location of the resource. + * + * @param {object} [peering.tags] The resource tags. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, peeringName, peering, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, peeringName, peering, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates a new peering or updates an existing peering with the specified name + * under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} peering The properties needed to create or update a peering. + * + * @param {object} peering.sku The SKU that defines the tier and kind of the + * peering. + * + * @param {string} [peering.sku.name] The name of the peering SKU. Possible + * values include: 'Basic_Exchange_Free', 'Basic_Direct_Free', + * 'Premium_Direct_Free', 'Premium_Exchange_Metered' + * + * @param {string} [peering.sku.tier] The tier of the peering SKU. Possible + * values include: 'Basic', 'Premium' + * + * @param {string} [peering.sku.family] The family of the peering SKU. Possible + * values include: 'Direct', 'Exchange' + * + * @param {string} [peering.sku.size] The size of the peering SKU. Possible + * values include: 'Free', 'Metered', 'Unlimited' + * + * @param {string} peering.kind The kind of the peering. Possible values + * include: 'Direct', 'Exchange' + * + * @param {object} [peering.direct] The properties that define a direct + * peering. + * + * @param {array} [peering.direct.connections] The set of connections that + * constitute a direct peering. + * + * @param {number} [peering.direct.peerAsn] The Autonomous System Number (ASN) + * associated with the peering. + * + * @param {boolean} [peering.direct.useForPeeringService] The flag that + * indicates whether or not the peering is used for peering service. + * + * @param {object} [peering.exchange] The properties that define an exchange + * peering. + * + * @param {array} [peering.exchange.connections] The set of connections that + * constitute an exchange peering. + * + * @param {number} [peering.exchange.peerAsn] The Autonomous System Number + * (ASN) associated with the peering. + * + * @param {string} [peering.peeringLocation] The location of the peering. + * + * @param {string} peering.location The location of the resource. + * + * @param {object} [peering.tags] The resource tags. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Peering} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, peeringName, peering, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, peeringName, peering, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, peeringName, peering, options, optionalCallback); + } + } + + /** + * Deletes an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, peeringName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, peeringName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes an existing peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, peeringName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, peeringName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, peeringName, options, optionalCallback); + } + } + + /** + * Updates tags for a peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.tags] Gets or sets the tags, a dictionary of + * descriptors arm object + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, peeringName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, peeringName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates tags for a peering with the specified name under the given + * subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} peeringName The name of the peering. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.tags] Gets or sets the tags, a dictionary of + * descriptors arm object + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Peering} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Peering} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, peeringName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, peeringName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, peeringName, options, optionalCallback); + } + } + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Lists all of the peerings under the given subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscription(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the peerings under the given subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscription(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscription(options, optionalCallback); + } + } + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the peerings under the given subscription and resource group. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Lists all of the peerings under the given subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the peerings under the given subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {PeeringListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link PeeringListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscriptionNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Peerings; diff --git a/lib/services/peeringManagement/lib/peeringManagementClient.d.ts b/lib/services/peeringManagement/lib/peeringManagementClient.d.ts new file mode 100644 index 0000000000..90999079ed --- /dev/null +++ b/lib/services/peeringManagement/lib/peeringManagementClient.d.ts @@ -0,0 +1,169 @@ +/* + * 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 { ServiceClient, ServiceClientOptions, ServiceCallback, HttpOperationResponse, ServiceClientCredentials } from 'ms-rest'; +import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class PeeringManagementClient extends AzureServiceClient { + /** + * Initializes a new instance of the PeeringManagementClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @param {string} subscriptionId - The Azure subscription ID. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.acceptLanguage] - The preferred language for the response. + * + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + */ + constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + subscriptionId: string; + + apiVersion: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + legacyPeerings: operations.LegacyPeerings; + operations: operations.Operations; + peeringLocations: operations.PeeringLocations; + peerings: operations.Peerings; + + + /** + * Gets the peer info associated with the specified subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getPeerInfoWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the peer info associated with the specified subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getPeerInfo(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getPeerInfo(callback: ServiceCallback): void; + getPeerInfo(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates the peer info associated with the specified subscription. + * + * @param {array} peerInfo The peer info. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updatePeerInfoWithHttpOperationResponse(peerInfo: models.PeerInfo[], options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates the peer info associated with the specified subscription. + * + * @param {array} peerInfo The peer info. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + updatePeerInfo(peerInfo: models.PeerInfo[], options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + updatePeerInfo(peerInfo: models.PeerInfo[], callback: ServiceCallback): void; + updatePeerInfo(peerInfo: models.PeerInfo[], options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +export { PeeringManagementClient, models as PeeringManagementModels }; diff --git a/lib/services/peeringManagement/lib/peeringManagementClient.js b/lib/services/peeringManagement/lib/peeringManagementClient.js new file mode 100644 index 0000000000..0f02e7965b --- /dev/null +++ b/lib/services/peeringManagement/lib/peeringManagementClient.js @@ -0,0 +1,573 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const ServiceClient = msRestAzure.AzureServiceClient; +const WebResource = msRest.WebResource; + +const models = require('./models'); +const operations = require('./operations'); + + +/** + * Gets the peer info associated with the specified subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getPeerInfo(options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.subscriptionId === null || this.subscriptionId === undefined || typeof this.subscriptionId.valueOf() !== 'string') { + throw new Error('this.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.apiVersion === null || this.apiVersion === undefined || typeof this.apiVersion.valueOf() !== 'string') { + throw new Error('this.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Peering/getPeerInfo'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PeerInfoElementType', + type: { + name: 'Composite', + className: 'PeerInfo' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates the peer info associated with the specified subscription. + * + * @param {array} peerInfo The peer info. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _updatePeerInfo(peerInfo, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.subscriptionId === null || this.subscriptionId === undefined || typeof this.subscriptionId.valueOf() !== 'string') { + throw new Error('this.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.apiVersion === null || this.apiVersion === undefined || typeof this.apiVersion.valueOf() !== 'string') { + throw new Error('this.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.acceptLanguage !== null && this.acceptLanguage !== undefined && typeof this.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Peering/updatePeerInfo'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (peerInfo !== null && peerInfo !== undefined) { + let requestModelMapper = { + required: true, + serializedName: 'peerInfo', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PeerInfoElementType', + type: { + name: 'Composite', + className: 'PeerInfo' + } + } + } + }; + requestModel = client.serialize(requestModelMapper, peerInfo, 'peerInfo'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(peerInfo, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PeerInfoElementType', + type: { + name: 'Composite', + className: 'PeerInfo' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a PeeringManagementClient. */ +class PeeringManagementClient extends ServiceClient { + /** + * Create a PeeringManagementClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @param {string} subscriptionId - The Azure subscription ID. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * @param {string} [options.acceptLanguage] - The preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - The retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + */ + constructor(credentials, subscriptionId, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.apiVersion = '2019-03-01-preview'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://management.azure.com'; + } + this.credentials = credentials; + this.subscriptionId = subscriptionId; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { + this.generateClientRequestId = options.generateClientRequestId; + } + this.legacyPeerings = new operations.LegacyPeerings(this); + this.operations = new operations.Operations(this); + this.peeringLocations = new operations.PeeringLocations(this); + this.peerings = new operations.Peerings(this); + this.models = models; + this._getPeerInfo = _getPeerInfo; + this._updatePeerInfo = _updatePeerInfo; + msRest.addSerializationMixin(this); + } + + /** + * Gets the peer info associated with the specified subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getPeerInfoWithHttpOperationResponse(options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._getPeerInfo(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the peer info associated with the specified subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getPeerInfo(options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getPeerInfo(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getPeerInfo(options, optionalCallback); + } + } + + /** + * Updates the peer info associated with the specified subscription. + * + * @param {array} peerInfo The peer info. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updatePeerInfoWithHttpOperationResponse(peerInfo, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._updatePeerInfo(peerInfo, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates the peer info associated with the specified subscription. + * + * @param {array} peerInfo The peer info. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + updatePeerInfo(peerInfo, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._updatePeerInfo(peerInfo, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._updatePeerInfo(peerInfo, options, optionalCallback); + } + } + +} + +module.exports = PeeringManagementClient; +module.exports['default'] = PeeringManagementClient; +module.exports.PeeringManagementClient = PeeringManagementClient; +module.exports.PeeringManagementModels = models; diff --git a/lib/services/peeringManagement/package.json b/lib/services/peeringManagement/package.json new file mode 100644 index 0000000000..ca39cc3c3c --- /dev/null +++ b/lib/services/peeringManagement/package.json @@ -0,0 +1,25 @@ +{ + "name": "azure-arm-peering", + "author": "Microsoft Corporation", + "description": "PeeringManagementClient Library with typescript type definitions for node", + "version": "1.0.0", + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, + "keywords": [ + "node", + "azure" + ], + "license": "MIT", + "main": "./lib/peeringManagementClient.js", + "types": "./lib/peeringManagementClient.d.ts", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/peeringManagement", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "https://github.com/azure/azure-sdk-for-node/issues" + } +}