Skip to content

Commit 758e56f

Browse files
box-sdk-buildbox-sdk-build
andauthored
feat: add metadata_template support and filter_fields to legal hold assignments (box/box-openapi#625)
Co-authored-by: box-sdk-build <box-sdk-build@box.com>
1 parent 03001e6 commit 758e56f

8 files changed

Lines changed: 54 additions & 4 deletions

‎.codegen.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "88c0ae7", "specHash": "a0e8038", "version": "10.18.0" }
1+
{ "engineHash": "88c0ae7", "specHash": "74452eb", "version": "10.18.0" }

‎box_sdk_gen/managers/legal_hold_policy_assignments.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
from box_sdk_gen.schemas.legal_hold_policy_assignment import LegalHoldPolicyAssignment
2424

25+
from box_sdk_gen.schemas.legal_hold_policy_assignment_filter_field import (
26+
LegalHoldPolicyAssignmentFilterField,
27+
)
28+
2529
from box_sdk_gen.schemas.files_on_hold import FilesOnHold
2630

2731
from box_sdk_gen.box.errors import BoxSDKError
@@ -52,6 +56,7 @@ class GetLegalHoldPolicyAssignmentsAssignToType(str, Enum):
5256
USER = 'user'
5357
OWNERSHIP = 'ownership'
5458
INTERACTIONS = 'interactions'
59+
METADATA_TEMPLATE = 'metadata_template'
5560

5661

5762
class CreateLegalHoldPolicyAssignmentAssignToTypeField(str, Enum):
@@ -61,6 +66,7 @@ class CreateLegalHoldPolicyAssignmentAssignToTypeField(str, Enum):
6166
USER = 'user'
6267
OWNERSHIP = 'ownership'
6368
INTERACTIONS = 'interactions'
69+
METADATA_TEMPLATE = 'metadata_template'
6470

6571

6672
class CreateLegalHoldPolicyAssignmentAssignTo(BaseObject):
@@ -71,6 +77,7 @@ class CreateLegalHoldPolicyAssignmentAssignTo(BaseObject):
7177
'user',
7278
'ownership',
7379
'interactions',
80+
'metadata_template',
7481
}
7582

