Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions armis_sdk/core/base_entity.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from typing import TypeVar

from pydantic import alias_generators
from pydantic import BaseModel
from pydantic import ConfigDict


class BaseEntity(BaseModel):
model_config = ConfigDict(
alias_generator=alias_generators.to_camel,
populate_by_name=True,
serialize_by_alias=True,
strict=True,
)

Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "armis_sdk"
version = "1.2.2"
version = "1.2.3"
description = "The Armis SDK is a package that encapsulates common use-cases for interacting with the Armis platform."
authors = [
{ name = "Shai Lachmanovich", email = "[email protected]" },
Expand All @@ -20,7 +20,7 @@ plugins = ['pydantic.mypy']
eval_type_backport = "*"
pandas = "*"
pyarrow = "*"
pydantic = "*"
pydantic = ">=2.11"
httpx = "*"
httpx-retries = "*"
universalasync = "*"
Expand Down
28 changes: 25 additions & 3 deletions tests/armis_sdk/clients/sites_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def test_create(httpx_mock: pytest_httpx.HTTPXMock):
"parent_id": 2,
"network_equipment_device_ids": [1, 2, 3],
"integration_ids": [4, 5, 6],
"asq_rule": {"or": ["asq1", "asq2"]},
},
json={
"id": "1",
Expand All @@ -28,6 +29,7 @@ async def test_create(httpx_mock: pytest_httpx.HTTPXMock):
"parent_id": 2,
"network_equipment_device_ids": [1, 2, 3],
"integration_ids": [4, 5, 6],
"asq_rule": {"or": ["asq1", "asq2"]},
},
)

Expand All @@ -37,6 +39,7 @@ async def test_create(httpx_mock: pytest_httpx.HTTPXMock):
parent_id=2,
network_equipment_device_ids=[1, 2, 3],
integration_ids=[4, 5, 6],
asq_rule=AsqRule(or_=["asq1", "asq2"]),
)

sites_client = SitesClient()
Expand All @@ -49,6 +52,7 @@ async def test_create(httpx_mock: pytest_httpx.HTTPXMock):
parent_id=2,
network_equipment_device_ids=[1, 2, 3],
integration_ids=[4, 5, 6],
asq_rule=AsqRule(or_=["asq1", "asq2"]),
)


Expand Down Expand Up @@ -294,20 +298,38 @@ async def test_update_simple_properties(httpx_mock: pytest_httpx.HTTPXMock):
httpx_mock.add_response(
url="https://api.armis.com/v3/settings/sites/1",
method="PATCH",
match_json={"name": "new_name", "location": "new location", "parent_id": 2},
match_json={
"name": "new_name",
"location": "new location",
"parent_id": 2,
"asq_rule": {"or": ["asq1", "asq2"]},
},
json={
"id": 1,
"name": "new_name",
"location": "new location",
"parent_id": 2,
"asq_rule": {"or": ["asq1", "asq2"]},
},
)

sites_client = SitesClient()
site = Site(id=1, name="new_name", location="new location", parent_id=2)
site = Site(
id=1,
name="new_name",
location="new location",
parent_id=2,
asq_rule=AsqRule(or_=["asq1", "asq2"]),
)

updated_site = await sites_client.update(site)
assert updated_site == Site(id=1, name="new_name", location="new location", parent_id=2)
assert updated_site == Site(
id=1,
name="new_name",
location="new location",
parent_id=2,
asq_rule=AsqRule(or_=["asq1", "asq2"]),
)


async def test_update_without_id(httpx_mock: pytest_httpx.HTTPXMock):
Expand Down
5 changes: 2 additions & 3 deletions tests/armis_sdk/entities/device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ def test_device_model_json_schema_includes_datetime_fields():
"""datetime.datetime fields must appear in the JSON schema (regression: TYPE_CHECKING import drops them)."""
schema = Device.model_json_schema()
props = schema.get("properties", {})
# Fields use camelCase aliases per BaseEntity's alias_generator
assert "firstSeen" in props, f"firstSeen missing from schema properties: {sorted(props.keys())}"
assert "lastSeen" in props, f"lastSeen missing from schema properties: {sorted(props.keys())}"
assert "first_seen" in props, f"first_seen missing from schema properties: {sorted(props.keys())}"
assert "last_seen" in props, f"last_seen missing from schema properties: {sorted(props.keys())}"
Loading