From 873a2c62ce674db391620fb94b0ce47e0ef8bc14 Mon Sep 17 00:00:00 2001 From: Phil Adams Date: Fri, 12 Jun 2020 12:52:52 -0500 Subject: [PATCH 1/2] feat(Catalog Management): add Catalog Management service to project --- .gitignore | 1 + README.md | 1 + catalog-management/v1.ts | 5307 +++++++++++++++++++++++ examples/catalog-management.v1.test.js | 1525 +++++++ test/unit/catalog-management.v1.test.js | 5254 ++++++++++++++++++++++ 5 files changed, 12088 insertions(+) create mode 100644 catalog-management/v1.ts create mode 100644 examples/catalog-management.v1.test.js create mode 100644 test/unit/catalog-management.v1.test.js diff --git a/.gitignore b/.gitignore index bd87f1f2..83cfcd3f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ lib/*.js # service-specific tsc outputs (js files) # service-name/*.js // UNCOMMENT AND ADD YOUR OWN SERVICE FILES case-management/*.js +catalog-management/*.js global-catalog/*.js global-search/*.js global-tagging/*.js diff --git a/README.md b/README.md index 98db9809..78529774 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ IBM Cloud services: Service Name | Import Path --- | --- [Case Management](https://cloud.ibm.com/apidocs/case-management) | ibm-platform-services/case-management/v1 +[Catalog Management](https://cloud.ibm.com/apidocs/resource-catalog/private-catalog) | ibm-platform-services/catalog-management/v1 [Enterprise Management](https://cloud.ibm.com/apidocs/enterprise-apis/enterprise) | ibm-platform-services/enterprise-management/v1 [Global Catalog](https://cloud.ibm.com/apidocs/resource-catalog/global-catalog) | ibm-platform-services/global-catalog/v1 [Global Search](https://cloud.ibm.com/apidocs/search) | ibm-platform-services/global-search/v2 diff --git a/catalog-management/v1.ts b/catalog-management/v1.ts new file mode 100644 index 00000000..95b29a50 --- /dev/null +++ b/catalog-management/v1.ts @@ -0,0 +1,5307 @@ +/** + * (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. + */ + +import * as extend from 'extend'; +import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'; +import { Authenticator, BaseService, getAuthenticatorFromEnvironment, getMissingParams, UserOptions } from 'ibm-cloud-sdk-core'; +import { getSdkHeaders } from '../lib/common'; + +/** + * This is the API to use for managing private catalogs for IBM Cloud. Private catalogs provide a way to centrally + * manage access to products in the IBM Cloud catalog and your own catalogs. + */ + +class CatalogManagementV1 extends BaseService { + + static DEFAULT_SERVICE_URL: string = 'https://cm.globalcatalog.cloud.ibm.com/api/v1-beta'; + static DEFAULT_SERVICE_NAME: string = 'catalog_management'; + + /************************* + * Factory method + ************************/ + + /** + * Constructs an instance of CatalogManagementV1 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 {CatalogManagementV1} + */ + + public static newInstance(options: UserOptions): CatalogManagementV1 { + options = options || {}; + + if (!options.serviceName) { + options.serviceName = this.DEFAULT_SERVICE_NAME; + } + if (!options.authenticator) { + options.authenticator = getAuthenticatorFromEnvironment(options.serviceName); + } + const service = new CatalogManagementV1(options); + service.configureService(options.serviceName); + if (options.serviceUrl) { + service.setServiceUrl(options.serviceUrl); + } + return service; + } + + + /** + * Construct a CatalogManagementV1 object. + * + * @param {Object} options - Options for the service. + * @param {string} [options.serviceUrl] - The base url to use when contacting the service (e.g. 'https://gateway.watsonplatform.net/api/v1-beta'). 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 {CatalogManagementV1} + */ + constructor(options: UserOptions) { + options = options || {}; + + super(options); + if (options.serviceUrl) { + this.setServiceUrl(options.serviceUrl); + } else { + this.setServiceUrl(CatalogManagementV1.DEFAULT_SERVICE_URL); + } + } + + /************************* + * account + ************************/ + + /** + * Get the account settings. + * + * Get the account level settings for the account for private catalog. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getCatalogAccount(params?: CatalogManagementV1.GetCatalogAccountParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getCatalogAccount'); + + const parameters = { + options: { + url: '/catalogaccount', + method: 'GET', + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Set the account settings. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.id] - Account identification. + * @param {Filters} [params.accountFilters] - Filters for account and catalog filters. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateCatalogAccount(params?: CatalogManagementV1.UpdateCatalogAccountParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const body = { + 'id': _params.id, + 'account_filters': _params.accountFilters + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'updateCatalogAccount'); + + const parameters = { + options: { + url: '/catalogaccount', + method: 'PUT', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get the accumulated filters of the account and of the catalogs you have access to. + * + * Get the accumulated filters of the account and of the catalogs you have access to. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.catalog] - catalog id. Narrow down filters to the account and just the one catalog. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getCatalogAccountFilters(params?: CatalogManagementV1.GetCatalogAccountFiltersParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const query = { + 'catalog': _params.catalog + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getCatalogAccountFilters'); + + const parameters = { + options: { + url: '/catalogaccount/filters', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * catalogs + ************************/ + + /** + * Get list of catalogs. + * + * List the available catalogs for a given account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listCatalogs(params?: CatalogManagementV1.ListCatalogsParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'listCatalogs'); + + const parameters = { + options: { + url: '/catalogs', + method: 'GET', + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Create a catalog. + * + * Create a catalog for a given account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.id] - Unique ID. + * @param {string} [params.rev] - Cloudant revision. + * @param {string} [params.label] - Display Name in the requested language. + * @param {string} [params.shortDescription] - Description in the requested language. + * @param {string} [params.catalogIconUrl] - URL for an icon associated with this catalog. + * @param {string[]} [params.tags] - List of tags associated with this catalog. + * @param {string} [params.url] - The url for this specific catalog. + * @param {string} [params.crn] - CRN associated with the catalog. + * @param {string} [params.offeringsUrl] - URL path to offerings. + * @param {Feature[]} [params.features] - List of features associated with this catalog. + * @param {boolean} [params.disabled] - Denotes whether a catalog is disabled. + * @param {string} [params.created] - The date'time this catalog was created. + * @param {string} [params.updated] - The date'time this catalog was last updated. + * @param {string} [params.resourceGroupId] - Resource group id the catalog is owned by. + * @param {string} [params.owningAccount] - Account that owns catalog. + * @param {Filters} [params.catalogFilters] - Filters for account and catalog filters. + * @param {SyndicationResource} [params.syndicationSettings] - Feature information. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createCatalog(params?: CatalogManagementV1.CreateCatalogParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const body = { + 'id': _params.id, + '_rev': _params.rev, + 'label': _params.label, + 'short_description': _params.shortDescription, + 'catalog_icon_url': _params.catalogIconUrl, + 'tags': _params.tags, + 'url': _params.url, + 'crn': _params.crn, + 'offerings_url': _params.offeringsUrl, + 'features': _params.features, + 'disabled': _params.disabled, + 'created': _params.created, + 'updated': _params.updated, + 'resource_group_id': _params.resourceGroupId, + 'owning_account': _params.owningAccount, + 'catalog_filters': _params.catalogFilters, + 'syndication_settings': _params.syndicationSettings + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'createCatalog'); + + const parameters = { + options: { + url: '/catalogs', + method: 'POST', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get a catalog. + * + * Get a catalog. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getCatalog(params: CatalogManagementV1.GetCatalogParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'catalog_identifier': _params.catalogIdentifier + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getCatalog'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Update a catalog. + * + * Update a catalog. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} [params.id] - Unique ID. + * @param {string} [params.rev] - Cloudant revision. + * @param {string} [params.label] - Display Name in the requested language. + * @param {string} [params.shortDescription] - Description in the requested language. + * @param {string} [params.catalogIconUrl] - URL for an icon associated with this catalog. + * @param {string[]} [params.tags] - List of tags associated with this catalog. + * @param {string} [params.url] - The url for this specific catalog. + * @param {string} [params.crn] - CRN associated with the catalog. + * @param {string} [params.offeringsUrl] - URL path to offerings. + * @param {Feature[]} [params.features] - List of features associated with this catalog. + * @param {boolean} [params.disabled] - Denotes whether a catalog is disabled. + * @param {string} [params.created] - The date'time this catalog was created. + * @param {string} [params.updated] - The date'time this catalog was last updated. + * @param {string} [params.resourceGroupId] - Resource group id the catalog is owned by. + * @param {string} [params.owningAccount] - Account that owns catalog. + * @param {Filters} [params.catalogFilters] - Filters for account and catalog filters. + * @param {SyndicationResource} [params.syndicationSettings] - Feature information. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public replaceCatalog(params: CatalogManagementV1.ReplaceCatalogParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'id': _params.id, + '_rev': _params.rev, + 'label': _params.label, + 'short_description': _params.shortDescription, + 'catalog_icon_url': _params.catalogIconUrl, + 'tags': _params.tags, + 'url': _params.url, + 'crn': _params.crn, + 'offerings_url': _params.offeringsUrl, + 'features': _params.features, + 'disabled': _params.disabled, + 'created': _params.created, + 'updated': _params.updated, + 'resource_group_id': _params.resourceGroupId, + 'owning_account': _params.owningAccount, + 'catalog_filters': _params.catalogFilters, + 'syndication_settings': _params.syndicationSettings + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceCatalog'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Delete a catalog. + * + * Delete a catalog. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteCatalog(params: CatalogManagementV1.DeleteCatalogParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'catalog_identifier': _params.catalogIdentifier + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteCatalog'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * enterprise + ************************/ + + /** + * Get the enterprise settings for the specified enterprise ID. + * + * Get the enterprise settings for the specified enterprise ID. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.enterpriseId - Enterprise identification. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getEnterprise(params: CatalogManagementV1.GetEnterpriseParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['enterpriseId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'enterprise_id': _params.enterpriseId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getEnterprise'); + + const parameters = { + options: { + url: '/enterprises/{enterprise_id}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Set the enterprise settings. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.enterpriseId - Enterprise identification. + * @param {string} [params.id] - Enterprise identification. + * @param {string} [params.rev] - Cloudant revision. + * @param {Filters} [params.accountFilters] - Filters for account and catalog filters. + * @param {EnterpriseAccountGroups} [params.accountGroups] - Map of account group ids to AccountGroup objects. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public replaceEnterprise(params: CatalogManagementV1.ReplaceEnterpriseParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['enterpriseId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'id': _params.id, + '_rev': _params.rev, + 'account_filters': _params.accountFilters, + 'account_groups': _params.accountGroups + }; + + const path = { + 'enterprise_id': _params.enterpriseId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceEnterprise'); + + const parameters = { + options: { + url: '/enterprises/{enterprise_id}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * offerings + ************************/ + + /** + * Get list of offerings for consumption. + * + * List the available offerings from both public and from the account that currently scoped for consumption. These + * copies cannot be used updating. They are not complete and only return what is visible to the caller. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {boolean} [params.digest] - true - Strip down the content of what is returned. For example don't return the + * readme. Makes the result much smaller. Defaults to false. + * @param {string} [params.catalog] - catalog id. Narrow search down to just a particular catalog. It will apply the + * catalog's public filters to the public catalog offerings on the result. + * @param {string} [params.select] - What should be selected. Default is 'all' which will return both public and + * private offerings. 'public' returns only the public offerings and 'private' returns only the private offerings. + * @param {boolean} [params.includeHidden] - true - include offerings which have been marked as hidden. The default is + * false and hidden offerings are not returned. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getConsumptionOfferings(params?: CatalogManagementV1.GetConsumptionOfferingsParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const query = { + 'digest': _params.digest, + 'catalog': _params.catalog, + 'select': _params.select, + 'includeHidden': _params.includeHidden + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getConsumptionOfferings'); + + const parameters = { + options: { + url: '/offerings', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get list of offerings. + * + * List the available offerings in the specified catalog. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {boolean} [params.digest] - true - Strip down the content of what is returned. For example don't return the + * readme. Makes the result much smaller. Defaults to false. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listOfferings(params: CatalogManagementV1.ListOfferingsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'digest': _params.digest + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'listOfferings'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Create an offering. + * + * Create an offering. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} [params.id] - unique id. + * @param {string} [params.rev] - Cloudant revision. + * @param {string} [params.url] - The url for this specific offering. + * @param {string} [params.crn] - The crn for this specific offering. + * @param {string} [params.label] - Display Name in the requested language. + * @param {string} [params.name] - The programmatic name of this offering. + * @param {string} [params.offeringIconUrl] - URL for an icon associated with this offering. + * @param {string} [params.offeringDocsUrl] - URL for an additional docs with this offering. + * @param {string} [params.offeringSupportUrl] - URL to be displayed in the Consumption UI for getting support on this + * offering. + * @param {string[]} [params.tags] - List of tags associated with this catalog. + * @param {Rating} [params.rating] - Repository info for offerings. + * @param {string} [params.created] - The date and time this catalog was created. + * @param {string} [params.updated] - The date and time this catalog was last updated. + * @param {string} [params.shortDescription] - Short description in the requested language. + * @param {string} [params.longDescription] - Long description in the requested language. + * @param {Feature[]} [params.features] - list of features associated with this offering. + * @param {Kind[]} [params.kinds] - Array of kind. + * @param {boolean} [params.permitRequestIbmPublicPublish] - Is it permitted to request publishing to IBM or Public. + * @param {boolean} [params.ibmPublishApproved] - Indicates if this offering has been approved for use by all IBMers. + * @param {boolean} [params.publicPublishApproved] - Indicates if this offering has been approved for use by all IBM + * Cloud users. + * @param {string} [params.publicOriginalCrn] - The original offering CRN that this publish entry came from. + * @param {string} [params.publishPublicCrn] - The crn of the public catalog entry of this offering. + * @param {string} [params.portalApprovalRecord] - The portal's approval record ID. + * @param {string} [params.portalUiUrl] - The portal UI URL. + * @param {string} [params.catalogId] - The id of the catalog containing this offering. + * @param {string} [params.catalogName] - The name of the catalog. + * @param {JsonObject} [params.metadata] - Map of metadata values for this offering. + * @param {string} [params.disclaimer] - A disclaimer for this offering. + * @param {boolean} [params.hidden] - Determine if this offering should be displayed in the Consumption UI. + * @param {string} [params.provider] - Provider of this offering. + * @param {RepoInfo} [params.repoInfo] - Repository info for offerings. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createOffering(params: CatalogManagementV1.CreateOfferingParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'id': _params.id, + '_rev': _params.rev, + 'url': _params.url, + 'crn': _params.crn, + 'label': _params.label, + 'name': _params.name, + 'offering_icon_url': _params.offeringIconUrl, + 'offering_docs_url': _params.offeringDocsUrl, + 'offering_support_url': _params.offeringSupportUrl, + 'tags': _params.tags, + 'rating': _params.rating, + 'created': _params.created, + 'updated': _params.updated, + 'short_description': _params.shortDescription, + 'long_description': _params.longDescription, + 'features': _params.features, + 'kinds': _params.kinds, + 'permit_request_ibm_public_publish': _params.permitRequestIbmPublicPublish, + 'ibm_publish_approved': _params.ibmPublishApproved, + 'public_publish_approved': _params.publicPublishApproved, + 'public_original_crn': _params.publicOriginalCrn, + 'publish_public_crn': _params.publishPublicCrn, + 'portal_approval_record': _params.portalApprovalRecord, + 'portal_ui_url': _params.portalUiUrl, + 'catalog_id': _params.catalogId, + 'catalog_name': _params.catalogName, + 'metadata': _params.metadata, + 'disclaimer': _params.disclaimer, + 'hidden': _params.hidden, + 'provider': _params.provider, + 'repo_info': _params.repoInfo + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'createOffering'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Import new version to offering from a tgz. + * + * Import new version to offering from a tgz. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {string} params.zipurl - URL path to zip location. + * @param {string[]} [params.tags] - Tags array. + * @param {string[]} [params.targetKinds] - Target kinds. Current valid values are 'iks', 'roks', 'vcenter', and + * 'terraform'. + * @param {string} [params.targetVersion] - The semver value for this new version, if not found in the zip url package + * content. + * @param {boolean} [params.includeConfig] - Add all possible configuration values to this version when importing. + * @param {string} [params.repoType] - The type of repository containing this version. Valid values are 'public_git' + * or 'enterprise_git'. + * @param {string} [params.xAuthToken] - Authentication token used to access the specified zip file. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public importOfferingVersion(params: CatalogManagementV1.ImportOfferingVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId', 'zipurl']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'tags': _params.tags, + 'target_kinds': _params.targetKinds + }; + + const query = { + 'zipurl': _params.zipurl, + 'targetVersion': _params.targetVersion, + 'includeConfig': _params.includeConfig, + 'repoType': _params.repoType + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'importOfferingVersion'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}/version', + method: 'POST', + body, + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Auth-Token': _params.xAuthToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Import a new offering from a tgz. + * + * Import a new offering from a tgz. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.zipurl - URL path to zip location. + * @param {string[]} [params.tags] - Tags array. + * @param {string[]} [params.targetKinds] - Target kinds. Current valid values are 'iks', 'roks', 'vcenter', and + * 'terraform'. + * @param {string} [params.offeringId] - Re-use the specified offeringID during import. + * @param {boolean} [params.includeConfig] - Add all possible configuration items when creating this version. + * @param {string} [params.repoType] - The type of repository containing this version. Valid values are 'public_git' + * or 'enterprise_git'. + * @param {string} [params.xAuthToken] - Authentication token used to access the specified zip file. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public importOffering(params: CatalogManagementV1.ImportOfferingParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'zipurl']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'tags': _params.tags, + 'target_kinds': _params.targetKinds + }; + + const query = { + 'zipurl': _params.zipurl, + 'offeringID': _params.offeringId, + 'includeConfig': _params.includeConfig, + 'repoType': _params.repoType + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'importOffering'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/import/offerings', + method: 'POST', + body, + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Auth-Token': _params.xAuthToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Reload existing version in offering from a tgz. + * + * Reload existing version in offering from a tgz. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {string} params.zipurl - URL path to zip location. + * @param {string} params.targetVersion - The semver value for this new version. + * @param {string[]} [params.tags] - Tags array. + * @param {string[]} [params.targetKinds] - Target kinds. Current valid values are 'iks', 'roks', 'vcenter', and + * 'terraform'. + * @param {string} [params.repoType] - The type of repository containing this version. Valid values are 'public_git' + * or 'enterprise_git'. + * @param {string} [params.xAuthToken] - Authentication token used to access the specified zip file. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public reloadOffering(params: CatalogManagementV1.ReloadOfferingParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId', 'zipurl', 'targetVersion']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'tags': _params.tags, + 'target_kinds': _params.targetKinds + }; + + const query = { + 'zipurl': _params.zipurl, + 'targetVersion': _params.targetVersion, + 'repoType': _params.repoType + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'reloadOffering'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}/reload', + method: 'PUT', + body, + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Auth-Token': _params.xAuthToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get an offering. + * + * Get an offering. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getOffering(params: CatalogManagementV1.GetOfferingParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getOffering'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Update an offering. + * + * Update an offering. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {string} [params.id] - unique id. + * @param {string} [params.rev] - Cloudant revision. + * @param {string} [params.url] - The url for this specific offering. + * @param {string} [params.crn] - The crn for this specific offering. + * @param {string} [params.label] - Display Name in the requested language. + * @param {string} [params.name] - The programmatic name of this offering. + * @param {string} [params.offeringIconUrl] - URL for an icon associated with this offering. + * @param {string} [params.offeringDocsUrl] - URL for an additional docs with this offering. + * @param {string} [params.offeringSupportUrl] - URL to be displayed in the Consumption UI for getting support on this + * offering. + * @param {string[]} [params.tags] - List of tags associated with this catalog. + * @param {Rating} [params.rating] - Repository info for offerings. + * @param {string} [params.created] - The date and time this catalog was created. + * @param {string} [params.updated] - The date and time this catalog was last updated. + * @param {string} [params.shortDescription] - Short description in the requested language. + * @param {string} [params.longDescription] - Long description in the requested language. + * @param {Feature[]} [params.features] - list of features associated with this offering. + * @param {Kind[]} [params.kinds] - Array of kind. + * @param {boolean} [params.permitRequestIbmPublicPublish] - Is it permitted to request publishing to IBM or Public. + * @param {boolean} [params.ibmPublishApproved] - Indicates if this offering has been approved for use by all IBMers. + * @param {boolean} [params.publicPublishApproved] - Indicates if this offering has been approved for use by all IBM + * Cloud users. + * @param {string} [params.publicOriginalCrn] - The original offering CRN that this publish entry came from. + * @param {string} [params.publishPublicCrn] - The crn of the public catalog entry of this offering. + * @param {string} [params.portalApprovalRecord] - The portal's approval record ID. + * @param {string} [params.portalUiUrl] - The portal UI URL. + * @param {string} [params.catalogId] - The id of the catalog containing this offering. + * @param {string} [params.catalogName] - The name of the catalog. + * @param {JsonObject} [params.metadata] - Map of metadata values for this offering. + * @param {string} [params.disclaimer] - A disclaimer for this offering. + * @param {boolean} [params.hidden] - Determine if this offering should be displayed in the Consumption UI. + * @param {string} [params.provider] - Provider of this offering. + * @param {RepoInfo} [params.repoInfo] - Repository info for offerings. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public replaceOffering(params: CatalogManagementV1.ReplaceOfferingParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'id': _params.id, + '_rev': _params.rev, + 'url': _params.url, + 'crn': _params.crn, + 'label': _params.label, + 'name': _params.name, + 'offering_icon_url': _params.offeringIconUrl, + 'offering_docs_url': _params.offeringDocsUrl, + 'offering_support_url': _params.offeringSupportUrl, + 'tags': _params.tags, + 'rating': _params.rating, + 'created': _params.created, + 'updated': _params.updated, + 'short_description': _params.shortDescription, + 'long_description': _params.longDescription, + 'features': _params.features, + 'kinds': _params.kinds, + 'permit_request_ibm_public_publish': _params.permitRequestIbmPublicPublish, + 'ibm_publish_approved': _params.ibmPublishApproved, + 'public_publish_approved': _params.publicPublishApproved, + 'public_original_crn': _params.publicOriginalCrn, + 'publish_public_crn': _params.publishPublicCrn, + 'portal_approval_record': _params.portalApprovalRecord, + 'portal_ui_url': _params.portalUiUrl, + 'catalog_id': _params.catalogId, + 'catalog_name': _params.catalogName, + 'metadata': _params.metadata, + 'disclaimer': _params.disclaimer, + 'hidden': _params.hidden, + 'provider': _params.provider, + 'repo_info': _params.repoInfo + }; + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceOffering'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Delete an offering. + * + * Delete an offering. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteOffering(params: CatalogManagementV1.DeleteOfferingParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteOffering'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * upload an icon for the offering. + * + * upload an icon file to be stored in GC. File is uploaded as a binary payload - not as a form. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {string} params.fileName - Name of the file name that is being uploaded. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public replaceOfferingIcon(params: CatalogManagementV1.ReplaceOfferingIconParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId', 'fileName']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId, + 'file_name': _params.fileName + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceOfferingIcon'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}/icon/{file_name}', + method: 'PUT', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Approve offering to be permitted to publish to IBM Public Catalog (IBMers only or Everyone). + * + * Approve or disapprove the offering to be allowed to publish to the IBM Public Catalog in `ibm` (visible to IBM + * only) or `public` (visible to everyone). Can approve to only `ibm`, or it can be extended to `public`. If extended + * to `public` then `ibm` is automatically approved too. If disapprove `public`, then `ibm` approval will not be + * changed. If disapprove `ibm` then `public` will automatically be disapproved. This is because the process steps + * always go first through `ibm` and then to `public`. `ibm` cannot be skipped. Only users with Approval IAM authority + * can use this. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.catalogIdentifier - Catalog identifier. + * @param {string} params.offeringId - Offering identification. + * @param {string} params.approvalType - Type of approval, ibm or public. + * @param {string} params.approved - Approve (true) or disapprove (false). + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateOfferingIbm(params: CatalogManagementV1.UpdateOfferingIbmParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['catalogIdentifier', 'offeringId', 'approvalType', 'approved']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'catalog_identifier': _params.catalogIdentifier, + 'offering_id': _params.offeringId, + 'approval_type': _params.approvalType, + 'approved': _params.approved + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'updateOfferingIbm'); + + const parameters = { + options: { + url: '/catalogs/{catalog_identifier}/offerings/{offering_id}/publish/{approval_type}/{approved}', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * versions + ************************/ + + /** + * Get the about information, in markdown, for the current version. + * + * Get the about information, in markdown, for the current version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getVersionAbout(params: CatalogManagementV1.GetVersionAboutParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getVersionAbout'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/about', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'text/markdown', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get the license content for the specified license ID in the specified version. + * + * Get the license content for the specified license ID in the specified version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.licenseId - The ID of the license, which maps to the file name in the 'licenses' directory + * of this verions tgz file. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getVersionLicense(params: CatalogManagementV1.GetVersionLicenseParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'licenseId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId, + 'license_id': _params.licenseId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getVersionLicense'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/licenses/{license_id}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get get the list of container images associated with this version. + * + * The "image_manifest_url" property of the version should be pointing the a URL for the image manifest, this api + * reflects that content. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getVersionContainerImages(params: CatalogManagementV1.GetVersionContainerImagesParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getVersionContainerImages'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/containerImages', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Deprecate the specified version. + * + * Deprecate the specified version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deprecateVersion(params: CatalogManagementV1.DeprecateVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'deprecateVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/deprecate', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Publish the specified version so it is viewable by account members. + * + * Publish the specified version so it is viewable by account members. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public accountPublishVersion(params: CatalogManagementV1.AccountPublishVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'accountPublishVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/account-publish', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Publish the specified version so that it is visible to IBMers in the public catalog. + * + * Publish the specified version so that it is visible to IBMers in the public catalog. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public ibmPublishVersion(params: CatalogManagementV1.IbmPublishVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'ibmPublishVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/ibm-publish', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Publish the specified version so it is visible to all users in the public catalog. + * + * Publish the specified version so it is visible to all users in the public catalog. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public publicPublishVersion(params: CatalogManagementV1.PublicPublishVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'publicPublishVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/public-publish', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Commit a working copy of the specified version. + * + * Commit a working copy of the specified version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public commitVersion(params: CatalogManagementV1.CommitVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'commitVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/commit', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Create a working copy of the specified version. + * + * Create a working copy of the specified version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getVersionWorkingCopy(params: CatalogManagementV1.GetVersionWorkingCopyParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getVersionWorkingCopy'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/workingcopy', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get available updates for the specified version. + * + * Get available updates for the specified version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} [params.clusterId] - The id of the cluster where this version was installed. + * @param {string} [params.region] - The region of the cluster where this version was installed. + * @param {string} [params.resourceGroupId] - The resource group id of the cluster where this version was installed. + * @param {string} [params.namespace] - The namespace of the cluster where this version was installed. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getVersionUpdates(params: CatalogManagementV1.GetVersionUpdatesParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'resource_group_id': _params.resourceGroupId, + 'namespace': _params.namespace + }; + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getVersionUpdates'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/updates', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get the Offering/Kind/Version 'branch' for the specified locator ID. + * + * Get the Offering/Kind/Version 'branch' for the specified locator ID. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getVersion(params: CatalogManagementV1.GetVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Delete a version. + * + * Delete a the specified version. If the version is an active version with a working copy, the working copy will be + * deleted as well. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteVersion(params: CatalogManagementV1.DeleteVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Search for versions. + * + * [deprecated] use /search/license/versions api instead. Search across all accounts for versions, requires global + * admin permission. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.q - query, for now only "q=entitlement_key:" is supported. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listVersions(params: CatalogManagementV1.ListVersionsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['q']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'q': _params.q + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'listVersions'); + + const parameters = { + options: { + url: '/versions', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * repo + ************************/ + + /** + * List a repo's entries. + * + * List the available entries from a given repo. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.type - The type of repo (valid repo types: helm). + * @param {string} params.repourl - The URL for the repo's root (e.g + * https://kubernetes-charts-incubator.storage.googleapis.com). + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getRepos(params: CatalogManagementV1.GetReposParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['type', 'repourl']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'repourl': _params.repourl + }; + + const path = { + 'type': _params.type + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getRepos'); + + const parameters = { + options: { + url: '/repo/{type}/entries', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get contents of a repo. + * + * Get the contents of a given repo. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.type - The type of repo (valid repo types: helm). + * @param {string} params.charturl - The URL for the repo's chart zip file (e.g + * https://registry.bluemix.net/helm/ibm-charts/charts/ibm-redis-ha-dev-1.0.0.tgz). + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getRepo(params: CatalogManagementV1.GetRepoParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['type', 'charturl']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'charturl': _params.charturl + }; + + const path = { + 'type': _params.type + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getRepo'); + + const parameters = { + options: { + url: '/repo/{type}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * deploy + ************************/ + + /** + * List Kube clusters. + * + * List Kube clusters. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {number} [params.limit] - number or results to return. + * @param {number} [params.offset] - number of results to skip before returning values. + * @param {string} [params.type] - Kubernetes or OpenShift. Default is kubernetes. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listClusters(params?: CatalogManagementV1.ListClustersParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const query = { + 'limit': _params.limit, + 'offset': _params.offset, + 'type': _params.type + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'listClusters'); + + const parameters = { + options: { + url: '/deploy/kubernetes/clusters', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get Kube cluster. + * + * Get Kube cluster. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.clusterId - ID of the cluster. + * @param {string} params.region - Region of the cluster. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getCluster(params: CatalogManagementV1.GetClusterParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['clusterId', 'region', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'region': _params.region + }; + + const path = { + 'cluster_id': _params.clusterId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getCluster'); + + const parameters = { + options: { + url: '/deploy/kubernetes/clusters/{cluster_id}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get cluster namespaces. + * + * Get cluster namespaces. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.clusterId - ID of the cluster. + * @param {string} params.region - Cluster region. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {number} [params.limit] - number or results to return. + * @param {number} [params.offset] - number of results to skip before returning values. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getNamespaces(params: CatalogManagementV1.GetNamespacesParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['clusterId', 'region', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'region': _params.region, + 'limit': _params.limit, + 'offset': _params.offset + }; + + const path = { + 'cluster_id': _params.clusterId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getNamespaces'); + + const parameters = { + options: { + url: '/deploy/kubernetes/clusters/{cluster_id}/namespaces', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Deploy Operator(s) on a Kube cluster. + * + * Deploy Operator(s) on a Kube cluster. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} [params.clusterId] - Cluster ID. + * @param {string} [params.region] - Cluster region. + * @param {string[]} [params.namespaces] - Kube namespaces to deploy Operator(s) to. + * @param {string} [params.versionLocatorId] - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createOperator(params: CatalogManagementV1.CreateOperatorParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespaces': _params.namespaces, + 'version_locator_id': _params.versionLocatorId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'createOperator'); + + const parameters = { + options: { + url: '/deploy/kubernetes/olm/operator', + method: 'POST', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get Operator(s) from a Kube cluster. + * + * Get Operator(s) from a Kube cluster. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} params.clusterId - Cluster identification. + * @param {string} params.region - Cluster region. + * @param {string} params.versionLocatorId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listOperators(params: CatalogManagementV1.ListOperatorsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['xAuthRefreshToken', 'clusterId', 'region', 'versionLocatorId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'version_locator_id': _params.versionLocatorId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'listOperators'); + + const parameters = { + options: { + url: '/deploy/kubernetes/olm/operator', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Update Operator(s) on a Kube cluster. + * + * Update Operator(s) on a Kube cluster. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} [params.clusterId] - Cluster ID. + * @param {string} [params.region] - Cluster region. + * @param {string[]} [params.namespaces] - Kube namespaces to deploy Operator(s) to. + * @param {string} [params.versionLocatorId] - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public replaceOperator(params: CatalogManagementV1.ReplaceOperatorParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespaces': _params.namespaces, + 'version_locator_id': _params.versionLocatorId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceOperator'); + + const parameters = { + options: { + url: '/deploy/kubernetes/olm/operator', + method: 'PUT', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Delete Operator(s) from a Kube cluster. + * + * Delete Operator(s) from a Kube cluster. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} params.clusterId - Cluster identification. + * @param {string} params.region - Cluster region. + * @param {string} params.versionLocatorId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteOperator(params: CatalogManagementV1.DeleteOperatorParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['xAuthRefreshToken', 'clusterId', 'region', 'versionLocatorId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'version_locator_id': _params.versionLocatorId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteOperator'); + + const parameters = { + options: { + url: '/deploy/kubernetes/olm/operator', + method: 'DELETE', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Create an install. + * + * Create an install. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} [params.clusterId] - Cluster ID. + * @param {string} [params.region] - Cluster region. + * @param {string} [params.namespace] - Kube namespace. + * @param {JsonObject} [params.overrideValues] - Object containing Helm chart override values. + * @param {string} [params.entitlementApikey] - Entitlement API Key for this offering. + * @param {DeployRequestBodySchematics} [params.schematics] - Schematics workspace configuration. + * @param {string} [params.script] - Script. + * @param {string} [params.scriptId] - Script ID. + * @param {string} [params.versionLocatorId] - A dotted value of `catalogID`.`versionID`. + * @param {string} [params.vcenterId] - VCenter ID. + * @param {string} [params.vcenterPassword] - VCenter Password. + * @param {string} [params.vcenterLocation] - VCenter Location. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public installVersion(params: CatalogManagementV1.InstallVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespace': _params.namespace, + 'override_values': _params.overrideValues, + 'entitlement_apikey': _params.entitlementApikey, + 'schematics': _params.schematics, + 'script': _params.script, + 'script_id': _params.scriptId, + 'version_locator_id': _params.versionLocatorId, + 'vcenter_id': _params.vcenterId, + 'vcenter_password': _params.vcenterPassword, + 'vcenter_location': _params.vcenterLocation + }; + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'installVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/install', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Content-Type': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Create a preinstall. + * + * Create a preinstall. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} [params.clusterId] - Cluster ID. + * @param {string} [params.region] - Cluster region. + * @param {string} [params.namespace] - Kube namespace. + * @param {JsonObject} [params.overrideValues] - Object containing Helm chart override values. + * @param {string} [params.entitlementApikey] - Entitlement API Key for this offering. + * @param {DeployRequestBodySchematics} [params.schematics] - Schematics workspace configuration. + * @param {string} [params.script] - Script. + * @param {string} [params.scriptId] - Script ID. + * @param {string} [params.versionLocatorId] - A dotted value of `catalogID`.`versionID`. + * @param {string} [params.vcenterId] - VCenter ID. + * @param {string} [params.vcenterPassword] - VCenter Password. + * @param {string} [params.vcenterLocation] - VCenter Location. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public preinstallVersion(params: CatalogManagementV1.PreinstallVersionParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespace': _params.namespace, + 'override_values': _params.overrideValues, + 'entitlement_apikey': _params.entitlementApikey, + 'schematics': _params.schematics, + 'script': _params.script, + 'script_id': _params.scriptId, + 'version_locator_id': _params.versionLocatorId, + 'vcenter_id': _params.vcenterId, + 'vcenter_password': _params.vcenterPassword, + 'vcenter_location': _params.vcenterLocation + }; + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'preinstallVersion'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/preinstall', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Content-Type': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get a preinstall. + * + * Get a preinstall. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} [params.clusterId] - ID of the cluster. + * @param {string} [params.region] - Cluster region. + * @param {string} [params.namespace] - Required if the version's pre-install scope is `namespace`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getPreinstall(params: CatalogManagementV1.GetPreinstallParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespace': _params.namespace + }; + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getPreinstall'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/preinstall', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Validate a offering. + * + * Validate a offering. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {string} [params.clusterId] - Cluster ID. + * @param {string} [params.region] - Cluster region. + * @param {string} [params.namespace] - Kube namespace. + * @param {JsonObject} [params.overrideValues] - Object containing Helm chart override values. + * @param {string} [params.entitlementApikey] - Entitlement API Key for this offering. + * @param {DeployRequestBodySchematics} [params.schematics] - Schematics workspace configuration. + * @param {string} [params.script] - Script. + * @param {string} [params.scriptId] - Script ID. + * @param {string} [params.versionLocatorId] - A dotted value of `catalogID`.`versionID`. + * @param {string} [params.vcenterId] - VCenter ID. + * @param {string} [params.vcenterPassword] - VCenter Password. + * @param {string} [params.vcenterLocation] - VCenter Location. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public validationInstall(params: CatalogManagementV1.ValidationInstallParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const body = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespace': _params.namespace, + 'override_values': _params.overrideValues, + 'entitlement_apikey': _params.entitlementApikey, + 'schematics': _params.schematics, + 'script': _params.script, + 'script_id': _params.scriptId, + 'version_locator_id': _params.versionLocatorId, + 'vcenter_id': _params.vcenterId, + 'vcenter_password': _params.vcenterPassword, + 'vcenter_location': _params.vcenterLocation + }; + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'validationInstall'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/validation/install', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Content-Type': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Returns the install status for the specified offering version. + * + * Returns the install status for the specified offering version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getValidationStatus(params: CatalogManagementV1.GetValidationStatusParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getValidationStatus'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/validation/install', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Returns the override values that were used to validate the specified offering version. + * + * Returns the override values that were used to validate the specified offering version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getOverrideValues(params: CatalogManagementV1.GetOverrideValuesParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getOverrideValues'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/validation/overridevalues', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Returns the schematics workspaces for the specified offering version. + * + * Returns the schematics workspaces for the specified offering version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.xAuthRefreshToken - IAM Refresh token. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getSchematicsWorkspaces(params: CatalogManagementV1.GetSchematicsWorkspacesParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'xAuthRefreshToken']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getSchematicsWorkspaces'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/workspaces', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'X-Auth-Refresh-Token': _params.xAuthRefreshToken + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Returns the schematics permissions for the specified user. + * + * Returns the schematics permissions for the specified user. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.versionLocId - A dotted value of `catalogID`.`versionID`. + * @param {string} params.clusterId - ID of the cluster. + * @param {string} params.region - Cluster region. + * @param {string} [params.namespace] - Required if the version's pre-install scope is `namespace`. + * @param {string} [params.resourceGroupId] - Resource group identification. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public canDeploySchematics(params: CatalogManagementV1.CanDeploySchematicsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['versionLocId', 'clusterId', 'region']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'cluster_id': _params.clusterId, + 'region': _params.region, + 'namespace': _params.namespace, + 'resource_group_id': _params.resourceGroupId + }; + + const path = { + 'version_loc_id': _params.versionLocId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'canDeploySchematics'); + + const parameters = { + options: { + url: '/versions/{version_loc_id}/candeploy', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Returns all active resource groups in the current account, where the current user has permission to create schematics workspaces. + * + * Returns all active resource groups in the current account, where the current user has permission to create + * schematics workspaces. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getResourceGroups(params?: CatalogManagementV1.GetResourceGroupsParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getResourceGroups'); + + const parameters = { + options: { + url: '/deploy/schematics/resourcegroups', + method: 'GET', + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * licensing + ************************/ + + /** + * Get license providers. + * + * Get license providers. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getLicenseProviders(params?: CatalogManagementV1.GetLicenseProvidersParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getLicenseProviders'); + + const parameters = { + options: { + url: '/license/license_providers', + method: 'GET', + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get license entitlements. + * + * Get license entitlements bound to an account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - The account ID to query for the entitlement. Default is the account from the + * user's token. + * @param {string} [params.licenseProductId] - The license product ID. If from PPA (Passport Advantage) this is the + * product Part number(s) which can be one or more IDs, eg. D1YGZLL,5737L09. + * @param {string} [params.versionId] - The GC ID of the specific offering version. + * @param {string} [params.state] - The state of the license entitlement. eg. usually 'active', or if it's been + * deleted will show as 'removed'. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listLicenseEntitlements(params?: CatalogManagementV1.ListLicenseEntitlementsParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const query = { + 'account_id': _params.accountId, + 'license_product_id': _params.licenseProductId, + 'version_id': _params.versionId, + 'state': _params.state + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'listLicenseEntitlements'); + + const parameters = { + options: { + url: '/license/entitlements', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Create a license entitlement. + * + * Create an entitlement for a Cloud account. This is used to give an account an entitlement to a license. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.name] - Entitlement name. + * @param {string} [params.effectiveFrom] - Entitlement is good from this starting date. eg. + * '2019-07-17T21:21:47.6794935Z'. + * @param {string} [params.effectiveUntil] - Entitlement is good until this ending date. eg. + * '2019-07-17T21:21:47.6794935Z'. + * @param {string} [params.versionId] - Global Catalog ID of the version. + * @param {string} [params.licenseId] - Specific license entitlement ID from the license provider, eg. D1W3R4. + * @param {string} [params.licenseOwnerId] - IBM ID of the owner of this license entitlement. + * @param {string} [params.licenseProviderId] - License provider ID. + * @param {string} [params.licenseProductId] - License product ID. + * @param {string} [params.accountId] - if not specified the token's account will be used. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createLicenseEntitlement(params?: CatalogManagementV1.CreateLicenseEntitlementParams): Promise> { + const _params = extend({}, params); + + return new Promise((resolve, reject) => { + const body = { + 'name': _params.name, + 'effective_from': _params.effectiveFrom, + 'effective_until': _params.effectiveUntil, + 'version_id': _params.versionId, + 'license_id': _params.licenseId, + 'license_owner_id': _params.licenseOwnerId, + 'license_provider_id': _params.licenseProviderId, + 'license_product_id': _params.licenseProductId + }; + + const query = { + 'account_id': _params.accountId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'createLicenseEntitlement'); + + const parameters = { + options: { + url: '/license/entitlements', + method: 'POST', + body, + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get entitlements for a specific license product ID. + * + * Get an entitlements for a specific license product ID bound to an account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.licenseProductId - The license product ID. If from PPA (Passport Advantage) this is a + * specific product Part number, eg. D1YGZLL. + * @param {string} [params.accountId] - The account ID to query for the entitlement. Default is the account from the + * user's token. + * @param {string} [params.versionId] - The GC ID of the specific offering version. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getLicenseEntitlements(params: CatalogManagementV1.GetLicenseEntitlementsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['licenseProductId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'account_id': _params.accountId, + 'version_id': _params.versionId + }; + + const path = { + 'license_product_id': _params.licenseProductId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getLicenseEntitlements'); + + const parameters = { + options: { + url: '/license/entitlements/productID/{license_product_id}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Delete license entitlement. + * + * Delete a license entitlement that is bound to an account. Note that BSS will mark the entitlement field "state": + * "removed". + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.entitlementId - The specific entitlement ID (can be obtained from one of the license + * entitlement queries). + * @param {string} [params.accountId] - The account ID to query for the entitlement. Default is the account from the + * user's token. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteLicenseEntitlement(params: CatalogManagementV1.DeleteLicenseEntitlementParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['entitlementId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'account_id': _params.accountId + }; + + const path = { + 'entitlement_id': _params.entitlementId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteLicenseEntitlement'); + + const parameters = { + options: { + url: '/license/entitlements/{entitlement_id}', + method: 'DELETE', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Get licenses. + * + * Retrieve available licenses from supported license subsystems. This is used to get the list of available licenses + * that the user has. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.licenseProviderId - ID of the license provider, ie. retrieved from GET license_providers. + * @param {string} [params.accountId] - If not specified the token's account will be used. + * @param {string} [params.name] - License name. + * @param {string} [params.licenseType] - Type of license, if not specified, default is ibm-ppa. + * @param {string} [params.licenseProductId] - The license product ID. If from PPA (Passport Advantage) this is the + * product Part number, eg. D1YGZLL. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getLicenses(params: CatalogManagementV1.GetLicensesParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['licenseProviderId']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'license_provider_id': _params.licenseProviderId, + 'account_id': _params.accountId, + 'name': _params.name, + 'license_type': _params.licenseType, + 'license_product_id': _params.licenseProductId + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'getLicenses'); + + const parameters = { + options: { + url: '/license/licenses', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + 'Accept': 'application/json', + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /************************* + * crossAccountSearch + ************************/ + + /** + * Search for versions. + * + * Search across accounts for all versions usig a particular license, requires global admin permission. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.q - query, for now only "q=entitlement_key:" is supported. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public searchLicenseVersions(params: CatalogManagementV1.SearchLicenseVersionsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['q']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'q': _params.q + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'searchLicenseVersions'); + + const parameters = { + options: { + url: '/search/license/versions', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + + /** + * Search for Offerings. + * + * Search across accounts for all offerings using a particular license, requires global admin permission. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.q - query, for now only "q=entitlement_key:" is supported. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public searchLicenseOfferings(params: CatalogManagementV1.SearchLicenseOfferingsParams): Promise> { + const _params = extend({}, params); + const requiredParams = ['q']; + + return new Promise((resolve, reject) => { + const missingParams = getMissingParams(_params, requiredParams); + if (missingParams) { + return reject(missingParams); + } + + const query = { + 'q': _params.q + }; + + const sdkHeaders = getSdkHeaders(CatalogManagementV1.DEFAULT_SERVICE_NAME, 'v1', 'searchLicenseOfferings'); + + const parameters = { + options: { + url: '/search/license/offerings', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, { + }, _params.headers), + }), + }; + + return resolve(this.createRequest(parameters)); + }); + }; + +} + +/************************* + * interfaces + ************************/ + +namespace CatalogManagementV1 { + + /** An operation response. */ + export interface Response { + result: T; + status: number; + statusText: string; + headers: IncomingHttpHeaders; + } + + /** The callback for a service request. */ + export type Callback = (error: any, response?: Response) => void; + + /** The body of a service request that returns no response data. */ + export interface Empty { } + + /** A standard JS object, defined to avoid the limitations of `Object` and `object` */ + export interface JsonObject { + [key: string]: any; + } + + /************************* + * request interfaces + ************************/ + + /** Parameters for the `getCatalogAccount` operation. */ + export interface GetCatalogAccountParams { + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateCatalogAccount` operation. */ + export interface UpdateCatalogAccountParams { + /** Account identification. */ + id?: string; + /** Filters for account and catalog filters. */ + accountFilters?: Filters; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getCatalogAccountFilters` operation. */ + export interface GetCatalogAccountFiltersParams { + /** catalog id. Narrow down filters to the account and just the one catalog. */ + catalog?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listCatalogs` operation. */ + export interface ListCatalogsParams { + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createCatalog` operation. */ + export interface CreateCatalogParams { + /** Unique ID. */ + id?: string; + /** Cloudant revision. */ + rev?: string; + /** Display Name in the requested language. */ + label?: string; + /** Description in the requested language. */ + shortDescription?: string; + /** URL for an icon associated with this catalog. */ + catalogIconUrl?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** The url for this specific catalog. */ + url?: string; + /** CRN associated with the catalog. */ + crn?: string; + /** URL path to offerings. */ + offeringsUrl?: string; + /** List of features associated with this catalog. */ + features?: Feature[]; + /** Denotes whether a catalog is disabled. */ + disabled?: boolean; + /** The date'time this catalog was created. */ + created?: string; + /** The date'time this catalog was last updated. */ + updated?: string; + /** Resource group id the catalog is owned by. */ + resourceGroupId?: string; + /** Account that owns catalog. */ + owningAccount?: string; + /** Filters for account and catalog filters. */ + catalogFilters?: Filters; + /** Feature information. */ + syndicationSettings?: SyndicationResource; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getCatalog` operation. */ + export interface GetCatalogParams { + /** Catalog identifier. */ + catalogIdentifier: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `replaceCatalog` operation. */ + export interface ReplaceCatalogParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Unique ID. */ + id?: string; + /** Cloudant revision. */ + rev?: string; + /** Display Name in the requested language. */ + label?: string; + /** Description in the requested language. */ + shortDescription?: string; + /** URL for an icon associated with this catalog. */ + catalogIconUrl?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** The url for this specific catalog. */ + url?: string; + /** CRN associated with the catalog. */ + crn?: string; + /** URL path to offerings. */ + offeringsUrl?: string; + /** List of features associated with this catalog. */ + features?: Feature[]; + /** Denotes whether a catalog is disabled. */ + disabled?: boolean; + /** The date'time this catalog was created. */ + created?: string; + /** The date'time this catalog was last updated. */ + updated?: string; + /** Resource group id the catalog is owned by. */ + resourceGroupId?: string; + /** Account that owns catalog. */ + owningAccount?: string; + /** Filters for account and catalog filters. */ + catalogFilters?: Filters; + /** Feature information. */ + syndicationSettings?: SyndicationResource; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteCatalog` operation. */ + export interface DeleteCatalogParams { + /** Catalog identifier. */ + catalogIdentifier: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getEnterprise` operation. */ + export interface GetEnterpriseParams { + /** Enterprise identification. */ + enterpriseId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `replaceEnterprise` operation. */ + export interface ReplaceEnterpriseParams { + /** Enterprise identification. */ + enterpriseId: string; + /** Enterprise identification. */ + id?: string; + /** Cloudant revision. */ + rev?: string; + /** Filters for account and catalog filters. */ + accountFilters?: Filters; + /** Map of account group ids to AccountGroup objects. */ + accountGroups?: EnterpriseAccountGroups; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getConsumptionOfferings` operation. */ + export interface GetConsumptionOfferingsParams { + /** true - Strip down the content of what is returned. For example don't return the readme. Makes the result + * much smaller. Defaults to false. + */ + digest?: boolean; + /** catalog id. Narrow search down to just a particular catalog. It will apply the catalog's public filters to + * the public catalog offerings on the result. + */ + catalog?: string; + /** What should be selected. Default is 'all' which will return both public and private offerings. 'public' + * returns only the public offerings and 'private' returns only the private offerings. + */ + select?: GetConsumptionOfferingsConstants.Select | string; + /** true - include offerings which have been marked as hidden. The default is false and hidden offerings are not + * returned. + */ + includeHidden?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `getConsumptionOfferings` operation. */ + export namespace GetConsumptionOfferingsConstants { + /** What should be selected. Default is 'all' which will return both public and private offerings. 'public' returns only the public offerings and 'private' returns only the private offerings. */ + export enum Select { + ALL = 'all', + PUBLIC = 'public', + PRIVATE = 'private', + } + } + + /** Parameters for the `listOfferings` operation. */ + export interface ListOfferingsParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** true - Strip down the content of what is returned. For example don't return the readme. Makes the result + * much smaller. Defaults to false. + */ + digest?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createOffering` operation. */ + export interface CreateOfferingParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** unique id. */ + id?: string; + /** Cloudant revision. */ + rev?: string; + /** The url for this specific offering. */ + url?: string; + /** The crn for this specific offering. */ + crn?: string; + /** Display Name in the requested language. */ + label?: string; + /** The programmatic name of this offering. */ + name?: string; + /** URL for an icon associated with this offering. */ + offeringIconUrl?: string; + /** URL for an additional docs with this offering. */ + offeringDocsUrl?: string; + /** URL to be displayed in the Consumption UI for getting support on this offering. */ + offeringSupportUrl?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** Repository info for offerings. */ + rating?: Rating; + /** The date and time this catalog was created. */ + created?: string; + /** The date and time this catalog was last updated. */ + updated?: string; + /** Short description in the requested language. */ + shortDescription?: string; + /** Long description in the requested language. */ + longDescription?: string; + /** list of features associated with this offering. */ + features?: Feature[]; + /** Array of kind. */ + kinds?: Kind[]; + /** Is it permitted to request publishing to IBM or Public. */ + permitRequestIbmPublicPublish?: boolean; + /** Indicates if this offering has been approved for use by all IBMers. */ + ibmPublishApproved?: boolean; + /** Indicates if this offering has been approved for use by all IBM Cloud users. */ + publicPublishApproved?: boolean; + /** The original offering CRN that this publish entry came from. */ + publicOriginalCrn?: string; + /** The crn of the public catalog entry of this offering. */ + publishPublicCrn?: string; + /** The portal's approval record ID. */ + portalApprovalRecord?: string; + /** The portal UI URL. */ + portalUiUrl?: string; + /** The id of the catalog containing this offering. */ + catalogId?: string; + /** The name of the catalog. */ + catalogName?: string; + /** Map of metadata values for this offering. */ + metadata?: JsonObject; + /** A disclaimer for this offering. */ + disclaimer?: string; + /** Determine if this offering should be displayed in the Consumption UI. */ + hidden?: boolean; + /** Provider of this offering. */ + provider?: string; + /** Repository info for offerings. */ + repoInfo?: RepoInfo; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `importOfferingVersion` operation. */ + export interface ImportOfferingVersionParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + /** URL path to zip location. */ + zipurl: string; + /** Tags array. */ + tags?: string[]; + /** Target kinds. Current valid values are 'iks', 'roks', 'vcenter', and 'terraform'. */ + targetKinds?: string[]; + /** The semver value for this new version, if not found in the zip url package content. */ + targetVersion?: string; + /** Add all possible configuration values to this version when importing. */ + includeConfig?: boolean; + /** The type of repository containing this version. Valid values are 'public_git' or 'enterprise_git'. */ + repoType?: string; + /** Authentication token used to access the specified zip file. */ + xAuthToken?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `importOffering` operation. */ + export interface ImportOfferingParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** URL path to zip location. */ + zipurl: string; + /** Tags array. */ + tags?: string[]; + /** Target kinds. Current valid values are 'iks', 'roks', 'vcenter', and 'terraform'. */ + targetKinds?: string[]; + /** Re-use the specified offeringID during import. */ + offeringId?: string; + /** Add all possible configuration items when creating this version. */ + includeConfig?: boolean; + /** The type of repository containing this version. Valid values are 'public_git' or 'enterprise_git'. */ + repoType?: string; + /** Authentication token used to access the specified zip file. */ + xAuthToken?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `reloadOffering` operation. */ + export interface ReloadOfferingParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + /** URL path to zip location. */ + zipurl: string; + /** The semver value for this new version. */ + targetVersion: string; + /** Tags array. */ + tags?: string[]; + /** Target kinds. Current valid values are 'iks', 'roks', 'vcenter', and 'terraform'. */ + targetKinds?: string[]; + /** The type of repository containing this version. Valid values are 'public_git' or 'enterprise_git'. */ + repoType?: string; + /** Authentication token used to access the specified zip file. */ + xAuthToken?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getOffering` operation. */ + export interface GetOfferingParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `replaceOffering` operation. */ + export interface ReplaceOfferingParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + /** unique id. */ + id?: string; + /** Cloudant revision. */ + rev?: string; + /** The url for this specific offering. */ + url?: string; + /** The crn for this specific offering. */ + crn?: string; + /** Display Name in the requested language. */ + label?: string; + /** The programmatic name of this offering. */ + name?: string; + /** URL for an icon associated with this offering. */ + offeringIconUrl?: string; + /** URL for an additional docs with this offering. */ + offeringDocsUrl?: string; + /** URL to be displayed in the Consumption UI for getting support on this offering. */ + offeringSupportUrl?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** Repository info for offerings. */ + rating?: Rating; + /** The date and time this catalog was created. */ + created?: string; + /** The date and time this catalog was last updated. */ + updated?: string; + /** Short description in the requested language. */ + shortDescription?: string; + /** Long description in the requested language. */ + longDescription?: string; + /** list of features associated with this offering. */ + features?: Feature[]; + /** Array of kind. */ + kinds?: Kind[]; + /** Is it permitted to request publishing to IBM or Public. */ + permitRequestIbmPublicPublish?: boolean; + /** Indicates if this offering has been approved for use by all IBMers. */ + ibmPublishApproved?: boolean; + /** Indicates if this offering has been approved for use by all IBM Cloud users. */ + publicPublishApproved?: boolean; + /** The original offering CRN that this publish entry came from. */ + publicOriginalCrn?: string; + /** The crn of the public catalog entry of this offering. */ + publishPublicCrn?: string; + /** The portal's approval record ID. */ + portalApprovalRecord?: string; + /** The portal UI URL. */ + portalUiUrl?: string; + /** The id of the catalog containing this offering. */ + catalogId?: string; + /** The name of the catalog. */ + catalogName?: string; + /** Map of metadata values for this offering. */ + metadata?: JsonObject; + /** A disclaimer for this offering. */ + disclaimer?: string; + /** Determine if this offering should be displayed in the Consumption UI. */ + hidden?: boolean; + /** Provider of this offering. */ + provider?: string; + /** Repository info for offerings. */ + repoInfo?: RepoInfo; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteOffering` operation. */ + export interface DeleteOfferingParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `replaceOfferingIcon` operation. */ + export interface ReplaceOfferingIconParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + /** Name of the file name that is being uploaded. */ + fileName: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateOfferingIbm` operation. */ + export interface UpdateOfferingIbmParams { + /** Catalog identifier. */ + catalogIdentifier: string; + /** Offering identification. */ + offeringId: string; + /** Type of approval, ibm or public. */ + approvalType: UpdateOfferingIbmConstants.ApprovalType | string; + /** Approve (true) or disapprove (false). */ + approved: UpdateOfferingIbmConstants.Approved | string; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `updateOfferingIbm` operation. */ + export namespace UpdateOfferingIbmConstants { + /** Type of approval, ibm or public. */ + export enum ApprovalType { + IBM = 'ibm', + PUBLIC = 'public', + } + /** Approve (true) or disapprove (false). */ + export enum Approved { + TRUE = 'true', + FALSE = 'false', + } + } + + /** Parameters for the `getVersionAbout` operation. */ + export interface GetVersionAboutParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getVersionLicense` operation. */ + export interface GetVersionLicenseParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** The ID of the license, which maps to the file name in the 'licenses' directory of this verions tgz file. */ + licenseId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getVersionContainerImages` operation. */ + export interface GetVersionContainerImagesParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deprecateVersion` operation. */ + export interface DeprecateVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `accountPublishVersion` operation. */ + export interface AccountPublishVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `ibmPublishVersion` operation. */ + export interface IbmPublishVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `publicPublishVersion` operation. */ + export interface PublicPublishVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `commitVersion` operation. */ + export interface CommitVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getVersionWorkingCopy` operation. */ + export interface GetVersionWorkingCopyParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getVersionUpdates` operation. */ + export interface GetVersionUpdatesParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** The id of the cluster where this version was installed. */ + clusterId?: string; + /** The region of the cluster where this version was installed. */ + region?: string; + /** The resource group id of the cluster where this version was installed. */ + resourceGroupId?: string; + /** The namespace of the cluster where this version was installed. */ + namespace?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getVersion` operation. */ + export interface GetVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteVersion` operation. */ + export interface DeleteVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listVersions` operation. */ + export interface ListVersionsParams { + /** query, for now only "q=entitlement_key:" is supported. */ + q: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getRepos` operation. */ + export interface GetReposParams { + /** The type of repo (valid repo types: helm). */ + type: string; + /** The URL for the repo's root (e.g https://kubernetes-charts-incubator.storage.googleapis.com). */ + repourl: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getRepo` operation. */ + export interface GetRepoParams { + /** The type of repo (valid repo types: helm). */ + type: string; + /** The URL for the repo's chart zip file (e.g + * https://registry.bluemix.net/helm/ibm-charts/charts/ibm-redis-ha-dev-1.0.0.tgz). + */ + charturl: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listClusters` operation. */ + export interface ListClustersParams { + /** number or results to return. */ + limit?: number; + /** number of results to skip before returning values. */ + offset?: number; + /** Kubernetes or OpenShift. Default is kubernetes. */ + type?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getCluster` operation. */ + export interface GetClusterParams { + /** ID of the cluster. */ + clusterId: string; + /** Region of the cluster. */ + region: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getNamespaces` operation. */ + export interface GetNamespacesParams { + /** ID of the cluster. */ + clusterId: string; + /** Cluster region. */ + region: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** number or results to return. */ + limit?: number; + /** number of results to skip before returning values. */ + offset?: number; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createOperator` operation. */ + export interface CreateOperatorParams { + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster ID. */ + clusterId?: string; + /** Cluster region. */ + region?: string; + /** Kube namespaces to deploy Operator(s) to. */ + namespaces?: string[]; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listOperators` operation. */ + export interface ListOperatorsParams { + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster identification. */ + clusterId: string; + /** Cluster region. */ + region: string; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `replaceOperator` operation. */ + export interface ReplaceOperatorParams { + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster ID. */ + clusterId?: string; + /** Cluster region. */ + region?: string; + /** Kube namespaces to deploy Operator(s) to. */ + namespaces?: string[]; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteOperator` operation. */ + export interface DeleteOperatorParams { + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster identification. */ + clusterId: string; + /** Cluster region. */ + region: string; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `installVersion` operation. */ + export interface InstallVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster ID. */ + clusterId?: string; + /** Cluster region. */ + region?: string; + /** Kube namespace. */ + namespace?: string; + /** Object containing Helm chart override values. */ + overrideValues?: JsonObject; + /** Entitlement API Key for this offering. */ + entitlementApikey?: string; + /** Schematics workspace configuration. */ + schematics?: DeployRequestBodySchematics; + /** Script. */ + script?: string; + /** Script ID. */ + scriptId?: string; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId?: string; + /** VCenter ID. */ + vcenterId?: string; + /** VCenter Password. */ + vcenterPassword?: string; + /** VCenter Location. */ + vcenterLocation?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `preinstallVersion` operation. */ + export interface PreinstallVersionParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster ID. */ + clusterId?: string; + /** Cluster region. */ + region?: string; + /** Kube namespace. */ + namespace?: string; + /** Object containing Helm chart override values. */ + overrideValues?: JsonObject; + /** Entitlement API Key for this offering. */ + entitlementApikey?: string; + /** Schematics workspace configuration. */ + schematics?: DeployRequestBodySchematics; + /** Script. */ + script?: string; + /** Script ID. */ + scriptId?: string; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId?: string; + /** VCenter ID. */ + vcenterId?: string; + /** VCenter Password. */ + vcenterPassword?: string; + /** VCenter Location. */ + vcenterLocation?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getPreinstall` operation. */ + export interface GetPreinstallParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** ID of the cluster. */ + clusterId?: string; + /** Cluster region. */ + region?: string; + /** Required if the version's pre-install scope is `namespace`. */ + namespace?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `validationInstall` operation. */ + export interface ValidationInstallParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + /** Cluster ID. */ + clusterId?: string; + /** Cluster region. */ + region?: string; + /** Kube namespace. */ + namespace?: string; + /** Object containing Helm chart override values. */ + overrideValues?: JsonObject; + /** Entitlement API Key for this offering. */ + entitlementApikey?: string; + /** Schematics workspace configuration. */ + schematics?: DeployRequestBodySchematics; + /** Script. */ + script?: string; + /** Script ID. */ + scriptId?: string; + /** A dotted value of `catalogID`.`versionID`. */ + versionLocatorId?: string; + /** VCenter ID. */ + vcenterId?: string; + /** VCenter Password. */ + vcenterPassword?: string; + /** VCenter Location. */ + vcenterLocation?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getValidationStatus` operation. */ + export interface GetValidationStatusParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getOverrideValues` operation. */ + export interface GetOverrideValuesParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getSchematicsWorkspaces` operation. */ + export interface GetSchematicsWorkspacesParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** IAM Refresh token. */ + xAuthRefreshToken: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `canDeploySchematics` operation. */ + export interface CanDeploySchematicsParams { + /** A dotted value of `catalogID`.`versionID`. */ + versionLocId: string; + /** ID of the cluster. */ + clusterId: string; + /** Cluster region. */ + region: string; + /** Required if the version's pre-install scope is `namespace`. */ + namespace?: string; + /** Resource group identification. */ + resourceGroupId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getResourceGroups` operation. */ + export interface GetResourceGroupsParams { + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getLicenseProviders` operation. */ + export interface GetLicenseProvidersParams { + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listLicenseEntitlements` operation. */ + export interface ListLicenseEntitlementsParams { + /** The account ID to query for the entitlement. Default is the account from the user's token. */ + accountId?: string; + /** The license product ID. If from PPA (Passport Advantage) this is the product Part number(s) which can be one + * or more IDs, eg. D1YGZLL,5737L09. + */ + licenseProductId?: string; + /** The GC ID of the specific offering version. */ + versionId?: string; + /** The state of the license entitlement. eg. usually 'active', or if it's been deleted will show as 'removed'. */ + state?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createLicenseEntitlement` operation. */ + export interface CreateLicenseEntitlementParams { + /** Entitlement name. */ + name?: string; + /** Entitlement is good from this starting date. eg. '2019-07-17T21:21:47.6794935Z'. */ + effectiveFrom?: string; + /** Entitlement is good until this ending date. eg. '2019-07-17T21:21:47.6794935Z'. */ + effectiveUntil?: string; + /** Global Catalog ID of the version. */ + versionId?: string; + /** Specific license entitlement ID from the license provider, eg. D1W3R4. */ + licenseId?: string; + /** IBM ID of the owner of this license entitlement. */ + licenseOwnerId?: string; + /** License provider ID. */ + licenseProviderId?: string; + /** License product ID. */ + licenseProductId?: string; + /** if not specified the token's account will be used. */ + accountId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getLicenseEntitlements` operation. */ + export interface GetLicenseEntitlementsParams { + /** The license product ID. If from PPA (Passport Advantage) this is a specific product Part number, eg. + * D1YGZLL. + */ + licenseProductId: string; + /** The account ID to query for the entitlement. Default is the account from the user's token. */ + accountId?: string; + /** The GC ID of the specific offering version. */ + versionId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteLicenseEntitlement` operation. */ + export interface DeleteLicenseEntitlementParams { + /** The specific entitlement ID (can be obtained from one of the license entitlement queries). */ + entitlementId: string; + /** The account ID to query for the entitlement. Default is the account from the user's token. */ + accountId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getLicenses` operation. */ + export interface GetLicensesParams { + /** ID of the license provider, ie. retrieved from GET license_providers. */ + licenseProviderId: string; + /** If not specified the token's account will be used. */ + accountId?: string; + /** License name. */ + name?: string; + /** Type of license, if not specified, default is ibm-ppa. */ + licenseType?: string; + /** The license product ID. If from PPA (Passport Advantage) this is the product Part number, eg. D1YGZLL. */ + licenseProductId?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `searchLicenseVersions` operation. */ + export interface SearchLicenseVersionsParams { + /** query, for now only "q=entitlement_key:" is supported. */ + q: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `searchLicenseOfferings` operation. */ + export interface SearchLicenseOfferingsParams { + /** query, for now only "q=entitlement_key:" is supported. */ + q: string; + headers?: OutgoingHttpHeaders; + } + + /************************* + * model interfaces + ************************/ + + /** Account information. */ + export interface Account { + /** Account identification. */ + id?: string; + /** Filters for account and catalog filters. */ + account_filters?: Filters; + } + + /** Filters for an Account Group. */ + export interface AccountGroup { + /** Account group identification. */ + id?: string; + /** Filters for account and catalog filters. */ + account_filters?: Filters; + } + + /** The accumulated filters for an account. This will return the account filters plus a filter for each catalog the user has access to. */ + export interface AccumulatedFilters { + /** Filters for accounts (at this time this will always be just one item array). */ + account_filters?: Filters[]; + /** The filters for all of the accessible catalogs. */ + catalog_filters?: AccumulatedFiltersCatalogFiltersItem[]; + } + + /** AccumulatedFiltersCatalogFiltersItem. */ + export interface AccumulatedFiltersCatalogFiltersItem { + /** Filters for catalog. */ + catalog?: AccumulatedFiltersCatalogFiltersItemCatalog; + /** Filters for account and catalog filters. */ + filters?: Filters; + } + + /** Filters for catalog. */ + export interface AccumulatedFiltersCatalogFiltersItemCatalog { + /** The ID of the catalog. */ + id?: string; + /** The name of the catalog. */ + name?: string; + } + + /** Result of approval. */ + export interface ApprovalResult { + /** Visible to IBM. */ + ibm?: boolean; + /** Visible to everyone. */ + public?: boolean; + /** Denotes whether approval has changed. */ + changed?: boolean; + } + + /** Catalog information. */ + export interface Catalog { + /** Unique ID. */ + id?: string; + /** Cloudant revision. */ + _rev?: string; + /** Display Name in the requested language. */ + label?: string; + /** Description in the requested language. */ + short_description?: string; + /** URL for an icon associated with this catalog. */ + catalog_icon_url?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** The url for this specific catalog. */ + url?: string; + /** CRN associated with the catalog. */ + crn?: string; + /** URL path to offerings. */ + offerings_url?: string; + /** List of features associated with this catalog. */ + features?: Feature[]; + /** Denotes whether a catalog is disabled. */ + disabled?: boolean; + /** The date'time this catalog was created. */ + created?: string; + /** The date'time this catalog was last updated. */ + updated?: string; + /** Resource group id the catalog is owned by. */ + resource_group_id?: string; + /** Account that owns catalog. */ + owning_account?: string; + /** Filters for account and catalog filters. */ + catalog_filters?: Filters; + /** Feature information. */ + syndication_settings?: SyndicationResource; + } + + /** Paginated catalog search result. */ + export interface CatalogSearchResult { + /** The offset (origin 0) of the first resource in this page of search results. */ + offset?: number; + /** The maximum number of resources returned in each page of search results. */ + limit?: number; + /** The overall total number of resources in the search result set. */ + total_count?: number; + /** The number of resources returned in this page of search results. */ + resource_count?: number; + /** A URL for retrieving the first page of search results. */ + first?: string; + /** A URL for retrieving the last page of search results. */ + last?: string; + /** A URL for retrieving the previous page of search results. */ + prev?: string; + /** A URL for retrieving the next page of search results. */ + next?: string; + /** Resulting objects. */ + resources?: Catalog[]; + } + + /** Filter on a category. The filter will match against the values of the given category with include or exclude. */ + export interface CategoryFilter { + /** -> true - This is an include filter, false - this is an exclude filter. */ + include?: boolean; + /** Offering filter terms. */ + filter?: FilterTerms; + } + + /** Cluster information. */ + export interface ClusterInfo { + /** Resource Group ID. */ + resource_group_id?: string; + /** Resource Group name. */ + resource_group_name?: string; + /** Cluster ID. */ + id?: string; + /** Cluster name. */ + name?: string; + /** Cluster region. */ + region?: string; + } + + /** Paginated cluster search result. */ + export interface ClusterSearchResult { + /** The offset (origin 0) of the first resource in this page of search results. */ + offset?: number; + /** The maximum number of resources returned in each page of search results. */ + limit?: number; + /** The overall total number of resources in the search result set. */ + total_count?: number; + /** The number of resources returned in this page of search results. */ + resource_count?: number; + /** A URL for retrieving the first page of search results. */ + first?: string; + /** A URL for retrieving the last page of search results. */ + last?: string; + /** A URL for retrieving the previous page of search results. */ + prev?: string; + /** A URL for retrieving the next page of search results. */ + next?: string; + /** Resulting objects. */ + resources?: ClusterInfo[]; + } + + /** Configuration description. */ + export interface Configuration { + /** Configuration key. */ + key?: string; + /** Value type (string, boolean, int). */ + type?: string; + /** The default value. */ + default_value?: any; + /** Constraint associated with value, e.g., for string type - regx:[a-z]. */ + value_constraint?: string; + /** Key description. */ + description?: string; + /** Is key required to install. */ + required?: boolean; + /** List of options of type. */ + options?: JsonObject[]; + /** Hide values. */ + hidden?: boolean; + } + + /** Schematics workspace configuration. */ + export interface DeployRequestBodySchematics { + /** Schematics workspace name. */ + name?: string; + /** Schematics workspace description. */ + description?: string; + /** Schematics workspace tags. */ + tags?: string[]; + /** Resource group to use when creating the schematics workspace. */ + resource_group_id?: string; + } + + /** Failed deployment requirements. */ + export interface DeployRequirementsCheck { + /** Failed during pre-install. */ + pre_install?: JsonObject; + /** Failed during install. */ + install?: JsonObject; + } + + /** Deployment for offering. */ + export interface Deployment { + /** unique id. */ + id?: string; + /** Display Name in the requested language. */ + label?: string; + /** The programmatic name of this offering. */ + name?: string; + /** Short description in the requested language. */ + short_description?: string; + /** Long description in the requested language. */ + long_description?: string; + /** open ended metadata information. */ + metadata?: JsonObject; + /** list of tags associated with this catalog. */ + tags?: string[]; + /** the date'time this catalog was created. */ + created?: string; + /** the date'time this catalog was last updated. */ + updated?: string; + } + + /** Enterprise account information. */ + export interface Enterprise { + /** Enterprise identification. */ + id?: string; + /** Cloudant revision. */ + _rev?: string; + /** Filters for account and catalog filters. */ + account_filters?: Filters; + /** Map of account group ids to AccountGroup objects. */ + account_groups?: EnterpriseAccountGroups; + } + + /** Map of account group ids to AccountGroup objects. */ + export interface EnterpriseAccountGroups { + /** Filters for an Account Group. */ + keys?: AccountGroup; + } + + /** Feature information. */ + export interface Feature { + /** Heading. */ + title?: string; + /** Feature description. */ + description?: string; + } + + /** Offering filter terms. */ + export interface FilterTerms { + /** List of values to match against. If include is true, then if the offering has one of the values then the + * offering is included. If include is false, then if the offering has one of the values then the offering is + * excluded. + */ + filter_terms?: string[]; + } + + /** Filters for account and catalog filters. */ + export interface Filters { + /** -> true - Include all of the public catalog when filtering. Further settings will specifically exclude some + * offerings. false - Exclude all of the public catalog when filtering. Further settings will specifically include + * some offerings. + */ + include_all?: boolean; + /** Filter against offering properties. */ + category_filters?: JsonObject; + /** Filter on offering ID's. There is an include filter and an exclule filter. Both can be set. */ + id_filters?: IDFilter; + } + + /** Helm chart. */ + export interface HelmChart { + /** Chart name. */ + name?: string; + /** Chart description. */ + description?: string; + /** Chart icon. */ + icon?: string; + /** Chart version. */ + version?: string; + /** Chart app version. */ + appVersion?: string; + } + + /** Helm package. */ + export interface HelmPackage { + /** The name of the requested chart, or the name of a nested chart within the requested chart. */ + chart?: HelmPackageChart; + } + + /** The name of the requested chart, or the name of a nested chart within the requested chart. */ + export interface HelmPackageChart { + /** Helm chart. */ + 'Chart.yaml'?: HelmChart; + /** Project SHA. */ + sha?: JsonObject; + /** Helm chart description. */ + 'README.md'?: string; + /** Values metadata. */ + 'values-metadata'?: JsonObject; + /** License metadata. */ + 'license-metadata'?: JsonObject; + } + + /** Helm repository metadata. */ + export interface HelmRepoList { + /** A chart entry in the repo. This response will contain many chart names. */ + chart?: HelmRepoListChart; + } + + /** A chart entry in the repo. This response will contain many chart names. */ + export interface HelmRepoListChart { + /** API version. */ + api_version?: string; + /** Date and time created. */ + created?: string; + /** Description of Helm repo entry. */ + description?: string; + /** Denotes whether repo entry is deprecated. */ + deprecated?: boolean; + /** Digest of entry. */ + digest?: string; + /** Location of repo entry. */ + home?: string; + /** Entry icon. */ + icon?: string; + /** List of keywords. */ + keywords?: string[]; + /** Emails and names of repo maintainers. */ + maintainers?: Maintainers[]; + /** Entry name. */ + name?: string; + /** Helm server version. */ + tiller_version?: string; + /** Array of URLs. */ + urls?: string[]; + /** Array of sources. */ + sources?: string[]; + /** Entry version. */ + version?: string; + /** Application version. */ + appVersion?: string; + } + + /** Filter on offering ID's. There is an include filter and an exclule filter. Both can be set. */ + export interface IDFilter { + /** Offering filter terms. */ + include?: FilterTerms; + /** Offering filter terms. */ + exclude?: FilterTerms; + } + + /** Image. */ + export interface Image { + /** Image. */ + image?: string; + } + + /** Image Manifest. */ + export interface ImageManifest { + /** Image manifest description. */ + description?: string; + /** List of images. */ + images?: Image[]; + } + + /** Installation status. */ + export interface InstallStatus { + /** Installation status metadata. */ + metadata?: InstallStatusMetadata; + /** Release information. */ + release?: InstallStatusRelease; + /** Content management information. */ + content_mgmt?: InstallStatusContentMgmt; + } + + /** Content management information. */ + export interface InstallStatusContentMgmt { + /** Pods. */ + pods?: JsonObject[]; + /** Errors. */ + errors?: JsonObject[]; + } + + /** Installation status metadata. */ + export interface InstallStatusMetadata { + /** Cluster ID. */ + cluster_id?: string; + /** Cluster region. */ + region?: string; + /** Cluster namespace. */ + namespace?: string; + /** Workspace ID. */ + workspace_id?: string; + /** Workspace name. */ + workspace_name?: string; + } + + /** Release information. */ + export interface InstallStatusRelease { + /** Kube deployments. */ + deployments?: JsonObject[]; + /** Kube replica sets. */ + replicasets?: JsonObject[]; + /** Kube stateful sets. */ + statefulsets?: JsonObject[]; + /** Kube pods. */ + pods?: JsonObject[]; + /** Kube errors. */ + errors?: JsonObject[]; + } + + /** Offering kind. */ + export interface Kind { + /** Unique ID. */ + id?: string; + /** content kind, e.g., helm, vm image. */ + format_kind?: string; + /** target cloud to install, e.g., iks, open_shift_iks. */ + target_kind?: string; + /** Open ended metadata information. */ + metadata?: JsonObject; + /** Installation instruction. */ + install_description?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** List of features associated with this offering. */ + additional_features?: Feature[]; + /** The date and time this catalog was created. */ + created?: string; + /** The date and time this catalog was last updated. */ + updated?: string; + /** list of versions. */ + versions?: Version[]; + /** list of plans. */ + plans?: Plan[]; + } + + /** BSS license. */ + export interface License { + /** License ID. */ + id?: string; + /** license name. */ + name?: string; + /** type of license e.g., Apache xxx. */ + type?: string; + /** URL for the license text. */ + url?: string; + /** License description. */ + description?: string; + } + + /** License entitlement. */ + export interface LicenseEntitlement { + /** Entitlement name. */ + name?: string; + /** Entitlement ID. */ + id?: string; + /** Entitlement CRN. */ + crn?: string; + /** URL for the BSS entitlement, e.g. /v1/licensing/entitlements/:id. */ + url?: string; + /** Entitlement offering type. */ + offering_type?: string; + /** State of the BSS entitlement, e.g. 'active' or if it's been deleted, 'removed'. */ + state?: string; + /** Entitlement is good from this starting date. eg. '2019-07-17T21:21:47.6794935Z'. */ + effective_from?: string; + /** Entitlement is good until this ending date. eg. '2019-07-17T21:21:47.6794935Z'. */ + effective_until?: string; + /** Account ID where this entitlement is bound to. */ + account_id?: string; + /** Account ID of owner. */ + owner_id?: string; + /** GC ID of the specific offering version. */ + version_id?: string; + /** Marketplace offering ID for this license entitlement. */ + license_offering_id?: string; + /** Specific license entitlement ID from the license provider, eg. D1W3R4. */ + license_id?: string; + /** IBM ID of the owner of this license entitlement. */ + license_owner_id?: string; + /** Type of license entitlement, e.g. ibm-ppa. */ + license_type?: string; + /** ID of the license provider. */ + license_provider_id?: string; + /** URL for the BSS license provider, e.g. /v1/licensing/license_providers/:license_provider_id. */ + license_provider_url?: string; + /** Specific license entitlement ID from the license provider, eg. D1W3R4. */ + license_product_id?: string; + /** Location of the registry images, eg. cp/cp4d. */ + namespace_repository?: string; + /** API key for access to the license entitlement. */ + apikey?: string; + /** IBM ID. */ + create_by?: string; + /** IBM ID. */ + update_by?: string; + /** Creation date, eg. '2019-07-17T21:21:47.6794935Z'. */ + create_at?: string; + /** Date last updated, eg. '2019-07-17T21:21:47.6794935Z'. */ + updated_at?: string; + /** Entitlement history. */ + history?: LicenseEntitlementHistoryItem[]; + /** Array of license offering references. */ + offering_list?: LicenseOfferingReference[]; + } + + /** LicenseEntitlementHistoryItem. */ + export interface LicenseEntitlementHistoryItem { + /** Eg. create. */ + action?: string; + /** Eg. IBM ID of user. */ + user?: string; + /** Date of action, eg. '2019-07-17T21:21:47.6794935Z'. */ + date?: string; + } + + /** Paginated list of license entitlements. */ + export interface LicenseEntitlements { + /** Total number of results. */ + total_results?: number; + /** Total number of pages. */ + total_pages?: number; + /** Previous URL. */ + prev_url?: string; + /** Next URL. */ + next_url?: string; + /** Resulting Entitlement objects. */ + resources?: LicenseEntitlement[]; + } + + /** License information. */ + export interface LicenseObject { + /** License name. */ + name?: string; + /** Type of offering. */ + offering_type?: string; + /** Number of seats allowed for license. */ + seats_allowed?: string; + /** Number of seats used for license. */ + seats_used?: string; + /** ID of license owner. */ + owner_id?: string; + /** Marketplace offering ID for this license. */ + license_offering_id?: string; + /** specific license entitlement ID from the license provider, eg. D1W3R4. */ + license_id?: string; + /** IBM ID of the owner of this license entitlement. */ + license_owner_id?: string; + /** type of license entitlement, e.g. ibm-ppa. */ + license_type?: string; + /** ID of the license provider. */ + license_provider_id?: string; + /** specific license entitlement ID from the license provider, eg. D1W3R4. */ + license_product_id?: string; + /** URL for the BSS license provider, e.g. /v1/licensing/license_providers/:license_provider_id. */ + license_provider_url?: string; + /** license is good from this starting date. eg. '2019-07-17T21:21:47.6794935Z'. */ + effective_from?: string; + /** license is good until this ending date. eg. '2019-07-17T21:21:47.6794935Z'. */ + effective_until?: string; + /** If true, this will allow use of this license by all IBMers. */ + internal?: boolean; + /** Array of license offering references. */ + offering_list?: LicenseOfferingReference[]; + } + + /** License offering reference. */ + export interface LicenseOfferingReference { + /** Offering ID. */ + id?: string; + /** Offering name. */ + name?: string; + /** Offering label'. */ + label?: string; + /** URL to offering icon. */ + offering_icon_url?: string; + /** Account ID associated with offering. */ + account_id?: string; + /** Catalog ID associated with offering. */ + catalog_id?: string; + } + + /** BSS License provider. */ + export interface LicenseProvider { + /** Provider name, eg. IBM Passport Advantage. */ + name?: string; + /** Short description of license provider. */ + short_description?: string; + /** Provider ID. */ + id?: string; + /** Type of license entitlement, e.g. ibm-ppa. */ + licence_type?: string; + /** Type of offering. */ + offering_type?: string; + /** URL of the license provider for where to create/get a license, e.g. + * https://www.ibm.com/software/passportadvantage/aboutpassport.html. + */ + create_url?: string; + /** URL of the license provider for additional info, e.g. https://www.ibm.com/software/passportadvantage. */ + info_url?: string; + /** URL for the BSS license provider, e.g. /v1/licensing/license_providers/:id. */ + url?: string; + /** Provider CRN. */ + crn?: string; + /** State of license provider. */ + state?: string; + } + + /** Paginated list of license providers. */ + export interface LicenseProviders { + /** Total number of results. */ + total_results?: number; + /** Total number of pages. */ + total_pages?: number; + /** Previous URL. */ + prev_url?: string; + /** Next URL. */ + next_url?: string; + /** Resulting License Provider objects. */ + resources?: LicenseProvider[]; + } + + /** Paginated list of licenses. */ + export interface Licenses { + /** Total number of results. */ + total_results?: number; + /** Total number of pages. */ + total_pages?: number; + /** Previous URL. */ + prev_url?: string; + /** Next URL. */ + next_url?: string; + /** Resulting License objects. */ + resources?: LicenseObject[]; + } + + /** Repo maintainers. */ + export interface Maintainers { + /** Maintainer email address. */ + email?: string; + /** Name of maintainer. */ + name?: string; + } + + /** Paginated list of namespace search results. */ + export interface NamespaceSearchResult { + /** The offset (origin 0) of the first resource in this page of search results. */ + offset?: number; + /** The maximum number of resources returned in each page of search results. */ + limit?: number; + /** The overall total number of resources in the search result set. */ + total_count?: number; + /** The number of resources returned in this page of search results. */ + resource_count?: number; + /** A URL for retrieving the first page of search results. */ + first?: string; + /** A URL for retrieving the last page of search results. */ + last?: string; + /** A URL for retrieving the previous page of search results. */ + prev?: string; + /** A URL for retrieving the next page of search results. */ + next?: string; + /** Resulting objects. */ + resources?: string[]; + } + + /** Offering information. */ + export interface Offering { + /** unique id. */ + id?: string; + /** Cloudant revision. */ + _rev?: string; + /** The url for this specific offering. */ + url?: string; + /** The crn for this specific offering. */ + crn?: string; + /** Display Name in the requested language. */ + label?: string; + /** The programmatic name of this offering. */ + name?: string; + /** URL for an icon associated with this offering. */ + offering_icon_url?: string; + /** URL for an additional docs with this offering. */ + offering_docs_url?: string; + /** URL to be displayed in the Consumption UI for getting support on this offering. */ + offering_support_url?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** Repository info for offerings. */ + rating?: Rating; + /** The date and time this catalog was created. */ + created?: string; + /** The date and time this catalog was last updated. */ + updated?: string; + /** Short description in the requested language. */ + short_description?: string; + /** Long description in the requested language. */ + long_description?: string; + /** list of features associated with this offering. */ + features?: Feature[]; + /** Array of kind. */ + kinds?: Kind[]; + /** Is it permitted to request publishing to IBM or Public. */ + permit_request_ibm_public_publish?: boolean; + /** Indicates if this offering has been approved for use by all IBMers. */ + ibm_publish_approved?: boolean; + /** Indicates if this offering has been approved for use by all IBM Cloud users. */ + public_publish_approved?: boolean; + /** The original offering CRN that this publish entry came from. */ + public_original_crn?: string; + /** The crn of the public catalog entry of this offering. */ + publish_public_crn?: string; + /** The portal's approval record ID. */ + portal_approval_record?: string; + /** The portal UI URL. */ + portal_ui_url?: string; + /** The id of the catalog containing this offering. */ + catalog_id?: string; + /** The name of the catalog. */ + catalog_name?: string; + /** Map of metadata values for this offering. */ + metadata?: JsonObject; + /** A disclaimer for this offering. */ + disclaimer?: string; + /** Determine if this offering should be displayed in the Consumption UI. */ + hidden?: boolean; + /** Provider of this offering. */ + provider?: string; + /** Repository info for offerings. */ + repo_info?: RepoInfo; + } + + /** Paginated offering search result. */ + export interface OfferingSearchResult { + /** The offset (origin 0) of the first resource in this page of search results. */ + offset?: number; + /** The maximum number of resources returned in each page of search results. */ + limit?: number; + /** The overall total number of resources in the search result set. */ + total_count?: number; + /** The number of resources returned in this page of search results. */ + resource_count?: number; + /** A URL for retrieving the first page of search results. */ + first?: string; + /** A URL for retrieving the last page of search results. */ + last?: string; + /** A URL for retrieving the previous page of search results. */ + prev?: string; + /** A URL for retrieving the next page of search results. */ + next?: string; + /** Resulting objects. */ + resources?: Offering[]; + } + + /** Operator deploy result. */ + export interface OperatorDeployResult { + /** Status phase. */ + phase?: string; + /** Status message. */ + message?: string; + /** Operator API path. */ + link?: string; + /** Name of Operator. */ + name?: string; + /** Operator version. */ + version?: string; + /** Kube namespace. */ + namespace?: string; + /** Package Operator exists in. */ + package_name?: string; + /** Catalog identification. */ + catalog_id?: string; + } + + /** Offering plan. */ + export interface Plan { + /** unique id. */ + id?: string; + /** Display Name in the requested language. */ + label?: string; + /** The programmatic name of this offering. */ + name?: string; + /** Short description in the requested language. */ + short_description?: string; + /** Long description in the requested language. */ + long_description?: string; + /** open ended metadata information. */ + metadata?: JsonObject; + /** list of tags associated with this catalog. */ + tags?: string[]; + /** list of features associated with this offering. */ + additional_features?: Feature[]; + /** the date'time this catalog was created. */ + created?: string; + /** the date'time this catalog was last updated. */ + updated?: string; + /** list of deployments. */ + deployments?: Deployment[]; + } + + /** Repository info for offerings. */ + export interface Rating { + /** One start rating. */ + one_star_count?: number; + /** Two start rating. */ + two_star_count?: number; + /** Three start rating. */ + three_star_count?: number; + /** Four start rating. */ + four_star_count?: number; + } + + /** Repository info for offerings. */ + export interface RepoInfo { + /** Token for private repos. */ + token?: string; + /** Public or enterprise GitHub. */ + type?: string; + } + + /** Resource requirements. */ + export interface Resource { + /** Type of requirement. */ + type?: string; + /** mem, disk, cores, and nodes can be parsed as an int. targetVersion will be a semver range value. */ + value?: any; + } + + /** Resource group details. */ + export interface ResourceGroup { + /** Resource Group ID. */ + id?: string; + /** Provider name, eg. IBM Passport Advantage. */ + name?: string; + /** Provider CRN. */ + crn?: string; + /** Account ID for this Resource Group. */ + account_id?: string; + /** State of this Resource Group. */ + state?: string; + /** Indicates if this Resource Group is active or not. */ + default?: boolean; + } + + /** Resource groups details. */ + export interface ResourceGroups { + /** The offset (origin 0) of the first resource in this page of search results. */ + offset?: number; + /** The maximum number of resources returned in each page of search results. */ + limit?: number; + /** The overall total number of resources in the search result set. */ + total_count?: number; + /** The number of resources returned in this page of search results. */ + resource_count?: number; + /** A URL for retrieving the first page of search results. */ + first?: string; + /** A URL for retrieving the last page of search results. */ + last?: string; + /** A URL for retrieving the previous page of search results. */ + prev?: string; + /** A URL for retrieving the next page of search results. */ + next?: string; + /** Resulting Resource Group objects. */ + resources?: ResourceGroup[]; + } + + /** Schematics workspace information. */ + export interface SchematicsWorkspace { + /** Workspace ID. */ + id?: string; + /** Workspace name. */ + name?: string; + /** Workspace types. */ + type?: string[]; + /** Workspace description. */ + description?: string; + /** Workspace tags. */ + tags?: string[]; + /** Workspace creation date and time. */ + created_at?: string; + /** Email address of user that created the ID. */ + created_by?: string; + /** Workspace apply status. */ + status?: string; + /** Workspace frozen/locked status. */ + workspace_status?: SchematicsWorkspaceWorkspaceStatus; + /** Template reference. */ + template_ref?: string; + /** Template repository. */ + template_repo?: SchematicsWorkspaceTemplateRepo; + /** Map of template data. */ + template_data?: JsonObject[]; + /** Data describing runtime. */ + runtime_data?: SchematicsWorkspaceRuntimeData; + /** Map of shared data. */ + shared_data?: JsonObject; + /** Catalog reference. */ + catalog_ref?: SchematicsWorkspaceCatalogRef; + } + + /** Catalog reference. */ + export interface SchematicsWorkspaceCatalogRef { + /** Version locator ID. */ + item_id?: string; + /** The name of the offering that generated this Blueprint. */ + item_name?: string; + /** Relative Dashboard URL for content that generated this Blueprint. */ + item_url?: string; + } + + /** Data describing runtime. */ + export interface SchematicsWorkspaceRuntimeData { + /** Runtime ID. */ + id?: string; + /** Engine name. */ + engine_name?: string; + /** Engine version. */ + engine_version?: string; + /** URL path to state store. */ + state_store_url?: string; + /** URL path to log store. */ + log_store_url?: string; + } + + /** Result of schematics workspace search. */ + export interface SchematicsWorkspaceSearchResult { + /** The offset (origin 0) of the first resource in this page of search results. */ + offset?: number; + /** The maximum number of resources returned in each page of search results. */ + limit?: number; + /** The overall total number of resources in the search result set. */ + total_count?: number; + /** The number of resources returned in this page of search results. */ + resource_count?: number; + /** A URL for retrieving the first page of search results. */ + first?: string; + /** A URL for retrieving the last page of search results. */ + last?: string; + /** A URL for retrieving the previous page of search results. */ + prev?: string; + /** A URL for retrieving the next page of search results. */ + next?: string; + /** Resulting objects. */ + resources?: SchematicsWorkspace[]; + } + + /** Template repository. */ + export interface SchematicsWorkspaceTemplateRepo { + /** The fully qualified path of the tgz used in the deploy. */ + repo_url?: string; + /** Name of chart. */ + chart_name?: string; + /** Name of script. */ + script_name?: string; + /** Name of uninstall script. */ + uninstall_script_name?: string; + /** Name of folder. */ + folder_name?: string; + /** Digest of project. */ + repo_sha_value?: string; + } + + /** Workspace frozen/locked status. */ + export interface SchematicsWorkspaceWorkspaceStatus { + /** Workspace frozen state. */ + frozen?: boolean; + /** Workspace locked state. */ + locked?: boolean; + } + + /** Script information. */ + export interface Script { + /** Instruction on step and by whom (role) that are needed to take place to prepare the target for installing + * this version. + */ + instructions?: string; + /** Optional script that needs to be run post any pre-condition script. */ + script?: string; + /** Optional iam permissions that are required on the target cluster to run this script. */ + script_permission?: string; + /** Optional script that if run will remove the installed version. */ + delete_script?: string; + /** Optional value indicating if this script is scoped to a namespace or the entire cluster. */ + scope?: string; + } + + /** Offering state. */ + export interface State { + /** one of: new, validated, account-published, ibm-published, public-published. */ + current?: string; + /** Date and time of current request. */ + current_entered?: string; + /** one of: new, validated, account-published, ibm-published, public-published. */ + pending?: string; + /** Date and time of pending request. */ + pending_requested?: string; + /** one of: new, validated, account-published, ibm-published, public-published. */ + previous?: string; + } + + /** Feature information. */ + export interface SyndicationAuthorization { + /** Array of syndicated namespaces. */ + token?: string; + /** Date and time last updated. */ + last_run?: string; + } + + /** Feature information. */ + export interface SyndicationCluster { + /** Cluster region. */ + region?: string; + /** Cluster ID. */ + id?: string; + /** Cluster name. */ + name?: string; + /** Resource group ID. */ + resource_group_name?: string; + /** Syndication type. */ + type?: string; + /** Syndicated namespaces. */ + namespaces?: string[]; + /** Syndicated to all namespaces on cluster. */ + all_namespaces?: boolean; + } + + /** Feature information. */ + export interface SyndicationHistory { + /** Array of syndicated namespaces. */ + namespaces?: string[]; + /** Array of syndicated namespaces. */ + clusters?: SyndicationCluster[]; + /** Date and time last syndicated. */ + last_run?: string; + } + + /** Feature information. */ + export interface SyndicationResource { + /** Remove related components. */ + remove_related_components?: boolean; + /** Syndication clusters. */ + clusters?: SyndicationCluster[]; + /** Feature information. */ + history?: SyndicationHistory; + /** Feature information. */ + authorization?: SyndicationAuthorization; + } + + /** Validation response. */ + export interface Validation { + /** Date and time of last successful validation. */ + validated?: string; + /** Date and time of last validation was requested. */ + requested?: string; + /** Current validation state - , in_progress, valid, invalid, expired. */ + state?: string; + /** Last operation (e.g. submit_deployment, generate_installer, install_offering. */ + last_operation?: string; + /** Validation target information (e.g. cluster_id, region, namespace, etc). Values will vary by Content type. */ + target?: JsonObject; + } + + /** Offering version information. */ + export interface Version { + /** Unique ID. */ + id?: string; + /** Cloudant revision. */ + _rev?: string; + /** Version's CRN. */ + crn?: string; + /** Version of content type. */ + version?: string; + /** hash of the content. */ + sha?: string; + /** The date and time this version was created. */ + created?: string; + /** The date and time this version was last updated. */ + updated?: string; + /** Offering ID. */ + offering_id?: string; + /** Catalog ID. */ + catalog_id?: string; + /** Kind ID. */ + kind_id?: string; + /** List of tags associated with this catalog. */ + tags?: string[]; + /** Content's repo URL. */ + repo_url?: string; + /** Content's source URL (e.g git repo). */ + source_url?: string; + /** File used to on-board this version. */ + tgz_url?: string; + /** List of user solicited overrides. */ + configuration?: Configuration[]; + /** Open ended metadata information. */ + metadata?: JsonObject; + /** Validation response. */ + validation?: Validation; + /** Resource requirments for installation. */ + required_resources?: Resource[]; + /** Denotes if single instance can be deployed to a given cluster. */ + single_instance?: boolean; + /** Script information. */ + install?: Script; + /** Optional pre-install instructions. */ + pre_install?: Script[]; + /** Entitlement license info. */ + entitlement?: VersionEntitlement; + /** List of licenses the product was built with. */ + licenses?: License[]; + /** If set, denotes a url to a YAML file with list of container images used by this version. */ + image_manifest_url?: string; + /** read only field, indicating if this version is deprecated. */ + deprecated?: boolean; + /** Version of the package used to create this version. */ + package_version?: string; + /** Offering state. */ + state?: State; + /** A dotted value of `catalogID`.`versionID`. */ + version_locator?: string; + /** Console URL. */ + console_url?: string; + /** Long description for version. */ + long_description?: string; + /** Whitelisted accounts for version. */ + whitelisted_accounts?: string[]; + } + + /** Entitlement license info. */ + export interface VersionEntitlement { + /** Provider name. */ + provider_name?: string; + /** Provider ID. */ + provider_id?: string; + /** Product ID. */ + product_id?: string; + /** list of license entitlement part numbers, eg. D1YGZLL,D1ZXILL. */ + part_numbers?: string[]; + /** Image repository name. */ + image_repo_name?: string; + } + + /** Indicates if the current version can be upgraded to the version identified by the descriptor. */ + export interface VersionUpdateDescriptor { + /** A dotted value of `catalogID`.`versionID`. */ + version_locator?: string; + /** the version number of this version. */ + version?: string; + /** Offering state. */ + state?: State; + /** Resource requirments for installation. */ + required_resources?: Resource[]; + /** Version of package. */ + package_version?: string; + /** true if the current version can be upgraded to this version, false otherwise. */ + can_update?: boolean; + /** If can_update is false, this map will contain messages for each failed check, otherwise it will be omitted. + * Possible keys include nodes, cores, mem, disk, targetVersion, and install-permission-check. + */ + messages?: JsonObject; + } + +} + +export = CatalogManagementV1; diff --git a/examples/catalog-management.v1.test.js b/examples/catalog-management.v1.test.js new file mode 100644 index 00000000..39b1d412 --- /dev/null +++ b/examples/catalog-management.v1.test.js @@ -0,0 +1,1525 @@ +/** +* @jest-environment node +*/ +/** + * (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. + */ +'use strict'; + +const CatalogManagementV1 = require('../dist/catalog-management/v1'); + +// Save original console.log and console.warn +const originalLog = console.log +const originalWarn = console.warn + +// Mocks for console.log and console.warn +const consoleLogMock = jest.spyOn(console, 'log'); +const consoleWarnMock = jest.spyOn(console, 'warn'); + +const catalogManagement = CatalogManagementV1.newInstance({}); + +describe('CatalogManagementV1', () => { + test('getCatalogAccount request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getCatalogAccount + + catalogManagement.getCatalogAccount({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getCatalogAccount + }); + test('updateCatalogAccount request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-updateCatalogAccount + + catalogManagement.updateCatalogAccount({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-updateCatalogAccount + }); + test('getCatalogAccountFilters request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getCatalogAccountFilters + + catalogManagement.getCatalogAccountFilters({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getCatalogAccountFilters + }); + test('listCatalogs request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-listCatalogs + + catalogManagement.listCatalogs({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-listCatalogs + }); + test('createCatalog request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-createCatalog + + catalogManagement.createCatalog({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-createCatalog + }); + test('getCatalog request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getCatalog + + const params = { + catalogIdentifier: 'testString', + }; + + catalogManagement.getCatalog(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getCatalog + }); + test('replaceCatalog request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-replaceCatalog + + const params = { + catalogIdentifier: 'testString', + }; + + catalogManagement.replaceCatalog(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-replaceCatalog + }); + test('getEnterprise request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getEnterprise + + const params = { + enterpriseId: 'testString', + }; + + catalogManagement.getEnterprise(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getEnterprise + }); + test('replaceEnterprise request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-replaceEnterprise + + const params = { + enterpriseId: 'testString', + }; + + catalogManagement.replaceEnterprise(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-replaceEnterprise + }); + test('getConsumptionOfferings request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getConsumptionOfferings + + catalogManagement.getConsumptionOfferings({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getConsumptionOfferings + }); + test('listOfferings request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-listOfferings + + const params = { + catalogIdentifier: 'testString', + }; + + catalogManagement.listOfferings(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-listOfferings + }); + test('createOffering request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-createOffering + + const params = { + catalogIdentifier: 'testString', + }; + + catalogManagement.createOffering(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-createOffering + }); + test('importOfferingVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-importOfferingVersion + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + zipurl: 'testString', + }; + + catalogManagement.importOfferingVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-importOfferingVersion + }); + test('importOffering request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-importOffering + + const params = { + catalogIdentifier: 'testString', + zipurl: 'testString', + }; + + catalogManagement.importOffering(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-importOffering + }); + test('reloadOffering request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-reloadOffering + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + zipurl: 'testString', + targetVersion: 'testString', + }; + + catalogManagement.reloadOffering(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-reloadOffering + }); + test('getOffering request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getOffering + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + }; + + catalogManagement.getOffering(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getOffering + }); + test('replaceOffering request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-replaceOffering + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + }; + + catalogManagement.replaceOffering(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-replaceOffering + }); + test('replaceOfferingIcon request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-replaceOfferingIcon + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + fileName: 'testString', + }; + + catalogManagement.replaceOfferingIcon(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-replaceOfferingIcon + }); + test('updateOfferingIbm request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-updateOfferingIbm + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + approvalType: 'ibm', + approved: 'true', + }; + + catalogManagement.updateOfferingIbm(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-updateOfferingIbm + }); + test('getVersionAbout request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getVersionAbout + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.getVersionAbout(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getVersionAbout + }); + test('getVersionLicense request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getVersionLicense + + const params = { + versionLocId: 'testString', + licenseId: 'testString', + }; + + catalogManagement.getVersionLicense(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getVersionLicense + }); + test('getVersionContainerImages request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getVersionContainerImages + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.getVersionContainerImages(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getVersionContainerImages + }); + test('deprecateVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-deprecateVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.deprecateVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-deprecateVersion + }); + test('accountPublishVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-accountPublishVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.accountPublishVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-accountPublishVersion + }); + test('ibmPublishVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-ibmPublishVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.ibmPublishVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-ibmPublishVersion + }); + test('publicPublishVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-publicPublishVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.publicPublishVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-publicPublishVersion + }); + test('commitVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-commitVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.commitVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-commitVersion + }); + test('getVersionWorkingCopy request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getVersionWorkingCopy + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.getVersionWorkingCopy(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getVersionWorkingCopy + }); + test('getVersionUpdates request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getVersionUpdates + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.getVersionUpdates(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getVersionUpdates + }); + test('getVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.getVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getVersion + }); + test('listVersions request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-listVersions + + const params = { + q: 'testString', + }; + + catalogManagement.listVersions(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-listVersions + }); + test('getRepos request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getRepos + + const params = { + type: 'testString', + repourl: 'testString', + }; + + catalogManagement.getRepos(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getRepos + }); + test('getRepo request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getRepo + + const params = { + type: 'testString', + charturl: 'testString', + }; + + catalogManagement.getRepo(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getRepo + }); + test('listClusters request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-listClusters + + catalogManagement.listClusters({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-listClusters + }); + test('getCluster request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getCluster + + const params = { + clusterId: 'testString', + region: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.getCluster(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getCluster + }); + test('getNamespaces request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getNamespaces + + const params = { + clusterId: 'testString', + region: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.getNamespaces(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getNamespaces + }); + test('createOperator request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-createOperator + + const params = { + xAuthRefreshToken: 'testString', + }; + + catalogManagement.createOperator(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-createOperator + }); + test('listOperators request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-listOperators + + const params = { + xAuthRefreshToken: 'testString', + clusterId: 'testString', + region: 'testString', + versionLocatorId: 'testString', + }; + + catalogManagement.listOperators(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-listOperators + }); + test('replaceOperator request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-replaceOperator + + const params = { + xAuthRefreshToken: 'testString', + }; + + catalogManagement.replaceOperator(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-replaceOperator + }); + test('installVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-installVersion + + const params = { + versionLocId: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.installVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-installVersion + }); + test('preinstallVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-preinstallVersion + + const params = { + versionLocId: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.preinstallVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-preinstallVersion + }); + test('getPreinstall request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getPreinstall + + const params = { + versionLocId: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.getPreinstall(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getPreinstall + }); + test('validationInstall request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-validationInstall + + const params = { + versionLocId: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.validationInstall(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-validationInstall + }); + test('getValidationStatus request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getValidationStatus + + const params = { + versionLocId: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.getValidationStatus(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getValidationStatus + }); + test('getOverrideValues request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getOverrideValues + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.getOverrideValues(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getOverrideValues + }); + test('getSchematicsWorkspaces request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getSchematicsWorkspaces + + const params = { + versionLocId: 'testString', + xAuthRefreshToken: 'testString', + }; + + catalogManagement.getSchematicsWorkspaces(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getSchematicsWorkspaces + }); + test('canDeploySchematics request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-canDeploySchematics + + const params = { + versionLocId: 'testString', + clusterId: 'testString', + region: 'testString', + }; + + catalogManagement.canDeploySchematics(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-canDeploySchematics + }); + test('getResourceGroups request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getResourceGroups + + catalogManagement.getResourceGroups({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getResourceGroups + }); + test('getLicenseProviders request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getLicenseProviders + + catalogManagement.getLicenseProviders({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getLicenseProviders + }); + test('listLicenseEntitlements request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-listLicenseEntitlements + + catalogManagement.listLicenseEntitlements({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-listLicenseEntitlements + }); + test('createLicenseEntitlement request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-createLicenseEntitlement + + catalogManagement.createLicenseEntitlement({}) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-createLicenseEntitlement + }); + test('getLicenseEntitlements request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getLicenseEntitlements + + const params = { + licenseProductId: 'testString', + }; + + catalogManagement.getLicenseEntitlements(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getLicenseEntitlements + }); + test('getLicenses request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-getLicenses + + const params = { + licenseProviderId: 'testString', + }; + + catalogManagement.getLicenses(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-getLicenses + }); + test('searchLicenseVersions request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-searchLicenseVersions + + const params = { + q: 'testString', + }; + + catalogManagement.searchLicenseVersions(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-searchLicenseVersions + }); + test('searchLicenseOfferings request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-searchLicenseOfferings + + const params = { + q: 'testString', + }; + + catalogManagement.searchLicenseOfferings(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-searchLicenseOfferings + }); + test('deleteVersion request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-deleteVersion + + const params = { + versionLocId: 'testString', + }; + + catalogManagement.deleteVersion(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-deleteVersion + }); + test('deleteOperator request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-deleteOperator + + const params = { + xAuthRefreshToken: 'testString', + clusterId: 'testString', + region: 'testString', + versionLocatorId: 'testString', + }; + + catalogManagement.deleteOperator(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-deleteOperator + }); + test('deleteOffering request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-deleteOffering + + const params = { + catalogIdentifier: 'testString', + offeringId: 'testString', + }; + + catalogManagement.deleteOffering(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-deleteOffering + }); + test('deleteLicenseEntitlement request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-deleteLicenseEntitlement + + const params = { + entitlementId: 'testString', + }; + + catalogManagement.deleteLicenseEntitlement(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-deleteLicenseEntitlement + }); + test('deleteCatalog request example', done => { + + consoleLogMock.mockImplementation(output => { + done(); + }); + consoleWarnMock.mockImplementation(output => { + done(output); + }); + + // begin-deleteCatalog + + const params = { + catalogIdentifier: 'testString', + }; + + catalogManagement.deleteCatalog(params) + .then(res => { + console.log(JSON.stringify(res.result, null, 2)); + }) + .catch(err => { + console.warn(err) + }); + + // end-deleteCatalog + }); +}); diff --git a/test/unit/catalog-management.v1.test.js b/test/unit/catalog-management.v1.test.js new file mode 100644 index 00000000..c87eb301 --- /dev/null +++ b/test/unit/catalog-management.v1.test.js @@ -0,0 +1,5254 @@ +/** + * (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. + */ +'use strict'; + +// need to import the whole package to mock getAuthenticatorFromEnvironment +const core = require('ibm-cloud-sdk-core'); +const { NoAuthAuthenticator, unitTestUtils } = core; + +const CatalogManagementV1 = require('../../dist/catalog-management/v1'); + +const { + getOptions, + checkUrlAndMethod, + checkMediaHeaders, + expectToBePromise, + checkUserHeader, + checkForSuccessfulExecution, +} = unitTestUtils; + +const service = { + authenticator: new NoAuthAuthenticator(), + url: 'https://cm.globalcatalog.cloud.ibm.com/api/v1-beta', +}; + +const catalogManagement = new CatalogManagementV1(service); + +// dont actually create a request +const createRequestMock = jest.spyOn(catalogManagement, 'createRequest'); +createRequestMock.mockImplementation(() => Promise.resolve()); + +// dont actually construct an authenticator +const getAuthenticatorMock = jest.spyOn(core, 'getAuthenticatorFromEnvironment'); +getAuthenticatorMock.mockImplementation(() => new NoAuthAuthenticator()); + +afterEach(() => { + createRequestMock.mockClear(); + getAuthenticatorMock.mockClear(); +}); + +describe('CatalogManagementV1', () => { + describe('the newInstance method', () => { + test('should use defaults when options not provided', () => { + const testInstance = CatalogManagementV1.newInstance(); + + expect(getAuthenticatorMock).toHaveBeenCalled(); + expect(testInstance.baseOptions.authenticator).toBeInstanceOf(NoAuthAuthenticator); + expect(testInstance.baseOptions.serviceName).toBe(CatalogManagementV1.DEFAULT_SERVICE_NAME); + expect(testInstance.baseOptions.serviceUrl).toBe(CatalogManagementV1.DEFAULT_SERVICE_URL); + expect(testInstance).toBeInstanceOf(CatalogManagementV1); + }); + + test('should set serviceName, serviceUrl, and authenticator when provided', () => { + const options = { + authenticator: new NoAuthAuthenticator(), + serviceUrl: 'custom.com', + serviceName: 'my-service', + }; + + const testInstance = CatalogManagementV1.newInstance(options); + + expect(getAuthenticatorMock).not.toHaveBeenCalled(); + expect(testInstance.baseOptions.authenticator).toBeInstanceOf(NoAuthAuthenticator); + expect(testInstance.baseOptions.serviceUrl).toBe('custom.com'); + expect(testInstance.baseOptions.serviceName).toBe('my-service'); + expect(testInstance).toBeInstanceOf(CatalogManagementV1); + }); + }); + describe('the constructor', () => { + test('use user-given service url', () => { + const options = { + authenticator: new NoAuthAuthenticator(), + serviceUrl: 'custom.com', + }; + + const testInstance = new CatalogManagementV1(options); + + expect(testInstance.baseOptions.serviceUrl).toBe('custom.com'); + }); + + test('use default service url', () => { + const options = { + authenticator: new NoAuthAuthenticator(), + }; + + const testInstance = new CatalogManagementV1(options); + + expect(testInstance.baseOptions.serviceUrl).toBe(CatalogManagementV1.DEFAULT_SERVICE_URL); + }); + }); + describe('getCatalogAccount', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getCatalogAccount + const params = {}; + + const getCatalogAccountResult = catalogManagement.getCatalogAccount(params); + + // all methods should return a Promise + expectToBePromise(getCatalogAccountResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogaccount', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getCatalogAccount(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.getCatalogAccount({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('updateCatalogAccount', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // FilterTerms + const filterTermsModel = { + filter_terms: ['testString'], + }; + + // CategoryFilter + const categoryFilterModel = { + include: true, + filter: filterTermsModel, + }; + + // IDFilter + const idFilterModel = { + include: filterTermsModel, + exclude: filterTermsModel, + }; + + // Filters + const filtersModel = { + include_all: true, + category_filters: { 'key1' : categoryFilterModel }, + id_filters: idFilterModel, + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation updateCatalogAccount + const id = 'testString'; + const accountFilters = filtersModel; + const params = { + id: id, + accountFilters: accountFilters, + }; + + const updateCatalogAccountResult = catalogManagement.updateCatalogAccount(params); + + // all methods should return a Promise + expectToBePromise(updateCatalogAccountResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogaccount', 'PUT'); + const expectedAccept = undefined; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['id']).toEqual(id); + expect(options.body['account_filters']).toEqual(accountFilters); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.updateCatalogAccount(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.updateCatalogAccount({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('getCatalogAccountFilters', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getCatalogAccountFilters + const catalog = 'testString'; + const params = { + catalog: catalog, + }; + + const getCatalogAccountFiltersResult = catalogManagement.getCatalogAccountFilters(params); + + // all methods should return a Promise + expectToBePromise(getCatalogAccountFiltersResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogaccount/filters', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['catalog']).toEqual(catalog); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getCatalogAccountFilters(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.getCatalogAccountFilters({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('listCatalogs', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation listCatalogs + const params = {}; + + const listCatalogsResult = catalogManagement.listCatalogs(params); + + // all methods should return a Promise + expectToBePromise(listCatalogsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.listCatalogs(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.listCatalogs({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('createCatalog', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // Feature + const featureModel = { + title: 'testString', + description: 'testString', + }; + + // FilterTerms + const filterTermsModel = { + filter_terms: ['testString'], + }; + + // CategoryFilter + const categoryFilterModel = { + include: true, + filter: filterTermsModel, + }; + + // IDFilter + const idFilterModel = { + include: filterTermsModel, + exclude: filterTermsModel, + }; + + // Filters + const filtersModel = { + include_all: true, + category_filters: { 'key1' : categoryFilterModel }, + id_filters: idFilterModel, + }; + + // SyndicationCluster + const syndicationClusterModel = { + region: 'testString', + id: 'testString', + name: 'testString', + resource_group_name: 'testString', + type: 'testString', + namespaces: ['testString'], + all_namespaces: true, + }; + + // SyndicationAuthorization + const syndicationAuthorizationModel = { + token: 'testString', + last_run: '2019-01-01T12:00:00', + }; + + // SyndicationHistory + const syndicationHistoryModel = { + namespaces: ['testString'], + clusters: [syndicationClusterModel], + last_run: '2019-01-01T12:00:00', + }; + + // SyndicationResource + const syndicationResourceModel = { + remove_related_components: true, + clusters: [syndicationClusterModel], + history: syndicationHistoryModel, + authorization: syndicationAuthorizationModel, + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation createCatalog + const id = 'testString'; + const rev = 'testString'; + const label = 'testString'; + const shortDescription = 'testString'; + const catalogIconUrl = 'testString'; + const tags = ['testString']; + const url = 'testString'; + const crn = 'testString'; + const offeringsUrl = 'testString'; + const features = [featureModel]; + const disabled = true; + const created = '2019-01-01T12:00:00'; + const updated = '2019-01-01T12:00:00'; + const resourceGroupId = 'testString'; + const owningAccount = 'testString'; + const catalogFilters = filtersModel; + const syndicationSettings = syndicationResourceModel; + const params = { + id: id, + rev: rev, + label: label, + shortDescription: shortDescription, + catalogIconUrl: catalogIconUrl, + tags: tags, + url: url, + crn: crn, + offeringsUrl: offeringsUrl, + features: features, + disabled: disabled, + created: created, + updated: updated, + resourceGroupId: resourceGroupId, + owningAccount: owningAccount, + catalogFilters: catalogFilters, + syndicationSettings: syndicationSettings, + }; + + const createCatalogResult = catalogManagement.createCatalog(params); + + // all methods should return a Promise + expectToBePromise(createCatalogResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['id']).toEqual(id); + expect(options.body['_rev']).toEqual(rev); + expect(options.body['label']).toEqual(label); + expect(options.body['short_description']).toEqual(shortDescription); + expect(options.body['catalog_icon_url']).toEqual(catalogIconUrl); + expect(options.body['tags']).toEqual(tags); + expect(options.body['url']).toEqual(url); + expect(options.body['crn']).toEqual(crn); + expect(options.body['offerings_url']).toEqual(offeringsUrl); + expect(options.body['features']).toEqual(features); + expect(options.body['disabled']).toEqual(disabled); + expect(options.body['created']).toEqual(created); + expect(options.body['updated']).toEqual(updated); + expect(options.body['resource_group_id']).toEqual(resourceGroupId); + expect(options.body['owning_account']).toEqual(owningAccount); + expect(options.body['catalog_filters']).toEqual(catalogFilters); + expect(options.body['syndication_settings']).toEqual(syndicationSettings); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.createCatalog(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.createCatalog({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('getCatalog', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getCatalog + const catalogIdentifier = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + }; + + const getCatalogResult = catalogManagement.getCatalog(params); + + // all methods should return a Promise + expectToBePromise(getCatalogResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getCatalog(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getCatalog({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getCatalogPromise = catalogManagement.getCatalog(); + expectToBePromise(getCatalogPromise); + + getCatalogPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('replaceCatalog', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // Feature + const featureModel = { + title: 'testString', + description: 'testString', + }; + + // FilterTerms + const filterTermsModel = { + filter_terms: ['testString'], + }; + + // CategoryFilter + const categoryFilterModel = { + include: true, + filter: filterTermsModel, + }; + + // IDFilter + const idFilterModel = { + include: filterTermsModel, + exclude: filterTermsModel, + }; + + // Filters + const filtersModel = { + include_all: true, + category_filters: { 'key1' : categoryFilterModel }, + id_filters: idFilterModel, + }; + + // SyndicationCluster + const syndicationClusterModel = { + region: 'testString', + id: 'testString', + name: 'testString', + resource_group_name: 'testString', + type: 'testString', + namespaces: ['testString'], + all_namespaces: true, + }; + + // SyndicationAuthorization + const syndicationAuthorizationModel = { + token: 'testString', + last_run: '2019-01-01T12:00:00', + }; + + // SyndicationHistory + const syndicationHistoryModel = { + namespaces: ['testString'], + clusters: [syndicationClusterModel], + last_run: '2019-01-01T12:00:00', + }; + + // SyndicationResource + const syndicationResourceModel = { + remove_related_components: true, + clusters: [syndicationClusterModel], + history: syndicationHistoryModel, + authorization: syndicationAuthorizationModel, + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation replaceCatalog + const catalogIdentifier = 'testString'; + const id = 'testString'; + const rev = 'testString'; + const label = 'testString'; + const shortDescription = 'testString'; + const catalogIconUrl = 'testString'; + const tags = ['testString']; + const url = 'testString'; + const crn = 'testString'; + const offeringsUrl = 'testString'; + const features = [featureModel]; + const disabled = true; + const created = '2019-01-01T12:00:00'; + const updated = '2019-01-01T12:00:00'; + const resourceGroupId = 'testString'; + const owningAccount = 'testString'; + const catalogFilters = filtersModel; + const syndicationSettings = syndicationResourceModel; + const params = { + catalogIdentifier: catalogIdentifier, + id: id, + rev: rev, + label: label, + shortDescription: shortDescription, + catalogIconUrl: catalogIconUrl, + tags: tags, + url: url, + crn: crn, + offeringsUrl: offeringsUrl, + features: features, + disabled: disabled, + created: created, + updated: updated, + resourceGroupId: resourceGroupId, + owningAccount: owningAccount, + catalogFilters: catalogFilters, + syndicationSettings: syndicationSettings, + }; + + const replaceCatalogResult = catalogManagement.replaceCatalog(params); + + // all methods should return a Promise + expectToBePromise(replaceCatalogResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['id']).toEqual(id); + expect(options.body['_rev']).toEqual(rev); + expect(options.body['label']).toEqual(label); + expect(options.body['short_description']).toEqual(shortDescription); + expect(options.body['catalog_icon_url']).toEqual(catalogIconUrl); + expect(options.body['tags']).toEqual(tags); + expect(options.body['url']).toEqual(url); + expect(options.body['crn']).toEqual(crn); + expect(options.body['offerings_url']).toEqual(offeringsUrl); + expect(options.body['features']).toEqual(features); + expect(options.body['disabled']).toEqual(disabled); + expect(options.body['created']).toEqual(created); + expect(options.body['updated']).toEqual(updated); + expect(options.body['resource_group_id']).toEqual(resourceGroupId); + expect(options.body['owning_account']).toEqual(owningAccount); + expect(options.body['catalog_filters']).toEqual(catalogFilters); + expect(options.body['syndication_settings']).toEqual(syndicationSettings); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.replaceCatalog(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.replaceCatalog({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const replaceCatalogPromise = catalogManagement.replaceCatalog(); + expectToBePromise(replaceCatalogPromise); + + replaceCatalogPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('deleteCatalog', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation deleteCatalog + const catalogIdentifier = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + }; + + const deleteCatalogResult = catalogManagement.deleteCatalog(params); + + // all methods should return a Promise + expectToBePromise(deleteCatalogResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.deleteCatalog(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.deleteCatalog({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const deleteCatalogPromise = catalogManagement.deleteCatalog(); + expectToBePromise(deleteCatalogPromise); + + deleteCatalogPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getEnterprise', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getEnterprise + const enterpriseId = 'testString'; + const params = { + enterpriseId: enterpriseId, + }; + + const getEnterpriseResult = catalogManagement.getEnterprise(params); + + // all methods should return a Promise + expectToBePromise(getEnterpriseResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/enterprises/{enterprise_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['enterprise_id']).toEqual(enterpriseId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const enterpriseId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + enterpriseId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getEnterprise(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getEnterprise({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getEnterprisePromise = catalogManagement.getEnterprise(); + expectToBePromise(getEnterprisePromise); + + getEnterprisePromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('replaceEnterprise', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // FilterTerms + const filterTermsModel = { + filter_terms: ['testString'], + }; + + // CategoryFilter + const categoryFilterModel = { + include: true, + filter: filterTermsModel, + }; + + // IDFilter + const idFilterModel = { + include: filterTermsModel, + exclude: filterTermsModel, + }; + + // Filters + const filtersModel = { + include_all: true, + category_filters: { 'key1' : categoryFilterModel }, + id_filters: idFilterModel, + }; + + // AccountGroup + const accountGroupModel = { + id: 'testString', + account_filters: filtersModel, + }; + + // EnterpriseAccountGroups + const enterpriseAccountGroupsModel = { + keys: accountGroupModel, + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation replaceEnterprise + const enterpriseId = 'testString'; + const id = 'testString'; + const rev = 'testString'; + const accountFilters = filtersModel; + const accountGroups = enterpriseAccountGroupsModel; + const params = { + enterpriseId: enterpriseId, + id: id, + rev: rev, + accountFilters: accountFilters, + accountGroups: accountGroups, + }; + + const replaceEnterpriseResult = catalogManagement.replaceEnterprise(params); + + // all methods should return a Promise + expectToBePromise(replaceEnterpriseResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/enterprises/{enterprise_id}', 'PUT'); + const expectedAccept = undefined; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['id']).toEqual(id); + expect(options.body['_rev']).toEqual(rev); + expect(options.body['account_filters']).toEqual(accountFilters); + expect(options.body['account_groups']).toEqual(accountGroups); + expect(options.path['enterprise_id']).toEqual(enterpriseId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const enterpriseId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + enterpriseId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.replaceEnterprise(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.replaceEnterprise({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const replaceEnterprisePromise = catalogManagement.replaceEnterprise(); + expectToBePromise(replaceEnterprisePromise); + + replaceEnterprisePromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getConsumptionOfferings', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getConsumptionOfferings + const digest = true; + const catalog = 'testString'; + const select = 'all'; + const includeHidden = true; + const params = { + digest: digest, + catalog: catalog, + select: select, + includeHidden: includeHidden, + }; + + const getConsumptionOfferingsResult = catalogManagement.getConsumptionOfferings(params); + + // all methods should return a Promise + expectToBePromise(getConsumptionOfferingsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/offerings', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['digest']).toEqual(digest); + expect(options.qs['catalog']).toEqual(catalog); + expect(options.qs['select']).toEqual(select); + expect(options.qs['includeHidden']).toEqual(includeHidden); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getConsumptionOfferings(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.getConsumptionOfferings({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('listOfferings', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation listOfferings + const catalogIdentifier = 'testString'; + const digest = true; + const params = { + catalogIdentifier: catalogIdentifier, + digest: digest, + }; + + const listOfferingsResult = catalogManagement.listOfferings(params); + + // all methods should return a Promise + expectToBePromise(listOfferingsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['digest']).toEqual(digest); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.listOfferings(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.listOfferings({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const listOfferingsPromise = catalogManagement.listOfferings(); + expectToBePromise(listOfferingsPromise); + + listOfferingsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('createOffering', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // Rating + const ratingModel = { + one_star_count: 38, + two_star_count: 38, + three_star_count: 38, + four_star_count: 38, + }; + + // Feature + const featureModel = { + title: 'testString', + description: 'testString', + }; + + // Configuration + const configurationModel = { + key: 'testString', + type: 'testString', + default_value: 'any', + value_constraint: 'testString', + description: 'testString', + required: true, + options: [{ foo: 'bar' }], + hidden: true, + }; + + // Deployment + const deploymentModel = { + id: 'testString', + label: 'testString', + name: 'testString', + short_description: 'testString', + long_description: 'testString', + metadata: { foo: 'bar' }, + tags: ['testString'], + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + }; + + // License + const licenseModel = { + id: 'testString', + name: 'testString', + type: 'testString', + url: 'testString', + description: 'testString', + }; + + // Resource + const resourceModel = { + type: 'mem', + value: 'any', + }; + + // Script + const scriptModel = { + instructions: 'testString', + script: 'testString', + script_permission: 'testString', + delete_script: 'testString', + scope: 'testString', + }; + + // State + const stateModel = { + current: 'testString', + current_entered: '2019-01-01T12:00:00', + pending: 'testString', + pending_requested: '2019-01-01T12:00:00', + previous: 'testString', + }; + + // Validation + const validationModel = { + validated: '2019-01-01T12:00:00', + requested: '2019-01-01T12:00:00', + state: 'testString', + last_operation: 'testString', + target: { foo: 'bar' }, + }; + + // VersionEntitlement + const versionEntitlementModel = { + provider_name: 'testString', + provider_id: 'testString', + product_id: 'testString', + part_numbers: ['testString'], + image_repo_name: 'testString', + }; + + // Plan + const planModel = { + id: 'testString', + label: 'testString', + name: 'testString', + short_description: 'testString', + long_description: 'testString', + metadata: { foo: 'bar' }, + tags: ['testString'], + additional_features: [featureModel], + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + deployments: [deploymentModel], + }; + + // Version + const versionModel = { + id: 'testString', + _rev: 'testString', + crn: 'testString', + version: 'testString', + sha: 'testString', + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + offering_id: 'testString', + catalog_id: 'testString', + kind_id: 'testString', + tags: ['testString'], + repo_url: 'testString', + source_url: 'testString', + tgz_url: 'testString', + configuration: [configurationModel], + metadata: { foo: 'bar' }, + validation: validationModel, + required_resources: [resourceModel], + single_instance: true, + install: scriptModel, + pre_install: [scriptModel], + entitlement: versionEntitlementModel, + licenses: [licenseModel], + image_manifest_url: 'testString', + deprecated: true, + package_version: 'testString', + state: stateModel, + version_locator: 'testString', + console_url: 'testString', + long_description: 'testString', + whitelisted_accounts: ['testString'], + }; + + // Kind + const kindModel = { + id: 'testString', + format_kind: 'testString', + target_kind: 'testString', + metadata: { foo: 'bar' }, + install_description: 'testString', + tags: ['testString'], + additional_features: [featureModel], + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + versions: [versionModel], + plans: [planModel], + }; + + // RepoInfo + const repoInfoModel = { + token: 'testString', + type: 'testString', + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation createOffering + const catalogIdentifier = 'testString'; + const id = 'testString'; + const rev = 'testString'; + const url = 'testString'; + const crn = 'testString'; + const label = 'testString'; + const name = 'testString'; + const offeringIconUrl = 'testString'; + const offeringDocsUrl = 'testString'; + const offeringSupportUrl = 'testString'; + const tags = ['testString']; + const rating = ratingModel; + const created = '2019-01-01T12:00:00'; + const updated = '2019-01-01T12:00:00'; + const shortDescription = 'testString'; + const longDescription = 'testString'; + const features = [featureModel]; + const kinds = [kindModel]; + const permitRequestIbmPublicPublish = true; + const ibmPublishApproved = true; + const publicPublishApproved = true; + const publicOriginalCrn = 'testString'; + const publishPublicCrn = 'testString'; + const portalApprovalRecord = 'testString'; + const portalUiUrl = 'testString'; + const catalogId = 'testString'; + const catalogName = 'testString'; + const metadata = { foo: 'bar' }; + const disclaimer = 'testString'; + const hidden = true; + const provider = 'testString'; + const repoInfo = repoInfoModel; + const params = { + catalogIdentifier: catalogIdentifier, + id: id, + rev: rev, + url: url, + crn: crn, + label: label, + name: name, + offeringIconUrl: offeringIconUrl, + offeringDocsUrl: offeringDocsUrl, + offeringSupportUrl: offeringSupportUrl, + tags: tags, + rating: rating, + created: created, + updated: updated, + shortDescription: shortDescription, + longDescription: longDescription, + features: features, + kinds: kinds, + permitRequestIbmPublicPublish: permitRequestIbmPublicPublish, + ibmPublishApproved: ibmPublishApproved, + publicPublishApproved: publicPublishApproved, + publicOriginalCrn: publicOriginalCrn, + publishPublicCrn: publishPublicCrn, + portalApprovalRecord: portalApprovalRecord, + portalUiUrl: portalUiUrl, + catalogId: catalogId, + catalogName: catalogName, + metadata: metadata, + disclaimer: disclaimer, + hidden: hidden, + provider: provider, + repoInfo: repoInfo, + }; + + const createOfferingResult = catalogManagement.createOffering(params); + + // all methods should return a Promise + expectToBePromise(createOfferingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['id']).toEqual(id); + expect(options.body['_rev']).toEqual(rev); + expect(options.body['url']).toEqual(url); + expect(options.body['crn']).toEqual(crn); + expect(options.body['label']).toEqual(label); + expect(options.body['name']).toEqual(name); + expect(options.body['offering_icon_url']).toEqual(offeringIconUrl); + expect(options.body['offering_docs_url']).toEqual(offeringDocsUrl); + expect(options.body['offering_support_url']).toEqual(offeringSupportUrl); + expect(options.body['tags']).toEqual(tags); + expect(options.body['rating']).toEqual(rating); + expect(options.body['created']).toEqual(created); + expect(options.body['updated']).toEqual(updated); + expect(options.body['short_description']).toEqual(shortDescription); + expect(options.body['long_description']).toEqual(longDescription); + expect(options.body['features']).toEqual(features); + expect(options.body['kinds']).toEqual(kinds); + expect(options.body['permit_request_ibm_public_publish']).toEqual(permitRequestIbmPublicPublish); + expect(options.body['ibm_publish_approved']).toEqual(ibmPublishApproved); + expect(options.body['public_publish_approved']).toEqual(publicPublishApproved); + expect(options.body['public_original_crn']).toEqual(publicOriginalCrn); + expect(options.body['publish_public_crn']).toEqual(publishPublicCrn); + expect(options.body['portal_approval_record']).toEqual(portalApprovalRecord); + expect(options.body['portal_ui_url']).toEqual(portalUiUrl); + expect(options.body['catalog_id']).toEqual(catalogId); + expect(options.body['catalog_name']).toEqual(catalogName); + expect(options.body['metadata']).toEqual(metadata); + expect(options.body['disclaimer']).toEqual(disclaimer); + expect(options.body['hidden']).toEqual(hidden); + expect(options.body['provider']).toEqual(provider); + expect(options.body['repo_info']).toEqual(repoInfo); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.createOffering(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.createOffering({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const createOfferingPromise = catalogManagement.createOffering(); + expectToBePromise(createOfferingPromise); + + createOfferingPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('importOfferingVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation importOfferingVersion + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const zipurl = 'testString'; + const tags = ['testString']; + const targetKinds = ['testString']; + const targetVersion = 'testString'; + const includeConfig = true; + const repoType = 'testString'; + const xAuthToken = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + zipurl: zipurl, + tags: tags, + targetKinds: targetKinds, + targetVersion: targetVersion, + includeConfig: includeConfig, + repoType: repoType, + xAuthToken: xAuthToken, + }; + + const importOfferingVersionResult = catalogManagement.importOfferingVersion(params); + + // all methods should return a Promise + expectToBePromise(importOfferingVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}/version', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Token', xAuthToken); + expect(options.body['tags']).toEqual(tags); + expect(options.body['target_kinds']).toEqual(targetKinds); + expect(options.qs['zipurl']).toEqual(zipurl); + expect(options.qs['targetVersion']).toEqual(targetVersion); + expect(options.qs['includeConfig']).toEqual(includeConfig); + expect(options.qs['repoType']).toEqual(repoType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const zipurl = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + zipurl, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.importOfferingVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.importOfferingVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const importOfferingVersionPromise = catalogManagement.importOfferingVersion(); + expectToBePromise(importOfferingVersionPromise); + + importOfferingVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('importOffering', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation importOffering + const catalogIdentifier = 'testString'; + const zipurl = 'testString'; + const tags = ['testString']; + const targetKinds = ['testString']; + const offeringId = 'testString'; + const includeConfig = true; + const repoType = 'testString'; + const xAuthToken = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + zipurl: zipurl, + tags: tags, + targetKinds: targetKinds, + offeringId: offeringId, + includeConfig: includeConfig, + repoType: repoType, + xAuthToken: xAuthToken, + }; + + const importOfferingResult = catalogManagement.importOffering(params); + + // all methods should return a Promise + expectToBePromise(importOfferingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/import/offerings', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Token', xAuthToken); + expect(options.body['tags']).toEqual(tags); + expect(options.body['target_kinds']).toEqual(targetKinds); + expect(options.qs['zipurl']).toEqual(zipurl); + expect(options.qs['offeringID']).toEqual(offeringId); + expect(options.qs['includeConfig']).toEqual(includeConfig); + expect(options.qs['repoType']).toEqual(repoType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const zipurl = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + zipurl, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.importOffering(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.importOffering({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const importOfferingPromise = catalogManagement.importOffering(); + expectToBePromise(importOfferingPromise); + + importOfferingPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('reloadOffering', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation reloadOffering + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const zipurl = 'testString'; + const targetVersion = 'testString'; + const tags = ['testString']; + const targetKinds = ['testString']; + const repoType = 'testString'; + const xAuthToken = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + zipurl: zipurl, + targetVersion: targetVersion, + tags: tags, + targetKinds: targetKinds, + repoType: repoType, + xAuthToken: xAuthToken, + }; + + const reloadOfferingResult = catalogManagement.reloadOffering(params); + + // all methods should return a Promise + expectToBePromise(reloadOfferingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}/reload', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Token', xAuthToken); + expect(options.body['tags']).toEqual(tags); + expect(options.body['target_kinds']).toEqual(targetKinds); + expect(options.qs['zipurl']).toEqual(zipurl); + expect(options.qs['targetVersion']).toEqual(targetVersion); + expect(options.qs['repoType']).toEqual(repoType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const zipurl = 'testString'; + const targetVersion = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + zipurl, + targetVersion, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.reloadOffering(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.reloadOffering({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const reloadOfferingPromise = catalogManagement.reloadOffering(); + expectToBePromise(reloadOfferingPromise); + + reloadOfferingPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getOffering', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getOffering + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + }; + + const getOfferingResult = catalogManagement.getOffering(params); + + // all methods should return a Promise + expectToBePromise(getOfferingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getOffering(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getOffering({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getOfferingPromise = catalogManagement.getOffering(); + expectToBePromise(getOfferingPromise); + + getOfferingPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('replaceOffering', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // Rating + const ratingModel = { + one_star_count: 38, + two_star_count: 38, + three_star_count: 38, + four_star_count: 38, + }; + + // Feature + const featureModel = { + title: 'testString', + description: 'testString', + }; + + // Configuration + const configurationModel = { + key: 'testString', + type: 'testString', + default_value: 'any', + value_constraint: 'testString', + description: 'testString', + required: true, + options: [{ foo: 'bar' }], + hidden: true, + }; + + // Deployment + const deploymentModel = { + id: 'testString', + label: 'testString', + name: 'testString', + short_description: 'testString', + long_description: 'testString', + metadata: { foo: 'bar' }, + tags: ['testString'], + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + }; + + // License + const licenseModel = { + id: 'testString', + name: 'testString', + type: 'testString', + url: 'testString', + description: 'testString', + }; + + // Resource + const resourceModel = { + type: 'mem', + value: 'any', + }; + + // Script + const scriptModel = { + instructions: 'testString', + script: 'testString', + script_permission: 'testString', + delete_script: 'testString', + scope: 'testString', + }; + + // State + const stateModel = { + current: 'testString', + current_entered: '2019-01-01T12:00:00', + pending: 'testString', + pending_requested: '2019-01-01T12:00:00', + previous: 'testString', + }; + + // Validation + const validationModel = { + validated: '2019-01-01T12:00:00', + requested: '2019-01-01T12:00:00', + state: 'testString', + last_operation: 'testString', + target: { foo: 'bar' }, + }; + + // VersionEntitlement + const versionEntitlementModel = { + provider_name: 'testString', + provider_id: 'testString', + product_id: 'testString', + part_numbers: ['testString'], + image_repo_name: 'testString', + }; + + // Plan + const planModel = { + id: 'testString', + label: 'testString', + name: 'testString', + short_description: 'testString', + long_description: 'testString', + metadata: { foo: 'bar' }, + tags: ['testString'], + additional_features: [featureModel], + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + deployments: [deploymentModel], + }; + + // Version + const versionModel = { + id: 'testString', + _rev: 'testString', + crn: 'testString', + version: 'testString', + sha: 'testString', + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + offering_id: 'testString', + catalog_id: 'testString', + kind_id: 'testString', + tags: ['testString'], + repo_url: 'testString', + source_url: 'testString', + tgz_url: 'testString', + configuration: [configurationModel], + metadata: { foo: 'bar' }, + validation: validationModel, + required_resources: [resourceModel], + single_instance: true, + install: scriptModel, + pre_install: [scriptModel], + entitlement: versionEntitlementModel, + licenses: [licenseModel], + image_manifest_url: 'testString', + deprecated: true, + package_version: 'testString', + state: stateModel, + version_locator: 'testString', + console_url: 'testString', + long_description: 'testString', + whitelisted_accounts: ['testString'], + }; + + // Kind + const kindModel = { + id: 'testString', + format_kind: 'testString', + target_kind: 'testString', + metadata: { foo: 'bar' }, + install_description: 'testString', + tags: ['testString'], + additional_features: [featureModel], + created: '2019-01-01T12:00:00', + updated: '2019-01-01T12:00:00', + versions: [versionModel], + plans: [planModel], + }; + + // RepoInfo + const repoInfoModel = { + token: 'testString', + type: 'testString', + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation replaceOffering + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const id = 'testString'; + const rev = 'testString'; + const url = 'testString'; + const crn = 'testString'; + const label = 'testString'; + const name = 'testString'; + const offeringIconUrl = 'testString'; + const offeringDocsUrl = 'testString'; + const offeringSupportUrl = 'testString'; + const tags = ['testString']; + const rating = ratingModel; + const created = '2019-01-01T12:00:00'; + const updated = '2019-01-01T12:00:00'; + const shortDescription = 'testString'; + const longDescription = 'testString'; + const features = [featureModel]; + const kinds = [kindModel]; + const permitRequestIbmPublicPublish = true; + const ibmPublishApproved = true; + const publicPublishApproved = true; + const publicOriginalCrn = 'testString'; + const publishPublicCrn = 'testString'; + const portalApprovalRecord = 'testString'; + const portalUiUrl = 'testString'; + const catalogId = 'testString'; + const catalogName = 'testString'; + const metadata = { foo: 'bar' }; + const disclaimer = 'testString'; + const hidden = true; + const provider = 'testString'; + const repoInfo = repoInfoModel; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + id: id, + rev: rev, + url: url, + crn: crn, + label: label, + name: name, + offeringIconUrl: offeringIconUrl, + offeringDocsUrl: offeringDocsUrl, + offeringSupportUrl: offeringSupportUrl, + tags: tags, + rating: rating, + created: created, + updated: updated, + shortDescription: shortDescription, + longDescription: longDescription, + features: features, + kinds: kinds, + permitRequestIbmPublicPublish: permitRequestIbmPublicPublish, + ibmPublishApproved: ibmPublishApproved, + publicPublishApproved: publicPublishApproved, + publicOriginalCrn: publicOriginalCrn, + publishPublicCrn: publishPublicCrn, + portalApprovalRecord: portalApprovalRecord, + portalUiUrl: portalUiUrl, + catalogId: catalogId, + catalogName: catalogName, + metadata: metadata, + disclaimer: disclaimer, + hidden: hidden, + provider: provider, + repoInfo: repoInfo, + }; + + const replaceOfferingResult = catalogManagement.replaceOffering(params); + + // all methods should return a Promise + expectToBePromise(replaceOfferingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['id']).toEqual(id); + expect(options.body['_rev']).toEqual(rev); + expect(options.body['url']).toEqual(url); + expect(options.body['crn']).toEqual(crn); + expect(options.body['label']).toEqual(label); + expect(options.body['name']).toEqual(name); + expect(options.body['offering_icon_url']).toEqual(offeringIconUrl); + expect(options.body['offering_docs_url']).toEqual(offeringDocsUrl); + expect(options.body['offering_support_url']).toEqual(offeringSupportUrl); + expect(options.body['tags']).toEqual(tags); + expect(options.body['rating']).toEqual(rating); + expect(options.body['created']).toEqual(created); + expect(options.body['updated']).toEqual(updated); + expect(options.body['short_description']).toEqual(shortDescription); + expect(options.body['long_description']).toEqual(longDescription); + expect(options.body['features']).toEqual(features); + expect(options.body['kinds']).toEqual(kinds); + expect(options.body['permit_request_ibm_public_publish']).toEqual(permitRequestIbmPublicPublish); + expect(options.body['ibm_publish_approved']).toEqual(ibmPublishApproved); + expect(options.body['public_publish_approved']).toEqual(publicPublishApproved); + expect(options.body['public_original_crn']).toEqual(publicOriginalCrn); + expect(options.body['publish_public_crn']).toEqual(publishPublicCrn); + expect(options.body['portal_approval_record']).toEqual(portalApprovalRecord); + expect(options.body['portal_ui_url']).toEqual(portalUiUrl); + expect(options.body['catalog_id']).toEqual(catalogId); + expect(options.body['catalog_name']).toEqual(catalogName); + expect(options.body['metadata']).toEqual(metadata); + expect(options.body['disclaimer']).toEqual(disclaimer); + expect(options.body['hidden']).toEqual(hidden); + expect(options.body['provider']).toEqual(provider); + expect(options.body['repo_info']).toEqual(repoInfo); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.replaceOffering(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.replaceOffering({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const replaceOfferingPromise = catalogManagement.replaceOffering(); + expectToBePromise(replaceOfferingPromise); + + replaceOfferingPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('deleteOffering', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation deleteOffering + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + }; + + const deleteOfferingResult = catalogManagement.deleteOffering(params); + + // all methods should return a Promise + expectToBePromise(deleteOfferingResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.deleteOffering(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.deleteOffering({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const deleteOfferingPromise = catalogManagement.deleteOffering(); + expectToBePromise(deleteOfferingPromise); + + deleteOfferingPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('replaceOfferingIcon', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation replaceOfferingIcon + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const fileName = 'testString'; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + fileName: fileName, + }; + + const replaceOfferingIconResult = catalogManagement.replaceOfferingIcon(params); + + // all methods should return a Promise + expectToBePromise(replaceOfferingIconResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}/icon/{file_name}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + expect(options.path['file_name']).toEqual(fileName); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const fileName = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + fileName, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.replaceOfferingIcon(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.replaceOfferingIcon({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const replaceOfferingIconPromise = catalogManagement.replaceOfferingIcon(); + expectToBePromise(replaceOfferingIconPromise); + + replaceOfferingIconPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('updateOfferingIbm', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation updateOfferingIbm + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const approvalType = 'ibm'; + const approved = 'true'; + const params = { + catalogIdentifier: catalogIdentifier, + offeringId: offeringId, + approvalType: approvalType, + approved: approved, + }; + + const updateOfferingIbmResult = catalogManagement.updateOfferingIbm(params); + + // all methods should return a Promise + expectToBePromise(updateOfferingIbmResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/catalogs/{catalog_identifier}/offerings/{offering_id}/publish/{approval_type}/{approved}', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['catalog_identifier']).toEqual(catalogIdentifier); + expect(options.path['offering_id']).toEqual(offeringId); + expect(options.path['approval_type']).toEqual(approvalType); + expect(options.path['approved']).toEqual(approved); + }); + + test('should prioritize user-given headers', () => { + // parameters + const catalogIdentifier = 'testString'; + const offeringId = 'testString'; + const approvalType = 'ibm'; + const approved = 'true'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + catalogIdentifier, + offeringId, + approvalType, + approved, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.updateOfferingIbm(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.updateOfferingIbm({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const updateOfferingIbmPromise = catalogManagement.updateOfferingIbm(); + expectToBePromise(updateOfferingIbmPromise); + + updateOfferingIbmPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getVersionAbout', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getVersionAbout + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const getVersionAboutResult = catalogManagement.getVersionAbout(params); + + // all methods should return a Promise + expectToBePromise(getVersionAboutResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/about', 'GET'); + const expectedAccept = 'text/markdown'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getVersionAbout(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getVersionAbout({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getVersionAboutPromise = catalogManagement.getVersionAbout(); + expectToBePromise(getVersionAboutPromise); + + getVersionAboutPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getVersionLicense', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getVersionLicense + const versionLocId = 'testString'; + const licenseId = 'testString'; + const params = { + versionLocId: versionLocId, + licenseId: licenseId, + }; + + const getVersionLicenseResult = catalogManagement.getVersionLicense(params); + + // all methods should return a Promise + expectToBePromise(getVersionLicenseResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/licenses/{license_id}', 'GET'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + expect(options.path['license_id']).toEqual(licenseId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const licenseId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + licenseId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getVersionLicense(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getVersionLicense({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getVersionLicensePromise = catalogManagement.getVersionLicense(); + expectToBePromise(getVersionLicensePromise); + + getVersionLicensePromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getVersionContainerImages', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getVersionContainerImages + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const getVersionContainerImagesResult = catalogManagement.getVersionContainerImages(params); + + // all methods should return a Promise + expectToBePromise(getVersionContainerImagesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/containerImages', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getVersionContainerImages(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getVersionContainerImages({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getVersionContainerImagesPromise = catalogManagement.getVersionContainerImages(); + expectToBePromise(getVersionContainerImagesPromise); + + getVersionContainerImagesPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('deprecateVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation deprecateVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const deprecateVersionResult = catalogManagement.deprecateVersion(params); + + // all methods should return a Promise + expectToBePromise(deprecateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/deprecate', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.deprecateVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.deprecateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const deprecateVersionPromise = catalogManagement.deprecateVersion(); + expectToBePromise(deprecateVersionPromise); + + deprecateVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('accountPublishVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation accountPublishVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const accountPublishVersionResult = catalogManagement.accountPublishVersion(params); + + // all methods should return a Promise + expectToBePromise(accountPublishVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/account-publish', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.accountPublishVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.accountPublishVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const accountPublishVersionPromise = catalogManagement.accountPublishVersion(); + expectToBePromise(accountPublishVersionPromise); + + accountPublishVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('ibmPublishVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation ibmPublishVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const ibmPublishVersionResult = catalogManagement.ibmPublishVersion(params); + + // all methods should return a Promise + expectToBePromise(ibmPublishVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/ibm-publish', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.ibmPublishVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.ibmPublishVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const ibmPublishVersionPromise = catalogManagement.ibmPublishVersion(); + expectToBePromise(ibmPublishVersionPromise); + + ibmPublishVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('publicPublishVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation publicPublishVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const publicPublishVersionResult = catalogManagement.publicPublishVersion(params); + + // all methods should return a Promise + expectToBePromise(publicPublishVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/public-publish', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.publicPublishVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.publicPublishVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const publicPublishVersionPromise = catalogManagement.publicPublishVersion(); + expectToBePromise(publicPublishVersionPromise); + + publicPublishVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('commitVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation commitVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const commitVersionResult = catalogManagement.commitVersion(params); + + // all methods should return a Promise + expectToBePromise(commitVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/commit', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.commitVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.commitVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const commitVersionPromise = catalogManagement.commitVersion(); + expectToBePromise(commitVersionPromise); + + commitVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getVersionWorkingCopy', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getVersionWorkingCopy + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const getVersionWorkingCopyResult = catalogManagement.getVersionWorkingCopy(params); + + // all methods should return a Promise + expectToBePromise(getVersionWorkingCopyResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/workingcopy', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getVersionWorkingCopy(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getVersionWorkingCopy({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getVersionWorkingCopyPromise = catalogManagement.getVersionWorkingCopy(); + expectToBePromise(getVersionWorkingCopyPromise); + + getVersionWorkingCopyPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getVersionUpdates', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getVersionUpdates + const versionLocId = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const resourceGroupId = 'testString'; + const namespace = 'testString'; + const params = { + versionLocId: versionLocId, + clusterId: clusterId, + region: region, + resourceGroupId: resourceGroupId, + namespace: namespace, + }; + + const getVersionUpdatesResult = catalogManagement.getVersionUpdates(params); + + // all methods should return a Promise + expectToBePromise(getVersionUpdatesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/updates', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['cluster_id']).toEqual(clusterId); + expect(options.qs['region']).toEqual(region); + expect(options.qs['resource_group_id']).toEqual(resourceGroupId); + expect(options.qs['namespace']).toEqual(namespace); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getVersionUpdates(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getVersionUpdates({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getVersionUpdatesPromise = catalogManagement.getVersionUpdates(); + expectToBePromise(getVersionUpdatesPromise); + + getVersionUpdatesPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const getVersionResult = catalogManagement.getVersion(params); + + // all methods should return a Promise + expectToBePromise(getVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getVersionPromise = catalogManagement.getVersion(); + expectToBePromise(getVersionPromise); + + getVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('deleteVersion', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation deleteVersion + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const deleteVersionResult = catalogManagement.deleteVersion(params); + + // all methods should return a Promise + expectToBePromise(deleteVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.deleteVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.deleteVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const deleteVersionPromise = catalogManagement.deleteVersion(); + expectToBePromise(deleteVersionPromise); + + deleteVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('listVersions', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation listVersions + const q = 'testString'; + const params = { + q: q, + }; + + const listVersionsResult = catalogManagement.listVersions(params); + + // all methods should return a Promise + expectToBePromise(listVersionsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions', 'GET'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['q']).toEqual(q); + }); + + test('should prioritize user-given headers', () => { + // parameters + const q = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + q, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.listVersions(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.listVersions({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const listVersionsPromise = catalogManagement.listVersions(); + expectToBePromise(listVersionsPromise); + + listVersionsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getRepos', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getRepos + const type = 'testString'; + const repourl = 'testString'; + const params = { + type: type, + repourl: repourl, + }; + + const getReposResult = catalogManagement.getRepos(params); + + // all methods should return a Promise + expectToBePromise(getReposResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/repo/{type}/entries', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['repourl']).toEqual(repourl); + expect(options.path['type']).toEqual(type); + }); + + test('should prioritize user-given headers', () => { + // parameters + const type = 'testString'; + const repourl = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + type, + repourl, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getRepos(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getRepos({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getReposPromise = catalogManagement.getRepos(); + expectToBePromise(getReposPromise); + + getReposPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getRepo', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getRepo + const type = 'testString'; + const charturl = 'testString'; + const params = { + type: type, + charturl: charturl, + }; + + const getRepoResult = catalogManagement.getRepo(params); + + // all methods should return a Promise + expectToBePromise(getRepoResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/repo/{type}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['charturl']).toEqual(charturl); + expect(options.path['type']).toEqual(type); + }); + + test('should prioritize user-given headers', () => { + // parameters + const type = 'testString'; + const charturl = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + type, + charturl, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getRepo(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getRepo({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getRepoPromise = catalogManagement.getRepo(); + expectToBePromise(getRepoPromise); + + getRepoPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('listClusters', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation listClusters + const limit = 38; + const offset = 38; + const type = 'testString'; + const params = { + limit: limit, + offset: offset, + type: type, + }; + + const listClustersResult = catalogManagement.listClusters(params); + + // all methods should return a Promise + expectToBePromise(listClustersResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/clusters', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['limit']).toEqual(limit); + expect(options.qs['offset']).toEqual(offset); + expect(options.qs['type']).toEqual(type); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.listClusters(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.listClusters({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('getCluster', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getCluster + const clusterId = 'testString'; + const region = 'testString'; + const xAuthRefreshToken = 'testString'; + const params = { + clusterId: clusterId, + region: region, + xAuthRefreshToken: xAuthRefreshToken, + }; + + const getClusterResult = catalogManagement.getCluster(params); + + // all methods should return a Promise + expectToBePromise(getClusterResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/clusters/{cluster_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.qs['region']).toEqual(region); + expect(options.path['cluster_id']).toEqual(clusterId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const clusterId = 'testString'; + const region = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + clusterId, + region, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getCluster(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getCluster({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getClusterPromise = catalogManagement.getCluster(); + expectToBePromise(getClusterPromise); + + getClusterPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getNamespaces', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getNamespaces + const clusterId = 'testString'; + const region = 'testString'; + const xAuthRefreshToken = 'testString'; + const limit = 38; + const offset = 38; + const params = { + clusterId: clusterId, + region: region, + xAuthRefreshToken: xAuthRefreshToken, + limit: limit, + offset: offset, + }; + + const getNamespacesResult = catalogManagement.getNamespaces(params); + + // all methods should return a Promise + expectToBePromise(getNamespacesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/clusters/{cluster_id}/namespaces', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.qs['region']).toEqual(region); + expect(options.qs['limit']).toEqual(limit); + expect(options.qs['offset']).toEqual(offset); + expect(options.path['cluster_id']).toEqual(clusterId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const clusterId = 'testString'; + const region = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + clusterId, + region, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getNamespaces(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getNamespaces({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getNamespacesPromise = catalogManagement.getNamespaces(); + expectToBePromise(getNamespacesPromise); + + getNamespacesPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('createOperator', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation createOperator + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespaces = ['testString']; + const versionLocatorId = 'testString'; + const params = { + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + namespaces: namespaces, + versionLocatorId: versionLocatorId, + }; + + const createOperatorResult = catalogManagement.createOperator(params); + + // all methods should return a Promise + expectToBePromise(createOperatorResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/olm/operator', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.body['cluster_id']).toEqual(clusterId); + expect(options.body['region']).toEqual(region); + expect(options.body['namespaces']).toEqual(namespaces); + expect(options.body['version_locator_id']).toEqual(versionLocatorId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.createOperator(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.createOperator({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const createOperatorPromise = catalogManagement.createOperator(); + expectToBePromise(createOperatorPromise); + + createOperatorPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('listOperators', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation listOperators + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const versionLocatorId = 'testString'; + const params = { + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + versionLocatorId: versionLocatorId, + }; + + const listOperatorsResult = catalogManagement.listOperators(params); + + // all methods should return a Promise + expectToBePromise(listOperatorsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/olm/operator', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.qs['cluster_id']).toEqual(clusterId); + expect(options.qs['region']).toEqual(region); + expect(options.qs['version_locator_id']).toEqual(versionLocatorId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const versionLocatorId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + xAuthRefreshToken, + clusterId, + region, + versionLocatorId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.listOperators(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.listOperators({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const listOperatorsPromise = catalogManagement.listOperators(); + expectToBePromise(listOperatorsPromise); + + listOperatorsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('replaceOperator', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation replaceOperator + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespaces = ['testString']; + const versionLocatorId = 'testString'; + const params = { + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + namespaces: namespaces, + versionLocatorId: versionLocatorId, + }; + + const replaceOperatorResult = catalogManagement.replaceOperator(params); + + // all methods should return a Promise + expectToBePromise(replaceOperatorResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/olm/operator', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.body['cluster_id']).toEqual(clusterId); + expect(options.body['region']).toEqual(region); + expect(options.body['namespaces']).toEqual(namespaces); + expect(options.body['version_locator_id']).toEqual(versionLocatorId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.replaceOperator(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.replaceOperator({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const replaceOperatorPromise = catalogManagement.replaceOperator(); + expectToBePromise(replaceOperatorPromise); + + replaceOperatorPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('deleteOperator', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation deleteOperator + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const versionLocatorId = 'testString'; + const params = { + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + versionLocatorId: versionLocatorId, + }; + + const deleteOperatorResult = catalogManagement.deleteOperator(params); + + // all methods should return a Promise + expectToBePromise(deleteOperatorResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/kubernetes/olm/operator', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.qs['cluster_id']).toEqual(clusterId); + expect(options.qs['region']).toEqual(region); + expect(options.qs['version_locator_id']).toEqual(versionLocatorId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const versionLocatorId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + xAuthRefreshToken, + clusterId, + region, + versionLocatorId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.deleteOperator(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.deleteOperator({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const deleteOperatorPromise = catalogManagement.deleteOperator(); + expectToBePromise(deleteOperatorPromise); + + deleteOperatorPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('installVersion', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // DeployRequestBodySchematics + const deployRequestBodySchematicsModel = { + name: 'testString', + description: 'testString', + tags: ['testString'], + resource_group_id: 'testString', + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation installVersion + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespace = 'testString'; + const overrideValues = { foo: 'bar' }; + const entitlementApikey = 'testString'; + const schematics = deployRequestBodySchematicsModel; + const script = 'testString'; + const scriptId = 'testString'; + const versionLocatorId = 'testString'; + const vcenterId = 'testString'; + const vcenterPassword = 'testString'; + const vcenterLocation = 'testString'; + const params = { + versionLocId: versionLocId, + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + namespace: namespace, + overrideValues: overrideValues, + entitlementApikey: entitlementApikey, + schematics: schematics, + script: script, + scriptId: scriptId, + versionLocatorId: versionLocatorId, + vcenterId: vcenterId, + vcenterPassword: vcenterPassword, + vcenterLocation: vcenterLocation, + }; + + const installVersionResult = catalogManagement.installVersion(params); + + // all methods should return a Promise + expectToBePromise(installVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/install', 'POST'); + const expectedAccept = undefined; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.body['cluster_id']).toEqual(clusterId); + expect(options.body['region']).toEqual(region); + expect(options.body['namespace']).toEqual(namespace); + expect(options.body['override_values']).toEqual(overrideValues); + expect(options.body['entitlement_apikey']).toEqual(entitlementApikey); + expect(options.body['schematics']).toEqual(schematics); + expect(options.body['script']).toEqual(script); + expect(options.body['script_id']).toEqual(scriptId); + expect(options.body['version_locator_id']).toEqual(versionLocatorId); + expect(options.body['vcenter_id']).toEqual(vcenterId); + expect(options.body['vcenter_password']).toEqual(vcenterPassword); + expect(options.body['vcenter_location']).toEqual(vcenterLocation); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.installVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.installVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const installVersionPromise = catalogManagement.installVersion(); + expectToBePromise(installVersionPromise); + + installVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('preinstallVersion', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // DeployRequestBodySchematics + const deployRequestBodySchematicsModel = { + name: 'testString', + description: 'testString', + tags: ['testString'], + resource_group_id: 'testString', + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation preinstallVersion + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespace = 'testString'; + const overrideValues = { foo: 'bar' }; + const entitlementApikey = 'testString'; + const schematics = deployRequestBodySchematicsModel; + const script = 'testString'; + const scriptId = 'testString'; + const versionLocatorId = 'testString'; + const vcenterId = 'testString'; + const vcenterPassword = 'testString'; + const vcenterLocation = 'testString'; + const params = { + versionLocId: versionLocId, + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + namespace: namespace, + overrideValues: overrideValues, + entitlementApikey: entitlementApikey, + schematics: schematics, + script: script, + scriptId: scriptId, + versionLocatorId: versionLocatorId, + vcenterId: vcenterId, + vcenterPassword: vcenterPassword, + vcenterLocation: vcenterLocation, + }; + + const preinstallVersionResult = catalogManagement.preinstallVersion(params); + + // all methods should return a Promise + expectToBePromise(preinstallVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/preinstall', 'POST'); + const expectedAccept = undefined; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.body['cluster_id']).toEqual(clusterId); + expect(options.body['region']).toEqual(region); + expect(options.body['namespace']).toEqual(namespace); + expect(options.body['override_values']).toEqual(overrideValues); + expect(options.body['entitlement_apikey']).toEqual(entitlementApikey); + expect(options.body['schematics']).toEqual(schematics); + expect(options.body['script']).toEqual(script); + expect(options.body['script_id']).toEqual(scriptId); + expect(options.body['version_locator_id']).toEqual(versionLocatorId); + expect(options.body['vcenter_id']).toEqual(vcenterId); + expect(options.body['vcenter_password']).toEqual(vcenterPassword); + expect(options.body['vcenter_location']).toEqual(vcenterLocation); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.preinstallVersion(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.preinstallVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const preinstallVersionPromise = catalogManagement.preinstallVersion(); + expectToBePromise(preinstallVersionPromise); + + preinstallVersionPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getPreinstall', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getPreinstall + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespace = 'testString'; + const params = { + versionLocId: versionLocId, + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + namespace: namespace, + }; + + const getPreinstallResult = catalogManagement.getPreinstall(params); + + // all methods should return a Promise + expectToBePromise(getPreinstallResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/preinstall', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.qs['cluster_id']).toEqual(clusterId); + expect(options.qs['region']).toEqual(region); + expect(options.qs['namespace']).toEqual(namespace); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getPreinstall(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getPreinstall({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getPreinstallPromise = catalogManagement.getPreinstall(); + expectToBePromise(getPreinstallPromise); + + getPreinstallPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('validationInstall', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // DeployRequestBodySchematics + const deployRequestBodySchematicsModel = { + name: 'testString', + description: 'testString', + tags: ['testString'], + resource_group_id: 'testString', + }; + + test('should pass the right params to createRequest', () => { + // Construct the params object for operation validationInstall + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespace = 'testString'; + const overrideValues = { foo: 'bar' }; + const entitlementApikey = 'testString'; + const schematics = deployRequestBodySchematicsModel; + const script = 'testString'; + const scriptId = 'testString'; + const versionLocatorId = 'testString'; + const vcenterId = 'testString'; + const vcenterPassword = 'testString'; + const vcenterLocation = 'testString'; + const params = { + versionLocId: versionLocId, + xAuthRefreshToken: xAuthRefreshToken, + clusterId: clusterId, + region: region, + namespace: namespace, + overrideValues: overrideValues, + entitlementApikey: entitlementApikey, + schematics: schematics, + script: script, + scriptId: scriptId, + versionLocatorId: versionLocatorId, + vcenterId: vcenterId, + vcenterPassword: vcenterPassword, + vcenterLocation: vcenterLocation, + }; + + const validationInstallResult = catalogManagement.validationInstall(params); + + // all methods should return a Promise + expectToBePromise(validationInstallResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/validation/install', 'POST'); + const expectedAccept = undefined; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.body['cluster_id']).toEqual(clusterId); + expect(options.body['region']).toEqual(region); + expect(options.body['namespace']).toEqual(namespace); + expect(options.body['override_values']).toEqual(overrideValues); + expect(options.body['entitlement_apikey']).toEqual(entitlementApikey); + expect(options.body['schematics']).toEqual(schematics); + expect(options.body['script']).toEqual(script); + expect(options.body['script_id']).toEqual(scriptId); + expect(options.body['version_locator_id']).toEqual(versionLocatorId); + expect(options.body['vcenter_id']).toEqual(vcenterId); + expect(options.body['vcenter_password']).toEqual(vcenterPassword); + expect(options.body['vcenter_location']).toEqual(vcenterLocation); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.validationInstall(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.validationInstall({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const validationInstallPromise = catalogManagement.validationInstall(); + expectToBePromise(validationInstallPromise); + + validationInstallPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getValidationStatus', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getValidationStatus + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const params = { + versionLocId: versionLocId, + xAuthRefreshToken: xAuthRefreshToken, + }; + + const getValidationStatusResult = catalogManagement.getValidationStatus(params); + + // all methods should return a Promise + expectToBePromise(getValidationStatusResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/validation/install', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getValidationStatus(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getValidationStatus({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getValidationStatusPromise = catalogManagement.getValidationStatus(); + expectToBePromise(getValidationStatusPromise); + + getValidationStatusPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getOverrideValues', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getOverrideValues + const versionLocId = 'testString'; + const params = { + versionLocId: versionLocId, + }; + + const getOverrideValuesResult = catalogManagement.getOverrideValues(params); + + // all methods should return a Promise + expectToBePromise(getOverrideValuesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/validation/overridevalues', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getOverrideValues(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getOverrideValues({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getOverrideValuesPromise = catalogManagement.getOverrideValues(); + expectToBePromise(getOverrideValuesPromise); + + getOverrideValuesPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getSchematicsWorkspaces', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getSchematicsWorkspaces + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const params = { + versionLocId: versionLocId, + xAuthRefreshToken: xAuthRefreshToken, + }; + + const getSchematicsWorkspacesResult = catalogManagement.getSchematicsWorkspaces(params); + + // all methods should return a Promise + expectToBePromise(getSchematicsWorkspacesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/workspaces', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'X-Auth-Refresh-Token', xAuthRefreshToken); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const xAuthRefreshToken = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + xAuthRefreshToken, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getSchematicsWorkspaces(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getSchematicsWorkspaces({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getSchematicsWorkspacesPromise = catalogManagement.getSchematicsWorkspaces(); + expectToBePromise(getSchematicsWorkspacesPromise); + + getSchematicsWorkspacesPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('canDeploySchematics', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation canDeploySchematics + const versionLocId = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const namespace = 'testString'; + const resourceGroupId = 'testString'; + const params = { + versionLocId: versionLocId, + clusterId: clusterId, + region: region, + namespace: namespace, + resourceGroupId: resourceGroupId, + }; + + const canDeploySchematicsResult = catalogManagement.canDeploySchematics(params); + + // all methods should return a Promise + expectToBePromise(canDeploySchematicsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/versions/{version_loc_id}/candeploy', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['cluster_id']).toEqual(clusterId); + expect(options.qs['region']).toEqual(region); + expect(options.qs['namespace']).toEqual(namespace); + expect(options.qs['resource_group_id']).toEqual(resourceGroupId); + expect(options.path['version_loc_id']).toEqual(versionLocId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const versionLocId = 'testString'; + const clusterId = 'testString'; + const region = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + versionLocId, + clusterId, + region, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.canDeploySchematics(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.canDeploySchematics({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const canDeploySchematicsPromise = catalogManagement.canDeploySchematics(); + expectToBePromise(canDeploySchematicsPromise); + + canDeploySchematicsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getResourceGroups', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getResourceGroups + const params = {}; + + const getResourceGroupsResult = catalogManagement.getResourceGroups(params); + + // all methods should return a Promise + expectToBePromise(getResourceGroupsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/deploy/schematics/resourcegroups', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getResourceGroups(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.getResourceGroups({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('getLicenseProviders', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getLicenseProviders + const params = {}; + + const getLicenseProvidersResult = catalogManagement.getLicenseProviders(params); + + // all methods should return a Promise + expectToBePromise(getLicenseProvidersResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/license/license_providers', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getLicenseProviders(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.getLicenseProviders({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('listLicenseEntitlements', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation listLicenseEntitlements + const accountId = 'testString'; + const licenseProductId = 'testString'; + const versionId = 'testString'; + const state = 'testString'; + const params = { + accountId: accountId, + licenseProductId: licenseProductId, + versionId: versionId, + state: state, + }; + + const listLicenseEntitlementsResult = catalogManagement.listLicenseEntitlements(params); + + // all methods should return a Promise + expectToBePromise(listLicenseEntitlementsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/license/entitlements', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['account_id']).toEqual(accountId); + expect(options.qs['license_product_id']).toEqual(licenseProductId); + expect(options.qs['version_id']).toEqual(versionId); + expect(options.qs['state']).toEqual(state); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.listLicenseEntitlements(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.listLicenseEntitlements({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('createLicenseEntitlement', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation createLicenseEntitlement + const name = 'testString'; + const effectiveFrom = 'testString'; + const effectiveUntil = 'testString'; + const versionId = 'testString'; + const licenseId = 'testString'; + const licenseOwnerId = 'testString'; + const licenseProviderId = 'testString'; + const licenseProductId = 'testString'; + const accountId = 'testString'; + const params = { + name: name, + effectiveFrom: effectiveFrom, + effectiveUntil: effectiveUntil, + versionId: versionId, + licenseId: licenseId, + licenseOwnerId: licenseOwnerId, + licenseProviderId: licenseProviderId, + licenseProductId: licenseProductId, + accountId: accountId, + }; + + const createLicenseEntitlementResult = catalogManagement.createLicenseEntitlement(params); + + // all methods should return a Promise + expectToBePromise(createLicenseEntitlementResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/license/entitlements', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.body['name']).toEqual(name); + expect(options.body['effective_from']).toEqual(effectiveFrom); + expect(options.body['effective_until']).toEqual(effectiveUntil); + expect(options.body['version_id']).toEqual(versionId); + expect(options.body['license_id']).toEqual(licenseId); + expect(options.body['license_owner_id']).toEqual(licenseOwnerId); + expect(options.body['license_provider_id']).toEqual(licenseProviderId); + expect(options.body['license_product_id']).toEqual(licenseProductId); + expect(options.qs['account_id']).toEqual(accountId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.createLicenseEntitlement(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + catalogManagement.createLicenseEntitlement({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + describe('getLicenseEntitlements', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getLicenseEntitlements + const licenseProductId = 'testString'; + const accountId = 'testString'; + const versionId = 'testString'; + const params = { + licenseProductId: licenseProductId, + accountId: accountId, + versionId: versionId, + }; + + const getLicenseEntitlementsResult = catalogManagement.getLicenseEntitlements(params); + + // all methods should return a Promise + expectToBePromise(getLicenseEntitlementsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/license/entitlements/productID/{license_product_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['account_id']).toEqual(accountId); + expect(options.qs['version_id']).toEqual(versionId); + expect(options.path['license_product_id']).toEqual(licenseProductId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const licenseProductId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + licenseProductId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getLicenseEntitlements(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getLicenseEntitlements({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getLicenseEntitlementsPromise = catalogManagement.getLicenseEntitlements(); + expectToBePromise(getLicenseEntitlementsPromise); + + getLicenseEntitlementsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('deleteLicenseEntitlement', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation deleteLicenseEntitlement + const entitlementId = 'testString'; + const accountId = 'testString'; + const params = { + entitlementId: entitlementId, + accountId: accountId, + }; + + const deleteLicenseEntitlementResult = catalogManagement.deleteLicenseEntitlement(params); + + // all methods should return a Promise + expectToBePromise(deleteLicenseEntitlementResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/license/entitlements/{entitlement_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['account_id']).toEqual(accountId); + expect(options.path['entitlement_id']).toEqual(entitlementId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const entitlementId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + entitlementId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.deleteLicenseEntitlement(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.deleteLicenseEntitlement({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const deleteLicenseEntitlementPromise = catalogManagement.deleteLicenseEntitlement(); + expectToBePromise(deleteLicenseEntitlementPromise); + + deleteLicenseEntitlementPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('getLicenses', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation getLicenses + const licenseProviderId = 'testString'; + const accountId = 'testString'; + const name = 'testString'; + const licenseType = 'testString'; + const licenseProductId = 'testString'; + const params = { + licenseProviderId: licenseProviderId, + accountId: accountId, + name: name, + licenseType: licenseType, + licenseProductId: licenseProductId, + }; + + const getLicensesResult = catalogManagement.getLicenses(params); + + // all methods should return a Promise + expectToBePromise(getLicensesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/license/licenses', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['license_provider_id']).toEqual(licenseProviderId); + expect(options.qs['account_id']).toEqual(accountId); + expect(options.qs['name']).toEqual(name); + expect(options.qs['license_type']).toEqual(licenseType); + expect(options.qs['license_product_id']).toEqual(licenseProductId); + }); + + test('should prioritize user-given headers', () => { + // parameters + const licenseProviderId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + licenseProviderId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.getLicenses(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.getLicenses({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const getLicensesPromise = catalogManagement.getLicenses(); + expectToBePromise(getLicensesPromise); + + getLicensesPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('searchLicenseVersions', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation searchLicenseVersions + const q = 'testString'; + const params = { + q: q, + }; + + const searchLicenseVersionsResult = catalogManagement.searchLicenseVersions(params); + + // all methods should return a Promise + expectToBePromise(searchLicenseVersionsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/search/license/versions', 'GET'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['q']).toEqual(q); + }); + + test('should prioritize user-given headers', () => { + // parameters + const q = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + q, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.searchLicenseVersions(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.searchLicenseVersions({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const searchLicenseVersionsPromise = catalogManagement.searchLicenseVersions(); + expectToBePromise(searchLicenseVersionsPromise); + + searchLicenseVersionsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); + describe('searchLicenseOfferings', () => { + describe('positive tests', () => { + test('should pass the right params to createRequest', () => { + // Construct the params object for operation searchLicenseOfferings + const q = 'testString'; + const params = { + q: q, + }; + + const searchLicenseOfferingsResult = catalogManagement.searchLicenseOfferings(params); + + // all methods should return a Promise + expectToBePromise(searchLicenseOfferingsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const options = getOptions(createRequestMock); + + checkUrlAndMethod(options, '/search/license/offerings', 'GET'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(options.qs['q']).toEqual(q); + }); + + test('should prioritize user-given headers', () => { + // parameters + const q = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const params = { + q, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + catalogManagement.searchLicenseOfferings(params); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async done => { + let err; + try { + await catalogManagement.searchLicenseOfferings({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + + test('should reject promise when required params are not given', done => { + const searchLicenseOfferingsPromise = catalogManagement.searchLicenseOfferings(); + expectToBePromise(searchLicenseOfferingsPromise); + + searchLicenseOfferingsPromise.catch(err => { + expect(err.message).toMatch(/Missing required parameters/); + done(); + }); + }); + }); + }); +}); From 3ab114c82e366f7af1900bd9ab94732efa8e1589 Mon Sep 17 00:00:00 2001 From: dubeejw Date: Wed, 17 Jun 2020 12:14:16 -0400 Subject: [PATCH 2/2] test: add Catalog Management integration tests --- .travis.yml | 1 + catalog_mgmt.env.enc | Bin 0 -> 272 bytes .../integration/catalog-management.v1.test.js | 1082 +++++++++++++++++ 3 files changed, 1083 insertions(+) create mode 100644 catalog_mgmt.env.enc create mode 100644 test/integration/catalog-management.v1.test.js diff --git a/.travis.yml b/.travis.yml index 78f77461..de5c3f99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ matrix: && openssl aes-256-cbc -K $encrypted_3058bc69cb40_key -iv $encrypted_3058bc69cb40_iv -in ghost.env.enc -out ghost.env -d && openssl aes-256-cbc -K $encrypted_66f264007c0d_key -iv $encrypted_66f264007c0d_iv -in iam_access_groups.env.enc -out iam_access_groups.env -d && openssl aes-256-cbc -K $encrypted_94fa7fdf4df9_key -iv $encrypted_94fa7fdf4df9_iv -in global_catalog.env.enc -out global_catalog.env -d + && openssl aes-256-cbc -K $encrypted_6eaa1fc94541_key -iv $encrypted_6eaa1fc94541_iv -in catalog_mgmt.env.enc -out catalog_mgmt.env -d || true # && openssl aes-256-cbc -K $encrypted_dac53b985913_key -iv $encrypted_dac53b985913_iv -in case_management.env.enc -out case_management.env -d diff --git a/catalog_mgmt.env.enc b/catalog_mgmt.env.enc new file mode 100644 index 0000000000000000000000000000000000000000..7a72fe1edfaaa0decb7030bc23bf98a49db80931 GIT binary patch literal 272 zcmV+r0q_3$K^f&}Ac-(k(M*aMQbZBAmFzl6qV#f!kdZ0il7L1YVo_P;VMaTha$NgJ zqza}<(Vsz)t!+O&pY>{)A#!x$gj?dJSA6-dB?b>-Uso|0e_0X~D?Cb72w*xcxRXtS z`;vG7CT2k*UuH&4_9Bo_b61uKsgL8D$K;U#muei+h061KVe5dbkxaXo;ynp2 z_6^I2G#|3I*)2D7;!kuNbXe(5Co$~Kln^5eI0 zG>c^ZSZk|Y{Ub|k>$u6}G%JI7Lq$h*&16&$(40q|yQeXQy~Xj=Ns@lgd!+8+2kf)U WGr4ge;P?oTZd4nf->c*3PIDR0(}c7D literal 0 HcmV?d00001 diff --git a/test/integration/catalog-management.v1.test.js b/test/integration/catalog-management.v1.test.js new file mode 100644 index 00000000..a2561470 --- /dev/null +++ b/test/integration/catalog-management.v1.test.js @@ -0,0 +1,1082 @@ +/* eslint-disable no-console */ +/** + * (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. + */ + +'use strict'; + +const CatalogManagementV1 = require('../../dist/catalog-management/v1'); +const authHelper = require('../resources/auth-helper.js'); +const util = require('util'); + +const timeout = 60000; +const configFile = 'catalog_mgmt.env'; +const describe = authHelper.prepareTests(configFile); + +describe('CatalogManagementV1_integration', () => { + jest.setTimeout(timeout); + + let service; + + const expectedAccount = '67d27f28d43948b2b3bda9138f251a13'; + const expectedLabel = 'integration-test'; + const expectedShortDesc = 'test'; + const expectedURL = 'https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s'; + const expectedOfferingsURL = 'https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s/offerings'; + const fakeName = 'bogus'; + const fakeVersionLocator = 'bogus.bogus'; + const expectedOfferingName = 'test-offering'; + const expectedOfferingURL = 'https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s/offerings/%s'; + + beforeAll(() => { + service = CatalogManagementV1.newInstance(); + }); + + beforeEach(async done => { + const response = await service.listCatalogs(); + const { result } = response || {}; + const { resources } = result || {}; + + try { + for (let i = 0; i < resources.length; i++) { + await service.deleteCatalog({ 'catalogIdentifier': resources[i].id }); + } + } catch (err) { + done(); + } + + done(); + }); + + afterEach(async done => { + const response = await service.listCatalogs(); + const { result } = response || {}; + const { resources } = result || {}; + + try { + for (let i = 0; i < resources.length; i++) { + await service.deleteCatalog({ 'catalogIdentifier': resources[i].id }); + } + } catch (err) { + done(); + } + + done(); + }); + + test('Get catalog account', async done => { + let response; + + try { + response = await service.getCatalogAccount(); + } catch (err) { + done(err); + } + + expect(response).toBeDefined(); + expect(response.status).toEqual(200); + + const { result } = response || {}; + expect(result).toBeDefined(); + expect(result.id).toEqual(expectedAccount); + expect(result.account_filters.include_all).toEqual(true); + expect(result.account_filters.category_filters).toEqual(undefined); + expect(result.account_filters.id_filters.include).toEqual(undefined); + expect(result.account_filters.id_filters.exclude).toEqual(undefined); + + done(); + }); + + test('Get catalog account filters', async done => { + let response; + + try { + response = await service.getCatalogAccountFilters(); + } catch (err) { + done(err); + } + + expect(response).toBeDefined(); + expect(response.status).toEqual(200); + + const { result } = response || {}; + expect(result).toBeDefined(); + expect(result.account_filters.length).toEqual(1); + expect(result.account_filters[0].include_all).toEqual(true); + expect(result.account_filters[0].category_filters).toEqual(undefined); + expect(result.account_filters[0].id_filters.include).toEqual(undefined); + expect(result.account_filters[0].id_filters.exclude).toEqual(undefined); + expect(result.catalog_filters).toEqual(undefined); + + done(); + }); + + test('List catalogs', async done => { + let createResponse; + let listResponse; + let createResult; + + try { + createResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + createResult = createResponse.result || {}; + listResponse = await service.listCatalogs(); + await service.deleteCatalog({ 'catalogIdentifier': createResult.id }); + } catch (err) { + done(err); + } + + expect(listResponse).toBeDefined(); + expect(listResponse.status).toEqual(200); + + const listResult = listResponse.result || {}; + expect(listResult).toBeDefined(); + expect(listResult.offset).toEqual(0); + expect(listResult.limit).toEqual(0); + expect(listResult.total_count).toEqual(1); + expect(listResult.last).toEqual(undefined); + expect(listResult.prev).toEqual(undefined); + expect(listResult.next).toEqual(undefined); + + const resources = listResult.resources; + expect(resources).toBeDefined(); + expect(resources.length).toEqual(1); + expect(resources[0].label).toEqual(expectedLabel); + expect(resources[0].short_description).toEqual(expectedShortDesc); + expect(resources[0].url).toEqual(util.format(expectedURL, createResult.id)); + expect(resources[0].offerings_url).toEqual(util.format(expectedOfferingsURL, createResult.id)); + expect(resources[0].owning_account).toEqual(expectedAccount); + expect(resources[0].catalog_filters.include_all).toEqual(false); + expect(resources[0].catalog_filters.category_filters).toEqual(undefined); + expect(resources[0].catalog_filters.id_filters.include).toEqual(undefined); + expect(resources[0].catalog_filters.id_filters.exclude).toEqual(undefined); + + done(); + }); + + test('Create catalog', async done => { + let response; + let result; + + try { + response = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + + expect(response).toBeDefined(); + expect(response.status).toEqual(201); + + result = response.result || {}; + + await service.deleteCatalog({ 'catalogIdentifier': result.id }); + } catch (err) { + done(err); + } + + expect(result).toBeDefined(); + expect(result.label).toEqual(expectedLabel); + expect(result.short_description).toEqual(expectedShortDesc); + expect(result.url).toEqual(util.format(expectedURL, result.id)); + expect(result.offerings_url).toEqual(util.format(expectedOfferingsURL, result.id)); + expect(result.owning_account).toEqual(expectedAccount); + expect(result.catalog_filters.include_all).toEqual(false); + expect(result.catalog_filters.category_filters).toEqual(undefined); + expect(result.catalog_filters.id_filters.include).toEqual(undefined); + expect(result.catalog_filters.id_filters.exclude).toEqual(undefined); + + done(); + }); + + test('Get catalog', async done => { + let createResponse; + let getResponse; + let createResult; + + try { + createResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + createResult = createResponse.result || {}; + getResponse = await service.getCatalog({ 'catalogIdentifier': createResult.id }); + await service.deleteCatalog({ 'catalogIdentifier': createResult.id }); + } catch (err) { + done(err); + } + + expect(getResponse).toBeDefined(); + expect(getResponse.status).toEqual(200); + + const getResult = getResponse.result || {}; + expect(getResult).toBeDefined(); + expect(getResult.label).toEqual(expectedLabel); + expect(getResult.short_description).toEqual(expectedShortDesc); + expect(getResult.url).toEqual(util.format(expectedURL, createResult.id)); + expect(getResult.offerings_url).toEqual(util.format(expectedOfferingsURL, createResult.id)); + expect(getResult.owning_account).toEqual(expectedAccount); + expect(getResult.catalog_filters.include_all).toEqual(false); + expect(getResult.catalog_filters.category_filters).toEqual(undefined); + expect(getResult.catalog_filters.id_filters.include).toEqual(undefined); + expect(getResult.catalog_filters.id_filters.exclude).toEqual(undefined); + + done(); + }); + + test('Get catalog failure', async done => { + expect.assertions(1); + + try { + await service.getCatalog({ 'catalogIdentifier': fakeName }); + } catch (err) { + expect(err.status).toEqual(404); + done(); + } + }); + + test('Update catalog', async done => { + const expectedLabelUpdated = 'test2'; + const expectedShortDescUpdated = 'integration-test-update'; + + let createResponse; + let updateResponse; + let createResult; + + try { + createResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + createResult = createResponse.result || {}; + updateResponse = await service.replaceCatalog({ 'catalogIdentifier': createResult.id, 'id': createResult.id, 'label': expectedLabelUpdated, 'shortDescription': expectedShortDescUpdated }); + await service.deleteCatalog({ 'catalogIdentifier': createResult.id }); + } catch (err) { + done(err); + } + + expect(updateResponse).toBeDefined(); + expect(updateResponse.status).toEqual(200); + + const updateResult = updateResponse.result || {}; + expect(updateResult).toBeDefined(); + expect(updateResult.label).toEqual(expectedLabelUpdated); + expect(updateResult.short_description).toEqual(expectedShortDescUpdated); + expect(updateResult.url).toEqual(util.format(expectedURL, createResult.id)); + expect(updateResult.offerings_url).toEqual(util.format(expectedOfferingsURL, createResult.id)); + expect(updateResult.owning_account).toEqual(expectedAccount); + expect(updateResult.catalog_filters.include_all).toEqual(true); + expect(updateResult.catalog_filters.category_filters).toEqual(undefined); + expect(updateResult.catalog_filters.id_filters.include).toEqual(undefined); + expect(updateResult.catalog_filters.id_filters.exclude).toEqual(undefined); + + done(); + }); + + test('Update catalog failure', async done => { + expect.assertions(1); + + try { + await service.replaceCatalog({ 'catalogIdentifier': fakeName, 'id': fakeName }); + } catch (err) { + expect(err.status).toEqual(404); + done(); + } + }); + + test('Delete catalog', async done => { + let createResponse; + let deleteResponse; + let createResult; + + try { + createResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + createResult = createResponse.result || {}; + deleteResponse = await service.deleteCatalog({ 'catalogIdentifier': createResult.id, 'id': createResult.id }); + } catch (err) { + done(err); + } + + expect(deleteResponse).toBeDefined(); + expect(deleteResponse.status).toEqual(200); + + done(); + }); + + test('Delete catalog failure', async done => { + let response; + + try { + response = await service.deleteCatalog({ 'catalogIdentifier': fakeName, 'id': fakeName }); + } catch (err) { + done(err); + } + + expect(response).toBeDefined(); + expect(response.status).toEqual(200); + + done(); + }); + + test('Create offering', async done => { + let catalogResponse; + let offeringResponse; + let catalogResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.createOffering({ 'catalogIdentifier': catalogResult.id, 'id': catalogResult.id, 'name': expectedOfferingName, 'label': expectedLabel }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(offeringResponse).toBeDefined(); + expect(offeringResponse.status).toEqual(201); + + const offeringResult = offeringResponse.result || {}; + expect(offeringResult).toBeDefined(); + expect(offeringResult.name).toEqual(expectedOfferingName); + expect(offeringResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(offeringResult.label).toEqual(expectedLabel); + + done(); + }); + + test('Get offering', async done => { + let catalogResponse; + let offeringResponse; + let getResponse; + let catalogResult; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.createOffering({ 'catalogIdentifier': catalogResult.id, 'id': catalogResult.id, 'name': expectedOfferingName, 'label': expectedLabel }); + offeringResult = offeringResponse.result || {}; + getResponse = await service.getOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': offeringResult.id }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(getResponse).toBeDefined(); + expect(getResponse.status).toEqual(200); + + const getResult = offeringResponse.result || {}; + expect(getResult).toBeDefined(); + expect(getResult.name).toEqual(expectedOfferingName); + expect(getResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(getResult.label).toEqual(expectedLabel); + + done(); + }); + + test('Get offering failure', async done => { + expect.assertions(2); + + let catalogResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + } catch (err) { + done(err); + } + + const catalogResult = catalogResponse.result || {}; + + try { + await service.getOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName }); + } catch (err) { + expect(err.status).toEqual(404); + } + + try { + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + await service.getOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); + + test('List offering', async done => { + const expectedFirst = '/api/v1-beta/catalogs/%s/offerings?limit=100&sort=label'; + const expectedLast = '/api/v1-beta/catalogs/%s/offerings?limit=100&sort=label'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let offeringResult; + let listResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.createOffering({ 'catalogIdentifier': catalogResult.id, 'id': catalogResult.id, 'name': expectedOfferingName, 'label': expectedLabel }); + offeringResult = offeringResponse.result || {}; + listResponse = await service.listOfferings({ 'catalogIdentifier': catalogResult.id, 'id': catalogResult.id, 'name': expectedOfferingName, 'label': expectedLabel }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(listResponse).toBeDefined(); + expect(listResponse.status).toEqual(200); + + const listResult = listResponse.result || {}; + expect(listResult).toBeDefined(); + expect(listResult.offset).toEqual(0); + expect(listResult.limit).toEqual(100); + expect(listResult.total_count).toEqual(1); + expect(listResult.resource_count).toEqual(1); + expect(listResult.first).toEqual(util.format(expectedFirst, catalogResult.id)); + expect(listResult.last).toEqual(util.format(expectedLast, catalogResult.id)); + + const resources = listResult.resources; + expect(resources).toBeDefined(); + expect(resources[0].id).toEqual(offeringResult.id); + expect(resources[0].url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(resources[0].label).toEqual(expectedLabel); + expect(resources[0].name).toEqual(expectedOfferingName); + expect(resources[0].catalog_id).toEqual(catalogResult.id); + expect(resources[0].catalog_name).toEqual(expectedLabel); + done(); + }); + + test('Delete offering', async done => { + let catalogResponse; + let offeringResponse; + let catalogResult; + let offeringResult; + let deleteResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.createOffering({ 'catalogIdentifier': catalogResult.id, 'id': catalogResult.id, 'name': expectedOfferingName, 'label': expectedLabel }); + offeringResult = offeringResponse.result || {}; + deleteResponse = await service.deleteOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': offeringResult.id }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(deleteResponse).toBeDefined(); + expect(deleteResponse.status).toEqual(200); + + done(); + }); + + test('Delete offering failure', async done => { + expect.assertions(3); + + let catalogResponse; + let deleteResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + } catch (err) { + done(err); + } + + const catalogResult = catalogResponse.result || {}; + + try { + deleteResponse = await service.deleteOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName }); + } catch (err) { + expect(err.status).toEqual(404); + } + + expect(deleteResponse).toBeDefined(); + expect(deleteResponse.status).toEqual(200); + + try { + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + await service.deleteOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); + + test('Update offering', async done => { + const expectedLabelUpdate = 'test-update'; + const expectedShortDescUpdate = 'test-desc-update'; + + let catalogResponse; + let offeringResponse; + let updateResponse; + let catalogResult; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.createOffering({ 'catalogIdentifier': catalogResult.id, 'id': catalogResult.id, 'name': expectedOfferingName, 'label': expectedLabel }); + offeringResult = offeringResponse.result || {}; + updateResponse = await service.replaceOffering({ + 'catalogIdentifier': catalogResult.id, + 'offeringId': offeringResult.id, + 'id': offeringResult.id, + 'rev': offeringResult._rev, + 'label': expectedLabelUpdate, + 'shortDescription': expectedShortDescUpdate, + }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(updateResponse).toBeDefined(); + expect(updateResponse.status).toEqual(200); + + const updateResult = updateResponse.result || {}; + expect(updateResult).toBeDefined(); + expect(updateResult.short_description).toEqual(expectedShortDescUpdate); + expect(updateResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(updateResult.label).toEqual(expectedLabelUpdate); + + done(); + }); + + test('Update offering failure', async done => { + expect.assertions(2); + + let catalogResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + } catch (err) { + done(err); + } + + const catalogResult = catalogResponse.result || {}; + + try { + await service.replaceOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName, 'id': fakeName, 'rev': fakeName }); + } catch (err) { + expect(err.status).toEqual(404); + } + + try { + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + await service.replaceOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName, 'id': fakeName, 'rev': fakeName }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); + + test('Get consumption offerings', async done => { + let response; + + try { + response = await service.getConsumptionOfferings(); + } catch (err) { + done(err); + } + + expect(response).toBeDefined(); + expect(response.status).toEqual(200); + + const result = response.result || {}; + expect(result).toBeDefined(); + expect(result.offset).toEqual(0); + expect(result.limit).toEqual(0); + expect(result.total_count).toBeGreaterThan(0); + expect(result.last).toEqual(undefined); + expect(result.prev).toEqual(undefined); + expect(result.next).toEqual(undefined); + expect(result.resources).toBeDefined; + + done(); + }); + + test('Import offering', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + const expectedOfferingTargetKind = 'roks'; + const expectedOfferingVersion = '0.4.0'; + const expectedJenkinsOfferingName = 'jenkins-operator'; + const expectedJenkinsOfferingLabel = 'Jenkins Operator'; + const expectedJenkinsOfferingShortDesc = 'Kubernetes native operator which fully manages Jenkins on Openshift.'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(offeringResponse).toBeDefined(); + expect(offeringResponse.status).toEqual(201); + + const offeringResult = offeringResponse.result || {}; + expect(offeringResult).toBeDefined(); + expect(offeringResult.name).toEqual(expectedJenkinsOfferingName); + expect(offeringResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(offeringResult.label).toEqual(expectedJenkinsOfferingLabel); + expect(offeringResult.short_description).toEqual(expectedJenkinsOfferingShortDesc); + expect(offeringResult.catalog_name).toEqual(expectedLabel); + expect(offeringResult.catalog_id).toEqual(catalogResult.id); + expect(offeringResult.kinds).toBeDefined(); + expect(offeringResult.kinds[0].target_kind).toEqual(expectedOfferingTargetKind); + expect(offeringResult.kinds[0].versions).toBeDefined(); + expect(offeringResult.kinds[0].versions[0].version).toEqual(expectedOfferingVersion); + expect(offeringResult.kinds[0].versions[0].tgz_url).toEqual(expectedOfferingZipURL); + + done(); + }); + + test('Import offering version', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.3.31/jenkins-operator.v0.3.31.clusterserviceversion.yaml'; + const expectedOfferingZipURLUpdate = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + const expectedOfferingTargetKind = 'roks'; + const expectedOfferingVersion = '0.3.31'; + const expectedOfferingVersionUpdate = '0.4.0'; + const expectedJenkinsOfferingName = 'jenkins-operator'; + const expectedJenkinsOfferingLabel = 'Jenkins Operator'; + const expectedJenkinsOfferingShortDesc = 'Kubernetes native operator which fully manages Jenkins on Openshift.'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let versionResponse; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + offeringResult = offeringResponse.result || {}; + versionResponse = await service.importOfferingVersion({ 'catalogIdentifier': catalogResult.id, 'offeringId': offeringResult.id, 'zipurl': expectedOfferingZipURLUpdate }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(versionResponse).toBeDefined(); + expect(versionResponse.status).toEqual(201); + + const versionResult = versionResponse.result || {}; + expect(versionResult).toBeDefined(); + expect(versionResult.name).toEqual(expectedJenkinsOfferingName); + expect(versionResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(versionResult.label).toEqual(expectedJenkinsOfferingLabel); + expect(versionResult.short_description).toEqual(expectedJenkinsOfferingShortDesc); + expect(versionResult.catalog_name).toEqual(expectedLabel); + expect(versionResult.catalog_id).toEqual(catalogResult.id); + expect(versionResult.kinds).toBeDefined(); + expect(versionResult.kinds[0].target_kind).toEqual(expectedOfferingTargetKind); + expect(versionResult.kinds[0].versions).toBeDefined(); + expect(versionResult.kinds[0].versions[0].version).toEqual(expectedOfferingVersion); + expect(versionResult.kinds[0].versions[0].tgz_url).toEqual(expectedOfferingZipURL); + expect(versionResult.kinds[0].versions[1].version).toEqual(expectedOfferingVersionUpdate); + expect(versionResult.kinds[0].versions[1].tgz_url).toEqual(expectedOfferingZipURLUpdate); + + done(); + }); + + test('Import offering version failure', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.3.31/jenkins-operator.v0.3.31.clusterserviceversion.yaml'; + + expect.assertions(2); + + let catalogResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + } catch (err) { + done(err); + } + + const catalogResult = catalogResponse.result || {}; + + try { + await service.importOfferingVersion({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName, 'zipurl': expectedOfferingZipURL }); + } catch (err) { + expect(err.status).toEqual(404); + } + + try { + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + await service.importOfferingVersion({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName, 'zipurl': expectedOfferingZipURL }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); + + test('Reload offering', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + const expectedOfferingTargetKind = 'roks'; + const expectedOfferingVersion = '0.4.0'; + const expectedJenkinsOfferingName = 'jenkins-operator'; + const expectedJenkinsOfferingLabel = 'Jenkins Operator'; + const expectedJenkinsOfferingShortDesc = 'Kubernetes native operator which fully manages Jenkins on Openshift.'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let reloadResponse; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + offeringResult = offeringResponse.result || {}; + reloadResponse = await service.reloadOffering({ + 'catalogIdentifier': catalogResult.id, + 'offeringId': offeringResult.id, + 'zipurl': expectedOfferingZipURL, + 'targetVersion': expectedOfferingVersion, + }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(reloadResponse).toBeDefined(); + expect(reloadResponse.status).toEqual(200); + + const reloadResult = reloadResponse.result || {}; + expect(reloadResult).toBeDefined(); + expect(reloadResult.name).toEqual(expectedJenkinsOfferingName); + expect(reloadResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(reloadResult.label).toEqual(expectedJenkinsOfferingLabel); + expect(reloadResult.short_description).toEqual(expectedJenkinsOfferingShortDesc); + expect(reloadResult.catalog_name).toEqual(expectedLabel); + expect(reloadResult.catalog_id).toEqual(catalogResult.id); + expect(reloadResult.kinds).toBeDefined(); + expect(reloadResult.kinds[0].target_kind).toEqual(expectedOfferingTargetKind); + expect(reloadResult.kinds[0].versions).toBeDefined(); + expect(reloadResult.kinds[0].versions[0].version).toEqual(expectedOfferingVersion); + expect(reloadResult.kinds[0].versions[0].tgz_url).toEqual(expectedOfferingZipURL); + + done(); + }); + + test('Reload offering failure', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.3.31/jenkins-operator.v0.3.31.clusterserviceversion.yaml'; + const expectedOfferingVersion = '0.4.0'; + + expect.assertions(2); + + let catalogResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + } catch (err) { + done(err); + } + + const catalogResult = catalogResponse.result || {}; + + try { + await service.reloadOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName, 'zipurl': expectedOfferingZipURL, 'targetVersion': expectedOfferingVersion }); + } catch (err) { + expect(err.status).toEqual(404); + } + + try { + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + await service.reloadOffering({ 'catalogIdentifier': catalogResult.id, 'offeringId': fakeName, 'zipurl': expectedOfferingZipURL, 'targetVersion': expectedOfferingVersion }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); + + test('Get version', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + const expectedOfferingTargetKind = 'roks'; + const expectedOfferingVersion = '0.4.0'; + const expectedJenkinsOfferingName = 'jenkins-operator'; + const expectedJenkinsOfferingLabel = 'Jenkins Operator'; + const expectedJenkinsOfferingShortDesc = 'Kubernetes native operator which fully manages Jenkins on Openshift.'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let getResponse; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + offeringResult = offeringResponse.result || {}; + getResponse = await service.getVersion({ 'versionLocId': offeringResult.kinds[0].versions[0].version_locator }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(getResponse).toBeDefined(); + expect(getResponse.status).toEqual(200); + + const getResult = getResponse.result || {}; + expect(getResult).toBeDefined(); + expect(getResult.name).toEqual(expectedJenkinsOfferingName); + expect(getResult.url).toEqual(util.format(expectedOfferingURL, catalogResult.id, offeringResult.id)); + expect(getResult.label).toEqual(expectedJenkinsOfferingLabel); + expect(getResult.short_description).toEqual(expectedJenkinsOfferingShortDesc); + expect(getResult.catalog_name).toEqual(expectedLabel); + expect(getResult.catalog_id).toEqual(catalogResult.id); + expect(getResult.kinds).toBeDefined(); + expect(getResult.kinds[0].target_kind).toEqual(expectedOfferingTargetKind); + expect(getResult.kinds[0].versions).toBeDefined(); + expect(getResult.kinds[0].versions[0].version).toEqual(expectedOfferingVersion); + expect(getResult.kinds[0].versions[0].tgz_url).toEqual(expectedOfferingZipURL); + + done(); + }); + + test('Get version failure', async done => { + expect.assertions(1); + + try { + await service.getVersion({ 'versionLocId': fakeVersionLocator }); + } catch (err) { + expect(err.status).toEqual(404); + done(); + } + }); + + test('Delete version', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let getResponse; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + offeringResult = offeringResponse.result || {}; + getResponse = await service.deleteVersion({ 'versionLocId': offeringResult.kinds[0].versions[0].version_locator }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(getResponse).toBeDefined(); + expect(getResponse.status).toEqual(200); + + done(); + }); + + test('Delete version failure', async done => { + expect.assertions(1); + + try { + await service.deleteVersion({ 'versionLocId': fakeVersionLocator }); + } catch (err) { + expect(err.status).toEqual(404); + done(); + } + }); + + test('Get version about', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let getResponse; + let offeringResult; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + offeringResult = offeringResponse.result || {}; + getResponse = await service.getVersionAbout({ 'versionLocId': offeringResult.kinds[0].versions[0].version_locator }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(getResponse).toBeDefined(); + expect(getResponse.status).toEqual(200); + + const getResult = getResponse.result || {}; + expect(getResult).toBeDefined(); + + done(); + }); + + test('Get version about failure', async done => { + expect.assertions(1); + + try { + await service.getVersionAbout({ 'versionLocId': fakeVersionLocator }); + } catch (err) { + expect(err.status).toEqual(404); + done(); + } + }); + + test('Get version updates', async done => { + const expectedOfferingZipURL = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.3.31/jenkins-operator.v0.3.31.clusterserviceversion.yaml'; + const expectedOfferingZipURLUpdate = + 'https://github.com/operator-framework/community-operators/blob/master/community-operators/jenkins-operator/0.4.0/jenkins-operator.v0.4.0.clusterserviceversion.yaml'; + const expectedOfferingVersionUpdate = '0.4.0'; + + let catalogResponse; + let offeringResponse; + let catalogResult; + let offeringResult; + let versionResponse; + let versionResult; + let updateResponse; + + try { + catalogResponse = await service.createCatalog({ 'label': expectedLabel, 'shortDescription': expectedShortDesc }); + catalogResult = catalogResponse.result || {}; + offeringResponse = await service.importOffering({ 'catalogIdentifier': catalogResult.id, 'zipurl': expectedOfferingZipURL }); + offeringResult = offeringResponse.result || {}; + versionResponse = await service.importOfferingVersion({ 'catalogIdentifier': catalogResult.id, 'offeringId': offeringResult.id, 'zipurl': expectedOfferingZipURLUpdate }); + versionResult = versionResponse.result || {}; + updateResponse = await service.getVersionUpdates({ 'versionLocId': offeringResult.kinds[0].versions[0].version_locator }); + await service.deleteCatalog({ 'catalogIdentifier': catalogResult.id }); + } catch (err) { + done(err); + } + + expect(updateResponse).toBeDefined(); + expect(updateResponse.status).toEqual(200); + + const updateResult = updateResponse.result || {}; + expect(updateResult).toBeDefined(); + expect(updateResult[0].version_locator).toEqual(versionResult.kinds[0].versions[1].version_locator); + expect(updateResult[0].version).toEqual(expectedOfferingVersionUpdate); + expect(updateResult[0].package_version).toEqual(expectedOfferingVersionUpdate); + expect(updateResult[0].can_update).toEqual(true); + + done(); + }); + + test('Get version updates failure', async done => { + expect.assertions(1); + + try { + await service.getVersionUpdates({ 'versionLocId': fakeVersionLocator }); + } catch (err) { + expect(err.status).toEqual(404); + done(); + } + }); + + test('Get license providers', async done => { + const expectedTotalResults = 1; + const expectedTotalPages = 1; + const expectedName = 'IBM Passport Advantage'; + const expectedOfferingType = 'content'; + const expectedCreateURL = 'https://www.ibm.com/software/passportadvantage/aboutpassport.html'; + const expectedInfoURL = 'https://www.ibm.com/software/passportadvantage/'; + const expectedURL = '/v1/licensing/license_providers/11cabc37-c4a7-410b-894d-8cb3586423f1'; + const expectedState = 'active'; + + let response; + + try { + response = await service.getLicenseProviders(); + } catch (err) { + done(err); + } + + expect(response).toBeDefined(); + expect(response.status).toEqual(200); + + const result = response.result || {}; + expect(result).toBeDefined(); + expect(result.total_results).toEqual(expectedTotalResults); + expect(result.total_pages).toEqual(expectedTotalPages); + + const resources = result.resources; + expect(resources).toBeDefined(); + expect(resources.length).toEqual(1); + expect(resources[0].name).toEqual(expectedName); + expect(resources[0].offering_type).toEqual(expectedOfferingType); + expect(resources[0].create_url).toEqual(expectedCreateURL); + expect(resources[0].info_url).toEqual(expectedInfoURL); + expect(resources[0].url).toEqual(expectedURL); + expect(resources[0].state).toEqual(expectedState); + + done(); + }); + + test('Get list license entitlements', async done => { + const expectedResourceCount = 0; + const expectedTotalResults = 0; + const expectedTotalPages = 1; + + let response; + + try { + response = await service.listLicenseEntitlements(); + } catch (err) { + done(err); + } + + expect(response).toBeDefined(); + expect(response.status).toEqual(200); + + const result = response.result || {}; + expect(result).toBeDefined(); + expect(result.total_results).toEqual(expectedTotalResults); + expect(result.total_pages).toEqual(expectedTotalPages); + + const resources = result.resources; + expect(resources).toBeDefined(); + expect(resources.length).toEqual(expectedResourceCount); + + done(); + }); + + test('Search license versions', async done => { + expect.assertions(1); + + try { + await service.searchLicenseVersions({ 'q': fakeName }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); + + test('Search license offerings', async done => { + expect.assertions(1); + + try { + await service.searchLicenseOfferings({ 'q': fakeName }); + } catch (err) { + expect(err.status).toEqual(403); + done(); + } + }); +});