stadiamaps 1.0.7__py3-none-any.whl → 2.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 (112) hide show
  1. stadiamaps/__init__.py +6 -24
  2. stadiamaps/api/geocoding_api.py +1917 -760
  3. stadiamaps/api/geospatial_api.py +483 -221
  4. stadiamaps/api/routing_api.py +1615 -723
  5. stadiamaps/api_client.py +275 -272
  6. stadiamaps/api_response.py +12 -16
  7. stadiamaps/configuration.py +13 -11
  8. stadiamaps/exceptions.py +67 -30
  9. stadiamaps/models/__init__.py +5 -23
  10. stadiamaps/models/access.py +44 -26
  11. stadiamaps/models/admin_region.py +46 -28
  12. stadiamaps/models/administrative.py +48 -30
  13. stadiamaps/models/auto_costing_options.py +75 -48
  14. stadiamaps/models/base_costing_options.py +59 -34
  15. stadiamaps/models/base_trace_request.py +70 -40
  16. stadiamaps/models/bicycle_costing_options.py +67 -42
  17. stadiamaps/models/bike_network.py +42 -24
  18. stadiamaps/models/contour.py +45 -27
  19. stadiamaps/models/coordinate.py +45 -26
  20. stadiamaps/models/costing_model.py +10 -12
  21. stadiamaps/models/costing_options.py +51 -33
  22. stadiamaps/models/directions_options.py +45 -27
  23. stadiamaps/models/distance_unit.py +8 -11
  24. stadiamaps/models/edge_sign.py +46 -28
  25. stadiamaps/models/edge_use.py +8 -11
  26. stadiamaps/models/end_node.py +48 -30
  27. stadiamaps/models/geo_attributes.py +47 -29
  28. stadiamaps/models/geo_json_geometry.py +25 -25
  29. stadiamaps/models/geo_json_geometry_base.py +45 -27
  30. stadiamaps/models/geo_json_line_string.py +47 -28
  31. stadiamaps/models/geo_json_line_string_all_of.py +1 -1
  32. stadiamaps/models/geo_json_point.py +47 -28
  33. stadiamaps/models/geo_json_point_all_of.py +1 -1
  34. stadiamaps/models/geo_json_polygon.py +47 -28
  35. stadiamaps/models/geo_json_polygon_all_of.py +1 -1
  36. stadiamaps/models/geocoding_object.py +46 -28
  37. stadiamaps/models/height_request.py +55 -34
  38. stadiamaps/models/height_response.py +49 -30
  39. stadiamaps/models/highway_classification.py +52 -34
  40. stadiamaps/models/intersecting_edge.py +45 -27
  41. stadiamaps/models/isochrone_costing_model.py +8 -11
  42. stadiamaps/models/isochrone_feature.py +45 -27
  43. stadiamaps/models/isochrone_properties.py +48 -30
  44. stadiamaps/models/isochrone_request.py +54 -35
  45. stadiamaps/models/isochrone_response.py +47 -29
  46. stadiamaps/models/locate_detailed_edge.py +73 -55
  47. stadiamaps/models/locate_edge.py +56 -39
  48. stadiamaps/models/locate_edge_info.py +47 -29
  49. stadiamaps/models/locate_node.py +50 -31
  50. stadiamaps/models/locate_object.py +49 -31
  51. stadiamaps/models/maneuver_sign.py +50 -32
  52. stadiamaps/models/maneuver_sign_element.py +45 -27
  53. stadiamaps/models/map_match_costing_model.py +8 -11
  54. stadiamaps/models/map_match_request.py +74 -44
  55. stadiamaps/models/map_match_route_response.py +57 -29
  56. stadiamaps/models/map_match_trace_options.py +47 -29
  57. stadiamaps/models/map_match_waypoint.py +49 -30
  58. stadiamaps/models/matched_point.py +52 -34
  59. stadiamaps/models/matrix_costing_model.py +9 -12
  60. stadiamaps/models/matrix_distance.py +46 -28
  61. stadiamaps/models/matrix_request.py +70 -39
  62. stadiamaps/models/matrix_response.py +60 -36
  63. stadiamaps/models/motor_scooter_costing_options.py +76 -49
  64. stadiamaps/models/motorcycle_costing_options.py +75 -48
  65. stadiamaps/models/nearest_roads_request.py +65 -34
  66. stadiamaps/models/node_id.py +42 -24
  67. stadiamaps/models/node_type.py +8 -11
  68. stadiamaps/models/optimized_route_request.py +66 -35
  69. stadiamaps/models/pedestrian_costing_options.py +59 -40
  70. stadiamaps/models/pelias_geo_json_feature.py +50 -31
  71. stadiamaps/models/pelias_geo_json_properties.py +54 -36
  72. stadiamaps/models/pelias_geo_json_properties_addendum.py +43 -25
  73. stadiamaps/models/pelias_geo_json_properties_addendum_osm.py +42 -24
  74. stadiamaps/models/pelias_layer.py +8 -11
  75. stadiamaps/models/pelias_response.py +49 -30
  76. stadiamaps/models/pelias_source.py +8 -11
  77. stadiamaps/models/restrictions.py +44 -26
  78. stadiamaps/models/road_class.py +8 -11
  79. stadiamaps/models/route_leg.py +48 -29
  80. stadiamaps/models/route_maneuver.py +73 -55
  81. stadiamaps/models/route_request.py +76 -43
  82. stadiamaps/models/route_response.py +56 -28
  83. stadiamaps/models/route_response_alternates_inner.py +105 -0
  84. stadiamaps/models/route_summary.py +48 -30
  85. stadiamaps/models/route_trip.py +135 -0
  86. stadiamaps/models/routing_response_waypoint.py +49 -30
  87. stadiamaps/models/routing_waypoint.py +60 -41
  88. stadiamaps/models/routing_waypoint_all_of_search_filter.py +48 -30
  89. stadiamaps/models/simple_routing_waypoint.py +48 -29
  90. stadiamaps/models/speeds.py +49 -31
  91. stadiamaps/models/trace_attribute_filter_options.py +47 -28
  92. stadiamaps/models/trace_attribute_key.py +8 -11
  93. stadiamaps/models/trace_attributes_base_response.py +51 -32
  94. stadiamaps/models/trace_attributes_request.py +72 -42
  95. stadiamaps/models/trace_attributes_request_all_of_filters.py +1 -1
  96. stadiamaps/models/trace_attributes_response.py +54 -35
  97. stadiamaps/models/trace_edge.py +88 -70
  98. stadiamaps/models/travel_mode.py +8 -11
  99. stadiamaps/models/traversability.py +8 -11
  100. stadiamaps/models/truck_costing_options.py +78 -51
  101. stadiamaps/models/tz_response.py +45 -27
  102. stadiamaps/models/valhalla_languages.py +8 -11
  103. stadiamaps/models/valhalla_long_units.py +8 -11
  104. stadiamaps/models/warning.py +42 -24
  105. stadiamaps/py.typed +0 -0
  106. stadiamaps/rest.py +127 -172
  107. {stadiamaps-1.0.7.dist-info → stadiamaps-2.1.0.dist-info}/METADATA +4 -4
  108. stadiamaps-2.1.0.dist-info/RECORD +128 -0
  109. {stadiamaps-1.0.7.dist-info → stadiamaps-2.1.0.dist-info}/WHEEL +1 -1
  110. stadiamaps-1.0.7.dist-info/RECORD +0 -125
  111. {stadiamaps-1.0.7.dist-info → stadiamaps-2.1.0.dist-info}/LICENSE.txt +0 -0
  112. {stadiamaps-1.0.7.dist-info → stadiamaps-2.1.0.dist-info}/top_level.txt +0 -0
