elastly 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.
Files changed (49) hide show
  1. elastly/__init__.py +117 -0
  2. elastly/api/__init__.py +7 -0
  3. elastly/api/ingest_api.py +1167 -0
  4. elastly/api/prices_api.py +349 -0
  5. elastly/api/writebacks_api.py +618 -0
  6. elastly/api_client.py +805 -0
  7. elastly/api_response.py +21 -0
  8. elastly/configuration.py +606 -0
  9. elastly/exceptions.py +219 -0
  10. elastly/models/__init__.py +49 -0
  11. elastly/models/ack_writebacks_response.py +94 -0
  12. elastly/models/api_error.py +93 -0
  13. elastly/models/api_error_error.py +102 -0
  14. elastly/models/batch_created_response.py +91 -0
  15. elastly/models/batch_status_response.py +110 -0
  16. elastly/models/claim_writebacks_request.py +90 -0
  17. elastly/models/claim_writebacks_response.py +97 -0
  18. elastly/models/claim_writebacks_response_tasks_inner.py +122 -0
  19. elastly/models/commit_batch_response.py +89 -0
  20. elastly/models/prices_request.py +98 -0
  21. elastly/models/prices_request_lines_inner.py +114 -0
  22. elastly/models/prices_response.py +97 -0
  23. elastly/models/prices_response_lines_inner.py +138 -0
  24. elastly/models/prices_response_lines_inner_one_of.py +131 -0
  25. elastly/models/prices_response_lines_inner_one_of1.py +105 -0
  26. elastly/models/prices_response_lines_inner_one_of_explanation.py +121 -0
  27. elastly/models/prices_response_lines_inner_one_of_explanation_drivers_inner.py +102 -0
  28. elastly/models/prices_response_lines_inner_one_of_reason_inner.py +95 -0
  29. elastly/models/stage_records_request.py +166 -0
  30. elastly/models/stage_records_request_one_of.py +107 -0
  31. elastly/models/stage_records_request_one_of1.py +107 -0
  32. elastly/models/stage_records_request_one_of1_records_inner.py +126 -0
  33. elastly/models/stage_records_request_one_of2.py +107 -0
  34. elastly/models/stage_records_request_one_of2_records_inner.py +160 -0
  35. elastly/models/stage_records_request_one_of2_records_inner_lines_inner.py +119 -0
  36. elastly/models/stage_records_request_one_of3.py +107 -0
  37. elastly/models/stage_records_request_one_of3_records_inner.py +131 -0
  38. elastly/models/stage_records_request_one_of3_records_inner_lines_inner.py +98 -0
  39. elastly/models/stage_records_request_one_of_records_inner.py +118 -0
  40. elastly/models/stage_records_response.py +90 -0
  41. elastly/models/writeback_ack_request.py +98 -0
  42. elastly/models/writeback_ack_request_results_inner.py +93 -0
  43. elastly/py.typed +0 -0
  44. elastly/rest.py +264 -0
  45. elastly-0.1.0.dist-info/METADATA +100 -0
  46. elastly-0.1.0.dist-info/RECORD +49 -0
  47. elastly-0.1.0.dist-info/WHEEL +5 -0
  48. elastly-0.1.0.dist-info/licenses/LICENSE +21 -0
  49. elastly-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,110 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Elastly API
