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,57 +18,74 @@ import pprint
18
18
  import re # noqa: F401
19
19
  import json
20
20
 
21
-
22
- from typing import Optional, Union
23
- from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, validator
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional, Union
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
24
25
 
25
26
  class MatchedPoint(BaseModel):
26
27
  """
27
28
  MatchedPoint
28
- """
29
- lat: Union[StrictFloat, StrictInt] = Field(..., description="The latitude of the matched point.")
30
- lon: Union[StrictFloat, StrictInt] = Field(..., description="The longitude of the matched point.")
31
- type: StrictStr = Field(...)
32
- edge_index: Optional[StrictInt] = Field(None, description="The index of the edge in the list of `edges`. This key will be missing if the point is unmatched.")
33
- begin_route_discontinuity: Optional[StrictBool] = Field(False, description="If true, this match result is the begin location of a route discontinuity.")
34
- end_route_discontinuity: Optional[StrictBool] = Field(False, description="If true, this match result is the end location of a route discontinuity.")
35
- distance_along_edge: Optional[Union[StrictFloat, StrictInt]] = Field(None, description="The distance along the associated edge for this matched point, expressed as a value between 0 and 1. For example, if the matched point is halfway along the edge, then the value will be 0.5. This key will be absent if the point is unmatched.")
36
- distance_from_trace_point: Optional[Union[StrictFloat, StrictInt]] = Field(None, description="The distance in meters from the trace point to the matched point. This key will be absent if the point is unmatched.")
29
+ """ # noqa: E501
30
+ lat: Union[StrictFloat, StrictInt] = Field(description="The latitude of the matched point.")
31
+ lon: Union[StrictFloat, StrictInt] = Field(description="The longitude of the matched point.")
32
+ type: StrictStr
33
+ edge_index: Optional[StrictInt] = Field(default=None, description="The index of the edge in the list of `edges`. This key will be missing if the point is unmatched.")
34
+ begin_route_discontinuity: Optional[StrictBool] = Field(default=False, description="If true, this match result is the begin location of a route discontinuity.")
35
+ end_route_discontinuity: Optional[StrictBool] = Field(default=False, description="If true, this match result is the end location of a route discontinuity.")
36
+ distance_along_edge: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The distance along the associated edge for this matched point, expressed as a value between 0 and 1. For example, if the matched point is halfway along the edge, then the value will be 0.5. This key will be absent if the point is unmatched.")
37
+ distance_from_trace_point: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The distance in meters from the trace point to the matched point. This key will be absent if the point is unmatched.")
37
38
  additional_properties: Dict[str, Any] = {}
38
- __properties = ["lat", "lon", "type", "edge_index", "begin_route_discontinuity", "end_route_discontinuity", "distance_along_edge", "distance_from_trace_point"]
39
+ __properties: ClassVar[List[str]] = ["lat", "lon", "type", "edge_index", "begin_route_discontinuity", "end_route_discontinuity", "distance_along_edge", "distance_from_trace_point"]
39
40
 
40
- @validator('type')
41
+ @field_validator('type')
41
42
  def type_validate_enum(cls, value):
42
43
  """Validates the enum"""
43
- if value not in ('unmatched', 'interpolated', 'matched'):
44
+ if value not in set(['unmatched', 'interpolated', 'matched']):
44
45
  raise ValueError("must be one of enum values ('unmatched', 'interpolated', 'matched')")
45
46
  return value
46
47
 
47
- class Config:
48
- """Pydantic configuration"""
49
- allow_population_by_field_name = True
50
- validate_assignment = True
48
+ model_config = ConfigDict(
49
+ populate_by_name=True,
50
+ validate_assignment=True,
51
+ protected_namespaces=(),
52
+ )
53
+
51
54
 
52
55
  def to_str(self) -> str:
53
56
  """Returns the string representation of the model using alias"""
54
- return pprint.pformat(self.dict(by_alias=True))
57
+ return pprint.pformat(self.model_dump(by_alias=True))
55
58
 
56
59
  def to_json(self) -> str:
57
60
  """Returns the JSON representation of the model using alias"""
61
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
58
62
  return json.dumps(self.to_dict())
59
63
 
60
64
  @classmethod
61
- def from_json(cls, json_str: str) -> MatchedPoint:
65
+ def from_json(cls, json_str: str) -> Optional[Self]:
62
66
  """Create an instance of MatchedPoint from a JSON string"""
63
67
  return cls.from_dict(json.loads(json_str))
64
68
 
65
- def to_dict(self):
66
- """Returns the dictionary representation of the model using alias"""
67
- _dict = self.dict(by_alias=True,
68
- exclude={
69
- "additional_properties"
70
- },
71
- exclude_none=True)
69
+ def to_dict(self) -> Dict[str, Any]:
70
+ """Return the dictionary representation of the model using alias.
71
+
72
+ This has the following differences from calling pydantic's
73
+ `self.model_dump(by_alias=True)`:
74
+
75
+ * `None` is only added to the output dict for nullable fields that
76
+ were set at model initialization. Other fields with value `None`
77
+ are ignored.
78
+ * Fields in `self.additional_properties` are added to the output dict.
79
+ """
80
+ excluded_fields: Set[str] = set([
81
+ "additional_properties",
82
+ ])
83
+
84
+ _dict = self.model_dump(
85
+ by_alias=True,
86
+ exclude=excluded_fields,
87
+ exclude_none=True,
88
+ )
72
89
  # puts key-value pairs in additional_properties in the top level
73
90
  if self.additional_properties is not None:
74
91
  for _key, _value in self.additional_properties.items():
@@ -77,15 +94,15 @@ class MatchedPoint(BaseModel):
77
94
  return _dict
78
95
 
79
96
  @classmethod
80
- def from_dict(cls, obj: dict) -> MatchedPoint:
97
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81
98
  """Create an instance of MatchedPoint from a dict"""
82
99
  if obj is None:
83
100
  return None
84
101
 
85
102
  if not isinstance(obj, dict):
86
- return MatchedPoint.parse_obj(obj)
103
+ return cls.model_validate(obj)
87
104
 
88
- _obj = MatchedPoint.parse_obj({
105
+ _obj = cls.model_validate({
89
106
  "lat": obj.get("lat"),
90
107
  "lon": obj.get("lon"),
91
108
  "type": obj.get("type"),
@@ -102,3 +119,4 @@ class MatchedPoint(BaseModel):
102
119
 
103
120
  return _obj
104
121
 
122
+
@@ -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 MatrixCostingModel(str, Enum):
@@ -32,7 +29,6 @@ class MatrixCostingModel(str, Enum):
32
29
  """
