From fd63c828c862b21e74009af30eff167dd0e8b806 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Tue, 2 Jan 2024 10:31:51 +0000 Subject: [PATCH] MINOR: add logging for documents, folder and user invitations (#712) * first implementation with documents * implement and test documents and folders * aborted try to test folder permission propagation * fix test get_path * add project invitation logs * improve admin * typo * add log view test and scope * fix check_access test * commit app migrations --- package/.openapi-generator/FILES | 1 + package/src/apis/CollaborationApi.ts | 66 +++++++++++++++- package/src/models/LogEntry.ts | 109 +++++++++++++++++++++++++++ package/src/models/index.ts | 1 + 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 package/src/models/LogEntry.ts diff --git a/package/.openapi-generator/FILES b/package/.openapi-generator/FILES index 3ee24d7..5f00bc8 100644 --- a/package/.openapi-generator/FILES +++ b/package/.openapi-generator/FILES @@ -78,6 +78,7 @@ src/models/LayerElementRequest.ts src/models/LayerRequest.ts src/models/Line.ts src/models/LineRequest.ts +src/models/LogEntry.ts src/models/MarketplaceAppImage.ts src/models/MarketplaceAppLight.ts src/models/MarketplaceAppLightRequest.ts diff --git a/package/src/apis/CollaborationApi.ts b/package/src/apis/CollaborationApi.ts index b02e0d2..af11d9c 100644 --- a/package/src/apis/CollaborationApi.ts +++ b/package/src/apis/CollaborationApi.ts @@ -69,6 +69,9 @@ import { ImportGroupRequest, ImportGroupRequestFromJSON, ImportGroupRequestToJSON, + LogEntry, + LogEntryFromJSON, + LogEntryToJSON, PatchedClassificationRequest, PatchedClassificationRequestFromJSON, PatchedClassificationRequestToJSON, @@ -574,6 +577,11 @@ export interface GetGroupsRequest { project_pk: number; } +export interface GetLogsRequest { + cloud_pk: number; + project_pk: number; +} + export interface GetManageGroupRequest { cloud_pk: number; id: number; @@ -1647,7 +1655,7 @@ export class CollaborationApi extends runtime.BaseAPI { } /** - * Create a document. If the document is one of {\'DWG\', \'IFC\', \'GLTF\', \'POINT_CLOUD\', \'OBJ\', \'DXF\'}, a model will be created and attached to this document Required scopes: document:write + * Create a document. If the document is one of {\'GLTF\', \'POINT_CLOUD\', \'DWG\', \'OBJ\', \'IFC\', \'DXF\'}, a model will be created and attached to this document Required scopes: document:write * Create a document */ async createDocumentRaw(requestParameters: CreateDocumentRequest, initOverrides?: RequestInit): Promise> { @@ -1750,7 +1758,7 @@ export class CollaborationApi extends runtime.BaseAPI { } /** - * Create a document. If the document is one of {\'DWG\', \'IFC\', \'GLTF\', \'POINT_CLOUD\', \'OBJ\', \'DXF\'}, a model will be created and attached to this document Required scopes: document:write + * Create a document. If the document is one of {\'GLTF\', \'POINT_CLOUD\', \'DWG\', \'OBJ\', \'IFC\', \'DXF\'}, a model will be created and attached to this document Required scopes: document:write * Create a document */ async createDocument(cloud_pk: number, project_pk: number, name: string, file: Blob, parent_id?: number | null, file_name?: string, description?: string | null, model_source?: CreateDocumentModelSourceEnum, ifc_source?: CreateDocumentIfcSourceEnum, successor_of?: number, initOverrides?: RequestInit): Promise { @@ -4445,6 +4453,60 @@ export class CollaborationApi extends runtime.BaseAPI { return await response.value(); } + /** + * Retrieve all logs of the project Required scopes: logs:read + * Retrieve all logs of the project + */ + async getLogsRaw(requestParameters: GetLogsRequest, initOverrides?: RequestInit): Promise>> { + if (requestParameters.cloud_pk === null || requestParameters.cloud_pk === undefined) { + throw new runtime.RequiredError('cloud_pk','Required parameter requestParameters.cloud_pk was null or undefined when calling getLogs.'); + } + + if (requestParameters.project_pk === null || requestParameters.project_pk === undefined) { + throw new runtime.RequiredError('project_pk','Required parameter requestParameters.project_pk was null or undefined when calling getLogs.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // ApiKey authentication + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("BIMData_Connect", []); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("BIMData_Connect", []); + } + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // Bearer authentication + } + + const response = await this.request({ + path: `/cloud/{cloud_pk}/project/{project_pk}/logs`.replace(`{${"cloud_pk"}}`, encodeURIComponent(String(requestParameters.cloud_pk))).replace(`{${"project_pk"}}`, encodeURIComponent(String(requestParameters.project_pk))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(LogEntryFromJSON)); + } + + /** + * Retrieve all logs of the project Required scopes: logs:read + * Retrieve all logs of the project + */ + async getLogs(cloud_pk: number, project_pk: number, initOverrides?: RequestInit): Promise> { + const response = await this.getLogsRaw({ cloud_pk: cloud_pk, project_pk: project_pk }, initOverrides); + return await response.value(); + } + /** * Retrieve a group. Must be an admin of the project Required scopes: org:manage * Retrieve a group diff --git a/package/src/models/LogEntry.ts b/package/src/models/LogEntry.ts new file mode 100644 index 0000000..6bc14c2 --- /dev/null +++ b/package/src/models/LogEntry.ts @@ -0,0 +1,109 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * BIMData API + * BIMData API is a tool to interact with your models stored on BIMData’s servers. Through the API, you can manage your projects, the clouds, upload your IFC files and manage them through endpoints. + * + * The version of the OpenAPI document: v1 (v1) + * Contact: support@bimdata.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface LogEntry + */ +export interface LogEntry { + /** + * + * @type {number} + * @memberof LogEntry + */ + readonly id: number; + /** + * + * @type {number} + * @memberof LogEntry + */ + readonly user_id: number | null; + /** + * + * @type {string} + * @memberof LogEntry + */ + user_email: string; + /** + * + * @type {string} + * @memberof LogEntry + */ + app_name: string; + /** + * + * @type {string} + * @memberof LogEntry + */ + project_name: string; + /** + * + * @type {Date} + * @memberof LogEntry + */ + readonly date: Date; + /** + * + * @type {string} + * @memberof LogEntry + */ + action: string; + /** + * + * @type {{ [key: string]: any; }} + * @memberof LogEntry + */ + description: { [key: string]: any; }; +} + +export function LogEntryFromJSON(json: any): LogEntry { + return LogEntryFromJSONTyped(json, false); +} + +export function LogEntryFromJSONTyped(json: any, ignoreDiscriminator: boolean): LogEntry { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': json['id'], + 'user_id': json['user_id'], + 'user_email': json['user_email'], + 'app_name': json['app_name'], + 'project_name': json['project_name'], + 'date': (new Date(json['date'])), + 'action': json['action'], + 'description': json['description'], + }; +} + +export function LogEntryToJSON(value?: LogEntry | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'user_email': value.user_email, + 'app_name': value.app_name, + 'project_name': value.project_name, + 'action': value.action, + 'description': value.description, + }; +} + diff --git a/package/src/models/index.ts b/package/src/models/index.ts index 55217cd..1bf2d73 100644 --- a/package/src/models/index.ts +++ b/package/src/models/index.ts @@ -71,6 +71,7 @@ export * from './LayerElementRequest'; export * from './LayerRequest'; export * from './Line'; export * from './LineRequest'; +export * from './LogEntry'; export * from './MarketplaceAppImage'; export * from './MarketplaceAppLight'; export * from './MarketplaceAppLightRequest';