Skip to content

Commit 1d8e732

Browse files
committed
MINOR: Rework document download flow to be able to log (#1068)
* Rework document download flow to be able to log * Fix n+1 queries
1 parent ca6257b commit 1d8e732

23 files changed

Lines changed: 460 additions & 177 deletions

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ with bimdata_api_client.ApiClient(configuration) as api_client:
144144
projects_pk = 1 # int | A unique integer value identifying this project.
145145
topics_guid = "topics_guid_example" # str |
146146
comment_request = CommentRequest(
147-
author="author_example",
147+
viewpoint_guid="viewpoint_guid_example",
148+
comment="comment_example",
149+
viewpoint_temp_id=1,
148150
date=dateutil_parser('1970-01-01T00:00:00.00Z'),
149151
reply_to_comment_guid="reply_to_comment_guid_example",
150152
modified_author="modified_author_example",
151-
comment="comment_example",
152-
viewpoint_guid="viewpoint_guid_example",
153-
viewpoint_temp_id=1,
153+
author="author_example",
154154
guid="guid_example",
155155
) # CommentRequest | (optional)
156156

@@ -285,6 +285,7 @@ Class | Method | HTTP request | Description
285285
*CollaborationApi* | [**delete_visa_comment**](docs/CollaborationApi.md#delete_visa_comment) | **DELETE** /cloud/{cloud_pk}/project/{project_pk}/document/{document_pk}/visa/{visa_pk}/comment/{id} | Remove a comment
286286
*CollaborationApi* | [**deny_user_invitation**](docs/CollaborationApi.md#deny_user_invitation) | **POST** /user/invitations/{id}/deny | Deny an invitation
287287
*CollaborationApi* | [**deny_validation**](docs/CollaborationApi.md#deny_validation) | **POST** /cloud/{cloud_pk}/project/{project_pk}/document/{document_pk}/visa/{visa_pk}/validation/{id}/deny | Deny a validation
288+
*CollaborationApi* | [**download_document**](docs/CollaborationApi.md#download_document) | **GET** /cloud/{cloud_pk}/project/{project_pk}/document/{id}/download/{dl_token} | Download a document
288289
*CollaborationApi* | [**get_classification**](docs/CollaborationApi.md#get_classification) | **GET** /cloud/{cloud_pk}/project/{project_pk}/classification/{id} | Retrieve a classification
289290
*CollaborationApi* | [**get_classifications**](docs/CollaborationApi.md#get_classifications) | **GET** /cloud/{cloud_pk}/project/{project_pk}/classification | Retrieve all classifications
290291
*CollaborationApi* | [**get_cloud**](docs/CollaborationApi.md#get_cloud) | **GET** /cloud/{id} | Retrieve one cloud

‎bimdata_api_client/api/collaboration_api.py‎

Lines changed: 168 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3379,6 +3379,83 @@ def __init__(self, api_client=None):
33793379
},
33803380
api_client=api_client
33813381
)
3382+
self.download_document_endpoint = _Endpoint(
3383+
settings={
3384+
'response_type': None,
3385+
'auth': [
3386+
'ApiKey',
3387+
'BIMData_Connect',
3388+
'BIMData_Connect',
3389+
'Bearer'
3390+
],
3391+
'endpoint_path': '/cloud/{cloud_pk}/project/{project_pk}/document/{id}/download/{dl_token}',
3392+
'operation_id': 'download_document',
3393+
'http_method': 'GET',
3394+
'servers': None,
3395+
},
3396+
params_map={
3397+
'all': [
3398+
'cloud_pk',
3399+
'dl_token',
3400+
'id',
3401+
'project_pk',
3402+
],
3403+
'required': [
3404+
'cloud_pk',
3405+
'dl_token',
3406+
'id',
3407+
'project_pk',
3408+
],
3409+
'nullable': [
3410+
],
3411+
'enum': [
3412+
],
3413+
'validation': [
3414+
'dl_token',
3415+
]
3416+
},
3417+
root_map={
3418+
'validations': {
3419+
('dl_token',): {
3420+
3421+
'regex': {
3422+
'pattern': r'^[^\/]+$', # noqa: E501
3423+
},
3424+
},
3425+
},
3426+
'allowed_values': {
3427+
},
3428+
'openapi_types': {
3429+
'cloud_pk':
3430+
(int,),
3431+
'dl_token':
3432+
(str,),
3433+
'id':
3434+
(int,),
3435+
'project_pk':
3436+
(int,),
3437+
},
3438+
'attribute_map': {
3439+
'cloud_pk': 'cloud_pk',
3440+
'dl_token': 'dl_token',
3441+
'id': 'id',
3442+
'project_pk': 'project_pk',
3443+
},
3444+
'location_map': {
3445+
'cloud_pk': 'path',
3446+
'dl_token': 'path',
3447+
'id': 'path',
3448+
'project_pk': 'path',
3449+
},
3450+
'collection_format_map': {
3451+
}
3452+
},
3453+
headers_map={
3454+
'accept': [],
3455+
'content_type': [],
3456+
},
3457+
api_client=api_client
3458+
)
33823459
self.get_classification_endpoint = _Endpoint(
33833460
settings={
33843461
'response_type': (Classification,),
@@ -10239,7 +10316,7 @@ def create_document(
1023910316
):
1024010317
"""Create a document # noqa: E501
1024110318

10242-
Create a document. If the document is one of {'DWG', 'GLTF', 'PHOTOSPHERE', 'IFC', 'OBJ', 'DXF', 'POINT_CLOUD'}, a model will be created and attached to this document Required scopes: document:write # noqa: E501
10319+
Create a document. If the document is one of {'GLTF', 'IFC', 'DWG', 'OBJ', 'DXF', 'POINT_CLOUD', 'PHOTOSPHERE'}, a model will be created and attached to this document Required scopes: document:write # noqa: E501
1024310320
This method makes a synchronous HTTP request by default. To make an
1024410321
asynchronous HTTP request, please pass async_req=True
1024510322

@@ -13012,6 +13089,96 @@ def deny_validation(
1301213089
visa_pk
1301313090
return self.deny_validation_endpoint.call_with_http_info(**kwargs)
1301413091

13092+
def download_document(
13093+
self,
13094+
cloud_pk,
13095+
dl_token,
13096+
id,
13097+
project_pk,
13098+
**kwargs
13099+
):
13100+
"""Download a document # noqa: E501
13101+
13102+
Log a document download event and redirect to the file URL Required scopes: document:read # noqa: E501
13103+
This method makes a synchronous HTTP request by default. To make an
13104+
asynchronous HTTP request, please pass async_req=True
13105+
13106+
>>> thread = api.download_document(cloud_pk, dl_token, id, project_pk, async_req=True)
13107+
>>> result = thread.get()
13108+
13109+
Args:
13110+
cloud_pk (int): A unique integer value identifying this cloud.
13111+
dl_token (str):
13112+
id (int): A unique integer value identifying this document.
13113+
project_pk (int): A unique integer value identifying this project.
13114+
13115+
Keyword Args:
13116+
_return_http_data_only (bool): response data without head status
13117+
code and headers. Default is True.
13118+
_preload_content (bool): if False, the urllib3.HTTPResponse object
13119+
will be returned without reading/decoding response data.
13120+
Default is True.
13121+
_request_timeout (int/float/tuple): timeout setting for this request. If
13122+
one number provided, it will be total request timeout. It can also
13123+
be a pair (tuple) of (connection, read) timeouts.
13124+
Default is None.
13125+
_check_input_type (bool): specifies if type checking
13126+
should be done one the data sent to the server.
13127+
Default is True.
13128+
_check_return_type (bool): specifies if type checking
13129+
should be done one the data received from the server.
13130+
Default is True.
13131+
_spec_property_naming (bool): True if the variable names in the input data
13132+
are serialized names, as specified in the OpenAPI document.
13133+
False if the variable names in the input data
13134+
are pythonic names, e.g. snake case (default)
13135+
_content_type (str/None): force body content-type.
13136+
Default is None and content-type will be predicted by allowed
13137+
content-types and body.
13138+
_host_index (int/None): specifies the index of the server
13139+
that we want to use.
13140+
Default is read from the configuration.
13141+
async_req (bool): execute request asynchronously
13142+
13143+
Returns:
13144+
None
13145+
If the method is called asynchronously, returns the request
13146+
thread.
13147+
"""
13148+
kwargs['async_req'] = kwargs.get(
13149+
'async_req', False
13150+
)
13151+
kwargs['_return_http_data_only'] = kwargs.get(
13152+
'_return_http_data_only', True
13153+
)
13154+
kwargs['_preload_content'] = kwargs.get(
13155+
'_preload_content', True
13156+
)
13157+
kwargs['_request_timeout'] = kwargs.get(
13158+
'_request_timeout', None
13159+
)
13160+
kwargs['_check_input_type'] = kwargs.get(
13161+
'_check_input_type', True
13162+
)
13163+
kwargs['_check_return_type'] = kwargs.get(
13164+
'_check_return_type', True
13165+
)
13166+
kwargs['_spec_property_naming'] = kwargs.get(
13167+
'_spec_property_naming', False
13168+
)
13169+
kwargs['_content_type'] = kwargs.get(
13170+
'_content_type')
13171+
kwargs['_host_index'] = kwargs.get('_host_index')
13172+
kwargs['cloud_pk'] = \
13173+
cloud_pk
13174+
kwargs['dl_token'] = \
13175+
dl_token
13176+
kwargs['id'] = \
13177+
id
13178+
kwargs['project_pk'] = \
13179+
project_pk
13180+
return self.download_document_endpoint.call_with_http_info(**kwargs)
13181+
1301513182
def get_classification(
1301613183
self,
1301713184
cloud_pk,

‎bimdata_api_client/model/comment.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class Comment(ModelNormal):
5959
}
6060

6161
validations = {
62-
('author',): {
62+
('modified_author',): {
6363
'max_length': 254,
6464
},
65-
('modified_author',): {
65+
('author',): {
6666
'max_length': 254,
6767
},
6868
}
@@ -90,12 +90,12 @@ def openapi_types():
9090
return {
9191
'modified_date': (datetime,), # noqa: E501
9292
'topic_guid': (str,), # noqa: E501
93-
'author': (str, none_type,), # noqa: E501
93+
'viewpoint_guid': (str, none_type,), # noqa: E501
94+
'comment': (str,), # noqa: E501
9495
'date': (datetime,), # noqa: E501
9596
'reply_to_comment_guid': (str, none_type,), # noqa: E501
9697
'modified_author': (str, none_type,), # noqa: E501
97-
'comment': (str,), # noqa: E501
98-
'viewpoint_guid': (str, none_type,), # noqa: E501
98+
'author': (str, none_type,), # noqa: E501
9999
'guid': (str,), # noqa: E501
100100
}
101101

@@ -107,12 +107,12 @@ def discriminator():
107107
attribute_map = {
108108
'modified_date': 'modified_date', # noqa: E501
109109
'topic_guid': 'topic_guid', # noqa: E501
110-
'author': 'author', # noqa: E501
110+
'viewpoint_guid': 'viewpoint_guid', # noqa: E501
111+
'comment': 'comment', # noqa: E501
111112
'date': 'date', # noqa: E501
112113
'reply_to_comment_guid': 'reply_to_comment_guid', # noqa: E501
113114
'modified_author': 'modified_author', # noqa: E501
114-
'comment': 'comment', # noqa: E501
115-
'viewpoint_guid': 'viewpoint_guid', # noqa: E501
115+
'author': 'author', # noqa: E501
116116
'guid': 'guid', # noqa: E501
117117
}
118118

@@ -163,12 +163,12 @@ def _from_openapi_data(cls, modified_date, topic_guid, *args, **kwargs): # noqa
163163
Animal class but this time we won't travel
164164
through its discriminator because we passed in
165165
_visited_composed_classes = (Animal,)
166-
author (str, none_type): [optional] # noqa: E501
166+
viewpoint_guid (str, none_type): [optional] # noqa: E501
167+
comment (str): [optional] # noqa: E501
167168
date (datetime): [optional] # noqa: E501
168169
reply_to_comment_guid (str, none_type): [optional] # noqa: E501
169170
modified_author (str, none_type): [optional] # noqa: E501
170-
comment (str): [optional] # noqa: E501
171-
viewpoint_guid (str, none_type): [optional] # noqa: E501
171+
author (str, none_type): [optional] # noqa: E501
172172
guid (str): [optional] # noqa: E501
173173
"""
174174

@@ -253,12 +253,12 @@ def __init__(self, *args, **kwargs): # noqa: E501
253253
Animal class but this time we won't travel
254254
through its discriminator because we passed in
255255
_visited_composed_classes = (Animal,)
256-
author (str, none_type): [optional] # noqa: E501
256+
viewpoint_guid (str, none_type): [optional] # noqa: E501
257+
comment (str): [optional] # noqa: E501
257258
date (datetime): [optional] # noqa: E501
258259
reply_to_comment_guid (str, none_type): [optional] # noqa: E501
259260
modified_author (str, none_type): [optional] # noqa: E501
260-
comment (str): [optional] # noqa: E501
261-
viewpoint_guid (str, none_type): [optional] # noqa: E501
261+
author (str, none_type): [optional] # noqa: E501
262262
guid (str): [optional] # noqa: E501
263263
"""
264264

‎bimdata_api_client/model/comment_request.py‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class CommentRequest(ModelNormal):
5959
}
6060

6161
validations = {
62-
('author',): {
62+
('modified_author',): {
6363
'max_length': 254,
6464
},
65-
('modified_author',): {
65+
('author',): {
6666
'max_length': 254,
6767
},
6868
}
@@ -88,13 +88,13 @@ def openapi_types():
8888
and the value is attribute type.
8989
"""
9090
return {
91-
'author': (str, none_type,), # noqa: E501
91+
'viewpoint_guid': (str, none_type,), # noqa: E501
92+
'comment': (str,), # noqa: E501
93+
'viewpoint_temp_id': (int,), # noqa: E501
9294
'date': (datetime,), # noqa: E501
9395
'reply_to_comment_guid': (str, none_type,), # noqa: E501
9496
'modified_author': (str, none_type,), # noqa: E501
95-
'comment': (str,), # noqa: E501
96-
'viewpoint_guid': (str, none_type,), # noqa: E501
97-
'viewpoint_temp_id': (int,), # noqa: E501
97+
'author': (str, none_type,), # noqa: E501
9898
'guid': (str,), # noqa: E501
9999
}
100100

@@ -104,13 +104,13 @@ def discriminator():
104104

105105

106106
attribute_map = {
107-
'author': 'author', # noqa: E501
107+
'viewpoint_guid': 'viewpoint_guid', # noqa: E501
108+
'comment': 'comment', # noqa: E501
109+
'viewpoint_temp_id': 'viewpoint_temp_id', # noqa: E501
108110
'date': 'date', # noqa: E501
109111
'reply_to_comment_guid': 'reply_to_comment_guid', # noqa: E501
110112
'modified_author': 'modified_author', # noqa: E501
111-
'comment': 'comment', # noqa: E501
112-
'viewpoint_guid': 'viewpoint_guid', # noqa: E501
113-
'viewpoint_temp_id': 'viewpoint_temp_id', # noqa: E501
113+
'author': 'author', # noqa: E501
114114
'guid': 'guid', # noqa: E501
115115
}
116116

@@ -155,13 +155,13 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
155155
Animal class but this time we won't travel
156156
through its discriminator because we passed in
157157
_visited_composed_classes = (Animal,)
158-
author (str, none_type): [optional] # noqa: E501
158+
viewpoint_guid (str, none_type): [optional] # noqa: E501
159+
comment (str): [optional] # noqa: E501
160+
viewpoint_temp_id (int): Only used when using POST on the full-topic route to bind viewpoint with comment. [optional] # noqa: E501
159161
date (datetime): [optional] # noqa: E501
160162
reply_to_comment_guid (str, none_type): [optional] # noqa: E501
161163
modified_author (str, none_type): [optional] # noqa: E501
162-
comment (str): [optional] # noqa: E501
163-
viewpoint_guid (str, none_type): [optional] # noqa: E501
164-
viewpoint_temp_id (int): Only used when using POST on the full-topic route to bind viewpoint with comment. [optional] # noqa: E501
164+
author (str, none_type): [optional] # noqa: E501
165165
guid (str): [optional] # noqa: E501
166166
"""
167167

@@ -244,13 +244,13 @@ def __init__(self, *args, **kwargs): # noqa: E501
244244
Animal class but this time we won't travel
245245
through its discriminator because we passed in
246246
_visited_composed_classes = (Animal,)
247-
author (str, none_type): [optional] # noqa: E501
247+
viewpoint_guid (str, none_type): [optional] # noqa: E501
248+
comment (str): [optional] # noqa: E501
249+
viewpoint_temp_id (int): Only used when using POST on the full-topic route to bind viewpoint with comment. [optional] # noqa: E501
248250
date (datetime): [optional] # noqa: E501
249251
reply_to_comment_guid (str, none_type): [optional] # noqa: E501
250252
modified_author (str, none_type): [optional] # noqa: E501
251-
comment (str): [optional] # noqa: E501
252-
viewpoint_guid (str, none_type): [optional] # noqa: E501
253-
viewpoint_temp_id (int): Only used when using POST on the full-topic route to bind viewpoint with comment. [optional] # noqa: E501
253+
author (str, none_type): [optional] # noqa: E501
254254
guid (str): [optional] # noqa: E501
255255
"""
256256

0 commit comments

Comments
 (0)