33
30
  AUTO = 'auto'
34
31
  BUS = 'bus'
35
- HOV = 'hov'
36
32
  TAXI = 'taxi'
37
33
  TRUCK = 'truck'
38
34
  BICYCLE = 'bicycle'
@@ -40,10 +36,11 @@ class MatrixCostingModel(str, Enum):
40
36
  MOTOR_SCOOTER = 'motor_scooter'
41
37
  MOTORCYCLE = 'motorcycle'
42
38
  PEDESTRIAN = 'pedestrian'
39
+ LOW_SPEED_VEHICLE = 'low_speed_vehicle'
43
40
 
44
41
  @classmethod
45
- def from_json(cls, json_str: str) -> MatrixCostingModel:
42
+ def from_json(cls, json_str: str) -> Self:
46
43
  """Create an instance of MatrixCostingModel from a JSON string"""
47
- return MatrixCostingModel(json.loads(json_str))
44
+ return cls(json.loads(json_str))
48
45
 
49
46
 
@@ -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 Union
23
- from pydantic import BaseModel, Field, StrictFloat, StrictInt
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Union
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
24
25
 
25
26
  class MatrixDistance(BaseModel):
26
27
  """
27
28
  MatrixDistance
28
- """
29
- distance: Union[StrictFloat, StrictInt] = Field(..., description="The distance (in `units`) between the location in `sources` at `from_index` and the location in `targets` at `to_index`.")
30
- time: StrictInt = Field(..., description="The travel time (in seconds) between the location in `sources` at `from_index` and the location in `targets` at `to_index`.")
31
- from_index: StrictInt = Field(..., description="The index of the start location in the `sources` array.")
32
- to_index: StrictInt = Field(..., description="The index of the end location in the `targets` array.")
29
+ """ # noqa: E501
30
+ distance: Union[StrictFloat, StrictInt] = Field(description="The distance (in `units`) between the location in `sources` at `from_index` and the location in `targets` at `to_index`.")
31
+ time: StrictInt = Field(description="The travel time (in seconds) between the location in `sources` at `from_index` and the location in `targets` at `to_index`.")
32
+ from_index: StrictInt = Field(description="The index of the start location in the `sources` array.")
33
+ to_index: StrictInt = Field(description="The index of the end location in the `targets` array.")
33
34
  additional_properties: Dict[str, Any] = {}
34
- __properties = ["distance", "time", "from_index", "to_index"]
35
+ __properties: ClassVar[List[str]] = ["distance", "time", "from_index", "to_index"]
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) -> MatrixDistance:
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
55
  """Create an instance of MatrixDistance 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 MatrixDistance(BaseModel):
