@ibm-cloud/ibm-schematics
Version:
IBM Cloud Node SDK
1,003 lines • 355 kB
JavaScript
"use strict";
/**
* (C) Copyright IBM Corp. 2024.
*
* 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);
};
/**
* IBM OpenAPI SDK Code Generator Version: 3.96.1-5136e54a-20241108-203028
*/
var extend = require("extend");
var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
var common_1 = require("../lib/common");
/**
* IBM Cloud Schematics service is to provide the capability to manage resources of cloud provider infrastructure by
* using file based configurations. With the IBM Cloud Schematics service you can specify the required set of
* resources and the configuration in `config files`, and then pass the config files to the service to fulfill it by
* calling the necessary actions on the infrastructure. This principle is known as Infrastructure as Code. For more
* information, refer to [Getting started with IBM Cloud Schematics]
* (https://cloud.ibm.com/docs/schematics?topic=schematics-getting-started).
*
* API Version: 1.0
*/
var SchematicsV1 = /** @class */ (function (_super) {
__extends(SchematicsV1, _super);
/**
* Construct a SchematicsV1 object.
*
* @param {Object} options - Options for the service.
* @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 {SchematicsV1}
*/
function SchematicsV1(options) {
var _this = this;
options = options || {};
_this = _super.call(this, options) || this;
if (options.serviceUrl) {
_this.setServiceUrl(options.serviceUrl);
}
else {
_this.setServiceUrl(SchematicsV1.DEFAULT_SERVICE_URL);
}
return _this;
}
/*************************
* Factory method
************************/
/**
* Constructs an instance of SchematicsV1 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 {SchematicsV1}
*/
SchematicsV1.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 SchematicsV1(options);
service.configureService(options.serviceName);
if (options.serviceUrl) {
service.setServiceUrl(options.serviceUrl);
}
return service;
};
/*************************
* util
************************/
/**
* List supported schematics locations.
*
* Retrieve a list of IBM Cloud locations where you can create the Schematics workspace or action. workspaces.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.SchematicsLocations[]>>}
*/
SchematicsV1.prototype.listSchematicsLocation = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'listSchematicsLocation');
var parameters = {
options: {
url: '/v1/locations',
method: 'GET',
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* List supported locations.
*
* Retrieve a list of IBM Cloud locations where you can work with the Schematics objects.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.SchematicsLocationsList>>}
*/
SchematicsV1.prototype.listLocations = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'listLocations');
var parameters = {
options: {
url: '/v2/locations',
method: 'GET',
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* List resource groups.
*
* Retrieve a list of IBM Cloud resource groups that your account has access to.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.ResourceGroupResponse[]>>}
*/
SchematicsV1.prototype.listResourceGroup = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'listResourceGroup');
var parameters = {
options: {
url: '/v1/resource_groups',
method: 'GET',
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Get Schematics API information.
*
* Retrieve detailed information about the IBM Cloud Schematics API version and the version of the provider plug-ins
* that the API uses.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.VersionResponse>>}
*/
SchematicsV1.prototype.getSchematicsVersion = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'getSchematicsVersion');
var parameters = {
options: {
url: '/v1/version',
method: 'GET',
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Get variable metadata by parsing the template.
*
* Get the variable metadata from the template. This metadata can be passed in the payload during Schematics workspace
* create or update API call.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions, see
* [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.templateType - Template type such as **terraform**, **ansible**, **helm**, **cloudpak**, or
* **bash script**.
* @param {ExternalSource} params.source - Source of templates, playbooks, or controls.
* @param {string} [params.region] - Region on which request should process. Applicable only on global endpoint.
* @param {string} [params.sourceType] - Type of source for the Template.
* @param {string} [params.xGithubToken] - The personal access token to authenticate with your private GitHub or
* GitLab repository and access your Terraform template.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.TemplateMetaDataResponse>>}
*/
SchematicsV1.prototype.processTemplateMetaData = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['templateType', 'source'];
var _validParams = [
'templateType',
'source',
'region',
'sourceType',
'xGithubToken',
'headers',
];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'template_type': _params.templateType,
'source': _params.source,
'region': _params.region,
'source_type': _params.sourceType,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'processTemplateMetaData');
var parameters = {
options: {
url: '/v2/template_metadata_processor',
method: 'POST',
body: body,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Github-token': _params.xGithubToken,
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/*************************
* workspaces
************************/
/**
* List workspaces.
*
* Retrieve a list of Schematics workspaces from your IBM Cloud account that you have access to. The list of
* workspaces that is returned depends on the API endpoint that you use. For example, if you use an API endpoint for a
* geography, such as North America, only workspaces that are created in `us-south` or `us-east` are returned.
*
* For more information about supported API endpoints, see [API endpoints](/apidocs/schematics#api-endpoints).
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} [params] - The parameters to send to the service.
* @param {number} [params.offset] - The starting position of the item in the list of items. For example, if you have
* three workspaces in your account, the first workspace is assigned position number 0, the second workspace is
* assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for workspaces
* `2-6`, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to the
* `offset` option. Negative numbers are not supported and are ignored.
* @param {number} [params.limit] - The maximum number of items that you want to list. The number must be a positive
* integer between 1 and 2000. If no value is provided, 100 is used by default.
* @param {string} [params.profile] - Level of details returned by the get method.
* @param {string} [params.resourceGroup] - The resource group (by default, fetch from all resource groups) name or
* ID.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.WorkspaceResponseList>>}
*/
SchematicsV1.prototype.listWorkspaces = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = ['offset', 'limit', 'profile', 'resourceGroup', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'offset': _params.offset,
'limit': _params.limit,
'profile': _params.profile,
'resource_group': _params.resourceGroup,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'listWorkspaces');
var parameters = {
options: {
url: '/v1/workspaces',
method: 'GET',
qs: query,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Create a workspace.
*
* Create an IBM Cloud Schematics workspace that points to the source repository where your Terraform template or the
* IBM Cloud software template is stored. You can decide to create your workspace without connecting it to a GitHub or
* GitLab repository. Your workspace is then created with a **Draft** state. To later connect your workspace to a
* GitHub or GitLab repository, you must use the `PUT /v1/workspaces/{id}` API to update the workspace or use the
* `/v1/workspaces/{id}/templates/{template_id}/template_repo_upload` API to upload a TAR file instead.
*
* **Getting API endpoint**:-
*
* * The Schematics API endpoint that you use to create the workspace determines where your Schematics actions run
* and your data is stored. See [API endpoints](/apidocs/schematics#api-endpoints) for more information.
* * If you use the API endpoint for a geography and not a specific location, such as North America, you can specify
* the location in your API request body.
* * If you do not specify the location in the request body, Schematics determines your workspace location based on
* availability.
* * If you use an API endpoint for a specific location, such as Frankfurt, the location that you enter in your API
* request body must match your API endpoint.
* * You also have the option to not specify a location in your API request body if you use a location-specific API
* endpoint.
*
* **Getting IAM access token** :-
* * Before you create Schematics workspace, you need to create the IAM access token for your IBM Cloud Account.
* * To create IAM access token, use `export IBMCLOUD_API_KEY=<ibmcloud_api_key>` and execute `curl -X POST
* "https://iam.cloud.ibm.com/identity/token" -H "Content-Type= application/x-www-form-urlencoded" -d
* "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx`. For more information, about
* creating IAM access token and API Docs, see [IAM access token](/apidocs/iam-identity-token-api#gettoken-password)
* and [Create API key](/apidocs/iam-identity-token-api#create-api-key).
* * You can set the environment values `export ACCESS_TOKEN=<access_token>` and `export
* REFRESH_TOKEN=<refresh_token>`.
* * You can use the obtained IAM access token in create workspace `curl` command.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} [params] - The parameters to send to the service.
* @param {string[]} [params.appliedShareddataIds] - Deprecated: List of applied shared dataset ID.
* @param {CatalogRef} [params.catalogRef] - Information about the software template that you chose from the IBM Cloud
* catalog. This information is returned for IBM Cloud catalog offerings only.
* @param {Dependencies} [params.dependencies] - Workspace dependencies.
* @param {string} [params.description] - The description of the workspace.
* @param {string} [params.location] - The location where you want to create your Schematics workspace and run the
* Schematics jobs. The location that you enter must match the API endpoint that you use. For example, if you use the
* Frankfurt API endpoint, you must specify `eu-de` as your location. If you use an API endpoint for a geography and
* you do not specify a location, Schematics determines the location based on availability.
* @param {string} [params.name] - The name of your workspace. The name can be up to 128 characters long and can
* include alphanumeric characters, spaces, dashes, and underscores. When you create a workspace for your own
* Terraform template, consider including the microservice component that you set up with your Terraform template and
* the IBM Cloud environment where you want to deploy your resources in your name.
* @param {string} [params.resourceGroup] - The ID of the resource group where you want to provision the workspace.
* @param {SharedTargetData} [params.sharedData] - Information about the Target used by the templates originating from
* the IBM Cloud catalog offerings. This information is not relevant for workspace created using your own Terraform
* template.
* @param {string[]} [params.tags] - A list of tags that are associated with the workspace.
* @param {TemplateSourceDataRequest[]} [params.templateData] - Input data for the Template.
* @param {string} [params.templateRef] - Workspace template ref.
* @param {TemplateRepoRequest} [params.templateRepo] - Input variables for the Template repoository, while creating a
* workspace.
* @param {string[]} [params.type] - List of Workspace type.
* @param {WorkspaceStatusRequest} [params.workspaceStatus] - WorkspaceStatusRequest -.
* @param {string} [params.agentId] - agent id which is binded to with the workspace.
* @param {VariableData[]} [params.settings] - Input settings to be applied to the workspace, for example,
* `job_timeout_override`.
* @param {string} [params.xGithubToken] - The personal access token to authenticate with your private GitHub or
* GitLab repository and access your Terraform template.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.WorkspaceResponse>>}
*/
SchematicsV1.prototype.createWorkspace = function (params) {
var _params = __assign({}, params);
var _requiredParams = [];
var _validParams = [
'appliedShareddataIds',
'catalogRef',
'dependencies',
'description',
'location',
'name',
'resourceGroup',
'sharedData',
'tags',
'templateData',
'templateRef',
'templateRepo',
'type',
'workspaceStatus',
'agentId',
'settings',
'xGithubToken',
'headers',
];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'applied_shareddata_ids': _params.appliedShareddataIds,
'catalog_ref': _params.catalogRef,
'dependencies': _params.dependencies,
'description': _params.description,
'location': _params.location,
'name': _params.name,
'resource_group': _params.resourceGroup,
'shared_data': _params.sharedData,
'tags': _params.tags,
'template_data': _params.templateData,
'template_ref': _params.templateRef,
'template_repo': _params.templateRepo,
'type': _params.type,
'workspace_status': _params.workspaceStatus,
'agent_id': _params.agentId,
'settings': _params.settings,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'createWorkspace');
var parameters = {
options: {
url: '/v1/workspaces',
method: 'POST',
body: body,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Github-token': _params.xGithubToken,
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Get workspace details.
*
* Retrieve detailed information for a workspace in your IBM Cloud account.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions, see [Schematics service access
* roles and required permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.WorkspaceResponse>>}
*/
SchematicsV1.prototype.getWorkspace = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['wId'];
var _validParams = ['wId', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var path = {
'w_id': _params.wId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'getWorkspace');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}',
method: 'GET',
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Update workspace.
*
* Use this API to update or replace the entire workspace, including the Terraform template (`template_repo`) or IBM
* Cloud catalog software template (`catalog_ref`) that your workspace points to.
*
* **Tip**:- If you want to update workspace metadata, use the `PATCH /v1/workspaces/{id}` API.
* To update workspace variables, use the `PUT /v1/workspaces/{id}/template_data/{template_id}/values` API.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {CatalogRef} [params.catalogRef] - Information about the software template that you chose from the IBM Cloud
* catalog. This information is returned for IBM Cloud catalog offerings only.
* @param {string} [params.description] - The description of the workspace.
* @param {Dependencies} [params.dependencies] - Workspace dependencies.
* @param {string} [params.name] - The name of the workspace.
* @param {SharedTargetData} [params.sharedData] - Information about the Target used by the templates originating from
* the IBM Cloud catalog offerings. This information is not relevant for workspace created using your own Terraform
* template.
* @param {string[]} [params.tags] - A list of tags that you want to associate with your workspace.
* @param {TemplateSourceDataRequest[]} [params.templateData] - Input data for the Template.
* @param {TemplateRepoUpdateRequest} [params.templateRepo] - Input to update the template repository data.
* @param {string[]} [params.type] - List of Workspace type.
* @param {WorkspaceStatusUpdateRequest} [params.workspaceStatus] - Input to update the workspace status.
* @param {WorkspaceStatusMessage} [params.workspaceStatusMsg] - Information about the last job that ran against the
* workspace. -.
* @param {string} [params.agentId] - agent id that process workspace jobs.
* @param {VariableData[]} [params.settings] - Input settings to be applied to the workspace, for example,
* `job_timeout_override`.
* @param {string} [params.xGithubToken] - The personal access token to authenticate with your private GitHub or
* GitLab repository and access your Terraform template.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.WorkspaceResponse>>}
*/
SchematicsV1.prototype.replaceWorkspace = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['wId'];
var _validParams = [
'wId',
'catalogRef',
'description',
'dependencies',
'name',
'sharedData',
'tags',
'templateData',
'templateRepo',
'type',
'workspaceStatus',
'workspaceStatusMsg',
'agentId',
'settings',
'xGithubToken',
'headers',
];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'catalog_ref': _params.catalogRef,
'description': _params.description,
'dependencies': _params.dependencies,
'name': _params.name,
'shared_data': _params.sharedData,
'tags': _params.tags,
'template_data': _params.templateData,
'template_repo': _params.templateRepo,
'type': _params.type,
'workspace_status': _params.workspaceStatus,
'workspace_status_msg': _params.workspaceStatusMsg,
'agent_id': _params.agentId,
'settings': _params.settings,
};
var path = {
'w_id': _params.wId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceWorkspace');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}',
method: 'PUT',
body: body,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Github-token': _params.xGithubToken,
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Delete a workspace.
*
* Deletes a workspace from IBM Cloud Schematics. Deleting a workspace does not automatically remove the IBM Cloud
* resources that the workspace manages. To remove all resources that are associated with the workspace, use the
* `DELETE /v1/workspaces/{id}?destroy_resources=true` API.
*
* **Note**: If you delete a workspace without deleting the resources,
* you must manage your resources with the resource dashboard or CLI afterwards.
* You cannot use IBM Cloud Schematics anymore to manage your resources.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.refreshToken - The IAM refresh token for the user or service identity. The IAM refresh token
* is required only if you want to destroy the Terraform resources before deleting the Schematics workspace. If you
* want to delete the workspace only and keep all your Terraform resources, refresh token is not required.
*
* **Retrieving refresh token**:
* * Use `export IBMCLOUD_API_KEY=<ibmcloud_api_key>`, and execute `curl -X POST
* "https://iam.cloud.ibm.com/identity/token" -H "Content-Type: application/x-www-form-urlencoded" -d
* "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx`.
* * For more information, about creating IAM access token and API Docs, refer, [IAM access
* token](/apidocs/iam-identity-token-api#gettoken-password) and [Create API
* key](/apidocs/iam-identity-token-api#create-api-key).
*
* **Limitation**:
* * If the token is expired, you can use `refresh token` to get a new IAM access token.
* * The `refresh_token` parameter cannot be used to retrieve a new IAM access token.
* * When the IAM access token is about to expire, use the API key to create a new access token.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {string} [params.destroyResources] - If set to `true`, refresh_token header configuration is required to
* delete all the Terraform resources, and the Schematics workspace. If set to `false`, you can remove only the
* workspace. Your Terraform resources are still available and must be managed with the resource dashboard or CLI.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<string>>}
*/
SchematicsV1.prototype.deleteWorkspace = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['refreshToken', 'wId'];
var _validParams = ['refreshToken', 'wId', 'destroyResources', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'destroy_resources': _params.destroyResources,
};
var path = {
'w_id': _params.wId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteWorkspace');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'refresh_token': _params.refreshToken,
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Update workspace metadata.
*
* Use this API to update the following workspace metadata:
*
* * Workspace name (`name`) - **Note**: Updating the workspace name does not update the ID of the workspace.
* * Workspace description (`description`)
* * Tags (`tags[]`)
* * Resource group (`resource_group`)
* * Workspace status (`workspace_status.frozen`)
*
*
* **Tip**: If you want to update information about the Terraform template
* or IBM Cloud catalog software template that your workspace points to,
* use the `PUT /v1/workspaces/{id}` API. To update workspace variables,
* use the `PUT /v1/workspaces/{id}/template_data/{template_id}/values` API.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {CatalogRef} [params.catalogRef] - Information about the software template that you chose from the IBM Cloud
* catalog. This information is returned for IBM Cloud catalog offerings only.
* @param {string} [params.description] - The description of the workspace.
* @param {Dependencies} [params.dependencies] - Workspace dependencies.
* @param {string} [params.name] - The name of the workspace.
* @param {SharedTargetData} [params.sharedData] - Information about the Target used by the templates originating from
* the IBM Cloud catalog offerings. This information is not relevant for workspace created using your own Terraform
* template.
* @param {string[]} [params.tags] - A list of tags that you want to associate with your workspace.
* @param {TemplateSourceDataRequest[]} [params.templateData] - Input data for the Template.
* @param {TemplateRepoUpdateRequest} [params.templateRepo] - Input to update the template repository data.
* @param {string[]} [params.type] - List of Workspace type.
* @param {WorkspaceStatusUpdateRequest} [params.workspaceStatus] - Input to update the workspace status.
* @param {WorkspaceStatusMessage} [params.workspaceStatusMsg] - Information about the last job that ran against the
* workspace. -.
* @param {string} [params.agentId] - agent id that process workspace jobs.
* @param {VariableData[]} [params.settings] - Input settings to be applied to the workspace, for example,
* `job_timeout_override`.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.WorkspaceResponse>>}
*/
SchematicsV1.prototype.updateWorkspace = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['wId'];
var _validParams = [
'wId',
'catalogRef',
'description',
'dependencies',
'name',
'sharedData',
'tags',
'templateData',
'templateRepo',
'type',
'workspaceStatus',
'workspaceStatusMsg',
'agentId',
'settings',
'headers',
];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var body = {
'catalog_ref': _params.catalogRef,
'description': _params.description,
'dependencies': _params.dependencies,
'name': _params.name,
'shared_data': _params.sharedData,
'tags': _params.tags,
'template_data': _params.templateData,
'template_repo': _params.templateRepo,
'type': _params.type,
'workspace_status': _params.workspaceStatus,
'workspace_status_msg': _params.workspaceStatusMsg,
'agent_id': _params.agentId,
'settings': _params.settings,
};
var path = {
'w_id': _params.wId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'updateWorkspace');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}',
method: 'PATCH',
body: body,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Show workspace template readme.
*
* Retrieve the `README.md` file of the Terraform of IBM Cloud catalog template that your workspace points to.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {string} [params.ref] - The GitHub or GitLab branch where the `README.md` file is stored, or the commit ID
* or tag that references the `README.md` file that you want to retrieve. If you do not specify this option, the
* `README.md` file is retrieved from the master branch by default.
* @param {string} [params.formatted] - The format of the readme file. Value ''markdown'' will give markdown,
* otherwise html.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.TemplateReadme>>}
* @deprecated this method is deprecated and may be removed in a future release
*/
SchematicsV1.prototype.getWorkspaceReadme = function (params) {
SchematicsV1._logger.warn('A deprecated operation has been invoked: getWorkspaceReadme');
var _params = __assign({}, params);
var _requiredParams = ['wId'];
var _validParams = ['wId', 'ref', 'formatted', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var query = {
'ref': _params.ref,
'formatted': _params.formatted,
};
var path = {
'w_id': _params.wId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'getWorkspaceReadme');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}/templates/readme',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Upload a TAR file to your workspace.
*
* Provide your Terraform template by uploading a TAR file from your local machine. Before you use this API, you must
* create a workspace without a link to a GitHub or GitLab repository with the `POST /v1/workspaces` API.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace where you want to upload your `.tar` file. To find the
* workspace ID, use the `GET /v1/workspaces` API.
* @param {string} params.tId - The ID of the Terraform template in your workspace. When you create a workspace, a
* unique ID is assigned to your Terraform template, even if no template was provided during workspace creation. To
* find this ID, use the `GET /v1/workspaces` API and review the `template_data.id` value.
* @param {NodeJS.ReadableStream | Buffer} [params.file] - Template tar file.
* @param {string} [params.fileContentType] - The content type of file.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.TemplateRepoTarUploadResponse>>}
*/
SchematicsV1.prototype.templateRepoUpload = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['wId', 'tId'];
var _validParams = ['wId', 'tId', 'file', 'fileContentType', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var formData = {
'file': {
data: _params.file,
contentType: _params.fileContentType,
},
};
var path = {
'w_id': _params.wId,
't_id': _params.tId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'templateRepoUpload');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}/template_data/{t_id}/template_repo_upload',
method: 'PUT',
path: path,
formData: formData,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'multipart/form-data',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* List workspace input variables.
*
* Retrieve a list of input variables that are declared in your Terraform or IBM Cloud catalog template.
*
* <h3>Authorization</h3>
*
* Schematics support generic authorization for its resources.
* For more information, about Schematics access and permissions,
* see [Schematics service access roles and required
* permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {string} params.tId - The ID of the Terraform template in your workspace. When you create a workspace, the
* Terraform template that your workspace points to is assigned a unique ID. Use the `GET /v1/workspaces` to look up
* the workspace IDs and template IDs or `template_data.id` in your IBM Cloud account.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<SchematicsV1.Response<SchematicsV1.TemplateValues>>}
*/
SchematicsV1.prototype.getWorkspaceInputs = function (params) {
var _params = __assign({}, params);
var _requiredParams = ['wId', 'tId'];
var _validParams = ['wId', 'tId', 'headers'];
var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}
var path = {
'w_id': _params.wId,
't_id': _params.tId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(SchematicsV1.DEFAULT_SERVICE_NAME, 'v1', 'getWorkspaceInputs');
var parameters = {
options: {
url: '/v1/workspaces/{w_id}/template_data/{t_id}/values',
method: 'GET',
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Replace workspace input variables.
*
* Replace or Update the input variables for the template that your workspace points to.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.wId - The ID of the workspace. To find the workspace ID, use the `GET /v1/workspaces` API.
* @param {string} params.tId - The ID of the Terraform template in your workspace. When you create a workspace, the
* Terr