@@ -3,14 +3,14 @@
3
3
  """
4
4
  Stadia Maps Geospatial APIs
5
5
 
6
- The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications. # noqa: E501
6
+ The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications.
7
7
 
8
- The version of the OpenAPI document: 5.0.6
8
+ The version of the OpenAPI document: 6.1.0
9
9
  Contact: support@stadiamaps.com
10
10
  Generated by OpenAPI Generator (https://openapi-generator.tech)
11
11
 
12
12
  Do not edit the class manually.
13
- """
13
+ """ # noqa: E501
14
14
 
15
15
 
16
16
  from __future__ import annotations
@@ -18,51 +18,82 @@ import pprint
18
18
  import re # noqa: F401
19
19
  import json
20
20
 
21
-
22
- from typing import List, Optional
23
- from pydantic import BaseModel, Field, StrictBool, conlist
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
24
  from stadiamaps.models.coordinate import Coordinate
25
25
  from stadiamaps.models.costing_model import CostingModel
26
26
  from stadiamaps.models.costing_options import CostingOptions
27
- from stadiamaps.models.directions_options import DirectionsOptions
27
+ from stadiamaps.models.distance_unit import DistanceUnit
28
+ from stadiamaps.models.valhalla_languages import ValhallaLanguages
29
+ from typing import Optional, Set
30
+ from typing_extensions import Self
28
31
 
29
32
  class NearestRoadsRequest(BaseModel):
30
33
  """