5
+
6
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: support@elastly.io
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+ from pydantic_core import to_jsonable_python
27
+
28
+ class BatchStatusResponse(BaseModel):
29
+ """
30
+ BatchStatusResponse
31
+ """ # noqa: E501
32
+ status: StrictStr
33
+ entities: List[StrictStr]
34
+ record_count: Annotated[int, Field(le=9007199254740991, strict=True, ge=-9007199254740991)] = Field(alias="recordCount")
35
+ skipped_over_cap: Annotated[int, Field(le=9007199254740991, strict=True, ge=-9007199254740991)] = Field(alias="skippedOverCap")
36
+ error: Optional[StrictStr]
37
+ __properties: ClassVar[List[str]] = ["status", "entities", "recordCount", "skippedOverCap", "error"]
38
+
39
+ @field_validator('status')
40
+ def status_validate_enum(cls, value):
41
+ """Validates the enum"""
42
+ if value not in set(['open', 'committed', 'draining', 'drained', 'failed']):
43
+ raise ValueError("must be one of enum values ('open', 'committed', 'draining', 'drained', 'failed')")
44
+ return value
45
+
46
+ model_config = ConfigDict(
47
+ validate_by_name=True,
48
+ validate_by_alias=True,
49
+ validate_assignment=True,
50
+ protected_namespaces=(),
51
+ )
52
+
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ return json.dumps(to_jsonable_python(self.to_dict()))
61
+
62
+ @classmethod
63
+ def from_json(cls, json_str: str) -> Optional[Self]:
64
+ """Create an instance of BatchStatusResponse from a JSON string"""
65
+ return cls.from_dict(json.loads(json_str))
66
+
67
+ def to_dict(self) -> Dict[str, Any]:
68
+ """Return the dictionary representation of the model using alias.
69
+
70
+ This has the following differences from calling pydantic's
71
+ `self.model_dump(by_alias=True)`:
72
+
73
+ * `None` is only added to the output dict for nullable fields that
74
+ were set at model initialization. Other fields with value `None`
75
+ are ignored.
76
+ """
77
+ excluded_fields: Set[str] = set([
78
+ ])
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ # set to None if error (nullable) is None
86
+ # and model_fields_set contains the field
87
+ if self.error is None and "error" in self.model_fields_set:
88
+ _dict['error'] = None
89
+
90
+ return _dict
91
+
92
+ @classmethod
93
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94
+ """Create an instance of BatchStatusResponse from a dict"""
95
+ if obj is None:
96
+ return None
97
+
98
+ if not isinstance(obj, dict):
99
+ return cls.model_validate(obj)
100
+
101
+ _obj = cls.model_validate({
102
+ "status": obj.get("status"),
103
+ "entities": obj.get("entities"),
104
+ "recordCount": obj.get("recordCount"),
105
+ "skippedOverCap": obj.get("skippedOverCap"),
106
+ "error": obj.get("error")
107
+ })
108
+ return _obj
109
+
110
+
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Elastly API
5
+
6
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: support@elastly.io
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+ from pydantic_core import to_jsonable_python
27
+
28
+ class ClaimWritebacksRequest(BaseModel):
29
+ """
30
+ ClaimWritebacksRequest
31
+ """ # noqa: E501
32
+ limit: Optional[Annotated[int, Field(le=500, strict=True, gt=0)]] = 100
33
+ __properties: ClassVar[List[str]] = ["limit"]
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ return json.dumps(to_jsonable_python(self.to_dict()))
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of ClaimWritebacksRequest from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ return _dict
75
+
76
+ @classmethod
77
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78
+ """Create an instance of ClaimWritebacksRequest from a dict"""
79
+ if obj is None:
80
+ return None
81
+
82
+ if not isinstance(obj, dict):
83
+ return cls.model_validate(obj)
84
+
85
+ _obj = cls.model_validate({
86
+ "limit": obj.get("limit") if obj.get("limit") is not None else 100
87
+ })
88
+ return _obj
89
+
90
+
@@ -0,0 +1,97 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Elastly API
5
+
6
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: support@elastly.io
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict
22
+ from typing import Any, ClassVar, Dict, List
23
+ from elastly.models.claim_writebacks_response_tasks_inner import ClaimWritebacksResponseTasksInner
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+ from pydantic_core import to_jsonable_python
27
+
28
+ class ClaimWritebacksResponse(BaseModel):
29
+ """
30
+ ClaimWritebacksResponse
31
+ """ # noqa: E501
32
+ tasks: List[ClaimWritebacksResponseTasksInner]
33
+ __properties: ClassVar[List[str]] = ["tasks"]
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True,
37
+ validate_by_alias=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ return json.dumps(to_jsonable_python(self.to_dict()))
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of ClaimWritebacksResponse from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # override the default output from pydantic by calling `to_dict()` of each item in tasks (list)
75
+ _items = []
76
+ if self.tasks:
77
+ for _item_tasks in self.tasks:
78
+ if _item_tasks:
79
+ _items.append(_item_tasks.to_dict())
80
+ _dict['tasks'] = _items
81
+ return _dict
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85
+ """Create an instance of ClaimWritebacksResponse from a dict"""
86
+ if obj is None:
87
+ return None
88
+
89
+ if not isinstance(obj, dict):
90
+ return cls.model_validate(obj)
91
+
92
+ _obj = cls.model_validate({
93
+ "tasks": [ClaimWritebacksResponseTasksInner.from_dict(_item) for _item in obj["tasks"]] if obj.get("tasks") is not None else None
94
+ })
95
+ return _obj
96
+
97
+
@@ -0,0 +1,122 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Elastly API
5
+
6
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: support@elastly.io
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional, Union
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+ from pydantic_core import to_jsonable_python
26
+
27
+ class ClaimWritebacksResponseTasksInner(BaseModel):
28
+ """
29
+ ClaimWritebacksResponseTasksInner
30
+ """ # noqa: E501
31
+ id: StrictStr
32
+ product_sku: StrictStr = Field(alias="productSku")
33
+ product_external_id: StrictStr = Field(alias="productExternalId")
34
+ price_cents: Union[StrictFloat, StrictInt] = Field(alias="priceCents")
35
+ currency: StrictStr
36
+ exchange_rate_to_base: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="exchangeRateToBase")
37
+ reason_summary: Optional[StrictStr] = Field(default=None, alias="reasonSummary")
38
+ pricing_decision_id: Optional[StrictStr] = Field(default=None, alias="pricingDecisionId")
39
+ lease_until: StrictStr = Field(alias="leaseUntil")
40
+ target: Dict[str, Any]
41
+ __properties: ClassVar[List[str]] = ["id", "productSku", "productExternalId", "priceCents", "currency", "exchangeRateToBase", "reasonSummary", "pricingDecisionId", "leaseUntil", "target"]
42
+
43
+ model_config = ConfigDict(
44
+ validate_by_name=True,
45
+ validate_by_alias=True,
46
+ validate_assignment=True,
47
+ protected_namespaces=(),
48
+ )
49
+
50
+
51
+ def to_str(self) -> str:
52
+ """Returns the string representation of the model using alias"""
53
+ return pprint.pformat(self.model_dump(by_alias=True))
54
+
55
+ def to_json(self) -> str:
56
+ """Returns the JSON representation of the model using alias"""
57
+ return json.dumps(to_jsonable_python(self.to_dict()))
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of ClaimWritebacksResponseTasksInner from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ """
74
+ excluded_fields: Set[str] = set([
75
+ ])
76
+
77
+ _dict = self.model_dump(
78
+ by_alias=True,
79
+ exclude=excluded_fields,
80
+ exclude_none=True,
81
+ )
82
+ # set to None if exchange_rate_to_base (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.exchange_rate_to_base is None and "exchange_rate_to_base" in self.model_fields_set:
85
+ _dict['exchangeRateToBase'] = None
86
+
87
+ # set to None if reason_summary (nullable) is None
88
+ # and model_fields_set contains the field
89
+ if self.reason_summary is None and "reason_summary" in self.model_fields_set:
90
+ _dict['reasonSummary'] = None
91
+
92
+ # set to None if pricing_decision_id (nullable) is None
93
+ # and model_fields_set contains the field
94
+ if self.pricing_decision_id is None and "pricing_decision_id" in self.model_fields_set:
95
+ _dict['pricingDecisionId'] = None
96
+
97
+ return _dict
98
+
99
+ @classmethod
100
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
101
+ """Create an instance of ClaimWritebacksResponseTasksInner from a dict"""
102
+ if obj is None:
103
+ return None
104
+
105
+ if not isinstance(obj, dict):
106
+ return cls.model_validate(obj)
107
+
108
+ _obj = cls.model_validate({
109
+ "id": obj.get("id"),
110
+ "productSku": obj.get("productSku"),
111
+ "productExternalId": obj.get("productExternalId"),
112
+ "priceCents": obj.get("priceCents"),
113
+ "currency": obj.get("currency"),
114
+ "exchangeRateToBase": obj.get("exchangeRateToBase"),
115
+ "reasonSummary": obj.get("reasonSummary"),
116
+ "pricingDecisionId": obj.get("pricingDecisionId"),
117
+ "leaseUntil": obj.get("leaseUntil"),
118
+ "target": obj.get("target")
119
+ })
120
+ return _obj
121
+
122
+
@@ -0,0 +1,89 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Elastly API
5
+
6
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: support@elastly.io
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
22
+ from typing import Any, ClassVar, Dict, List
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+ from pydantic_core import to_jsonable_python
26
+
27
+ class CommitBatchResponse(BaseModel):
28
+ """
29
+ CommitBatchResponse
30
+ """ # noqa: E501
31
+ job_id: StrictStr = Field(alias="jobId")
32
+ __properties: ClassVar[List[str]] = ["jobId"]
33
+
34
+ model_config = ConfigDict(
35
+ validate_by_name=True,
36
+ validate_by_alias=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ return json.dumps(to_jsonable_python(self.to_dict()))
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of CommitBatchResponse from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of CommitBatchResponse from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "jobId": obj.get("jobId")
86
+ })
87
+ return _obj
88
+
89
+
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Elastly API
5
+
6
+ Elastly public API v1: price serving, canonical ingest, write-back claims and webhooks. Authenticate every request with an API key: Authorization: Bearer elastly_live_...
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: support@elastly.io
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field
22
+ from typing import Any, ClassVar, Dict, List
23
+ from typing_extensions import Annotated
24
+ from elastly.models.prices_request_lines_inner import PricesRequestLinesInner
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+ from pydantic_core import to_jsonable_python
28
+
29
+ class PricesRequest(BaseModel):
30
+ """
31
+ PricesRequest
32
+ """ # noqa: E501
33
+ lines: Annotated[List[PricesRequestLinesInner], Field(min_length=1, max_length=100)]
34
+ __properties: ClassVar[List[str]] = ["lines"]
35
+
36
+ model_config = ConfigDict(
37
+ validate_by_name=True,
38
+ validate_by_alias=True,
39
+ validate_assignment=True,
40
+ protected_namespaces=(),
41
+ )
42
+
43
+
44
+ def to_str(self) -> str:
45
+ """Returns the string representation of the model using alias"""
46
+ return pprint.pformat(self.model_dump(by_alias=True))
47
+
48
+ def to_json(self) -> str:
49
+ """Returns the JSON representation of the model using alias"""
50
+ return json.dumps(to_jsonable_python(self.to_dict()))
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of PricesRequest from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # override the default output from pydantic by calling `to_dict()` of each item in lines (list)
76
+ _items = []
77
+ if self.lines:
78
+ for _item_lines in self.lines:
79
+ if _item_lines:
80
+ _items.append(_item_lines.to_dict())
81
+ _dict['lines'] = _items
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of PricesRequest from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "lines": [PricesRequestLinesInner.from_dict(_item) for _item in obj["lines"]] if obj.get("lines") is not None else None
95
+ })
96
+ return _obj
97
+
98
+