Skip to content

Commit

Permalink
docs: Hubs Beta (box/box-openapi#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Sep 2, 2024
1 parent 5f904b8 commit f518c54
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "2994c4a", "specHash": "739d87b", "version": "1.4.1" }
{ "engineHash": "2994c4a", "specHash": "6ca858e", "version": "1.4.1" }
5 changes: 5 additions & 0 deletions box_sdk_gen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from box_sdk_gen.managers.trashed_files import TrashedFilesManager

from box_sdk_gen.managers.app_item_associations import AppItemAssociationsManager

from box_sdk_gen.managers.downloads import DownloadsManager

from box_sdk_gen.managers.uploads import UploadsManager
Expand Down Expand Up @@ -182,6 +184,9 @@ def __init__(self, auth: Authentication, *, network_session: NetworkSession = No
self.trashed_files = TrashedFilesManager(
auth=self.auth, network_session=self.network_session
)
self.app_item_associations = AppItemAssociationsManager(
auth=self.auth, network_session=self.network_session
)
self.downloads = DownloadsManager(
auth=self.auth, network_session=self.network_session
)
Expand Down
2 changes: 2 additions & 0 deletions box_sdk_gen/managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from box_sdk_gen.managers.trashed_files import *

from box_sdk_gen.managers.app_item_associations import *

from box_sdk_gen.managers.downloads import *

from box_sdk_gen.managers.uploads import *
Expand Down
195 changes: 195 additions & 0 deletions box_sdk_gen/managers/app_item_associations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
from typing import Optional

from typing import Dict

from box_sdk_gen.internal.utils import to_string

from box_sdk_gen.serialization.json.serializer import deserialize

from box_sdk_gen.schemas.app_item_associations import AppItemAssociations

from box_sdk_gen.schemas.client_error import ClientError

from box_sdk_gen.networking.auth import Authentication

from box_sdk_gen.networking.network import NetworkSession

from box_sdk_gen.internal.utils import prepare_params

from box_sdk_gen.internal.utils import to_string

from box_sdk_gen.internal.utils import ByteStream

from box_sdk_gen.serialization.json.json_data import sd_to_json

from box_sdk_gen.networking.fetch import FetchOptions

from box_sdk_gen.networking.fetch import FetchResponse

from box_sdk_gen.networking.fetch import fetch

from box_sdk_gen.serialization.json.json_data import SerializedData


class AppItemAssociationsManager:
def __init__(
self,
*,
auth: Optional[Authentication] = None,
network_session: NetworkSession = None
):
if network_session is None:
network_session = NetworkSession()
self.auth = auth
self.network_session = network_session

def get_file_app_item_associations(
self,
file_id: str,
*,
limit: Optional[int] = None,
marker: Optional[str] = None,
application_type: Optional[str] = None,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> AppItemAssociations:
"""
**This is a beta feature, which means that its availability might be limited.**
Returns all app items the file is associated with. This includes app items
associated with ancestors of the file. Assuming the context user has access
to the file, the type/ids are revealed even if the context user does not
have **View** permission on the app item.
:param file_id: The unique identifier that represents a file.
The ID for any file can be determined
by visiting a file in the web application
and copying the ID from the URL. For example,
for the URL `https://*.app.box.com/files/123`
the `file_id` is `123`.
Example: "12345"
:type file_id: str
:param limit: The maximum number of items to return per page., defaults to None
:type limit: Optional[int], optional
:param marker: Defines the position marker at which to begin returning results. This is
used when paginating using marker-based pagination.
This requires `usemarker` to be set to `true`., defaults to None
:type marker: Optional[str], optional
:param application_type: If given, only return app items for this application type, defaults to None
:type application_type: Optional[str], optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
query_params_map: Dict[str, str] = prepare_params(
{
'limit': to_string(limit),
'marker': to_string(marker),
'application_type': to_string(application_type),
}
)
headers_map: Dict[str, str] = prepare_params({**extra_headers})
response: FetchResponse = fetch(
FetchOptions(
url=''.join(
[
self.network_session.base_urls.base_url,
'/2.0/files/',
to_string(file_id),
'/app_item_associations',
]
),
method='GET',
params=query_params_map,
headers=headers_map,
response_format='json',
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, AppItemAssociations)

def get_folder_app_item_associations(
self,
folder_id: str,
*,
limit: Optional[int] = None,
marker: Optional[str] = None,
application_type: Optional[str] = None,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> AppItemAssociations:
"""
**This is a beta feature, which means that its availability might be limited.**
Returns all app items the folder is associated with. This includes app items
associated with ancestors of the folder. Assuming the context user has access
to the folder, the type/ids are revealed even if the context user does not
have **View** permission on the app item.
:param folder_id: The unique identifier that represent a folder.
The ID for any folder can be determined
by visiting this folder in the web application
and copying the ID from the URL. For example,
for the URL `https://*.app.box.com/folder/123`
the `folder_id` is `123`.
The root folder of a Box account is
always represented by the ID `0`.
Example: "12345"
:type folder_id: str
:param limit: The maximum number of items to return per page., defaults to None
:type limit: Optional[int], optional
:param marker: Defines the position marker at which to begin returning results. This is
used when paginating using marker-based pagination.
This requires `usemarker` to be set to `true`., defaults to None
:type marker: Optional[str], optional
:param application_type: If given, returns only app items for this application type, defaults to None
:type application_type: Optional[str], optional
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
"""
if extra_headers is None:
extra_headers = {}
query_params_map: Dict[str, str] = prepare_params(
{
'limit': to_string(limit),
'marker': to_string(marker),
'application_type': to_string(application_type),
}
)
headers_map: Dict[str, str] = prepare_params({**extra_headers})
response: FetchResponse = fetch(
FetchOptions(
url=''.join(
[
self.network_session.base_urls.base_url,
'/2.0/folders/',
to_string(folder_id),
'/app_item_associations',
]
),
method='GET',
params=query_params_map,
headers=headers_map,
response_format='json',
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, AppItemAssociations)
6 changes: 6 additions & 0 deletions box_sdk_gen/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from box_sdk_gen.schemas.ai_response import *

from box_sdk_gen.schemas.app_item import *

from box_sdk_gen.schemas.classification import *

from box_sdk_gen.schemas.classification_template import *
Expand Down Expand Up @@ -314,6 +316,10 @@

from box_sdk_gen.schemas.webhook_invocation import *

from box_sdk_gen.schemas.app_item_association import *

from box_sdk_gen.schemas.app_item_associations import *

from box_sdk_gen.schemas.workflow_mini import *

from box_sdk_gen.schemas.workflow import *
Expand Down
32 changes: 32 additions & 0 deletions box_sdk_gen/schemas/app_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from enum import Enum

from box_sdk_gen.internal.base_object import BaseObject


class AppItemTypeField(str, Enum):
APP_ITEM = 'app_item'


class AppItem(BaseObject):
_discriminator = 'type', {'app_item'}

def __init__(
self,
id: str,
application_type: str,
*,
type: AppItemTypeField = AppItemTypeField.APP_ITEM.value,
**kwargs
):
"""
:param id: The unique identifier for this app item.
:type id: str
:param application_type: The type of the app that owns this app item.
:type application_type: str
:param type: `app_item`, defaults to AppItemTypeField.APP_ITEM.value
:type type: AppItemTypeField, optional
"""
super().__init__(**kwargs)
self.id = id
self.application_type = application_type
self.type = type
42 changes: 42 additions & 0 deletions box_sdk_gen/schemas/app_item_association.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from enum import Enum

from typing import Union

from box_sdk_gen.internal.base_object import BaseObject

from box_sdk_gen.schemas.app_item import AppItem

from box_sdk_gen.schemas.file_base import FileBase

from box_sdk_gen.schemas.folder_base import FolderBase

from box_sdk_gen.schemas.web_link_base import WebLinkBase


class AppItemAssociationTypeField(str, Enum):
APP_ITEM_ASSOCIATION = 'app_item_association'


class AppItemAssociation(BaseObject):
_discriminator = 'type', {'app_item_association'}

def __init__(
self,
id: str,
app_item: AppItem,
item: Union[FileBase, FolderBase, WebLinkBase],
*,
type: AppItemAssociationTypeField = AppItemAssociationTypeField.APP_ITEM_ASSOCIATION.value,
**kwargs
):
"""
:param id: The unique identifier for this app item association.
:type id: str
:param type: `app_item_association`, defaults to AppItemAssociationTypeField.APP_ITEM_ASSOCIATION.value
:type type: AppItemAssociationTypeField, optional
"""
super().__init__(**kwargs)
self.id = id
self.app_item = app_item
self.item = item
self.type = type
34 changes: 34 additions & 0 deletions box_sdk_gen/schemas/app_item_associations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import Optional

from typing import List

from box_sdk_gen.internal.base_object import BaseObject

from box_sdk_gen.schemas.app_item_association import AppItemAssociation


class AppItemAssociations(BaseObject):
def __init__(
self,
*,
limit: Optional[int] = None,
next_marker: Optional[str] = None,
prev_marker: Optional[str] = None,
entries: Optional[List[AppItemAssociation]] = None,
**kwargs
):
"""
:param limit: The limit that was used for these entries. This will be the same as the
`limit` query parameter unless that value exceeded the maximum value
allowed. The maximum value varies by API., defaults to None
:type limit: Optional[int], optional
:param next_marker: The marker for the start of the next page of results., defaults to None
:type next_marker: Optional[str], optional
:param prev_marker: The marker for the start of the previous page of results., defaults to None
:type prev_marker: Optional[str], optional
"""
super().__init__(**kwargs)
self.limit = limit
self.next_marker = next_marker
self.prev_marker = prev_marker
self.entries = entries
4 changes: 4 additions & 0 deletions box_sdk_gen/schemas/collaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from box_sdk_gen.schemas.web_link import WebLink

from box_sdk_gen.schemas.app_item import AppItem

from box_sdk_gen.schemas.user_collaborations import UserCollaborations

from box_sdk_gen.schemas.group_mini import GroupMini
Expand Down Expand Up @@ -151,6 +153,7 @@ def __init__(
*,
type: CollaborationTypeField = CollaborationTypeField.COLLABORATION.value,
item: Optional[Union[File, Folder, WebLink]] = None,
app_item: Optional[AppItem] = None,
accessible_by: Optional[Union[UserCollaborations, GroupMini]] = None,
invite_email: Optional[str] = None,
role: Optional[CollaborationRoleField] = None,
Expand Down Expand Up @@ -200,6 +203,7 @@ def __init__(
self.id = id
self.type = type
self.item = item
self.app_item = app_item
self.accessible_by = accessible_by
self.invite_email = invite_email
self.role = role
Expand Down
Loading

0 comments on commit f518c54

Please sign in to comment.