31
34
  NearestRoadsRequest
32
- """
33
- locations: conlist(Coordinate, min_items=1) = Field(...)
35
+ """ # noqa: E501
36
+ units: Optional[DistanceUnit] = None
37
+ language: Optional[ValhallaLanguages] = None
38
+ directions_type: Optional[StrictStr] = Field(default='instructions', description="The level of directional narrative to include. Locations and times will always be returned, but narrative generation verbosity can be controlled with this parameter.")
39
+ locations: Annotated[List[Coordinate], Field(min_length=1)]
34
40
  costing: Optional[CostingModel] = None
35
41
  costing_options: Optional[CostingOptions] = None
36
42
  verbose: Optional[StrictBool] = False
37
- directions_options: Optional[DirectionsOptions] = None
38
43
  additional_properties: Dict[str, Any] = {}
39
- __properties = ["locations", "costing", "costing_options", "verbose", "directions_options"]
44
+ __properties: ClassVar[List[str]] = ["units", "language", "directions_type", "locations", "costing", "costing_options", "verbose"]
45
+
46
+ @field_validator('directions_type')
47
+ def directions_type_validate_enum(cls, value):
48
+ """Validates the enum"""
49
+ if value is None:
50
+ return value
51
+
52
+ if value not in set(['none', 'maneuvers', 'instructions']):
53
+ raise ValueError("must be one of enum values ('none', 'maneuvers', 'instructions')")
54
+ return value
55
+
56
+ model_config = ConfigDict(
57
+ populate_by_name=True,
58
+ validate_assignment=True,
59
+ protected_namespaces=(),
60
+ )
40
61
 
41
- class Config:
42
- """Pydantic configuration"""
43
- allow_population_by_field_name = True
44
- validate_assignment = True
45
62
 
46
63
  def to_str(self) -> str:
47
64
  """Returns the string representation of the model using alias"""
48
- return pprint.pformat(self.dict(by_alias=True))
65
+ return pprint.pformat(self.model_dump(by_alias=True))
49
66
 
50
67
  def to_json(self) -> str:
51
68
  """Returns the JSON representation of the model using alias"""
69
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
70
  return json.dumps(self.to_dict())
53
71
 
54
72
  @classmethod
55
- def from_json(cls, json_str: str) -> NearestRoadsRequest:
73
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
74
  """Create an instance of NearestRoadsRequest from a JSON string"""
57
75
  return cls.from_dict(json.loads(json_str))
58
76
 
59
- def to_dict(self):
60
- """Returns the dictionary representation of the model using alias"""
61
- _dict = self.dict(by_alias=True,
62
- exclude={
63
- "additional_properties"
64
- },
65
- exclude_none=True)
77
+ def to_dict(self) -> Dict[str, Any]:
78
+ """Return the dictionary representation of the model using alias.
79
+
80
+ This has the following differences from calling pydantic's
81
+ `self.model_dump(by_alias=True)`:
82
+
83
+ * `None` is only added to the output dict for nullable fields that
84
+ were set at model initialization. Other fields with value `None`
85
+ are ignored.
86
+ * Fields in `self.additional_properties` are added to the output dict.
87
+ """
88
+ excluded_fields: Set[str] = set([
89
+ "additional_properties",
90
+ ])
91
+
92
+ _dict = self.model_dump(
93
+ by_alias=True,
94
+ exclude=excluded_fields,
95
+ exclude_none=True,
96
+ )
66
97
  # override the default output from pydantic by calling `to_dict()` of each item in locations (list)
