From 487029637632bf084fb05b567f62cbd8d20a164d Mon Sep 17 00:00:00 2001 From: Oleksandr Pravosudko <71440851+oleksandrpravosudko-okta@users.noreply.github.com> Date: Thu, 28 Jul 2022 12:49:21 +0200 Subject: [PATCH] integrate Subscription API (#351) * use token issuer user for Subscription tests --- scripts/e2e.sh | 2 + src/client.js | 2 + src/generated-client.js | 118 +--- src/generated/apis/EmailDomainApi.js | 516 ++++++++++++++++++ src/generated/models/ApplicationLayout.js | 74 +++ src/generated/models/ApplicationLayoutRule.js | 50 ++ .../models/ApplicationLayoutRuleCondition.js | 50 ++ src/generated/models/BaseEmailDomain.js | 50 ++ src/generated/models/EmailDomain.js | 56 ++ .../models/EmailDomainListResponse.js | 44 ++ src/generated/models/EmailDomainResponse.js | 74 +++ src/generated/models/EmailDomainStatus.js | 26 + src/generated/models/UpdateEmailDomain.js | 50 ++ src/types/client.d.ts | 2 + src/types/generated-client.d.ts | 20 +- templates/generated-client.d.ts.hbs | 2 +- templates/generated-client.js.hbs | 3 - templates/helpers/operation-v3.js | 10 + test/it/subscription-role.ts | 6 +- test/it/subscription-user.ts | 49 +- test/type/subscription-user.ts | 10 +- 21 files changed, 1052 insertions(+), 162 deletions(-) create mode 100644 src/generated/apis/EmailDomainApi.js create mode 100644 src/generated/models/ApplicationLayout.js create mode 100644 src/generated/models/ApplicationLayoutRule.js create mode 100644 src/generated/models/ApplicationLayoutRuleCondition.js create mode 100644 src/generated/models/BaseEmailDomain.js create mode 100644 src/generated/models/EmailDomain.js create mode 100644 src/generated/models/EmailDomainListResponse.js create mode 100644 src/generated/models/EmailDomainResponse.js create mode 100644 src/generated/models/EmailDomainStatus.js create mode 100644 src/generated/models/UpdateEmailDomain.js diff --git a/scripts/e2e.sh b/scripts/e2e.sh index 4510b1178..77469fa1b 100644 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -6,6 +6,8 @@ export OKTA_CLIENT_ORGURL=https://node-sdk-oie.oktapreview.com get_vault_secret_key devex/okta-sdk-nodejs-vars api_key OKTA_CLIENT_TOKEN export OKTA_CLIENT_CLIENTID=0oa1q34stxthm0zbJ1d7 get_vault_secret_key devex/okta-sdk-nodejs-vars private_key OKTA_CLIENT_PRIVATEKEY +get_vault_secret_key devex/okta-sdk-nodejs-vars username ORG_USER + export TEST_SUITE_TYPE="junit" export TEST_RESULT_FILE_DIR="${REPO}/test-reports" diff --git a/src/client.js b/src/client.js index 476a5b5c6..757fe5891 100644 --- a/src/client.js +++ b/src/client.js @@ -45,6 +45,7 @@ const { SessionApi, TemplateApi, PolicyApi, + SubscriptionApi, } = require('./generated'); const { createConfiguration } = require('./generated/configuration'); const { ServerConfiguration } = require('./generated/servers'); @@ -145,6 +146,7 @@ class Client extends GeneratedApiClient { this.sessionApi = new SessionApi(configuration); this.templateApi = new TemplateApi(configuration); this.policyApi = new PolicyApi(configuration); + this.subscriptionApi = new SubscriptionApi(configuration); } } diff --git a/src/generated-client.js b/src/generated-client.js index a6a7a692d..6732c20ea 100644 --- a/src/generated-client.js +++ b/src/generated-client.js @@ -15,9 +15,7 @@ const qs = require('querystring'); -const { Collection } = require('./collection'); const models = require('./models'); -const { ModelFactory } = require('./model-factory'); /** * Auto-Generated API client, implements the operations as defined in the OpenaAPI JSON spec @@ -4546,13 +4544,7 @@ class GeneratedApiClient { if (!roleTypeOrRoleId) { return Promise.reject(new Error('OKTA API listRoleSubscriptions parameter roleTypeOrRoleId is required.')); } - let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions`; - - return new Collection( - this.http, - url, - new ModelFactory(models.Subscription, this), - ); + return this.subscriptionApi.listRoleSubscriptions(roleTypeOrRoleId); } /** @@ -4570,19 +4562,7 @@ class GeneratedApiClient { if (!notificationType) { return Promise.reject(new Error('OKTA API getRoleSubscriptionByNotificationType parameter notificationType is required.')); } - let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`; - - const resources = [ - `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`, - `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}` - ]; - - const request = this.http.getJson( - url, - null, - { resources } - ); - return request.then(jsonRes => new models.Subscription(jsonRes, this)); + return this.subscriptionApi.getRoleSubscriptionByNotificationType(roleTypeOrRoleId, notificationType); } /** @@ -4599,23 +4579,7 @@ class GeneratedApiClient { if (!notificationType) { return Promise.reject(new Error('OKTA API subscribeRoleSubscriptionByNotificationType parameter notificationType is required.')); } - let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}/subscribe`; - - const resources = [ - `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`, - `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}` - ]; - - const request = this.http.post( - url, - { - headers: { - 'Content-Type': 'application/json', 'Accept': 'application/json', - }, - }, - { resources } - ); - return request; + return this.subscriptionApi.subscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId, notificationType); } /** @@ -4632,23 +4596,7 @@ class GeneratedApiClient { if (!notificationType) { return Promise.reject(new Error('OKTA API unsubscribeRoleSubscriptionByNotificationType parameter notificationType is required.')); } - let url = `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}/unsubscribe`; - - const resources = [ - `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}/subscriptions/${notificationType}`, - `${this.baseUrl}/api/v1/roles/${roleTypeOrRoleId}` - ]; - - const request = this.http.post( - url, - { - headers: { - 'Content-Type': 'application/json', 'Accept': 'application/json', - }, - }, - { resources } - ); - return request; + return this.subscriptionApi.unsubscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId, notificationType); } /** @@ -6191,13 +6139,7 @@ class GeneratedApiClient { if (!userId) { return Promise.reject(new Error('OKTA API listUserSubscriptions parameter userId is required.')); } - let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions`; - - return new Collection( - this.http, - url, - new ModelFactory(models.Subscription, this), - ); + return this.subscriptionApi.listUserSubscriptions(userId); } /** @@ -6215,19 +6157,7 @@ class GeneratedApiClient { if (!notificationType) { return Promise.reject(new Error('OKTA API getUserSubscriptionByNotificationType parameter notificationType is required.')); } - let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`; - - const resources = [ - `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`, - `${this.baseUrl}/api/v1/users/${userId}` - ]; - - const request = this.http.getJson( - url, - null, - { resources } - ); - return request.then(jsonRes => new models.Subscription(jsonRes, this)); + return this.subscriptionApi.getUserSubscriptionByNotificationType(userId, notificationType); } /** @@ -6244,23 +6174,7 @@ class GeneratedApiClient { if (!notificationType) { return Promise.reject(new Error('OKTA API subscribeUserSubscriptionByNotificationType parameter notificationType is required.')); } - let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}/subscribe`; - - const resources = [ - `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`, - `${this.baseUrl}/api/v1/users/${userId}` - ]; - - const request = this.http.post( - url, - { - headers: { - 'Content-Type': 'application/json', 'Accept': 'application/json', - }, - }, - { resources } - ); - return request; + return this.subscriptionApi.subscribeUserSubscriptionByNotificationType(userId, notificationType); } /** @@ -6277,23 +6191,7 @@ class GeneratedApiClient { if (!notificationType) { return Promise.reject(new Error('OKTA API unsubscribeUserSubscriptionByNotificationType parameter notificationType is required.')); } - let url = `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}/unsubscribe`; - - const resources = [ - `${this.baseUrl}/api/v1/users/${userId}/subscriptions/${notificationType}`, - `${this.baseUrl}/api/v1/users/${userId}` - ]; - - const request = this.http.post( - url, - { - headers: { - 'Content-Type': 'application/json', 'Accept': 'application/json', - }, - }, - { resources } - ); - return request; + return this.subscriptionApi.unsubscribeUserSubscriptionByNotificationType(userId, notificationType); } /** diff --git a/src/generated/apis/EmailDomainApi.js b/src/generated/apis/EmailDomainApi.js new file mode 100644 index 000000000..380f9adfd --- /dev/null +++ b/src/generated/apis/EmailDomainApi.js @@ -0,0 +1,516 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.EmailDomainApiResponseProcessor = exports.EmailDomainApiRequestFactory = void 0; +// TODO: better import syntax? +const baseapi_1 = require('./baseapi'); +const http_1 = require('../http/http'); +const ObjectSerializer_1 = require('../models/ObjectSerializer'); +const exception_1 = require('./exception'); +const util_1 = require('../util'); +/** + * no description + */ +class EmailDomainApiRequestFactory extends baseapi_1.BaseAPIRequestFactory { + /** + * Creates a custom email domain. + * Create an Email Domain + * @param emailDomain + */ + async createEmailDomain(emailDomain, _options) { + let _config = _options || this.configuration; + // verify required parameter 'emailDomain' is not null or undefined + if (emailDomain === null || emailDomain === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'createEmailDomain', 'emailDomain'); + } + // Path Params + const path = '/api/v1/email-domains'; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.POST); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + // Body Params + const [contentType, contentEncoding] = ObjectSerializer_1.ObjectSerializer.getPreferredMediaTypeAndEncoding([ + 'application/json' + ], emailDomain); + requestContext.setHeaderParam('Content-Type', contentType); + requestContext.setHeaderParam('Content-Transfer-Encoding', contentEncoding); + const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(emailDomain, 'EmailDomain', ''), contentType); + requestContext.setBody(serializedBody); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } + /** + * Deletes an Email Domain by `emailDomainId`. + * Delete an Email Domain + * @param emailDomainId + */ + async deleteEmailDomain(emailDomainId, _options) { + let _config = _options || this.configuration; + // verify required parameter 'emailDomainId' is not null or undefined + if (emailDomainId === null || emailDomainId === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'deleteEmailDomain', 'emailDomainId'); + } + // Path Params + const path = '/api/v1/email-domains/{emailDomainId}'; + const vars = { + ['emailDomainId']: String(emailDomainId), + }; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.DELETE, vars); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } + /** + * Fetches an Email Domain by `emailDomainId`. + * Retrieve a Email Domain + * @param emailDomainId + */ + async getEmailDomain(emailDomainId, _options) { + let _config = _options || this.configuration; + // verify required parameter 'emailDomainId' is not null or undefined + if (emailDomainId === null || emailDomainId === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'getEmailDomain', 'emailDomainId'); + } + // Path Params + const path = '/api/v1/email-domains/{emailDomainId}'; + const vars = { + ['emailDomainId']: String(emailDomainId), + }; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.GET, vars); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } + /** + * List all brands linked to an email domain. + * List all brands linked to an email domain + * @param emailDomainId + */ + async listEmailDomainBrands(emailDomainId, _options) { + let _config = _options || this.configuration; + // verify required parameter 'emailDomainId' is not null or undefined + if (emailDomainId === null || emailDomainId === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'listEmailDomainBrands', 'emailDomainId'); + } + // Path Params + const path = '/api/v1/email-domains/{emailDomainId}/brands'; + const vars = { + ['emailDomainId']: String(emailDomainId), + }; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.GET, vars); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } + /** + * List all the email domains in your org. + * List all email domains + */ + async listEmailDomains(_options) { + let _config = _options || this.configuration; + // Path Params + const path = '/api/v1/email-domains'; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.GET); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } + /** + * Updates an email domain by `emailDomainId` + * Update an Email Domain + * @param emailDomainId + * @param updateEmailDomain + */ + async updateEmailDomain(emailDomainId, updateEmailDomain, _options) { + let _config = _options || this.configuration; + // verify required parameter 'emailDomainId' is not null or undefined + if (emailDomainId === null || emailDomainId === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'updateEmailDomain', 'emailDomainId'); + } + // verify required parameter 'updateEmailDomain' is not null or undefined + if (updateEmailDomain === null || updateEmailDomain === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'updateEmailDomain', 'updateEmailDomain'); + } + // Path Params + const path = '/api/v1/email-domains/{emailDomainId}'; + const vars = { + ['emailDomainId']: String(emailDomainId), + }; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.PUT, vars); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + // Body Params + const [contentType, contentEncoding] = ObjectSerializer_1.ObjectSerializer.getPreferredMediaTypeAndEncoding([ + 'application/json' + ], updateEmailDomain); + requestContext.setHeaderParam('Content-Type', contentType); + requestContext.setHeaderParam('Content-Transfer-Encoding', contentEncoding); + const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(updateEmailDomain, 'UpdateEmailDomain', ''), contentType); + requestContext.setBody(serializedBody); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } + /** + * Verifies the Email Domain by `id`. + * Verify Email Domain + * @param emailDomainId + */ + async verifyEmailDomain(emailDomainId, _options) { + let _config = _options || this.configuration; + // verify required parameter 'emailDomainId' is not null or undefined + if (emailDomainId === null || emailDomainId === undefined) { + throw new baseapi_1.RequiredError('EmailDomainApi', 'verifyEmailDomain', 'emailDomainId'); + } + // Path Params + const path = '/api/v1/email-domains/{emailDomainId}/verify'; + const vars = { + ['emailDomainId']: String(emailDomainId), + }; + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(path, http_1.HttpMethodEnum.POST, vars); + requestContext.setHeaderParam('Accept', 'application/json, */*;q=0.8'); + let authMethod; + // Apply auth methods + authMethod = _config.authMethods['API_Token']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods['OAuth_2.0']; + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + const defaultAuth = _options?.authMethods?.default || this.configuration?.authMethods?.default; + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + return requestContext; + } +} +exports.EmailDomainApiRequestFactory = EmailDomainApiRequestFactory; +class EmailDomainApiResponseProcessor { + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createEmailDomain + * @throws ApiException if the response code was not in [200, 299] + */ + async createEmailDomain(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + if ((0, util_1.isCodeInRange)('400', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(400, 'Bad Request', body, response.headers); + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteEmailDomain + * @throws ApiException if the response code was not in [200, 299] + */ + async deleteEmailDomain(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('204', response.httpStatusCode)) { + return; + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('404', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(404, 'Not Found', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'void', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getEmailDomain + * @throws ApiException if the response code was not in [200, 299] + */ + async getEmailDomain(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('404', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(404, 'Not Found', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to listEmailDomainBrands + * @throws ApiException if the response code was not in [200, 299] + */ + async listEmailDomainBrands(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Array', ''); + return body; + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('404', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(404, 'Not Found', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Array', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to listEmailDomains + * @throws ApiException if the response code was not in [200, 299] + */ + async listEmailDomains(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainListResponse', ''); + return body; + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainListResponse', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updateEmailDomain + * @throws ApiException if the response code was not in [200, 299] + */ + async updateEmailDomain(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + if ((0, util_1.isCodeInRange)('400', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(400, 'Bad Request', body, response.headers); + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('404', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(404, 'Not Found', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to verifyEmailDomain + * @throws ApiException if the response code was not in [200, 299] + */ + async verifyEmailDomain(response) { + const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']); + if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(403, 'Forbidden', body, response.headers); + } + if ((0, util_1.isCodeInRange)('404', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(404, 'Not Found', body, response.headers); + } + if ((0, util_1.isCodeInRange)('429', response.httpStatusCode)) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'Error', ''); + throw new exception_1.ApiException(429, 'Too Many Requests', body, response.headers); + } + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(await response.body.text(), contentType), 'EmailDomainResponse', ''); + return body; + } + throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!', await response.getBodyAsAny(), response.headers); + } +} +exports.EmailDomainApiResponseProcessor = EmailDomainApiResponseProcessor; diff --git a/src/generated/models/ApplicationLayout.js b/src/generated/models/ApplicationLayout.js new file mode 100644 index 000000000..8badfdf8a --- /dev/null +++ b/src/generated/models/ApplicationLayout.js @@ -0,0 +1,74 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.ApplicationLayout = void 0; +class ApplicationLayout { + constructor() { + } + static getAttributeTypeMap() { + return ApplicationLayout.attributeTypeMap; + } +} +exports.ApplicationLayout = ApplicationLayout; +ApplicationLayout.discriminator = undefined; +ApplicationLayout.attributeTypeMap = [ + { + 'name': 'elements', + 'baseName': 'elements', + 'type': 'Array', + 'format': '' + }, + { + 'name': 'label', + 'baseName': 'label', + 'type': 'string', + 'format': '' + }, + { + 'name': 'options', + 'baseName': 'options', + 'type': '{ [key: string]: any; }', + 'format': '' + }, + { + 'name': 'rule', + 'baseName': 'rule', + 'type': 'ApplicationLayoutRule', + 'format': '' + }, + { + 'name': 'scope', + 'baseName': 'scope', + 'type': 'string', + 'format': '' + }, + { + 'name': 'type', + 'baseName': 'type', + 'type': 'string', + 'format': '' + } +]; diff --git a/src/generated/models/ApplicationLayoutRule.js b/src/generated/models/ApplicationLayoutRule.js new file mode 100644 index 000000000..1376492a3 --- /dev/null +++ b/src/generated/models/ApplicationLayoutRule.js @@ -0,0 +1,50 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.ApplicationLayoutRule = void 0; +class ApplicationLayoutRule { + constructor() { + } + static getAttributeTypeMap() { + return ApplicationLayoutRule.attributeTypeMap; + } +} +exports.ApplicationLayoutRule = ApplicationLayoutRule; +ApplicationLayoutRule.discriminator = undefined; +ApplicationLayoutRule.attributeTypeMap = [ + { + 'name': 'effect', + 'baseName': 'effect', + 'type': 'string', + 'format': '' + }, + { + 'name': 'condition', + 'baseName': 'condition', + 'type': 'ApplicationLayoutRuleCondition', + 'format': '' + } +]; diff --git a/src/generated/models/ApplicationLayoutRuleCondition.js b/src/generated/models/ApplicationLayoutRuleCondition.js new file mode 100644 index 000000000..57f0a3d48 --- /dev/null +++ b/src/generated/models/ApplicationLayoutRuleCondition.js @@ -0,0 +1,50 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.ApplicationLayoutRuleCondition = void 0; +class ApplicationLayoutRuleCondition { + constructor() { + } + static getAttributeTypeMap() { + return ApplicationLayoutRuleCondition.attributeTypeMap; + } +} +exports.ApplicationLayoutRuleCondition = ApplicationLayoutRuleCondition; +ApplicationLayoutRuleCondition.discriminator = undefined; +ApplicationLayoutRuleCondition.attributeTypeMap = [ + { + 'name': 'schema', + 'baseName': 'schema', + 'type': '{ [key: string]: any; }', + 'format': '' + }, + { + 'name': 'scope', + 'baseName': 'scope', + 'type': 'string', + 'format': '' + } +]; diff --git a/src/generated/models/BaseEmailDomain.js b/src/generated/models/BaseEmailDomain.js new file mode 100644 index 000000000..21760966c --- /dev/null +++ b/src/generated/models/BaseEmailDomain.js @@ -0,0 +1,50 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.BaseEmailDomain = void 0; +class BaseEmailDomain { + constructor() { + } + static getAttributeTypeMap() { + return BaseEmailDomain.attributeTypeMap; + } +} +exports.BaseEmailDomain = BaseEmailDomain; +BaseEmailDomain.discriminator = undefined; +BaseEmailDomain.attributeTypeMap = [ + { + 'name': 'displayName', + 'baseName': 'displayName', + 'type': 'string', + 'format': '' + }, + { + 'name': 'userName', + 'baseName': 'userName', + 'type': 'string', + 'format': '' + } +]; diff --git a/src/generated/models/EmailDomain.js b/src/generated/models/EmailDomain.js new file mode 100644 index 000000000..b97b219b8 --- /dev/null +++ b/src/generated/models/EmailDomain.js @@ -0,0 +1,56 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.EmailDomain = void 0; +class EmailDomain { + constructor() { + } + static getAttributeTypeMap() { + return EmailDomain.attributeTypeMap; + } +} +exports.EmailDomain = EmailDomain; +EmailDomain.discriminator = undefined; +EmailDomain.attributeTypeMap = [ + { + 'name': 'domain', + 'baseName': 'domain', + 'type': 'string', + 'format': '' + }, + { + 'name': 'displayName', + 'baseName': 'displayName', + 'type': 'string', + 'format': '' + }, + { + 'name': 'userName', + 'baseName': 'userName', + 'type': 'string', + 'format': '' + } +]; diff --git a/src/generated/models/EmailDomainListResponse.js b/src/generated/models/EmailDomainListResponse.js new file mode 100644 index 000000000..3d46a80b7 --- /dev/null +++ b/src/generated/models/EmailDomainListResponse.js @@ -0,0 +1,44 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.EmailDomainListResponse = void 0; +class EmailDomainListResponse { + constructor() { + } + static getAttributeTypeMap() { + return EmailDomainListResponse.attributeTypeMap; + } +} +exports.EmailDomainListResponse = EmailDomainListResponse; +EmailDomainListResponse.discriminator = undefined; +EmailDomainListResponse.attributeTypeMap = [ + { + 'name': 'email_domains', + 'baseName': 'email-domains', + 'type': 'Array', + 'format': '' + } +]; diff --git a/src/generated/models/EmailDomainResponse.js b/src/generated/models/EmailDomainResponse.js new file mode 100644 index 000000000..79d0d6305 --- /dev/null +++ b/src/generated/models/EmailDomainResponse.js @@ -0,0 +1,74 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.EmailDomainResponse = void 0; +class EmailDomainResponse { + constructor() { + } + static getAttributeTypeMap() { + return EmailDomainResponse.attributeTypeMap; + } +} +exports.EmailDomainResponse = EmailDomainResponse; +EmailDomainResponse.discriminator = undefined; +EmailDomainResponse.attributeTypeMap = [ + { + 'name': 'dnsValidationRecords', + 'baseName': 'dnsValidationRecords', + 'type': 'Array', + 'format': '' + }, + { + 'name': 'domain', + 'baseName': 'domain', + 'type': 'string', + 'format': '' + }, + { + 'name': 'id', + 'baseName': 'id', + 'type': 'string', + 'format': '' + }, + { + 'name': 'validationStatus', + 'baseName': 'validationStatus', + 'type': 'EmailDomainStatus', + 'format': '' + }, + { + 'name': 'displayName', + 'baseName': 'displayName', + 'type': 'string', + 'format': '' + }, + { + 'name': 'userName', + 'baseName': 'userName', + 'type': 'string', + 'format': '' + } +]; diff --git a/src/generated/models/EmailDomainStatus.js b/src/generated/models/EmailDomainStatus.js new file mode 100644 index 000000000..034c8ae8f --- /dev/null +++ b/src/generated/models/EmailDomainStatus.js @@ -0,0 +1,26 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/src/generated/models/UpdateEmailDomain.js b/src/generated/models/UpdateEmailDomain.js new file mode 100644 index 000000000..55e23c12d --- /dev/null +++ b/src/generated/models/UpdateEmailDomain.js @@ -0,0 +1,50 @@ +/*! + * Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved. + * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (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'; +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 3.0.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, '__esModule', { value: true }); +exports.UpdateEmailDomain = void 0; +class UpdateEmailDomain { + constructor() { + } + static getAttributeTypeMap() { + return UpdateEmailDomain.attributeTypeMap; + } +} +exports.UpdateEmailDomain = UpdateEmailDomain; +UpdateEmailDomain.discriminator = undefined; +UpdateEmailDomain.attributeTypeMap = [ + { + 'name': 'displayName', + 'baseName': 'displayName', + 'type': 'string', + 'format': '' + }, + { + 'name': 'userName', + 'baseName': 'userName', + 'type': 'string', + 'format': '' + } +]; diff --git a/src/types/client.d.ts b/src/types/client.d.ts index f62c43bf6..3edcbd055 100644 --- a/src/types/client.d.ts +++ b/src/types/client.d.ts @@ -40,6 +40,7 @@ import { SessionApi, TemplateApi, PolicyApi, + SubscriptionApi, } from './generated'; export declare class Client extends ParameterizedOperationsClient { constructor(config?: V2Configuration); @@ -78,4 +79,5 @@ export declare class Client extends ParameterizedOperationsClient { sessionApi: SessionApi; templateApi: TemplateApi; policyApi: PolicyApi; + subscription: SubscriptionApi; } diff --git a/src/types/generated-client.d.ts b/src/types/generated-client.d.ts index a3cd3e25c..e562eefa3 100644 --- a/src/types/generated-client.d.ts +++ b/src/types/generated-client.d.ts @@ -14,12 +14,10 @@ /* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ import { ReadStream } from 'fs'; -import { ApplicationOptions } from './parameterized-operations-client'; +import { Collection } from './collection'; import * as v3 from './generated'; import { JsonWebKey } from './models/JsonWebKey'; import { Response } from 'node-fetch'; -import { Collection } from './collection'; -import { Subscription } from './models/Subscription'; import { ForgotPasswordResponse } from './models/ForgotPasswordResponse'; export declare class GeneratedApiClient { @@ -405,10 +403,10 @@ export declare class GeneratedApiClient { updatePolicyRule(policyId: string, ruleId: string, policyRule: v3.PolicyRule): Promise; activatePolicyRule(policyId: string, ruleId: string): Promise; deactivatePolicyRule(policyId: string, ruleId: string): Promise; - listRoleSubscriptions(roleTypeOrRoleId: string): Collection; - getRoleSubscriptionByNotificationType(roleTypeOrRoleId: string, notificationType: string): Promise; - subscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId: string, notificationType: string): Promise; - unsubscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId: string, notificationType: string): Promise; + listRoleSubscriptions(roleTypeOrRoleId: string): Promise>; + getRoleSubscriptionByNotificationType(roleTypeOrRoleId: string, notificationType: string): Promise; + subscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId: string, notificationType: string): Promise; + unsubscribeRoleSubscriptionByNotificationType(roleTypeOrRoleId: string, notificationType: string): Promise; createSession(createSessionRequest: v3.CreateSessionRequest): Promise; endSession(sessionId: string): Promise; getSession(sessionId: string): Promise; @@ -573,10 +571,10 @@ export declare class GeneratedApiClient { clearUserSessions(userId: string, queryParameters?: { oauthTokens?: boolean, }): Promise; - listUserSubscriptions(userId: string): Collection; - getUserSubscriptionByNotificationType(userId: string, notificationType: string): Promise; - subscribeUserSubscriptionByNotificationType(userId: string, notificationType: string): Promise; - unsubscribeUserSubscriptionByNotificationType(userId: string, notificationType: string): Promise; + listUserSubscriptions(userId: string): Promise>; + getUserSubscriptionByNotificationType(userId: string, notificationType: string): Promise; + subscribeUserSubscriptionByNotificationType(userId: string, notificationType: string): Promise; + unsubscribeUserSubscriptionByNotificationType(userId: string, notificationType: string): Promise; listNetworkZones(queryParameters?: { after?: string, limit?: number, diff --git a/templates/generated-client.d.ts.hbs b/templates/generated-client.d.ts.hbs index af5055b47..2dc42fadb 100644 --- a/templates/generated-client.d.ts.hbs +++ b/templates/generated-client.d.ts.hbs @@ -2,7 +2,7 @@ /* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ import { ReadStream } from 'fs'; -import { ApplicationOptions } from './parameterized-operations-client'; +import { Collection } from './collection'; import * as v3 from './generated'; {{{typeScriptClientImportBuilder operations}}} diff --git a/templates/generated-client.js.hbs b/templates/generated-client.js.hbs index 2bf7c4599..3e23c4f34 100644 --- a/templates/generated-client.js.hbs +++ b/templates/generated-client.js.hbs @@ -3,10 +3,7 @@ const qs = require('querystring'); -const { Collection } = require('./collection'); const models = require('./models'); -const factories = require('./factories'); -const { ModelFactory } = require('./model-factory'); /** * Auto-Generated API client, implements the operations as defined in the OpenaAPI JSON spec diff --git a/templates/helpers/operation-v3.js b/templates/helpers/operation-v3.js index 73abb29b3..8b42f5225 100644 --- a/templates/helpers/operation-v3.js +++ b/templates/helpers/operation-v3.js @@ -375,6 +375,16 @@ const V3ApiOperations = { 'listPolicyRules', 'updatePolicy', 'updatePolicyRule' + ], + SubscriptionApi: [ + 'getRoleSubscriptionByNotificationType', + 'getUserSubscriptionByNotificationType', + 'listRoleSubscriptions', + 'listUserSubscriptions', + 'subscribeRoleSubscriptionByNotificationType', + 'subscribeUserSubscriptionByNotificationType', + 'unsubscribeRoleSubscriptionByNotificationType', + 'unsubscribeUserSubscriptionByNotificationType', ] }; diff --git a/test/it/subscription-role.ts b/test/it/subscription-role.ts index 7d92bfa65..d2656bd7d 100644 --- a/test/it/subscription-role.ts +++ b/test/it/subscription-role.ts @@ -16,7 +16,7 @@ const client = new Client({ describe('Subscription API', () => { it('provides method for listing notification subscriptions for given user role', async () => { const subscriptions = []; - for await (const subscription of client.listRoleSubscriptions(RoleType.ORG_ADMIN)) { + for await (const subscription of (await client.listRoleSubscriptions(RoleType.ORG_ADMIN))) { subscriptions.push(subscription); } expect(subscriptions).to.be.an('array').that.is.not.empty; @@ -29,11 +29,11 @@ describe('Subscription API', () => { it('provides methods for subscribing/unsubscribing to/from notification subscribtion for given user role and notfication type', async () => { let response = await client.unsubscribeRoleSubscriptionByNotificationType(RoleType.ORG_ADMIN, NotificationType.OKTA_UPDATE); - expect(response.status).to.equal(200); + expect(response).to.be.undefined; let subscription = await client.getRoleSubscriptionByNotificationType(RoleType.ORG_ADMIN, NotificationType.OKTA_UPDATE); expect(subscription.status).to.equal(SubscriptionStatus.UNSUBSCRIBED); response = await client.subscribeRoleSubscriptionByNotificationType(RoleType.ORG_ADMIN, NotificationType.OKTA_UPDATE); - expect(response.status).to.equal(200); + expect(response).to.be.undefined; subscription = await client.getRoleSubscriptionByNotificationType(RoleType.ORG_ADMIN, NotificationType.OKTA_UPDATE); expect(subscription.status).to.equal(SubscriptionStatus.SUBSCRIBED); }); diff --git a/test/it/subscription-user.ts b/test/it/subscription-user.ts index defb56efc..967c2c1fe 100644 --- a/test/it/subscription-user.ts +++ b/test/it/subscription-user.ts @@ -1,9 +1,9 @@ import { expect } from 'chai'; -import { Client, NotificationType, Subscription, SubscriptionStatus } from '@okta/okta-sdk-nodejs'; -import utils = require('../utils'); +import { Client, v3 } from '@okta/okta-sdk-nodejs'; let orgUrl = process.env.OKTA_CLIENT_ORGURL; +const orgUser = process.env.ORG_USER; if (process.env.OKTA_USE_MOCK) { orgUrl = `${orgUrl}/subsctiption-user`; @@ -15,45 +15,38 @@ const client = new Client({ }); // User Subscription API endpoints can only be queried by API Token owner -xdescribe('Subscription API', () => { +describe('Subscription API', () => { let user; - const userOptions = { - profile: utils.getMockProfile('subscription-user'), - credentials: { - password: { value: 'Abcd1234#@' } - } - }; - - beforeEach(async () => { - await utils.cleanup(client, userOptions); - user = await client.createUser(userOptions); - }); - afterEach(async () => { - await utils.cleanup(client, userOptions); + before(async () => { + for await (const usr of await client.listUsers({search: `profile.login eq "${orgUser}"`})) { + if (usr.profile.login === orgUser) { + user = usr; + } + } }); it('provides method for listing user\'s notification subscriptions', async () => { - const subscriptions: Subscription[] = []; - for await (const subscription of client.listUserSubscriptions('jd.kuckan+test127@gmail.com')) { + const subscriptions: v3.Subscription[] = []; + for await (const subscription of (await client.listUserSubscriptions(user.id))) { subscriptions.push(subscription); } expect(subscriptions).to.be.an('array').which.is.not.empty; }); it('provides method for fetching notification subscription for given user and notification type', async () => { - const subscription = await client.getUserSubscriptionByNotificationType(user.id, NotificationType.OKTA_ISSUE); - expect(subscription.notificationType).to.equal(NotificationType.OKTA_ISSUE); + const subscription = await client.getUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE'); + expect(subscription.notificationType).to.equal('OKTA_ISSUE'); }); it('provides methods for subscribing/unsubscribing to/from notification subscribtion for given user role and notfication type', async () => { - let response = await client.unsubscribeUserSubscriptionByNotificationType(user.id, NotificationType.OKTA_ISSUE); - expect(response.status).to.equal(200); - let subscription = await client.getUserSubscriptionByNotificationType(user.id, NotificationType.OKTA_ISSUE); - expect(subscription.status).to.equal(SubscriptionStatus.UNSUBSCRIBED); - response = await client.subscribeUserSubscriptionByNotificationType(user.id, NotificationType.OKTA_ISSUE); - expect(response.status).to.equal(200); - subscription = await client.getUserSubscriptionByNotificationType(user.id, NotificationType.OKTA_ISSUE); - expect(subscription.status).to.equal(SubscriptionStatus.SUBSCRIBED); + let response = await client.unsubscribeUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE'); + expect(response).to.be.undefined; + let subscription = await client.getUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE'); + expect(subscription.status).to.equal('unsubscribed'); + response = await client.subscribeUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE'); + expect(response).to.be.undefined; + subscription = await client.getUserSubscriptionByNotificationType(user.id, 'OKTA_ISSUE'); + expect(subscription.status).to.equal('subscribed'); }); }); diff --git a/test/type/subscription-user.ts b/test/type/subscription-user.ts index dbd4cdec0..4bb65720d 100644 --- a/test/type/subscription-user.ts +++ b/test/type/subscription-user.ts @@ -1,14 +1,12 @@ import { expectType } from 'tsd'; -import { Response } from 'node-fetch'; import { Client } from '../../src/types/client'; -import { NotificationType } from '../../src/types/models/NotificationType'; -import { Subscription } from '../../src/types/models/Subscription'; +import { Subscription } from '../../src/types/generated/models/Subscription'; const client = new Client(); (async function () { const { value: subscription } = await (await client.listUserSubscriptions('testAppId')).next(); expectType(subscription!); - expectType(await client.getUserSubscriptionByNotificationType('userId', NotificationType.OKTA_ISSUE)); - expectType(await client.unsubscribeUserSubscriptionByNotificationType('userId', NotificationType.OKTA_ISSUE)); - expectType(await client.subscribeUserSubscriptionByNotificationType('userId', NotificationType.OKTA_ISSUE)); + expectType(await client.getUserSubscriptionByNotificationType('userId', 'OKTA_ISSUE')); + expectType(await client.unsubscribeUserSubscriptionByNotificationType('userId', 'OKTA_ISSUE')); + expectType(await client.subscribeUserSubscriptionByNotificationType('userId', 'OKTA_ISSUE')); }());