|
| 1 | +from enum import Enum |
| 2 | + |
| 3 | +from box_sdk_gen.internal.base_object import BaseObject |
| 4 | + |
| 5 | +from typing import Optional |
| 6 | + |
| 7 | +from typing import Dict |
| 8 | + |
| 9 | +from box_sdk_gen.internal.utils import to_string |
| 10 | + |
| 11 | +from box_sdk_gen.serialization.json import deserialize |
| 12 | + |
| 13 | +from box_sdk_gen.serialization.json import serialize |
| 14 | + |
| 15 | +from box_sdk_gen.networking.fetch_options import ResponseFormat |
| 16 | + |
| 17 | +from box_sdk_gen.schemas.v2025_r0.hub_collaborations_v2025_r0 import ( |
| 18 | + HubCollaborationsV2025R0, |
| 19 | +) |
| 20 | + |
| 21 | +from box_sdk_gen.schemas.v2025_r0.client_error_v2025_r0 import ClientErrorV2025R0 |
| 22 | + |
| 23 | +from box_sdk_gen.parameters.v2025_r0.box_version_header_v2025_r0 import ( |
| 24 | + BoxVersionHeaderV2025R0, |
| 25 | +) |
| 26 | + |
| 27 | +from box_sdk_gen.schemas.v2025_r0.hub_collaboration_v2025_r0 import ( |
| 28 | + HubCollaborationV2025R0, |
| 29 | +) |
| 30 | + |
| 31 | +from box_sdk_gen.schemas.v2025_r0.hub_collaboration_create_request_v2025_r0 import ( |
| 32 | + HubCollaborationCreateRequestV2025R0, |
| 33 | +) |
| 34 | + |
| 35 | +from box_sdk_gen.schemas.v2025_r0.hub_collaboration_update_request_v2025_r0 import ( |
| 36 | + HubCollaborationUpdateRequestV2025R0, |
| 37 | +) |
| 38 | + |
| 39 | +from box_sdk_gen.box.errors import BoxSDKError |
| 40 | + |
| 41 | +from box_sdk_gen.networking.auth import Authentication |
| 42 | + |
| 43 | +from box_sdk_gen.networking.network import NetworkSession |
| 44 | + |
| 45 | +from box_sdk_gen.networking.fetch_options import FetchOptions |
| 46 | + |
| 47 | +from box_sdk_gen.networking.fetch_response import FetchResponse |
| 48 | + |
| 49 | +from box_sdk_gen.internal.utils import prepare_params |
| 50 | + |
| 51 | +from box_sdk_gen.internal.utils import to_string |
| 52 | + |
| 53 | +from box_sdk_gen.internal.utils import ByteStream |
| 54 | + |
| 55 | +from box_sdk_gen.serialization.json import sd_to_json |
| 56 | + |
| 57 | +from box_sdk_gen.serialization.json import SerializedData |
| 58 | + |
| 59 | + |
| 60 | +class CreateHubCollaborationV2025R0HubTypeField(str, Enum): |
| 61 | + HUBS = 'hubs' |
| 62 | + |
| 63 | + |
| 64 | +class CreateHubCollaborationV2025R0Hub(BaseObject): |
| 65 | + _discriminator = 'type', {'hubs'} |
| 66 | + |
| 67 | + def __init__( |
| 68 | + self, |
| 69 | + id: str, |
| 70 | + *, |
| 71 | + type: CreateHubCollaborationV2025R0HubTypeField = CreateHubCollaborationV2025R0HubTypeField.HUBS, |
| 72 | + **kwargs |
| 73 | + ): |
| 74 | + """ |
| 75 | + :param id: ID of the object. |
| 76 | + :type id: str |
| 77 | + :param type: The value will always be `hubs`., defaults to CreateHubCollaborationV2025R0HubTypeField.HUBS |
| 78 | + :type type: CreateHubCollaborationV2025R0HubTypeField, optional |
| 79 | + """ |
| 80 | + super().__init__(**kwargs) |
| 81 | + self.id = id |
| 82 | + self.type = type |
| 83 | + |
| 84 | + |
| 85 | +class CreateHubCollaborationV2025R0AccessibleBy(BaseObject): |
| 86 | + def __init__( |
| 87 | + self, |
| 88 | + type: str, |
| 89 | + *, |
| 90 | + id: Optional[str] = None, |
| 91 | + login: Optional[str] = None, |
| 92 | + **kwargs |
| 93 | + ): |
| 94 | + """ |
| 95 | + :param type: The type of collaborator to invite. |
| 96 | + Possible values are `user` or `group`. |
| 97 | + :type type: str |
| 98 | + :param id: The ID of the user or group. |
| 99 | +
|
| 100 | + Alternatively, use `login` to specify a user by email |
| 101 | + address., defaults to None |
| 102 | + :type id: Optional[str], optional |
| 103 | + :param login: The email address of the user who gets access to the item. |
| 104 | +
|
| 105 | + Alternatively, use `id` to specify a user by user ID., defaults to None |
| 106 | + :type login: Optional[str], optional |
| 107 | + """ |
| 108 | + super().__init__(**kwargs) |
| 109 | + self.type = type |
| 110 | + self.id = id |
| 111 | + self.login = login |
| 112 | + |
| 113 | + |
| 114 | +class HubCollaborationsManager: |
| 115 | + def __init__( |
| 116 | + self, |
| 117 | + *, |
| 118 | + auth: Optional[Authentication] = None, |
| 119 | + network_session: NetworkSession = None |
| 120 | + ): |
| 121 | + if network_session is None: |
| 122 | + network_session = NetworkSession() |
| 123 | + self.auth = auth |
| 124 | + self.network_session = network_session |
| 125 | + |
| 126 | + def get_hub_collaborations_v2025_r0( |
| 127 | + self, |
| 128 | + hub_id: str, |
| 129 | + *, |
| 130 | + marker: Optional[str] = None, |
| 131 | + limit: Optional[int] = None, |
| 132 | + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, |
| 133 | + extra_headers: Optional[Dict[str, Optional[str]]] = None |
| 134 | + ) -> HubCollaborationsV2025R0: |
| 135 | + """ |
| 136 | + Retrieves all collaborations for a hub. |
| 137 | + :param hub_id: The unique identifier that represent a hub. |
| 138 | +
|
| 139 | + The ID for any hub can be determined |
| 140 | + by visiting this hub in the web application |
| 141 | + and copying the ID from the URL. For example, |
| 142 | + for the URL `https://*.app.box.com/hubs/123` |
| 143 | + the `hub_id` is `123`. |
| 144 | + :type hub_id: str |
| 145 | + :param marker: Defines the position marker at which to begin returning results. This is |
| 146 | + used when paginating using marker-based pagination. |
| 147 | +
|
| 148 | + This requires `usemarker` to be set to `true`., defaults to None |
| 149 | + :type marker: Optional[str], optional |
| 150 | + :param limit: The maximum number of items to return per page., defaults to None |
| 151 | + :type limit: Optional[int], optional |
| 152 | + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 |
| 153 | + :type box_version: BoxVersionHeaderV2025R0, optional |
| 154 | + :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None |
| 155 | + :type extra_headers: Optional[Dict[str, Optional[str]]], optional |
| 156 | + """ |
| 157 | + if extra_headers is None: |
| 158 | + extra_headers = {} |
| 159 | + query_params_map: Dict[str, str] = prepare_params( |
| 160 | + { |
| 161 | + 'hub_id': to_string(hub_id), |
| 162 | + 'marker': to_string(marker), |
| 163 | + 'limit': to_string(limit), |
| 164 | + } |
| 165 | + ) |
| 166 | + headers_map: Dict[str, str] = prepare_params( |
| 167 | + {'box-version': to_string(box_version), **extra_headers} |
| 168 | + ) |
| 169 | + response: FetchResponse = self.network_session.network_client.fetch( |
| 170 | + FetchOptions( |
| 171 | + url=''.join( |
| 172 | + [self.network_session.base_urls.base_url, '/2.0/hub_collaborations'] |
| 173 | + ), |
| 174 | + method='GET', |
| 175 | + params=query_params_map, |
| 176 | + headers=headers_map, |
| 177 | + response_format=ResponseFormat.JSON, |
| 178 | + auth=self.auth, |
| 179 | + network_session=self.network_session, |
| 180 | + ) |
| 181 | + ) |
| 182 | + return deserialize(response.data, HubCollaborationsV2025R0) |
| 183 | + |
| 184 | + def create_hub_collaboration_v2025_r0( |
| 185 | + self, |
| 186 | + hub: CreateHubCollaborationV2025R0Hub, |
| 187 | + accessible_by: CreateHubCollaborationV2025R0AccessibleBy, |
| 188 | + role: str, |
| 189 | + *, |
| 190 | + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, |
| 191 | + extra_headers: Optional[Dict[str, Optional[str]]] = None |
| 192 | + ) -> HubCollaborationV2025R0: |
| 193 | + """ |
| 194 | + Adds a collaboration for a single user or a single group to a hub. |
| 195 | +
|
| 196 | + Collaborations can be created using email address, user IDs, or group IDs. |
| 197 | +
|
| 198 | + :param hub: Hubs reference. |
| 199 | + :type hub: CreateHubCollaborationV2025R0Hub |
| 200 | + :param accessible_by: The user or group who gets access to the item. |
| 201 | + :type accessible_by: CreateHubCollaborationV2025R0AccessibleBy |
| 202 | + :param role: The level of access granted to hub. |
| 203 | + Possible values are `editor`, `viewer`, and `co-owner`. |
| 204 | + :type role: str |
| 205 | + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 |
| 206 | + :type box_version: BoxVersionHeaderV2025R0, optional |
| 207 | + :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None |
| 208 | + :type extra_headers: Optional[Dict[str, Optional[str]]], optional |
| 209 | + """ |
| 210 | + if extra_headers is None: |
| 211 | + extra_headers = {} |
| 212 | + request_body: Dict = {'hub': hub, 'accessible_by': accessible_by, 'role': role} |
| 213 | + headers_map: Dict[str, str] = prepare_params( |
| 214 | + {'box-version': to_string(box_version), **extra_headers} |
| 215 | + ) |
| 216 | + response: FetchResponse = self.network_session.network_client.fetch( |
| 217 | + FetchOptions( |
| 218 | + url=''.join( |
| 219 | + [self.network_session.base_urls.base_url, '/2.0/hub_collaborations'] |
| 220 | + ), |
| 221 | + method='POST', |
| 222 | + headers=headers_map, |
| 223 | + data=serialize(request_body), |
| 224 | + content_type='application/json', |
| 225 | + response_format=ResponseFormat.JSON, |
| 226 | + auth=self.auth, |
| 227 | + network_session=self.network_session, |
| 228 | + ) |
| 229 | + ) |
| 230 | + return deserialize(response.data, HubCollaborationV2025R0) |
| 231 | + |
| 232 | + def get_hub_collaboration_by_id_v2025_r0( |
| 233 | + self, |
| 234 | + hub_collaboration_id: str, |
| 235 | + *, |
| 236 | + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, |
| 237 | + extra_headers: Optional[Dict[str, Optional[str]]] = None |
| 238 | + ) -> HubCollaborationV2025R0: |
| 239 | + """ |
| 240 | + Retrieves details for a hub collaboration by collaboration ID. |
| 241 | + :param hub_collaboration_id: The ID of the hub collaboration. |
| 242 | + Example: "1234" |
| 243 | + :type hub_collaboration_id: str |
| 244 | + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 |
| 245 | + :type box_version: BoxVersionHeaderV2025R0, optional |
| 246 | + :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None |
| 247 | + :type extra_headers: Optional[Dict[str, Optional[str]]], optional |
| 248 | + """ |
| 249 | + if extra_headers is None: |
| 250 | + extra_headers = {} |
| 251 | + headers_map: Dict[str, str] = prepare_params( |
| 252 | + {'box-version': to_string(box_version), **extra_headers} |
| 253 | + ) |
| 254 | + response: FetchResponse = self.network_session.network_client.fetch( |
| 255 | + FetchOptions( |
| 256 | + url=''.join( |
| 257 | + [ |
| 258 | + self.network_session.base_urls.base_url, |
| 259 | + '/2.0/hub_collaborations/', |
| 260 | + to_string(hub_collaboration_id), |
| 261 | + ] |
| 262 | + ), |
| 263 | + method='GET', |
| 264 | + headers=headers_map, |
| 265 | + response_format=ResponseFormat.JSON, |
| 266 | + auth=self.auth, |
| 267 | + network_session=self.network_session, |
| 268 | + ) |
| 269 | + ) |
| 270 | + return deserialize(response.data, HubCollaborationV2025R0) |
| 271 | + |
| 272 | + def update_hub_collaboration_by_id_v2025_r0( |
| 273 | + self, |
| 274 | + hub_collaboration_id: str, |
| 275 | + *, |
| 276 | + role: Optional[str] = None, |
| 277 | + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, |
| 278 | + extra_headers: Optional[Dict[str, Optional[str]]] = None |
| 279 | + ) -> HubCollaborationV2025R0: |
| 280 | + """ |
| 281 | + Updates a hub collaboration. |
| 282 | +
|
| 283 | + Can be used to change the hub role. |
| 284 | +
|
| 285 | + :param hub_collaboration_id: The ID of the hub collaboration. |
| 286 | + Example: "1234" |
| 287 | + :type hub_collaboration_id: str |
| 288 | + :param role: The level of access granted to hub. |
| 289 | + Possible values are `editor`, `viewer`, and `co-owner`., defaults to None |
| 290 | + :type role: Optional[str], optional |
| 291 | + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 |
| 292 | + :type box_version: BoxVersionHeaderV2025R0, optional |
| 293 | + :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None |
| 294 | + :type extra_headers: Optional[Dict[str, Optional[str]]], optional |
| 295 | + """ |
| 296 | + if extra_headers is None: |
| 297 | + extra_headers = {} |
| 298 | + request_body: Dict = {'role': role} |
| 299 | + headers_map: Dict[str, str] = prepare_params( |
| 300 | + {'box-version': to_string(box_version), **extra_headers} |
| 301 | + ) |
| 302 | + response: FetchResponse = self.network_session.network_client.fetch( |
| 303 | + FetchOptions( |
| 304 | + url=''.join( |
| 305 | + [ |
| 306 | + self.network_session.base_urls.base_url, |
| 307 | + '/2.0/hub_collaborations/', |
| 308 | + to_string(hub_collaboration_id), |
| 309 | + ] |
| 310 | + ), |
| 311 | + method='PUT', |
| 312 | + headers=headers_map, |
| 313 | + data=serialize(request_body), |
| 314 | + content_type='application/json', |
| 315 | + response_format=ResponseFormat.JSON, |
| 316 | + auth=self.auth, |
| 317 | + network_session=self.network_session, |
| 318 | + ) |
| 319 | + ) |
| 320 | + return deserialize(response.data, HubCollaborationV2025R0) |
| 321 | + |
| 322 | + def delete_hub_collaboration_by_id_v2025_r0( |
| 323 | + self, |
| 324 | + hub_collaboration_id: str, |
| 325 | + *, |
| 326 | + box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0, |
| 327 | + extra_headers: Optional[Dict[str, Optional[str]]] = None |
| 328 | + ) -> None: |
| 329 | + """ |
| 330 | + Deletes a single hub collaboration. |
| 331 | + :param hub_collaboration_id: The ID of the hub collaboration. |
| 332 | + Example: "1234" |
| 333 | + :type hub_collaboration_id: str |
| 334 | + :param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0 |
| 335 | + :type box_version: BoxVersionHeaderV2025R0, optional |
| 336 | + :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None |
| 337 | + :type extra_headers: Optional[Dict[str, Optional[str]]], optional |
| 338 | + """ |
| 339 | + if extra_headers is None: |
| 340 | + extra_headers = {} |
| 341 | + headers_map: Dict[str, str] = prepare_params( |
| 342 | + {'box-version': to_string(box_version), **extra_headers} |
| 343 | + ) |
| 344 | + response: FetchResponse = self.network_session.network_client.fetch( |
| 345 | + FetchOptions( |
| 346 | + url=''.join( |
| 347 | + [ |
| 348 | + self.network_session.base_urls.base_url, |
| 349 | + '/2.0/hub_collaborations/', |
| 350 | + to_string(hub_collaboration_id), |
| 351 | + ] |
| 352 | + ), |
| 353 | + method='DELETE', |
| 354 | + headers=headers_map, |
| 355 | + response_format=ResponseFormat.NO_CONTENT, |
| 356 | + auth=self.auth, |
| 357 | + network_session=self.network_session, |
| 358 | + ) |
| 359 | + ) |
| 360 | + return None |
0 commit comments