From 099503d441c08c2f25c70c059e9b3767e10101e4 Mon Sep 17 00:00:00 2001 From: Nikita Turchaninov <2010628+slowaner@users.noreply.github.com> Date: Wed, 31 Jul 2024 18:15:18 +0300 Subject: [PATCH] Update datasource api Update entities api --- HISTORY.md | 2 ++ cybsi/api/data_source/api.py | 10 +++++-- cybsi/api/observable/entities_api.py | 44 +++++++++++++++++++++------- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index e355a65..32f204f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,8 @@ Release History 2.13.0 (2024-08-01) ------------------- - Add search entities api +- Increase maximum length of `query` parameter for datasource filter method. +- Add `suggest` parameter to entities aggregate method. 2.13.0a1 (2024-07-10) --------------------- diff --git a/cybsi/api/data_source/api.py b/cybsi/api/data_source/api.py index 378fbca..609ce43 100644 --- a/cybsi/api/data_source/api.py +++ b/cybsi/api/data_source/api.py @@ -130,11 +130,14 @@ def filter( Added new parameters: `query`, `type_uuids`, `order_by`. Added semantic error `DataSourceNotFound` + .. versionchanged:: 2.13 + Increased maxumum length of `query` parameter. + Note: Calls `GET /data-sources`. Args: query: Filter of data sources by specified substring (case-insensitive). - Substring length must be in range [1, 50]. + Substring length must be in range [1, 250]. Filtering is performed by specified substring in data source names or its type names. type_uuids: List of data source type UUIDs. @@ -308,11 +311,14 @@ async def filter( ) -> AsyncPage["DataSourceCommonView"]: """Get a filtered list of data sources. + .. versionchanged:: 2.13 + Increased maxumum length of `query` parameter. + Note: Calls `GET /data-sources`. Args: query: Filter of data sources by specified substring (case-insensitive). - Substring length must be in range [1, 50]. + Substring length must be in range [1, 250]. Filtering is performed by specified substring in data source names or its type names. type_uuids: List of data source type UUIDs. diff --git a/cybsi/api/observable/entities_api.py b/cybsi/api/observable/entities_api.py index 7b8e87b..d28b220 100644 --- a/cybsi/api/observable/entities_api.py +++ b/cybsi/api/observable/entities_api.py @@ -174,6 +174,7 @@ def aggregate( entity_type: Optional[EntityTypes] = None, key_type: Optional[EntityKeyTypes] = None, key: Optional[str] = None, + suggest: Optional[str] = None, sections: Optional[Iterable[EntityAggregateSections]] = None, forecast_at: Optional[datetime] = None, cursor: Optional[Cursor] = None, @@ -188,6 +189,9 @@ def aggregate( .. versionchanged:: 2.11 Added new parameter `dict_item_uuid`. + .. versionchanged:: 2.13 + Added new parameter `suggest`. + Note: Calls `GET /observable/entities`. @@ -195,20 +199,26 @@ def aggregate( should be specified else Cybsi API will return error. Args: entity_uuids: Entity uuids. - Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`. + Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`, + `suggest`. dict_item_uuid: Dictionary item which is attributed to the entity. - Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`. + Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`, + `suggest`. entity_type: Entity type. Excludes parameter `entity_uuids`, `dict_item_uuid` and requires parameter `key`. The parameter is not required if the `entity_type` can be uniquely determined by `key_type`. key_type: Entity natural key type. - Excludes parameter `entity_uuids`, `dict_item_uuid` and + Excludes parameter `entity_uuids`, `dict_item_uuid`, `suggest` and requires parameter `key`. The parameter is not required if only one `key_type` is used for the specified `entity_type`. - key: Entity natural key value. Required if `entity_type` or `key_type` - parameter is specified. + key: Entity natural key value. Excludes parameter `suggest` and required + if `entity_type` or `key_type` parameter is specified. It is possible to pass a key value in a non-canonical representation. + suggest: Case-insensitive prefix of natural key or value of + `identity.Names` attribute. Excludes parameter `key` and can be used + with `entity_type` parameter. + `suggest` length must greater than or equals to 2. sections: Sections to be aggregated. forecast_at: Point of time to aggregate sections at. cursor: Page cursor. @@ -268,6 +278,8 @@ def aggregate( params["keyType"] = key_type.value if key is not None: params["key"] = key + if suggest is not None: + params["suggest"] = suggest if sections is not None: params["section"] = [section.value for section in sections] if forecast_at is not None: @@ -648,6 +660,7 @@ async def aggregate( entity_type: Optional[EntityTypes] = None, key_type: Optional[EntityKeyTypes] = None, key: Optional[str] = None, + suggest: Optional[str] = None, sections: Optional[Iterable[EntityAggregateSections]] = None, forecast_at: Optional[datetime] = None, cursor: Optional[Cursor] = None, @@ -658,6 +671,9 @@ async def aggregate( .. versionchanged:: 2.11 Added new parameter `dict_item_uuid`. + .. versionchanged:: 2.13 + Added new parameter `suggest`. + Note: Calls `GET /observable/entities`. @@ -665,20 +681,26 @@ async def aggregate( should be specified else Cybsi API will return error. Args: entity_uuids: Entity uuids. - Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`. + Excludes parameters: `dict_item_uuid`, `entity_type`, `key_type`, `key`, + `suggest`. dict_item_uuid: Dictionary item which is attributed to the entity. - Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`. + Excludes parameters: `entity_uuids`, `entity_type`, `key_type`, `key`, + `suggest`. entity_type: Entity type. Excludes parameter `entity_uuids`, `dict_item_uuid` and requires parameter `key`. The parameter is not required if the `entity_type` can be uniquely determined by `key_type`. key_type: Entity natural key type. - Excludes parameter `entity_uuids`, `dict_item_uuid` and + Excludes parameter `entity_uuids`, `dict_item_uuid`, `suggest` and requires parameter `key`. The parameter is not required if only one `key_type` is used for the specified `entity_type`. - key: Entity natural key value. Required if `entity_type` or `key_type` - parameter is specified. + key: Entity natural key value. Excludes parameter `suggest` and required + if `entity_type` or `key_type` parameter is specified. It is possible to pass a key value in a non-canonical representation. + suggest: Case-insensitive prefix of natural key or value of + `identity.Names` attribute. Excludes parameter `key` and can be used + with `entity_type` parameter. + `suggest` length must greater than or equals to 2. sections: Sections to be aggregated. forecast_at: Point of time to aggregate sections at. cursor: Page cursor. @@ -702,6 +724,8 @@ async def aggregate( params["keyType"] = key_type.value if key is not None: params["key"] = key + if suggest is not None: + params["suggest"] = suggest if sections is not None: params["section"] = [section.value for section in sections] if forecast_at is not None: