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

Use bytes rather than text as to allow direct conversion to relevant data type later #262

Merged
merged 1 commit into from
Sep 22, 2023
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
2 changes: 1 addition & 1 deletion axis/vapix/models/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ApiRequest(ABC, Generic[ApiDataT]):
error_codes: dict[int, str] = field(init=False)

@abstractmethod
def process_raw(self, raw: str) -> ApiDataT:
def process_raw(self, raw: bytes) -> ApiDataT:
"""Process raw data."""


Expand Down
4 changes: 2 additions & 2 deletions axis/vapix/models/api_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __post_init__(self) -> None:
"method": "getApiList",
}

def process_raw(self, raw: str) -> ListApisT:
def process_raw(self, raw: bytes) -> ListApisT:
"""Prepare API description dictionary."""
data: ListApisResponseT = orjson.loads(raw)
apis = data.get("data", {}).get("apiList", [])
Expand Down Expand Up @@ -230,7 +230,7 @@ def __post_init__(self) -> None:
"method": "getSupportedVersions",
}

def process_raw(self, raw: str) -> list[str]:
def process_raw(self, raw: bytes) -> list[str]:
"""Process supported versions."""
data: GetSupportedVersionsResponseT = orjson.loads(raw)
return data.get("data", {}).get("apiVersions", [])
4 changes: 2 additions & 2 deletions axis/vapix/models/basic_device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __post_init__(self) -> None:
"method": "getAllProperties",
}

def process_raw(self, raw: str) -> GetAllPropertiesT:
def process_raw(self, raw: bytes) -> GetAllPropertiesT:
"""Prepare API description dictionary."""
data: GetAllPropertiesResponseT = orjson.loads(raw)
device_information = data.get("data", {}).get("propertyList", {})
Expand Down Expand Up @@ -166,7 +166,7 @@ def __post_init__(self) -> None:
"method": "getSupportedVersions",
}

def process_raw(self, raw: str) -> list[str]:
def process_raw(self, raw: bytes) -> list[str]:
"""Process supported versions."""
data: GetSupportedVersionsResponseT = orjson.loads(raw)
return data.get("data", {}).get("apiVersions", [])
38 changes: 19 additions & 19 deletions axis/vapix/models/light_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def __post_init__(self) -> None:
"method": "getLightInformation",
}

def process_raw(self, raw: str) -> dict[str, LightInformation]:
def process_raw(self, raw: bytes) -> dict[str, LightInformation]:
"""Prepare light information dictionary."""
data: GetLightInformationResponseT = orjson.loads(raw)
return LightInformation.from_list(data["data"]["items"])
Expand Down Expand Up @@ -316,7 +316,7 @@ def __post_init__(self) -> None:
"method": "getServiceCapabilities",
}

def process_raw(self, raw: str) -> ServiceCapabilities:
def process_raw(self, raw: bytes) -> ServiceCapabilities:
"""Prepare light information dictionary."""
data: GetServiceCapabilitiesResponseT = orjson.loads(raw)
return ServiceCapabilities.from_dict(data["data"])
Expand Down Expand Up @@ -345,7 +345,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand Down Expand Up @@ -417,7 +417,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> bool:
def process_raw(self, raw: bytes) -> bool:
"""If light is on or off."""
data: GetLightStatusResponseT = orjson.loads(raw)
return data["data"]["status"]
Expand Down Expand Up @@ -448,7 +448,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id, "enabled": self.enabled},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand All @@ -475,7 +475,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> Range:
def process_raw(self, raw: bytes) -> Range:
"""If light is on or off."""
data: GetValidRangesResponseT = orjson.loads(raw)
return Range.from_dict(data["data"]["ranges"][0])
Expand Down Expand Up @@ -506,7 +506,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id, "intensity": self.intensity},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand All @@ -533,7 +533,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> int:
def process_raw(self, raw: bytes) -> int:
"""If light is on or off."""
data: GetIntensityResponseT = orjson.loads(raw)
return data["data"]["intensity"]
Expand Down Expand Up @@ -570,7 +570,7 @@ def __post_init__(self) -> None:
},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand Down Expand Up @@ -599,7 +599,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id, "LEDID": self.led_id},
}

def process_raw(self, raw: str) -> int:
def process_raw(self, raw: bytes) -> int:
"""Process light intensity."""
data: GetIntensityResponseT = orjson.loads(raw)
return data["data"]["intensity"]
Expand Down Expand Up @@ -628,7 +628,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> int:
def process_raw(self, raw: bytes) -> int:
"""If light is on or off."""
data: GetIntensityResponseT = orjson.loads(raw)
return data["data"]["intensity"]
Expand Down Expand Up @@ -659,7 +659,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id, "enabled": self.enabled},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand All @@ -686,7 +686,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> list[Range]:
def process_raw(self, raw: bytes) -> list[Range]:
"""If light is on or off."""
data: GetValidRangesResponseT = orjson.loads(raw)
return Range.from_list(data["data"]["ranges"])
Expand Down Expand Up @@ -720,7 +720,7 @@ def __post_init__(self) -> None:
},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand All @@ -747,7 +747,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> int:
def process_raw(self, raw: bytes) -> int:
"""Angle of illumination."""
data: GetAngleOfIlluminationResponseT = orjson.loads(raw)
return data["data"]["angleOfIllumination"]
Expand Down Expand Up @@ -776,7 +776,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> int:
def process_raw(self, raw: bytes) -> int:
"""Angle of illumination."""
data: GetAngleOfIlluminationResponseT = orjson.loads(raw)
return data["data"]["angleOfIllumination"]
Expand Down Expand Up @@ -807,7 +807,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id, "enabled": self.enabled},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No return data to process."""


Expand All @@ -834,7 +834,7 @@ def __post_init__(self) -> None:
"params": {"lightID": self.light_id},
}

def process_raw(self, raw: str) -> bool:
def process_raw(self, raw: bytes) -> bool:
"""If light is on or off."""
data: GetLightSynchronizationDayNightModeResponseT = orjson.loads(raw)
return data["data"]["synchronize"]
Expand All @@ -858,7 +858,7 @@ def __post_init__(self) -> None:
"method": "getSupportedVersions",
}

def process_raw(self, raw: str) -> list[str]:
def process_raw(self, raw: bytes) -> list[str]:
"""Process supported versions."""
data: GetSupportedVersionsResponseT = orjson.loads(raw)
return data.get("data", {}).get("apiVersions", [])
10 changes: 5 additions & 5 deletions axis/vapix/models/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def __post_init__(self) -> None:
"params": self.client_config.to_dict(),
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""Prepare view area dictionary."""