7683
def __init__(
@@ -176,20 +183,27 @@ def create_legal_hold_policy_assignment(
176183
policy_id: str,
177184
assign_to: CreateLegalHoldPolicyAssignmentAssignTo,
178185
*,
186+
filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]] = None,
179187
extra_headers: Optional[Dict[str, Optional[str]]] = None
180188
) -> LegalHoldPolicyAssignment:
181189
"""
182-
Assign a legal hold to an item type of: file, file version, folder, user, ownership, or interactions.
190+
Assign a legal hold to an item type of: file, file version, folder, user, ownership, interactions, or metadata template.
183191
:param policy_id: The ID of the policy to assign.
184192
:type policy_id: str
185193
:param assign_to: The item to assign the policy to.
186194
:type assign_to: CreateLegalHoldPolicyAssignmentAssignTo
195+
:param filter_fields: List of metadata template field filters. Only required when `assign_to.type` is `metadata_template`., defaults to None
196+
:type filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]], optional
187197
:param extra_headers: Extra headers that will be included in the HTTP request., defaults to None
188198
:type extra_headers: Optional[Dict[str, Optional[str]]], optional
189199
"""
190200
if extra_headers is None:
191201
extra_headers = {}
192-
request_body: Dict = {'policy_id': policy_id, 'assign_to': assign_to}
202+
request_body: Dict = {
203+
'policy_id': policy_id,
204+
'assign_to': assign_to,
205+
'filter_fields': filter_fields,
206+
}
193207
headers_map: Dict[str, str] = prepare_params({**extra_headers})
194208
response: FetchResponse = self.network_session.network_client.fetch(
195209
FetchOptions(

‎box_sdk_gen/schemas/__init__.py‎

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

205205
from box_sdk_gen.schemas.legal_hold_policy_assignment_base import *
206206

207+
from box_sdk_gen.schemas.legal_hold_policy_assignment_filter_field import *
208+
207209
from box_sdk_gen.schemas.metadata_base import *
208210

209211
from box_sdk_gen.schemas.metadata import *

‎box_sdk_gen/schemas/legal_hold_policy.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(
3232
file_version: Optional[int] = None,
3333
ownership: Optional[int] = None,
3434
interactions: Optional[int] = None,
35+
metadata_template: Optional[int] = None,
3536
**kwargs
3637
):
3738
"""
@@ -47,6 +48,8 @@ def __init__(
4748
:type ownership: Optional[int], optional
4849
:param interactions: The number of users this policy is applied to with the `interactions` type assignment., defaults to None
4950
:type interactions: Optional[int], optional
51+
:param metadata_template: The number of metadata templates this policy is applied to., defaults to None
52+
:type metadata_template: Optional[int], optional
5053
"""
5154
super().__init__(**kwargs)
5255
self.user = user
@@ -55,6 +58,7 @@ def __init__(
5558
self.file_version = file_version
5659
self.ownership = ownership
5760
self.interactions = interactions
61+
self.metadata_template = metadata_template
5862

5963

6064
class LegalHoldPolicy(LegalHoldPolicyMini):

‎box_sdk_gen/schemas/legal_hold_policy_assigned_item.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class LegalHoldPolicyAssignedItemTypeField(str, Enum):
1212
USER = 'user'
1313
OWNERSHIP = 'ownership'
1414
INTERACTIONS = 'interactions'
15+
METADATA_TEMPLATE = 'metadata_template'
1516

1617

1718
class LegalHoldPolicyAssignedItem(BaseObject):
@@ -22,6 +23,7 @@ class LegalHoldPolicyAssignedItem(BaseObject):
2223
'user',
2324
'ownership',
2425
'interactions',
26+
'metadata_template',
2527
}
2628

2729
def __init__(self, type: LegalHoldPolicyAssignedItemTypeField, id: str, **kwargs):

‎box_sdk_gen/schemas/legal_hold_policy_assignment.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Optional
22

3+
from typing import List
4+
35
from box_sdk_gen.schemas.legal_hold_policy_assignment_base import (
46
LegalHoldPolicyAssignmentBaseTypeField,
57
)
@@ -16,6 +18,10 @@
1618

1719
from box_sdk_gen.schemas.user_mini import UserMini
1820

21+
from box_sdk_gen.schemas.legal_hold_policy_assignment_filter_field import (
22+
LegalHoldPolicyAssignmentFilterField,
23+
)
24+
1925
from box_sdk_gen.box.errors import BoxSDKError
2026

2127
from box_sdk_gen.internal.utils import DateTime
@@ -32,6 +38,7 @@ def __init__(
3238
assigned_by: Optional[UserMini] = None,
3339
assigned_at: Optional[DateTime] = None,
3440
deleted_at: Optional[DateTime] = None,
41+
filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]] = None,
3542
id: Optional[str] = None,
3643
type: Optional[LegalHoldPolicyAssignmentBaseTypeField] = None,
3744
**kwargs
@@ -46,6 +53,8 @@ def __init__(
4653
assignment is fully deleted). If null, Assignment
4754
was not deleted., defaults to None
4855
:type deleted_at: Optional[DateTime], optional
56+
:param filter_fields: List of metadata template field filters. Only present when `assigned_to.type` is `metadata_template`., defaults to None
57+
:type filter_fields: Optional[List[LegalHoldPolicyAssignmentFilterField]], optional
4958
:param id: The unique identifier for this legal hold assignment., defaults to None
5059
:type id: Optional[str], optional
5160
:param type: The value will always be `legal_hold_policy_assignment`., defaults to None
@@ -57,3 +66,4 @@ def __init__(
5766
self.assigned_by = assigned_by
5867
self.assigned_at = assigned_at
5968
self.deleted_at = deleted_at
69+
self.filter_fields = filter_fields
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from box_sdk_gen.internal.base_object import BaseObject
2+
3+
from box_sdk_gen.box.errors import BoxSDKError
4+
5+
6+
class LegalHoldPolicyAssignmentFilterField(BaseObject):
7+
def __init__(self, field: str, value: str, **kwargs):
8+
"""
9+
:param field: The ID of the metadata template field to filter on.
10+
:type field: str
11+
:param value: The value of the metadata template field to filter on.
12+
:type value: str
13+
"""
14+
super().__init__(**kwargs)
15+
self.field = field
16+
self.value = value

‎docs/legal_hold_policy_assignments.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Returns a list of legal hold policy assignments.
4848

4949
## Assign legal hold policy
5050

51-
Assign a legal hold to an item type of: file, file version, folder, user, ownership, or interactions.
51+
Assign a legal hold to an item type of: file, file version, folder, user, ownership, interactions, or metadata template.
5252

5353
This operation is performed by calling function `create_legal_hold_policy_assignment`.
5454

@@ -72,6 +72,8 @@ client.legal_hold_policy_assignments.create_legal_hold_policy_assignment(
7272
- The ID of the policy to assign.
7373
- assign_to `CreateLegalHoldPolicyAssignmentAssignTo`
7474
- The item to assign the policy to.
75+
- filter_fields `Optional[List[LegalHoldPolicyAssignmentFilterField]]`
76+
- List of metadata template field filters. Only required when `assign_to.type` is `metadata_template`.
7577
- extra_headers `Optional[Dict[str, Optional[str]]]`
7678
- Extra headers that will be included in the HTTP request.
7779

0 commit comments

Comments
 (0)