66
83
  return _dict
67
84
 
68
85
  @classmethod
69
- def from_dict(cls, obj: dict) -> MatrixDistance:
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
70
87
  """Create an instance of MatrixDistance from a dict"""
71
88
  if obj is None:
72
89
  return None
73
90
 
74
91
  if not isinstance(obj, dict):
75
- return MatrixDistance.parse_obj(obj)
92
+ return cls.model_validate(obj)
76
93
 
77
- _obj = MatrixDistance.parse_obj({
94
+ _obj = cls.model_validate({
78
95
  "distance": obj.get("distance"),
79
96
  "time": obj.get("time"),
80
97
  "from_index": obj.get("from_index"),
@@ -87,3 +104,4 @@ class MatrixDistance(BaseModel):
87
104
 
88
105
  return _obj
89
106
 
107
+
@@ -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,53 +18,84 @@ 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, StrictInt, StrictStr, conlist
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, 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 MatrixRequest(BaseModel):
30
33
  """
31
34
  MatrixRequest
32
- """
33
- id: Optional[StrictStr] = Field(None, description="An identifier to disambiguate requests (echoed by the server).")
34
- sources: conlist(Coordinate, min_items=1) = Field(..., description="The list of starting locations")
35
- targets: conlist(Coordinate, min_items=1) = Field(..., description="The list of ending locations")
36
- 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
+ sources: Annotated[List[Coordinate], Field(min_length=1)] = Field(description="The list of starting locations")
41
+ targets: Annotated[List[Coordinate], Field(min_length=1)] = Field(description="The list of ending locations")
42
+ costing: MatrixCostingModel
37
43
  costing_options: Optional[CostingOptions] = None
38
- matrix_locations: Optional[StrictInt] = Field(None, description="Only applicable to one-to-many or many-to-one requests. This defaults to all locations. When specified explicitly, this option allows a partial result to be returned. This is basically equivalent to \"find the closest/best locations out of the full set.\" This can have a dramatic improvement for large requests.")
39
- directions_options: Optional[DirectionsOptions] = None
44
+ matrix_locations: Optional[StrictInt] = Field(default=None, description="Only applicable to one-to-many or many-to-one requests. This defaults to all locations. When specified explicitly, this option allows a partial result to be returned. This is basically equivalent to \"find the closest/best locations out of the full set.\" This can have a dramatic improvement for large requests.")
40
45
  additional_properties: Dict[str, Any] = {}
41
- __properties = ["id", "sources", "targets", "costing", "costing_options", "matrix_locations", "directions_options"]
46
+ __properties: ClassVar[List[str]] = ["units", "language", "directions_type", "id", "sources", "targets", "costing", "costing_options", "matrix_locations"]
47
+
48
+ @field_validator('directions_type')
49
+ def directions_type_validate_enum(cls, value):
50
+ """Validates the enum"""
51
+ if value is None:
52
+ return value
53
+
54
+ if value not in set(['none', 'maneuvers', 'instructions']):
55
+ raise ValueError("must be one of enum values ('none', 'maneuvers', 'instructions')")
56
+ return value
57
+
58
+ model_config = ConfigDict(
59
+ populate_by_name=True,
60
+ validate_assignment=True,
61
+ protected_namespaces=(),
62
+ )
42
63
 
43
- class Config:
44
- """Pydantic configuration"""
45
- allow_population_by_field_name = True
46
- validate_assignment = True
47
64
 
48
65
  def to_str(self) -> str:
49
66
  """Returns the string representation of the model using alias"""
50
- return pprint.pformat(self.dict(by_alias=True))
67
+ return pprint.pformat(self.model_dump(by_alias=True))
51
68
 
52
69
  def to_json(self) -> str:
53
70
  """Returns the JSON representation of the model using alias"""
71
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
72
  return json.dumps(self.to_dict())
55
73
 
56
74
  @classmethod
57
- def from_json(cls, json_str: str) -> MatrixRequest:
75
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
76
  """Create an instance of MatrixRequest from a JSON string"""
59
77
  return cls.from_dict(json.loads(json_str))
60
78
 
61
- def to_dict(self):
62
- """Returns the dictionary representation of the model using alias"""
63
- _dict = self.dict(by_alias=True,
64
- exclude={
65
- "additional_properties"
66
- },
67
- exclude_none=True)
79
+ def to_dict(self) -> Dict[str, Any]:
80
+ """Return the dictionary representation of the model using alias.
81
+
82
+ This has the following differences from calling pydantic's
83
+ `self.model_dump(by_alias=True)`:
84
+
85
+ * `None` is only added to the output dict for nullable fields that
86
+ were set at model initialization. Other fields with value `None`
87
+ are ignored.
88
+ * Fields in `self.additional_properties` are added to the output dict.
89
+ """
90
+ excluded_fields: Set[str] = set([
91
+ "additional_properties",
92
+ ])
93
+
94
+ _dict = self.model_dump(
95
+ by_alias=True,
96
+ exclude=excluded_fields,
97
+ exclude_none=True,
98
+ )
68
99
  # override the default output from pydantic by calling `to_dict()` of each item in sources (list)
69
100
  _items = []
70
101
  if self.sources:
@@ -82,9 +113,6 @@ class MatrixRequest(BaseModel):
82
113
  # override the default output from pydantic by calling `to_dict()` of costing_options
83
114
  if self.costing_options:
84
115
  _dict['costing_options'] = self.costing_options.to_dict()
85
- # override the default output from pydantic by calling `to_dict()` of directions_options
86
- if self.directions_options:
87
- _dict['directions_options'] = self.directions_options.to_dict()
88
116
  # puts key-value pairs in additional_properties in the top level
89
117
  if self.additional_properties is not None:
90
118
  for _key, _value in self.additional_properties.items():
@@ -93,22 +121,24 @@ class MatrixRequest(BaseModel):
93
121
  return _dict
94
122
 
95
123
  @classmethod
96
- def from_dict(cls, obj: dict) -> MatrixRequest:
124
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
97
125
  """Create an instance of MatrixRequest from a dict"""
98
126
  if obj is None:
99
127
  return None
100
128
 
101
129
  if not isinstance(obj, dict):
102
- return MatrixRequest.parse_obj(obj)
130
+ return cls.model_validate(obj)
103
131
 
104
- _obj = MatrixRequest.parse_obj({
132
+ _obj = cls.model_validate({
133
+ "units": obj.get("units"),
134
+ "language": obj.get("language"),
135
+ "directions_type": obj.get("directions_type") if obj.get("directions_type") is not None else 'instructions',
105
136
  "id": obj.get("id"),
106
- "sources": [Coordinate.from_dict(_item) for _item in obj.get("sources")] if obj.get("sources") is not None else None,
107
- "targets": [Coordinate.from_dict(_item) for _item in obj.get("targets")] if obj.get("targets") is not None else None,
137
+ "sources": [Coordinate.from_dict(_item) for _item in obj["sources"]] if obj.get("sources") is not None else None,
138
+ "targets": [Coordinate.from_dict(_item) for _item in obj["targets"]] if obj.get("targets") is not None else None,
108
139
  "costing": obj.get("costing"),
109
- "costing_options": CostingOptions.from_dict(obj.get("costing_options")) if obj.get("costing_options") is not None else None,
110
- "matrix_locations": obj.get("matrix_locations"),
111
- "directions_options": DirectionsOptions.from_dict(obj.get("directions_options")) if obj.get("directions_options") is not None else None
140
+ "costing_options": CostingOptions.from_dict(obj["costing_options"]) if obj.get("costing_options") is not None else None,
141
+ "matrix_locations": obj.get("matrix_locations")
112
142
  })
113
143
  # store additional fields in additional_properties
114
144
  for _key in obj.keys():
@@ -117,3 +147,4 @@ class MatrixRequest(BaseModel):
117
147
 
118
148
  return _obj
119
149
 
150
+