67
98
  _items = []
68
99
  if self.locations:
@@ -73,9 +104,6 @@ class NearestRoadsRequest(BaseModel):
73
104
  # override the default output from pydantic by calling `to_dict()` of costing_options
74
105
  if self.costing_options:
75
106
  _dict['costing_options'] = self.costing_options.to_dict()
76
- # override the default output from pydantic by calling `to_dict()` of directions_options
77
- if self.directions_options:
78
- _dict['directions_options'] = self.directions_options.to_dict()
79
107
  # puts key-value pairs in additional_properties in the top level
80
108
  if self.additional_properties is not None:
81
109
  for _key, _value in self.additional_properties.items():
@@ -84,20 +112,22 @@ class NearestRoadsRequest(BaseModel):
84
112
  return _dict
85
113
 
86
114
  @classmethod
87
- def from_dict(cls, obj: dict) -> NearestRoadsRequest:
115
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
116
  """Create an instance of NearestRoadsRequest from a dict"""
89
117
  if obj is None:
90
118
  return None
91
119
 
92
120
  if not isinstance(obj, dict):
93
- return NearestRoadsRequest.parse_obj(obj)
121
+ return cls.model_validate(obj)
94
122
 
95
- _obj = NearestRoadsRequest.parse_obj({
96
- "locations": [Coordinate.from_dict(_item) for _item in obj.get("locations")] if obj.get("locations") is not None else None,
123
+ _obj = cls.model_validate({
124
+ "units": obj.get("units"),
125
+ "language": obj.get("language"),
126
+ "directions_type": obj.get("directions_type") if obj.get("directions_type") is not None else 'instructions',
127
+ "locations": [Coordinate.from_dict(_item) for _item in obj["locations"]] if obj.get("locations") is not None else None,
97
128
  "costing": obj.get("costing"),
98
- "costing_options": CostingOptions.from_dict(obj.get("costing_options")) if obj.get("costing_options") is not None else None,
99
- "verbose": obj.get("verbose") if obj.get("verbose") is not None else False,
100
- "directions_options": DirectionsOptions.from_dict(obj.get("directions_options")) if obj.get("directions_options") is not None else None
129
+ "costing_options": CostingOptions.from_dict(obj["costing_options"]) if obj.get("costing_options") is not None else None,
130
+ "verbose": obj.get("verbose") if obj.get("verbose") is not None else False
101
131
  })
102
132
  # store additional fields in additional_properties
103
133
  for _key in obj.keys():
@@ -106,3 +136,4 @@ class NearestRoadsRequest(BaseModel):
106
136
 
107
137
  return _obj
108
138
 
139
+
@@ -3,14 +3,14 @@
3
3
  """
4
4
  Stadia Maps Geospatial APIs
5
5
 
6
- The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications. # noqa: E501
6
+ The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications.
7
7
 
8
- The version of the OpenAPI document: 5.0.6
8
+ The version of the OpenAPI document: 6.1.0
9
9
  Contact: support@stadiamaps.com
10
10
  Generated by OpenAPI Generator (https://openapi-generator.tech)
11
11
 
12
12
  Do not edit the class manually.
13
- """
13
+ """ # noqa: E501
14
14
 
15
15
 
16
16
  from __future__ import annotations
@@ -18,46 +18,63 @@ import pprint
18
18
  import re # noqa: F401
19
19
  import json
20
20
 
21
-
22
- from typing import Optional
23
- from pydantic import BaseModel, StrictInt
21
+ from pydantic import BaseModel, ConfigDict, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
24
25
 
25
26
  class NodeId(BaseModel):
26
27
  """
27
28
  NodeId
28
- """
29
+ """ # noqa: E501
29
30
  id: Optional[StrictInt] = None
30
31
  value: Optional[StrictInt] = None
31
32
  tile_id: Optional[StrictInt] = None
32
33
  level: Optional[StrictInt] = None
33
34
  additional_properties: Dict[str, Any] = {}
34
- __properties = ["id", "value", "tile_id", "level"]
35
+ __properties: ClassVar[List[str]] = ["id", "value", "tile_id", "level"]
36
+
37
+ model_config = ConfigDict(
38
+ populate_by_name=True,
39
+ validate_assignment=True,
40
+ protected_namespaces=(),
41
+ )
35
42
 
36
- class Config:
37
- """Pydantic configuration"""
38
- allow_population_by_field_name = True
39
- validate_assignment = True
40
43
 
41
44
  def to_str(self) -> str:
42
45
  """Returns the string representation of the model using alias"""
43
- return pprint.pformat(self.dict(by_alias=True))
46
+ return pprint.pformat(self.model_dump(by_alias=True))
44
47
 
45
48
  def to_json(self) -> str:
46
49
  """Returns the JSON representation of the model using alias"""
50
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
51
  return json.dumps(self.to_dict())
48
52
 
49
53
  @classmethod
50
- def from_json(cls, json_str: str) -> NodeId:
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
55
  """Create an instance of NodeId from a JSON string"""
52
56
  return cls.from_dict(json.loads(json_str))
53
57
 
54
- def to_dict(self):
55
- """Returns the dictionary representation of the model using alias"""
56
- _dict = self.dict(by_alias=True,
57
- exclude={
58
- "additional_properties"
59
- },
60
- exclude_none=True)
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ * Fields in `self.additional_properties` are added to the output dict.
68
+ """
69
+ excluded_fields: Set[str] = set([
70
+ "additional_properties",
71
+ ])
72
+
73
+ _dict = self.model_dump(
74
+ by_alias=True,
75
+ exclude=excluded_fields,
76
+ exclude_none=True,
77
+ )
61
78
  # puts key-value pairs in additional_properties in the top level
62
79
  if self.additional_properties is not None:
63
80
  for _key, _value in self.additional_properties.items():
@@ -66,15 +83,15 @@ class NodeId(BaseModel):
66
83
  return _dict
67
84
 
68
85
  @classmethod
69
- def from_dict(cls, obj: dict) -> NodeId:
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
70
87
  """Create an instance of NodeId from a dict"""
71
88
  if obj is None:
72
89
  return None
73
90
 
74
91
  if not isinstance(obj, dict):
75
- return NodeId.parse_obj(obj)
92
+ return cls.model_validate(obj)
76
93
 
77
- _obj = NodeId.parse_obj({
94
+ _obj = cls.model_validate({
78
95
  "id": obj.get("id"),
79
96
  "value": obj.get("value"),
80
97
  "tile_id": obj.get("tile_id"),
@@ -87,3 +104,4 @@ class NodeId(BaseModel):
87
104
 
88
105
  return _obj
89
106
 
107
+
@@ -3,23 +3,20 @@
3
3
  """
4
4
  Stadia Maps Geospatial APIs
5
5
 
6
- The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications. # noqa: E501
6
+ The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications.
7
7
 
8
- The version of the OpenAPI document: 5.0.6
8
+ The version of the OpenAPI document: 6.1.0
9
9
  Contact: support@stadiamaps.com
10
10
  Generated by OpenAPI Generator (https://openapi-generator.tech)
11
11
 
12
12
  Do not edit the class manually.
13
- """
13
+ """ # noqa: E501
14
14
 
15
15
 
16
+ from __future__ import annotations
16
17
  import json
17
- import pprint
18
- import re # noqa: F401
19
- from aenum import Enum, no_arg
20
-
21
-
22
-
18
+ from enum import Enum
19
+ from typing_extensions import Self
23
20
 
24
21
 
25
22
  class NodeType(str, Enum):
@@ -41,8 +38,8 @@ class NodeType(str, Enum):
41
38
  BORDER_CONTROL = 'border_control'
42
39
 
43
40
  @classmethod
44
- def from_json(cls, json_str: str) -> NodeType:
41
+ def from_json(cls, json_str: str) -> Self:
45
42
  """Create an instance of NodeType from a JSON string"""
46
- return NodeType(json.loads(json_str))
43
+ return cls(json.loads(json_str))
47
44
 
48
45
 
@@ -3,14 +3,14 @@
3
3
  """
4
4
  Stadia Maps Geospatial APIs
5
5
 
6
- The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications. # noqa: E501
6
+ The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications.
7
7
 
8
- The version of the OpenAPI document: 5.0.6
8
+ The version of the OpenAPI document: 6.1.0
9
9
  Contact: support@stadiamaps.com
10
10
  Generated by OpenAPI Generator (https://openapi-generator.tech)
11
11
 
12
12
  Do not edit the class manually.
13
- """
13
+ """ # noqa: E501
14
14
 
15
15
 
16
16
  from __future__ import annotations
@@ -18,51 +18,82 @@ import pprint
18
18
  import re # noqa: F401
19
19
  import json
20
20
 
21
-
22
- from typing import List, Optional
23
- from pydantic import BaseModel, Field, StrictStr, conlist
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
24
  from stadiamaps.models.coordinate import Coordinate
25
25
  from stadiamaps.models.costing_options import CostingOptions
26
- from stadiamaps.models.directions_options import DirectionsOptions
26
+ from stadiamaps.models.distance_unit import DistanceUnit
27
27
  from stadiamaps.models.matrix_costing_model import MatrixCostingModel
28
+ from stadiamaps.models.valhalla_languages import ValhallaLanguages
29
+ from typing import Optional, Set
30
+ from typing_extensions import Self
28
31
 
29
32
  class OptimizedRouteRequest(BaseModel):
30
33
  """
31
34
  OptimizedRouteRequest
32
- """
33
- id: Optional[StrictStr] = Field(None, description="An identifier to disambiguate requests (echoed by the server).")
34
- locations: conlist(Coordinate, min_items=3) = Field(..., description="The list of locations. The first and last are assumed to be the start and end points, and all intermediate points are locations that you want to visit along the way.")
35
- costing: MatrixCostingModel = Field(...)
35
+ """ # noqa: E501
36
+ units: Optional[DistanceUnit] = None
37
+ language: Optional[ValhallaLanguages] = None
38
+ directions_type: Optional[StrictStr] = Field(default='instructions', description="The level of directional narrative to include. Locations and times will always be returned, but narrative generation verbosity can be controlled with this parameter.")
39
+ id: Optional[StrictStr] = Field(default=None, description="An identifier to disambiguate requests (echoed by the server).")
40
+ locations: Annotated[List[Coordinate], Field(min_length=3)] = Field(description="The list of locations. The first and last are assumed to be the start and end points, and all intermediate points are locations that you want to visit along the way.")
41
+ costing: MatrixCostingModel
36
42
  costing_options: Optional[CostingOptions] = None
37
- directions_options: Optional[DirectionsOptions] = None
38
43
  additional_properties: Dict[str, Any] = {}
39
- __properties = ["id", "locations", "costing", "costing_options", "directions_options"]
44
+ __properties: ClassVar[List[str]] = ["units", "language", "directions_type", "id", "locations", "costing", "costing_options"]
45
+
46
+ @field_validator('directions_type')
47
+ def directions_type_validate_enum(cls, value):
48
+ """Validates the enum"""
49
+ if value is None:
50
+ return value
51
+
52
+ if value not in set(['none', 'maneuvers', 'instructions']):
53
+ raise ValueError("must be one of enum values ('none', 'maneuvers', 'instructions')")
54
+ return value
55
+
56
+ model_config = ConfigDict(
57
+ populate_by_name=True,
58
+ validate_assignment=True,
59
+ protected_namespaces=(),
60
+ )
40
61
 
41
- class Config:
42
- """Pydantic configuration"""
43
- allow_population_by_field_name = True
44
- validate_assignment = True
45
62
 
46
63
  def to_str(self) -> str:
47
64
  """Returns the string representation of the model using alias"""
48
- return pprint.pformat(self.dict(by_alias=True))
65
+ return pprint.pformat(self.model_dump(by_alias=True))
49
66
 
50
67
  def to_json(self) -> str:
51
68
  """Returns the JSON representation of the model using alias"""
69
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
70
  return json.dumps(self.to_dict())
53
71
 
54
72
  @classmethod
55
- def from_json(cls, json_str: str) -> OptimizedRouteRequest:
73
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
74
  """Create an instance of OptimizedRouteRequest from a JSON string"""
57
75
  return cls.from_dict(json.loads(json_str))
58
76
 
59
- def to_dict(self):
60
- """Returns the dictionary representation of the model using alias"""
61
- _dict = self.dict(by_alias=True,
62
- exclude={
63
- "additional_properties"
64
- },
65
- exclude_none=True)
77
+ def to_dict(self) -> Dict[str, Any]:
78
+ """Return the dictionary representation of the model using alias.
79
+
80
+ This has the following differences from calling pydantic's
81
+ `self.model_dump(by_alias=True)`:
82
+
83
+ * `None` is only added to the output dict for nullable fields that
84
+ were set at model initialization. Other fields with value `None`
85
+ are ignored.
86
+ * Fields in `self.additional_properties` are added to the output dict.
87
+ """
88
+ excluded_fields: Set[str] = set([
89
+ "additional_properties",
90
+ ])
91
+
92
+ _dict = self.model_dump(
93
+ by_alias=True,
94
+ exclude=excluded_fields,
95
+ exclude_none=True,
96
+ )
66
97
  # override the default output from pydantic by calling `to_dict()` of each item in locations (list)
67
98
  _items = []
68
99
  if self.locations:
@@ -73,9 +104,6 @@ class OptimizedRouteRequest(BaseModel):
73
104
  # override the default output from pydantic by calling `to_dict()` of costing_options
74
105
  if self.costing_options:
75
106
  _dict['costing_options'] = self.costing_options.to_dict()
76
- # override the default output from pydantic by calling `to_dict()` of directions_options
77
- if self.directions_options:
78
- _dict['directions_options'] = self.directions_options.to_dict()
79
107
  # puts key-value pairs in additional_properties in the top level
80
108
  if self.additional_properties is not None:
81
109
  for _key, _value in self.additional_properties.items():
@@ -84,20 +112,22 @@ class OptimizedRouteRequest(BaseModel):
84
112
  return _dict
85
113
 
86
114
  @classmethod
87
- def from_dict(cls, obj: dict) -> OptimizedRouteRequest:
115
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
116
  """Create an instance of OptimizedRouteRequest from a dict"""
89
117
  if obj is None:
90
118
  return None
91
119
 
92
120
  if not isinstance(obj, dict):
93
- return OptimizedRouteRequest.parse_obj(obj)
121
+ return cls.model_validate(obj)
94
122
 
95
- _obj = OptimizedRouteRequest.parse_obj({
123
+ _obj = cls.model_validate({
124
+ "units": obj.get("units"),
125
+ "language": obj.get("language"),
126
+ "directions_type": obj.get("directions_type") if obj.get("directions_type") is not None else 'instructions',
96
127
  "id": obj.get("id"),
97
- "locations": [Coordinate.from_dict(_item) for _item in obj.get("locations")] if obj.get("locations") is not None else None,
128
+ "locations": [Coordinate.from_dict(_item) for _item in obj["locations"]] if obj.get("locations") is not None else None,
98
129
  "costing": obj.get("costing"),
99
- "costing_options": CostingOptions.from_dict(obj.get("costing_options")) if obj.get("costing_options") is not None else None,
100
- "directions_options": DirectionsOptions.from_dict(obj.get("directions_options")) if obj.get("directions_options") is not None else None
130
+ "costing_options": CostingOptions.from_dict(obj["costing_options"]) if obj.get("costing_options") is not None else None
101
131
  })
102
132
  # store additional fields in additional_properties
103
133
  for _key in obj.keys():
@@ -106,3 +136,4 @@ class OptimizedRouteRequest(BaseModel):
106
136
 
107
137
  return _obj
108
138
 
139
+