Expand All @@ -421,7 +421,7 @@ def __post_init__(self) -> None:
"method": "activateClient",
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""Prepare view area dictionary."""


Expand Down Expand Up @@ -458,7 +458,7 @@ def __post_init__(self) -> None:
"method": "getClientStatus",
}

def process_raw(self, raw: str) -> ClientConfigStatus:
def process_raw(self, raw: bytes) -> ClientConfigStatus:
"""Prepare view area dictionary."""
data: GetClientStatusResponseT = orjson.loads(raw)
return ClientConfigStatus.from_dict(data["data"])
Expand All @@ -484,7 +484,7 @@ def __post_init__(self) -> None:
"method": "getEventPublicationConfig",
}

def process_raw(self, raw: str) -> EventPublicationConfig:
def process_raw(self, raw: bytes) -> EventPublicationConfig:
"""Prepare view area dictionary."""
data: GetEventPublicationConfigResponseT = orjson.loads(raw)
return EventPublicationConfig.from_dict(data["data"]["eventPublicationConfig"])
Expand Down Expand Up @@ -513,5 +513,5 @@ def __post_init__(self) -> None:
"params": self.config.to_dict(),
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""Prepare view area dictionary."""
8 changes: 4 additions & 4 deletions axis/vapix/models/pir_sensor_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __post_init__(self) -> None:
"method": "listSensors",
}

def process_raw(self, raw: str) -> ListSensorsT:
def process_raw(self, raw: bytes) -> ListSensorsT:
"""Prepare Pir sensor configuration dictionary."""
data: ListSensorsResponseT = orjson.loads(raw)
sensors = data.get("data", {}).get("sensors", [])
Expand Down Expand Up @@ -169,7 +169,7 @@ def __post_init__(self) -> None:
},
}

def process_raw(self, raw: str) -> float | None:
def process_raw(self, raw: bytes) -> float | None:
"""Prepare sensitivity value."""
data: GetSensitivityResponseT = orjson.loads(raw)
return data.get("data", {}).get("sensitivity")
Expand Down Expand Up @@ -201,7 +201,7 @@ def __post_init__(self) -> None:
},
}

def process_raw(self, raw: str) -> None:
def process_raw(self, raw: bytes) -> None:
"""No expected data in response."""
return None

Expand All @@ -224,7 +224,7 @@ def __post_init__(self) -> None:
"method": "getSupportedVersions",
}

def process_raw(self, raw: str) -> list[str]:
def process_raw(self, raw: bytes) -> list[str]:
"""Process supported versions."""
data: GetSupportedVersionsResponseT = orjson.loads(raw)
return data.get("data", {}).get("apiVersions", [])
4 changes: 2 additions & 2 deletions axis/vapix/models/stream_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __post_init__(self) -> None:
"params": {"streamProfileName": profile_list},
}

def process_raw(self, raw: str) -> ListStreamProfilesT:
def process_raw(self, raw: bytes) -> ListStreamProfilesT:
"""Prepare API description dictionary."""
data: ListStreamProfilesResponseT = orjson.loads(raw)
stream_profiles = data.get("data", {}).get("streamProfile", [])
Expand Down Expand Up @@ -140,7 +140,7 @@ def __post_init__(self) -> None:
"method": "getSupportedVersions",
}

def process_raw(self, raw: str) -> list[str]:
def process_raw(self, raw: bytes) -> list[str]:
"""Process supported versions."""
data: GetSupportedVersionsResponseT = orjson.loads(raw)
return data.get("data", {}).get("apiVersions", [])
4 changes: 2 additions & 2 deletions axis/vapix/models/view_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __post_init__(self) -> None:
"method": "list",
}

def process_raw(self, raw: str) -> ListViewAreasT:
def process_raw(self, raw: bytes) -> ListViewAreasT:
"""Prepare view area dictionary."""
data: ListViewAreasResponseT = orjson.loads(raw)
items = data.get("data", {}).get("viewAreas", [])
Expand Down Expand Up @@ -264,7 +264,7 @@ def __post_init__(self) -> None:
"method": "getSupportedVersions",
}

def process_raw(self, raw: str) -> list[str]:
def process_raw(self, raw: bytes) -> list[str]:
"""Process supported versions."""
data: GetSupportedVersionsResponseT = orjson.loads(raw)
return data.get("data", {}).get("apiVersions", [])
Expand Down
Loading