Skip to content

Commit cf41273

Browse files
feat: update chunked upload to support sha512 and add external_id to DocGen (box/box-openapi#620)
1 parent 1072f67 commit cf41273

16 files changed

Lines changed: 220 additions & 82 deletions

‎.codegen.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "d55532c", "specHash": "c5a35a6", "version": "10.17.1" }
1+
{ "engineHash": "d55532c", "specHash": "e21eebc", "version": "10.17.1" }

‎box_sdk_gen/managers/chunked_uploads.py‎

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,18 @@ def upload_file_part_by_url(
304304
:type request_body: ByteStream
305305
:param digest: The [RFC3230][1] message digest of the chunk uploaded.
306306
307-
Only SHA1 is supported. The SHA1 digest must be base64
307+
`SHA-1` and `SHA-512` ([RFC5843][2]) are supported. The digest must be base64
308308
encoded. The format of this header is as
309-
`sha=BASE64_ENCODED_DIGEST`.
309+
`sha=BASE64_ENCODED_DIGEST` for `SHA-1`, or
310+
`sha-512=BASE64_ENCODED_DIGEST` for `SHA-512`.
310311
311-
To get the value for the `SHA` digest, use the
312+
To get the value for the digest, use the
312313
openSSL command to encode the file part:
313-
`openssl sha1 -binary <FILE_PART_NAME> | base64`.
314+
`openssl sha1 -binary <FILE_PART_NAME> | base64` for `SHA-1`, or
315+
`openssl sha512 -binary <FILE_PART_NAME> | base64` for `SHA-512`.
314316
315317
[1]: https://tools.ietf.org/html/rfc3230
318+
[2]: https://tools.ietf.org/html/rfc5843
316319
:type digest: str
317320
:param content_range: The byte range of the chunk.
318321
@@ -378,15 +381,18 @@ def upload_file_part(
378381
:type request_body: ByteStream
379382
:param digest: The [RFC3230][1] message digest of the chunk uploaded.
380383
381-
Only SHA1 is supported. The SHA1 digest must be base64
384+
`SHA-1` and `SHA-512` ([RFC5843][2]) are supported. The digest must be base64
382385
encoded. The format of this header is as
383-
`sha=BASE64_ENCODED_DIGEST`.
386+
`sha=BASE64_ENCODED_DIGEST` for `SHA-1`, or
387+
`sha-512=BASE64_ENCODED_DIGEST` for `SHA-512`.
384388
385-
To get the value for the `SHA` digest, use the
389+
To get the value for the digest, use the
386390
openSSL command to encode the file part:
387-
`openssl sha1 -binary <FILE_PART_NAME> | base64`.
391+
`openssl sha1 -binary <FILE_PART_NAME> | base64` for `SHA-1`, or
392+
`openssl sha512 -binary <FILE_PART_NAME> | base64` for `SHA-512`.
388393
389394
[1]: https://tools.ietf.org/html/rfc3230
395+
[2]: https://tools.ietf.org/html/rfc5843
390396
:type digest: str
391397
:param content_range: The byte range of the chunk.
392398
@@ -650,10 +656,10 @@ def create_file_upload_session_plan_by_url(
650656
have already been uploaded (cache hits) and only uploading missing parts.
651657
652658
653-
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
659+
The actual endpoint URL is returned by the [`Create upload session`](https://developer.box.com/reference/post-files-upload-sessions)
654660
655661
656-
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
662+
and [`Get upload session`](https://developer.box.com/reference/get-files-upload-sessions-id) endpoints.
657663
658664
:param url: URL of createFileUploadSessionPlan method
659665
:type url: str
@@ -696,10 +702,10 @@ def create_file_upload_session_plan(
696702
have already been uploaded (cache hits) and only uploading missing parts.
697703
698704
699-
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
705+
The actual endpoint URL is returned by the [`Create upload session`](https://developer.box.com/reference/post-files-upload-sessions)
700706
701707
702-
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
708+
and [`Get upload session`](https://developer.box.com/reference/get-files-upload-sessions-id) endpoints.
703709
704710
:param upload_session_id: The ID of the upload session.
705711
Example: "D5E3F7A"
@@ -761,13 +767,27 @@ def create_file_upload_session_commit_by_url(
761767
:param url: URL of createFileUploadSessionCommit method
762768
:type url: str
763769
:param parts: The list details for the uploaded parts.
770+
771+
Each entry can include `sha1` or `sha512`. Include `sha512`
772+
on every entry or on none of them. A request where only
773+
some entries include `sha512` is rejected.
774+
775+
Include parts that the server already has, returned as
776+
`hits` by the [`Plan upload session`](https://developer.box.com/reference/post-files-upload-sessions-id-plan)
777+
endpoint. Use the `part_id`, `offset`, and `size` from the
778+
plan response. If the other entries include `sha512`,
779+
include the `sha512` value from the plan response.
780+
Otherwise, leave the hash out of these entries.
764781
:type parts: List[UploadPart]
765782
:param digest: The [RFC3230][1] message digest of the whole file.
766783
767784
Only SHA1 is supported. The SHA1 digest must be Base64
768785
encoded. The format of this header is as
769786
`sha=BASE64_ENCODED_DIGEST`.
770787
788+
`SHA-512` is not supported for the whole-file digest, even if
789+
the parts were uploaded with `SHA-512` digests.
790+
771791
[1]: https://tools.ietf.org/html/rfc3230
772792
:type digest: str
773793
:param if_match: Ensures this item hasn't recently changed before
@@ -837,13 +857,27 @@ def create_file_upload_session_commit(
837857
Example: "D5E3F7A"
838858
:type upload_session_id: str
839859
:param parts: The list details for the uploaded parts.
860+
861+
Each entry can include `sha1` or `sha512`. Include `sha512`
862+
on every entry or on none of them. A request where only
863+
some entries include `sha512` is rejected.
864+
865+
Include parts that the server already has, returned as
866+
`hits` by the [`Plan upload session`](https://developer.box.com/reference/post-files-upload-sessions-id-plan)
867+
endpoint. Use the `part_id`, `offset`, and `size` from the
868+
plan response. If the other entries include `sha512`,
869+
include the `sha512` value from the plan response.
870+
Otherwise, leave the hash out of these entries.
840871
:type parts: List[UploadPart]
841872
:param digest: The [RFC3230][1] message digest of the whole file.
842873
843874
Only SHA1 is supported. The SHA1 digest must be Base64
844875
encoded. The format of this header is as
845876
`sha=BASE64_ENCODED_DIGEST`.
846877
878+
`SHA-512` is not supported for the whole-file digest, even if
879+
the parts were uploaded with `SHA-512` digests.
880+
847881
[1]: https://tools.ietf.org/html/rfc3230
848882
:type digest: str
849883
:param if_match: Ensures this item hasn't recently changed before

‎box_sdk_gen/managers/query.py‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,51 @@ def create_query_v2026_r0(
154154
extra_headers: Optional[Dict[str, Optional[str]]] = None
155155
) -> QueryResultsV2026R0:
156156
"""
157-
Runs a query to discover Box items using a logical predicate that can filter
157+
Runs a query to discover Box items using a logical predicate, similar to a SQL
158158
159-
across item fields and metadata templates. Results can be sorted, paginated,
159+
WHERE clause. The predicate can filter across multiple metadata templates and
160160
161161
162-
and shaped to include additional item or metadata fields.
162+
item fields in a single request. Results can be sorted, paginated with markers,
163+
164+
165+
and shaped with fields so each entry includes additional item or metadata
166+
167+
168+
attributes.
169+
170+
171+
This is the item-retrieval endpoint in the Query API (version 2026.0). Unlike
172+
173+
174+
the [Metadata Query API](https://developer.box.com/reference/post-metadata-queries-execute-read),
175+
176+
177+
it is not limited to a single metadata template or to files and folders. For
178+
179+
180+
totals and grouped metrics over the same predicates, use
181+
182+
183+
[Query Insights](https://developer.box.com/reference/v2026.0/post-query-insights)
184+
185+
186+
instead of paging through every matching item.
187+
188+
189+
For predicate syntax, parameters, examples, pagination behavior, and error
190+
191+
192+
codes, see the
193+
194+
195+
[Box Query guide](https://developer.box.com/guides/query/box-query). For shared
196+
197+
198+
response schemas, including Query results and result entries, see
199+
200+
201+
[Query resources](https://developer.box.com/reference/v2026.0/query-resources).
163202
164203
:param query: The query definition, including the filtering predicate and its optional
165204
parameters and ancestor restrictions.

‎box_sdk_gen/managers/search.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,17 @@ def search_by_metadata_query(
144144
extra_headers: Optional[Dict[str, Optional[str]]] = None
145145
) -> MetadataQueryResults:
146146
"""
147+
For new integrations, use the [v2026.0 Query API](https://developer.box.com/reference/v2026.0/query-resources).
148+
149+
This is the latest version of the Query API, with advanced capabilities including multi-template queries and
150+
151+
152+
Query Insights, and is the API we will continue to enhance with new Query capabilities.
153+
154+
147155
Create a search using SQL-like syntax to return items that match specific
148156
157+
149158
metadata.
150159
151160

‎box_sdk_gen/schemas/client_error.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ClientErrorCodeField(str, Enum):
2626
METHOD_NOT_ALLOWED = 'method_not_allowed'
2727
CONFLICT = 'conflict'
2828
PRECONDITION_FAILED = 'precondition_failed'
29+
UNPROCESSABLE_ENTITY = 'unprocessable_entity'
2930
TOO_MANY_REQUESTS = 'too_many_requests'
3031
INTERNAL_SERVER_ERROR = 'internal_server_error'
3132
UNAVAILABLE = 'unavailable'

‎box_sdk_gen/schemas/upload_part.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
class UploadPart(UploadPartMini):
1111
_fields_to_json_mapping: Dict[str, str] = {
1212
'sha_1': 'sha1',
13+
'sha_512': 'sha512',
1314
**UploadPartMini._fields_to_json_mapping,
1415
}
1516
_json_to_fields_mapping: Dict[str, str] = {
1617
'sha1': 'sha_1',
18+
'sha512': 'sha_512',
1719
**UploadPartMini._json_to_fields_mapping,
1820
}
1921

2022
def __init__(
2123
self,
2224
*,
2325
sha_1: Optional[str] = None,
26+
sha_512: Optional[str] = None,
2427
part_id: Optional[str] = None,
2528
offset: Optional[int] = None,
2629
size: Optional[int] = None,
@@ -29,6 +32,9 @@ def __init__(
2932
"""
3033
:param sha_1: The SHA1 hash of the chunk., defaults to None
3134
:type sha_1: Optional[str], optional
35+
:param sha_512: The `SHA-512` hash of the chunk, as a hex string
36+
of 128 lower case characters., defaults to None
37+
:type sha_512: Optional[str], optional
3238
:param part_id: The unique ID of the chunk., defaults to None
3339
:type part_id: Optional[str], optional
3440
:param offset: The offset of the chunk within the file
@@ -40,3 +46,4 @@ def __init__(
4046
"""
4147
super().__init__(part_id=part_id, offset=offset, size=size, **kwargs)
4248
self.sha_1 = sha_1
49+
self.sha_512 = sha_512

‎box_sdk_gen/schemas/upload_part_plan.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def __init__(self, offset: int, size: int, sha_512: str, **kwargs):
2323
:type offset: int
2424
:param size: The size of the chunk in bytes.
2525
:type size: int
26-
:param sha_512: The `SHA-512` hash of the chunk.
26+
:param sha_512: The `SHA-512` hash of the chunk, as a hex string
27+
of 128 lower case characters.
2728
:type sha_512: str
2829
"""
2930
super().__init__(**kwargs)

‎box_sdk_gen/schemas/upload_part_plan_hit.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def __init__(self, offset: int, size: int, sha_512: str, part_id: str, **kwargs)
2323
:type offset: int
2424
:param size: The size of the chunk in bytes.
2525
:type size: int
26-
:param sha_512: The `SHA-512` hash of the chunk.
26+
:param sha_512: The `SHA-512` hash of the chunk, as a hex string
27+
of 128 lower case characters.
2728
:type sha_512: str
2829
:param part_id: The unique ID of the chunk.
2930
:type part_id: str
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
from typing import Dict
22

3+
from typing import Optional
4+
35
from box_sdk_gen.internal.base_object import BaseObject
46

57
from box_sdk_gen.box.errors import BoxSDKError
68

79

810
class DocGenDocumentGenerationDataV2025R0(BaseObject):
9-
def __init__(self, generated_file_name: str, user_input: Dict, **kwargs):
11+
def __init__(
12+
self,
13+
generated_file_name: str,
14+
user_input: Dict,
15+
*,
16+
external_id: Optional[str] = None,
17+
**kwargs
18+
):
1019
"""
11-
:param generated_file_name: File name of the output file.
12-
:type generated_file_name: str
20+
:param generated_file_name: File name of the output file.
21+
:type generated_file_name: str
22+
:param external_id: An optional identifier supplied by the caller for this Box Doc Gen job.
23+
The value is returned on job responses for correlation only. It is not
24+
a Box resource ID, is not required to be unique, and cannot be used to
25+
look up the job., defaults to None
26+
:type external_id: Optional[str], optional
1327
"""
1428
super().__init__(**kwargs)
1529
self.generated_file_name = generated_file_name
1630
self.user_input = user_input
31+
self.external_id = external_id

‎box_sdk_gen/schemas/v2025_r0/doc_gen_job_full_v2025_r0.py‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,33 @@ def __init__(
5151
id: str,
5252
*,
5353
created_at: Optional[str] = None,
54+
external_id: Optional[str] = None,
5455
output_file: Optional[FileReferenceV2025R0] = None,
5556
output_file_version: Optional[FileVersionBaseV2025R0] = None,
5657
failures: Optional[DocGenJobV2025R0FailuresField] = None,
5758
type: DocGenJobBaseV2025R0TypeField = DocGenJobBaseV2025R0TypeField.DOCGEN_JOB,
5859
**kwargs
5960
):
6061
"""
61-
:param source: Source of the request.
62-
:type source: str
63-
:param status: Status of the job.
64-
:type status: DocGenJobV2025R0StatusField
65-
:param output_type: Type of the generated file.
66-
:type output_type: str
67-
:param id: The unique identifier that represent a Box Doc Gen job.
68-
:type id: str
69-
:param created_at: Time of job creation., defaults to None
70-
:type created_at: Optional[str], optional
71-
:param failures: Errors and warnings that occurred during document generation., defaults to None
72-
:type failures: Optional[DocGenJobV2025R0FailuresField], optional
73-
:param type: The value will always be `docgen_job`., defaults to DocGenJobBaseV2025R0TypeField.DOCGEN_JOB
74-
:type type: DocGenJobBaseV2025R0TypeField, optional
62+
:param source: Source of the request.
63+
:type source: str
64+
:param status: Status of the job.
65+
:type status: DocGenJobV2025R0StatusField
66+
:param output_type: Type of the generated file.
67+
:type output_type: str
68+
:param id: The unique identifier that represent a Box Doc Gen job.
69+
:type id: str
70+
:param created_at: Time of job creation., defaults to None
71+
:type created_at: Optional[str], optional
72+
:param external_id: An optional identifier supplied by the caller when the Box Doc Gen
73+
job was created. Returned for correlation only. It is not a Box
74+
resource ID, is not required to be unique, and cannot be used to
75+
look up the job., defaults to None
76+
:type external_id: Optional[str], optional
77+
:param failures: Errors and warnings that occurred during document generation., defaults to None
78+
:type failures: Optional[DocGenJobV2025R0FailuresField], optional
79+
:param type: The value will always be `docgen_job`., defaults to DocGenJobBaseV2025R0TypeField.DOCGEN_JOB
80+
:type type: DocGenJobBaseV2025R0TypeField, optional
7581
"""
7682
super().__init__(
7783
batch=batch,
@@ -80,6 +86,7 @@ def __init__(
8086
status=status,
8187
output_type=output_type,
8288
id=id,
89+
external_id=external_id,
8390
output_file=output_file,
8491
output_file_version=output_file_version,
8592
failures=failures,

0 commit comments

Comments
 (0)