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 412aa98 commit 59336cc
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ docs/LayerElementRequest.md
docs/LayerRequest.md
docs/Line.md
docs/LineRequest.md
docs/LogEntry.md
docs/MarketplaceAppImage.md
docs/MarketplaceAppLight.md
docs/MarketplaceAppLightRequest.md
Expand Down Expand Up @@ -329,6 +330,7 @@ src/model/LayerElementRequest.js
src/model/LayerRequest.js
src/model/Line.js
src/model/LineRequest.js
src/model/LogEntry.js
src/model/MarketplaceAppImage.js
src/model/MarketplaceAppLight.js
src/model/MarketplaceAppLightRequest.js
Expand Down Expand Up @@ -575,6 +577,7 @@ test/model/LayerElementRequest.spec.js
test/model/LayerRequest.spec.js
test/model/Line.spec.js
test/model/LineRequest.spec.js
test/model/LogEntry.spec.js
test/model/MarketplaceAppImage.spec.js
test/model/MarketplaceAppLight.spec.js
test/model/MarketplaceAppLightRequest.spec.js
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ Class | Method | HTTP request | Description
*bimdata.CollaborationApi* | [**getFolders**](docs/CollaborationApi.md#getFolders) | **GET** /cloud/{cloud_pk}/project/{project_pk}/folder | Retrieve all folders
*bimdata.CollaborationApi* | [**getGroup**](docs/CollaborationApi.md#getGroup) | **GET** /cloud/{cloud_pk}/project/{project_pk}/me/group/{id} | Retrieve a group
*bimdata.CollaborationApi* | [**getGroups**](docs/CollaborationApi.md#getGroups) | **GET** /cloud/{cloud_pk}/project/{project_pk}/me/group | Retrieve all groups
*bimdata.CollaborationApi* | [**getLogs**](docs/CollaborationApi.md#getLogs) | **GET** /cloud/{cloud_pk}/project/{project_pk}/logs | Retrieve all logs of the project
*bimdata.CollaborationApi* | [**getManageGroup**](docs/CollaborationApi.md#getManageGroup) | **GET** /cloud/{cloud_pk}/project/{project_pk}/group/{id} | Retrieve a group
*bimdata.CollaborationApi* | [**getManageGroups**](docs/CollaborationApi.md#getManageGroups) | **GET** /cloud/{cloud_pk}/project/{project_pk}/group | Retrieve all groups
*bimdata.CollaborationApi* | [**getProject**](docs/CollaborationApi.md#getProject) | **GET** /cloud/{cloud_pk}/project/{id} | Retrieve a project
Expand Down Expand Up @@ -704,6 +705,7 @@ Class | Method | HTTP request | Description
- [bimdata.LayerRequest](docs/LayerRequest.md)
- [bimdata.Line](docs/Line.md)
- [bimdata.LineRequest](docs/LineRequest.md)
- [bimdata.LogEntry](docs/LogEntry.md)
- [bimdata.MarketplaceAppImage](docs/MarketplaceAppImage.md)
- [bimdata.MarketplaceAppLight](docs/MarketplaceAppLight.md)
- [bimdata.MarketplaceAppLightRequest](docs/MarketplaceAppLightRequest.md)
Expand Down
66 changes: 65 additions & 1 deletion docs/CollaborationApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Method | HTTP request | Description
[**getFolders**](CollaborationApi.md#getFolders) | **GET** /cloud/{cloud_pk}/project/{project_pk}/folder | Retrieve all folders
[**getGroup**](CollaborationApi.md#getGroup) | **GET** /cloud/{cloud_pk}/project/{project_pk}/me/group/{id} | Retrieve a group
[**getGroups**](CollaborationApi.md#getGroups) | **GET** /cloud/{cloud_pk}/project/{project_pk}/me/group | Retrieve all groups
[**getLogs**](CollaborationApi.md#getLogs) | **GET** /cloud/{cloud_pk}/project/{project_pk}/logs | Retrieve all logs of the project
[**getManageGroup**](CollaborationApi.md#getManageGroup) | **GET** /cloud/{cloud_pk}/project/{project_pk}/group/{id} | Retrieve a group
[**getManageGroups**](CollaborationApi.md#getManageGroups) | **GET** /cloud/{cloud_pk}/project/{project_pk}/group | Retrieve all groups
[**getProject**](CollaborationApi.md#getProject) | **GET** /cloud/{cloud_pk}/project/{id} | Retrieve a project
Expand Down Expand Up @@ -960,7 +961,7 @@ Name | Type | Description | Notes
Create a document

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

### Example

Expand Down Expand Up @@ -3928,6 +3929,69 @@ Name | Type | Description | Notes
- **Accept**: application/json


## getLogs

> [LogEntry] getLogs(cloudPk, projectPk)
Retrieve all logs of the project

Retrieve all logs of the project Required scopes: logs:read

### Example

```javascript
import bimdata from '@bimdata/bimdata-api-client';
let defaultClient = bimdata.ApiClient.instance;
// Configure API key authorization: ApiKey
let ApiKey = defaultClient.authentications['ApiKey'];
ApiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKey.apiKeyPrefix = 'Token';
// Configure OAuth2 access token for authorization: BIMData_Connect
let BIMData_Connect = defaultClient.authentications['BIMData_Connect'];
BIMData_Connect.accessToken = 'YOUR ACCESS TOKEN';
// Configure OAuth2 access token for authorization: BIMData_Connect
let BIMData_Connect = defaultClient.authentications['BIMData_Connect'];
BIMData_Connect.accessToken = 'YOUR ACCESS TOKEN';
// Configure API key authorization: Bearer
let Bearer = defaultClient.authentications['Bearer'];
Bearer.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Bearer.apiKeyPrefix = 'Token';

let apiInstance = new bimdata.CollaborationApi();
let cloudPk = 56; // Number |
let projectPk = 56; // Number |
apiInstance.getLogs(cloudPk, projectPk).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});

```

### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**cloudPk** | **Number**| |
**projectPk** | **Number**| |

### Return type

[**[LogEntry]**](LogEntry.md)

### Authorization

[ApiKey](../README.md#ApiKey), [BIMData_Connect](../README.md#BIMData_Connect), [BIMData_Connect](../README.md#BIMData_Connect), [Bearer](../README.md#Bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json


## getManageGroup

> Group getManageGroup(cloudPk, id, projectPk)
Expand Down
16 changes: 16 additions & 0 deletions docs/LogEntry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# bimdata.LogEntry

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Number** | | [readonly]
**userId** | **Number** | | [readonly]
**userEmail** | **String** | |
**appName** | **String** | |
**projectName** | **String** | |
**date** | **Date** | | [readonly]
**action** | **String** | |
**description** | **{String: Object}** | |


60 changes: 58 additions & 2 deletions src/api/CollaborationApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Group from '../model/Group';
import GroupFolder from '../model/GroupFolder';
import GroupRequest from '../model/GroupRequest';
import ImportGroupRequest from '../model/ImportGroupRequest';
import LogEntry from '../model/LogEntry';
import PatchedClassificationRequest from '../model/PatchedClassificationRequest';
import PatchedCloudRequest from '../model/PatchedCloudRequest';
import PatchedDocumentRequest from '../model/PatchedDocumentRequest';
Expand Down Expand Up @@ -865,7 +866,7 @@ export default class CollaborationApi {

/**
* Create a document
* 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
* @param {Number} cloudPk A unique integer value identifying this cloud.
* @param {Number} projectPk A unique integer value identifying this project.
* @param {String} name Shown name of the file
Expand Down Expand Up @@ -931,7 +932,7 @@ export default class CollaborationApi {

/**
* Create a document
* 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
* @param {Number} cloudPk A unique integer value identifying this cloud.
* @param {Number} projectPk A unique integer value identifying this project.
* @param {String} name Shown name of the file
Expand Down Expand Up @@ -3717,6 +3718,61 @@ export default class CollaborationApi {
}


/**
* Retrieve all logs of the project
* Retrieve all logs of the project Required scopes: logs:read
* @param {Number} cloudPk
* @param {Number} projectPk
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/LogEntry>} and HTTP response
*/
getLogsWithHttpInfo(cloudPk, projectPk) {
let postBody = null;
// verify the required parameter 'cloudPk' is set
if (cloudPk === undefined || cloudPk === null) {
throw new Error("Missing the required parameter 'cloudPk' when calling getLogs");
}
// verify the required parameter 'projectPk' is set
if (projectPk === undefined || projectPk === null) {
throw new Error("Missing the required parameter 'projectPk' when calling getLogs");
}

let pathParams = {
'cloud_pk': cloudPk,
'project_pk': projectPk
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};

let authNames = ['ApiKey', 'BIMData_Connect', 'BIMData_Connect', 'Bearer'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = [LogEntry];
return this.apiClient.callApi(
'/cloud/{cloud_pk}/project/{project_pk}/logs', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null
);
}

/**
* Retrieve all logs of the project
* Retrieve all logs of the project Required scopes: logs:read
* @param {Number} cloudPk
* @param {Number} projectPk
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/LogEntry>}
*/
getLogs(cloudPk, projectPk) {
return this.getLogsWithHttpInfo(cloudPk, projectPk)
.then(function(response_and_data) {
return response_and_data.data;
});
}


/**
* Retrieve a group
* Retrieve a group. Must be an admin of the project Required scopes: org:manage
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import LayerElementRequest from './model/LayerElementRequest';
import LayerRequest from './model/LayerRequest';
import Line from './model/Line';
import LineRequest from './model/LineRequest';
import LogEntry from './model/LogEntry';
import MarketplaceAppImage from './model/MarketplaceAppImage';
import MarketplaceAppLight from './model/MarketplaceAppLight';
import MarketplaceAppLightRequest from './model/MarketplaceAppLightRequest';
Expand Down Expand Up @@ -725,6 +726,12 @@ export {
*/
LineRequest,

/**
* The LogEntry model constructor.
* @property {module:model/LogEntry}
*/
LogEntry,

/**
* The MarketplaceAppImage model constructor.
* @property {module:model/MarketplaceAppImage}
Expand Down
143 changes: 143 additions & 0 deletions src/model/LogEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* 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 ApiClient from '../ApiClient';

/**
* The LogEntry model module.
* @module model/LogEntry
* @version 0.0.0
*/
class LogEntry {
/**
* Constructs a new <code>LogEntry</code>.
* @alias module:model/LogEntry
* @param id {Number}
* @param userId {Number}
* @param userEmail {String}
* @param appName {String}
* @param projectName {String}
* @param date {Date}
* @param action {String}
* @param description {Object.<String, Object>}
*/
constructor(id, userId, userEmail, appName, projectName, date, action, description) {

LogEntry.initialize(this, id, userId, userEmail, appName, projectName, date, action, description);
}

/**
* Initializes the fields of this object.
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
* Only for internal use.
*/
static initialize(obj, id, userId, userEmail, appName, projectName, date, action, description) {
obj['id'] = id;
obj['user_id'] = userId;
obj['user_email'] = userEmail;
obj['app_name'] = appName;
obj['project_name'] = projectName;
obj['date'] = date;
obj['action'] = action;
obj['description'] = description;
}

/**
* Constructs a <code>LogEntry</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/LogEntry} obj Optional instance to populate.
* @return {module:model/LogEntry} The populated <code>LogEntry</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new LogEntry();

if (data.hasOwnProperty('id')) {
obj['id'] = ApiClient.convertToType(data['id'], 'Number');
}
if (data.hasOwnProperty('user_id')) {
obj['user_id'] = ApiClient.convertToType(data['user_id'], 'Number');
}
if (data.hasOwnProperty('user_email')) {
obj['user_email'] = ApiClient.convertToType(data['user_email'], 'String');
}
if (data.hasOwnProperty('app_name')) {
obj['app_name'] = ApiClient.convertToType(data['app_name'], 'String');
}
if (data.hasOwnProperty('project_name')) {
obj['project_name'] = ApiClient.convertToType(data['project_name'], 'String');
}
if (data.hasOwnProperty('date')) {
obj['date'] = ApiClient.convertToType(data['date'], 'Date');
}
if (data.hasOwnProperty('action')) {
obj['action'] = ApiClient.convertToType(data['action'], 'String');
}
if (data.hasOwnProperty('description')) {
obj['description'] = ApiClient.convertToType(data['description'], {'String': Object});
}
}
return obj;
}


}

/**
* @member {Number} id
*/
LogEntry.prototype['id'] = undefined;

/**
* @member {Number} user_id
*/
LogEntry.prototype['user_id'] = undefined;

/**
* @member {String} user_email
*/
LogEntry.prototype['user_email'] = undefined;

/**
* @member {String} app_name
*/
LogEntry.prototype['app_name'] = undefined;

/**
* @member {String} project_name
*/
LogEntry.prototype['project_name'] = undefined;

/**
* @member {Date} date
*/
LogEntry.prototype['date'] = undefined;

/**
* @member {String} action
*/
LogEntry.prototype['action'] = undefined;

/**
* @member {Object.<String, Object>} description
*/
LogEntry.prototype['description'] = undefined;






export default LogEntry;

Loading

0 comments on commit 59336cc

Please sign in to comment.