diff --git a/.gitignore b/.gitignore index 1eeaa2aa1..d4b938492 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,10 @@ test-reports/ .yalc yalc.lock +src/v3/.swagger-codegen/ +src/v3/.gitignore +src/v3/.npmignore +src/v3/.swagger-codegen-ignore +src/v3/git_push.sh +src/v3/README.md +src/v3/tsconfig.json diff --git a/README.md b/README.md index cb31ab097..9d058b93a 100644 --- a/README.md +++ b/README.md @@ -987,6 +987,14 @@ This version 4.0 release also updated APIs latest `@okta/openapi` (v2.0.0) that Run `yarn build` from repository root. +### Building with swagger-codegen + - Obtain OASv3 combined spec + - Install [swagger-codegen](https://github.com/swagger-api/swagger-codegen/tree/3.0.0#homebrew) + - run `swagger-codegen generate -i ./path/to/specfile.yaml|json -o ./src/v3 -l typescript-axios -t ./templates/swagger-codegen` + - remove APIs and models which are not intended to be pushed to upstream from `src/v3` + - run `./scripts/emitV3Types.sh` to replace TypeScript modules with typings + javascript modules + - commit changes + ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) if you would like to propose changes to this library. diff --git a/scripts/emitV3Types.sh b/scripts/emitV3Types.sh new file mode 100755 index 000000000..30ec06a3b --- /dev/null +++ b/scripts/emitV3Types.sh @@ -0,0 +1,3 @@ +tsc src/v3/**/*.ts --declaration +rsync -r src/v3/**/*.d.ts src/types/v3 +find src/v3/ -type f ! -name "*.js" -delete diff --git a/src/configuration.js b/src/configuration.js new file mode 100644 index 000000000..f6af78bcb --- /dev/null +++ b/src/configuration.js @@ -0,0 +1,2 @@ +// no js code for V2Configuration, it is only used as a type in TypeScript modules +module.exports = {}; diff --git a/src/index.js b/src/index.js index e6a6cd91a..30d537688 100644 --- a/src/index.js +++ b/src/index.js @@ -18,5 +18,6 @@ module.exports = Object.assign( DefaultRequestExecutor: require('./default-request-executor'), Collection: require('./collection'), }, - require('./models') + require('./models'), + require('./v3') ); diff --git a/src/types/client.d.ts b/src/types/client.d.ts index 8b5d1ee02..0c741a562 100644 --- a/src/types/client.d.ts +++ b/src/types/client.d.ts @@ -14,24 +14,10 @@ import { ParameterizedOperationsClient } from './parameterized-operations-client import { OAuth } from './oauth'; import { Http } from './http'; import { RequestExecutor } from './request-executor'; -import { defaultCacheMiddleware } from './default-cache-middleware'; -import { CacheStorage } from './memory-store'; - +import { V2Configuration } from './configuration'; export declare class Client extends ParameterizedOperationsClient { - constructor(config?: { - orgUrl?: string, - token?: string, - clientId?: string, - scopes?: string[], - requestExecutor?: RequestExecutor, - authorizationMode?: string, - privateKey?: string | Record - cacheStore?: CacheStorage, - cacheMiddleware?: typeof defaultCacheMiddleware | unknown - defaultCacheMiddlewareResponseBufferSize?: number, - httpsProxy?: string | unknown, // https://github.com/TooTallNate/node-agent-base/issues/56 - }); + constructor(config?: V2Configuration); requestExecutor: RequestExecutor; authorizationMode: string; diff --git a/src/types/config-loader.d.ts b/src/types/config-loader.d.ts index 0b30a473c..2481df6d6 100644 --- a/src/types/config-loader.d.ts +++ b/src/types/config-loader.d.ts @@ -19,7 +19,8 @@ export declare class ConfigLoader { token: string; clientId: string; scopes: string; - privateKey: string; + privateKey?: string; + userAgent?: string; }; }; applyDefaults(): void; diff --git a/src/types/configuration.d.ts b/src/types/configuration.d.ts new file mode 100644 index 000000000..14a90b137 --- /dev/null +++ b/src/types/configuration.d.ts @@ -0,0 +1,15 @@ +import { defaultCacheMiddleware } from './default-cache-middleware'; +import { RequestExecutor } from './request-executor'; + +export declare interface V2Configuration { + orgUrl?: string, + token?: string, + clientId?: string, + scopes?: string[], + requestExecutor?: RequestExecutor, + authorizationMode?: string, + privateKey?: string | Record + cacheStore?: CacheStorage, + cacheMiddleware?: typeof defaultCacheMiddleware | unknown + defaultCacheMiddlewareResponseBufferSize?: number, +} diff --git a/src/types/http.d.ts b/src/types/http.d.ts index 5c4aff326..f038ccc14 100644 --- a/src/types/http.d.ts +++ b/src/types/http.d.ts @@ -29,7 +29,8 @@ export declare class Http { oauth: OAuth, cacheStore?: CacheStorage, cacheMiddleware?: typeof defaultCacheMiddleware | unknown, - httpsProxy?: string | unknown, // https://github.com/TooTallNate/node-agent-base/issues/56 + httpsProxy?: string | unknown, // https://github.com/TooTallNate/node-agent-base/issues/56, + defaultCacheMiddlewareResponseBufferSize?: number, }); defaultHeaders: Record; requestExecutor: RequestExecutor; diff --git a/src/types/index.d.ts b/src/types/index.d.ts index a88b1fad0..4ef5e4166 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -28,6 +28,7 @@ export * from './request-options/SecurePasswordStoreApplicationOptions'; export * from './request-options/SwaApplicationOptions'; export * from './request-options/SwaThreeFieldApplicationOptions'; export * from './request-options/WsFederationApplicationOptions'; +export * from './v3'; export * from './models/AccessPolicy'; export * from './models/AccessPolicyConstraint'; diff --git a/src/types/request-options/SecurePasswordStoreApplicationOptions.d.ts b/src/types/request-options/SecurePasswordStoreApplicationOptions.d.ts index 7c7318306..2ff623e19 100644 --- a/src/types/request-options/SecurePasswordStoreApplicationOptions.d.ts +++ b/src/types/request-options/SecurePasswordStoreApplicationOptions.d.ts @@ -33,4 +33,3 @@ declare interface SecurePasswordStoreApplicationOptions { export { SecurePasswordStoreApplicationOptions }; - diff --git a/src/types/v3/api.d.ts b/src/types/v3/api.d.ts new file mode 100644 index 000000000..2f2e44752 --- /dev/null +++ b/src/types/v3/api.d.ts @@ -0,0 +1,12 @@ +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +export * from './apis/user-type-api'; diff --git a/src/types/v3/apis/user-type-api.d.ts b/src/types/v3/apis/user-type-api.d.ts new file mode 100644 index 000000000..90976af3c --- /dev/null +++ b/src/types/v3/apis/user-type-api.d.ts @@ -0,0 +1,246 @@ +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +import { RequestArgs, BaseAPI } from '../base'; +import { UserType } from '../models'; +import { Response } from 'node-fetch'; +import Http = require('../../http'); +import { V2Configuration } from '../../configuration'; +import { Configuration } from '../configuration'; +/** + * UserTypeApi - request parameter creator + * @export + */ +export declare const UserTypeApiRequestParamCreator: (configuration?: Configuration & V2Configuration) => { + httpClient: any; + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUserType: (body: UserType, options?: any) => Promise; + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUserType: (typeId: string, options?: any) => Promise; + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserType: (typeId: string, options?: any) => Promise; + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserTypes: (options?: any) => Promise; + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + replaceUserType: (body: UserType, typeId: string, options?: any) => Promise; + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUserType: (body: UserType, typeId: string, options?: any) => Promise; +}; +/** + * UserTypeApi - functional programming interface + * @export + */ +export declare const UserTypeApiFp: (configuration?: Configuration & V2Configuration) => { + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUserType(body: UserType, options?: any): Promise<(httpClient?: any, basePath?: string) => Promise>; + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUserType(typeId: string, options?: any): Promise<(httpClient?: any, basePath?: string) => Promise>; + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserType(typeId: string, options?: any): Promise<(httpClient?: any, basePath?: string) => Promise>; + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserTypes(options?: any): Promise<(httpClient?: any, basePath?: string) => Promise>>; + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + replaceUserType(body: UserType, typeId: string, options?: any): Promise<(httpClient?: any, basePath?: string) => Promise>; + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUserType(body: UserType, typeId: string, options?: any): Promise<(httpClient?: any, basePath?: string) => Promise>; +}; +/** + * UserTypeApi - factory interface + * @export + */ +export declare const UserTypeApiFactory: (configuration?: Configuration, basePath?: string, httpClient?: any) => { + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUserType(body: UserType, options?: any): Promise; + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUserType(typeId: string, options?: any): Promise; + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserType(typeId: string, options?: any): Promise; + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserTypes(options?: any): Promise>; + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + replaceUserType(body: UserType, typeId: string, options?: any): Promise; + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUserType(body: UserType, typeId: string, options?: any): Promise; +}; +/** + * UserTypeApi - object-oriented interface + * @export + * @class UserTypeApi + * @extends {BaseAPI} + */ +export declare class UserTypeApi extends BaseAPI { + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + createUserType(body: UserType, options?: any): Promise; + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + deleteUserType(typeId: string, options?: any): Promise; + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + getUserType(typeId: string, options?: any): Promise; + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + listUserTypes(options?: any): Promise; + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + replaceUserType(body: UserType, typeId: string, options?: any): Promise; + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + updateUserType(body: UserType, typeId: string, options?: any): Promise; +} diff --git a/src/types/v3/base.d.ts b/src/types/v3/base.d.ts new file mode 100644 index 000000000..f49f3a9c0 --- /dev/null +++ b/src/types/v3/base.d.ts @@ -0,0 +1,55 @@ +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +import { Configuration } from './configuration'; +import { Http } from '../http'; +export declare const BASE_PATH: string; +/** + * + * @export + */ +export declare const COLLECTION_FORMATS: { + csv: string; + ssv: string; + tsv: string; + pipes: string; +}; +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} +/** + * + * @export + * @class BaseAPI + */ +export declare class BaseAPI { + protected basePath: string; + protected httpClient?: Http; + protected configuration: Configuration | undefined; + constructor(configuration?: Configuration, basePath?: string, httpClient?: Http); +} +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export declare class RequiredError extends Error { + field: string; + name: 'RequiredError'; + constructor(field: string, msg?: string); +} diff --git a/src/types/v3/configuration.d.ts b/src/types/v3/configuration.d.ts new file mode 100644 index 000000000..02e19b30b --- /dev/null +++ b/src/types/v3/configuration.d.ts @@ -0,0 +1,63 @@ +/** + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +export interface ConfigurationParameters { + apiToken?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + baseOptions?: any; +} +export declare class Configuration { + /** + * parameter for apiToken security + * @param name security name + * @memberof Configuration + */ + apiToken?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + constructor(param?: ConfigurationParameters); +} diff --git a/src/types/v3/index.d.ts b/src/types/v3/index.d.ts new file mode 100644 index 000000000..87aeb453d --- /dev/null +++ b/src/types/v3/index.d.ts @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +import * as models from './models'; +import * as apis from './api'; +import * as config from './configuration'; +export declare namespace v3 { + export import model = models; + export import api = apis; + export import configuration = config; +} diff --git a/src/types/v3/models/index.d.ts b/src/types/v3/models/index.d.ts new file mode 100644 index 000000000..576fa1b9c --- /dev/null +++ b/src/types/v3/models/index.d.ts @@ -0,0 +1 @@ +export * from './user-type'; diff --git a/src/types/v3/models/user-type.d.ts b/src/types/v3/models/user-type.d.ts new file mode 100644 index 000000000..68a00f89d --- /dev/null +++ b/src/types/v3/models/user-type.d.ts @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +/** + * + * @export + * @class UserType + */ +export declare class UserType { + /** + * + * @type {{ [key, string]: any;}} + * @memberof UserType + */ + links?: any; + /** + * + * @type {Date} + * @memberof UserType + */ + created?: any; + /** + * + * @type {string} + * @memberof UserType + */ + createdBy?: any; + /** + * + * @type {boolean} + * @memberof UserType + */ + _default?: any; + /** + * + * @type {string} + * @memberof UserType + */ + description?: any; + /** + * + * @type {string} + * @memberof UserType + */ + displayName?: any; + /** + * + * @type {string} + * @memberof UserType + */ + id?: any; + /** + * + * @type {Date} + * @memberof UserType + */ + lastUpdated?: any; + /** + * + * @type {string} + * @memberof UserType + */ + lastUpdatedBy?: any; + /** + * + * @type {string} + * @memberof UserType + */ + name?: any; +} diff --git a/src/v3/.eslintrc b/src/v3/.eslintrc new file mode 100644 index 000000000..705d42acb --- /dev/null +++ b/src/v3/.eslintrc @@ -0,0 +1,11 @@ +{ + "rules": { + "no-use-before-define": [ + "error", + { + "functions": false, + "variables": false + } + ] + } +} diff --git a/src/v3/api.js b/src/v3/api.js new file mode 100644 index 000000000..812594c18 --- /dev/null +++ b/src/v3/api.js @@ -0,0 +1,46 @@ +'use strict'; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { + if (k2 === undefined) { + k2 = k; + } + Object.defineProperty(o, k2, { enumerable: true, get: function () { + return m[k]; + } }); +}) : (function (o, m, k, k2) { + if (k2 === undefined) { + k2 = k; + } + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function (m, exports) { + for (var p in m) { + if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) { + __createBinding(exports, m, p); + } + } +}; +exports.__esModule = true; +/* tslint:disable */ +/* eslint-disable */ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +__exportStar(require("./apis/user-type-api"), exports); diff --git a/src/v3/apis/index.js b/src/v3/apis/index.js new file mode 100644 index 000000000..5bd06d075 --- /dev/null +++ b/src/v3/apis/index.js @@ -0,0 +1,23 @@ +'use strict'; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { + if (k2 === undefined) { + k2 = k; + } + Object.defineProperty(o, k2, { enumerable: true, get: function () { + return m[k]; + } }); +}) : (function (o, m, k, k2) { + if (k2 === undefined) { + k2 = k; + } + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function (m, exports) { + for (var p in m) { + if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) { + __createBinding(exports, m, p); + } + } +}; +exports.__esModule = true; +__exportStar(require('./user-type-api'), exports); diff --git a/src/v3/apis/user-type-api.js b/src/v3/apis/user-type-api.js new file mode 100644 index 000000000..249f5b23d --- /dev/null +++ b/src/v3/apis/user-type-api.js @@ -0,0 +1,963 @@ +'use strict'; +/* tslint:disable */ +/* eslint-disable */ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.UserTypeApi = exports.UserTypeApiFactory = exports.UserTypeApiFp = exports.UserTypeApiRequestParamCreator = void 0; +// Some imports not used depending on template conditions +// @ts-ignore +var base_1 = require("../base"); +var Oauth = require("../../oauth"); +var Http = require("../../http"); +var ConfigLoader = require("../../config-loader"); +var DefaultRequestExecutor = require("../../default-request-executor"); +var os = require('os'); +var packageJson = require('../../../package.json'); +var DEFAULT_USER_AGENT = packageJson.name + "/" + packageJson.version + " node/" + process.versions.node + " " + os.platform() + "/" + os.release(); +var repoUrl = 'https://github.com/okta/okta-sdk-nodejs'; +/** + * UserTypeApi - request parameter creator + * @export + */ +var UserTypeApiRequestParamCreator = function (configuration) { + var _this = this; + var configLoader = new ConfigLoader(); + var clientConfig = Object.assign({}, configuration); + configLoader.applyDefaults(); + configLoader.apply({ + client: clientConfig || {} + }); + var parsedConfig = configLoader.config; + var requestExecutor = clientConfig.requestExecutor || new DefaultRequestExecutor(); + var errors = []; + if (!parsedConfig.client.orgUrl) { + errors.push('Okta Org URL not provided'); + } + if (!parsedConfig.client.token && parsedConfig.client.authorizationMode !== 'PrivateKey') { + errors.push('Okta API token not provided'); + } + if (parsedConfig.client.authorizationMode === 'PrivateKey') { + if (!parsedConfig.client.clientId) { + errors.push('Okta Client ID not provided'); + } + if (!parsedConfig.client.scopes) { + errors.push('Scopes not provided'); + } + if (!parsedConfig.client.privateKey) { + errors.push('Private Key not provided'); + } + } + else if (parsedConfig.client.authorizationMode !== 'SSWS') { + errors.push('Unknown Authorization Mode'); + } + if (errors.length) { + throw new Error("Found " + errors.length + " errors:\n" + errors.join('\n') + "\nSee " + repoUrl + " for usage."); + } + var authorizationMode = parsedConfig.client.authorizationMode; + var baseUrl = parsedConfig.client.orgUrl.replace(/\/$/, ''); + var apiToken = parsedConfig.client.token; + var clientId; + var scopes; + var privateKey; + var oauth; + if (authorizationMode === 'PrivateKey') { + clientId = parsedConfig.client.clientId; + scopes = parsedConfig.client.scopes.split(' '); + privateKey = parsedConfig.client.privateKey; + oauth = new Oauth(this); + } + var httpClient = new Http({ + cacheStore: clientConfig.cacheStore, + cacheMiddleware: clientConfig.cacheMiddleware, + defaultCacheMiddlewareResponseBufferSize: clientConfig.defaultCacheMiddlewareResponseBufferSize, + requestExecutor: requestExecutor, + oauth: oauth + }); + if (authorizationMode === 'SSWS') { + httpClient.defaultHeaders.Authorization = "SSWS " + apiToken; + } + httpClient.defaultHeaders['User-Agent'] = parsedConfig.client.userAgent ? parsedConfig.client.userAgent + ' ' + DEFAULT_USER_AGENT : DEFAULT_USER_AGENT; + return { + httpClient: httpClient, + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUserType: function (body, options) { + if (options === void 0) { options = {}; } + return __awaiter(_this, void 0, void 0, function () { + var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, localVarAccessTokenValue, _b, query, key, key, headersFromBaseOptions, needsSerialization; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new base_1.RequiredError('body', 'Required parameter body was null or undefined when calling createUserType.'); + } + localVarPath = "/api/v1/meta/types/user"; + localVarUrlObj = new URL(localVarPath, 'https://example.com'); + if (configuration) { + baseOptions = configuration.baseOptions; + } + localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options); + localVarHeaderParameter = {}; + localVarQueryParameter = {}; + if (!(configuration && configuration.apiToken)) return [3 /*break*/, 5]; + if (!(typeof configuration.apiToken === 'function')) return [3 /*break*/, 2]; + return [4 /*yield*/, configuration.apiToken("Authorization")]; + case 1: + _a = _c.sent(); + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, configuration.apiToken]; + case 3: + _a = _c.sent(); + _c.label = 4; + case 4: + localVarApiKeyValue = _a; + localVarHeaderParameter["Authorization"] = localVarApiKeyValue; + _c.label = 5; + case 5: + if (!(configuration && configuration.accessToken)) return [3 /*break*/, 10]; + if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 7]; + return [4 /*yield*/, configuration.accessToken("oauth2", ["okta.apps.read", "okta.apps.manage", "okta.authenticators.read", "okta.authenticators.manage", "okta.authorizationServers.read", "okta.authorizationServers.manage", "okta.brands.read", "okta.brands.manage", "okta.captchas.manage", "okta.captchas.read", "okta.domains.read", "okta.domains.manage", "okta.eventHooks.read", "okta.eventHooks.manage", "okta.groups.read", "okta.groups.manage", "okta.roles.read", "okta.roles.manage", "okta.idps.read", "okta.idps.manage", "okta.users.manage", "okta.inlineHooks.read", "okta.inlineHooks.manage", "okta.logs.read", "okta.profileMappings.read", "okta.profileMappings.manage", "okta.schemas.read", "okta.schemas.manage", "okta.linkedObjects.read", "okta.linkedObjects.manage", "okta.userTypes.read", "okta.userTypes.manage", "okta.orgs.read", "okta.orgs.manage", "okta.policies.read", "okta.policies.manage", "okta.sessions.read", "okta.sessions.manage", "okta.templates.read", "okta.templates.manage", "okta.trustedOrigins.read", "okta.trustedOrigins.manage", "okta.users.read.self", "okta.users.read"])]; + case 6: + _b = _c.sent(); + return [3 /*break*/, 9]; + case 7: return [4 /*yield*/, configuration.accessToken]; + case 8: + _b = _c.sent(); + _c.label = 9; + case 9: + localVarAccessTokenValue = _b; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + _c.label = 10; + case 10: + localVarHeaderParameter['Content-Type'] = 'application/json'; + query = new URLSearchParams(localVarUrlObj.search); + for (key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || ""); + return [2 /*return*/, { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions + }]; + } + }); + }); + }, + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUserType: function (typeId, options) { + if (options === void 0) { options = {}; } + return __awaiter(_this, void 0, void 0, function () { + var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, localVarAccessTokenValue, _b, query, key, key, headersFromBaseOptions; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // verify required parameter 'typeId' is not null or undefined + if (typeId === null || typeId === undefined) { + throw new base_1.RequiredError('typeId', 'Required parameter typeId was null or undefined when calling deleteUserType.'); + } + localVarPath = "/api/v1/meta/types/user/{typeId}" + .replace("{" + "typeId" + "}", encodeURIComponent(String(typeId))); + localVarUrlObj = new URL(localVarPath, 'https://example.com'); + if (configuration) { + baseOptions = configuration.baseOptions; + } + localVarRequestOptions = __assign(__assign({ method: 'DELETE' }, baseOptions), options); + localVarHeaderParameter = {}; + localVarQueryParameter = {}; + if (!(configuration && configuration.apiToken)) return [3 /*break*/, 5]; + if (!(typeof configuration.apiToken === 'function')) return [3 /*break*/, 2]; + return [4 /*yield*/, configuration.apiToken("Authorization")]; + case 1: + _a = _c.sent(); + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, configuration.apiToken]; + case 3: + _a = _c.sent(); + _c.label = 4; + case 4: + localVarApiKeyValue = _a; + localVarHeaderParameter["Authorization"] = localVarApiKeyValue; + _c.label = 5; + case 5: + if (!(configuration && configuration.accessToken)) return [3 /*break*/, 10]; + if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 7]; + return [4 /*yield*/, configuration.accessToken("oauth2", ["okta.apps.read", "okta.apps.manage", "okta.authenticators.read", "okta.authenticators.manage", "okta.authorizationServers.read", "okta.authorizationServers.manage", "okta.brands.read", "okta.brands.manage", "okta.captchas.manage", "okta.captchas.read", "okta.domains.read", "okta.domains.manage", "okta.eventHooks.read", "okta.eventHooks.manage", "okta.groups.read", "okta.groups.manage", "okta.roles.read", "okta.roles.manage", "okta.idps.read", "okta.idps.manage", "okta.users.manage", "okta.inlineHooks.read", "okta.inlineHooks.manage", "okta.logs.read", "okta.profileMappings.read", "okta.profileMappings.manage", "okta.schemas.read", "okta.schemas.manage", "okta.linkedObjects.read", "okta.linkedObjects.manage", "okta.userTypes.read", "okta.userTypes.manage", "okta.orgs.read", "okta.orgs.manage", "okta.policies.read", "okta.policies.manage", "okta.sessions.read", "okta.sessions.manage", "okta.templates.read", "okta.templates.manage", "okta.trustedOrigins.read", "okta.trustedOrigins.manage", "okta.users.read.self", "okta.users.read"])]; + case 6: + _b = _c.sent(); + return [3 /*break*/, 9]; + case 7: return [4 /*yield*/, configuration.accessToken]; + case 8: + _b = _c.sent(); + _c.label = 9; + case 9: + localVarAccessTokenValue = _b; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + _c.label = 10; + case 10: + query = new URLSearchParams(localVarUrlObj.search); + for (key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + return [2 /*return*/, { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions + }]; + } + }); + }); + }, + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserType: function (typeId, options) { + if (options === void 0) { options = {}; } + return __awaiter(_this, void 0, void 0, function () { + var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, localVarAccessTokenValue, _b, query, key, key, headersFromBaseOptions; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // verify required parameter 'typeId' is not null or undefined + if (typeId === null || typeId === undefined) { + throw new base_1.RequiredError('typeId', 'Required parameter typeId was null or undefined when calling getUserType.'); + } + localVarPath = "/api/v1/meta/types/user/{typeId}" + .replace("{" + "typeId" + "}", encodeURIComponent(String(typeId))); + localVarUrlObj = new URL(localVarPath, 'https://example.com'); + if (configuration) { + baseOptions = configuration.baseOptions; + } + localVarRequestOptions = __assign(__assign({ method: 'GET' }, baseOptions), options); + localVarHeaderParameter = {}; + localVarQueryParameter = {}; + if (!(configuration && configuration.apiToken)) return [3 /*break*/, 5]; + if (!(typeof configuration.apiToken === 'function')) return [3 /*break*/, 2]; + return [4 /*yield*/, configuration.apiToken("Authorization")]; + case 1: + _a = _c.sent(); + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, configuration.apiToken]; + case 3: + _a = _c.sent(); + _c.label = 4; + case 4: + localVarApiKeyValue = _a; + localVarHeaderParameter["Authorization"] = localVarApiKeyValue; + _c.label = 5; + case 5: + if (!(configuration && configuration.accessToken)) return [3 /*break*/, 10]; + if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 7]; + return [4 /*yield*/, configuration.accessToken("oauth2", ["okta.apps.read", "okta.apps.manage", "okta.authenticators.read", "okta.authenticators.manage", "okta.authorizationServers.read", "okta.authorizationServers.manage", "okta.brands.read", "okta.brands.manage", "okta.captchas.manage", "okta.captchas.read", "okta.domains.read", "okta.domains.manage", "okta.eventHooks.read", "okta.eventHooks.manage", "okta.groups.read", "okta.groups.manage", "okta.roles.read", "okta.roles.manage", "okta.idps.read", "okta.idps.manage", "okta.users.manage", "okta.inlineHooks.read", "okta.inlineHooks.manage", "okta.logs.read", "okta.profileMappings.read", "okta.profileMappings.manage", "okta.schemas.read", "okta.schemas.manage", "okta.linkedObjects.read", "okta.linkedObjects.manage", "okta.userTypes.read", "okta.userTypes.manage", "okta.orgs.read", "okta.orgs.manage", "okta.policies.read", "okta.policies.manage", "okta.sessions.read", "okta.sessions.manage", "okta.templates.read", "okta.templates.manage", "okta.trustedOrigins.read", "okta.trustedOrigins.manage", "okta.users.read.self", "okta.users.read"])]; + case 6: + _b = _c.sent(); + return [3 /*break*/, 9]; + case 7: return [4 /*yield*/, configuration.accessToken]; + case 8: + _b = _c.sent(); + _c.label = 9; + case 9: + localVarAccessTokenValue = _b; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + _c.label = 10; + case 10: + query = new URLSearchParams(localVarUrlObj.search); + for (key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + return [2 /*return*/, { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions + }]; + } + }); + }); + }, + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserTypes: function (options) { + if (options === void 0) { options = {}; } + return __awaiter(_this, void 0, void 0, function () { + var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, localVarAccessTokenValue, _b, query, key, key, headersFromBaseOptions; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + localVarPath = "/api/v1/meta/types/user"; + localVarUrlObj = new URL(localVarPath, 'https://example.com'); + if (configuration) { + baseOptions = configuration.baseOptions; + } + localVarRequestOptions = __assign(__assign({ method: 'GET' }, baseOptions), options); + localVarHeaderParameter = {}; + localVarQueryParameter = {}; + if (!(configuration && configuration.apiToken)) return [3 /*break*/, 5]; + if (!(typeof configuration.apiToken === 'function')) return [3 /*break*/, 2]; + return [4 /*yield*/, configuration.apiToken("Authorization")]; + case 1: + _a = _c.sent(); + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, configuration.apiToken]; + case 3: + _a = _c.sent(); + _c.label = 4; + case 4: + localVarApiKeyValue = _a; + localVarHeaderParameter["Authorization"] = localVarApiKeyValue; + _c.label = 5; + case 5: + if (!(configuration && configuration.accessToken)) return [3 /*break*/, 10]; + if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 7]; + return [4 /*yield*/, configuration.accessToken("oauth2", ["okta.apps.read", "okta.apps.manage", "okta.authenticators.read", "okta.authenticators.manage", "okta.authorizationServers.read", "okta.authorizationServers.manage", "okta.brands.read", "okta.brands.manage", "okta.captchas.manage", "okta.captchas.read", "okta.domains.read", "okta.domains.manage", "okta.eventHooks.read", "okta.eventHooks.manage", "okta.groups.read", "okta.groups.manage", "okta.roles.read", "okta.roles.manage", "okta.idps.read", "okta.idps.manage", "okta.users.manage", "okta.inlineHooks.read", "okta.inlineHooks.manage", "okta.logs.read", "okta.profileMappings.read", "okta.profileMappings.manage", "okta.schemas.read", "okta.schemas.manage", "okta.linkedObjects.read", "okta.linkedObjects.manage", "okta.userTypes.read", "okta.userTypes.manage", "okta.orgs.read", "okta.orgs.manage", "okta.policies.read", "okta.policies.manage", "okta.sessions.read", "okta.sessions.manage", "okta.templates.read", "okta.templates.manage", "okta.trustedOrigins.read", "okta.trustedOrigins.manage", "okta.users.read.self", "okta.users.read"])]; + case 6: + _b = _c.sent(); + return [3 /*break*/, 9]; + case 7: return [4 /*yield*/, configuration.accessToken]; + case 8: + _b = _c.sent(); + _c.label = 9; + case 9: + localVarAccessTokenValue = _b; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + _c.label = 10; + case 10: + query = new URLSearchParams(localVarUrlObj.search); + for (key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + return [2 /*return*/, { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions + }]; + } + }); + }); + }, + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + replaceUserType: function (body, typeId, options) { + if (options === void 0) { options = {}; } + return __awaiter(_this, void 0, void 0, function () { + var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, localVarAccessTokenValue, _b, query, key, key, headersFromBaseOptions, needsSerialization; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new base_1.RequiredError('body', 'Required parameter body was null or undefined when calling replaceUserType.'); + } + // verify required parameter 'typeId' is not null or undefined + if (typeId === null || typeId === undefined) { + throw new base_1.RequiredError('typeId', 'Required parameter typeId was null or undefined when calling replaceUserType.'); + } + localVarPath = "/api/v1/meta/types/user/{typeId}" + .replace("{" + "typeId" + "}", encodeURIComponent(String(typeId))); + localVarUrlObj = new URL(localVarPath, 'https://example.com'); + if (configuration) { + baseOptions = configuration.baseOptions; + } + localVarRequestOptions = __assign(__assign({ method: 'PUT' }, baseOptions), options); + localVarHeaderParameter = {}; + localVarQueryParameter = {}; + if (!(configuration && configuration.apiToken)) return [3 /*break*/, 5]; + if (!(typeof configuration.apiToken === 'function')) return [3 /*break*/, 2]; + return [4 /*yield*/, configuration.apiToken("Authorization")]; + case 1: + _a = _c.sent(); + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, configuration.apiToken]; + case 3: + _a = _c.sent(); + _c.label = 4; + case 4: + localVarApiKeyValue = _a; + localVarHeaderParameter["Authorization"] = localVarApiKeyValue; + _c.label = 5; + case 5: + if (!(configuration && configuration.accessToken)) return [3 /*break*/, 10]; + if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 7]; + return [4 /*yield*/, configuration.accessToken("oauth2", ["okta.apps.read", "okta.apps.manage", "okta.authenticators.read", "okta.authenticators.manage", "okta.authorizationServers.read", "okta.authorizationServers.manage", "okta.brands.read", "okta.brands.manage", "okta.captchas.manage", "okta.captchas.read", "okta.domains.read", "okta.domains.manage", "okta.eventHooks.read", "okta.eventHooks.manage", "okta.groups.read", "okta.groups.manage", "okta.roles.read", "okta.roles.manage", "okta.idps.read", "okta.idps.manage", "okta.users.manage", "okta.inlineHooks.read", "okta.inlineHooks.manage", "okta.logs.read", "okta.profileMappings.read", "okta.profileMappings.manage", "okta.schemas.read", "okta.schemas.manage", "okta.linkedObjects.read", "okta.linkedObjects.manage", "okta.userTypes.read", "okta.userTypes.manage", "okta.orgs.read", "okta.orgs.manage", "okta.policies.read", "okta.policies.manage", "okta.sessions.read", "okta.sessions.manage", "okta.templates.read", "okta.templates.manage", "okta.trustedOrigins.read", "okta.trustedOrigins.manage", "okta.users.read.self", "okta.users.read"])]; + case 6: + _b = _c.sent(); + return [3 /*break*/, 9]; + case 7: return [4 /*yield*/, configuration.accessToken]; + case 8: + _b = _c.sent(); + _c.label = 9; + case 9: + localVarAccessTokenValue = _b; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + _c.label = 10; + case 10: + localVarHeaderParameter['Content-Type'] = 'application/json'; + query = new URLSearchParams(localVarUrlObj.search); + for (key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || ""); + return [2 /*return*/, { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions + }]; + } + }); + }); + }, + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUserType: function (body, typeId, options) { + if (options === void 0) { options = {}; } + return __awaiter(_this, void 0, void 0, function () { + var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, localVarAccessTokenValue, _b, query, key, key, headersFromBaseOptions, needsSerialization; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new base_1.RequiredError('body', 'Required parameter body was null or undefined when calling updateUserType.'); + } + // verify required parameter 'typeId' is not null or undefined + if (typeId === null || typeId === undefined) { + throw new base_1.RequiredError('typeId', 'Required parameter typeId was null or undefined when calling updateUserType.'); + } + localVarPath = "/api/v1/meta/types/user/{typeId}" + .replace("{" + "typeId" + "}", encodeURIComponent(String(typeId))); + localVarUrlObj = new URL(localVarPath, 'https://example.com'); + if (configuration) { + baseOptions = configuration.baseOptions; + } + localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options); + localVarHeaderParameter = {}; + localVarQueryParameter = {}; + if (!(configuration && configuration.apiToken)) return [3 /*break*/, 5]; + if (!(typeof configuration.apiToken === 'function')) return [3 /*break*/, 2]; + return [4 /*yield*/, configuration.apiToken("Authorization")]; + case 1: + _a = _c.sent(); + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, configuration.apiToken]; + case 3: + _a = _c.sent(); + _c.label = 4; + case 4: + localVarApiKeyValue = _a; + localVarHeaderParameter["Authorization"] = localVarApiKeyValue; + _c.label = 5; + case 5: + if (!(configuration && configuration.accessToken)) return [3 /*break*/, 10]; + if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 7]; + return [4 /*yield*/, configuration.accessToken("oauth2", ["okta.apps.read", "okta.apps.manage", "okta.authenticators.read", "okta.authenticators.manage", "okta.authorizationServers.read", "okta.authorizationServers.manage", "okta.brands.read", "okta.brands.manage", "okta.captchas.manage", "okta.captchas.read", "okta.domains.read", "okta.domains.manage", "okta.eventHooks.read", "okta.eventHooks.manage", "okta.groups.read", "okta.groups.manage", "okta.roles.read", "okta.roles.manage", "okta.idps.read", "okta.idps.manage", "okta.users.manage", "okta.inlineHooks.read", "okta.inlineHooks.manage", "okta.logs.read", "okta.profileMappings.read", "okta.profileMappings.manage", "okta.schemas.read", "okta.schemas.manage", "okta.linkedObjects.read", "okta.linkedObjects.manage", "okta.userTypes.read", "okta.userTypes.manage", "okta.orgs.read", "okta.orgs.manage", "okta.policies.read", "okta.policies.manage", "okta.sessions.read", "okta.sessions.manage", "okta.templates.read", "okta.templates.manage", "okta.trustedOrigins.read", "okta.trustedOrigins.manage", "okta.users.read.self", "okta.users.read"])]; + case 6: + _b = _c.sent(); + return [3 /*break*/, 9]; + case 7: return [4 /*yield*/, configuration.accessToken]; + case 8: + _b = _c.sent(); + _c.label = 9; + case 9: + localVarAccessTokenValue = _b; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + _c.label = 10; + case 10: + localVarHeaderParameter['Content-Type'] = 'application/json'; + query = new URLSearchParams(localVarUrlObj.search); + for (key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || ""); + return [2 /*return*/, { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions + }]; + } + }); + }); + } + }; +}; +exports.UserTypeApiRequestParamCreator = UserTypeApiRequestParamCreator; +/** + * UserTypeApi - functional programming interface + * @export + */ +var UserTypeApiFp = function (configuration) { + return { + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUserType: function (body, options) { + return __awaiter(this, void 0, void 0, function () { + var api, localVarRequestArgs; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + api = (0, exports.UserTypeApiRequestParamCreator)(configuration); + return [4 /*yield*/, api.createUserType(body, options)]; + case 1: + localVarRequestArgs = _a.sent(); + return [2 /*return*/, function (httpClient, basePath) { + if (httpClient === void 0) { httpClient = api.httpClient; } + if (basePath === void 0) { basePath = configuration.basePath || configuration.orgUrl; } + var requestArgs = __assign(__assign({}, localVarRequestArgs.options), { url: basePath + localVarRequestArgs.url }); + return httpClient.http(requestArgs.url, requestArgs).then(function (res) { return res.json(); }); + }]; + } + }); + }); + }, + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUserType: function (typeId, options) { + return __awaiter(this, void 0, void 0, function () { + var api, localVarRequestArgs; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + api = (0, exports.UserTypeApiRequestParamCreator)(configuration); + return [4 /*yield*/, api.deleteUserType(typeId, options)]; + case 1: + localVarRequestArgs = _a.sent(); + return [2 /*return*/, function (httpClient, basePath) { + if (httpClient === void 0) { httpClient = api.httpClient; } + if (basePath === void 0) { basePath = configuration.basePath || configuration.orgUrl; } + var requestArgs = __assign(__assign({}, localVarRequestArgs.options), { url: basePath + localVarRequestArgs.url }); + return httpClient.http(requestArgs.url, requestArgs); + }]; + } + }); + }); + }, + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserType: function (typeId, options) { + return __awaiter(this, void 0, void 0, function () { + var api, localVarRequestArgs; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + api = (0, exports.UserTypeApiRequestParamCreator)(configuration); + return [4 /*yield*/, api.getUserType(typeId, options)]; + case 1: + localVarRequestArgs = _a.sent(); + return [2 /*return*/, function (httpClient, basePath) { + if (httpClient === void 0) { httpClient = api.httpClient; } + if (basePath === void 0) { basePath = configuration.basePath || configuration.orgUrl; } + var requestArgs = __assign(__assign({}, localVarRequestArgs.options), { url: basePath + localVarRequestArgs.url }); + return httpClient.http(requestArgs.url, requestArgs).then(function (res) { return res.json(); }); + }]; + } + }); + }); + }, + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserTypes: function (options) { + return __awaiter(this, void 0, void 0, function () { + var api, localVarRequestArgs; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + api = (0, exports.UserTypeApiRequestParamCreator)(configuration); + return [4 /*yield*/, api.listUserTypes(options)]; + case 1: + localVarRequestArgs = _a.sent(); + return [2 /*return*/, function (httpClient, basePath) { + if (httpClient === void 0) { httpClient = api.httpClient; } + if (basePath === void 0) { basePath = configuration.basePath || configuration.orgUrl; } + var requestArgs = __assign(__assign({}, localVarRequestArgs.options), { url: basePath + localVarRequestArgs.url }); + return httpClient.http(requestArgs.url, requestArgs).then(function (res) { return res.json(); }); + }]; + } + }); + }); + }, + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + replaceUserType: function (body, typeId, options) { + return __awaiter(this, void 0, void 0, function () { + var api, localVarRequestArgs; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + api = (0, exports.UserTypeApiRequestParamCreator)(configuration); + return [4 /*yield*/, api.replaceUserType(body, typeId, options)]; + case 1: + localVarRequestArgs = _a.sent(); + return [2 /*return*/, function (httpClient, basePath) { + if (httpClient === void 0) { httpClient = api.httpClient; } + if (basePath === void 0) { basePath = configuration.basePath || configuration.orgUrl; } + var requestArgs = __assign(__assign({}, localVarRequestArgs.options), { url: basePath + localVarRequestArgs.url }); + return httpClient.http(requestArgs.url, requestArgs).then(function (res) { return res.json(); }); + }]; + } + }); + }); + }, + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUserType: function (body, typeId, options) { + return __awaiter(this, void 0, void 0, function () { + var api, localVarRequestArgs; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + api = (0, exports.UserTypeApiRequestParamCreator)(configuration); + return [4 /*yield*/, api.updateUserType(body, typeId, options)]; + case 1: + localVarRequestArgs = _a.sent(); + return [2 /*return*/, function (httpClient, basePath) { + if (httpClient === void 0) { httpClient = api.httpClient; } + if (basePath === void 0) { basePath = configuration.basePath || configuration.orgUrl; } + var requestArgs = __assign(__assign({}, localVarRequestArgs.options), { url: basePath + localVarRequestArgs.url }); + return httpClient.http(requestArgs.url, requestArgs).then(function (res) { return res.json(); }); + }]; + } + }); + }); + } + }; +}; +exports.UserTypeApiFp = UserTypeApiFp; +/** + * UserTypeApi - factory interface + * @export + */ +var UserTypeApiFactory = function (configuration, basePath, httpClient) { + return { + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createUserType: function (body, options) { + return (0, exports.UserTypeApiFp)(configuration).createUserType(body, options).then(function (request) { return request(httpClient, basePath); }); + }, + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteUserType: function (typeId, options) { + return (0, exports.UserTypeApiFp)(configuration).deleteUserType(typeId, options).then(function (request) { return request(httpClient, basePath); }); + }, + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getUserType: function (typeId, options) { + return (0, exports.UserTypeApiFp)(configuration).getUserType(typeId, options).then(function (request) { return request(httpClient, basePath); }); + }, + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listUserTypes: function (options) { + return (0, exports.UserTypeApiFp)(configuration).listUserTypes(options).then(function (request) { return request(httpClient, basePath); }); + }, + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + replaceUserType: function (body, typeId, options) { + return (0, exports.UserTypeApiFp)(configuration).replaceUserType(body, typeId, options).then(function (request) { return request(httpClient, basePath); }); + }, + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + updateUserType: function (body, typeId, options) { + return (0, exports.UserTypeApiFp)(configuration).updateUserType(body, typeId, options).then(function (request) { return request(httpClient, basePath); }); + } + }; +}; +exports.UserTypeApiFactory = UserTypeApiFactory; +/** + * UserTypeApi - object-oriented interface + * @export + * @class UserTypeApi + * @extends {BaseAPI} + */ +var UserTypeApi = /** @class */ (function (_super) { + __extends(UserTypeApi, _super); + function UserTypeApi() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Creates a new User Type. A default User Type is automatically created along with your org, and you may add another 9 User Types for a maximum of 10. + * @summary Create User Type + * @param {UserType} body + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + UserTypeApi.prototype.createUserType = function (body, options) { + var _this = this; + var api = (0, exports.UserTypeApiRequestParamCreator)(this.configuration); + return (0, exports.UserTypeApiFp)(this.configuration).createUserType(body, options).then(function (request) { return request(api.httpClient, _this.basePath); }); + }; + /** + * Deletes a User Type permanently. This operation is not permitted for the default type, nor for any User Type that has existing users + * @summary Delete User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + UserTypeApi.prototype.deleteUserType = function (typeId, options) { + var _this = this; + var api = (0, exports.UserTypeApiRequestParamCreator)(this.configuration); + return (0, exports.UserTypeApiFp)(this.configuration).deleteUserType(typeId, options).then(function (request) { return request(api.httpClient, _this.basePath); }); + }; + /** + * Fetches a User Type by ID. The special identifier `default` may be used to fetch the default User Type. + * @summary Get User Type + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + UserTypeApi.prototype.getUserType = function (typeId, options) { + var _this = this; + var api = (0, exports.UserTypeApiRequestParamCreator)(this.configuration); + return (0, exports.UserTypeApiFp)(this.configuration).getUserType(typeId, options).then(function (request) { return request(api.httpClient, _this.basePath); }); + }; + /** + * Fetches all User Types in your org + * @summary List User Types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + UserTypeApi.prototype.listUserTypes = function (options) { + var _this = this; + var api = (0, exports.UserTypeApiRequestParamCreator)(this.configuration); + return (0, exports.UserTypeApiFp)(this.configuration).listUserTypes(options).then(function (request) { return request(api.httpClient, _this.basePath); }); + }; + /** + * Replace an existing User Type + * @summary Replace User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + UserTypeApi.prototype.replaceUserType = function (body, typeId, options) { + var _this = this; + var api = (0, exports.UserTypeApiRequestParamCreator)(this.configuration); + return (0, exports.UserTypeApiFp)(this.configuration).replaceUserType(body, typeId, options).then(function (request) { return request(api.httpClient, _this.basePath); }); + }; + /** + * Updates an existing User Type + * @summary Update User Type + * @param {UserType} body + * @param {string} typeId + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserTypeApi + */ + UserTypeApi.prototype.updateUserType = function (body, typeId, options) { + var _this = this; + var api = (0, exports.UserTypeApiRequestParamCreator)(this.configuration); + return (0, exports.UserTypeApiFp)(this.configuration).updateUserType(body, typeId, options).then(function (request) { return request(api.httpClient, _this.basePath); }); + }; + return UserTypeApi; +}(base_1.BaseAPI)); +exports.UserTypeApi = UserTypeApi; diff --git a/src/v3/base.js b/src/v3/base.js new file mode 100644 index 000000000..7c2b4c397 --- /dev/null +++ b/src/v3/base.js @@ -0,0 +1,90 @@ +'use strict'; +/* tslint:disable */ +/* eslint-disable */ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0; +// Some imports not used depending on template conditions +// @ts-ignore +exports.BASE_PATH = "https://{subdomain}.{domain}".replace(/\/+$/, ""); +/** + * + * @export + */ +exports.COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|" +}; +/** + * + * @export + * @class BaseAPI + */ +var BaseAPI = /** @class */ (function () { + function BaseAPI(configuration, basePath, httpClient) { + if (basePath === void 0) { basePath = exports.BASE_PATH; } + this.basePath = basePath; + this.httpClient = httpClient; + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } + return BaseAPI; +}()); +exports.BaseAPI = BaseAPI; +; +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +var RequiredError = /** @class */ (function (_super) { + __extends(RequiredError, _super); + function RequiredError(field, msg) { + var _this = _super.call(this, msg) || this; + _this.field = field; + _this.name = "RequiredError"; + return _this; + } + return RequiredError; +}(Error)); +exports.RequiredError = RequiredError; diff --git a/src/v3/configuration.js b/src/v3/configuration.js new file mode 100644 index 000000000..72af7eb81 --- /dev/null +++ b/src/v3/configuration.js @@ -0,0 +1,39 @@ +'use strict'; +/* tslint:disable */ +/* eslint-disable */ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +exports.__esModule = true; +exports.Configuration = void 0; +var Configuration = /** @class */ (function () { + function Configuration(param) { + if (param === void 0) { param = {}; } + this.apiToken = param.apiToken; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.baseOptions = param.baseOptions; + } + return Configuration; +}()); +exports.Configuration = Configuration; diff --git a/src/v3/index.js b/src/v3/index.js new file mode 100644 index 000000000..6d2ec89fc --- /dev/null +++ b/src/v3/index.js @@ -0,0 +1,35 @@ +'use strict'; +/* tslint:disable */ +/* eslint-disable */ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +exports.__esModule = true; +exports.v3 = void 0; +var models = require("./models"); +var apis = require("./api"); +var config = require("./configuration"); +var v3; +(function (v3) { + v3.model = models; + v3.api = apis; + v3.configuration = config; +})(v3 = exports.v3 || (exports.v3 = {})); diff --git a/src/v3/models/index.js b/src/v3/models/index.js new file mode 100644 index 000000000..dfb61e4b2 --- /dev/null +++ b/src/v3/models/index.js @@ -0,0 +1,23 @@ +'use strict'; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { + if (k2 === undefined) { + k2 = k; + } + Object.defineProperty(o, k2, { enumerable: true, get: function () { + return m[k]; + } }); +}) : (function (o, m, k, k2) { + if (k2 === undefined) { + k2 = k; + } + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function (m, exports) { + for (var p in m) { + if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) { + __createBinding(exports, m, p); + } + } +}; +exports.__esModule = true; +__exportStar(require('./user-type'), exports); diff --git a/src/v3/models/user-type.js b/src/v3/models/user-type.js new file mode 100644 index 000000000..e8f6da4ce --- /dev/null +++ b/src/v3/models/user-type.js @@ -0,0 +1,37 @@ +'use strict'; +/* tslint:disable */ +/* eslint-disable */ +/** + * Copyright (c) 2022-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. + * + * Okta API + * Allows customers to easily access the Okta API + * + * OpenAPI spec version: 2.10.0 + * Contact: devex-public@okta.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +exports.__esModule = true; +exports.UserType = void 0; +/** + * + * @export + * @class UserType + */ +var UserType = /** @class */ (function () { + function UserType() { + } + return UserType; +}()); +exports.UserType = UserType; diff --git a/templates/codegen-config.json b/templates/codegen-config.json new file mode 100644 index 000000000..c10ba9ea1 --- /dev/null +++ b/templates/codegen-config.json @@ -0,0 +1,5 @@ +{ + "additionalProperties": { + "supportsES6": true + } +} \ No newline at end of file diff --git a/templates/swagger-codegen/api.mustache b/templates/swagger-codegen/api.mustache new file mode 100644 index 000000000..281cd9332 --- /dev/null +++ b/templates/swagger-codegen/api.mustache @@ -0,0 +1,12 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +{{#apiInfo}} +{{#apis}} +{{#operations}} +export * from './{{tsApiPackage}}/{{classFilename}}'; +{{/operations}} +{{/apis}} +{{/apiInfo}} + diff --git a/templates/swagger-codegen/apiInner.mustache b/templates/swagger-codegen/apiInner.mustache new file mode 100644 index 000000000..aeb19d3d4 --- /dev/null +++ b/templates/swagger-codegen/apiInner.mustache @@ -0,0 +1,424 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +// Some imports not used depending on template conditions +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '{{apiRelativeToRoot}}base'; +{{#imports}} +import { {{import}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}'; +import { Response } from 'node-fetch'; +import Oauth = require('../../oauth'); +import Http = require('../../http'); +import ConfigLoader = require('../../config-loader'); +import DefaultRequestExecutor = require('../../default-request-executor'); +import { V2Configuration } from '../../configuration'; +import { Configuration } from '{{apiRelativeToRoot}}configuration'; + + +const os = require('os'); +const packageJson = require('../../../package.json'); + +const DEFAULT_USER_AGENT = `${packageJson.name}/${packageJson.version} node/${process.versions.node} ${os.platform()}/${os.release()}`; + +const repoUrl = 'https://github.com/okta/okta-sdk-nodejs'; + +{{/imports}} +{{#operations}} + +/** + * {{classname}} - request parameter creator{{#description}} + * {{&description}}{{/description}} + * @export + */ +export const {{classname}}RequestParamCreator = function (configuration?: Configuration & V2Configuration) { + const configLoader = new ConfigLoader(); + const clientConfig = Object.assign({}, configuration); + configLoader.applyDefaults(); + configLoader.apply({ + client: clientConfig || {} + }); + + const parsedConfig = configLoader.config; + const requestExecutor = clientConfig.requestExecutor || new DefaultRequestExecutor(); + const errors = []; + if (!parsedConfig.client.orgUrl) { + errors.push('Okta Org URL not provided'); + } + + if (!parsedConfig.client.token && parsedConfig.client.authorizationMode !== 'PrivateKey') { + errors.push('Okta API token not provided'); + } + + if (parsedConfig.client.authorizationMode === 'PrivateKey') { + if (!parsedConfig.client.clientId) { + errors.push('Okta Client ID not provided'); + } + if (!parsedConfig.client.scopes) { + errors.push('Scopes not provided'); + } + if (!parsedConfig.client.privateKey) { + errors.push('Private Key not provided'); + } + } else if (parsedConfig.client.authorizationMode !== 'SSWS') { + errors.push('Unknown Authorization Mode'); + } + if (errors.length) { + throw new Error(`Found ${errors.length} errors:\n${errors.join('\n')}\nSee ${repoUrl} for usage.`); + } + const authorizationMode = parsedConfig.client.authorizationMode; + const baseUrl = parsedConfig.client.orgUrl.replace(/\/$/, ''); + const apiToken = parsedConfig.client.token; + + let clientId; + let scopes; + let privateKey; + let oauth; + if (authorizationMode === 'PrivateKey') { + clientId = parsedConfig.client.clientId; + scopes = parsedConfig.client.scopes.split(' '); + privateKey = parsedConfig.client.privateKey; + oauth = new Oauth(this); + } + + const httpClient = new Http({ + cacheStore: clientConfig.cacheStore, + cacheMiddleware: clientConfig.cacheMiddleware, + defaultCacheMiddlewareResponseBufferSize: clientConfig.defaultCacheMiddlewareResponseBufferSize, + requestExecutor: requestExecutor, + oauth: oauth + }); + if (authorizationMode === 'SSWS') { + httpClient.defaultHeaders.Authorization = `SSWS ${apiToken}`; + } + httpClient.defaultHeaders['User-Agent'] = parsedConfig.client.userAgent ? parsedConfig.client.userAgent + ' ' + DEFAULT_USER_AGENT : DEFAULT_USER_AGENT; + + return { + httpClient, + {{#operation}} + {{#contents}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#parameters}} + * @param {{braces "left"}}{{dataType}}{{braces "right"}} {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/parameters}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + {{nickname}}: async ({{#parameters}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/parameters}}options: any = {}): Promise => { + {{#parameters}} + {{#required}} + // verify required parameter '{{paramName}}' is not null or undefined + if ({{paramName}} === null || {{paramName}} === undefined) { + throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } + {{/required}} + {{/parameters}} + const localVarPath = `{{{path}}}`{{#pathParams}} + .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}}; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, 'https://example.com'); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}} + const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}FormData(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}} + + {{#authMethods}} + // authentication {{name}} required + {{#isApiKey}} + {{#isKeyInHeader}} + if (configuration && configuration.apiToken) { + const localVarApiKeyValue = typeof configuration.apiToken === 'function' + ? await configuration.apiToken("{{keyParamName}}") + : await configuration.apiToken; + localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue; + } + {{/isKeyInHeader}} + {{#isKeyInQuery}} + if (configuration && configuration.apiToken) { + const localVarApiKeyValue = typeof configuration.apiToken === 'function' + ? await configuration.apiToken("{{keyParamName}}") + : await configuration.apiToken; + localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue; + } + {{/isKeyInQuery}} + {{/isApiKey}} + {{#isBasicBasic}} + // http basic authentication required + if (configuration && (configuration.username || configuration.password)) { + localVarRequestOptions["auth"] = { username: configuration.username, password: configuration.password }; + } + {{/isBasicBasic}} + {{#isBasicBearer}} + // http bearer authentication required + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + accessToken; + } + {{/isBasicBearer}} + {{#isOAuth}} + // oauth required + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken("{{name}}", [{{#each scopes}}"{{@key}}"{{^@last}}, {{/@last}}{{/each}}]) + : await configuration.accessToken; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; + } + {{/isOAuth}} + + {{/authMethods}} + {{#queryParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined) { + {{#isDateTime}} + localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? + ({{paramName}} as any).toISOString() : + {{paramName}}; + {{/isDateTime}} + {{^isDateTime}} + {{#isDate}} + localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? + ({{paramName}} as any).toISOString().substr(0,10) : + {{paramName}}; + {{/isDate}} + {{^isDate}} + localVarQueryParameter['{{baseName}}'] = {{paramName}}; + {{/isDate}} + {{/isDateTime}} + } + {{/isListContainer}} + + {{/queryParams}} + {{#headerParams}} + {{#isListContainer}} + if ({{paramName}}) { + let mapped = {{paramName}}.map(value => ("{{{dataType}}}" !== "Array") ? JSON.stringify(value) : (value || "")); + localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]); + } + {{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined && {{paramName}} !== null) { + {{#isString}} + localVarHeaderParameter['{{baseName}}'] = String({{paramName}}); + {{/isString}} + {{^isString}} + localVarHeaderParameter['{{baseName}}'] = String(JSON.stringify({{paramName}})); + {{/isString}} + } + {{/isListContainer}} + + {{/headerParams}} + {{#vendorExtensions}} + {{#formParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + localVarFormParams.append('{{baseName}}', element as any); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}}{{^multipartFormData}} + localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}}{{#multipartFormData}} + localVarFormParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}} + {{/isCollectionFormatMulti}} + }{{/isListContainer}} + {{^isListContainer}} + if ({{paramName}} !== undefined) { {{^multipartFormData}} + localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}} + localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/multipartFormData}} + } + {{/isListContainer}} + {{/formParams}}{{/vendorExtensions}} + {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}} + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}} + localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}} + {{/hasFormParams}}{{/vendorExtensions}} + {{#bodyParam}} + {{^consumes}} + localVarHeaderParameter['Content-Type'] = 'application/json'; + {{/consumes}} + {{#consumes.0}} + localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}'; + {{/consumes.0}} + + {{/bodyParam}} + const query = new URLSearchParams(localVarUrlObj.search); + for (const key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (const key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + {{#hasFormParams}} + localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; + {{/hasFormParams}} + {{#bodyParam}} + const needsSerialization = (typeof {{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify({{paramName}} !== undefined ? {{paramName}} : {}) : ({{paramName}} || ""); + {{/bodyParam}} + + return { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions, + }; + }, + {{/contents}} + {{/operation}} + } +}; + +/** + * {{classname}} - functional programming interface{{#description}} + * {{{description}}}{{/description}} + * @export + */ +export const {{classname}}Fp = function(configuration?: Configuration & V2Configuration) { + return { + {{#operation}} + {{#contents}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#parameters}} + * @param {{braces "left"}}{{dataType}}{{braces "right"}} {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/parameters}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async {{nickname}}({{#parameters}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/parameters}}options?: any): Promise<(httpClient?: Http, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>> { + const api = {{classname}}RequestParamCreator(configuration); + const localVarRequestArgs = await api.{{nickname}}({{#parameters}}{{paramName}}, {{/parameters}}options); + return (httpClient: Http = api.httpClient, basePath: string = configuration.basePath || configuration.orgUrl) => { + const requestArgs = {...localVarRequestArgs.options, url: basePath + localVarRequestArgs.url}; + {{#returnType}} + return httpClient.http(requestArgs.url, requestArgs).then(res => res.json()) as Promise<{{{returnType}}}>; + {{/returnType}} + {{^returnType}} + return httpClient.http(requestArgs.url, requestArgs) as Promise; + {{/returnType}} + } + }, + {{/contents}} + {{/operation}} + } +}; + +/** + * {{classname}} - factory interface{{#description}} + * {{&description}}{{/description}} + * @export + */ +export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, httpClient?: Http) { + return { + {{#operation}} + {{#contents}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#parameters}} + * @param {{braces "left"}}{{dataType}}{{braces "right"}} {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/parameters}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + {{nickname}}({{#parameters}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/parameters}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { + return {{classname}}Fp(configuration).{{nickname}}({{#parameters}}{{paramName}}, {{/parameters}}options).then((request) => request(httpClient, basePath)); + }, + {{/contents}} + {{/operation}} + }; +}; + +{{#withInterfaces}} +/** + * {{classname}} - interface{{#description}} + * {{&description}}{{/description}} + * @export + * @interface {{classname}} + */ +export interface {{classname}}Interface { +{{#operation}} +{{#contents}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#parameters}} + * @param {{braces "left"}}{{dataType}}{{braces "right"}} {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/parameters}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof {{classname}}Interface + */ + {{nickname}}({{#parameters}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/parameters}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>; + +{{/contents}} +{{/operation}} +} + +{{/withInterfaces}} +/** + * {{classname}} - object-oriented interface{{#description}} + * {{{description}}}{{/description}} + * @export + * @class {{classname}} + * @extends {BaseAPI} + */ +{{#withInterfaces}} +export class {{classname}} extends BaseAPI implements {{classname}}Interface { +{{/withInterfaces}} +{{^withInterfaces}} +export class {{classname}} extends BaseAPI { +{{/withInterfaces}} + {{#operation}} + {{#contents}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#parameters}} + * @param {{braces "left"}}{{dataType}}{{braces "right"}} {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/parameters}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof {{classname}} + */ + public {{nickname}}({{#parameters}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/parameters}}options?: any) { + const api = {{classname}}RequestParamCreator(this.configuration); + return {{classname}}Fp(this.configuration).{{nickname}}({{#parameters}}{{paramName}}, {{/parameters}}options).then((request) => request(api.httpClient, this.basePath)); + } + {{^@last}} + + {{/@last}} + {{/contents}} + {{/operation}} +} +{{/operations}} diff --git a/templates/swagger-codegen/baseApi.mustache b/templates/swagger-codegen/baseApi.mustache new file mode 100644 index 000000000..d6d9e0d26 --- /dev/null +++ b/templates/swagger-codegen/baseApi.mustache @@ -0,0 +1,61 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +import { Configuration } from "./configuration"; +import { Http } from "../http"; + +// Some imports not used depending on template conditions +// @ts-ignore + +export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected httpClient?: Http) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/templates/swagger-codegen/configuration.mustache b/templates/swagger-codegen/configuration.mustache new file mode 100644 index 000000000..f484baa34 --- /dev/null +++ b/templates/swagger-codegen/configuration.mustache @@ -0,0 +1,65 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +export interface ConfigurationParameters { + apiToken?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + baseOptions?: any; +} + +export class Configuration { + /** + * parameter for apiToken security + * @param name security name + * @memberof Configuration + */ + apiToken?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + + constructor(param: ConfigurationParameters = {}) { + this.apiToken = param.apiToken; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.baseOptions = param.baseOptions; + } +} diff --git a/templates/swagger-codegen/index.mustache b/templates/swagger-codegen/index.mustache new file mode 100644 index 000000000..585364a48 --- /dev/null +++ b/templates/swagger-codegen/index.mustache @@ -0,0 +1,7 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +export * from "./api"; +export * from "./configuration"; +export * from "./models"; diff --git a/templates/swagger-codegen/licenseInfo.mustache b/templates/swagger-codegen/licenseInfo.mustache new file mode 100644 index 000000000..ae3214a98 --- /dev/null +++ b/templates/swagger-codegen/licenseInfo.mustache @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022-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. + * + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + \ No newline at end of file diff --git a/templates/swagger-codegen/model.mustache b/templates/swagger-codegen/model.mustache new file mode 100644 index 000000000..9e0e05c39 --- /dev/null +++ b/templates/swagger-codegen/model.mustache @@ -0,0 +1,12 @@ +/* tslint:disable */ +/* eslint-disable */ +{{>licenseInfo}} + +{{#withSeparateModelsAndApi}}{{#hasAllOf}}{{#allOf}} +import { {{class}} } from './{{filename}}';{{/allOf}}{{/hasAllOf}}{{#hasOneOf}}{{#oneOf}} +import { {{class}} } from './{{filename}}';{{/oneOf}}{{/hasOneOf}}{{^hasAllOf}}{{^hasOneOf}}{{#imports}} +import { {{class}} } from './{{filename}}';{{/imports}}{{/hasOneOf}}{{/hasAllOf}}{{/withSeparateModelsAndApi}} +{{#models}}{{#model}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#@first}}{{>modelOneOf}}{{/@first}}{{/oneOf}}{{#allOf}}{{#@first}}{{>modelAllOf}}{{/@first}}{{/allOf}}{{^isEnum}}{{^oneOf}}{{^allOf}}{{>modelGeneric}}{{/allOf}}{{/oneOf}}{{/isEnum}} +{{/model}}{{/models}} + diff --git a/templates/swagger-codegen/modelAllOf.mustache b/templates/swagger-codegen/modelAllOf.mustache new file mode 100644 index 000000000..e0fbf0ab7 --- /dev/null +++ b/templates/swagger-codegen/modelAllOf.mustache @@ -0,0 +1,6 @@ +/** + * @type {{classname}}{{#description}} + * {{{description}}}{{/description}} + * @export + */ +export type {{classname}} = {{#allOf}}{{{.}}}{{^@last}} & {{/@last}}{{/allOf}}; diff --git a/templates/swagger-codegen/modelEnum.mustache b/templates/swagger-codegen/modelEnum.mustache new file mode 100644 index 000000000..98c73f2cf --- /dev/null +++ b/templates/swagger-codegen/modelEnum.mustache @@ -0,0 +1,12 @@ +/** + * {{{description}}} + * @export + * @enum {string} + */ +export enum {{classname}} { +{{#allowableValues}} +{{#enumVars}} + {{{name}}} = {{{value}}}{{^@last}},{{/@last}} +{{/enumVars}} +{{/allowableValues}} +} diff --git a/templates/swagger-codegen/modelGeneric.mustache b/templates/swagger-codegen/modelGeneric.mustache new file mode 100644 index 000000000..11b21c88e --- /dev/null +++ b/templates/swagger-codegen/modelGeneric.mustache @@ -0,0 +1,39 @@ +/** + * {{{description}}} + * @export + * @class {{classname}} + */ +export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ +{{#additionalPropertiesType}} + [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}}; + +{{/additionalPropertiesType}} +{{#vars}} + /** + * {{{description}}} + * @type {{braces "left"}}{{datatype}}{{braces "right"}} + * @memberof {{classname}} + {{#deprecated}} + * @deprecated + {{/deprecated}} + */ + {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}; +{{/vars}} +}{{#hasEnums}} + +{{#vars}} +{{#isEnum}} +/** + * @export + * @enum {string} + */ +export enum {{enumName}} { +{{#allowableValues}} + {{#enumVars}} + {{{name}}} = {{{value}}}{{^@last}},{{/@last}} + {{/enumVars}} +{{/allowableValues}} +} +{{/isEnum}} +{{/vars}} +{{/hasEnums}} diff --git a/templates/swagger-codegen/modelIndex.mustache b/templates/swagger-codegen/modelIndex.mustache new file mode 100644 index 000000000..84d938eef --- /dev/null +++ b/templates/swagger-codegen/modelIndex.mustache @@ -0,0 +1,4 @@ +{{>licenseInfo}} + +{{#models}}{{#model}}export * from './{{classFilename}}';{{/model}} +{{/models}} \ No newline at end of file diff --git a/templates/swagger-codegen/modelOneOf.mustache b/templates/swagger-codegen/modelOneOf.mustache new file mode 100644 index 000000000..2e89c82f5 --- /dev/null +++ b/templates/swagger-codegen/modelOneOf.mustache @@ -0,0 +1,6 @@ +/** + * @type {{classname}}{{#description}} + * {{{description}}}{{/description}} + * @export + */ +export type {{classname}} = {{#oneOf}}{{{.}}}{{^@last}} | {{/@last}}{{/oneOf}}; diff --git a/test/it/user-type-api.ts b/test/it/user-type-api.ts new file mode 100644 index 000000000..c1ca7864a --- /dev/null +++ b/test/it/user-type-api.ts @@ -0,0 +1,14 @@ +import { expect } from 'chai'; +import { v3 } from '@okta/okta-sdk-nodejs'; +//import { } from '@okta/okta-sdk-nodejs'; + + +describe('User Type API', () => { + it('lists existing user types', async () => { + const userTypes: v3.model.UserType[] = await v3.api.UserTypeApiFp({ + orgUrl: process.env.OKTA_CLIENT_ORGURL, + token: process.env.OKTA_CLIENT_TOKEN, + }).listUserTypes().then(method => method()); + expect(userTypes.length).to.be.greaterThan(0); + }); +});