Skip to content

Commit d05a650

Browse files
committed
fix: Fix metadata filter resource (box/box-openapi#419)
1 parent b0f0110 commit d05a650

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "36bf5da", "specHash": "a8c36df", "version": "0.6.4" }
1+
{ "engineHash": "36bf5da", "specHash": "f7e92ba", "version": "0.6.4" }

box_sdk_gen/managers/events.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class GetEventsEventType(str, Enum):
100100
GROUP_EDITED = 'GROUP_EDITED'
101101
GROUP_REMOVE_ITEM = 'GROUP_REMOVE_ITEM'
102102
GROUP_REMOVE_USER = 'GROUP_REMOVE_USER'
103+
ITEM_EMAIL_SEND = 'ITEM_EMAIL_SEND'
103104
ITEM_MODIFY = 'ITEM_MODIFY'
104105
ITEM_OPEN = 'ITEM_OPEN'
105106
ITEM_SHARED_UPDATE = 'ITEM_SHARED_UPDATE'
@@ -127,6 +128,7 @@ class GetEventsEventType(str, Enum):
127128
RENAME = 'RENAME'
128129
RETENTION_POLICY_ASSIGNMENT_ADD = 'RETENTION_POLICY_ASSIGNMENT_ADD'
129130
SHARE = 'SHARE'
131+
SHARED_LINK_SEND = 'SHARED_LINK_SEND'
130132
SHARE_EXPIRATION = 'SHARE_EXPIRATION'
131133
SHIELD_ALERT = 'SHIELD_ALERT'
132134
SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED = 'SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED'

