stackit-cost 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/PKG-INFO +1 -1
  2. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/pyproject.toml +1 -1
  3. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/api_client.py +15 -17
  4. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/auth_error_response.py +4 -3
  5. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/detailed_service_cost.py +4 -3
  6. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/error_response.py +4 -3
  7. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/project_cost_with_detailed_services.py +4 -3
  8. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/project_cost_with_reports.py +4 -3
  9. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/project_cost_with_summarized_services.py +4 -3
  10. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/report_data.py +4 -3
  11. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/report_data_time_period.py +4 -3
  12. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/summarized_project_cost.py +4 -3
  13. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/summarized_service_cost.py +4 -3
  14. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/.gitignore +0 -0
  15. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/README.md +0 -0
  16. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/__init__.py +0 -0
  17. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/api/__init__.py +0 -0
  18. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/api/default_api.py +0 -0
  19. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/api_response.py +0 -0
  20. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/configuration.py +0 -0
  21. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/exceptions.py +0 -0
  22. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/__init__.py +0 -0
  23. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/models/project_cost.py +0 -0
  24. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/py.typed +0 -0
  25. {stackit_cost-0.1.0 → stackit_cost-0.2.0}/src/stackit/cost/rest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stackit-cost
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: STACKIT Cost API
5
5
  Project-URL: Homepage, https://github.com/stackitcloud/stackit-sdk-python
6
6
  Project-URL: Issues, https://github.com/stackitcloud/stackit-sdk-python/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "stackit-cost"
3
- version = "v0.1.0"
3
+ version = "v0.2.0"
4
4
  description = "STACKIT Cost API"
