Skip to content

Commit fc1679d

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#4)
1 parent 589201b commit fc1679d

File tree

13 files changed

+597
-12
lines changed

13 files changed

+597
-12
lines changed

.github/workflows/release-doctor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Release Doctor
22
on:
33
pull_request:
4+
branches:
5+
- main
46
workflow_dispatch:
57

68
jobs:

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 12
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-d7feb31fedeae9f0af2581bf85d95d374eb2eee635e6823975bc4f419bd8e492.yml
1+
configured_endpoints: 13
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-6c051801071707e025c582891048beeb3c06d10d13c852f8401a71604b81ac5d.yml

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
1010

1111
## Documentation
1212

13-
The REST API documentation can be found [on developer.onebusaway.org](https://developer.onebusaway.org). The full API of this library can be found in [api.md](api.md).
13+
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). The full API of this library can be found in [api.md](api.md).
1414

1515
## Installation
1616

@@ -277,6 +277,12 @@ client = OnebusawaySDK(
277277
)
278278
```
279279

280+
You can also customize the client on a per-request basis by using `with_options()`:
281+
282+
```python
283+
client.with_options(http_client=DefaultHttpxClient(...))
284+
```
285+
280286
### Managing HTTP resources
281287

282288
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,15 @@ from onebusaway.types import TripDetailRetrieveResponse
136136
Methods:
137137

138138
- <code title="get /api/where/trip-details/{tripID}.json">client.trip_details.<a href="./src/onebusaway/resources/trip_details.py">retrieve</a>(trip_id, \*\*<a href="src/onebusaway/types/trip_detail_retrieve_params.py">params</a>) -> <a href="./src/onebusaway/types/trip_detail_retrieve_response.py">TripDetailRetrieveResponse</a></code>
139+
140+
# TripForVehicle
141+
142+
Types:
143+
144+
```python
145+
from onebusaway.types import TripForVehicleRetrieveResponse
146+
```
147+
148+
Methods:
149+
150+
- <code title="get /api/where/trip-for-vehicle/{vehicleID}.json">client.trip_for_vehicle.<a href="./src/onebusaway/resources/trip_for_vehicle.py">retrieve</a>(vehicle_id, \*\*<a href="src/onebusaway/types/trip_for_vehicle_retrieve_params.py">params</a>) -> <a href="./src/onebusaway/types/trip_for_vehicle_retrieve_response.py">TripForVehicleRetrieveResponse</a></code>

src/onebusaway/_base_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,9 @@ def __exit__(
879879
def _prepare_options(
880880
self,
881881
options: FinalRequestOptions, # noqa: ARG002
882-
) -> None:
882+
) -> FinalRequestOptions:
883883
"""Hook for mutating the given options"""
884-
return None
884+
return options
885885

886886
def _prepare_request(
887887
self,
@@ -961,7 +961,7 @@ def _request(
961961
input_options = model_copy(options)
962962

963963
cast_to = self._maybe_override_cast_to(cast_to, options)
964-
self._prepare_options(options)
964+
options = self._prepare_options(options)
965965

966966
retries = self._remaining_retries(remaining_retries, options)
967967
request = self._build_request(options)
@@ -1442,9 +1442,9 @@ async def __aexit__(
14421442
async def _prepare_options(
14431443
self,
14441444
options: FinalRequestOptions, # noqa: ARG002
1445-
) -> None:
1445+
) -> FinalRequestOptions:
14461446
"""Hook for mutating the given options"""
1447-
return None
1447+
return options
14481448

14491449
async def _prepare_request(
14501450
self,
@@ -1529,7 +1529,7 @@ async def _request(
15291529
input_options = model_copy(options)
15301530

15311531
cast_to = self._maybe_override_cast_to(cast_to, options)
1532-
await self._prepare_options(options)
1532+
options = await self._prepare_options(options)
15331533

15341534
retries = self._remaining_retries(remaining_retries, options)
15351535
request = self._build_request(options)

src/onebusaway/_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class OnebusawaySDK(SyncAPIClient):
5757
trip: resources.TripResource
5858
trips_for_location: resources.TripsForLocationResource
5959
trip_details: resources.TripDetailsResource
60+
trip_for_vehicle: resources.TripForVehicleResource
6061
with_raw_response: OnebusawaySDKWithRawResponse
6162
with_streaming_response: OnebusawaySDKWithStreamedResponse
6263

@@ -125,6 +126,7 @@ def __init__(
125126
self.trip = resources.TripResource(self)
126127
self.trips_for_location = resources.TripsForLocationResource(self)
127128
self.trip_details = resources.TripDetailsResource(self)
129+
self.trip_for_vehicle = resources.TripForVehicleResource(self)
128130
self.with_raw_response = OnebusawaySDKWithRawResponse(self)
129131
self.with_streaming_response = OnebusawaySDKWithStreamedResponse(self)
130132

@@ -253,6 +255,7 @@ class AsyncOnebusawaySDK(AsyncAPIClient):
253255
trip: resources.AsyncTripResource
254256
trips_for_location: resources.AsyncTripsForLocationResource
255257
trip_details: resources.AsyncTripDetailsResource
258+
trip_for_vehicle: resources.AsyncTripForVehicleResource
256259
with_raw_response: AsyncOnebusawaySDKWithRawResponse
257260
with_streaming_response: AsyncOnebusawaySDKWithStreamedResponse
258261

@@ -321,6 +324,7 @@ def __init__(
321324
self.trip = resources.AsyncTripResource(self)
322325
self.trips_for_location = resources.AsyncTripsForLocationResource(self)
323326
self.trip_details = resources.AsyncTripDetailsResource(self)
327+
self.trip_for_vehicle = resources.AsyncTripForVehicleResource(self)
324328
self.with_raw_response = AsyncOnebusawaySDKWithRawResponse(self)
325329
self.with_streaming_response = AsyncOnebusawaySDKWithStreamedResponse(self)
326330

@@ -452,6 +456,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
452456
self.trip = resources.TripResourceWithRawResponse(client.trip)
453457
self.trips_for_location = resources.TripsForLocationResourceWithRawResponse(client.trips_for_location)
454458
self.trip_details = resources.TripDetailsResourceWithRawResponse(client.trip_details)
459+
self.trip_for_vehicle = resources.TripForVehicleResourceWithRawResponse(client.trip_for_vehicle)
455460

456461

457462
class AsyncOnebusawaySDKWithRawResponse:
@@ -471,6 +476,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
471476
self.trip = resources.AsyncTripResourceWithRawResponse(client.trip)
472477
self.trips_for_location = resources.AsyncTripsForLocationResourceWithRawResponse(client.trips_for_location)
473478
self.trip_details = resources.AsyncTripDetailsResourceWithRawResponse(client.trip_details)
479+
self.trip_for_vehicle = resources.AsyncTripForVehicleResourceWithRawResponse(client.trip_for_vehicle)
474480

475481

476482
class OnebusawaySDKWithStreamedResponse:
@@ -490,6 +496,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
490496
self.trip = resources.TripResourceWithStreamingResponse(client.trip)
491497
self.trips_for_location = resources.TripsForLocationResourceWithStreamingResponse(client.trips_for_location)
492498
self.trip_details = resources.TripDetailsResourceWithStreamingResponse(client.trip_details)
499+
self.trip_for_vehicle = resources.TripForVehicleResourceWithStreamingResponse(client.trip_for_vehicle)
493500

494501

495502
class AsyncOnebusawaySDKWithStreamedResponse:
@@ -513,6 +520,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
513520
client.trips_for_location
514521
)
515522
self.trip_details = resources.AsyncTripDetailsResourceWithStreamingResponse(client.trip_details)
523+
self.trip_for_vehicle = resources.AsyncTripForVehicleResourceWithStreamingResponse(client.trip_for_vehicle)
516524

517525

518526
Client = OnebusawaySDK

src/onebusaway/_compat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]:
118118
return model.__fields__ # type: ignore
119119

120120

121-
def model_copy(model: _ModelT) -> _ModelT:
121+
def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT:
122122
if PYDANTIC_V2:
123-
return model.model_copy()
124-
return model.copy() # type: ignore
123+
return model.model_copy(deep=deep)
124+
return model.copy(deep=deep) # type: ignore
125125

126126

127127
def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:

src/onebusaway/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
StopsForRouteResourceWithStreamingResponse,
5757
AsyncStopsForRouteResourceWithStreamingResponse,
5858
)
59+
from .trip_for_vehicle import (
60+
TripForVehicleResource,
61+
AsyncTripForVehicleResource,
62+
TripForVehicleResourceWithRawResponse,
63+
AsyncTripForVehicleResourceWithRawResponse,
64+
TripForVehicleResourceWithStreamingResponse,
65+
AsyncTripForVehicleResourceWithStreamingResponse,
66+
)
5967
from .stops_for_location import (
6068
StopsForLocationResource,
6169
AsyncStopsForLocationResource,
@@ -156,4 +164,10 @@
156164
"AsyncTripDetailsResourceWithRawResponse",
157165
"TripDetailsResourceWithStreamingResponse",
158166
"AsyncTripDetailsResourceWithStreamingResponse",
167+
"TripForVehicleResource",
168+
"AsyncTripForVehicleResource",
169+
"TripForVehicleResourceWithRawResponse",
170+
"AsyncTripForVehicleResourceWithRawResponse",
171+
"TripForVehicleResourceWithStreamingResponse",
172+
"AsyncTripForVehicleResourceWithStreamingResponse",
159173
]
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import httpx
6+
7+
from ..types import trip_for_vehicle_retrieve_params
8+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9+
from .._utils import (
10+
maybe_transform,
11+
async_maybe_transform,
12+
)
13+
from .._compat import cached_property
14+
from .._resource import SyncAPIResource, AsyncAPIResource
15+
from .._response import (
16+
to_raw_response_wrapper,
17+
to_streamed_response_wrapper,
18+
async_to_raw_response_wrapper,
19+
async_to_streamed_response_wrapper,
20+
)
21+
from .._base_client import make_request_options
22+
from ..types.trip_for_vehicle_retrieve_response import TripForVehicleRetrieveResponse
23+
24+
__all__ = ["TripForVehicleResource", "AsyncTripForVehicleResource"]
25+
26+
27+
class TripForVehicleResource(SyncAPIResource):
28+
@cached_property
29+
def with_raw_response(self) -> TripForVehicleResourceWithRawResponse:
30+
return TripForVehicleResourceWithRawResponse(self)
31+
32+
@cached_property
33+
def with_streaming_response(self) -> TripForVehicleResourceWithStreamingResponse:
34+
return TripForVehicleResourceWithStreamingResponse(self)
35+
36+
def retrieve(
37+
self,
38+
vehicle_id: str,
39+
*,
40+
include_schedule: bool | NotGiven = NOT_GIVEN,
41+
include_status: bool | NotGiven = NOT_GIVEN,
42+
include_trip: bool | NotGiven = NOT_GIVEN,
43+
time: int | NotGiven = NOT_GIVEN,
44+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
45+
# The extra values given here take precedence over values defined on the client or passed to this method.
46+
extra_headers: Headers | None = None,
47+
extra_query: Query | None = None,
48+
extra_body: Body | None = None,
49+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
50+
) -> TripForVehicleRetrieveResponse:
51+
"""
52+
Retrieve trip for a specific vehicle
53+
54+
Args:
55+
include_schedule: Determines whether full <schedule/> element is included in the <tripDetails/>
56+
section. Defaults to false.
57+
58+
include_status: Determines whether the full <status/> element is included in the <tripDetails/>
59+
section. Defaults to true.
60+
61+
include_trip: Determines whether full <trip/> element is included in the <references/>
62+
section. Defaults to false.
63+
64+
time: Time parameter to query the system at a specific time (optional).
65+
66+
extra_headers: Send extra headers
67+
68+
extra_query: Add additional query parameters to the request
69+
70+
extra_body: Add additional JSON properties to the request
71+
72+
timeout: Override the client-level default timeout for this request, in seconds
73+
"""
74+
if not vehicle_id:
75+
raise ValueError(f"Expected a non-empty value for `vehicle_id` but received {vehicle_id!r}")
76+
return self._get(
77+
f"/api/where/trip-for-vehicle/vehicleID.json",
78+
options=make_request_options(
79+
extra_headers=extra_headers,
80+
extra_query=extra_query,
81+
extra_body=extra_body,
82+
timeout=timeout,
83+
query=maybe_transform(
84+
{
85+
"include_schedule": include_schedule,
86+
"include_status": include_status,
87+
"include_trip": include_trip,
88+
"time": time,
89+
},
90+
trip_for_vehicle_retrieve_params.TripForVehicleRetrieveParams,
91+
),
92+
),
93+
cast_to=TripForVehicleRetrieveResponse,
94+
)
95+
96+
97+
class AsyncTripForVehicleResource(AsyncAPIResource):
98+
@cached_property
99+
def with_raw_response(self) -> AsyncTripForVehicleResourceWithRawResponse:
100+
return AsyncTripForVehicleResourceWithRawResponse(self)
101+
102+
@cached_property
103+
def with_streaming_response(self) -> AsyncTripForVehicleResourceWithStreamingResponse:
104+
return AsyncTripForVehicleResourceWithStreamingResponse(self)
105+
106+
async def retrieve(
107+
self,
108+
vehicle_id: str,
109+
*,
110+
include_schedule: bool | NotGiven = NOT_GIVEN,
111+
include_status: bool | NotGiven = NOT_GIVEN,
112+
include_trip: bool | NotGiven = NOT_GIVEN,
113+
time: int | NotGiven = NOT_GIVEN,
114+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
115+
# The extra values given here take precedence over values defined on the client or passed to this method.
116+
extra_headers: Headers | None = None,
117+
extra_query: Query | None = None,
118+
extra_body: Body | None = None,
119+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
120+
) -> TripForVehicleRetrieveResponse:
121+
"""
122+
Retrieve trip for a specific vehicle
123+
124+
Args:
125+
include_schedule: Determines whether full <schedule/> element is included in the <tripDetails/>
126+
section. Defaults to false.
127+
128+
include_status: Determines whether the full <status/> element is included in the <tripDetails/>
129+
section. Defaults to true.
130+
131+
include_trip: Determines whether full <trip/> element is included in the <references/>
132+
section. Defaults to false.
133+
134+
time: Time parameter to query the system at a specific time (optional).
135+
136+
extra_headers: Send extra headers
137+
138+
extra_query: Add additional query parameters to the request
139+
140+
extra_body: Add additional JSON properties to the request
141+
142+
timeout: Override the client-level default timeout for this request, in seconds
143+
"""
144+
if not vehicle_id:
145+
raise ValueError(f"Expected a non-empty value for `vehicle_id` but received {vehicle_id!r}")
146+
return await self._get(
147+
f"/api/where/trip-for-vehicle/vehicleID.json",
148+
options=make_request_options(
149+
extra_headers=extra_headers,
150+
extra_query=extra_query,
151+
extra_body=extra_body,
152+
timeout=timeout,
153+
query=await async_maybe_transform(
154+
{
155+
"include_schedule": include_schedule,
156+
"include_status": include_status,
157+
"include_trip": include_trip,
158+
"time": time,
159+
},
160+
trip_for_vehicle_retrieve_params.TripForVehicleRetrieveParams,
161+
),
162+
),
163+
cast_to=TripForVehicleRetrieveResponse,
164+
)
165+
166+
167+
class TripForVehicleResourceWithRawResponse:
168+
def __init__(self, trip_for_vehicle: TripForVehicleResource) -> None:
169+
self._trip_for_vehicle = trip_for_vehicle
170+
171+
self.retrieve = to_raw_response_wrapper(
172+
trip_for_vehicle.retrieve,
173+
)
174+
175+
176+
class AsyncTripForVehicleResourceWithRawResponse:
177+
def __init__(self, trip_for_vehicle: AsyncTripForVehicleResource) -> None:
178+
self._trip_for_vehicle = trip_for_vehicle
179+
180+
self.retrieve = async_to_raw_response_wrapper(
181+
trip_for_vehicle.retrieve,
182+
)
183+
184+
185+
class TripForVehicleResourceWithStreamingResponse:
186+
def __init__(self, trip_for_vehicle: TripForVehicleResource) -> None:
187+
self._trip_for_vehicle = trip_for_vehicle
188+
189+
self.retrieve = to_streamed_response_wrapper(
190+
trip_for_vehicle.retrieve,
191+
)
192+
193+
194+
class AsyncTripForVehicleResourceWithStreamingResponse:
195+
def __init__(self, trip_for_vehicle: AsyncTripForVehicleResource) -> None:
196+
self._trip_for_vehicle = trip_for_vehicle
197+
198+
self.retrieve = async_to_streamed_response_wrapper(
199+
trip_for_vehicle.retrieve,
200+
)

0 commit comments

Comments
 (0)