ibm-vpc
Version:
IBM Cloud VPC Node.js SDK
1,075 lines • 2.1 MB
JavaScript
"use strict";
/**
* (C) Copyright IBM Corp. 2023, 2024, 2025.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
/**
* IBM OpenAPI SDK Code Generator Version: 3.105.1-067d600b-20250616-154447
*/
/* eslint-disable max-classes-per-file */
/* eslint-disable no-await-in-loop */
var extend = require("extend");
var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
var common_1 = require("../lib/common");
/**
* The IBM Cloud Virtual Private Cloud (VPC) API can be used to programmatically provision and manage virtual server
* instances, along with subnets, volumes, load balancers, and more.
*
* API Version: 2025-07-08
*/
var VpcV1 = /** @class */ (function (_super) {
__extends(VpcV1, _super);
/**
* Construct a VpcV1 object.
*
* @param {Object} options - Options for the service.
* @param {number} [options.generation] - The infrastructure generation. For the API behavior documented here, specify
* `2`.
* @param {string} options.version - The API version, in format `YYYY-MM-DD`. For the API behavior documented here,
* specify any date between `2025-06-30` and `2025-07-10`.
* @param {string} [options.serviceUrl] - The base URL for the service
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
* @param {Authenticator} options.authenticator - The Authenticator object used to authenticate requests to the service
* @constructor
* @returns {VpcV1}
*/
function VpcV1(options) {
var _this = this;
options = options || {};
_this = _super.call(this, options) || this;
if (options.serviceUrl) {
_this.setServiceUrl(options.serviceUrl);
}
else {
_this.setServiceUrl(VpcV1.DEFAULT_SERVICE_URL);
}
_this.generation = options.generation;
if (!('generation' in options)) {
_this.generation = 2;
}
_this.version = options.version || '2025-07-08';
return _this;
}
/**
* Returns the service URL associated with the specified region.
* @param region a string representing the region
* @returns the service URL associated with the specified region or undefined
* if no mapping for the region exists
*/
VpcV1.getServiceUrlForRegion = function (region) {
return this._regionalEndpoints.get(region);
};
/*************************
* Factory method
************************/
/**
* Constructs an instance of VpcV1 with passed in options and external configuration.
*
* @param {UserOptions} [options] - The parameters to send to the service.
* @param {string} [options.serviceName] - The name of the service to configure
* @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service
* @param {string} [options.serviceUrl] - The base URL for the service
* @returns {VpcV1}
*/
VpcV1.newInstance = function (options) {
options = options || {};
if (!options.serviceName) {
options.serviceName = this.DEFAULT_SERVICE_NAME;
}
if (!options.authenticator) {
options.authenticator = (0, ibm_cloud_sdk_core_1.getAuthenticatorFromEnvironment)(options.serviceName);
}
var service = new VpcV1(options);
service.configureService(options.serviceName);
if (options.serviceUrl) {
service.setServiceUrl(options.serviceUrl);
}
return service;
};
/*************************
* vPCs
************************/
/**
* List VPCs.
*
* This request lists VPCs in the region. A VPC is a virtual network that belongs to an account and provides logical
* isolation from other networks. A VPC is made up of resources in one or more zones. VPCs are regional, and each VPC
* can contain resources in multiple zones in a region.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {string} [params.start] - A server-provided token determining what resource to start the page on.
* @param {number} [params.limit] - The number of resources to return on a page.
* @param {string} [params.resourceGroupId] - Filters the collection to resources with a `resource_group.id` property
* matching the specified identifier.
* @param {boolean} [params.classicAccess] - Filters the collection to VPCs with a `classic_access` property matching
* the specified value.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPCCollection>>}
*/
VpcV1.prototype.listVpcs = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['start', 'limit', 'resourceGroupId', 'classicAccess', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
'start': _params.start,
'limit': _params.limit,
'resource_group.id': _params.resourceGroupId,
'classic_access': _params.classicAccess,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listVpcs');
var parameters = {
options: {
url: '/vpcs',
method: 'GET',
qs: query,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Create a VPC.
*
* This request creates a new VPC from a VPC prototype object. The prototype object is structured in the same way as a
* retrieved VPC, and contains the information necessary to create the new VPC.
*
* The system will automatically create the following additional resources for the VPC:
* - Unless `address_prefix_management` is `manual`, a [default address
* prefix](https://cloud.ibm.com/apidocs/vpc/latest#get-vpc-address-prefix) for each zone
* - A [default network
* ACL](https://cloud.ibm.com/apidocs/vpc/latest#get-vpc-default-network-acl)
* - A [default routing
* table](https://cloud.ibm.com/apidocs/vpc/latest#get-vpc-default-routing-table)
* - A [default security
* group](https://cloud.ibm.com/apidocs/vpc/latest#get-vpc-default-security-group).
*
* @param {Object} [params] - The parameters to send to the service.
* @param {string} [params.addressPrefixManagement] - Indicates whether a [default address
* prefix](https://cloud.ibm.com/docs/vpc?topic=vpc-configuring-address-prefixes) will be automatically created for
* each zone in this VPC. If `manual`, this VPC will be created with no default address prefixes.
*
* Since address prefixes are managed identically regardless of whether they were automatically created, the value is
* not preserved as a VPC property.
* @param {boolean} [params.classicAccess] - Deprecated: Indicates whether this VPC will be connected to Classic
* Infrastructure. If true, this VPC's resources will have private network connectivity to the account's Classic
* Infrastructure resources. Only one VPC, per region, may be connected in this way. This value is set at creation and
* subsequently immutable.
*
* This property has been deprecated. Instead, use a [Transit Gateway](https://cloud.ibm.com/docs/transit-gateway) to
* connect this VPC to Classic Infrastructure. For more information, see [upcoming
* changes](https://cloud.ibm.com/docs/vpc?topic=vpc-api-change-log#upcoming-changes).
* @param {VPCDNSPrototype} [params.dns] - The DNS configuration for this VPC.
*
* If unspecified, the system will assign DNS servers capable of resolving hosts and endpoint
* gateways within this VPC, and hosts on the internet.
* @param {string} [params.name] - The name for this VPC. The name must not be used by another VPC in the region. If
* unspecified, the name will be a hyphenated list of randomly-selected words.
* @param {ResourceGroupIdentity} [params.resourceGroup] - The resource group to use. If unspecified, the account's
* [default resource
* group](https://cloud.ibm.com/apidocs/resource-manager#introduction) will be used.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPC>>}
*/
VpcV1.prototype.createVpc = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['addressPrefixManagement', 'classicAccess', 'dns', 'name', 'resourceGroup', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'address_prefix_management': _params.addressPrefixManagement,
'classic_access': _params.classicAccess,
'dns': _params.dns,
'name': _params.name,
'resource_group': _params.resourceGroup,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'createVpc');
var parameters = {
options: {
url: '/vpcs',
method: 'POST',
body: body,
qs: query,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Delete a VPC.
*
* This request deletes a VPC. This operation cannot be reversed.
*
* For this request to succeed:
* - Instances, subnets, public gateways, endpoint gateways, and private path service
* gateways must not reside in this VPC
* - The VPC must not be providing DNS resolution for any other VPCs
* - If `dns.enable_hub` is `true`, `dns.resolution_binding_count` must be zero
*
* All security groups and network ACLs associated with the VPC are automatically deleted. All flow log collectors
* with `auto_delete` set to `true` targeting the VPC or any resource in the VPC are automatically deleted. All public
* address ranges attached to the VPC are automatically detached.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The VPC identifier.
* @param {string} [params.ifMatch] - If present, the request will fail if the specified ETag value does not match the
* resource's current ETag value.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.EmptyObject>>}
*/
VpcV1.prototype.deleteVpc = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'ifMatch', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteVpc');
var parameters = {
options: {
url: '/vpcs/{id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'If-Match': _params.ifMatch,
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a VPC.
*
* This request retrieves a single VPC specified by the identifier in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The VPC identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPC>>}
*/
VpcV1.prototype.getVpc = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getVpc');
var parameters = {
options: {
url: '/vpcs/{id}',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Update a VPC.
*
* This request updates a VPC with the information provided in a VPC patch object. The patch object is structured in
* the same way as a retrieved VPC and needs to contain only the information to be updated.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The VPC identifier.
* @param {VPCDNSPatch} [params.dns] - The DNS configuration for this VPC.
* @param {string} [params.name] - The name for this VPC. The name must not be used by another VPC in the region.
* @param {string} [params.ifMatch] - If present, the request will fail if the specified ETag value does not match the
* resource's current ETag value. Required if the request body includes an array.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPC>>}
*/
VpcV1.prototype.updateVpc = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'dns', 'name', 'ifMatch', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'dns': _params.dns,
'name': _params.name,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'updateVpc');
var parameters = {
options: {
url: '/vpcs/{id}',
method: 'PATCH',
body: body,
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'Content-Type': 'application/merge-patch+json',
'If-Match': _params.ifMatch,
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a VPC's default network ACL.
*
* This request retrieves the default network ACL for the VPC specified by the identifier in the URL. The default
* network ACL is applied to any new subnets in the VPC which do not specify a network ACL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The VPC identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.DefaultNetworkACL>>}
*/
VpcV1.prototype.getVpcDefaultNetworkAcl = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getVpcDefaultNetworkAcl');
var parameters = {
options: {
url: '/vpcs/{id}/default_network_acl',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a VPC's default routing table.
*
* This request retrieves the default routing table for the VPC specified by the identifier in the URL. The default
* routing table is associated with any subnets in the VPC which have not been explicitly associated with another
* routing table.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The VPC identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.DefaultRoutingTable>>}
*/
VpcV1.prototype.getVpcDefaultRoutingTable = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getVpcDefaultRoutingTable');
var parameters = {
options: {
url: '/vpcs/{id}/default_routing_table',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a VPC's default security group.
*
* This request retrieves the default security group for the VPC specified by the identifier in the URL. Resources
* created in this VPC that allow a security group to be optionally specified will use this security group by default.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The VPC identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.DefaultSecurityGroup>>}
*/
VpcV1.prototype.getVpcDefaultSecurityGroup = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getVpcDefaultSecurityGroup');
var parameters = {
options: {
url: '/vpcs/{id}/default_security_group',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* List address prefixes for a VPC.
*
* This request lists address pool prefixes for a VPC.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} [params.start] - A server-provided token determining what resource to start the page on.
* @param {number} [params.limit] - The number of resources to return on a page.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.AddressPrefixCollection>>}
*/
VpcV1.prototype.listVpcAddressPrefixes = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId'];
var _validParams = ['vpcId', 'start', 'limit', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
'start': _params.start,
'limit': _params.limit,
};
var path = {
'vpc_id': _params.vpcId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listVpcAddressPrefixes');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/address_prefixes',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Create an address prefix for a VPC.
*
* This request creates a new prefix from a prefix prototype object. The prototype object is structured in the same
* way as a retrieved prefix, and contains the information necessary to create the new prefix.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} params.cidr - The IPv4 range of the address prefix, expressed in CIDR format. The range must not
* overlap with any existing address prefixes in the VPC or any of the following reserved address ranges:
*
* - `127.0.0.0/8` (IPv4 loopback addresses)
* - `161.26.0.0/16` (IBM services)
* - `166.8.0.0/14` (Cloud Service Endpoints)
* - `169.254.0.0/16` (IPv4 link-local addresses)
* - `224.0.0.0/4` (IPv4 multicast addresses)
*
* The prefix length of the address prefix's CIDR must be between `/9` (8,388,608 addresses) and `/29` (8 addresses).
* @param {ZoneIdentity} params.zone - The zone this address prefix will reside in.
* @param {boolean} [params.isDefault] - Indicates whether this will be the default address prefix for this zone in
* this VPC. If `true`, the VPC must not have a default address prefix for this zone.
* @param {string} [params.name] - The name for this address prefix. The name must not be used by another address
* prefix for the VPC. If unspecified, the name will be a hyphenated list of randomly-selected words.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.AddressPrefix>>}
*/
VpcV1.prototype.createVpcAddressPrefix = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'cidr', 'zone'];
var _validParams = ['vpcId', 'cidr', 'zone', 'isDefault', 'name', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'cidr': _params.cidr,
'zone': _params.zone,
'is_default': _params.isDefault,
'name': _params.name,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'vpc_id': _params.vpcId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'createVpcAddressPrefix');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/address_prefixes',
method: 'POST',
body: body,
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Delete an address prefix.
*
* This request deletes a prefix. This operation cannot be reversed. The request will fail if any subnets use
* addresses from this prefix.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} params.id - The prefix identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.EmptyObject>>}
*/
VpcV1.prototype.deleteVpcAddressPrefix = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'id'];
var _validParams = ['vpcId', 'id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'vpc_id': _params.vpcId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteVpcAddressPrefix');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/address_prefixes/{id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve an address prefix.
*
* This request retrieves a single prefix specified by the identifier in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} params.id - The prefix identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.AddressPrefix>>}
*/
VpcV1.prototype.getVpcAddressPrefix = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'id'];
var _validParams = ['vpcId', 'id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'vpc_id': _params.vpcId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getVpcAddressPrefix');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/address_prefixes/{id}',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Update an address prefix.
*
* This request updates a prefix with the information in a provided prefix patch. The prefix patch object is
* structured in the same way as a retrieved prefix and contains only the information to be updated.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} params.id - The prefix identifier.
* @param {boolean} [params.isDefault] - Indicates whether this is the default prefix for this zone in this VPC.
* Updating to true makes this prefix the default prefix for this zone in this VPC, provided the VPC currently has no
* default address prefix for this zone. Updating to false removes the default prefix for this zone in this VPC.
* @param {string} [params.name] - The name for this address prefix. The name must not be used by another address
* prefix for the VPC.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.AddressPrefix>>}
*/
VpcV1.prototype.updateVpcAddressPrefix = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'id'];
var _validParams = ['vpcId', 'id', 'isDefault', 'name', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'is_default': _params.isDefault,
'name': _params.name,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'vpc_id': _params.vpcId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'updateVpcAddressPrefix');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/address_prefixes/{id}',
method: 'PATCH',
body: body,
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'Content-Type': 'application/merge-patch+json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* List DNS resolution bindings for a VPC.
*
* This request lists DNS resolution bindings for a VPC. A DNS resolution binding represents an association with
* another VPC for centralizing DNS name resolution.
*
* If the VPC specified by the identifier in the URL is a DNS hub VPC (has `dns.enable_hub` set to `true`) then there
* is one binding for each VPC bound to the hub VPC. The endpoint gateways in the bound VPCs can allow (using
* `allow_dns_resolution_binding`) the hub VPC to centralize resolution of their DNS names.
*
* If the VPC specified by the identifier in the URL is not a DNS hub VPC, then there is at most one binding (to a hub
* VPC). The endpoint gateways in the VPC specified by the identifier in the URL can allow (using
* `allow_dns_resolution_binding`) its hub VPC to centralize resolution of their DNS names.
*
* To make use of centralized DNS resolution, a VPC bound to a DNS hub VPC must delegate DNS resolution to its hub VPC
* by setting `dns.resolver.type` to `delegate`.
*
* The bindings will be sorted by their `created_at` property values, with newest bindings first. Bindings with
* identical `created_at` property values will in turn be sorted by ascending `name` property values.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} [params.sort] - Sorts the returned collection by the specified property name in ascending order. A
* `-` may be prepended to the name to sort in descending order. For example, the value `-created_at` sorts the
* collection by the `created_at` property in descending order, and the value `name` sorts it by the `name` property
* in ascending order.
* @param {string} [params.start] - A server-provided token determining what resource to start the page on.
* @param {number} [params.limit] - The number of resources to return on a page.
* @param {string} [params.name] - Filters the collection to resources with a `name` property matching the exact
* specified name.
* @param {string} [params.vpcCrn] - Filters the collection to resources with a `vpc.crn` property matching the
* specified CRN.
* @param {string} [params.vpcName] - Filters the collection to resources with a `vpc.name` property matching the
* exact specified name.
* @param {string} [params.accountId] - Filters the collection to resources with a `vpc.remote.account.id` property
* matching the specified account identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPCDNSResolutionBindingCollection>>}
*/
VpcV1.prototype.listVpcDnsResolutionBindings = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId'];
var _validParams = ['vpcId', 'sort', 'start', 'limit', 'name', 'vpcCrn', 'vpcName', 'accountId', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
'sort': _params.sort,
'start': _params.start,
'limit': _params.limit,
'name': _params.name,
'vpc.crn': _params.vpcCrn,
'vpc.name': _params.vpcName,
'account.id': _params.accountId,
};
var path = {
'vpc_id': _params.vpcId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listVpcDnsResolutionBindings');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/dns_resolution_bindings',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Create a DNS resolution binding.
*
* This request creates a new DNS resolution binding from a DNS resolution binding prototype object. The prototype
* object is structured in the same way as a retrieved DNS resolution binding, and contains the information necessary
* to create the new DNS resolution binding.
*
* For this request to succeed:
* - The VPC specified by the identifier in the URL must not already have a DNS resolution
* binding
* - The VPC specified by the identifier in the URL must have `dns.enable_hub` set to `false`
* - The updated DNS sharing connected topology must not contain more than one endpoint
* gateway with `allow_dns_resolution_binding` set to `true` targeting the same service.
*
* See [About DNS sharing for VPE gateways](/docs/vpc?topic=vpc-vpe-dns-sharing) for more information.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {VPCIdentity} params.vpc - The VPC to bind this VPC to for DNS resolution. The VPC must be different from
* the VPC
* specified in the URL, must have `dns.enable_hub` set to `true`, and may be in a
* different account (subject to IAM policies).
*
* Additionally, the VPC specified in the URL (this VPC) must have `dns.enable_hub` set
* to `false` and a `dns.resolution_binding_count` of zero.
* @param {string} [params.name] - The name for this DNS resolution binding. The name must not be used by another DNS
* resolution binding for the VPC. If unspecified, the name will be a hyphenated list of randomly-selected words.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPCDNSResolutionBinding>>}
*/
VpcV1.prototype.createVpcDnsResolutionBinding = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'vpc'];
var _validParams = ['vpcId', 'vpc', 'name', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'vpc': _params.vpc,
'name': _params.name,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'vpc_id': _params.vpcId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'createVpcDnsResolutionBinding');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/dns_resolution_bindings',
method: 'POST',
body: body,
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Delete a DNS resolution binding.
*
* This request deletes a DNS resolution binding. This operation cannot be reversed.
*
* For this request to succeed, the VPC specified by the identifier in the URL must not have
* `dns.resolver.type` set to `delegated`.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} params.id - The DNS resolution binding identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPCDNSResolutionBinding>>}
*/
VpcV1.prototype.deleteVpcDnsResolutionBinding = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'id'];
var _validParams = ['vpcId', 'id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'vpc_id': _params.vpcId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteVpcDnsResolutionBinding');
var parameters = {
options: {
url: '/vpcs/{vpc_id}/dns_resolution_bindings/{id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a DNS resolution binding.
*
* This request retrieves a single DNS resolution binding specified by the identifier in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.vpcId - The VPC identifier.
* @param {string} params.id - The DNS resolution binding identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.VPCDNSResolutionBinding>>}
*/
VpcV1.prototype.getVpcDnsResolutionBinding = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['vpcId', 'id'];
var _validParams = ['vpcId', 'id', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'version': this.version,
'generatio