Skip to content

Commit

Permalink
Merge branch 'releases/0.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mz06 committed Nov 7, 2024
2 parents dc7ba00 + 31bc249 commit 9d47322
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/pytmv1/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0"
__version__ = "0.9.1"
10 changes: 5 additions & 5 deletions src/pytmv1/model/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ class Endpoint(BaseConsumable):
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
component_update_policy: Optional[str] = None
component_update_status: Optional[str] = None
component_version: Optional[str] = None
policy_name: Optional[str] = None
protection_manager: Optional[str] = None

@field_validator("os_name", "product_code", mode="before")
@classmethod
Expand Down
40 changes: 15 additions & 25 deletions src/pytmv1/model/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Dict, Generic, List, Optional, TypeVar, Union

from pydantic import Field, model_validator
from pydantic import Field, field_validator, model_validator

from .common import (
Account,
Expand Down Expand Up @@ -88,27 +88,21 @@ class AccountTaskResp(BaseTaskResp):


class AddAlertNoteResp(BaseResponse):
note_id: str
note_id: str = Field(validation_alias="Location")

@model_validator(mode="before")
@field_validator("note_id", mode="before")
@classmethod
def map_data(
cls, data: Dict[str, Optional[str]]
) -> Dict[str, Optional[str]]:
data["note_id"] = _get_id(data)
return data
def get_id(cls, value: str) -> str:
return _get_id(value)


class AddCustomScriptResp(BaseResponse):
script_id: str
script_id: str = Field(validation_alias="Location")

@model_validator(mode="before")
@field_validator("script_id", mode="before")
@classmethod
def map_data(
cls, data: Dict[str, Optional[str]]
) -> Dict[str, Optional[str]]:
data["script_id"] = _get_id(data)
return data
def get_id(cls, value: str) -> str:
return _get_id(value)


class BlockListTaskResp(BaseTaskResp):
Expand Down Expand Up @@ -263,15 +257,12 @@ class CustomScriptTaskResp(BaseTaskResp):


class OatPipelineResp(BaseResponse):
pipeline_id: str
pipeline_id: str = Field(validation_alias="Location")

@model_validator(mode="before")
@field_validator("pipeline_id", mode="before")
@classmethod
def map_data(
cls, data: Dict[str, Optional[str]]
) -> Dict[str, Optional[str]]:
data["pipeline_id"] = _get_id(data)
return data
def get_id(cls, value: str) -> str:
return _get_id(value)


class SubmitFileToSandboxResp(BaseResponse):
Expand Down Expand Up @@ -320,6 +311,5 @@ class TextResp(BaseResponse):
text: str


def _get_id(data: Dict[str, Optional[str]]) -> Optional[str]:
location = data.get("Location")
return location.split("/")[-1] if location else None
def _get_id(location: str) -> str:
return location.split("/")[-1]
6 changes: 3 additions & 3 deletions tests/integration/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def test_list_endpoint_data(client):
assert result.result_code == ResultCode.SUCCESS
assert isinstance(result.response, ListEndpointDataResp)
assert len(result.response.items) > 0
assert result.response.items[0].componentUpdatePolicy == "N-2"
assert result.response.items[0].componentUpdateStatus == "pause"
assert result.response.items[0].componentVersion == "outdatedVersion"
assert result.response.items[0].component_update_policy == "N-2"
assert result.response.items[0].component_update_status == "pause"
assert result.response.items[0].component_version == "outdatedVersion"


def test_list_endpoint_data_optional_fields(client):
Expand Down

0 comments on commit 9d47322

Please sign in to comment.