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
4 changes: 3 additions & 1 deletion scaleway-core/scaleway_core/bridge/decimal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from decimal import Decimal
from typing import Any, Dict

from scaleway_core.profile import ProfileDefaults


def unmarshal_Decimal(data: Any) -> Decimal:
"""
Expand All @@ -19,7 +21,7 @@ def unmarshal_Decimal(data: Any) -> Decimal:
return Decimal(data["value"])


def marshal_Decimal(data: Decimal) -> Dict[str, Any]:
def marshal_Decimal(data: Decimal, _defaults: ProfileDefaults | None) -> Dict[str, Any]:
"""
Marshal an instance of Decimal into google.protobuf.Decimal JSON representation.
"""
Expand Down
4 changes: 3 additions & 1 deletion scaleway-core/scaleway_core/bridge/money.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from dataclasses import dataclass
from typing import Any, Dict

from scaleway_core.profile import ProfileDefaults


@dataclass
class Money:
Expand Down Expand Up @@ -48,7 +50,7 @@ def unmarshal_Money(data: Any) -> Money:
)


def marshal_Money(data: Money) -> Dict[str, Any]:
def marshal_Money(data: Money, _defaults: ProfileDefaults | None) -> Dict[str, Any]:
"""
Marshal an instance of Money into a JSON compatible data structure.
"""
Expand Down
4 changes: 3 additions & 1 deletion scaleway-core/scaleway_core/bridge/scwfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from dataclasses import dataclass
from typing import Any, Dict

from scaleway_core.profile import ProfileDefaults


@dataclass
class ScwFile:
Expand Down Expand Up @@ -40,7 +42,7 @@ def unmarshal_ScwFile(data: Any) -> ScwFile:
)


def marshal_ScwFile(obj: ScwFile) -> Dict[str, Any]:
def marshal_ScwFile(obj: ScwFile, _defaults: ProfileDefaults | None) -> Dict[str, Any]:
"""
Marshals a ScwFile object into a dict.
"""
Expand Down
6 changes: 5 additions & 1 deletion scaleway-core/scaleway_core/bridge/serviceinfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from dataclasses import dataclass
from typing import Any, Dict, Optional

from scaleway_core.profile import ProfileDefaults


@dataclass
class ServiceInfo:
Expand Down Expand Up @@ -48,7 +50,9 @@ def unmarshal_ServiceInfo(data: Any) -> ServiceInfo:
)


def marshal_ServiceInfo(obj: ServiceInfo) -> Dict[str, Any]:
def marshal_ServiceInfo(
obj: ServiceInfo, _defaults: ProfileDefaults | None
) -> Dict[str, Any]:
"""
Marshals a ServiceInfo object into a dict.
"""
Expand Down
12 changes: 9 additions & 3 deletions scaleway-core/scaleway_core/bridge/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from typing import Any, Dict, List
from dateutil import parser

from scaleway_core.profile import ProfileDefaults


@dataclass
class TimeSeriesPoint:
Expand Down Expand Up @@ -36,7 +38,9 @@ def unmarshal_TimeSeriesPoint(data: Any) -> TimeSeriesPoint:
)


def marshal_TimeSeriesPoint(data: TimeSeriesPoint) -> Dict[str, Any]:
def marshal_TimeSeriesPoint(
data: TimeSeriesPoint, _defaults: ProfileDefaults | None
) -> Dict[str, Any]:
"""
Marshal an instance of TimeSeriesPoint into a JSON compatible data structure.
"""
Expand Down Expand Up @@ -84,12 +88,14 @@ def unmarshal_TimeSeries(data: Any) -> TimeSeries:
)


def marshal_TimeSeries(data: TimeSeries) -> Dict[str, Any]:
def marshal_TimeSeries(
data: TimeSeries, defaults: ProfileDefaults | None
) -> Dict[str, Any]:
"""
Marshal an instance of TimeSeries into a JSON compatible data structure.
"""
return {
"name": data.name,
"points": [marshal_TimeSeriesPoint(point) for point in data.points],
"points": [marshal_TimeSeriesPoint(point, defaults) for point in data.points],
"metadata": data.metadata,
}
2 changes: 1 addition & 1 deletion scaleway-core/tests/test_bridge_marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestBridgeMarshal(unittest.TestCase):
def test_decimal_marshal(self):
decimal = Decimal("1.2")
self.assertEqual(marshal_Decimal(decimal), {"value": "1.2"})
self.assertEqual(marshal_Decimal(decimal, None), {"value": "1.2"})

def test_decimal_unmarshal(self):
decimal = Decimal("1.2")
Expand Down