@ibm-cloud/platform-services
Version:
Node.js client library for IBM Cloud Platform Services
634 lines • 34.4 kB
JavaScript
"use strict";
/**
* (C) Copyright IBM Corp. 2020.
*
* 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: 99-SNAPSHOT-d753183b-20201209-163011
*/
var extend = require("extend");
var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
var common_1 = require("../lib/common");
/**
* Contribute resources to the IBM Cloud catalog by implementing a `service broker` that conforms to the [Open Service
* Broker API](https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md) version 2.12 specification
* and provides enablement extensions for integration with IBM Cloud and the Resource Controller provisioning model.
*/
var OpenServiceBrokerV1 = /** @class */ (function (_super) {
__extends(OpenServiceBrokerV1, _super);
/**
* Construct a OpenServiceBrokerV1 object.
*
* @param {Object} options - Options for the service.
* @param {string} [options.serviceUrl] - The base url to use when contacting the service. The base url may differ between IBM Cloud regions.
* @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 {OpenServiceBrokerV1}
*/
function OpenServiceBrokerV1(options) {
var _this = this;
options = options || {};
_this = _super.call(this, options) || this;
if (options.serviceUrl) {
_this.setServiceUrl(options.serviceUrl);
}
return _this;
}
/*************************
* Factory method
************************/
/**
* Constructs an instance of OpenServiceBrokerV1 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 URL for the service
* @returns {OpenServiceBrokerV1}
*/
OpenServiceBrokerV1.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 OpenServiceBrokerV1(options);
service.configureService(options.serviceName);
if (options.serviceUrl) {
service.setServiceUrl(options.serviceUrl);
}
return service;
};
/*************************
* enableAndDisableInstances
************************/
/**
* Get the current state of the service instance.
*
* Get the current state information associated with the service instance.
*
* As a service provider you need a way to manage provisioned service instances. If an account comes past due, you
* may need a to disable the service (without deleting it), and when the account is settled re-enable the service.
*
* This endpoint allows both the provider and IBM Cloud to query for the state of a provisioned service instance. For
* example, IBM Cloud may query the provider to figure out if a given service is disabled or not and present that
* state to the user.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.instanceId - The `instance_id` of a service instance is provided by the IBM Cloud platform.
* This ID will be used for future requests to bind and deprovision, so the broker can use it to correlate the
* resource it creates.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp1874644Root>>}
*/
OpenServiceBrokerV1.prototype.getServiceInstanceState = function (params) {
var _params = __assign({}, params);
var requiredParams = ['instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var path = {
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'getServiceInstanceState');
var parameters = {
options: {
url: '/bluemix_v1/service_instances/{instance_id}',
method: 'GET',
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Update the state of a provisioned service instance.
*
* Update (disable or enable) the state of a provisioned service instance. As a service provider you need a way to
* manage provisioned service instances. If an account comes past due, you may need a to disable the service (without
* deleting it), and when the account is settled re-enable the service. This endpoint allows the provider to enable or
* disable the state of a provisioned service instance. It is the service provider's responsibility to disable access
* to the service instance when the disable endpoint is invoked and to re-enable that access when the enable endpoint
* is invoked. When your service broker receives an enable / disable request, it should take whatever action is
* necessary to enable / disable (respectively) the service. Additionally, If a bind request comes in for a disabled
* service, the broker should reject that request with any code other than `204`, and provide a user-facing message in
* the description.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.instanceId - The `instance_id` of a service instance is provided by the IBM Cloud platform.
* This ID will be used for future requests to bind and deprovision, so the broker can use it to correlate the
* resource it creates.
* @param {boolean} [params.enabled] - Indicates the current state of the service instance.
* @param {string} [params.initiatorId] - Optional string that shows the user ID that is initiating the call.
* @param {string} [params.reasonCode] - Optional string that states the reason code for the service instance state
* change. Valid values are `IBMCLOUD_ACCT_ACTIVATE`, `IBMCLOUD_RECLAMATION_RESTORE`, or
* `IBMCLOUD_SERVICE_INSTANCE_BELOW_CAP` for enable calls; `IBMCLOUD_ACCT_SUSPEND`, `IBMCLOUD_RECLAMATION_SCHEDULE`,
* or `IBMCLOUD_SERVICE_INSTANCE_ABOVE_CAP` for disable calls; and `IBMCLOUD_ADMIN_REQUEST` for enable and disable
* calls.<br/><br/>Previously accepted values had a `BMX_` prefix, such as `BMX_ACCT_ACTIVATE`. These values are
* deprecated.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp2448145Root>>}
*/
OpenServiceBrokerV1.prototype.replaceServiceInstanceState = function (params) {
var _params = __assign({}, params);
var requiredParams = ['instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var body = {
'enabled': _params.enabled,
'initiator_id': _params.initiatorId,
'reason_code': _params.reasonCode,
};
var path = {
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceServiceInstanceState');
var parameters = {
options: {
url: '/bluemix_v1/service_instances/{instance_id}',
method: 'PUT',
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);
};
/*************************
* resourceInstances
************************/
/**
* Create (provision) a service instance.
*
* Create a service instance with GUID. When your service broker receives a provision request from the IBM Cloud
* platform, it MUST take whatever action is necessary to create a new resource.
*
* When a user creates a service instance from the IBM Cloud console or the IBM Cloud CLI, the IBM Cloud platform
* validates that the user has permission to create the service instance using IBM Cloud IAM. After this validation
* occurs, your service broker's provision endpoint (PUT /v2/resource_instances/:instance_id) will be invoked. When
* provisioning occurs, the IBM Cloud platform provides the following values:
*
* - The IBM Cloud context is included in the context variable
* - The X-Broker-API-Originating-Identity will have the IBM IAM ID of the user that initiated the request
* - The parameters section will include the requested location (and additional parameters required by your service).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.instanceId - The `instance_id` of a service instance is provided by the IBM Cloud platform.
* This ID will be used for future requests to bind and deprovision, so the broker can use it to correlate the
* resource it creates.
* @param {string} [params.organizationGuid] - Deprecated in favor of `context`. The IBM Cloud platform GUID for the
* organization under which the service instance is to be provisioned. Although most brokers will not use this field,
* it might be helpful for executing operations on a user's behalf. It MUST be a non-empty string.
* @param {string} [params.planId] - The ID of the plan for which the service instance has been requested, which is
* stored in the catalog.json of your broker. This value should be a GUID and it MUST be unique to a service.
* @param {string} [params.serviceId] - The ID of the service stored in the catalog.json of your broker. This value
* should be a GUID and it MUST be a non-empty string.
* @param {string} [params.spaceGuid] - Deprecated in favor of `context`. The identifier for the project space within
* the IBM Cloud platform organization. Although most brokers will not use this field, it might be helpful for
* executing operations on a user's behalf. It MUST be a non-empty string.
* @param {Context} [params.context] - Platform specific contextual information under which the service instance is to
* be provisioned.
* @param {JsonObject} [params.parameters] - Configuration options for the service instance. An opaque object,
* controller treats this as a blob. Brokers should ensure that the client has provided valid configuration parameters
* and values for the operation. If this field is not present in the request message, then the broker MUST NOT change
* the parameters of the instance as a result of this request.
* @param {boolean} [params.acceptsIncomplete] - A value of true indicates that both the IBM Cloud platform and the
* requesting client support asynchronous deprovisioning. If this parameter is not included in the request, and the
* broker can only deprovision a service instance of the requested plan asynchronously, the broker MUST reject the
* request with a `422` Unprocessable Entity.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp2079872Root>>}
*/
OpenServiceBrokerV1.prototype.replaceServiceInstance = function (params) {
var _params = __assign({}, params);
var requiredParams = ['instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var body = {
'organization_guid': _params.organizationGuid,
'plan_id': _params.planId,
'service_id': _params.serviceId,
'space_guid': _params.spaceGuid,
'context': _params.context,
'parameters': _params.parameters,
};
var query = {
'accepts_incomplete': _params.acceptsIncomplete,
};
var path = {
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceServiceInstance');
var parameters = {
options: {
url: '/v2/service_instances/{instance_id}',
method: 'PUT',
body: body,
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Update a service instance.
*
* Patch an instance by GUID. Enabling this endpoint allows your user to change plans and service parameters in a
* provisioned service instance. If your offering supports multiple plans, and you want users to be able to change
* plans for a provisioned instance, you will need to enable the ability for users to update their service instance.
*
* To enable support for the update of the plan, a broker MUST declare support per service by specifying
* `"plan_updateable": true` in your brokers' catalog.json.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.instanceId - The ID of a previously provisioned service instance.
* @param {string} [params.serviceId] - The ID of the service stored in the catalog.json of your broker. This value
* should be a GUID. It MUST be a non-empty string.
* @param {Context} [params.context] - Platform specific contextual information under which the service instance is to
* be provisioned.
* @param {JsonObject} [params.parameters] - Configuration options for the service instance. An opaque object,
* controller treats this as a blob. Brokers should ensure that the client has provided valid configuration parameters
* and values for the operation. If this field is not present in the request message, then the broker MUST NOT change
* the parameters of the instance as a result of this request.
* @param {string} [params.planId] - The ID of the plan for which the service instance has been requested, which is
* stored in the catalog.json of your broker. This value should be a GUID. MUST be unique to a service. If present,
* MUST be a non-empty string. If this field is not present in the request message, then the broker MUST NOT change
* the plan of the instance as a result of this request.
* @param {JsonObject} [params.previousValues] - Information about the service instance prior to the update.
* @param {boolean} [params.acceptsIncomplete] - A value of true indicates that both the IBM Cloud platform and the
* requesting client support asynchronous deprovisioning. If this parameter is not included in the request, and the
* broker can only deprovision a service instance of the requested plan asynchronously, the broker MUST reject the
* request with a `422` Unprocessable Entity.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp2079874Root>>}
*/
OpenServiceBrokerV1.prototype.updateServiceInstance = function (params) {
var _params = __assign({}, params);
var requiredParams = ['instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var body = {
'service_id': _params.serviceId,
'context': _params.context,
'parameters': _params.parameters,
'plan_id': _params.planId,
'previous_values': _params.previousValues,
};
var query = {
'accepts_incomplete': _params.acceptsIncomplete,
};
var path = {
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'updateServiceInstance');
var parameters = {
options: {
url: '/v2/service_instances/{instance_id}',
method: 'PATCH',
body: body,
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
'Content-Type': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/**
* Delete (deprovision) a service instance.
*
* Delete (deprovision) a service instance by GUID. When a service broker receives a deprovision request from the IBM
* Cloud platform, it MUST delete any resources it created during the provision. Usually this means that all resources
* are immediately reclaimed for future provisions.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.serviceId - The ID of the service stored in the catalog.json of your broker. This value
* should be a GUID. MUST be a non-empty string.
* @param {string} params.planId - The ID of the plan for which the service instance has been requested, which is
* stored in the catalog.json of your broker. This value should be a GUID. MUST be a non-empty string.
* @param {string} params.instanceId - The ID of a previously provisioned service instance.
* @param {boolean} [params.acceptsIncomplete] - A value of true indicates that both the IBM Cloud platform and the
* requesting client support asynchronous deprovisioning. If this parameter is not included in the request, and the
* broker can only deprovision a service instance of the requested plan asynchronously, the broker MUST reject the
* request with a `422` Unprocessable Entity.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp2079874Root>>}
*/
OpenServiceBrokerV1.prototype.deleteServiceInstance = function (params) {
var _params = __assign({}, params);
var requiredParams = ['serviceId', 'planId', 'instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var query = {
'service_id': _params.serviceId,
'plan_id': _params.planId,
'accepts_incomplete': _params.acceptsIncomplete,
};
var path = {
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteServiceInstance');
var parameters = {
options: {
url: '/v2/service_instances/{instance_id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/*************************
* catalog
************************/
/**
* Get the catalog metadata stored within the broker.
*
* This endpoints defines the contract between the broker and the IBM Cloud platform for the services and plans that
* the broker supports. This endpoint returns the catalog metadata stored within your broker. These values define the
* minimal provisioning contract between your service and the IBM Cloud platform. All additional catalog metadata that
* is not required for provisioning is stored within the IBM Cloud catalog, and any updates to catalog display values
* that are used to render your dashboard like links, icons, and i18n translated metadata should be updated in the
* Resource Management Console (RMC), and not housed in your broker. None of metadata stored in your broker is
* displayed in the IBM Cloud console or the IBM Cloud CLI; the console and CLI will return what was set withn RMC and
* stored in the IBM Cloud catalog.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp1874650Root>>}
*/
OpenServiceBrokerV1.prototype.listCatalog = function (params) {
var _params = __assign({}, params);
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'listCatalog');
var parameters = {
options: {
url: '/v2/catalog',
method: 'GET',
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/*************************
* lastOperationAsync
************************/
/**
* Get the current status of a provision in-progress for a service instance.
*
* Get `last_operation` for instance by GUID (for asynchronous provision calls). When a broker returns status code
* `202 Accepted` during a provision, update, or deprovision call, the IBM Cloud platform will begin polling the
* `last_operation` endpoint to obtain the state of the last requested operation. The broker response MUST contain the
* field `state` and MAY contain the field `description`.
*
* Valid values for `state` are `in progress`, `succeeded`, and `failed`. The platform will poll the `last_operation
* `endpoint as long as the broker returns "state": "in progress". Returning "state": "succeeded" or "state": "failed"
* will cause the platform to cease polling. The value provided for description will be passed through to the platform
* API client and can be used to provide additional detail for users about the progress of the operation.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.instanceId - The unique instance ID generated during provisioning by the IBM Cloud platform.
* @param {string} [params.operation] - A broker-provided identifier for the operation. When a value for operation is
* included with asynchronous responses for provision and update, and deprovision requests, the IBM Cloud platform
* will provide the same value using this query parameter as a URL-encoded string. If present, MUST be a non-empty
* string.
* @param {string} [params.planId] - ID of the plan from the catalog.json in your broker. If present, MUST be a
* non-empty string.
* @param {string} [params.serviceId] - ID of the service from the catalog.json in your service broker. If present,
* MUST be a non-empty string.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp2079894Root>>}
*/
OpenServiceBrokerV1.prototype.getLastOperation = function (params) {
var _params = __assign({}, params);
var requiredParams = ['instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var query = {
'operation': _params.operation,
'plan_id': _params.planId,
'service_id': _params.serviceId,
};
var path = {
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'getLastOperation');
var parameters = {
options: {
url: '/v2/service_instances/{instance_id}/last_operation',
method: 'GET',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
/*************************
* bindingsAndCredentials
************************/
/**
* Bind a service instance to another resource.
*
* Create binding by GUID on service instance.
*
* If your service can be bound to applications in IBM Cloud, `bindable:true` must be specified in the catalog.json of
* your service broker. If bindable, it must be able to return API endpoints and credentials to your service
* consumers.
*
* **Note:** Brokers that do not offer any bindable services do not need to implement the endpoint for bind requests.
*
* See the OSB 2.12 spec for more details on
* [binding](https://github.com/openservicebrokerapi/servicebroker/blob/v2.12/spec.md#binding).
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.bindingId - The `binding_id` is provided by the IBM Cloud platform. This ID will be used for
* future unbind requests, so the broker can use it to correlate the resource it creates.
* @param {string} params.instanceId - The :`instance_id` is the ID of a previously provisioned service instance.
* @param {string} [params.planId] - The ID of the plan from the catalog.json in your broker. If present, it MUST be a
* non-empty string.
* @param {string} [params.serviceId] - The ID of the service from the catalog.json in your broker. If present, it
* MUST be a non-empty string.
* @param {BindResource} [params.bindResource] - A JSON object that contains data for platform resources associated
* with the binding to be created.
* @param {JsonObject} [params.parameters] - Configuration options for the service instance. An opaque object,
* controller treats this as a blob. Brokers should ensure that the client has provided valid configuration parameters
* and values for the operation. If this field is not present in the request message, then the broker MUST NOT change
* the parameters of the instance as a result of this request.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Resp2079876Root>>}
*/
OpenServiceBrokerV1.prototype.replaceServiceBinding = function (params) {
var _params = __assign({}, params);
var requiredParams = ['bindingId', 'instanceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var body = {
'plan_id': _params.planId,
'service_id': _params.serviceId,
'bind_resource': _params.bindResource,
'parameters': _params.parameters,
};
var path = {
'binding_id': _params.bindingId,
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceServiceBinding');
var parameters = {
options: {
url: '/v2/service_instances/{instance_id}/service_bindings/{binding_id}',
method: 'PUT',
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);
};
/**
* Delete (unbind) the credentials bound to a resource.
*
* Delete instance binding by GUID.
*
* When a broker receives an unbind request from the IBM Cloud platform, it MUST delete any resources associated with
* the binding. In the case where credentials were generated, this might result in requests to the service instance
* failing to authenticate.
*
* **Note**: Brokers that do not provide any bindable services or plans do not need to implement this endpoint.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.bindingId - The `binding_id` is the ID of a previously provisioned binding for that service
* instance.
* @param {string} params.instanceId - The `instance_id` is the ID of a previously provisioned service instance.
* @param {string} params.planId - The ID of the plan from the catalog.json in the broker. It MUST be a non-empty
* string and should be a GUID.
* @param {string} params.serviceId - The ID of the service from the catalog.json in the broker. It MUST be a
* non-empty string and should be a GUID.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<OpenServiceBrokerV1.Response<OpenServiceBrokerV1.Empty>>}
*/
OpenServiceBrokerV1.prototype.deleteServiceBinding = function (params) {
var _params = __assign({}, params);
var requiredParams = ['bindingId', 'instanceId', 'planId', 'serviceId'];
var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}
var query = {
'plan_id': _params.planId,
'service_id': _params.serviceId,
};
var path = {
'binding_id': _params.bindingId,
'instance_id': _params.instanceId,
};
var sdkHeaders = (0, common_1.getSdkHeaders)(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteServiceBinding');
var parameters = {
options: {
url: '/v2/service_instances/{instance_id}/service_bindings/{binding_id}',
method: 'DELETE',
qs: query,
path: path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};
return this.createRequest(parameters);
};
OpenServiceBrokerV1.DEFAULT_SERVICE_NAME = 'open_service_broker';
return OpenServiceBrokerV1;
}(ibm_cloud_sdk_core_1.BaseService));
module.exports = OpenServiceBrokerV1;
//# sourceMappingURL=v1.js.map