5
5
  authors = [{name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud"}]
6
6
  requires-python = ">=3.9,<4.0"
@@ -66,6 +66,7 @@ class ApiClient:
66
66
  "date": datetime.date,
67
67
  "datetime": datetime.datetime,
68
68
  "decimal": decimal.Decimal,
69
+ "UUID": uuid.UUID,
69
70
  "object": object,
70
71
  }
71
72
  _pool = None
@@ -265,7 +266,7 @@ class ApiClient:
265
266
  response_text = None
266
267
  return_data = None
267
268
  try:
268
- if response_type == "bytearray":
269
+ if response_type in ("bytearray", "bytes"):
269
270
  return_data = response_data.data
270
271
  elif response_type == "file":
271
272
  return_data = self.__deserialize_file(response_data)
@@ -326,25 +327,20 @@ class ApiClient:
326
327
  return obj.isoformat()
327
328
  elif isinstance(obj, decimal.Decimal):
328
329
  return str(obj)
329
-
330
330
  elif isinstance(obj, dict):
331
- obj_dict = obj
331
+ return {key: self.sanitize_for_serialization(val) for key, val in obj.items()}
332
+
333
+ # Convert model obj to dict except
334
+ # attributes `openapi_types`, `attribute_map`
335
+ # and attributes which value is not None.
336
+ # Convert attribute name to json key in
337
+ # model definition for request.
338
+ if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
339
+ obj_dict = obj.to_dict()
332
340
  else:
333
- # Convert model obj to dict except
334
- # attributes `openapi_types`, `attribute_map`
335
- # and attributes which value is not None.
336
- # Convert attribute name to json key in
337
- # model definition for request.
338
- if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
339
- obj_dict = obj.to_dict()
340
- else:
341
- obj_dict = obj.__dict__
342
-
343
- if isinstance(obj_dict, list):
344
- # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501
345
- return self.sanitize_for_serialization(obj_dict)
341
+ obj_dict = obj.__dict__
346
342
 
347
- return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
343
+ return self.sanitize_for_serialization(obj_dict)
348
344
 
349
345
  def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
350
346
  """Deserializes response into an object.
@@ -417,6 +413,8 @@ class ApiClient:
417
413
  return self.__deserialize_datetime(data)
418
414
  elif klass is decimal.Decimal:
419
415
  return decimal.Decimal(data)
416
+ elif klass is uuid.UUID:
417
+ return uuid.UUID(data)
420
418
  elif issubclass(klass, Enum):
421
419
  return self.__deserialize_enum(data, klass)
422
420
  else:
@@ -20,6 +20,7 @@ from datetime import datetime
20
20
  from typing import Any, ClassVar, Dict, List, Optional, Set
21
21
 
22
22
  from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
23
+ from pydantic_core import to_jsonable_python
23
24
  from typing_extensions import Self
24
25
 
25
26
 
@@ -49,7 +50,8 @@ class AuthErrorResponse(BaseModel):
49
50
  return value
50
51
 
51
52
  model_config = ConfigDict(
52
- populate_by_name=True,
53
+ validate_by_name=True,
54
+ validate_by_alias=True,
53
55
  validate_assignment=True,
54
56
  protected_namespaces=(),
55
57
  )
@@ -60,8 +62,7 @@ class AuthErrorResponse(BaseModel):
60
62
 
61
63
  def to_json(self) -> str:
62
64
  """Returns the JSON representation of the model using alias"""
63
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
64
- return json.dumps(self.to_dict())
65
+ return json.dumps(to_jsonable_python(self.to_dict()))
65
66
 
66
67
  @classmethod
67
68
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -24,6 +24,7 @@ from pydantic import (
24
24
  StrictFloat,
25
25
  StrictInt,
26
26
  )
27
+ from pydantic_core import to_jsonable_python
27
28
  from typing_extensions import Annotated, Self
28
29
 
29
30
  from stackit.cost.models.report_data import ReportData
@@ -70,7 +71,8 @@ class DetailedServiceCost(BaseModel):
70
71
  ]
71
72
 
72
73
  model_config = ConfigDict(
73
- populate_by_name=True,
74
+ validate_by_name=True,
75
+ validate_by_alias=True,
74
76
  validate_assignment=True,
75
77
  protected_namespaces=(),
76
78
  )
@@ -81,8 +83,7 @@ class DetailedServiceCost(BaseModel):
81
83
 
82
84
  def to_json(self) -> str:
83
85
  """Returns the JSON representation of the model using alias"""
84
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
85
- return json.dumps(self.to_dict())
86
+ return json.dumps(to_jsonable_python(self.to_dict()))
86
87
 
87
88
  @classmethod
88
89
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -18,6 +18,7 @@ import pprint
18
18
  from typing import Any, ClassVar, Dict, List, Optional, Set
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from pydantic_core import to_jsonable_python
21
22
  from typing_extensions import Self
22
23
 
23
24
 
@@ -30,7 +31,8 @@ class ErrorResponse(BaseModel):
30
31
  __properties: ClassVar[List[str]] = ["msg"]
31
32
 
32
33
  model_config = ConfigDict(
33
- populate_by_name=True,
34
+ validate_by_name=True,
35
+ validate_by_alias=True,
34
36
  validate_assignment=True,
35
37
  protected_namespaces=(),
36
38
  )
@@ -41,8 +43,7 @@ class ErrorResponse(BaseModel):
41
43
 
42
44
  def to_json(self) -> str:
43
45
  """Returns the JSON representation of the model using alias"""
44
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
- return json.dumps(self.to_dict())
46
+ return json.dumps(to_jsonable_python(self.to_dict()))
46
47
 
47
48
  @classmethod
48
49
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -26,6 +26,7 @@ from pydantic import (
26
26
  StrictInt,
27
27
  StrictStr,
28
28
  )
29
+ from pydantic_core import to_jsonable_python
29
30
  from typing_extensions import Self
30
31
 
31
32
  from stackit.cost.models.detailed_service_cost import DetailedServiceCost
@@ -61,7 +62,8 @@ class ProjectCostWithDetailedServices(BaseModel):
61
62
  ]
62
63
 
63
64
  model_config = ConfigDict(
64
- populate_by_name=True,
65
+ validate_by_name=True,
66
+ validate_by_alias=True,
65
67
  validate_assignment=True,
66
68
  protected_namespaces=(),
67
69
  )
@@ -72,8 +74,7 @@ class ProjectCostWithDetailedServices(BaseModel):
72
74
 
73
75
  def to_json(self) -> str:
74
76
  """Returns the JSON representation of the model using alias"""
75
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
76
- return json.dumps(self.to_dict())
77
+ return json.dumps(to_jsonable_python(self.to_dict()))
77
78
 
78
79
  @classmethod
79
80
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -26,6 +26,7 @@ from pydantic import (
26
26
  StrictInt,
27
27
  StrictStr,
28
28
  )
29
+ from pydantic_core import to_jsonable_python
29
30
  from typing_extensions import Self
30
31
 
31
32
  from stackit.cost.models.report_data import ReportData
@@ -62,7 +63,8 @@ class ProjectCostWithReports(BaseModel):
62
63
  ]
63
64
 
64
65
  model_config = ConfigDict(
65
- populate_by_name=True,
66
+ validate_by_name=True,
67
+ validate_by_alias=True,
66
68
  validate_assignment=True,
67
69
  protected_namespaces=(),
68
70
  )
@@ -73,8 +75,7 @@ class ProjectCostWithReports(BaseModel):
73
75
 
74
76
  def to_json(self) -> str:
75
77
  """Returns the JSON representation of the model using alias"""
76
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
77
- return json.dumps(self.to_dict())
78
+ return json.dumps(to_jsonable_python(self.to_dict()))
78
79
 
79
80
  @classmethod
80
81
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -26,6 +26,7 @@ from pydantic import (
26
26
  StrictInt,
27
27
  StrictStr,
28
28
  )
29
+ from pydantic_core import to_jsonable_python
29
30
  from typing_extensions import Self
30
31
 
31
32
  from stackit.cost.models.summarized_service_cost import SummarizedServiceCost
@@ -58,7 +59,8 @@ class ProjectCostWithSummarizedServices(BaseModel):
58
59
  ]
59
60
 
60
61
  model_config = ConfigDict(
61
- populate_by_name=True,
62
+ validate_by_name=True,
63
+ validate_by_alias=True,
62
64
  validate_assignment=True,
63
65
  protected_namespaces=(),
64
66
  )
@@ -69,8 +71,7 @@ class ProjectCostWithSummarizedServices(BaseModel):
69
71
 
70
72
  def to_json(self) -> str:
71
73
  """Returns the JSON representation of the model using alias"""
72
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
73
- return json.dumps(self.to_dict())
74
+ return json.dumps(to_jsonable_python(self.to_dict()))
74
75
 
75
76
  @classmethod
76
77
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -24,6 +24,7 @@ from pydantic import (
24
24
  StrictFloat,
25
25
  StrictInt,
26
26
  )
27
+ from pydantic_core import to_jsonable_python
27
28
  from typing_extensions import Self
28
29
 
29
30
  from stackit.cost.models.report_data_time_period import ReportDataTimePeriod
@@ -41,7 +42,8 @@ class ReportData(BaseModel):
41
42
  __properties: ClassVar[List[str]] = ["charge", "discount", "quantity", "timePeriod"]
42
43
 
43
44
  model_config = ConfigDict(
44
- populate_by_name=True,
45
+ validate_by_name=True,
46
+ validate_by_alias=True,
45
47
  validate_assignment=True,
46
48
  protected_namespaces=(),
47
49
  )
@@ -52,8 +54,7 @@ class ReportData(BaseModel):
52
54
 
53
55
  def to_json(self) -> str:
54
56
  """Returns the JSON representation of the model using alias"""
55
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
- return json.dumps(self.to_dict())
57
+ return json.dumps(to_jsonable_python(self.to_dict()))
57
58
 
58
59
  @classmethod
59
60
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -19,6 +19,7 @@ from datetime import date
19
19
  from typing import Any, ClassVar, Dict, List, Optional, Set
20
20
 
21
21
  from pydantic import BaseModel, ConfigDict
22
+ from pydantic_core import to_jsonable_python
22
23
  from typing_extensions import Self
23
24
 
24
25
 
@@ -32,7 +33,8 @@ class ReportDataTimePeriod(BaseModel):
32
33
  __properties: ClassVar[List[str]] = ["end", "start"]
33
34
 
34
35
  model_config = ConfigDict(
35
- populate_by_name=True,
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
36
38
  validate_assignment=True,
37
39
  protected_namespaces=(),
38
40
  )
@@ -43,8 +45,7 @@ class ReportDataTimePeriod(BaseModel):
43
45
 
44
46
  def to_json(self) -> str:
45
47
  """Returns the JSON representation of the model using alias"""
46
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
- return json.dumps(self.to_dict())
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
48
49
 
49
50
  @classmethod
50
51
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -26,6 +26,7 @@ from pydantic import (
26
26
  StrictInt,
27
27
  StrictStr,
28
28
  )
29
+ from pydantic_core import to_jsonable_python
29
30
  from typing_extensions import Self
30
31
 
31
32
 
@@ -54,7 +55,8 @@ class SummarizedProjectCost(BaseModel):
54
55
  ]
55
56
 
56
57
  model_config = ConfigDict(
57
- populate_by_name=True,
58
+ validate_by_name=True,
59
+ validate_by_alias=True,
58
60
  validate_assignment=True,
59
61
  protected_namespaces=(),
60
62
  )
@@ -65,8 +67,7 @@ class SummarizedProjectCost(BaseModel):
65
67
 
66
68
  def to_json(self) -> str:
67
69
  """Returns the JSON representation of the model using alias"""
68
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
69
- return json.dumps(self.to_dict())
70
+ return json.dumps(to_jsonable_python(self.to_dict()))
70
71
 
71
72
  @classmethod
72
73
  def from_json(cls, json_str: str) -> Optional[Self]:
@@ -26,6 +26,7 @@ from pydantic import (
26
26
  StrictInt,
27
27
  StrictStr,
28
28
  )
29
+ from pydantic_core import to_jsonable_python
29
30
  from typing_extensions import Self
30
31
 
31
32
 
@@ -54,7 +55,8 @@ class SummarizedServiceCost(BaseModel):
54
55
  ]
55
56
 
56
57
  model_config = ConfigDict(
57
- populate_by_name=True,
58
+ validate_by_name=True,
59
+ validate_by_alias=True,
58
60
  validate_assignment=True,
59
61
  protected_namespaces=(),
60
62
  )
@@ -65,8 +67,7 @@ class SummarizedServiceCost(BaseModel):
65
67
 
66
68
  def to_json(self) -> str:
67
69
  """Returns the JSON representation of the model using alias"""
68
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
69
- return json.dumps(self.to_dict())
70
+ return json.dumps(to_jsonable_python(self.to_dict()))
70
71
 
71
72
  @classmethod
72
73
  def from_json(cls, json_str: str) -> Optional[Self]:
File without changes
File without changes