box_sdk_gen/managers/search.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,9 @@ def search_for_content(
428428
the trash
429429
* `all_items` - Searches for both trashed and non-trashed items., defaults to None
430430
:type trash_content: Optional[SearchForContentTrashContent], optional
431-
:param mdfilters: Limits the search results to any items for which the metadata matches
432-
the provided filter.
433-
434-
This parameter contains a list of 1 metadata template to filter
435-
the search results by. This list can currently only
436-
contain one entry, though this might be expanded in the future.
437-
438-
This parameter is required unless the `query` parameter is provided., defaults to None
431+
:param mdfilters: Limits the search results to any items for which the metadata matches the provided filter.
432+
This parameter is a list that specifies exactly **one** metadata template used to filter the search results.
433+
It is required unless the `query` parameter is provided., defaults to None
439434
:type mdfilters: Optional[List[MetadataFilter]], optional
440435
:param sort: Defines the order in which search results are returned. This API
441436
defaults to returning items by relevance unless this parameter is

box_sdk_gen/schemas.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9173,6 +9173,7 @@ class EventEventTypeField(str, Enum):
91739173
ITEM_COPY = 'ITEM_COPY'
91749174
ITEM_CREATE = 'ITEM_CREATE'
91759175
ITEM_DOWNLOAD = 'ITEM_DOWNLOAD'
9176+
ITEM_EMAIL_SEND = 'ITEM_EMAIL_SEND'
91769177
ITEM_MAKE_CURRENT_VERSION = 'ITEM_MAKE_CURRENT_VERSION'
91779178
ITEM_MODIFY = 'ITEM_MODIFY'
91789179
ITEM_MOVE = 'ITEM_MOVE'
@@ -9213,6 +9214,7 @@ class EventEventTypeField(str, Enum):
92139214
RENAME = 'RENAME'
92149215
RETENTION_POLICY_ASSIGNMENT_ADD = 'RETENTION_POLICY_ASSIGNMENT_ADD'
92159216
SHARE = 'SHARE'
9217+
SHARED_LINK_SEND = 'SHARED_LINK_SEND'
92169218
SHARE_EXPIRATION = 'SHARE_EXPIRATION'
92179219
SHIELD_ALERT = 'SHIELD_ALERT'
92189220
SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED = 'SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED'
@@ -12913,7 +12915,7 @@ def __init__(
1291312915
self.entries = entries
1291412916

1291512917

12916-
class MetadataFieldFilterFloatRangeValue(BaseObject):
12918+
class MetadataFieldFilterFloatRange(BaseObject):
1291712919
def __init__(
1291812920
self, *, lt: Optional[float] = None, gt: Optional[float] = None, **kwargs
1291912921
):
@@ -12934,7 +12936,7 @@ def __init__(
1293412936
self.gt = gt
1293512937

1293612938

12937-
class MetadataFieldFilterDateRangeValue(BaseObject):
12939+
class MetadataFieldFilterDateRange(BaseObject):
1293812940
def __init__(
1293912941
self, *, lt: Optional[DateTime] = None, gt: Optional[DateTime] = None, **kwargs
1294012942
):
@@ -12977,12 +12979,15 @@ def __init__(
1297712979
scope: Optional[MetadataFilterScopeField] = None,
1297812980
template_key: Optional[str] = None,
1297912981
filters: Optional[
12980-
Union[
12981-
Dict[str, str],
12982-
Dict[str, float],
12983-
Dict[str, List[str]],
12984-
Dict[str, MetadataFieldFilterFloatRangeValue],
12985-
Dict[str, MetadataFieldFilterDateRangeValue],
12982+
Dict[
12983+
str,
12984+
Union[
12985+
str,
12986+
float,
12987+
List[str],
12988+
MetadataFieldFilterFloatRange,
12989+
MetadataFieldFilterDateRange,
12990+
],
1298612991
]
1298712992
] = None,
1298812993
**kwargs
@@ -12994,7 +12999,7 @@ def __init__(
1299412999
for use in this enterprise, and `global` for general templates
1299513000
that are available to all enterprises using Box., defaults to None
1299613001
:type scope: Optional[MetadataFilterScopeField], optional
12997-
:param template_key: The key of the template to filter search results by.
13002+
:param template_key: The key of the template used to filter search results.
1299813003

1299913004
In many cases the template key is automatically derived
1300013005
of its display name, for example `Contract Template` would
@@ -13009,6 +13014,11 @@ def __init__(
1300913014
[file]: e://get-files-id-metadata
1301013015
[folder]: e://get-folders-id-metadata, defaults to None
1301113016
:type template_key: Optional[str], optional
13017+
:param filters: Specifies which fields on the template to filter the search
13018+
results by. When more than one field is specified, the query
13019+
performs a logical `AND` to ensure that the instance of the
13020+
template matches each of the fields specified., defaults to None
13021+
:type filters: Optional[Dict[str, Union[str, float, List[str], MetadataFieldFilterFloatRange, MetadataFieldFilterDateRange]]], optional
1301213022
"""
1301313023
super().__init__(**kwargs)
1301413024
self.scope = scope

docs/search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ See the endpoint docs at
6363
<!-- sample get_search -->
6464

6565
```python
66-
client.search.search_for_content(ancestor_folder_ids=['0'], mdfilters=[MetadataFilter(filters={'stringField': 'stringValue', 'dateField': {}(lt=date_time_from_string('2035-01-01T00:00:00Z'), gt=date_time_from_string('2035-01-03T00:00:00Z')), 'floatField': {}(lt=9.5, gt=10.5), 'enumField': 'enumValue2', 'multiSelectField': ['multiSelectValue1', 'multiSelectValue2']}, scope=MetadataFilterScopeField.ENTERPRISE.value, template_key=template_key)])
66+
client.search.search_for_content(ancestor_folder_ids=['0'], mdfilters=[MetadataFilter(filters={'stringField': 'stringValue', 'dateField': MetadataFieldFilterDateRange(lt=date_time_from_string('2035-01-01T00:00:00Z'), gt=date_time_from_string('2035-01-03T00:00:00Z')), 'floatField': MetadataFieldFilterFloatRange(lt=9.5, gt=10.5), 'enumField': 'enumValue2', 'multiSelectField': ['multiSelectValue1', 'multiSelectValue2']}, scope=MetadataFilterScopeField.ENTERPRISE.value, template_key=template_key)])
6767
```
6868

6969
### Arguments
@@ -93,7 +93,7 @@ client.search.search_for_content(ancestor_folder_ids=['0'], mdfilters=[MetadataF
9393
- trash_content `Optional[SearchForContentTrashContent]`
9494
- Determines if the search should look in the trash for items. By default, this API only returns search results for items not currently in the trash (`non_trashed_only`). _ `trashed_only` - Only searches for items currently in the trash _ `non_trashed_only` - Only searches for items currently not in the trash \* `all_items` - Searches for both trashed and non-trashed items.
9595
- mdfilters `Optional[List[MetadataFilter]]`
96-
- Limits the search results to any items for which the metadata matches the provided filter. This parameter contains a list of 1 metadata template to filter the search results by. This list can currently only contain one entry, though this might be expanded in the future. This parameter is required unless the `query` parameter is provided.
96+
- Limits the search results to any items for which the metadata matches the provided filter. This parameter is a list that specifies exactly **one** metadata template used to filter the search results. It is required unless the `query` parameter is provided.
9797
- sort `Optional[SearchForContentSort]`
9898
- Defines the order in which search results are returned. This API defaults to returning items by relevance unless this parameter is explicitly specified. _ `relevance` (default) returns the results sorted by relevance to the query search term. The relevance is based on the occurrence of the search term in the items name, description, content, and additional properties. _ `modified_at` returns the results ordered in descending order by date at which the item was last modified.
9999
- direction `Optional[SearchForContentDirection]`

test/search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ def testMetadataFilters():
189189
MetadataFilter(
190190
filters={
191191
'stringField': 'stringValue',
192-
'dateField': {}(
192+
'dateField': MetadataFieldFilterDateRange(
193193
lt=date_time_from_string('2035-01-01T00:00:00Z'),
194194
gt=date_time_from_string('2035-01-03T00:00:00Z'),
195195
),
196-
'floatField': {}(lt=9.5, gt=10.5),
196+
'floatField': MetadataFieldFilterFloatRange(lt=9.5, gt=10.5),
197197
'enumField': 'enumValue2',
198198
'multiSelectField': ['multiSelectValue1', 'multiSelectValue2'],
199199
},

0 commit comments

Comments
 (0)