From 2976dfcf4efad92a20c8a6cb1b2ceebb8d1b2dfb Mon Sep 17 00:00:00 2001 From: Ian Liu <81595625+ianliuwk1019@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:59:02 -0700 Subject: [PATCH] fix: #365 Remove Unused Endponts. (#968) --- client-code-gen/README.md | 8 + client-code-gen/gen/.openapi-generator/FILES | 7 +- .../gen/.openapi-generator/VERSION | 2 +- client-code-gen/gen/api.ts | 2 - client-code-gen/gen/api/bcscproxy-api.ts | 6 +- .../gen/api/famapplications-api.ts | 6 +- .../gen/api/famforest-clients-api.ts | 6 +- client-code-gen/gen/api/famroles-api.ts | 220 ----------- .../gen/api/famuser-role-assignment-api.ts | 6 +- client-code-gen/gen/api/famusers-api.ts | 374 ------------------ .../gen/api/idirbce-idproxy-api.ts | 6 +- client-code-gen/gen/api/smoke-test-api.ts | 6 +- client-code-gen/gen/base.ts | 7 +- client-code-gen/gen/common.ts | 10 +- .../gen/model/fam-application-role.ts | 9 +- client-code-gen/gen/model/fam-application.ts | 2 + .../gen/model/fam-forest-client-status.ts | 2 + client-code-gen/gen/model/fam-role-create.ts | 75 ---- client-code-gen/gen/model/fam-role-get.ts | 108 ----- client-code-gen/gen/model/fam-role-min.ts | 9 +- .../gen/model/fam-role-with-client.ts | 9 +- client-code-gen/gen/model/fam-user-get.ts | 90 ----- .../gen/model/fam-user-only-name.ts | 2 + .../model/fam-user-role-assignment-create.ts | 2 + client-code-gen/gen/model/fam-user-type.ts | 2 + client-code-gen/gen/model/fam-user.ts | 63 --- client-code-gen/gen/model/index.ts | 5 +- client-code-gen/gen/model/role-type.ts | 31 ++ client-code-gen/gen/package-lock.json | 15 +- client-code-gen/gen/package.json | 3 +- client-code-gen/openapi.json | 2 +- client-code-gen/openapitools.json | 2 +- client-code-gen/package.json | 6 +- frontend/package-lock.json | 6 +- frontend/src/services/ApiServiceFactory.ts | 14 - server/backend/api/app/main.py | 20 +- server/backend/api/app/routers/router_role.py | 55 --- server/backend/api/app/routers/router_user.py | 95 ----- 38 files changed, 128 insertions(+), 1165 deletions(-) delete mode 100644 client-code-gen/gen/api/famroles-api.ts delete mode 100644 client-code-gen/gen/api/famusers-api.ts delete mode 100644 client-code-gen/gen/model/fam-role-create.ts delete mode 100644 client-code-gen/gen/model/fam-role-get.ts delete mode 100644 client-code-gen/gen/model/fam-user-get.ts delete mode 100644 client-code-gen/gen/model/fam-user.ts create mode 100644 client-code-gen/gen/model/role-type.ts mode change 100644 => 100755 client-code-gen/gen/package.json delete mode 100644 server/backend/api/app/routers/router_role.py delete mode 100644 server/backend/api/app/routers/router_user.py diff --git a/client-code-gen/README.md b/client-code-gen/README.md index 349672066..167944538 100644 --- a/client-code-gen/README.md +++ b/client-code-gen/README.md @@ -49,6 +49,8 @@ With CLI: >> npm run gen-api The generated client is located at "./gen" directory specified by the "-o" option at the script. + +- Make sure (and adjust) "axios" package version to be consistent with "frontend" axios version. ``` Note: @@ -59,7 +61,13 @@ Depending on the Axios version used at frontend, please be aware different axios ``` In some cases, it would be good idea to delete "/gen" directory before running script to regenerate new api client code to avoid leaving unnecessary files from last version generated code. +If you encounter folder permission during npm install or during generation, can issue command to temporarily change `gen` folder and files permission with `chmod -R 777`. ``` +### Special Care on openapi.json Spec +* Current openapi(Swagger) spec produced from FastAPI is having issue. Specifically for the "Path" parameter of two endpoints: `"/{application_id}/fam_roles"` and `"/{application_id}/user_role_assignment"`. The path parameter in the produced spec isn't correctly typed (it has "any" type). This, however, only happens on these two endpoints and not on the endpoint that has the same signature `(@router.delete("/{user_role_xref_id}",))` +* We suspect FastAPI version (after we bump up verson to 0.100.0) might be related to this issue. However, we can not downgrade to lower than 0.90.0 and up to today's(2023/10/17) version 0.103.0 does not resolve to correct schema. +* Temporary solution is to add `"type":"integer",` into the corresponding `schema` section of the produced openapi.json manually. +* This is not a desirable behaviour but a temporary solution. So in the future, please verify again with higher FastAPI version and investigate further it further to see if it is fixed. ## How to Use/Integrate with Generated Client/Lib The generated api client code (under /gen directory) can be used in frontend (located `frontend` folder under project root) as one of its dependencies/libs (currently named it as 'fam-api'). diff --git a/client-code-gen/gen/.openapi-generator/FILES b/client-code-gen/gen/.openapi-generator/FILES index c77527903..6c4983333 100644 --- a/client-code-gen/gen/.openapi-generator/FILES +++ b/client-code-gen/gen/.openapi-generator/FILES @@ -5,9 +5,7 @@ api.ts api/bcscproxy-api.ts api/famapplications-api.ts api/famforest-clients-api.ts -api/famroles-api.ts api/famuser-role-assignment-api.ts -api/famusers-api.ts api/idirbce-idproxy-api.ts api/smoke-test-api.ts base.ts @@ -23,20 +21,17 @@ model/fam-forest-client-create.ts model/fam-forest-client-status-type.ts model/fam-forest-client-status.ts model/fam-forest-client.ts -model/fam-role-create.ts -model/fam-role-get.ts model/fam-role-min.ts model/fam-role-with-client.ts -model/fam-user-get.ts model/fam-user-only-name.ts model/fam-user-role-assignment-create.ts model/fam-user-role-assignment-get.ts model/fam-user-type.ts -model/fam-user.ts model/httpvalidation-error.ts model/idim-proxy-idir-info.ts model/index.ts model/location-inner.ts +model/role-type.ts model/user-type.ts model/validation-error.ts package.json diff --git a/client-code-gen/gen/.openapi-generator/VERSION b/client-code-gen/gen/.openapi-generator/VERSION index 0df17dd0f..73a86b197 100644 --- a/client-code-gen/gen/.openapi-generator/VERSION +++ b/client-code-gen/gen/.openapi-generator/VERSION @@ -1 +1 @@ -6.2.1 \ No newline at end of file +7.0.1 \ No newline at end of file diff --git a/client-code-gen/gen/api.ts b/client-code-gen/gen/api.ts index afffeaa70..3073866b3 100644 --- a/client-code-gen/gen/api.ts +++ b/client-code-gen/gen/api.ts @@ -17,9 +17,7 @@ export * from './api/bcscproxy-api'; export * from './api/famapplications-api'; export * from './api/famforest-clients-api'; -export * from './api/famroles-api'; export * from './api/famuser-role-assignment-api'; -export * from './api/famusers-api'; export * from './api/idirbce-idproxy-api'; export * from './api/smoke-test-api'; diff --git a/client-code-gen/gen/api/bcscproxy-api.ts b/client-code-gen/gen/api/bcscproxy-api.ts index a8e139165..99049505f 100644 --- a/client-code-gen/gen/api/bcscproxy-api.ts +++ b/client-code-gen/gen/api/bcscproxy-api.ts @@ -13,8 +13,9 @@ */ -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; +import type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; @@ -547,3 +548,4 @@ export class BCSCProxyApi extends BaseAPI implements BCSCProxyApiInterface { return BCSCProxyApiFp(this.configuration).bcscUserinfoTest(options).then((request) => request(this.axios, this.basePath)); } } + diff --git a/client-code-gen/gen/api/famapplications-api.ts b/client-code-gen/gen/api/famapplications-api.ts index 5ea2722d7..86bc26cb4 100644 --- a/client-code-gen/gen/api/famapplications-api.ts +++ b/client-code-gen/gen/api/famapplications-api.ts @@ -13,8 +13,9 @@ */ -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; +import type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; @@ -307,3 +308,4 @@ export class FAMApplicationsApi extends BaseAPI implements FAMApplicationsApiInt return FAMApplicationsApiFp(this.configuration).getFamApplicationUserRoleAssignment(applicationId, options).then((request) => request(this.axios, this.basePath)); } } + diff --git a/client-code-gen/gen/api/famforest-clients-api.ts b/client-code-gen/gen/api/famforest-clients-api.ts index 3ea3666dc..17e173152 100644 --- a/client-code-gen/gen/api/famforest-clients-api.ts +++ b/client-code-gen/gen/api/famforest-clients-api.ts @@ -13,8 +13,9 @@ */ -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; +import type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; @@ -152,3 +153,4 @@ export class FAMForestClientsApi extends BaseAPI implements FAMForestClientsApiI return FAMForestClientsApiFp(this.configuration).search(clientNumber, options).then((request) => request(this.axios, this.basePath)); } } + diff --git a/client-code-gen/gen/api/famroles-api.ts b/client-code-gen/gen/api/famroles-api.ts deleted file mode 100644 index 4009ae56b..000000000 --- a/client-code-gen/gen/api/famroles-api.ts +++ /dev/null @@ -1,220 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Forest Access Management - FAM - API - * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. - * - * The version of the OpenAPI document: 0.0.1 - * Contact: guy.lafleur@montreal.canadians.ca - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; -// @ts-ignore -import { FamRoleCreate } from '../model'; -// @ts-ignore -import { FamRoleGet } from '../model'; -// @ts-ignore -import { HTTPValidationError } from '../model'; -/** - * FAMRolesApi - axios parameter creator - * @export - */ -export const FAMRolesApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Add a role to FAM - * @summary Create Fam Role - * @param {FamRoleCreate} famRoleCreate - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createFamRole: async (famRoleCreate: FamRoleCreate, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'famRoleCreate' is not null or undefined - assertParamExists('createFamRole', 'famRoleCreate', famRoleCreate) - const localVarPath = `/fam_roles`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(famRoleCreate, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * List of different roles that are administered by FAM - * @summary Get Fam Roles - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getFamRoles: async (options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/fam_roles`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * FAMRolesApi - functional programming interface - * @export - */ -export const FAMRolesApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = FAMRolesApiAxiosParamCreator(configuration) - return { - /** - * Add a role to FAM - * @summary Create Fam Role - * @param {FamRoleCreate} famRoleCreate - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async createFamRole(famRoleCreate: FamRoleCreate, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.createFamRole(famRoleCreate, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * List of different roles that are administered by FAM - * @summary Get Fam Roles - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getFamRoles(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getFamRoles(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * FAMRolesApi - factory interface - * @export - */ -export const FAMRolesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = FAMRolesApiFp(configuration) - return { - /** - * Add a role to FAM - * @summary Create Fam Role - * @param {FamRoleCreate} famRoleCreate - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createFamRole(famRoleCreate: FamRoleCreate, options?: any): AxiosPromise { - return localVarFp.createFamRole(famRoleCreate, options).then((request) => request(axios, basePath)); - }, - /** - * List of different roles that are administered by FAM - * @summary Get Fam Roles - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getFamRoles(options?: any): AxiosPromise> { - return localVarFp.getFamRoles(options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * FAMRolesApi - interface - * @export - * @interface FAMRolesApi - */ -export interface FAMRolesApiInterface { - /** - * Add a role to FAM - * @summary Create Fam Role - * @param {FamRoleCreate} famRoleCreate - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMRolesApiInterface - */ - createFamRole(famRoleCreate: FamRoleCreate, options?: AxiosRequestConfig): AxiosPromise; - - /** - * List of different roles that are administered by FAM - * @summary Get Fam Roles - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMRolesApiInterface - */ - getFamRoles(options?: AxiosRequestConfig): AxiosPromise>; - -} - -/** - * FAMRolesApi - object-oriented interface - * @export - * @class FAMRolesApi - * @extends {BaseAPI} - */ -export class FAMRolesApi extends BaseAPI implements FAMRolesApiInterface { - /** - * Add a role to FAM - * @summary Create Fam Role - * @param {FamRoleCreate} famRoleCreate - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMRolesApi - */ - public createFamRole(famRoleCreate: FamRoleCreate, options?: AxiosRequestConfig) { - return FAMRolesApiFp(this.configuration).createFamRole(famRoleCreate, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * List of different roles that are administered by FAM - * @summary Get Fam Roles - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMRolesApi - */ - public getFamRoles(options?: AxiosRequestConfig) { - return FAMRolesApiFp(this.configuration).getFamRoles(options).then((request) => request(this.axios, this.basePath)); - } -} diff --git a/client-code-gen/gen/api/famuser-role-assignment-api.ts b/client-code-gen/gen/api/famuser-role-assignment-api.ts index bb7c20f45..bd721e118 100644 --- a/client-code-gen/gen/api/famuser-role-assignment-api.ts +++ b/client-code-gen/gen/api/famuser-role-assignment-api.ts @@ -13,8 +13,9 @@ */ -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; +import type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; @@ -234,3 +235,4 @@ export class FAMUserRoleAssignmentApi extends BaseAPI implements FAMUserRoleAssi return FAMUserRoleAssignmentApiFp(this.configuration).deleteUserRoleAssignment(userRoleXrefId, options).then((request) => request(this.axios, this.basePath)); } } + diff --git a/client-code-gen/gen/api/famusers-api.ts b/client-code-gen/gen/api/famusers-api.ts deleted file mode 100644 index 9963c1829..000000000 --- a/client-code-gen/gen/api/famusers-api.ts +++ /dev/null @@ -1,374 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Forest Access Management - FAM - API - * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. - * - * The version of the OpenAPI document: 0.0.1 - * Contact: guy.lafleur@montreal.canadians.ca - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; -// @ts-ignore -import { FamUser } from '../model'; -// @ts-ignore -import { FamUserGet } from '../model'; -// @ts-ignore -import { HTTPValidationError } from '../model'; -/** - * FAMUsersApi - axios parameter creator - * @export - */ -export const FAMUsersApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Add a user to FAM - * @summary Create Fam User - * @param {FamUser} famUser - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createFamUser: async (famUser: FamUser, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'famUser' is not null or undefined - assertParamExists('createFamUser', 'famUser', famUser) - const localVarPath = `/fam_users`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(famUser, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Delete a FAM user - * @summary Delete Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deleteFamUser: async (userId: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'userId' is not null or undefined - assertParamExists('deleteFamUser', 'userId', userId) - const localVarPath = `/fam_users/{user_id}` - .replace(`{${"user_id"}}`, encodeURIComponent(String(userId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Get a FAM user - * @summary Get Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getFamUser: async (userId: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'userId' is not null or undefined - assertParamExists('getFamUser', 'userId', userId) - const localVarPath = `/fam_users/{user_id}` - .replace(`{${"user_id"}}`, encodeURIComponent(String(userId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * List of different users that are administered by FAM - * @summary Get Users - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getUsers: async (options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/fam_users`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * FAMUsersApi - functional programming interface - * @export - */ -export const FAMUsersApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = FAMUsersApiAxiosParamCreator(configuration) - return { - /** - * Add a user to FAM - * @summary Create Fam User - * @param {FamUser} famUser - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async createFamUser(famUser: FamUser, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.createFamUser(famUser, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Delete a FAM user - * @summary Delete Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async deleteFamUser(userId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.deleteFamUser(userId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Get a FAM user - * @summary Get Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getFamUser(userId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getFamUser(userId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * List of different users that are administered by FAM - * @summary Get Users - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getUsers(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getUsers(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * FAMUsersApi - factory interface - * @export - */ -export const FAMUsersApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = FAMUsersApiFp(configuration) - return { - /** - * Add a user to FAM - * @summary Create Fam User - * @param {FamUser} famUser - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createFamUser(famUser: FamUser, options?: any): AxiosPromise { - return localVarFp.createFamUser(famUser, options).then((request) => request(axios, basePath)); - }, - /** - * Delete a FAM user - * @summary Delete Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deleteFamUser(userId: number, options?: any): AxiosPromise { - return localVarFp.deleteFamUser(userId, options).then((request) => request(axios, basePath)); - }, - /** - * Get a FAM user - * @summary Get Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getFamUser(userId: number, options?: any): AxiosPromise { - return localVarFp.getFamUser(userId, options).then((request) => request(axios, basePath)); - }, - /** - * List of different users that are administered by FAM - * @summary Get Users - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getUsers(options?: any): AxiosPromise> { - return localVarFp.getUsers(options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * FAMUsersApi - interface - * @export - * @interface FAMUsersApi - */ -export interface FAMUsersApiInterface { - /** - * Add a user to FAM - * @summary Create Fam User - * @param {FamUser} famUser - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApiInterface - */ - createFamUser(famUser: FamUser, options?: AxiosRequestConfig): AxiosPromise; - - /** - * Delete a FAM user - * @summary Delete Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApiInterface - */ - deleteFamUser(userId: number, options?: AxiosRequestConfig): AxiosPromise; - - /** - * Get a FAM user - * @summary Get Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApiInterface - */ - getFamUser(userId: number, options?: AxiosRequestConfig): AxiosPromise; - - /** - * List of different users that are administered by FAM - * @summary Get Users - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApiInterface - */ - getUsers(options?: AxiosRequestConfig): AxiosPromise>; - -} - -/** - * FAMUsersApi - object-oriented interface - * @export - * @class FAMUsersApi - * @extends {BaseAPI} - */ -export class FAMUsersApi extends BaseAPI implements FAMUsersApiInterface { - /** - * Add a user to FAM - * @summary Create Fam User - * @param {FamUser} famUser - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApi - */ - public createFamUser(famUser: FamUser, options?: AxiosRequestConfig) { - return FAMUsersApiFp(this.configuration).createFamUser(famUser, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * Delete a FAM user - * @summary Delete Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApi - */ - public deleteFamUser(userId: number, options?: AxiosRequestConfig) { - return FAMUsersApiFp(this.configuration).deleteFamUser(userId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * Get a FAM user - * @summary Get Fam User - * @param {number} userId - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApi - */ - public getFamUser(userId: number, options?: AxiosRequestConfig) { - return FAMUsersApiFp(this.configuration).getFamUser(userId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * List of different users that are administered by FAM - * @summary Get Users - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof FAMUsersApi - */ - public getUsers(options?: AxiosRequestConfig) { - return FAMUsersApiFp(this.configuration).getUsers(options).then((request) => request(this.axios, this.basePath)); - } -} diff --git a/client-code-gen/gen/api/idirbce-idproxy-api.ts b/client-code-gen/gen/api/idirbce-idproxy-api.ts index d9b31c99b..e3448f7eb 100644 --- a/client-code-gen/gen/api/idirbce-idproxy-api.ts +++ b/client-code-gen/gen/api/idirbce-idproxy-api.ts @@ -13,8 +13,9 @@ */ -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; +import type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; @@ -152,3 +153,4 @@ export class IDIRBCeIDProxyApi extends BaseAPI implements IDIRBCeIDProxyApiInter return IDIRBCeIDProxyApiFp(this.configuration).idirSearch(userId, options).then((request) => request(this.axios, this.basePath)); } } + diff --git a/client-code-gen/gen/api/smoke-test-api.ts b/client-code-gen/gen/api/smoke-test-api.ts index 59da32874..89eada65e 100644 --- a/client-code-gen/gen/api/smoke-test-api.ts +++ b/client-code-gen/gen/api/smoke-test-api.ts @@ -13,8 +13,9 @@ */ -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; +import type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; @@ -133,3 +134,4 @@ export class SmokeTestApi extends BaseAPI implements SmokeTestApiInterface { return SmokeTestApiFp(this.configuration).smokeTest(options).then((request) => request(this.axios, this.basePath)); } } + diff --git a/client-code-gen/gen/base.ts b/client-code-gen/gen/base.ts index 3bcb56811..7594c9b2d 100644 --- a/client-code-gen/gen/base.ts +++ b/client-code-gen/gen/base.ts @@ -13,10 +13,11 @@ */ -import { Configuration } from "./configuration"; +import type { Configuration } from './configuration'; // Some imports not used depending on template conditions // @ts-ignore -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); @@ -64,8 +65,8 @@ export class BaseAPI { * @extends {Error} */ export class RequiredError extends Error { - name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + this.name = "RequiredError" } } diff --git a/client-code-gen/gen/common.ts b/client-code-gen/gen/common.ts index 267e41784..8727989b0 100644 --- a/client-code-gen/gen/common.ts +++ b/client-code-gen/gen/common.ts @@ -13,9 +13,10 @@ */ -import { Configuration } from "./configuration"; -import { RequiredError, RequestArgs } from "./base"; -import { AxiosInstance, AxiosResponse } from 'axios'; +import type { Configuration } from "./configuration"; +import type { RequestArgs } from "./base"; +import type { AxiosInstance, AxiosResponse } from 'axios'; +import { RequiredError } from "./base"; /** * @@ -84,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); @@ -142,7 +144,7 @@ export const toPathString = function (url: URL) { */ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url}; + const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || axios.defaults.baseURL || basePath) + axiosArgs.url}; return axios.request(axiosRequestArgs); }; } diff --git a/client-code-gen/gen/model/fam-application-role.ts b/client-code-gen/gen/model/fam-application-role.ts index 37a7bd6aa..8e0a0c4c7 100644 --- a/client-code-gen/gen/model/fam-application-role.ts +++ b/client-code-gen/gen/model/fam-application-role.ts @@ -16,6 +16,9 @@ // May contain unused imports in some cases // @ts-ignore import { FamForestClientCreate } from './fam-forest-client-create'; +// May contain unused imports in some cases +// @ts-ignore +import { RoleType } from './role-type'; /** * @@ -61,10 +64,10 @@ export interface FamApplicationRole { 'create_user': string; /** * - * @type {string} + * @type {RoleType} * @memberof FamApplicationRole */ - 'role_type_code': string; + 'role_type_code': RoleType; /** * * @type {FamForestClientCreate} @@ -79,3 +82,5 @@ export interface FamApplicationRole { 'role_id': number; } + + diff --git a/client-code-gen/gen/model/fam-application.ts b/client-code-gen/gen/model/fam-application.ts index 7889f2b96..7ac79f283 100644 --- a/client-code-gen/gen/model/fam-application.ts +++ b/client-code-gen/gen/model/fam-application.ts @@ -79,3 +79,5 @@ export interface FamApplication { 'update_date'?: string; } + + diff --git a/client-code-gen/gen/model/fam-forest-client-status.ts b/client-code-gen/gen/model/fam-forest-client-status.ts index 0cd0b9e9c..ae9a193f4 100644 --- a/client-code-gen/gen/model/fam-forest-client-status.ts +++ b/client-code-gen/gen/model/fam-forest-client-status.ts @@ -37,3 +37,5 @@ export interface FamForestClientStatus { 'description': string; } + + diff --git a/client-code-gen/gen/model/fam-role-create.ts b/client-code-gen/gen/model/fam-role-create.ts deleted file mode 100644 index b1e7133d8..000000000 --- a/client-code-gen/gen/model/fam-role-create.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Forest Access Management - FAM - API - * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. - * - * The version of the OpenAPI document: 0.0.1 - * Contact: guy.lafleur@montreal.canadians.ca - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -// May contain unused imports in some cases -// @ts-ignore -import { FamForestClientCreate } from './fam-forest-client-create'; - -/** - * - * @export - * @interface FamRoleCreate - */ -export interface FamRoleCreate { - /** - * - * @type {string} - * @memberof FamRoleCreate - */ - 'role_name': string; - /** - * - * @type {string} - * @memberof FamRoleCreate - */ - 'role_purpose'?: string; - /** - * - * @type {number} - * @memberof FamRoleCreate - */ - 'parent_role_id'?: number; - /** - * - * @type {number} - * @memberof FamRoleCreate - */ - 'application_id': number; - /** - * - * @type {string} - * @memberof FamRoleCreate - */ - 'forest_client_number'?: string; - /** - * - * @type {string} - * @memberof FamRoleCreate - */ - 'create_user': string; - /** - * - * @type {string} - * @memberof FamRoleCreate - */ - 'role_type_code': string; - /** - * - * @type {FamForestClientCreate} - * @memberof FamRoleCreate - */ - 'client_number'?: FamForestClientCreate; -} - diff --git a/client-code-gen/gen/model/fam-role-get.ts b/client-code-gen/gen/model/fam-role-get.ts deleted file mode 100644 index f9de4c5a9..000000000 --- a/client-code-gen/gen/model/fam-role-get.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Forest Access Management - FAM - API - * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. - * - * The version of the OpenAPI document: 0.0.1 - * Contact: guy.lafleur@montreal.canadians.ca - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -// May contain unused imports in some cases -// @ts-ignore -import { FamApplication } from './fam-application'; -// May contain unused imports in some cases -// @ts-ignore -import { FamForestClientCreate } from './fam-forest-client-create'; - -/** - * - * @export - * @interface FamRoleGet - */ -export interface FamRoleGet { - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'role_name': string; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'role_purpose'?: string; - /** - * - * @type {number} - * @memberof FamRoleGet - */ - 'parent_role_id'?: number; - /** - * - * @type {number} - * @memberof FamRoleGet - */ - 'application_id': number; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'forest_client_number'?: string; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'create_user': string; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'role_type_code': string; - /** - * - * @type {FamForestClientCreate} - * @memberof FamRoleGet - */ - 'client_number'?: FamForestClientCreate; - /** - * - * @type {number} - * @memberof FamRoleGet - */ - 'role_id': number; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'update_user'?: string; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'create_date'?: string; - /** - * - * @type {string} - * @memberof FamRoleGet - */ - 'update_date'?: string; - /** - * - * @type {FamApplication} - * @memberof FamRoleGet - */ - 'application'?: FamApplication; -} - diff --git a/client-code-gen/gen/model/fam-role-min.ts b/client-code-gen/gen/model/fam-role-min.ts index 99b9aa563..e55be8269 100644 --- a/client-code-gen/gen/model/fam-role-min.ts +++ b/client-code-gen/gen/model/fam-role-min.ts @@ -13,6 +13,9 @@ */ +// May contain unused imports in some cases +// @ts-ignore +import { RoleType } from './role-type'; /** * @@ -28,10 +31,10 @@ export interface FamRoleMin { 'role_name': string; /** * - * @type {string} + * @type {RoleType} * @memberof FamRoleMin */ - 'role_type_code': string; + 'role_type_code': RoleType; /** * * @type {number} @@ -40,3 +43,5 @@ export interface FamRoleMin { 'application_id': number; } + + diff --git a/client-code-gen/gen/model/fam-role-with-client.ts b/client-code-gen/gen/model/fam-role-with-client.ts index 1d7920c0e..2502bee31 100644 --- a/client-code-gen/gen/model/fam-role-with-client.ts +++ b/client-code-gen/gen/model/fam-role-with-client.ts @@ -19,6 +19,9 @@ import { FamForestClient } from './fam-forest-client'; // May contain unused imports in some cases // @ts-ignore import { FamRoleMin } from './fam-role-min'; +// May contain unused imports in some cases +// @ts-ignore +import { RoleType } from './role-type'; /** * @@ -64,10 +67,10 @@ export interface FamRoleWithClient { 'create_user': string; /** * - * @type {string} + * @type {RoleType} * @memberof FamRoleWithClient */ - 'role_type_code': string; + 'role_type_code': RoleType; /** * * @type {FamForestClient} @@ -88,3 +91,5 @@ export interface FamRoleWithClient { 'parent_role'?: FamRoleMin; } + + diff --git a/client-code-gen/gen/model/fam-user-get.ts b/client-code-gen/gen/model/fam-user-get.ts deleted file mode 100644 index 0f7bd68d3..000000000 --- a/client-code-gen/gen/model/fam-user-get.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Forest Access Management - FAM - API - * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. - * - * The version of the OpenAPI document: 0.0.1 - * Contact: guy.lafleur@montreal.canadians.ca - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -// May contain unused imports in some cases -// @ts-ignore -import { FamRoleCreate } from './fam-role-create'; -// May contain unused imports in some cases -// @ts-ignore -import { UserType } from './user-type'; - -/** - * - * @export - * @interface FamUserGet - */ -export interface FamUserGet { - /** - * - * @type {UserType} - * @memberof FamUserGet - */ - 'user_type_code': UserType; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'cognito_user_id'?: string; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'user_name': string; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'user_guid'?: string; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'create_user': string; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'update_user'?: string; - /** - * - * @type {number} - * @memberof FamUserGet - */ - 'user_id': number; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'create_date': string; - /** - * - * @type {string} - * @memberof FamUserGet - */ - 'update_date'?: string; - /** - * - * @type {FamRoleCreate} - * @memberof FamUserGet - */ - 'role'?: FamRoleCreate; -} - diff --git a/client-code-gen/gen/model/fam-user-only-name.ts b/client-code-gen/gen/model/fam-user-only-name.ts index 35294429a..222b9da7a 100644 --- a/client-code-gen/gen/model/fam-user-only-name.ts +++ b/client-code-gen/gen/model/fam-user-only-name.ts @@ -70,3 +70,5 @@ export interface FamUserOnlyName { 'user_type': FamUserType; } + + diff --git a/client-code-gen/gen/model/fam-user-role-assignment-create.ts b/client-code-gen/gen/model/fam-user-role-assignment-create.ts index 9a9f5e307..3e501629d 100644 --- a/client-code-gen/gen/model/fam-user-role-assignment-create.ts +++ b/client-code-gen/gen/model/fam-user-role-assignment-create.ts @@ -49,3 +49,5 @@ export interface FamUserRoleAssignmentCreate { 'forest_client_number'?: string; } + + diff --git a/client-code-gen/gen/model/fam-user-type.ts b/client-code-gen/gen/model/fam-user-type.ts index 45dc85e9c..62ccdb4d7 100644 --- a/client-code-gen/gen/model/fam-user-type.ts +++ b/client-code-gen/gen/model/fam-user-type.ts @@ -37,3 +37,5 @@ export interface FamUserType { 'description': string; } + + diff --git a/client-code-gen/gen/model/fam-user.ts b/client-code-gen/gen/model/fam-user.ts deleted file mode 100644 index 4f94f1196..000000000 --- a/client-code-gen/gen/model/fam-user.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Forest Access Management - FAM - API - * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. - * - * The version of the OpenAPI document: 0.0.1 - * Contact: guy.lafleur@montreal.canadians.ca - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -// May contain unused imports in some cases -// @ts-ignore -import { UserType } from './user-type'; - -/** - * - * @export - * @interface FamUser - */ -export interface FamUser { - /** - * - * @type {UserType} - * @memberof FamUser - */ - 'user_type_code': UserType; - /** - * - * @type {string} - * @memberof FamUser - */ - 'cognito_user_id'?: string; - /** - * - * @type {string} - * @memberof FamUser - */ - 'user_name': string; - /** - * - * @type {string} - * @memberof FamUser - */ - 'user_guid'?: string; - /** - * - * @type {string} - * @memberof FamUser - */ - 'create_user': string; - /** - * - * @type {string} - * @memberof FamUser - */ - 'update_user'?: string; -} - diff --git a/client-code-gen/gen/model/index.ts b/client-code-gen/gen/model/index.ts index f30554286..fb4f6c46c 100644 --- a/client-code-gen/gen/model/index.ts +++ b/client-code-gen/gen/model/index.ts @@ -6,12 +6,8 @@ export * from './fam-forest-client'; export * from './fam-forest-client-create'; export * from './fam-forest-client-status'; export * from './fam-forest-client-status-type'; -export * from './fam-role-create'; -export * from './fam-role-get'; export * from './fam-role-min'; export * from './fam-role-with-client'; -export * from './fam-user'; -export * from './fam-user-get'; export * from './fam-user-only-name'; export * from './fam-user-role-assignment-create'; export * from './fam-user-role-assignment-get'; @@ -19,5 +15,6 @@ export * from './fam-user-type'; export * from './httpvalidation-error'; export * from './idim-proxy-idir-info'; export * from './location-inner'; +export * from './role-type'; export * from './user-type'; export * from './validation-error'; diff --git a/client-code-gen/gen/model/role-type.ts b/client-code-gen/gen/model/role-type.ts new file mode 100644 index 000000000..1696ca01a --- /dev/null +++ b/client-code-gen/gen/model/role-type.ts @@ -0,0 +1,31 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Forest Access Management - FAM - API + * Forest Access Management API used by the Forest Access Management application to Define who has access to what apps, and what roles they will operate under once access is granted. + * + * The version of the OpenAPI document: 0.0.1 + * Contact: guy.lafleur@montreal.canadians.ca + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +/** + * An enumeration. + * @export + * @enum {string} + */ + +export const RoleType = { + A: 'A', + C: 'C' +} as const; + +export type RoleType = typeof RoleType[keyof typeof RoleType]; + + + diff --git a/client-code-gen/gen/package-lock.json b/client-code-gen/gen/package-lock.json index 50bef35fd..cd6678a20 100644 --- a/client-code-gen/gen/package-lock.json +++ b/client-code-gen/gen/package-lock.json @@ -9,19 +9,12 @@ "version": "1.0.0", "license": "Unlicense", "dependencies": { - "axios": "^0.26.1" + "axios": "0.26.1" }, "devDependencies": { - "@types/node": "^18.0.0", "typescript": "^4.0" } }, - "node_modules/@types/node": { - "version": "18.17.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.8.tgz", - "integrity": "sha512-Av/7MqX/iNKwT9Tr60V85NqMnsmh8ilfJoBlIVibkXfitk9Q22D9Y5mSpm+FvG5DET7EbVfB40bOiLzKgYFgPw==", - "dev": true - }, "node_modules/axios": { "version": "0.26.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", @@ -31,9 +24,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", "funding": [ { "type": "individual", diff --git a/client-code-gen/gen/package.json b/client-code-gen/gen/package.json old mode 100644 new mode 100755 index 53234153e..63a9bc5cf --- a/client-code-gen/gen/package.json +++ b/client-code-gen/gen/package.json @@ -24,10 +24,9 @@ "prepare": "npm run build" }, "dependencies": { - "axios": "^0.26.1" + "axios": "0.26.1" }, "devDependencies": { - "@types/node": "^18.0.0", "typescript": "^4.0" } } diff --git a/client-code-gen/openapi.json b/client-code-gen/openapi.json index 645889e4b..a8b1da2d3 100644 --- a/client-code-gen/openapi.json +++ b/client-code-gen/openapi.json @@ -1 +1 @@ -{"openapi":"3.0.2","info":{"title":"Forest Access Management - FAM - API","description":"\nForest Access Management API used by the Forest Access Management application\nto Define who has access to what apps, and what roles they will operate under\n once access is granted.\n","contact":{"name":"Guy Lafleur","url":"https://en.wikipedia.org/wiki/Guy_Lafleur","email":"guy.lafleur@montreal.canadians.ca"},"license":{"name":"Apache 2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"version":"0.0.1"},"paths":{"/fam_applications":{"get":{"tags":["FAM Applications"],"summary":"Get Applications","description":"List of different applications that are administered by FAM","operationId":"get_applications","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Get Applications","type":"array","items":{"$ref":"#/components/schemas/FamApplication"}}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/fam_applications/{application_id}/fam_roles":{"get":{"tags":["FAM Applications"],"summary":"Get Fam Application Roles","description":"gets the roles associated with an application\n\n:param application_id: application id\n:param db: database session, defaults to Depends(database.get_db)","operationId":"get_fam_application_roles","parameters":[{"required":true,"schema":{"title":"Application Id","type":"integer"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Get Fam Application Roles","type":"array","items":{"$ref":"#/components/schemas/FamApplicationRole"}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/fam_applications/{application_id}/user_role_assignment":{"get":{"tags":["FAM Applications"],"summary":"Get Fam Application User Role Assignment","description":"gets the roles associated with an application\n\n:param application_id: application id\n:param db: database session, defaults to Depends(database.get_db)","operationId":"get_fam_application_user_role_assignment","parameters":[{"required":true,"schema":{"title":"Application Id","type":"integer"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Get Fam Application User Role Assignment","type":"array","items":{"$ref":"#/components/schemas/FamApplicationUserRoleAssignmentGet"}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/user_role_assignment":{"post":{"tags":["FAM User Role Assignment"],"summary":"Create User Role Assignment","description":"Create FAM user_role_xref association.","operationId":"create_user_role_assignment","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUserRoleAssignmentCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUserRoleAssignmentGet"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/user_role_assignment/{user_role_xref_id}":{"delete":{"tags":["FAM User Role Assignment"],"summary":"Delete User Role Assignment","description":"Delete FAM user_role_xref association.","operationId":"delete_user_role_assignment","parameters":[{"required":true,"schema":{"title":"User Role Xref Id","type":"integer"},"name":"user_role_xref_id","in":"path"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/forest_clients/search":{"get":{"tags":["FAM Forest Clients"],"summary":"Search","description":"Forest Client(s) search (by defined query parameter(s)).\n\nparam: 'client_number=[query_value]'\n Note! Current Forest Client API limits it to exact search for a whole 8-digits number.\n\nreturn: List of found FamForestClient. However, currently only 1 exact match returns.","operationId":"search","parameters":[{"required":true,"schema":{"title":"Client Number","maxLength":8,"minLength":3,"type":"string"},"name":"client_number","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Search","type":"array","items":{"$ref":"#/components/schemas/FamForestClient"}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/identity_search/idir":{"get":{"tags":["IDIR/BCeID Proxy"],"summary":"Idir Search","operationId":"idir_search","parameters":[{"required":true,"schema":{"title":"User Id","type":"string"},"name":"user_id","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdimProxyIdirInfo"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/fam_users":{"get":{"tags":["FAM Users"],"summary":"Get Users","description":"List of different users that are administered by FAM","operationId":"get_users","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Get Users","type":"array","items":{"$ref":"#/components/schemas/FamUserGet"}}}}}}},"post":{"tags":["FAM Users"],"summary":"Create Fam User","description":"Add a user to FAM","operationId":"create_fam_user","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUser"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUserGet"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/fam_users/{user_id}":{"get":{"tags":["FAM Users"],"summary":"Get Fam User","description":"Get a FAM user","operationId":"get_fam_user","parameters":[{"required":true,"schema":{"title":"User Id","type":"integer"},"name":"user_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUserGet"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["FAM Users"],"summary":"Delete Fam User","description":"Delete a FAM user","operationId":"delete_fam_user","parameters":[{"required":true,"schema":{"title":"User Id","type":"integer"},"name":"user_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUser"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/fam_roles":{"get":{"tags":["FAM Roles"],"summary":"Get Fam Roles","description":"List of different roles that are administered by FAM","operationId":"get_fam_roles","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"title":"Response Get Fam Roles","type":"array","items":{"$ref":"#/components/schemas/FamRoleGet"}}}}}}},"post":{"tags":["FAM Roles"],"summary":"Create Fam Role","description":"Add a role to FAM","operationId":"create_fam_role","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamRoleCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamRoleGet"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/bcsc/token/dev":{"post":{"tags":["BCSC Proxy"],"summary":"Bcsc Token Dev","operationId":"bcsc_token_dev","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/token/test":{"post":{"tags":["BCSC Proxy"],"summary":"Bcsc Token Test","operationId":"bcsc_token_test","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/token/prod":{"post":{"tags":["BCSC Proxy"],"summary":"Bcsc Token Prod","operationId":"bcsc_token_prod","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/userinfo/dev":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Userinfo Dev","operationId":"bcsc_userinfo_dev","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/userinfo/test":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Userinfo Test","operationId":"bcsc_userinfo_test","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/userinfo/prod":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Userinfo Prod","operationId":"bcsc_userinfo_prod","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/jwks.json":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Jwks","operationId":"bcsc_jwks","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/smoke_test":{"get":{"tags":["Smoke Test"],"summary":"Smoke Test","description":"List of different applications that are administered by FAM","operationId":"smoke_test","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"AppEnv":{"title":"AppEnv","enum":["DEV","TEST","PROD"],"type":"string","description":"An enumeration."},"FamApplication":{"title":"FamApplication","required":["application_name","application_description","application_id","create_user","create_date"],"type":"object","properties":{"application_name":{"title":"Application Name","type":"string"},"application_description":{"title":"Application Description","type":"string"},"application_client_id":{"title":"Application Client Id","type":"integer"},"app_environment":{"$ref":"#/components/schemas/AppEnv"},"application_id":{"title":"Application Id","type":"integer"},"create_user":{"title":"Create User","type":"string"},"create_date":{"title":"Create Date","type":"string","format":"date-time"},"update_user":{"title":"Update User","type":"string"},"update_date":{"title":"Update Date","type":"string","format":"date-time"}}},"FamApplicationRole":{"title":"FamApplicationRole","required":["role_name","application_id","create_user","role_type_code","role_id"],"type":"object","properties":{"role_name":{"title":"Role Name","type":"string"},"role_purpose":{"title":"Role Purpose","type":"string"},"parent_role_id":{"title":"Reference role_id to higher role","type":"integer"},"application_id":{"title":"Application this role is associated with","type":"integer"},"forest_client_number":{"title":"Forest Client this role is associated with","type":"string"},"create_user":{"title":"Create User","type":"string"},"role_type_code":{"title":"Role Type Code","type":"string"},"client_number":{"$ref":"#/components/schemas/FamForestClientCreate"},"role_id":{"title":"Role Id","type":"integer"}}},"FamApplicationUserRoleAssignmentGet":{"title":"FamApplicationUserRoleAssignmentGet","required":["user_role_xref_id","user_id","role_id","user","role"],"type":"object","properties":{"user_role_xref_id":{"title":"User Role Xref Id","type":"integer"},"user_id":{"title":"User Id","type":"integer"},"role_id":{"title":"Role Id","type":"integer"},"application_id":{"title":"Application Id","type":"integer"},"user":{"$ref":"#/components/schemas/FamUserOnlyName"},"role":{"$ref":"#/components/schemas/FamRoleWithClient"}}},"FamForestClient":{"title":"FamForestClient","required":["forest_client_number"],"type":"object","properties":{"client_name":{"title":"Client Name","type":"string"},"forest_client_number":{"title":"Forest Client Number","type":"string"},"status":{"$ref":"#/components/schemas/FamForestClientStatus"}}},"FamForestClientCreate":{"title":"FamForestClientCreate","required":["forest_client_number","create_user"],"type":"object","properties":{"forest_client_number":{"title":"Forest Client Number","type":"string"},"create_user":{"title":"Create User","type":"string"}}},"FamForestClientStatus":{"title":"FamForestClientStatus","required":["status_code","description"],"type":"object","properties":{"status_code":{"$ref":"#/components/schemas/FamForestClientStatusType"},"description":{"title":"Description","type":"string"}}},"FamForestClientStatusType":{"title":"FamForestClientStatusType","enum":["A","I"],"type":"string","description":"An enumeration."},"FamRoleCreate":{"title":"FamRoleCreate","required":["role_name","application_id","create_user","role_type_code"],"type":"object","properties":{"role_name":{"title":"Role Name","type":"string"},"role_purpose":{"title":"Role Purpose","type":"string"},"parent_role_id":{"title":"Reference role_id to higher role","type":"integer"},"application_id":{"title":"Application this role is associated with","type":"integer"},"forest_client_number":{"title":"Forest Client this role is associated with","type":"string"},"create_user":{"title":"Create User","type":"string"},"role_type_code":{"title":"Role Type Code","type":"string"},"client_number":{"$ref":"#/components/schemas/FamForestClientCreate"}}},"FamRoleGet":{"title":"FamRoleGet","required":["role_name","application_id","create_user","role_type_code","role_id"],"type":"object","properties":{"role_name":{"title":"Role Name","type":"string"},"role_purpose":{"title":"Role Purpose","type":"string"},"parent_role_id":{"title":"Reference role_id to higher role","type":"integer"},"application_id":{"title":"Application this role is associated with","type":"integer"},"forest_client_number":{"title":"Forest Client this role is associated with","type":"string"},"create_user":{"title":"Create User","type":"string"},"role_type_code":{"title":"Role Type Code","type":"string"},"client_number":{"$ref":"#/components/schemas/FamForestClientCreate"},"role_id":{"title":"Role Id","type":"integer"},"update_user":{"title":"Update User","type":"string"},"create_date":{"title":"Create Date","type":"string","format":"date-time"},"update_date":{"title":"Update Date","type":"string","format":"date-time"},"application":{"$ref":"#/components/schemas/FamApplication"}}},"FamRoleMin":{"title":"FamRoleMin","required":["role_name","role_type_code","application_id"],"type":"object","properties":{"role_name":{"title":"Role Name","type":"string"},"role_type_code":{"title":"Role Type Code","type":"string"},"application_id":{"title":"Application Id","type":"integer"}}},"FamRoleWithClient":{"title":"FamRoleWithClient","required":["role_name","application_id","create_user","role_type_code","role_id"],"type":"object","properties":{"role_name":{"title":"Role Name","type":"string"},"role_purpose":{"title":"Role Purpose","type":"string"},"parent_role_id":{"title":"Reference role_id to higher role","type":"integer"},"application_id":{"title":"Application this role is associated with","type":"integer"},"forest_client_number":{"title":"Forest Client this role is associated with","type":"string"},"create_user":{"title":"Create User","type":"string"},"role_type_code":{"title":"Role Type Code","type":"string"},"client_number":{"$ref":"#/components/schemas/FamForestClient"},"role_id":{"title":"Role Id","type":"integer"},"parent_role":{"$ref":"#/components/schemas/FamRoleMin"}}},"FamUser":{"title":"FamUser","required":["user_type_code","user_name","create_user"],"type":"object","properties":{"user_type_code":{"$ref":"#/components/schemas/UserType"},"cognito_user_id":{"title":"Cognito User Id","type":"string"},"user_name":{"title":"User Name","type":"string"},"user_guid":{"title":"User Guid","type":"string"},"create_user":{"title":"Create User","type":"string"},"update_user":{"title":"Update User","type":"string"}}},"FamUserGet":{"title":"FamUserGet","required":["user_type_code","user_name","create_user","user_id","create_date"],"type":"object","properties":{"user_type_code":{"$ref":"#/components/schemas/UserType"},"cognito_user_id":{"title":"Cognito User Id","type":"string"},"user_name":{"title":"User Name","type":"string"},"user_guid":{"title":"User Guid","type":"string"},"create_user":{"title":"Create User","type":"string"},"update_user":{"title":"Update User","type":"string"},"user_id":{"title":"User Id","type":"integer"},"create_date":{"title":"Create Date","type":"string","format":"date-time"},"update_date":{"title":"Update Date","type":"string","format":"date-time"},"role":{"$ref":"#/components/schemas/FamRoleCreate"}}},"FamUserOnlyName":{"title":"FamUserOnlyName","required":["user_type_code","user_name","create_user","user_type"],"type":"object","properties":{"user_type_code":{"$ref":"#/components/schemas/UserType"},"cognito_user_id":{"title":"Cognito User Id","type":"string"},"user_name":{"title":"User Name","type":"string"},"user_guid":{"title":"User Guid","type":"string"},"create_user":{"title":"Create User","type":"string"},"update_user":{"title":"Update User","type":"string"},"user_type":{"$ref":"#/components/schemas/FamUserType"}}},"FamUserRoleAssignmentCreate":{"title":"FamUserRoleAssignmentCreate","required":["user_name","user_type_code","role_id"],"type":"object","properties":{"user_name":{"title":"User Name","type":"string"},"user_type_code":{"$ref":"#/components/schemas/UserType"},"role_id":{"title":"Role Id","type":"integer"},"forest_client_number":{"title":"Forest Client Number","maxLength":8,"minLength":1,"type":"string"}}},"FamUserRoleAssignmentGet":{"title":"FamUserRoleAssignmentGet","required":["user_role_xref_id","user_id","role_id","application_id"],"type":"object","properties":{"user_role_xref_id":{"title":"User Role Xref Id","type":"integer"},"user_id":{"title":"User Id","type":"integer"},"role_id":{"title":"Role Id","type":"integer"},"application_id":{"title":"Application Id","type":"integer"}}},"FamUserType":{"title":"FamUserType","required":["code","description"],"type":"object","properties":{"code":{"$ref":"#/components/schemas/UserType"},"description":{"title":"Description","type":"string"}}},"HTTPValidationError":{"title":"HTTPValidationError","type":"object","properties":{"detail":{"title":"Detail","type":"array","items":{"$ref":"#/components/schemas/ValidationError"}}}},"IdimProxyIdirInfo":{"title":"IdimProxyIdirInfo","required":["found"],"type":"object","properties":{"found":{"title":"Found","type":"boolean"},"userId":{"title":"Userid","type":"string"},"displayName":{"title":"Displayname","type":"string"}}},"UserType":{"title":"UserType","enum":["I","B"],"type":"string","description":"An enumeration."},"ValidationError":{"title":"ValidationError","required":["loc","msg","type"],"type":"object","properties":{"loc":{"title":"Location","type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]}},"msg":{"title":"Message","type":"string"},"type":{"title":"Error Type","type":"string"}}}},"securitySchemes":{"6jfveou69mgford233or30hmta":{"type":"oauth2","flows":{"authorizationCode":{"scopes":{},"authorizationUrl":"https://dev-fam-user-pool-domain.auth.ca-central-1.amazoncognito.com/authorize","tokenUrl":"https://dev-fam-user-pool-domain.auth.ca-central-1.amazoncognito.com/token"}}}}},"tags":[{"name":"Forest Access Management - FAM","description":"Controls the user access to different Forest basedapplications and what roles different users will have once logged in"}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"Forest Access Management - FAM - API","description":"\nForest Access Management API used by the Forest Access Management application\nto Define who has access to what apps, and what roles they will operate under\n once access is granted.\n","contact":{"name":"Guy Lafleur","url":"https://en.wikipedia.org/wiki/Guy_Lafleur","email":"guy.lafleur@montreal.canadians.ca"},"license":{"name":"Apache 2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"version":"0.0.1"},"paths":{"/fam_applications":{"get":{"tags":["FAM Applications"],"summary":"Get Applications","description":"List of different applications that are administered by FAM","operationId":"get_applications","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/FamApplication"},"type":"array","title":"Response Get Applications"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/fam_applications/{application_id}/fam_roles":{"get":{"tags":["FAM Applications"],"summary":"Get Fam Application Roles","description":"gets the roles associated with an application\n\n:param application_id: application id\n:param db: database session, defaults to Depends(database.get_db)","operationId":"get_fam_application_roles","parameters":[{"required":true,"schema":{"type":"integer", "title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/FamApplicationRole"},"type":"array","title":"Response Get Fam Application Roles"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/fam_applications/{application_id}/user_role_assignment":{"get":{"tags":["FAM Applications"],"summary":"Get Fam Application User Role Assignment","description":"gets the roles associated with an application\n\n:param application_id: application id\n:param db: database session, defaults to Depends(database.get_db)","operationId":"get_fam_application_user_role_assignment","parameters":[{"required":true,"schema":{"type":"integer","title":"Application Id"},"name":"application_id","in":"path"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/FamApplicationUserRoleAssignmentGet"},"type":"array","title":"Response Get Fam Application User Role Assignment"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/user_role_assignment":{"post":{"tags":["FAM User Role Assignment"],"summary":"Create User Role Assignment","description":"Create FAM user_role_xref association.","operationId":"create_user_role_assignment","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUserRoleAssignmentCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamUserRoleAssignmentGet"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/user_role_assignment/{user_role_xref_id}":{"delete":{"tags":["FAM User Role Assignment"],"summary":"Delete User Role Assignment","description":"Delete FAM user_role_xref association.","operationId":"delete_user_role_assignment","parameters":[{"required":true,"schema":{"type":"integer","title":"User Role Xref Id"},"name":"user_role_xref_id","in":"path"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/forest_clients/search":{"get":{"tags":["FAM Forest Clients"],"summary":"Search","description":"Forest Client(s) search (by defined query parameter(s)).\n\nparam: 'client_number=[query_value]'\n Note! Current Forest Client API limits it to exact search for a whole 8-digits number.\n\nreturn: List of found FamForestClient. However, currently only 1 exact match returns.","operationId":"search","parameters":[{"required":true,"schema":{"type":"string","maxLength":8,"minLength":3,"title":"Client Number"},"name":"client_number","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/FamForestClient"},"type":"array","title":"Response Search"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/identity_search/idir":{"get":{"tags":["IDIR/BCeID Proxy"],"summary":"Idir Search","operationId":"idir_search","parameters":[{"required":true,"schema":{"type":"string","maxLength":15,"title":"User Id"},"name":"user_id","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdimProxyIdirInfo"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"6jfveou69mgford233or30hmta":[]}]}},"/bcsc/token/dev":{"post":{"tags":["BCSC Proxy"],"summary":"Bcsc Token Dev","operationId":"bcsc_token_dev","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/token/test":{"post":{"tags":["BCSC Proxy"],"summary":"Bcsc Token Test","operationId":"bcsc_token_test","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/token/prod":{"post":{"tags":["BCSC Proxy"],"summary":"Bcsc Token Prod","operationId":"bcsc_token_prod","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/userinfo/dev":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Userinfo Dev","operationId":"bcsc_userinfo_dev","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/userinfo/test":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Userinfo Test","operationId":"bcsc_userinfo_test","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/userinfo/prod":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Userinfo Prod","operationId":"bcsc_userinfo_prod","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/bcsc/jwks.json":{"get":{"tags":["BCSC Proxy"],"summary":"Bcsc Jwks","operationId":"bcsc_jwks","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/smoke_test":{"get":{"tags":["Smoke Test"],"summary":"Smoke Test","description":"List of different applications that are administered by FAM","operationId":"smoke_test","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"AppEnv":{"type":"string","enum":["DEV","TEST","PROD"],"title":"AppEnv","description":"An enumeration."},"FamApplication":{"properties":{"application_name":{"type":"string","maxLength":100,"title":"Application Name"},"application_description":{"type":"string","maxLength":200,"title":"Application Description"},"application_client_id":{"type":"integer","title":"Application Client Id"},"app_environment":{"$ref":"#/components/schemas/AppEnv"},"application_id":{"type":"integer","title":"Application Id"},"create_user":{"type":"string","maxLength":60,"title":"Create User"},"create_date":{"type":"string","format":"date-time","title":"Create Date"},"update_user":{"type":"string","maxLength":60,"title":"Update User"},"update_date":{"type":"string","format":"date-time","title":"Update Date"}},"type":"object","required":["application_name","application_description","application_id","create_user","create_date"],"title":"FamApplication"},"FamApplicationRole":{"properties":{"role_name":{"type":"string","maxLength":100,"title":"Role Name"},"role_purpose":{"type":"string","maxLength":200,"title":"Role Purpose"},"parent_role_id":{"type":"integer","title":"Reference role_id to higher role"},"application_id":{"type":"integer","title":"Application this role is associated with"},"forest_client_number":{"type":"string","maxLength":8,"title":"Forest Client this role is associated with"},"create_user":{"type":"string","maxLength":60,"title":"Create User"},"role_type_code":{"$ref":"#/components/schemas/RoleType"},"client_number":{"$ref":"#/components/schemas/FamForestClientCreate"},"role_id":{"type":"integer","title":"Role Id"}},"type":"object","required":["role_name","application_id","create_user","role_type_code","role_id"],"title":"FamApplicationRole"},"FamApplicationUserRoleAssignmentGet":{"properties":{"user_role_xref_id":{"type":"integer","title":"User Role Xref Id"},"user_id":{"type":"integer","title":"User Id"},"role_id":{"type":"integer","title":"Role Id"},"application_id":{"type":"integer","title":"Application Id"},"user":{"$ref":"#/components/schemas/FamUserOnlyName"},"role":{"$ref":"#/components/schemas/FamRoleWithClient"}},"type":"object","required":["user_role_xref_id","user_id","role_id","user","role"],"title":"FamApplicationUserRoleAssignmentGet"},"FamForestClient":{"properties":{"client_name":{"type":"string","maxLength":60,"title":"Client Name"},"forest_client_number":{"type":"string","maxLength":8,"title":"Forest Client Number"},"status":{"$ref":"#/components/schemas/FamForestClientStatus"}},"type":"object","required":["forest_client_number"],"title":"FamForestClient"},"FamForestClientCreate":{"properties":{"forest_client_number":{"type":"string","maxLength":8,"title":"Forest Client Number"},"create_user":{"type":"string","maxLength":60,"title":"Create User"}},"type":"object","required":["forest_client_number","create_user"],"title":"FamForestClientCreate"},"FamForestClientStatus":{"properties":{"status_code":{"$ref":"#/components/schemas/FamForestClientStatusType"},"description":{"type":"string","maxLength":10,"title":"Description"}},"type":"object","required":["status_code","description"],"title":"FamForestClientStatus"},"FamForestClientStatusType":{"type":"string","enum":["A","I"],"title":"FamForestClientStatusType","description":"An enumeration."},"FamRoleMin":{"properties":{"role_name":{"type":"string","maxLength":100,"title":"Role Name"},"role_type_code":{"$ref":"#/components/schemas/RoleType"},"application_id":{"type":"integer","title":"Application Id"}},"type":"object","required":["role_name","role_type_code","application_id"],"title":"FamRoleMin"},"FamRoleWithClient":{"properties":{"role_name":{"type":"string","maxLength":100,"title":"Role Name"},"role_purpose":{"type":"string","maxLength":200,"title":"Role Purpose"},"parent_role_id":{"type":"integer","title":"Reference role_id to higher role"},"application_id":{"type":"integer","title":"Application this role is associated with"},"forest_client_number":{"type":"string","maxLength":8,"title":"Forest Client this role is associated with"},"create_user":{"type":"string","maxLength":60,"title":"Create User"},"role_type_code":{"$ref":"#/components/schemas/RoleType"},"client_number":{"$ref":"#/components/schemas/FamForestClient"},"role_id":{"type":"integer","title":"Role Id"},"parent_role":{"$ref":"#/components/schemas/FamRoleMin"}},"type":"object","required":["role_name","application_id","create_user","role_type_code","role_id"],"title":"FamRoleWithClient"},"FamUserOnlyName":{"properties":{"user_type_code":{"$ref":"#/components/schemas/UserType"},"cognito_user_id":{"type":"string","maxLength":100,"title":"Cognito User Id"},"user_name":{"type":"string","maxLength":100,"title":"User Name"},"user_guid":{"type":"string","maxLength":32,"title":"User Guid"},"create_user":{"type":"string","maxLength":60,"title":"Create User"},"update_user":{"type":"string","maxLength":60,"title":"Update User"},"user_type":{"$ref":"#/components/schemas/FamUserType"}},"type":"object","required":["user_type_code","user_name","create_user","user_type"],"title":"FamUserOnlyName"},"FamUserRoleAssignmentCreate":{"properties":{"user_name":{"type":"string","maxLength":100,"minLength":3,"title":"User Name"},"user_type_code":{"$ref":"#/components/schemas/UserType"},"role_id":{"type":"integer","title":"Role Id"},"forest_client_number":{"type":"string","maxLength":8,"minLength":1,"title":"Forest Client Number"}},"type":"object","required":["user_name","user_type_code","role_id"],"title":"FamUserRoleAssignmentCreate"},"FamUserRoleAssignmentGet":{"properties":{"user_role_xref_id":{"type":"integer","title":"User Role Xref Id"},"user_id":{"type":"integer","title":"User Id"},"role_id":{"type":"integer","title":"Role Id"},"application_id":{"type":"integer","title":"Application Id"}},"type":"object","required":["user_role_xref_id","user_id","role_id","application_id"],"title":"FamUserRoleAssignmentGet"},"FamUserType":{"properties":{"code":{"$ref":"#/components/schemas/UserType"},"description":{"type":"string","maxLength":35,"title":"Description"}},"type":"object","required":["code","description"],"title":"FamUserType"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"IdimProxyIdirInfo":{"properties":{"found":{"type":"boolean","title":"Found"},"userId":{"type":"string","maxLength":15,"title":"Userid"},"displayName":{"type":"string","maxLength":50,"title":"Displayname"}},"type":"object","required":["found"],"title":"IdimProxyIdirInfo"},"RoleType":{"type":"string","enum":["A","C"],"title":"RoleType","description":"An enumeration."},"UserType":{"type":"string","enum":["I","B"],"title":"UserType","description":"An enumeration."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"6jfveou69mgford233or30hmta":{"type":"oauth2","flows":{"authorizationCode":{"scopes":{},"authorizationUrl":"https://dev-fam-user-pool-domain.auth.ca-central-1.amazoncognito.com/authorize","tokenUrl":"https://dev-fam-user-pool-domain.auth.ca-central-1.amazoncognito.com/token"}}}}},"tags":[{"name":"Forest Access Management - FAM","description":"Controls the user access to different Forest basedapplications and what roles different users will have once logged in"}]} \ No newline at end of file diff --git a/client-code-gen/openapitools.json b/client-code-gen/openapitools.json index c871d87b7..4053ae890 100644 --- a/client-code-gen/openapitools.json +++ b/client-code-gen/openapitools.json @@ -2,6 +2,6 @@ "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "6.2.1" + "version": "7.0.1" } } diff --git a/client-code-gen/package.json b/client-code-gen/package.json index 963fd28cd..13b4dfd87 100644 --- a/client-code-gen/package.json +++ b/client-code-gen/package.json @@ -3,11 +3,11 @@ "version": "1.0.0", "description": "OpenAPI Generation for API Client Code", "scripts": { - "dockergen-api-bash": "docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v6.2.1 generate -i local/openapi.json -g typescript-axios --config local/api.json -o /local/gen", - "dockergen-api-win": "docker run --rm -v %cd%:/local openapitools/openapi-generator-cli:v6.2.1 generate -i local/openapi.json -g typescript-axios --config local/api.json -o local/gen", + "dockergen-api-bash": "docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v7.0.1 generate -i local/openapi.json -g typescript-axios --config local/api.json -o /local/gen", + "dockergen-api-win": "docker run --rm -v %cd%:/local openapitools/openapi-generator-cli:v7.0.1 generate -i local/openapi.json -g typescript-axios --config local/api.json -o local/gen", "gen-api": "rm -rf gen && openapi-generator-cli generate -i openapi.json --generator-name typescript-axios -o gen --config api.json" }, "dependencies": { "@openapitools/openapi-generator-cli": "^2.7.0" } -} +} \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 451aef5d9..f8ca1f825 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -41,10 +41,9 @@ "version": "1.0.0", "license": "Unlicense", "dependencies": { - "axios": "^0.26.1" + "axios": "0.26.1" }, "devDependencies": { - "@types/node": "^18.0.0", "typescript": "^4.0" } }, @@ -27677,8 +27676,7 @@ "fam-api": { "version": "file:../client-code-gen/gen", "requires": { - "@types/node": "^18.0.0", - "axios": "^0.26.1", + "axios": "0.26.1", "typescript": "^4.0" } }, diff --git a/frontend/src/services/ApiServiceFactory.ts b/frontend/src/services/ApiServiceFactory.ts index 2fe8325b6..43784b88c 100644 --- a/frontend/src/services/ApiServiceFactory.ts +++ b/frontend/src/services/ApiServiceFactory.ts @@ -1,18 +1,14 @@ import httpInstance from '@/services/http/HttpCommon'; import { FAMApplicationsApi, - FAMRolesApi, FAMUserRoleAssignmentApi, - FAMUsersApi, FAMForestClientsApi, IDIRBCeIDProxyApi, } from 'fam-api'; export class ApiServiceFactory { private applicationsApi: FAMApplicationsApi; - private rolesApi: FAMRolesApi; private userRoleAssignmentApi: FAMUserRoleAssignmentApi; - private usersApi: FAMUsersApi; private forestClientApi: FAMForestClientsApi; private idirBceidProxyApi: IDIRBCeIDProxyApi; @@ -23,13 +19,11 @@ export class ApiServiceFactory { '', httpInstance ); // Note, Axios is strange, second parameter needs empty string, not null. - this.rolesApi = new FAMRolesApi(undefined, '', httpInstance); this.userRoleAssignmentApi = new FAMUserRoleAssignmentApi( undefined, '', httpInstance ); - this.usersApi = new FAMUsersApi(undefined, '', httpInstance); this.forestClientApi = new FAMForestClientsApi( undefined, '', @@ -46,18 +40,10 @@ export class ApiServiceFactory { return this.applicationsApi; } - getRolesApi(): FAMRolesApi { - return this.rolesApi; - } - getUserRoleAssignmentApi(): FAMUserRoleAssignmentApi { return this.userRoleAssignmentApi; } - getUsersApi(): FAMUsersApi { - return this.usersApi; - } - getForestClientApi(): FAMForestClientsApi { return this.forestClientApi; } diff --git a/server/backend/api/app/main.py b/server/backend/api/app/main.py index 1d6b42860..1b1892061 100644 --- a/server/backend/api/app/main.py +++ b/server/backend/api/app/main.py @@ -15,8 +15,8 @@ from .jwt_validation import init_jwks from .kms_lookup import init_bcsc_public_key from .routers import (router_application, router_bcsc_proxy, - router_forest_client, router_idim_proxy, router_role, - router_smoke_test, router_user, + router_forest_client, router_idim_proxy, + router_smoke_test, router_user_role_assignment) logConfigFile = os.path.join( @@ -72,6 +72,13 @@ def custom_generate_unique_id(route: APIRouter): generate_unique_id_function=custom_generate_unique_id ) +# Temporary assign openapi_version = "3.0.3" to fix not able to generate correct api-client for frontend. +# Due to current fastapi==0.100.0, this default to swagger spec version to 3.1.0, but version 3.1.0 is not +# yet well supported by openapi-generator. +# Also, FastAPI only 'hardcoded' with '3.0.3' it isn't truly convert to 3.0.3 openapi spec. However, it does +# temporarily solve openapi-generator issue. +app.openapi_version = "3.0.3" + app.add_middleware( CORSMiddleware, allow_origins=get_allow_origins(), @@ -104,15 +111,6 @@ def main(): dependencies=[Depends(jwt_validation.authorize)], tags=["IDIR/BCeID Proxy"]) -# These two routers are disabled for MVP - -app.include_router(router_user.router, - prefix=apiPrefix + '/fam_users', - tags=["FAM Users"]) -app.include_router(router_role.router, - prefix=apiPrefix + '/fam_roles', - tags=["FAM Roles"]) - # This router is used to proxy the BCSC userinfo endpoint app.include_router(router_bcsc_proxy.router, diff --git a/server/backend/api/app/routers/router_role.py b/server/backend/api/app/routers/router_role.py deleted file mode 100644 index fff3bc457..000000000 --- a/server/backend/api/app/routers/router_role.py +++ /dev/null @@ -1,55 +0,0 @@ -import logging -from typing import List - -from api.app.crud import crud_role -from fastapi import APIRouter, Depends, HTTPException -from sqlalchemy.exc import IntegrityError -from sqlalchemy.orm import Session - -from .. import database, schemas - -LOGGER = logging.getLogger(__name__) - -router = APIRouter() - - -@router.get("", response_model=List[schemas.FamRoleGet]) -def get_fam_roles(db: Session = Depends(database.get_db)): - """ - List of different roles that are administered by FAM - """ - - raise HTTPException( - status_code=501, - detail={'code': 'not_implemented', - 'description': 'This endpoint is not yet implemented'} - ) - # LOGGER.debug(f"running router ... {db}") - # query_data = crud_role.get_roles(db) - # return query_data - - -@router.post("", response_model=schemas.FamRoleGet) -def create_fam_role( - fam_role: schemas.FamRoleCreate, db: Session = Depends(database.get_db) -): - """ - Add a role to FAM - """ - - raise HTTPException( - status_code=501, - detail={'code': 'not_implemented', - 'description': 'This endpoint is not yet implemented'} - ) - - # query_data = None - # LOGGER.debug(f"running router ... {db}") - # try: - # query_data = crud_role.create_role(fam_role, db) - # LOGGER.debug(f"query_data: {query_data}") - # except IntegrityError as e: - # LOGGER.debug(f"error: {e}") - # raise HTTPException(status_code=422, detail=str(e)) - - # return query_data diff --git a/server/backend/api/app/routers/router_user.py b/server/backend/api/app/routers/router_user.py deleted file mode 100644 index 06cc05c95..000000000 --- a/server/backend/api/app/routers/router_user.py +++ /dev/null @@ -1,95 +0,0 @@ -import logging -from typing import List - -from api.app.crud import crud_user -from fastapi import APIRouter, Depends, HTTPException -from sqlalchemy.exc import IntegrityError -from sqlalchemy.orm import Session - -from .. import database, schemas - -LOGGER = logging.getLogger(__name__) - -router = APIRouter() - - -@router.get("", response_model=List[schemas.FamUserGet]) -def get_users(db: Session = Depends(database.get_db)): - """ - List of different users that are administered by FAM - """ - - raise HTTPException( - status_code=501, - detail={'code': 'not_implemented', - 'description': 'This endpoint is not yet implemented'} - ) - - # LOGGER.debug(f"running router ... {db}") - # query_data = crud_user.get_users(db) - # return query_data - - -@router.post("", response_model=schemas.FamUserGet) -def create_fam_user( - famUser: schemas.FamUser, db: Session = Depends(database.get_db) -): - """ - Add a user to FAM - """ - - raise HTTPException( - status_code=501, - detail={'code': 'not_implemented', - 'description': 'This endpoint is not yet implemented'} - ) - - # query_data = None - # LOGGER.debug(f"running router ... {db}") - # try: - # query_data = crud_user.create_user(famUser, db) - # LOGGER.debug(f"queryData: {query_data}") - # except IntegrityError as e: - # LOGGER.debug(f"error: {e}") - # raise HTTPException(status_code=422, detail=str(e)) - - # return query_data - - -@router.delete("/{user_id}", response_model=schemas.FamUser) -def delete_fam_user(user_id: int, db: Session = Depends(database.get_db)): - """ - Delete a FAM user - """ - - raise HTTPException( - status_code=501, - detail={'code': 'not_implemented', - 'description': 'This endpoint is not yet implemented'} - ) - - # user = crud_user.get_user(user_id=user_id, db=db) - # LOGGER.debug(f"user: {user}") - # if not user: - # raise HTTPException(status_code=404, detail=f"user_id={user_id} does not exist") - # user = crud_user.delete_user(db=db, user_id=user_id) - # return user - - -@router.get("/{user_id}", response_model=schemas.FamUserGet) -def get_fam_user(user_id: int, db: Session = Depends(database.get_db)): - - """ - Get a FAM user - """ - - raise HTTPException( - status_code=501, - detail={'code': 'not_implemented', - 'description': 'This endpoint is not yet implemented'} - ) - - # LOGGER.debug(f"userid is: {user_id}") - # user = crud_user.get_user(user_id=user_id, db=db) - # LOGGER.debug(f"userdata: {user}") - # return user