Skip to content

Commit a973b3a

Browse files
authored
Merge pull request #894 from simvue-io/hotfix/fix-extra-object-args
Remove extra arguments from object creation
2 parents 5bbae4d + 3b85324 commit a973b3a

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

simvue/api/objects/alert/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ def __init__(self, identifier: str | None = None, **kwargs) -> None:
3131
"""Retrieve an alert from the Simvue server by identifier"""
3232
self._label = "alert"
3333
super().__init__(identifier=identifier, **kwargs)
34-
self._local_only_args = ["frequency", "pattern", "aggregation"]
34+
self._local_only_args = [
35+
"frequency",
36+
"pattern",
37+
"aggregation",
38+
"status",
39+
]
3540

3641
def compare(self, other: "AlertBase") -> bool:
3742
"""Compare this alert to another"""

simvue/api/objects/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def __init__(
201201
# For simvue object initialisation, unlike the server there is no nested
202202
# arguments, however this means that there are extra keys during post which
203203
# need removing, this attribute handles that and should be set in subclasses.
204-
self._local_only_args: list[str] = []
204+
self._local_only_args: list[str] = ["created"]
205205

206206
self._identifier: str | None = (
207207
identifier if identifier is not None else f"offline_{uuid.uuid1()}"
@@ -636,13 +636,13 @@ def _post_batch(
636636
def _post_single(
637637
self, *, is_json: bool = True, data: list | dict | None = None, **kwargs
638638
) -> dict[str, typing.Any] | list[dict[str, typing.Any]]:
639-
if not is_json:
640-
kwargs = msgpack.packb(data or kwargs, use_bin_type=True)
641-
642639
# Remove any extra keys
643640
for key in self._local_only_args:
644641
_ = (data or kwargs).pop(key, None)
645642

643+
if not is_json:
644+
kwargs = msgpack.packb(data or kwargs, use_bin_type=True)
645+
646646
_response = sv_post(
647647
url=f"{self._base_url}",
648648
headers=self._headers | {"Content-Type": "application/msgpack"},

simvue/api/objects/storage/s3.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ def __init__(self, identifier: str | None = None, **kwargs) -> None:
2727
"""Initialise an S3Storage instance attaching a configuration"""
2828
self.config = Config(self)
2929
super().__init__(identifier, **kwargs)
30+
self._local_only_args: list[str] = [
31+
"endpoint_url",
32+
"region_name",
33+
"access_key_id",
34+
"secret_access_key",
35+
"bucket",
36+
]
3037

3138
@classmethod
3239
@pydantic.validate_call

0 commit comments

Comments
 (0)