stackit-cost 0.1.0__py3-none-any.whl
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.
- src/stackit/cost/__init__.py +85 -0
- src/stackit/cost/api/__init__.py +4 -0
- src/stackit/cost/api/default_api.py +1285 -0
- src/stackit/cost/api_client.py +652 -0
- src/stackit/cost/api_response.py +23 -0
- src/stackit/cost/configuration.py +163 -0
- src/stackit/cost/exceptions.py +217 -0
- src/stackit/cost/models/__init__.py +30 -0
- src/stackit/cost/models/auth_error_response.py +108 -0
- src/stackit/cost/models/detailed_service_cost.py +143 -0
- src/stackit/cost/models/error_response.py +81 -0
- src/stackit/cost/models/project_cost.py +203 -0
- src/stackit/cost/models/project_cost_with_detailed_services.py +132 -0
- src/stackit/cost/models/project_cost_with_reports.py +133 -0
- src/stackit/cost/models/project_cost_with_summarized_services.py +129 -0
- src/stackit/cost/models/report_data.py +104 -0
- src/stackit/cost/models/report_data_time_period.py +83 -0
- src/stackit/cost/models/summarized_project_cost.py +113 -0
- src/stackit/cost/models/summarized_service_cost.py +113 -0
- src/stackit/cost/py.typed +0 -0
- src/stackit/cost/rest.py +164 -0
- stackit_cost-0.1.0.dist-info/METADATA +46 -0
- stackit_cost-0.1.0.dist-info/RECORD +24 -0
- stackit_cost-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Cost API
|
|
5
|
+
|
|
6
|
+
The cost API provides detailed reports on the costs for a customer or project over a certain amount of time
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, StrictStr
|
|
21
|
+
from typing_extensions import Self
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ErrorResponse(BaseModel):
|
|
25
|
+
"""
|
|
26
|
+
ErrorResponse
|
|
27
|
+
""" # noqa: E501
|
|
28
|
+
|
|
29
|
+
msg: StrictStr
|
|
30
|
+
__properties: ClassVar[List[str]] = ["msg"]
|
|
31
|
+
|
|
32
|
+
model_config = ConfigDict(
|
|
33
|
+
populate_by_name=True,
|
|
34
|
+
validate_assignment=True,
|
|
35
|
+
protected_namespaces=(),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def to_str(self) -> str:
|
|
39
|
+
"""Returns the string representation of the model using alias"""
|
|
40
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
41
|
+
|
|
42
|
+
def to_json(self) -> str:
|
|
43
|
+
"""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
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
49
|
+
"""Create an instance of ErrorResponse from a JSON string"""
|
|
50
|
+
return cls.from_dict(json.loads(json_str))
|
|
51
|
+
|
|
52
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
53
|
+
"""Return the dictionary representation of the model using alias.
|
|
54
|
+
|
|
55
|
+
This has the following differences from calling pydantic's
|
|
56
|
+
`self.model_dump(by_alias=True)`:
|
|
57
|
+
|
|
58
|
+
* `None` is only added to the output dict for nullable fields that
|
|
59
|
+
were set at model initialization. Other fields with value `None`
|
|
60
|
+
are ignored.
|
|
61
|
+
"""
|
|
62
|
+
excluded_fields: Set[str] = set([])
|
|
63
|
+
|
|
64
|
+
_dict = self.model_dump(
|
|
65
|
+
by_alias=True,
|
|
66
|
+
exclude=excluded_fields,
|
|
67
|
+
exclude_none=True,
|
|
68
|
+
)
|
|
69
|
+
return _dict
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
73
|
+
"""Create an instance of ErrorResponse from a dict"""
|
|
74
|
+
if obj is None:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
if not isinstance(obj, dict):
|
|
78
|
+
return cls.model_validate(obj)
|
|
79
|
+
|
|
80
|
+
_obj = cls.model_validate({"msg": obj.get("msg")})
|
|
81
|
+
return _obj
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Cost API
|
|
5
|
+
|
|
6
|
+
The cost API provides detailed reports on the costs for a customer or project over a certain amount of time
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional, Set, Union
|
|
19
|
+
|
|
20
|
+
from pydantic import (
|
|
21
|
+
BaseModel,
|
|
22
|
+
ValidationError,
|
|
23
|
+
field_validator,
|
|
24
|
+
)
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
from stackit.cost.models.project_cost_with_detailed_services import (
|
|
28
|
+
ProjectCostWithDetailedServices,
|
|
29
|
+
)
|
|
30
|
+
from stackit.cost.models.project_cost_with_reports import ProjectCostWithReports
|
|
31
|
+
from stackit.cost.models.project_cost_with_summarized_services import (
|
|
32
|
+
ProjectCostWithSummarizedServices,
|
|
33
|
+
)
|
|
34
|
+
from stackit.cost.models.summarized_project_cost import SummarizedProjectCost
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
PROJECTCOST_ANY_OF_SCHEMAS = [
|
|
38
|
+
"ProjectCostWithDetailedServices",
|
|
39
|
+
"ProjectCostWithReports",
|
|
40
|
+
"ProjectCostWithSummarizedServices",
|
|
41
|
+
"SummarizedProjectCost",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class ProjectCost(BaseModel):
|
|
46
|
+
"""
|
|
47
|
+
ProjectCost
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
# data type: SummarizedProjectCost
|
|
51
|
+
anyof_schema_1_validator: Optional[SummarizedProjectCost] = None
|
|
52
|
+
# data type: ProjectCostWithReports
|
|
53
|
+
anyof_schema_2_validator: Optional[ProjectCostWithReports] = None
|
|
54
|
+
# data type: ProjectCostWithSummarizedServices
|
|
55
|
+
anyof_schema_3_validator: Optional[ProjectCostWithSummarizedServices] = None
|
|
56
|
+
# data type: ProjectCostWithDetailedServices
|
|
57
|
+
anyof_schema_4_validator: Optional[ProjectCostWithDetailedServices] = None
|
|
58
|
+
if TYPE_CHECKING:
|
|
59
|
+
actual_instance: Optional[
|
|
60
|
+
Union[
|
|
61
|
+
ProjectCostWithDetailedServices,
|
|
62
|
+
ProjectCostWithReports,
|
|
63
|
+
ProjectCostWithSummarizedServices,
|
|
64
|
+
SummarizedProjectCost,
|
|
65
|
+
]
|
|
66
|
+
] = None
|
|
67
|
+
else:
|
|
68
|
+
actual_instance: Any = None
|
|
69
|
+
any_of_schemas: Set[str] = {
|
|
70
|
+
"ProjectCostWithDetailedServices",
|
|
71
|
+
"ProjectCostWithReports",
|
|
72
|
+
"ProjectCostWithSummarizedServices",
|
|
73
|
+
"SummarizedProjectCost",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
model_config = {
|
|
77
|
+
"validate_assignment": True,
|
|
78
|
+
"protected_namespaces": (),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
82
|
+
if args:
|
|
83
|
+
if len(args) > 1:
|
|
84
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
85
|
+
if kwargs:
|
|
86
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
87
|
+
super().__init__(actual_instance=args[0])
|
|
88
|
+
else:
|
|
89
|
+
super().__init__(**kwargs)
|
|
90
|
+
|
|
91
|
+
@field_validator("actual_instance")
|
|
92
|
+
def actual_instance_must_validate_anyof(cls, v):
|
|
93
|
+
instance = ProjectCost.model_construct()
|
|
94
|
+
error_messages = []
|
|
95
|
+
# validate data type: SummarizedProjectCost
|
|
96
|
+
if not isinstance(v, SummarizedProjectCost):
|
|
97
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `SummarizedProjectCost`")
|
|
98
|
+
else:
|
|
99
|
+
return v
|
|
100
|
+
|
|
101
|
+
# validate data type: ProjectCostWithReports
|
|
102
|
+
if not isinstance(v, ProjectCostWithReports):
|
|
103
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ProjectCostWithReports`")
|
|
104
|
+
else:
|
|
105
|
+
return v
|
|
106
|
+
|
|
107
|
+
# validate data type: ProjectCostWithSummarizedServices
|
|
108
|
+
if not isinstance(v, ProjectCostWithSummarizedServices):
|
|
109
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ProjectCostWithSummarizedServices`")
|
|
110
|
+
else:
|
|
111
|
+
return v
|
|
112
|
+
|
|
113
|
+
# validate data type: ProjectCostWithDetailedServices
|
|
114
|
+
if not isinstance(v, ProjectCostWithDetailedServices):
|
|
115
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ProjectCostWithDetailedServices`")
|
|
116
|
+
else:
|
|
117
|
+
return v
|
|
118
|
+
|
|
119
|
+
if error_messages:
|
|
120
|
+
# no match
|
|
121
|
+
raise ValueError(
|
|
122
|
+
"No match found when setting the actual_instance in ProjectCost with anyOf schemas: ProjectCostWithDetailedServices, ProjectCostWithReports, ProjectCostWithSummarizedServices, SummarizedProjectCost. Details: "
|
|
123
|
+
+ ", ".join(error_messages)
|
|
124
|
+
)
|
|
125
|
+
else:
|
|
126
|
+
return v
|
|
127
|
+
|
|
128
|
+
@classmethod
|
|
129
|
+
def from_dict(cls, obj: Dict[str, Any]) -> Self:
|
|
130
|
+
return cls.from_json(json.dumps(obj))
|
|
131
|
+
|
|
132
|
+
@classmethod
|
|
133
|
+
def from_json(cls, json_str: str) -> Self:
|
|
134
|
+
"""Returns the object represented by the json string"""
|
|
135
|
+
instance = cls.model_construct()
|
|
136
|
+
error_messages = []
|
|
137
|
+
# anyof_schema_1_validator: Optional[SummarizedProjectCost] = None
|
|
138
|
+
try:
|
|
139
|
+
instance.actual_instance = SummarizedProjectCost.from_json(json_str)
|
|
140
|
+
return instance
|
|
141
|
+
except (ValidationError, ValueError) as e:
|
|
142
|
+
error_messages.append(str(e))
|
|
143
|
+
# anyof_schema_2_validator: Optional[ProjectCostWithReports] = None
|
|
144
|
+
try:
|
|
145
|
+
instance.actual_instance = ProjectCostWithReports.from_json(json_str)
|
|
146
|
+
return instance
|
|
147
|
+
except (ValidationError, ValueError) as e:
|
|
148
|
+
error_messages.append(str(e))
|
|
149
|
+
# anyof_schema_3_validator: Optional[ProjectCostWithSummarizedServices] = None
|
|
150
|
+
try:
|
|
151
|
+
instance.actual_instance = ProjectCostWithSummarizedServices.from_json(json_str)
|
|
152
|
+
return instance
|
|
153
|
+
except (ValidationError, ValueError) as e:
|
|
154
|
+
error_messages.append(str(e))
|
|
155
|
+
# anyof_schema_4_validator: Optional[ProjectCostWithDetailedServices] = None
|
|
156
|
+
try:
|
|
157
|
+
instance.actual_instance = ProjectCostWithDetailedServices.from_json(json_str)
|
|
158
|
+
return instance
|
|
159
|
+
except (ValidationError, ValueError) as e:
|
|
160
|
+
error_messages.append(str(e))
|
|
161
|
+
|
|
162
|
+
if error_messages:
|
|
163
|
+
# no match
|
|
164
|
+
raise ValueError(
|
|
165
|
+
"No match found when deserializing the JSON string into ProjectCost with anyOf schemas: ProjectCostWithDetailedServices, ProjectCostWithReports, ProjectCostWithSummarizedServices, SummarizedProjectCost. Details: "
|
|
166
|
+
+ ", ".join(error_messages)
|
|
167
|
+
)
|
|
168
|
+
else:
|
|
169
|
+
return instance
|
|
170
|
+
|
|
171
|
+
def to_json(self) -> str:
|
|
172
|
+
"""Returns the JSON representation of the actual instance"""
|
|
173
|
+
if self.actual_instance is None:
|
|
174
|
+
return "null"
|
|
175
|
+
|
|
176
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
177
|
+
return self.actual_instance.to_json()
|
|
178
|
+
else:
|
|
179
|
+
return json.dumps(self.actual_instance)
|
|
180
|
+
|
|
181
|
+
def to_dict(
|
|
182
|
+
self,
|
|
183
|
+
) -> Optional[
|
|
184
|
+
Union[
|
|
185
|
+
Dict[str, Any],
|
|
186
|
+
ProjectCostWithDetailedServices,
|
|
187
|
+
ProjectCostWithReports,
|
|
188
|
+
ProjectCostWithSummarizedServices,
|
|
189
|
+
SummarizedProjectCost,
|
|
190
|
+
]
|
|
191
|
+
]:
|
|
192
|
+
"""Returns the dict representation of the actual instance"""
|
|
193
|
+
if self.actual_instance is None:
|
|
194
|
+
return None
|
|
195
|
+
|
|
196
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
197
|
+
return self.actual_instance.to_dict()
|
|
198
|
+
else:
|
|
199
|
+
return self.actual_instance
|
|
200
|
+
|
|
201
|
+
def to_str(self) -> str:
|
|
202
|
+
"""Returns the string representation of the actual instance"""
|
|
203
|
+
return pprint.pformat(self.model_dump())
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Cost API
|
|
5
|
+
|
|
6
|
+
The cost API provides detailed reports on the costs for a customer or project over a certain amount of time
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set, Union
|
|
19
|
+
from uuid import UUID
|
|
20
|
+
|
|
21
|
+
from pydantic import (
|
|
22
|
+
BaseModel,
|
|
23
|
+
ConfigDict,
|
|
24
|
+
Field,
|
|
25
|
+
StrictFloat,
|
|
26
|
+
StrictInt,
|
|
27
|
+
StrictStr,
|
|
28
|
+
)
|
|
29
|
+
from typing_extensions import Self
|
|
30
|
+
|
|
31
|
+
from stackit.cost.models.detailed_service_cost import DetailedServiceCost
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ProjectCostWithDetailedServices(BaseModel):
|
|
35
|
+
"""
|
|
36
|
+
Detailed costs for a project including service costs
|
|
37
|
+
""" # noqa: E501
|
|
38
|
+
|
|
39
|
+
customer_account_id: UUID = Field(alias="customerAccountId")
|
|
40
|
+
project_id: UUID = Field(alias="projectId")
|
|
41
|
+
project_name: StrictStr = Field(alias="projectName")
|
|
42
|
+
services: Optional[List[DetailedServiceCost]] = Field(
|
|
43
|
+
default=None,
|
|
44
|
+
description='Total discount for all services and the whole requested date range (value in cents). Please see "depth" parameter for more details.',
|
|
45
|
+
)
|
|
46
|
+
total_charge: Union[StrictFloat, StrictInt] = Field(
|
|
47
|
+
description="Total charge (including discounts) for all services and the whole requested date range (value in cents)",
|
|
48
|
+
alias="totalCharge",
|
|
49
|
+
)
|
|
50
|
+
total_discount: Union[StrictFloat, StrictInt] = Field(
|
|
51
|
+
description="Total discount for all services and the whole requested date range (value in cents)",
|
|
52
|
+
alias="totalDiscount",
|
|
53
|
+
)
|
|
54
|
+
__properties: ClassVar[List[str]] = [
|
|
55
|
+
"customerAccountId",
|
|
56
|
+
"projectId",
|
|
57
|
+
"projectName",
|
|
58
|
+
"services",
|
|
59
|
+
"totalCharge",
|
|
60
|
+
"totalDiscount",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
model_config = ConfigDict(
|
|
64
|
+
populate_by_name=True,
|
|
65
|
+
validate_assignment=True,
|
|
66
|
+
protected_namespaces=(),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def to_str(self) -> str:
|
|
70
|
+
"""Returns the string representation of the model using alias"""
|
|
71
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
72
|
+
|
|
73
|
+
def to_json(self) -> str:
|
|
74
|
+
"""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
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
80
|
+
"""Create an instance of ProjectCostWithDetailedServices from a JSON string"""
|
|
81
|
+
return cls.from_dict(json.loads(json_str))
|
|
82
|
+
|
|
83
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
84
|
+
"""Return the dictionary representation of the model using alias.
|
|
85
|
+
|
|
86
|
+
This has the following differences from calling pydantic's
|
|
87
|
+
`self.model_dump(by_alias=True)`:
|
|
88
|
+
|
|
89
|
+
* `None` is only added to the output dict for nullable fields that
|
|
90
|
+
were set at model initialization. Other fields with value `None`
|
|
91
|
+
are ignored.
|
|
92
|
+
"""
|
|
93
|
+
excluded_fields: Set[str] = set([])
|
|
94
|
+
|
|
95
|
+
_dict = self.model_dump(
|
|
96
|
+
by_alias=True,
|
|
97
|
+
exclude=excluded_fields,
|
|
98
|
+
exclude_none=True,
|
|
99
|
+
)
|
|
100
|
+
# override the default output from pydantic by calling `to_dict()` of each item in services (list)
|
|
101
|
+
_items = []
|
|
102
|
+
if self.services:
|
|
103
|
+
for _item_services in self.services:
|
|
104
|
+
if _item_services:
|
|
105
|
+
_items.append(_item_services.to_dict())
|
|
106
|
+
_dict["services"] = _items
|
|
107
|
+
return _dict
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
111
|
+
"""Create an instance of ProjectCostWithDetailedServices from a dict"""
|
|
112
|
+
if obj is None:
|
|
113
|
+
return None
|
|
114
|
+
|
|
115
|
+
if not isinstance(obj, dict):
|
|
116
|
+
return cls.model_validate(obj)
|
|
117
|
+
|
|
118
|
+
_obj = cls.model_validate(
|
|
119
|
+
{
|
|
120
|
+
"customerAccountId": obj.get("customerAccountId"),
|
|
121
|
+
"projectId": obj.get("projectId"),
|
|
122
|
+
"projectName": obj.get("projectName"),
|
|
123
|
+
"services": (
|
|
124
|
+
[DetailedServiceCost.from_dict(_item) for _item in obj["services"]]
|
|
125
|
+
if obj.get("services") is not None
|
|
126
|
+
else None
|
|
127
|
+
),
|
|
128
|
+
"totalCharge": obj.get("totalCharge"),
|
|
129
|
+
"totalDiscount": obj.get("totalDiscount"),
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
return _obj
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Cost API
|
|
5
|
+
|
|
6
|
+
The cost API provides detailed reports on the costs for a customer or project over a certain amount of time
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set, Union
|
|
19
|
+
from uuid import UUID
|
|
20
|
+
|
|
21
|
+
from pydantic import (
|
|
22
|
+
BaseModel,
|
|
23
|
+
ConfigDict,
|
|
24
|
+
Field,
|
|
25
|
+
StrictFloat,
|
|
26
|
+
StrictInt,
|
|
27
|
+
StrictStr,
|
|
28
|
+
)
|
|
29
|
+
from typing_extensions import Self
|
|
30
|
+
|
|
31
|
+
from stackit.cost.models.report_data import ReportData
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ProjectCostWithReports(BaseModel):
|
|
35
|
+
"""
|
|
36
|
+
Detailed costs for a project
|
|
37
|
+
""" # noqa: E501
|
|
38
|
+
|
|
39
|
+
customer_account_id: UUID = Field(alias="customerAccountId")
|
|
40
|
+
project_id: UUID = Field(alias="projectId")
|
|
41
|
+
project_name: StrictStr = Field(alias="projectName")
|
|
42
|
+
report_data: Optional[List[ReportData]] = Field(
|
|
43
|
+
default=None,
|
|
44
|
+
description='Detailed project costs which are ONLY included if granularity is provided AND depth is "project"',
|
|
45
|
+
alias="reportData",
|
|
46
|
+
)
|
|
47
|
+
total_charge: Union[StrictFloat, StrictInt] = Field(
|
|
48
|
+
description="Total charge (including discounts) for all services and the whole requested date range (value in cents)",
|
|
49
|
+
alias="totalCharge",
|
|
50
|
+
)
|
|
51
|
+
total_discount: Union[StrictFloat, StrictInt] = Field(
|
|
52
|
+
description="Total discount for all services and the whole requested date range (value in cents)",
|
|
53
|
+
alias="totalDiscount",
|
|
54
|
+
)
|
|
55
|
+
__properties: ClassVar[List[str]] = [
|
|
56
|
+
"customerAccountId",
|
|
57
|
+
"projectId",
|
|
58
|
+
"projectName",
|
|
59
|
+
"reportData",
|
|
60
|
+
"totalCharge",
|
|
61
|
+
"totalDiscount",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
model_config = ConfigDict(
|
|
65
|
+
populate_by_name=True,
|
|
66
|
+
validate_assignment=True,
|
|
67
|
+
protected_namespaces=(),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def to_str(self) -> str:
|
|
71
|
+
"""Returns the string representation of the model using alias"""
|
|
72
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
73
|
+
|
|
74
|
+
def to_json(self) -> str:
|
|
75
|
+
"""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
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
81
|
+
"""Create an instance of ProjectCostWithReports from a JSON string"""
|
|
82
|
+
return cls.from_dict(json.loads(json_str))
|
|
83
|
+
|
|
84
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
85
|
+
"""Return the dictionary representation of the model using alias.
|
|
86
|
+
|
|
87
|
+
This has the following differences from calling pydantic's
|
|
88
|
+
`self.model_dump(by_alias=True)`:
|
|
89
|
+
|
|
90
|
+
* `None` is only added to the output dict for nullable fields that
|
|
91
|
+
were set at model initialization. Other fields with value `None`
|
|
92
|
+
are ignored.
|
|
93
|
+
"""
|
|
94
|
+
excluded_fields: Set[str] = set([])
|
|
95
|
+
|
|
96
|
+
_dict = self.model_dump(
|
|
97
|
+
by_alias=True,
|
|
98
|
+
exclude=excluded_fields,
|
|
99
|
+
exclude_none=True,
|
|
100
|
+
)
|
|
101
|
+
# override the default output from pydantic by calling `to_dict()` of each item in report_data (list)
|
|
102
|
+
_items = []
|
|
103
|
+
if self.report_data:
|
|
104
|
+
for _item_report_data in self.report_data:
|
|
105
|
+
if _item_report_data:
|
|
106
|
+
_items.append(_item_report_data.to_dict())
|
|
107
|
+
_dict["reportData"] = _items
|
|
108
|
+
return _dict
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
112
|
+
"""Create an instance of ProjectCostWithReports from a dict"""
|
|
113
|
+
if obj is None:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
if not isinstance(obj, dict):
|
|
117
|
+
return cls.model_validate(obj)
|
|
118
|
+
|
|
119
|
+
_obj = cls.model_validate(
|
|
120
|
+
{
|
|
121
|
+
"customerAccountId": obj.get("customerAccountId"),
|
|
122
|
+
"projectId": obj.get("projectId"),
|
|
123
|
+
"projectName": obj.get("projectName"),
|
|
124
|
+
"reportData": (
|
|
125
|
+
[ReportData.from_dict(_item) for _item in obj["reportData"]]
|
|
126
|
+
if obj.get("reportData") is not None
|
|
127
|
+
else None
|
|
128
|
+
),
|
|
129
|
+
"totalCharge": obj.get("totalCharge"),
|
|
130
|
+
"totalDiscount": obj.get("totalDiscount"),
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
return _obj
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
STACKIT Cost API
|
|
5
|
+
|
|
6
|
+
The cost API provides detailed reports on the costs for a customer or project over a certain amount of time
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 3.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
from typing import Any, ClassVar, Dict, List, Optional, Set, Union
|
|
19
|
+
from uuid import UUID
|
|
20
|
+
|
|
21
|
+
from pydantic import (
|
|
22
|
+
BaseModel,
|
|
23
|
+
ConfigDict,
|
|
24
|
+
Field,
|
|
25
|
+
StrictFloat,
|
|
26
|
+
StrictInt,
|
|
27
|
+
StrictStr,
|
|
28
|
+
)
|
|
29
|
+
from typing_extensions import Self
|
|
30
|
+
|
|
31
|
+
from stackit.cost.models.summarized_service_cost import SummarizedServiceCost
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ProjectCostWithSummarizedServices(BaseModel):
|
|
35
|
+
"""
|
|
36
|
+
Costs for a project including summarized service costs
|
|
37
|
+
""" # noqa: E501
|
|
38
|
+
|
|
39
|
+
customer_account_id: UUID = Field(alias="customerAccountId")
|
|
40
|
+
project_id: UUID = Field(alias="projectId")
|
|
41
|
+
project_name: StrictStr = Field(alias="projectName")
|
|
42
|
+
services: Optional[List[SummarizedServiceCost]] = Field(default=None, description="Summarized service costs")
|
|
43
|
+
total_charge: Union[StrictFloat, StrictInt] = Field(
|
|
44
|
+
description="Total charge (including discounts) for all services and the whole requested date range (value in cents)",
|
|
45
|
+
alias="totalCharge",
|
|
46
|
+
)
|
|
47
|
+
total_discount: Union[StrictFloat, StrictInt] = Field(
|
|
48
|
+
description="Total discount for all services and the whole requested date range (value in cents)",
|
|
49
|
+
alias="totalDiscount",
|
|
50
|
+
)
|
|
51
|
+
__properties: ClassVar[List[str]] = [
|
|
52
|
+
"customerAccountId",
|
|
53
|
+
"projectId",
|
|
54
|
+
"projectName",
|
|
55
|
+
"services",
|
|
56
|
+
"totalCharge",
|
|
57
|
+
"totalDiscount",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
model_config = ConfigDict(
|
|
61
|
+
populate_by_name=True,
|
|
62
|
+
validate_assignment=True,
|
|
63
|
+
protected_namespaces=(),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def to_str(self) -> str:
|
|
67
|
+
"""Returns the string representation of the model using alias"""
|
|
68
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
69
|
+
|
|
70
|
+
def to_json(self) -> str:
|
|
71
|
+
"""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
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
77
|
+
"""Create an instance of ProjectCostWithSummarizedServices from a JSON string"""
|
|
78
|
+
return cls.from_dict(json.loads(json_str))
|
|
79
|
+
|
|
80
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
81
|
+
"""Return the dictionary representation of the model using alias.
|
|
82
|
+
|
|
83
|
+
This has the following differences from calling pydantic's
|
|
84
|
+
`self.model_dump(by_alias=True)`:
|
|
85
|
+
|
|
86
|
+
* `None` is only added to the output dict for nullable fields that
|
|
87
|
+
were set at model initialization. Other fields with value `None`
|
|
88
|
+
are ignored.
|
|
89
|
+
"""
|
|
90
|
+
excluded_fields: Set[str] = set([])
|
|
91
|
+
|
|
92
|
+
_dict = self.model_dump(
|
|
93
|
+
by_alias=True,
|
|
94
|
+
exclude=excluded_fields,
|
|
95
|
+
exclude_none=True,
|
|
96
|
+
)
|
|
97
|
+
# override the default output from pydantic by calling `to_dict()` of each item in services (list)
|
|
98
|
+
_items = []
|
|
99
|
+
if self.services:
|
|
100
|
+
for _item_services in self.services:
|
|
101
|
+
if _item_services:
|
|
102
|
+
_items.append(_item_services.to_dict())
|
|
103
|
+
_dict["services"] = _items
|
|
104
|
+
return _dict
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
108
|
+
"""Create an instance of ProjectCostWithSummarizedServices from a dict"""
|
|
109
|
+
if obj is None:
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
if not isinstance(obj, dict):
|
|
113
|
+
return cls.model_validate(obj)
|
|
114
|
+
|
|
115
|
+
_obj = cls.model_validate(
|
|
116
|
+
{
|
|
117
|
+
"customerAccountId": obj.get("customerAccountId"),
|
|
118
|
+
"projectId": obj.get("projectId"),
|
|
119
|
+
"projectName": obj.get("projectName"),
|
|
120
|
+
"services": (
|
|
121
|
+
[SummarizedServiceCost.from_dict(_item) for _item in obj["services"]]
|
|
122
|
+
if obj.get("services") is not None
|
|
123
|
+
else None
|
|
124
|
+
),
|
|
125
|
+
"totalCharge": obj.get("totalCharge"),
|
|
126
|
+
"totalDiscount": obj.get("totalDiscount"),
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
return _obj
|