ibm-vpc
Version:
IBM Cloud VPC Node.js SDK
1,045 lines (1,044 loc) • 2.15 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.107.1-41b0fbd0-20250825-080732
*/
/* 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-09-23
*/
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-09-16` and `2025-09-24`.
* @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-09-23';
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;
};
/*************************
* backupPolicies
************************/
/**
* List backup policies.
*
* This request lists backup policies in the region. Backup policies control which sources are selected for backup and
* include a set of backup policy plans that provide the backup schedules and deletion triggers.
*
* @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 {string} [params.name] - Filters the collection to resources with a `name` property matching the exact
* specified name.
* @param {string} [params.tag] - Filters the collection to resources with an item in the `tags` property matching the
* exact specified tag.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicyCollection>>}
*/
VpcV1.prototype.listBackupPolicies = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['start', 'limit', 'resourceGroupId', 'name', 'tag', '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,
'name': _params.name,
'tag': _params.tag,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listBackupPolicies');
var parameters = {
options: {
url: '/backup_policies',
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 backup policy.
*
* This request creates a new backup policy from a backup policy prototype object. The prototype object is structured
* in the same way as a retrieved backup policy, and contains the information necessary to create the new backup
* policy.
*
* @param {Object} params - The parameters to send to the service.
* @param {BackupPolicyPrototype} params.backupPolicyPrototype - The backup policy prototype object.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicy>>}
*/
VpcV1.prototype.createBackupPolicy = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyPrototype'];
var _validParams = ['backupPolicyPrototype', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = _params.backupPolicyPrototype;
var query = {
'version': this.version,
'generation': this.generation,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'createBackupPolicy');
var parameters = {
options: {
url: '/backup_policies',
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);
};
/**
* List jobs for a backup policy.
*
* This request retrieves jobs for a backup policy. A backup job represents the execution of a backup policy plan for
* a resource matching the policy's criteria.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} [params.status] - Filters the collection to backup policy jobs with a `status` property matching
* the specified value.
* @param {string} [params.backupPolicyPlanId] - Filters the collection to backup policy jobs with a
* `backup_policy_plan.id` property matching the specified 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 {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.sourceId] - Filters the collection to backup policy jobs with a `source.id` property
* matching the specified identifier.
* @param {string} [params.targetSnapshotsId] - Filters the collection to backup policy jobs with an item in the
* `target_snapshots` property with an `id` property matching the specified identifier.
* @param {string} [params.targetSnapshotsCrn] - Filters the collection to backup policy jobs with an item in the
* `target_snapshots` property with a `crn` property matching the specified CRN.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicyJobCollection>>}
*/
VpcV1.prototype.listBackupPolicyJobs = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId'];
var _validParams = ['backupPolicyId', 'status', 'backupPolicyPlanId', 'start', 'limit', 'sort', 'sourceId', 'targetSnapshotsId', 'targetSnapshotsCrn', '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,
'status': _params.status,
'backup_policy_plan.id': _params.backupPolicyPlanId,
'start': _params.start,
'limit': _params.limit,
'sort': _params.sort,
'source.id': _params.sourceId,
'target_snapshots[].id': _params.targetSnapshotsId,
'target_snapshots[].crn': _params.targetSnapshotsCrn,
};
var path = {
'backup_policy_id': _params.backupPolicyId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listBackupPolicyJobs');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/jobs',
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 backup policy job.
*
* This request retrieves a single backup policy job specified by the identifier in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} params.id - The backup policy job identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicyJob>>}
*/
VpcV1.prototype.getBackupPolicyJob = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId', 'id'];
var _validParams = ['backupPolicyId', '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 = {
'backup_policy_id': _params.backupPolicyId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getBackupPolicyJob');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/jobs/{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);
};
/**
* List plans for a backup policy.
*
* This request retrieves plans for a backup policy. Backup plans provide the backup schedule and deletion triggers.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} [params.name] - Filters the collection to resources with a `name` property matching the exact
* specified name.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicyPlanCollection>>}
*/
VpcV1.prototype.listBackupPolicyPlans = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId'];
var _validParams = ['backupPolicyId', 'name', '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,
'name': _params.name,
};
var path = {
'backup_policy_id': _params.backupPolicyId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listBackupPolicyPlans');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/plans',
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 plan for a backup policy.
*
* This request creates a new backup policy plan from a backup policy plan prototype object. The prototype object is
* structured in the same way as a retrieved backup policy plan, and contains the information necessary to create the
* new backup policy plan.
*
* Backups created by this plan will use the resource group of the source being backed up.
*
* Backups created by this plan will use the plan's name truncated to 46 characters, followed by a unique 16-character
* suffix.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} params.cronSpec - The cron specification for the backup schedule. The backup policy jobs
* (which create and delete backups for this plan) will not start until this time, and may start for up to 90 minutes
* after this time.
*
* All backup schedules for plans in the same policy must be at least an hour apart.
* @param {boolean} [params.active] - Indicates whether the plan is active.
* @param {string[]} [params.attachUserTags] - The user tags to attach to each backup (snapshot) created by this plan.
* @param {BackupPolicyPlanClonePolicyPrototype} [params.clonePolicy] -
* @param {boolean} [params.copyUserTags] - Indicates whether to copy the source's user tags to the created backups
* (snapshots).
* @param {BackupPolicyPlanDeletionTriggerPrototype} [params.deletionTrigger] -
* @param {string} [params.name] - The name for this backup policy plan. The name must not be used by another plan for
* the backup policy. If unspecified, the name will be a hyphenated list of randomly-selected words.
* @param {BackupPolicyPlanRemoteRegionPolicyPrototype[]} [params.remoteRegionPolicies] - The policies for additional
* backups in remote regions.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicyPlan>>}
*/
VpcV1.prototype.createBackupPolicyPlan = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId', 'cronSpec'];
var _validParams = ['backupPolicyId', 'cronSpec', 'active', 'attachUserTags', 'clonePolicy', 'copyUserTags', 'deletionTrigger', 'name', 'remoteRegionPolicies', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'cron_spec': _params.cronSpec,
'active': _params.active,
'attach_user_tags': _params.attachUserTags,
'clone_policy': _params.clonePolicy,
'copy_user_tags': _params.copyUserTags,
'deletion_trigger': _params.deletionTrigger,
'name': _params.name,
'remote_region_policies': _params.remoteRegionPolicies,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'backup_policy_id': _params.backupPolicyId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'createBackupPolicyPlan');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/plans',
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 backup policy plan.
*
* This request deletes a backup policy plan. This operation cannot be reversed. Any backups that have been created by
* the plan will remain but will no longer be subject to the plan's deletion trigger. Any running jobs associated with
* the plan will run to completion before the plan is deleted.
*
* If the request is accepted, the backup policy plan `status` will be set to `deleting`. Once deletion processing
* completes, the backup policy plan will no longer be retrievable.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} params.id - The backup policy plan 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.BackupPolicyPlan>>}
*/
VpcV1.prototype.deleteBackupPolicyPlan = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId', 'id'];
var _validParams = ['backupPolicyId', '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 = {
'backup_policy_id': _params.backupPolicyId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteBackupPolicyPlan');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/plans/{id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'If-Match': _params.ifMatch,
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a backup policy plan.
*
* This request retrieves a single backup policy plan specified by the identifier in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} params.id - The backup policy plan identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicyPlan>>}
*/
VpcV1.prototype.getBackupPolicyPlan = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId', 'id'];
var _validParams = ['backupPolicyId', '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 = {
'backup_policy_id': _params.backupPolicyId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getBackupPolicyPlan');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/plans/{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 backup policy plan.
*
* This request updates a backup policy plan with the information in a provided plan patch. The plan patch object is
* structured in the same way as a retrieved backup policy plan and can contains only the information to be updated.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.backupPolicyId - The backup policy identifier.
* @param {string} params.id - The backup policy plan identifier.
* @param {boolean} [params.active] - Indicates whether the plan is active.
* @param {string[]} [params.attachUserTags] - The user tags to attach to backups (snapshots) created by this plan.
* Updating this value does not change the user tags for backups that have already been created by this plan.
* @param {BackupPolicyPlanClonePolicyPatch} [params.clonePolicy] -
* @param {boolean} [params.copyUserTags] - Indicates whether to copy the source's user tags to the created backups
* (snapshots).
* @param {string} [params.cronSpec] - The cron specification for the backup schedule. The backup policy jobs
* (which create and delete backups for this plan) will not start until this time, and may start for up to 90 minutes
* after this time.
*
* All backup schedules for plans in the same policy must be at least an hour apart.
* @param {BackupPolicyPlanDeletionTriggerPatch} [params.deletionTrigger] -
* @param {string} [params.name] - The name for this backup policy plan. The name must not be used by another plan for
* the backup policy.
* @param {BackupPolicyPlanRemoteRegionPolicyPrototype[]} [params.remoteRegionPolicies] - The policies for additional
* backups in remote regions (replacing any existing policies).
* @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.BackupPolicyPlan>>}
*/
VpcV1.prototype.updateBackupPolicyPlan = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['backupPolicyId', 'id'];
var _validParams = ['backupPolicyId', 'id', 'active', 'attachUserTags', 'clonePolicy', 'copyUserTags', 'cronSpec', 'deletionTrigger', 'name', 'remoteRegionPolicies', 'ifMatch', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'active': _params.active,
'attach_user_tags': _params.attachUserTags,
'clone_policy': _params.clonePolicy,
'copy_user_tags': _params.copyUserTags,
'cron_spec': _params.cronSpec,
'deletion_trigger': _params.deletionTrigger,
'name': _params.name,
'remote_region_policies': _params.remoteRegionPolicies,
};
var query = {
'version': this.version,
'generation': this.generation,
};
var path = {
'backup_policy_id': _params.backupPolicyId,
'id': _params.id,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'updateBackupPolicyPlan');
var parameters = {
options: {
url: '/backup_policies/{backup_policy_id}/plans/{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);
};
/**
* Delete a backup policy.
*
* This request deletes a backup policy. This operation cannot be reversed.
*
* If the request is accepted, the backup policy `status` will be set to `deleting`. Once deletion processing
* completes, the backup policy will no longer be retrievable.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The backup policy 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.BackupPolicy>>}
*/
VpcV1.prototype.deleteBackupPolicy = 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', 'deleteBackupPolicy');
var parameters = {
options: {
url: '/backup_policies/{id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, this.baseOptions.headers, {
'Accept': 'application/json',
'If-Match': _params.ifMatch,
}, _params.headers),
axiosOptions: {
signal: _params.signal,
},
}),
};
return this.createRequest(parameters);
};
/**
* Retrieve a backup policy.
*
* This request retrieves a single backup policy specified by the identifier in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The backup policy identifier.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BackupPolicy>>}
*/
VpcV1.prototype.getBackupPolicy = 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', 'getBackupPolicy');
var parameters = {
options: {
url: '/backup_policies/{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 backup policy.
*
* This request updates a backup policy with the information in a provided backup policy patch. The backup policy
* patch object is structured in the same way as a retrieved backup policy and contains only the information to be
* updated.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.id - The backup policy identifier.
* @param {string[]} [params.includedContent] - The included content for backups created using this policy:
* - `boot_volume`: Include the instance's boot volume.
* - `data_volumes`: Include the instance's data volumes.
* @param {string[]} [params.matchUserTags] - The user tags this backup policy will apply to (replacing any existing
* tags). Resources that have both a matching user tag and a matching type will be subject to the backup policy.
* @param {string} [params.name] - The name for this backup policy. The name must not be used by another backup policy
* 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.BackupPolicy>>}
*/
VpcV1.prototype.updateBackupPolicy = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['id'];
var _validParams = ['id', 'includedContent', 'matchUserTags', 'name', 'ifMatch', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'included_content': _params.includedContent,
'match_user_tags': _params.matchUserTags,
'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', 'updateBackupPolicy');
var parameters = {
options: {
url: '/backup_policies/{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);
};
/*************************
* bareMetalServers
************************/
/**
* List bare metal server profiles.
*
* This request lists [bare metal server
* profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-bare-metal-servers-profile) available in the region. A bare
* metal server profile specifies the performance characteristics and pricing model for a bare metal server.
*
* @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 {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BareMetalServerProfileCollection>>}
*/
VpcV1.prototype.listBareMetalServerProfiles = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['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 sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listBareMetalServerProfiles');
var parameters = {
options: {
url: '/bare_metal_server/profiles',
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);
};
/**
* Retrieve a bare metal server profile.
*
* This request retrieves a single bare metal server profile specified by the name in the URL.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.name - The bare metal server profile name.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BareMetalServerProfile>>}
*/
VpcV1.prototype.getBareMetalServerProfile = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['name'];
var _validParams = ['name', '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 = {
'name': _params.name,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'getBareMetalServerProfile');
var parameters = {
options: {
url: '/bare_metal_server/profiles/{name}',
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 bare metal servers.
*
* This request lists bare metal servers in the 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 {string} [params.name] - Filters the collection to resources with a `name` property matching the exact
* specified name.
* @param {string} [params.reservationId] - Filters the collection to resources with a `reservation.id` property
* matching the specified identifier.
* @param {string} [params.reservationCrn] - Filters the collection to resources with a `reservation.crn` property
* matching the specified identifier.
* @param {string} [params.reservationName] - Filters the collection to resources with a `reservation.name` property
* matching the specified identifier.
* @param {string} [params.vpcId] - Filters the collection to resources with a `vpc.id` property matching the
* specified identifier.
* @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 {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BareMetalServerCollection>>}
*/
VpcV1.prototype.listBareMetalServers = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['start', 'limit', 'resourceGroupId', 'name', 'reservationId', 'reservationCrn', 'reservationName', 'vpcId', 'vpcCrn', 'vpcName', '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,
'name': _params.name,
'reservation.id': _params.reservationId,
'reservation.crn': _params.reservationCrn,
'reservation.name': _params.reservationName,
'vpc.id': _params.vpcId,
'vpc.crn': _params.vpcCrn,
'vpc.name': _params.vpcName,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'listBareMetalServers');
var parameters = {
options: {
url: '/bare_metal_servers',
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 bare metal server.
*
* This request provisions a new bare metal server from a prototype object. The prototype object is structured in the
* same way as a retrieved bare metal server, and contains the information necessary to provision the new bare metal
* server. The bare metal server is automatically started.
*
* For this request to succeed, the properties in the request must adhere to the source image's `allowed_use`
* property.
*
* @param {Object} params - The parameters to send to the service.
* @param {BareMetalServerPrototype} params.bareMetalServerPrototype - The bare metal server prototype object.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<VpcV1.Response<VpcV1.BareMetalServer>>}
*/
VpcV1.prototype.createBareMetalServer = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['bareMetalServerPrototype'];
var _validParams = ['bareMetalServerPrototype', 'signal', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = _params.bareMetalServerPrototype;
var query = {
'version': this.version,
'generation': this.generation,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(VpcV1.DEFAULT_SERVICE_NAME, 'v1', 'createBareMetalServer');
var parameters = {
options: {
url: '/bare_metal_servers',
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);
};