Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated endpoint data VisionOne empty/optional fields #34

Merged
merged 1 commit into from
Oct 29, 2024
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
19 changes: 13 additions & 6 deletions src/pytmv1/model/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pydantic import BaseModel as PydanticBaseModel
from pydantic import ConfigDict, Field
from pydantic import RootModel as PydanticRootModel
from pydantic import model_validator
from pydantic import field_validator, model_validator
from pydantic.alias_generators import to_camel

from .enum import (
Expand Down Expand Up @@ -131,17 +131,24 @@ class Endpoint(BaseConsumable):
endpoint_name: Value
mac_address: ValueList
ip: ValueList
os_name: OperatingSystem
os_version: str
os_description: str
product_code: ProductCode
installed_product_codes: List[ProductCode]
os_name: Optional[OperatingSystem] = None
os_version: Optional[str] = None
os_description: Optional[str] = None
product_code: Optional[ProductCode] = None
installed_product_codes: List[ProductCode] = Field(default=[])
componentUpdatePolicy: Optional[str] = None
componentUpdateStatus: Optional[str] = None
componentVersion: Optional[str] = None
policyName: Optional[str] = None
protectionManager: Optional[str] = None

@field_validator("os_name", "product_code", mode="before")
@classmethod
def allow_empty_enum_string(cls, value: Any) -> Union[Any, None]:
if value == "":
return None
return value


class EmailActivity(BaseConsumable):
mail_msg_subject: Optional[str] = None
Expand Down
1 change: 0 additions & 1 deletion src/pytmv1/model/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ class ProductCode(str, Enum):
SAO = "sao"
SDS = "sds"
XES = "xes"
NOT_FOUND = ""


class Provenance(str, Enum):
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ def test_list_endpoint_data(client):
assert result.response.items[0].componentUpdatePolicy == "N-2"
assert result.response.items[0].componentUpdateStatus == "pause"
assert result.response.items[0].componentVersion == "outdatedVersion"


def test_list_endpoint_data_optional_fields(client):
result = client.endpoint.list_data(endpointName="optional_fields")
assert result.result_code == ResultCode.SUCCESS
assert isinstance(result.response, ListEndpointDataResp)
assert len(result.response.items) > 0
assert not result.response.items[0].product_code
assert not result.response.items[0].os_name
assert not result.response.items[0].os_version
assert not result.response.items[0].os_description
Loading