Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 22, 2024
1 parent fc1679d commit b6a54cf
Show file tree
Hide file tree
Showing 8 changed files with 330 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 13
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-6c051801071707e025c582891048beeb3c06d10d13c852f8401a71604b81ac5d.yml
configured_endpoints: 14
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-3a44d3a64c0f613f81e7dd42644c2b2df90e8be20210428450149f771c7f13d8.yml
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ Methods:

- <code title="get /api/where/stops-for-route/{routeID}.json">client.stops_for_route.<a href="./src/onebusaway/resources/stops_for_route.py">list</a>(route_id, \*\*<a href="src/onebusaway/types/stops_for_route_list_params.py">params</a>) -> <a href="./src/onebusaway/types/stops_for_route_list_response.py">StopsForRouteListResponse</a></code>

# Stop

Types:

```python
from onebusaway.types import StopRetrieveResponse
```

Methods:

- <code title="get /api/where/stop/{stopID}.json">client.stop.<a href="./src/onebusaway/resources/stop.py">retrieve</a>(stop_id) -> <a href="./src/onebusaway/types/stop_retrieve_response.py">StopRetrieveResponse</a></code>

# Route

Types:
Expand Down
8 changes: 8 additions & 0 deletions src/onebusaway/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class OnebusawaySDK(SyncAPIClient):
current_time: resources.CurrentTimeResource
stops_for_location: resources.StopsForLocationResource
stops_for_route: resources.StopsForRouteResource
stop: resources.StopResource
route: resources.RouteResource
arrival_and_departure: resources.ArrivalAndDepartureResource
trip: resources.TripResource
Expand Down Expand Up @@ -121,6 +122,7 @@ def __init__(
self.current_time = resources.CurrentTimeResource(self)
self.stops_for_location = resources.StopsForLocationResource(self)
self.stops_for_route = resources.StopsForRouteResource(self)
self.stop = resources.StopResource(self)
self.route = resources.RouteResource(self)
self.arrival_and_departure = resources.ArrivalAndDepartureResource(self)
self.trip = resources.TripResource(self)
Expand Down Expand Up @@ -250,6 +252,7 @@ class AsyncOnebusawaySDK(AsyncAPIClient):
current_time: resources.AsyncCurrentTimeResource
stops_for_location: resources.AsyncStopsForLocationResource
stops_for_route: resources.AsyncStopsForRouteResource
stop: resources.AsyncStopResource
route: resources.AsyncRouteResource
arrival_and_departure: resources.AsyncArrivalAndDepartureResource
trip: resources.AsyncTripResource
Expand Down Expand Up @@ -319,6 +322,7 @@ def __init__(
self.current_time = resources.AsyncCurrentTimeResource(self)
self.stops_for_location = resources.AsyncStopsForLocationResource(self)
self.stops_for_route = resources.AsyncStopsForRouteResource(self)
self.stop = resources.AsyncStopResource(self)
self.route = resources.AsyncRouteResource(self)
self.arrival_and_departure = resources.AsyncArrivalAndDepartureResource(self)
self.trip = resources.AsyncTripResource(self)
Expand Down Expand Up @@ -451,6 +455,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
self.current_time = resources.CurrentTimeResourceWithRawResponse(client.current_time)
self.stops_for_location = resources.StopsForLocationResourceWithRawResponse(client.stops_for_location)
self.stops_for_route = resources.StopsForRouteResourceWithRawResponse(client.stops_for_route)
self.stop = resources.StopResourceWithRawResponse(client.stop)
self.route = resources.RouteResourceWithRawResponse(client.route)
self.arrival_and_departure = resources.ArrivalAndDepartureResourceWithRawResponse(client.arrival_and_departure)
self.trip = resources.TripResourceWithRawResponse(client.trip)
Expand All @@ -469,6 +474,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
self.current_time = resources.AsyncCurrentTimeResourceWithRawResponse(client.current_time)
self.stops_for_location = resources.AsyncStopsForLocationResourceWithRawResponse(client.stops_for_location)
self.stops_for_route = resources.AsyncStopsForRouteResourceWithRawResponse(client.stops_for_route)
self.stop = resources.AsyncStopResourceWithRawResponse(client.stop)
self.route = resources.AsyncRouteResourceWithRawResponse(client.route)
self.arrival_and_departure = resources.AsyncArrivalAndDepartureResourceWithRawResponse(
client.arrival_and_departure
Expand All @@ -489,6 +495,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
self.current_time = resources.CurrentTimeResourceWithStreamingResponse(client.current_time)
self.stops_for_location = resources.StopsForLocationResourceWithStreamingResponse(client.stops_for_location)
self.stops_for_route = resources.StopsForRouteResourceWithStreamingResponse(client.stops_for_route)
self.stop = resources.StopResourceWithStreamingResponse(client.stop)
self.route = resources.RouteResourceWithStreamingResponse(client.route)
self.arrival_and_departure = resources.ArrivalAndDepartureResourceWithStreamingResponse(
client.arrival_and_departure
Expand All @@ -511,6 +518,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
client.stops_for_location
)
self.stops_for_route = resources.AsyncStopsForRouteResourceWithStreamingResponse(client.stops_for_route)
self.stop = resources.AsyncStopResourceWithStreamingResponse(client.stop)
self.route = resources.AsyncRouteResourceWithStreamingResponse(client.route)
self.arrival_and_departure = resources.AsyncArrivalAndDepartureResourceWithStreamingResponse(
client.arrival_and_departure
Expand Down
14 changes: 14 additions & 0 deletions src/onebusaway/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .stop import (
StopResource,
AsyncStopResource,
StopResourceWithRawResponse,
AsyncStopResourceWithRawResponse,
StopResourceWithStreamingResponse,
AsyncStopResourceWithStreamingResponse,
)
from .trip import (
TripResource,
AsyncTripResource,
Expand Down Expand Up @@ -134,6 +142,12 @@
"AsyncStopsForRouteResourceWithRawResponse",
"StopsForRouteResourceWithStreamingResponse",
"AsyncStopsForRouteResourceWithStreamingResponse",
"StopResource",
"AsyncStopResource",
"StopResourceWithRawResponse",
"AsyncStopResourceWithRawResponse",
"StopResourceWithStreamingResponse",
"AsyncStopResourceWithStreamingResponse",
"RouteResource",
"AsyncRouteResource",
"RouteResourceWithRawResponse",
Expand Down
141 changes: 141 additions & 0 deletions src/onebusaway/resources/stop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import httpx

from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from .._base_client import make_request_options
from ..types.stop_retrieve_response import StopRetrieveResponse

__all__ = ["StopResource", "AsyncStopResource"]


class StopResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> StopResourceWithRawResponse:
return StopResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> StopResourceWithStreamingResponse:
return StopResourceWithStreamingResponse(self)

def retrieve(
self,
stop_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> StopRetrieveResponse:
"""
Retrieve information for a specific stop identified by its unique ID.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not stop_id:
raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}")
return self._get(
f"/api/where/stop/stopID.json",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=StopRetrieveResponse,
)


class AsyncStopResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncStopResourceWithRawResponse:
return AsyncStopResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncStopResourceWithStreamingResponse:
return AsyncStopResourceWithStreamingResponse(self)

async def retrieve(
self,
stop_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> StopRetrieveResponse:
"""
Retrieve information for a specific stop identified by its unique ID.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not stop_id:
raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}")
return await self._get(
f"/api/where/stop/stopID.json",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=StopRetrieveResponse,
)


class StopResourceWithRawResponse:
def __init__(self, stop: StopResource) -> None:
self._stop = stop

self.retrieve = to_raw_response_wrapper(
stop.retrieve,
)


class AsyncStopResourceWithRawResponse:
def __init__(self, stop: AsyncStopResource) -> None:
self._stop = stop

self.retrieve = async_to_raw_response_wrapper(
stop.retrieve,
)


class StopResourceWithStreamingResponse:
def __init__(self, stop: StopResource) -> None:
self._stop = stop

self.retrieve = to_streamed_response_wrapper(
stop.retrieve,
)


class AsyncStopResourceWithStreamingResponse:
def __init__(self, stop: AsyncStopResource) -> None:
self._stop = stop

self.retrieve = async_to_streamed_response_wrapper(
stop.retrieve,
)
1 change: 1 addition & 0 deletions src/onebusaway/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from .shared import References as References, ResponseWrapper as ResponseWrapper
from .stop_retrieve_response import StopRetrieveResponse as StopRetrieveResponse
from .trip_retrieve_response import TripRetrieveResponse as TripRetrieveResponse
from .route_retrieve_response import RouteRetrieveResponse as RouteRetrieveResponse
from .agency_retrieve_response import AgencyRetrieveResponse as AgencyRetrieveResponse
Expand Down
54 changes: 54 additions & 0 deletions src/onebusaway/types/stop_retrieve_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Optional

from pydantic import Field as FieldInfo

from .._models import BaseModel
from .shared.references import References
from .shared.response_wrapper import ResponseWrapper

__all__ = [
"StopRetrieveResponse",
"StopRetrieveResponseData",
"StopRetrieveResponseDataData",
"StopRetrieveResponseDataDataEntry",
]


class StopRetrieveResponseDataDataEntry(BaseModel):
id: str

code: str

lat: float

lon: float

name: str

direction: Optional[str] = None

location_type: Optional[int] = FieldInfo(alias="locationType", default=None)

parent: Optional[str] = None

route_ids: Optional[List[str]] = FieldInfo(alias="routeIds", default=None)

static_route_ids: Optional[List[str]] = FieldInfo(alias="staticRouteIds", default=None)

wheelchair_boarding: Optional[str] = FieldInfo(alias="wheelchairBoarding", default=None)


class StopRetrieveResponseDataData(BaseModel):
entry: Optional[StopRetrieveResponseDataDataEntry] = None

references: Optional[References] = None


class StopRetrieveResponseData(BaseModel):
data: Optional[StopRetrieveResponseDataData] = None


class StopRetrieveResponse(ResponseWrapper):
data: Optional[StopRetrieveResponseData] = None
Loading

0 comments on commit b6a54cf

Please sign in to comment.