Skip to content

Commit a5c305c

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#48)
1 parent c58e171 commit a5c305c

File tree

8 files changed

+303
-2
lines changed

8 files changed

+303
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 17
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-e1da29690ebfb4c6c07ede3d292a4f6babcd2202d6f3bb38bfa287ae04dfeb50.yml
1+
configured_endpoints: 18
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-745fc14b503259d6b0d29d50d4277b86cada74faf6f831bb19710d2e7ead8a7c.yml

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ Methods:
136136

137137
- <code title="get /api/where/route/{routeID}.json">client.route.<a href="./src/onebusaway/resources/route.py">retrieve</a>(route_id) -> <a href="./src/onebusaway/types/route_retrieve_response.py">RouteRetrieveResponse</a></code>
138138

139+
# RouteIDsForAgency
140+
141+
Types:
142+
143+
```python
144+
from onebusaway.types import RouteIDsForAgencyListResponse
145+
```
146+
147+
Methods:
148+
149+
- <code title="get /api/where/route-ids-for-agency/{agencyID}.json">client.route_ids_for_agency.<a href="./src/onebusaway/resources/route_ids_for_agency.py">list</a>(agency_id) -> <a href="./src/onebusaway/types/route_ids_for_agency_list_response.py">RouteIDsForAgencyListResponse</a></code>
150+
139151
# ArrivalAndDeparture
140152

141153
Types:

