Skip to content

Commit

Permalink
Merge pull request #34 from cyberstudio/update-api
Browse files Browse the repository at this point in the history
Update api
  • Loading branch information
slowaner authored Aug 5, 2024
2 parents 2916df2 + 099503d commit 0a2fcab
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---------------------
Expand Down
10 changes: 8 additions & 2 deletions cybsi/api/data_source/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
44 changes: 34 additions & 10 deletions cybsi/api/observable/entities_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -188,27 +189,36 @@ def aggregate(
.. versionchanged:: 2.11
Added new parameter `dict_item_uuid`.
.. versionchanged:: 2.13
Added new parameter `suggest`.
Note:
Calls `GET /observable/entities`.
To get entity aggregate, only one of [key, entity_uuids] parameters
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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -658,27 +671,36 @@ async def aggregate(
.. versionchanged:: 2.11
Added new parameter `dict_item_uuid`.
.. versionchanged:: 2.13
Added new parameter `suggest`.
Note:
Calls `GET /observable/entities`.
To get entity aggregate, only one of [key, entity_uuids] parameters
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.
Expand All @@ -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:
Expand Down

0 comments on commit 0a2fcab

Please sign in to comment.