Skip to content

Commit 5f6f792

Browse files
committed
Minor: Add ability to invite user in cloud & all projects (#744)
* Minor: Add ability to invite user in cloud & all projects * Improve performance & fixes * Fix cloud invite when project invite already exists * Fix more bugs in invitation process. * Fix bug where last admin can leave if an admin invit exists. * Remove useless sql query.
1 parent 157b488 commit 5f6f792

8 files changed

Lines changed: 58 additions & 16 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ Class | Method | HTTP request | Description
309309
*CollaborationApi* | [**get_visas**](docs/CollaborationApi.md#get_visas) | **GET** /cloud/{cloud_pk}/project/{project_pk}/document/{document_pk}/visa | List all visas of a document
310310
*CollaborationApi* | [**import_from_project**](docs/CollaborationApi.md#import_from_project) | **POST** /cloud/{cloud_pk}/project/{id}/import_from | Import data from a project
311311
*CollaborationApi* | [**import_manage_group**](docs/CollaborationApi.md#import_manage_group) | **POST** /cloud/{cloud_pk}/project/{project_pk}/group/import | Import a group from another project
312-
*CollaborationApi* | [**invite_cloud_user**](docs/CollaborationApi.md#invite_cloud_user) | **POST** /cloud/{cloud_pk}/invitation | Invite a cloud administrator
312+
*CollaborationApi* | [**invite_cloud_user**](docs/CollaborationApi.md#invite_cloud_user) | **POST** /cloud/{cloud_pk}/invitation | Invite a cloud member
313313
*CollaborationApi* | [**invite_project_user**](docs/CollaborationApi.md#invite_project_user) | **POST** /cloud/{cloud_pk}/project/{project_pk}/invitation | Invite a project member
314314
*CollaborationApi* | [**leave_project**](docs/CollaborationApi.md#leave_project) | **POST** /cloud/{cloud_pk}/project/{id}/leave | Leave the project
315315
*CollaborationApi* | [**leave_version_document_history**](docs/CollaborationApi.md#leave_version_document_history) | **POST** /cloud/{cloud_pk}/project/{project_pk}/document/{document_pk}/history/{id}/leave | Leave the history version
@@ -758,7 +758,7 @@ Class | Method | HTTP request | Description
758758

759759
- **Type**: OAuth
760760
- **Flow**: implicit
761-
- **Authorization URL**: http://fakeurl.bimdata.io/realms/bimdata/protocol/openid-connect/auth
761+
- **Authorization URL**: http://fakeurl.bimdata.example/realms/bimdata/protocol/openid-connect/auth
762762
- **Scopes**: N/A
763763

764764

bimdata_api_client/api/collaboration_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8741,7 +8741,7 @@ def create_document(
87418741
):
87428742
"""Create a document # noqa: E501
87438743

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

@@ -15038,9 +15038,9 @@ def invite_cloud_user(
1503815038
cloud_invitation_request,
1503915039
**kwargs
1504015040
):
15041-
"""Invite a cloud administrator # noqa: E501
15041+
"""Invite a cloud member # noqa: E501
1504215042

15043-
Invite cloud administrators only. To invite in a project, see inviteProjectUser. You can't invite a user already in the cloud. Create multiple invitations of the same email in the same cloud will generate multiple invitation emails but not multiple invitation object Required scopes: org:manage # noqa: E501
15043+
Invite a cloud member. To invite in a project, see inviteProjectUser. You can't invite a user already in the cloud. Create multiple invitations of the same email in the same cloud will generate multiple invitation emails but not multiple invitation object Required scopes: org:manage # noqa: E501
1504415044
This method makes a synchronous HTTP request by default. To make an
1504515045
asynchronous HTTP request, please pass async_req=True
1504615046

bimdata_api_client/model/cloud_invitation.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class CloudInvitation(ModelNormal):
6060
'100': 100,
6161
'50': 50,
6262
},
63+
('project_role',): {
64+
'100': 100,
65+
'50': 50,
66+
'25': 25,
67+
},
6368
}
6469

6570
validations = {
@@ -96,6 +101,8 @@ def openapi_types():
96101
'email': (str,), # noqa: E501
97102
'redirect_uri': (str,), # noqa: E501
98103
'role': (int,), # noqa: E501
104+
'project_role': (int,), # noqa: E501
105+
'in_all_projects': (bool,), # noqa: E501
99106
}
100107

101108
@cached_property
@@ -108,25 +115,25 @@ def discriminator():
108115
'email': 'email', # noqa: E501
109116
'redirect_uri': 'redirect_uri', # noqa: E501
110117
'role': 'role', # noqa: E501
118+
'project_role': 'project_role', # noqa: E501
119+
'in_all_projects': 'in_all_projects', # noqa: E501
111120
}
112121

113122
read_only_vars = {
114123
'id', # noqa: E501
115-
'role', # noqa: E501
116124
}
117125

118126
_composed_schemas = {}
119127

120128
@classmethod
121129
@convert_js_args_to_python_args
122-
def _from_openapi_data(cls, id, email, redirect_uri, role, *args, **kwargs): # noqa: E501
130+
def _from_openapi_data(cls, id, email, redirect_uri, *args, **kwargs): # noqa: E501
123131
"""CloudInvitation - a model defined in OpenAPI
124132
125133
Args:
126134
id (int):
127135
email (str): email of the user to invite
128136
redirect_uri (str): User will be redirected to this uri when they accept the invitation
129-
role (int): * `100` - admin * `50` - user
130137
131138
Keyword Args:
132139
_check_type (bool): if True, values for parameters in openapi_types
@@ -159,6 +166,9 @@ def _from_openapi_data(cls, id, email, redirect_uri, role, *args, **kwargs): #
159166
Animal class but this time we won't travel
160167
through its discriminator because we passed in
161168
_visited_composed_classes = (Animal,)
169+
role (int): * `100` - admin * `50` - user. [optional] if omitted the server will use the default value of 100 # noqa: E501
170+
project_role (int): * `100` - admin * `50` - user * `25` - guest. [optional] # noqa: E501
171+
in_all_projects (bool): When inviting non-admin cloud user, specify if the user will be invited in all existing projects. project_role needs to be specified.. [optional] if omitted the server will use the default value of False # noqa: E501
162172
"""
163173

164174
_check_type = kwargs.pop('_check_type', True)
@@ -189,7 +199,6 @@ def _from_openapi_data(cls, id, email, redirect_uri, role, *args, **kwargs): #
189199
self.id = id
190200
self.email = email
191201
self.redirect_uri = redirect_uri
192-
self.role = role
193202
for var_name, var_value in kwargs.items():
194203
if var_name not in self.attribute_map and \
195204
self._configuration is not None and \
@@ -215,6 +224,7 @@ def __init__(self, email, redirect_uri, *args, **kwargs): # noqa: E501
215224
216225
email (str): email of the user to invite
217226
redirect_uri (str): User will be redirected to this uri when they accept the invitation
227+
218228
Keyword Args:
219229
_check_type (bool): if True, values for parameters in openapi_types
220230
will be type checked and a TypeError will be
@@ -246,6 +256,9 @@ def __init__(self, email, redirect_uri, *args, **kwargs): # noqa: E501
246256
Animal class but this time we won't travel
247257
through its discriminator because we passed in
248258
_visited_composed_classes = (Animal,)
259+
role (int): * `100` - admin * `50` - user. [optional] if omitted the server will use the default value of 100 # noqa: E501
260+
project_role (int): * `100` - admin * `50` - user * `25` - guest. [optional] # noqa: E501
261+
in_all_projects (bool): When inviting non-admin cloud user, specify if the user will be invited in all existing projects. project_role needs to be specified.. [optional] if omitted the server will use the default value of False # noqa: E501
249262
"""
250263

251264
_check_type = kwargs.pop('_check_type', True)

bimdata_api_client/model/cloud_invitation_request.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ class CloudInvitationRequest(ModelNormal):
5656
"""
5757

5858
allowed_values = {
59+
('role',): {
60+
'100': 100,
61+
'50': 50,
62+
},
63+
('project_role',): {
64+
'100': 100,
65+
'50': 50,
66+
'25': 25,
67+
},
5968
}
6069

6170
validations = {
@@ -92,6 +101,9 @@ def openapi_types():
92101
return {
93102
'email': (str,), # noqa: E501
94103
'redirect_uri': (str,), # noqa: E501
104+
'role': (int,), # noqa: E501
105+
'project_role': (int,), # noqa: E501
106+
'in_all_projects': (bool,), # noqa: E501
95107
}
96108

97109
@cached_property
@@ -102,6 +114,9 @@ def discriminator():
102114
attribute_map = {
103115
'email': 'email', # noqa: E501
104116
'redirect_uri': 'redirect_uri', # noqa: E501
117+
'role': 'role', # noqa: E501
118+
'project_role': 'project_role', # noqa: E501
119+
'in_all_projects': 'in_all_projects', # noqa: E501
105120
}
106121

107122
read_only_vars = {
@@ -149,6 +164,9 @@ def _from_openapi_data(cls, email, redirect_uri, *args, **kwargs): # noqa: E501
149164
Animal class but this time we won't travel
150165
through its discriminator because we passed in
151166
_visited_composed_classes = (Animal,)
167+
role (int): * `100` - admin * `50` - user. [optional] if omitted the server will use the default value of 100 # noqa: E501
168+
project_role (int): * `100` - admin * `50` - user * `25` - guest. [optional] # noqa: E501
169+
in_all_projects (bool): When inviting non-admin cloud user, specify if the user will be invited in all existing projects. project_role needs to be specified.. [optional] if omitted the server will use the default value of False # noqa: E501
152170
"""
153171

154172
_check_type = kwargs.pop('_check_type', True)
@@ -236,6 +254,9 @@ def __init__(self, email, redirect_uri, *args, **kwargs): # noqa: E501
236254
Animal class but this time we won't travel
237255
through its discriminator because we passed in
238256
_visited_composed_classes = (Animal,)
257+
role (int): * `100` - admin * `50` - user. [optional] if omitted the server will use the default value of 100 # noqa: E501
258+
project_role (int): * `100` - admin * `50` - user * `25` - guest. [optional] # noqa: E501
259+
in_all_projects (bool): When inviting non-admin cloud user, specify if the user will be invited in all existing projects. project_role needs to be specified.. [optional] if omitted the server will use the default value of False # noqa: E501
239260
"""
240261

241262
_check_type = kwargs.pop('_check_type', True)

docs/CloudInvitation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Name | Type | Description | Notes
77
**id** | **int** | | [readonly]
88
**email** | **str** | email of the user to invite |
99
**redirect_uri** | **str** | User will be redirected to this uri when they accept the invitation |
10-
**role** | **int** | * `100` - admin * `50` - user | [readonly]
10+
**role** | **int** | * `100` - admin * `50` - user | [optional] if omitted the server will use the default value of 100
11+
**project_role** | **int** | * `100` - admin * `50` - user * `25` - guest | [optional]
12+
**in_all_projects** | **bool** | When inviting non-admin cloud user, specify if the user will be invited in all existing projects. project_role needs to be specified. | [optional] if omitted the server will use the default value of False
1113
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
1214

1315
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

docs/CloudInvitationRequest.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**email** | **str** | email of the user to invite |
88
**redirect_uri** | **str** | User will be redirected to this uri when they accept the invitation |
9+
**role** | **int** | * `100` - admin * `50` - user | [optional] if omitted the server will use the default value of 100
10+
**project_role** | **int** | * `100` - admin * `50` - user * `25` - guest | [optional]
11+
**in_all_projects** | **bool** | When inviting non-admin cloud user, specify if the user will be invited in all existing projects. project_role needs to be specified. | [optional] if omitted the server will use the default value of False
912
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
1013

1114
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

docs/CollaborationApi.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Method | HTTP request | Description
9191
[**get_visas**](CollaborationApi.md#get_visas) | **GET** /cloud/{cloud_pk}/project/{project_pk}/document/{document_pk}/visa | List all visas of a document
9292
[**import_from_project**](CollaborationApi.md#import_from_project) | **POST** /cloud/{cloud_pk}/project/{id}/import_from | Import data from a project
9393
[**import_manage_group**](CollaborationApi.md#import_manage_group) | **POST** /cloud/{cloud_pk}/project/{project_pk}/group/import | Import a group from another project
94-
[**invite_cloud_user**](CollaborationApi.md#invite_cloud_user) | **POST** /cloud/{cloud_pk}/invitation | Invite a cloud administrator
94+
[**invite_cloud_user**](CollaborationApi.md#invite_cloud_user) | **POST** /cloud/{cloud_pk}/invitation | Invite a cloud member
9595
[**invite_project_user**](CollaborationApi.md#invite_project_user) | **POST** /cloud/{cloud_pk}/project/{project_pk}/invitation | Invite a project member
9696
[**leave_project**](CollaborationApi.md#leave_project) | **POST** /cloud/{cloud_pk}/project/{id}/leave | Leave the project
9797
[**leave_version_document_history**](CollaborationApi.md#leave_version_document_history) | **POST** /cloud/{cloud_pk}/project/{project_pk}/document/{document_pk}/history/{id}/leave | Leave the history version
@@ -1541,7 +1541,7 @@ Name | Type | Description | Notes
15411541
15421542
Create a document
15431543

1544-
Create a document. If the document is one of {'OBJ', 'DWG', 'POINT_CLOUD', 'DXF', 'IFC', 'GLTF'}, a model will be created and attached to this document Required scopes: document:write
1544+
Create a document. If the document is one of {'OBJ', 'POINT_CLOUD', 'DXF', 'DWG', 'GLTF', 'IFC'}, a model will be created and attached to this document Required scopes: document:write
15451545

15461546
### Example
15471547

@@ -9616,9 +9616,9 @@ Name | Type | Description | Notes
96169616
# **invite_cloud_user**
96179617
> CloudInvitation invite_cloud_user(cloud_pk, cloud_invitation_request)
96189618
9619-
Invite a cloud administrator
9619+
Invite a cloud member
96209620

9621-
Invite cloud administrators only. To invite in a project, see inviteProjectUser. You can't invite a user already in the cloud. Create multiple invitations of the same email in the same cloud will generate multiple invitation emails but not multiple invitation object Required scopes: org:manage
9621+
Invite a cloud member. To invite in a project, see inviteProjectUser. You can't invite a user already in the cloud. Create multiple invitations of the same email in the same cloud will generate multiple invitation emails but not multiple invitation object Required scopes: org:manage
96229622

96239623
### Example
96249624

@@ -9677,11 +9677,14 @@ with bimdata_api_client.ApiClient(configuration) as api_client:
96779677
cloud_invitation_request = CloudInvitationRequest(
96789678
email="email_example",
96799679
redirect_uri="redirect_uri_example",
9680+
role=100,
9681+
project_role=100,
9682+
in_all_projects=False,
96809683
) # CloudInvitationRequest |
96819684

96829685
# example passing only required values which don't have defaults set
96839686
try:
9684-
# Invite a cloud administrator
9687+
# Invite a cloud member
96859688
api_response = api_instance.invite_cloud_user(cloud_pk, cloud_invitation_request)
96869689
pprint(api_response)
96879690
except bimdata_api_client.ApiException as e:

test/test_collaboration_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def test_import_manage_group(self):
636636
def test_invite_cloud_user(self):
637637
"""Test case for invite_cloud_user
638638
639-
Invite a cloud administrator # noqa: E501
639+
Invite a cloud member # noqa: E501
640640
"""
641641
pass
642642

0 commit comments

Comments
 (0)