src/onebusaway/_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class OnebusawaySDK(SyncAPIClient):
5757
stop_ids_for_agency: resources.StopIDsForAgencyResource
5858
schedule_for_stop: resources.ScheduleForStopResource
5959
route: resources.RouteResource
60+
route_ids_for_agency: resources.RouteIDsForAgencyResource
6061
arrival_and_departure: resources.ArrivalAndDepartureResource
6162
trip: resources.TripResource
6263
trips_for_location: resources.TripsForLocationResource
@@ -130,6 +131,7 @@ def __init__(
130131
self.stop_ids_for_agency = resources.StopIDsForAgencyResource(self)
131132
self.schedule_for_stop = resources.ScheduleForStopResource(self)
132133
self.route = resources.RouteResource(self)
134+
self.route_ids_for_agency = resources.RouteIDsForAgencyResource(self)
133135
self.arrival_and_departure = resources.ArrivalAndDepartureResource(self)
134136
self.trip = resources.TripResource(self)
135137
self.trips_for_location = resources.TripsForLocationResource(self)
@@ -263,6 +265,7 @@ class AsyncOnebusawaySDK(AsyncAPIClient):
263265
stop_ids_for_agency: resources.AsyncStopIDsForAgencyResource
264266
schedule_for_stop: resources.AsyncScheduleForStopResource
265267
route: resources.AsyncRouteResource
268+
route_ids_for_agency: resources.AsyncRouteIDsForAgencyResource
266269
arrival_and_departure: resources.AsyncArrivalAndDepartureResource
267270
trip: resources.AsyncTripResource
268271
trips_for_location: resources.AsyncTripsForLocationResource
@@ -336,6 +339,7 @@ def __init__(
336339
self.stop_ids_for_agency = resources.AsyncStopIDsForAgencyResource(self)
337340
self.schedule_for_stop = resources.AsyncScheduleForStopResource(self)
338341
self.route = resources.AsyncRouteResource(self)
342+
self.route_ids_for_agency = resources.AsyncRouteIDsForAgencyResource(self)
339343
self.arrival_and_departure = resources.AsyncArrivalAndDepartureResource(self)
340344
self.trip = resources.AsyncTripResource(self)
341345
self.trips_for_location = resources.AsyncTripsForLocationResource(self)
@@ -472,6 +476,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
472476
self.stop_ids_for_agency = resources.StopIDsForAgencyResourceWithRawResponse(client.stop_ids_for_agency)
473477
self.schedule_for_stop = resources.ScheduleForStopResourceWithRawResponse(client.schedule_for_stop)
474478
self.route = resources.RouteResourceWithRawResponse(client.route)
479+
self.route_ids_for_agency = resources.RouteIDsForAgencyResourceWithRawResponse(client.route_ids_for_agency)
475480
self.arrival_and_departure = resources.ArrivalAndDepartureResourceWithRawResponse(client.arrival_and_departure)
476481
self.trip = resources.TripResourceWithRawResponse(client.trip)
477482
self.trips_for_location = resources.TripsForLocationResourceWithRawResponse(client.trips_for_location)
@@ -494,6 +499,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
494499
self.stop_ids_for_agency = resources.AsyncStopIDsForAgencyResourceWithRawResponse(client.stop_ids_for_agency)
495500
self.schedule_for_stop = resources.AsyncScheduleForStopResourceWithRawResponse(client.schedule_for_stop)
496501
self.route = resources.AsyncRouteResourceWithRawResponse(client.route)
502+
self.route_ids_for_agency = resources.AsyncRouteIDsForAgencyResourceWithRawResponse(client.route_ids_for_agency)
497503
self.arrival_and_departure = resources.AsyncArrivalAndDepartureResourceWithRawResponse(
498504
client.arrival_and_departure
499505
)
@@ -518,6 +524,9 @@ def __init__(self, client: OnebusawaySDK) -> None:
518524
self.stop_ids_for_agency = resources.StopIDsForAgencyResourceWithStreamingResponse(client.stop_ids_for_agency)
519525
self.schedule_for_stop = resources.ScheduleForStopResourceWithStreamingResponse(client.schedule_for_stop)
520526
self.route = resources.RouteResourceWithStreamingResponse(client.route)
527+
self.route_ids_for_agency = resources.RouteIDsForAgencyResourceWithStreamingResponse(
528+
client.route_ids_for_agency
529+
)
521530
self.arrival_and_departure = resources.ArrivalAndDepartureResourceWithStreamingResponse(
522531
client.arrival_and_departure
523532
)
@@ -548,6 +557,9 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
548557
)
549558
self.schedule_for_stop = resources.AsyncScheduleForStopResourceWithStreamingResponse(client.schedule_for_stop)
550559
self.route = resources.AsyncRouteResourceWithStreamingResponse(client.route)
560+
self.route_ids_for_agency = resources.AsyncRouteIDsForAgencyResourceWithStreamingResponse(
561+
client.route_ids_for_agency
562+
)
551563
self.arrival_and_departure = resources.AsyncArrivalAndDepartureResourceWithStreamingResponse(
552564
client.arrival_and_departure
553565
)

src/onebusaway/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@
112112
VehiclesForAgencyResourceWithStreamingResponse,
113113
AsyncVehiclesForAgencyResourceWithStreamingResponse,
114114
)
115+
from .route_ids_for_agency import (
116+
RouteIDsForAgencyResource,
117+
AsyncRouteIDsForAgencyResource,
118+
RouteIDsForAgencyResourceWithRawResponse,
119+
AsyncRouteIDsForAgencyResourceWithRawResponse,
120+
RouteIDsForAgencyResourceWithStreamingResponse,
121+
AsyncRouteIDsForAgencyResourceWithStreamingResponse,
122+
)
115123
from .arrival_and_departure import (
116124
ArrivalAndDepartureResource,
117125
AsyncArrivalAndDepartureResource,
@@ -196,6 +204,12 @@
196204
"AsyncRouteResourceWithRawResponse",
197205
"RouteResourceWithStreamingResponse",
198206
"AsyncRouteResourceWithStreamingResponse",
207+
"RouteIDsForAgencyResource",
208+
"AsyncRouteIDsForAgencyResource",
209+
"RouteIDsForAgencyResourceWithRawResponse",
210+
"AsyncRouteIDsForAgencyResourceWithRawResponse",
211+
"RouteIDsForAgencyResourceWithStreamingResponse",
212+
"AsyncRouteIDsForAgencyResourceWithStreamingResponse",
199213
"ArrivalAndDepartureResource",
200214
"AsyncArrivalAndDepartureResource",
201215
"ArrivalAndDepartureResourceWithRawResponse",
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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 NOT_GIVEN, Body, Query, Headers, NotGiven
8+
from .._compat import cached_property
9+
from .._resource import SyncAPIResource, AsyncAPIResource
10+
from .._response import (
11+
to_raw_response_wrapper,
12+
to_streamed_response_wrapper,
13+
async_to_raw_response_wrapper,
14+
async_to_streamed_response_wrapper,
15+
)
16+
from .._base_client import make_request_options
17+
from ..types.route_ids_for_agency_list_response import RouteIDsForAgencyListResponse
18+
19+
__all__ = ["RouteIDsForAgencyResource", "AsyncRouteIDsForAgencyResource"]
20+
21+
22+
class RouteIDsForAgencyResource(SyncAPIResource):
23+
@cached_property
24+
def with_raw_response(self) -> RouteIDsForAgencyResourceWithRawResponse:
25+
return RouteIDsForAgencyResourceWithRawResponse(self)
26+
27+
@cached_property
28+
def with_streaming_response(self) -> RouteIDsForAgencyResourceWithStreamingResponse:
29+
return RouteIDsForAgencyResourceWithStreamingResponse(self)
30+
31+
def list(
32+
self,
33+
agency_id: str,
34+
*,
35+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
36+
# The extra values given here take precedence over values defined on the client or passed to this method.
37+
extra_headers: Headers | None = None,
38+
extra_query: Query | None = None,
39+
extra_body: Body | None = None,
40+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
41+
) -> RouteIDsForAgencyListResponse:
42+
"""
43+
Get route IDs for a specific agency
44+
45+
Args:
46+
extra_headers: Send extra headers
47+
48+
extra_query: Add additional query parameters to the request
49+
50+
extra_body: Add additional JSON properties to the request
51+
52+
timeout: Override the client-level default timeout for this request, in seconds
53+
"""
54+
if not agency_id:
55+
raise ValueError(f"Expected a non-empty value for `agency_id` but received {agency_id!r}")
56+
return self._get(
57+
f"/api/where/route-ids-for-agency/agencyID.json",
58+
options=make_request_options(
59+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
60+
),
61+
cast_to=RouteIDsForAgencyListResponse,
62+
)
63+
64+
65+
class AsyncRouteIDsForAgencyResource(AsyncAPIResource):
66+
@cached_property
67+
def with_raw_response(self) -> AsyncRouteIDsForAgencyResourceWithRawResponse:
68+
return AsyncRouteIDsForAgencyResourceWithRawResponse(self)
69+
70+
@cached_property
71+
def with_streaming_response(self) -> AsyncRouteIDsForAgencyResourceWithStreamingResponse:
72+
return AsyncRouteIDsForAgencyResourceWithStreamingResponse(self)
73+
74+
async def list(
75+
self,
76+
agency_id: str,
77+
*,
78+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
79+
# The extra values given here take precedence over values defined on the client or passed to this method.
80+
extra_headers: Headers | None = None,
81+
extra_query: Query | None = None,
82+
extra_body: Body | None = None,
83+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
84+
) -> RouteIDsForAgencyListResponse:
85+
"""
86+
Get route IDs for a specific agency
87+
88+
Args:
89+
extra_headers: Send extra headers
90+
91+
extra_query: Add additional query parameters to the request
92+
93+
extra_body: Add additional JSON properties to the request
94+
95+
timeout: Override the client-level default timeout for this request, in seconds
96+
"""
97+
if not agency_id:
98+
raise ValueError(f"Expected a non-empty value for `agency_id` but received {agency_id!r}")
99+
return await self._get(
100+
f"/api/where/route-ids-for-agency/agencyID.json",
101+
options=make_request_options(
102+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
103+
),
104+
cast_to=RouteIDsForAgencyListResponse,
105+
)
106+
107+
108+
class RouteIDsForAgencyResourceWithRawResponse:
109+
def __init__(self, route_ids_for_agency: RouteIDsForAgencyResource) -> None:
110+
self._route_ids_for_agency = route_ids_for_agency
111+
112+
self.list = to_raw_response_wrapper(
113+
route_ids_for_agency.list,
114+
)
115+
116+
117+
class AsyncRouteIDsForAgencyResourceWithRawResponse:
118+
def __init__(self, route_ids_for_agency: AsyncRouteIDsForAgencyResource) -> None:
119+
self._route_ids_for_agency = route_ids_for_agency
120+
121+
self.list = async_to_raw_response_wrapper(
122+
route_ids_for_agency.list,
123+
)
124+
125+
126+
class RouteIDsForAgencyResourceWithStreamingResponse:
127+
def __init__(self, route_ids_for_agency: RouteIDsForAgencyResource) -> None:
128+
self._route_ids_for_agency = route_ids_for_agency
129+
130+
self.list = to_streamed_response_wrapper(
131+
route_ids_for_agency.list,
132+
)
133+
134+
135+
class AsyncRouteIDsForAgencyResourceWithStreamingResponse:
136+
def __init__(self, route_ids_for_agency: AsyncRouteIDsForAgencyResource) -> None:
137+
self._route_ids_for_agency = route_ids_for_agency
138+
139+
self.list = async_to_streamed_response_wrapper(
140+
route_ids_for_agency.list,
141+
)

src/onebusaway/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .schedule_for_stop_retrieve_params import ScheduleForStopRetrieveParams as ScheduleForStopRetrieveParams
2020
from .stop_ids_for_agency_list_response import StopIDsForAgencyListResponse as StopIDsForAgencyListResponse
2121
from .vehicles_for_agency_list_response import VehiclesForAgencyListResponse as VehiclesForAgencyListResponse
22+
from .route_ids_for_agency_list_response import RouteIDsForAgencyListResponse as RouteIDsForAgencyListResponse
2223
from .stops_for_location_retrieve_params import StopsForLocationRetrieveParams as StopsForLocationRetrieveParams
2324
from .trip_for_vehicle_retrieve_response import TripForVehicleRetrieveResponse as TripForVehicleRetrieveResponse
2425
from .trips_for_location_retrieve_params import TripsForLocationRetrieveParams as TripsForLocationRetrieveParams
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
5+
from pydantic import Field as FieldInfo
6+
7+
from .._models import BaseModel
8+
from .shared.references import References
9+
from .shared.response_wrapper import ResponseWrapper
10+
11+
__all__ = ["RouteIDsForAgencyListResponse", "RouteIDsForAgencyListResponseData"]
12+
13+
14+
class RouteIDsForAgencyListResponseData(BaseModel):
15+
list: List[str]
16+
17+
references: References
18+
19+
limit_exceeded: Optional[bool] = FieldInfo(alias="limitExceeded", default=None)
20+
21+
22+
class RouteIDsForAgencyListResponse(ResponseWrapper):
23+
data: RouteIDsForAgencyListResponseData
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import os
6+
from typing import Any, cast
7+
8+
import pytest
9+
10+
from onebusaway import OnebusawaySDK, AsyncOnebusawaySDK
11+
from tests.utils import assert_matches_type
12+
from onebusaway.types import RouteIDsForAgencyListResponse
13+
14+
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
15+
16+
17+
class TestRouteIDsForAgency:
18+
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
19+
20+
@parametrize
21+
def test_method_list(self, client: OnebusawaySDK) -> None:
22+
route_ids_for_agency = client.route_ids_for_agency.list(
23+
"agencyID",
24+
)
25+
assert_matches_type(RouteIDsForAgencyListResponse, route_ids_for_agency, path=["response"])
26+
27+
@parametrize
28+
def test_raw_response_list(self, client: OnebusawaySDK) -> None:
29+
response = client.route_ids_for_agency.with_raw_response.list(
30+
"agencyID",
31+
)
32+
33+
assert response.is_closed is True
34+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
35+
route_ids_for_agency = response.parse()
36+
assert_matches_type(RouteIDsForAgencyListResponse, route_ids_for_agency, path=["response"])
37+
38+
@parametrize
39+
def test_streaming_response_list(self, client: OnebusawaySDK) -> None:
40+
with client.route_ids_for_agency.with_streaming_response.list(
41+
"agencyID",
42+
) as response:
43+
assert not response.is_closed
44+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
45+
46+
route_ids_for_agency = response.parse()
47+
assert_matches_type(RouteIDsForAgencyListResponse, route_ids_for_agency, path=["response"])
48+
49+
assert cast(Any, response.is_closed) is True
50+
51+
@parametrize
52+
def test_path_params_list(self, client: OnebusawaySDK) -> None:
53+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `agency_id` but received ''"):
54+
client.route_ids_for_agency.with_raw_response.list(
55+
"",
56+
)
57+
58+
59+
class TestAsyncRouteIDsForAgency:
60+
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
61+
62+
@parametrize
63+
async def test_method_list(self, async_client: AsyncOnebusawaySDK) -> None:
64+
route_ids_for_agency = await async_client.route_ids_for_agency.list(
65+
"agencyID",
66+
)
67+
assert_matches_type(RouteIDsForAgencyListResponse, route_ids_for_agency, path=["response"])
68+
69+
@parametrize
70+
async def test_raw_response_list(self, async_client: AsyncOnebusawaySDK) -> None:
71+
response = await async_client.route_ids_for_agency.with_raw_response.list(
72+
"agencyID",
73+
)
74+
75+
assert response.is_closed is True
76+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
77+
route_ids_for_agency = await response.parse()
78+
assert_matches_type(RouteIDsForAgencyListResponse, route_ids_for_agency, path=["response"])
79+
80+
@parametrize
81+
async def test_streaming_response_list(self, async_client: AsyncOnebusawaySDK) -> None:
82+
async with async_client.route_ids_for_agency.with_streaming_response.list(
83+
"agencyID",
84+
) as response:
85+
assert not response.is_closed
86+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
87+
88+
route_ids_for_agency = await response.parse()
89+
assert_matches_type(RouteIDsForAgencyListResponse, route_ids_for_agency, path=["response"])
90+
91+
assert cast(Any, response.is_closed) is True
92+
93+
@parametrize
94+
async def test_path_params_list(self, async_client: AsyncOnebusawaySDK) -> None:
95+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `agency_id` but received ''"):
96+
await async_client.route_ids_for_agency.with_raw_response.list(
97+
"",
98+
)

0 commit comments

Comments
 (0)