Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "7c94f4f", "specHash": "a646ae6", "version": "10.0.1" }
{ "engineHash": "7c94f4f", "specHash": "8b51a89", "version": "10.0.1" }
64 changes: 63 additions & 1 deletion box_sdk_gen/managers/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def create_archive_v2025_r0(
self,
name: str,
*,
description: Optional[str] = None,
storage_policy_id: Optional[str] = None,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> ArchiveV2025R0:
Expand All @@ -111,14 +113,22 @@ def create_archive_v2025_r0(

:param name: The name of the archive.
:type name: str
:param description: The description of the archive., defaults to None
:type description: Optional[str], optional
:param storage_policy_id: The ID of the storage policy that the archive is assigned to., defaults to None
:type storage_policy_id: Optional[str], optional
:param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, 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 = {}
request_body: Dict = {'name': name}
request_body: Dict = {
'name': name,
'description': description,
'storage_policy_id': storage_policy_id,
}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
Expand Down Expand Up @@ -178,3 +188,55 @@ def delete_archive_by_id_v2025_r0(
)
)
return None

def update_archive_by_id_v2025_r0(
self,
archive_id: str,
*,
name: Optional[str] = None,
description: Optional[str] = None,
box_version: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._2025_0,
extra_headers: Optional[Dict[str, Optional[str]]] = None
) -> ArchiveV2025R0:
"""
Updates an archive.

To learn more about the archive APIs, see the [Archive API Guide](g://archives).

:param archive_id: The ID of the archive.
Example: "982312"
:type archive_id: str
:param name: The name of the archive., defaults to None
:type name: Optional[str], optional
:param description: The description of the archive., defaults to None
:type description: Optional[str], optional
:param box_version: Version header., defaults to BoxVersionHeaderV2025R0._2025_0
:type box_version: BoxVersionHeaderV2025R0, 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 = {}
request_body: Dict = {'name': name, 'description': description}
headers_map: Dict[str, str] = prepare_params(
{'box-version': to_string(box_version), **extra_headers}
)
response: FetchResponse = self.network_session.network_client.fetch(
FetchOptions(
url=''.join(
[
self.network_session.base_urls.base_url,
'/2.0/archives/',
to_string(archive_id),
]
),
method='PUT',
headers=headers_map,
data=serialize(request_body),
content_type='application/json',
response_format=ResponseFormat.JSON,
auth=self.auth,
network_session=self.network_session,
)
)
return deserialize(response.data, ArchiveV2025R0)
25 changes: 24 additions & 1 deletion box_sdk_gen/schemas/v2025_r0/archive_v2025_r0.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@

from box_sdk_gen.internal.base_object import BaseObject

from typing import Optional

from box_sdk_gen.box.errors import BoxSDKError


class ArchiveV2025R0TypeField(str, Enum):
ARCHIVE = 'archive'


class ArchiveV2025R0OwnedByField(BaseObject):
def __init__(self, id: str, type: str, **kwargs):
"""
:param id: The unique identifier that represents a user who owns the archive.
:type id: str
:param type: The value is always `user`.
:type type: str
"""
super().__init__(**kwargs)
self.id = id
self.type = type


class ArchiveV2025R0(BaseObject):
_discriminator = 'type', {'archive'}

Expand All @@ -19,6 +34,8 @@ def __init__(
size: int,
*,
type: ArchiveV2025R0TypeField = ArchiveV2025R0TypeField.ARCHIVE,
description: Optional[str] = None,
owned_by: Optional[ArchiveV2025R0OwnedByField] = None,
**kwargs
):
r"""
Expand All @@ -33,11 +50,17 @@ def __init__(
:type name: str
:param size: The size of the archive in bytes.
:type size: int
:param type: The value will always be `archive`., defaults to ArchiveV2025R0TypeField.ARCHIVE
:param type: The value is always `archive`., defaults to ArchiveV2025R0TypeField.ARCHIVE
:type type: ArchiveV2025R0TypeField, optional
:param description: The description of the archive., defaults to None
:type description: Optional[str], optional
:param owned_by: The part of an archive API response that describes the user who owns the archive., defaults to None
:type owned_by: Optional[ArchiveV2025R0OwnedByField], optional
"""
super().__init__(**kwargs)
self.id = id
self.name = name
self.size = size
self.type = type
self.description = description
self.owned_by = owned_by
8 changes: 4 additions & 4 deletions box_sdk_gen/schemas/v2025_r0/weblink_reference_v2025_r0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@


class WeblinkReferenceV2025R0TypeField(str, Enum):
WEBLINK = 'weblink'
WEB_LINK = 'web_link'


class WeblinkReferenceV2025R0(BaseObject):
_discriminator = 'type', {'weblink'}
_discriminator = 'type', {'web_link'}

def __init__(
self,
id: str,
*,
type: WeblinkReferenceV2025R0TypeField = WeblinkReferenceV2025R0TypeField.WEBLINK,
type: WeblinkReferenceV2025R0TypeField = WeblinkReferenceV2025R0TypeField.WEB_LINK,
**kwargs
):
"""
:param id: ID of the web link.
:type id: str
:param type: The value will always be `weblink`., defaults to WeblinkReferenceV2025R0TypeField.WEBLINK
:param type: The value will always be `web_link`., defaults to WeblinkReferenceV2025R0TypeField.WEB_LINK
:type type: WeblinkReferenceV2025R0TypeField, optional
"""
super().__init__(**kwargs)
Expand Down
37 changes: 37 additions & 0 deletions docs/archives.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [List archives](#list-archives)
- [Create archive](#create-archive)
- [Delete archive](#delete-archive)
- [Update archive](#update-archive)

## List archives

Expand Down Expand Up @@ -59,6 +60,10 @@ client.archives.create_archive_v2025_r0(archive_name)

- name `str`
- The name of the archive.
- description `Optional[str]`
- The description of the archive.
- storage_policy_id `Optional[str]`
- The ID of the storage policy that the archive is assigned to.
- box_version `BoxVersionHeaderV2025R0`
- Version header.
- extra_headers `Optional[Dict[str, Optional[str]]]`
Expand Down Expand Up @@ -101,3 +106,35 @@ client.archives.delete_archive_by_id_v2025_r0(archive.id)
This function returns a value of type `None`.

Returns an empty response when the archive has been deleted.

## Update archive

Updates an archive.

To learn more about the archive APIs, see the [Archive API Guide](g://archives).

This operation is performed by calling function `update_archive_by_id_v2025_r0`.

See the endpoint docs at
[API Reference](https://developer.box.com/reference/v2025.0/put-archives-id/).

_Currently we don't have an example for calling `update_archive_by_id_v2025_r0` in integration tests_

### Arguments

- archive_id `str`
- The ID of the archive. Example: "982312"
- name `Optional[str]`
- The name of the archive.
- description `Optional[str]`
- The description of the archive.
- box_version `BoxVersionHeaderV2025R0`
- Version header.
- extra_headers `Optional[Dict[str, Optional[str]]]`
- Extra headers that will be included in the HTTP request.

### Returns

This function returns a value of type `ArchiveV2025R0`.

Returns the updated archive object.