Skip to content

Commit fd6c693

Browse files
box-sdk-buildbox-sdk-build
andauthored
feat: add find app item for shared link endpoint (box/box-openapi#514) (#502)
Co-authored-by: box-sdk-build <[email protected]>
1 parent 229f238 commit fd6c693

File tree

7 files changed

+124
-2
lines changed

7 files changed

+124
-2
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "8f5e41b", "specHash": "6782a0d", "version": "1.12.0" }
1+
{ "engineHash": "41feeaa", "specHash": "3dc6f70", "version": "1.12.0" }

box_sdk_gen/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070

7171
from box_sdk_gen.managers.shared_links_web_links import SharedLinksWebLinksManager
7272

73+
from box_sdk_gen.managers.shared_links_app_items import SharedLinksAppItemsManager
74+
7375
from box_sdk_gen.managers.users import UsersManager
7476

7577
from box_sdk_gen.managers.session_termination import SessionTerminationManager
@@ -289,6 +291,9 @@ def __init__(self, auth: Authentication, *, network_session: NetworkSession = No
289291
self.shared_links_web_links = SharedLinksWebLinksManager(
290292
auth=self.auth, network_session=self.network_session
291293
)
294+
self.shared_links_app_items = SharedLinksAppItemsManager(
295+
auth=self.auth, network_session=self.network_session
296+
)
292297
self.users = UsersManager(auth=self.auth, network_session=self.network_session)
293298
self.session_termination = SessionTerminationManager(
294299
auth=self.auth, network_session=self.network_session

box_sdk_gen/managers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666

6767
from box_sdk_gen.managers.shared_links_web_links import *
6868

69+
from box_sdk_gen.managers.shared_links_app_items import *
70+
6971
from box_sdk_gen.managers.users import *
7072

7173
from box_sdk_gen.managers.session_termination import *
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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)

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ the SDK are available by topic:
4949
- [Retention policy assignments](retention_policy_assignments.md)
5050
- [Search](search.md)
5151
- [Session termination](session_termination.md)
52+
- [Shared links app items](shared_links_app_items.md)
5253
- [Shared links files](shared_links_files.md)
5354
- [Shared links folders](shared_links_folders.md)
5455
- [Shared links web links](shared_links_web_links.md)

docs/shared_links_app_items.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SharedLinksAppItemsManager
2+
3+
- [Find app item for shared link](#find-app-item-for-shared-link)
4+
5+
## Find app item for shared link
6+
7+
Returns the app item represented by a shared link.
8+
9+
The link can originate from the current enterprise or another.
10+
11+
This operation is performed by calling function `get_shared_item_app_items`.
12+
13+
See the endpoint docs at
14+
[API Reference](https://developer.box.com/reference/get-shared-items--app-items/).
15+
16+
_Currently we don't have an example for calling `get_shared_item_app_items` in integration tests_
17+
18+
### Arguments
19+
20+
- boxapi `str`
21+
- A header containing the shared link and optional password for the shared link. The format for this header is `shared_link=[link]&shared_link_password=[password]`
22+
- extra_headers `Optional[Dict[str, Optional[str]]]`
23+
- Extra headers that will be included in the HTTP request.
24+
25+
### Returns
26+
27+
This function returns a value of type `AppItem`.
28+
29+
Returns a full app item resource if the shared link is valid and
30+
the user has access to it.

docs/shared_links_web_links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ user_client.shared_links_web_links.find_web_link_for_shared_link(
5050

5151
This function returns a value of type `WebLink`.
5252

53-
Returns a full file resource if the shared link is valid and
53+
Returns a full web link resource if the shared link is valid and
5454
the user has access to it.
5555

5656
## Get shared link for web link

0 commit comments

Comments
 (0)