Skip to content

Commit

Permalink
fix: Fix metadata filter resource (box/box-openapi#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed May 8, 2024
1 parent b0f0110 commit d05a650
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "36bf5da", "specHash": "a8c36df", "version": "0.6.4" }
{ "engineHash": "36bf5da", "specHash": "f7e92ba", "version": "0.6.4" }
2 changes: 2 additions & 0 deletions box_sdk_gen/managers/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class GetEventsEventType(str, Enum):
GROUP_EDITED = 'GROUP_EDITED'
GROUP_REMOVE_ITEM = 'GROUP_REMOVE_ITEM'
GROUP_REMOVE_USER = 'GROUP_REMOVE_USER'
ITEM_EMAIL_SEND = 'ITEM_EMAIL_SEND'
ITEM_MODIFY = 'ITEM_MODIFY'
ITEM_OPEN = 'ITEM_OPEN'
ITEM_SHARED_UPDATE = 'ITEM_SHARED_UPDATE'
Expand Down Expand Up @@ -127,6 +128,7 @@ class GetEventsEventType(str, Enum):
RENAME = 'RENAME'
RETENTION_POLICY_ASSIGNMENT_ADD = 'RETENTION_POLICY_ASSIGNMENT_ADD'
SHARE = 'SHARE'
SHARED_LINK_SEND = 'SHARED_LINK_SEND'
SHARE_EXPIRATION = 'SHARE_EXPIRATION'
SHIELD_ALERT = 'SHIELD_ALERT'
SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED = 'SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED'
Expand Down
11 changes: 3 additions & 8 deletions box_sdk_gen/managers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,9 @@ def search_for_content(
the trash
* `all_items` - Searches for both trashed and non-trashed items., defaults to None
:type trash_content: Optional[SearchForContentTrashContent], optional
:param mdfilters: 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., defaults to None
:param mdfilters: 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., defaults to None
:type mdfilters: Optional[List[MetadataFilter]], optional
:param sort: Defines the order in which search results are returned. This API
defaults to returning items by relevance unless this parameter is
Expand Down
28 changes: 19 additions & 9 deletions box_sdk_gen/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9173,6 +9173,7 @@ class EventEventTypeField(str, Enum):
ITEM_COPY = 'ITEM_COPY'
ITEM_CREATE = 'ITEM_CREATE'
ITEM_DOWNLOAD = 'ITEM_DOWNLOAD'
ITEM_EMAIL_SEND = 'ITEM_EMAIL_SEND'
ITEM_MAKE_CURRENT_VERSION = 'ITEM_MAKE_CURRENT_VERSION'
ITEM_MODIFY = 'ITEM_MODIFY'
ITEM_MOVE = 'ITEM_MOVE'
Expand Down Expand Up @@ -9213,6 +9214,7 @@ class EventEventTypeField(str, Enum):
RENAME = 'RENAME'
RETENTION_POLICY_ASSIGNMENT_ADD = 'RETENTION_POLICY_ASSIGNMENT_ADD'
SHARE = 'SHARE'
SHARED_LINK_SEND = 'SHARED_LINK_SEND'
SHARE_EXPIRATION = 'SHARE_EXPIRATION'
SHIELD_ALERT = 'SHIELD_ALERT'
SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED = 'SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED'
Expand Down Expand Up @@ -12913,7 +12915,7 @@ def __init__(
self.entries = entries


class MetadataFieldFilterFloatRangeValue(BaseObject):
class MetadataFieldFilterFloatRange(BaseObject):
def __init__(
self, *, lt: Optional[float] = None, gt: Optional[float] = None, **kwargs
):
Expand All @@ -12934,7 +12936,7 @@ def __init__(
self.gt = gt


class MetadataFieldFilterDateRangeValue(BaseObject):
class MetadataFieldFilterDateRange(BaseObject):
def __init__(
self, *, lt: Optional[DateTime] = None, gt: Optional[DateTime] = None, **kwargs
):
Expand Down Expand Up @@ -12977,12 +12979,15 @@ def __init__(
scope: Optional[MetadataFilterScopeField] = None,
template_key: Optional[str] = None,
filters: Optional[
Union[
Dict[str, str],
Dict[str, float],
Dict[str, List[str]],
Dict[str, MetadataFieldFilterFloatRangeValue],
Dict[str, MetadataFieldFilterDateRangeValue],
Dict[
str,
Union[
str,
float,
List[str],
MetadataFieldFilterFloatRange,
MetadataFieldFilterDateRange,
],
]
] = None,
**kwargs
Expand All @@ -12994,7 +12999,7 @@ def __init__(
for use in this enterprise, and `global` for general templates
that are available to all enterprises using Box., defaults to None
:type scope: Optional[MetadataFilterScopeField], optional
:param template_key: The key of the template to filter search results by.
:param template_key: The key of the template used to filter search results.

In many cases the template key is automatically derived
of its display name, for example `Contract Template` would
Expand All @@ -13009,6 +13014,11 @@ def __init__(
[file]: e://get-files-id-metadata
[folder]: e://get-folders-id-metadata, defaults to None
:type template_key: Optional[str], optional
:param filters: Specifies which fields on the template to filter the search
results by. When more than one field is specified, the query
performs a logical `AND` to ensure that the instance of the
template matches each of the fields specified., defaults to None
:type filters: Optional[Dict[str, Union[str, float, List[str], MetadataFieldFilterFloatRange, MetadataFieldFilterDateRange]]], optional
"""
super().__init__(**kwargs)
self.scope = scope
Expand Down
4 changes: 2 additions & 2 deletions docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ See the endpoint docs at
<!-- sample get_search -->

```python
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)])
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)])
```

### Arguments
Expand Down Expand Up @@ -93,7 +93,7 @@ client.search.search_for_content(ancestor_folder_ids=['0'], mdfilters=[MetadataF
- trash_content `Optional[SearchForContentTrashContent]`
- 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.
- mdfilters `Optional[List[MetadataFilter]]`
- 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.
- 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.
- sort `Optional[SearchForContentSort]`
- 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.
- direction `Optional[SearchForContentDirection]`
Expand Down
4 changes: 2 additions & 2 deletions test/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def testMetadataFilters():
MetadataFilter(
filters={
'stringField': 'stringValue',
'dateField': {}(
'dateField': MetadataFieldFilterDateRange(
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),
'floatField': MetadataFieldFilterFloatRange(lt=9.5, gt=10.5),
'enumField': 'enumValue2',
'multiSelectField': ['multiSelectValue1', 'multiSelectValue2'],
},
Expand Down

0 comments on commit d05a650

Please sign in to comment.