|
| 1 | +from typing import Optional |
| 2 | + |
| 3 | +from typing import Dict |
| 4 | + |
| 5 | +from box_sdk_gen.internal.utils import to_string |
| 6 | + |
| 7 | +from box_sdk_gen.serialization.json import deserialize |
| 8 | + |
| 9 | +from box_sdk_gen.networking.fetch_options import ResponseFormat |
| 10 | + |
| 11 | +from box_sdk_gen.schemas.app_item import AppItem |
| 12 | + |
| 13 | +from box_sdk_gen.schemas.client_error import ClientError |
| 14 | + |
| 15 | +from box_sdk_gen.box.errors import BoxSDKError |
| 16 | + |
| 17 | +from box_sdk_gen.networking.auth import Authentication |
| 18 | + |
| 19 | +from box_sdk_gen.networking.network import NetworkSession |
| 20 | + |
| 21 | +from box_sdk_gen.networking.fetch_options import FetchOptions |
| 22 | + |
| 23 | +from box_sdk_gen.networking.fetch_response import FetchResponse |
| 24 | + |
| 25 | +from box_sdk_gen.internal.utils import prepare_params |
| 26 | + |
| 27 | +from box_sdk_gen.internal.utils import to_string |
| 28 | + |
| 29 | +from box_sdk_gen.internal.utils import ByteStream |
| 30 | + |
| 31 | +from box_sdk_gen.serialization.json import sd_to_json |
| 32 | + |
| 33 | +from box_sdk_gen.serialization.json import SerializedData |
| 34 | + |
| 35 | + |
| 36 | +class SharedLinksAppItemsManager: |
| 37 | + def __init__( |
| 38 | + self, |
| 39 | + *, |
| 40 | + auth: Optional[Authentication] = None, |
| 41 | + network_session: NetworkSession = None |
| 42 | + ): |
| 43 | + if network_session is None: |
| 44 | + network_session = NetworkSession() |
| 45 | + self.auth = auth |
| 46 | + self.network_session = network_session |
| 47 | + |
| 48 | + def get_shared_item_app_items( |
| 49 | + self, boxapi: str, *, extra_headers: Optional[Dict[str, Optional[str]]] = None |
| 50 | + ) -> AppItem: |
| 51 | + """ |
| 52 | + Returns the app item represented by a shared link. |
| 53 | +
|
| 54 | + The link can originate from the current enterprise or another. |
| 55 | +
|
| 56 | + :param boxapi: A header containing the shared link and optional password for the |
| 57 | + shared link. |
| 58 | +
|
| 59 | + The format for this header is `shared_link=[link]&shared_link_password=[password]` |
| 60 | + :type boxapi: str |
| 61 | + :param extra_headers: Extra headers that will be included in the HTTP request., defaults to None |
| 62 | + :type extra_headers: Optional[Dict[str, Optional[str]]], optional |
| 63 | + """ |
| 64 | + if extra_headers is None: |
| 65 | + extra_headers = {} |
| 66 | + headers_map: Dict[str, str] = prepare_params( |
| 67 | + {'boxapi': to_string(boxapi), **extra_headers} |
| 68 | + ) |
| 69 | + response: FetchResponse = self.network_session.network_client.fetch( |
| 70 | + FetchOptions( |
| 71 | + url=''.join( |
| 72 | + [ |
| 73 | + self.network_session.base_urls.base_url, |
| 74 | + '/2.0/shared_items#app_items', |
| 75 | + ] |
| 76 | + ), |
| 77 | + method='GET', |
| 78 | + headers=headers_map, |
| 79 | + response_format=ResponseFormat.JSON, |
| 80 | + auth=self.auth, |
| 81 | + network_session=self.network_session, |
| 82 | + ) |
| 83 | + ) |
| 84 | + return deserialize(response.data, AppItem) |
0 commit comments