Skip to content

Commit

Permalink
MINOR: add logging for documents, folder and user invitations (#712)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Bimdata-io committed Jan 2, 2024
1 parent 5ed6aac commit fd63c82
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 2 deletions.
1 change: 1 addition & 0 deletions package/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 64 additions & 2 deletions package/src/apis/CollaborationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ import {
ImportGroupRequest,
ImportGroupRequestFromJSON,
ImportGroupRequestToJSON,
LogEntry,
LogEntryFromJSON,
LogEntryToJSON,
PatchedClassificationRequest,
PatchedClassificationRequestFromJSON,
PatchedClassificationRequestToJSON,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<runtime.ApiResponse<Document>> {
Expand Down Expand Up @@ -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<Document> {
Expand Down Expand Up @@ -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<runtime.ApiResponse<Array<LogEntry>>> {
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<Array<LogEntry>> {
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
Expand Down
109 changes: 109 additions & 0 deletions package/src/models/LogEntry.ts
Original file line number Diff line number Diff line change
@@ -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: [email protected]
*
* 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,
};
}

1 change: 1 addition & 0 deletions package/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit fd63c82

Please sign in to comment.