Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Jun 19, 2024
1 parent 0ad9c15 commit 3beb328
Show file tree
Hide file tree
Showing 33 changed files with 302 additions and 638 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ client = OneBusAway(
api_key=os.environ.get("ONEBUSAWAY_API_KEY"),
)

current_time_retrieve_response = client.api.where.current_time.retrieve()
current_time_retrieve_response = client.current_time.retrieve()
```

While you can provide an `api_key` keyword argument,
Expand All @@ -59,7 +59,7 @@ client = AsyncOneBusAway(


async def main() -> None:
current_time_retrieve_response = await client.api.where.current_time.retrieve()
current_time_retrieve_response = await client.current_time.retrieve()


asyncio.run(main())
Expand Down Expand Up @@ -92,7 +92,7 @@ from open_transit import OneBusAway
client = OneBusAway()

try:
client.api.where.current_time.retrieve()
client.current_time.retrieve()
except open_transit.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -135,7 +135,7 @@ client = OneBusAway(
)

# Or, configure per-request:
client.with_options(max_retries=5).api.where.current_time.retrieve()
client.with_options(max_retries=5).current_time.retrieve()
```

### Timeouts
Expand All @@ -158,7 +158,7 @@ client = OneBusAway(
)

# Override per-request:
client.with_options(timeout=5.0).api.where.current_time.retrieve()
client.with_options(timeout=5.0).current_time.retrieve()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -197,10 +197,10 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from open_transit import OneBusAway

client = OneBusAway()
response = client.api.where.current_time.with_raw_response.retrieve()
response = client.current_time.with_raw_response.retrieve()
print(response.headers.get('X-My-Header'))

current_time = response.parse() # get the object that `api.where.current_time.retrieve()` would have returned
current_time = response.parse() # get the object that `current_time.retrieve()` would have returned
print(current_time)
```

Expand All @@ -215,7 +215,7 @@ The above interface eagerly reads the full response body when you make the reque
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.

```python
with client.api.where.current_time.with_streaming_response.retrieve() as response:
with client.current_time.with_streaming_response.retrieve() as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down
40 changes: 18 additions & 22 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,74 @@
from open_transit.types import ResponseWrapper
```

# API

## Where

### AgenciesWithCoverage
# AgenciesWithCoverage

Types:

```python
from open_transit.types.api.where import AgenciesWithCoverageListResponse
from open_transit.types import AgenciesWithCoverageListResponse
```

Methods:

- <code title="get /api/where/agencies-with-coverage.json">client.api.where.agencies_with_coverage.<a href="./src/open_transit/resources/api/where/agencies_with_coverage.py">list</a>() -> <a href="./src/open_transit/types/api/where/agencies_with_coverage_list_response.py">AgenciesWithCoverageListResponse</a></code>
- <code title="get /api/where/agencies-with-coverage.json">client.agencies_with_coverage.<a href="./src/open_transit/resources/agencies_with_coverage.py">list</a>() -> <a href="./src/open_transit/types/agencies_with_coverage_list_response.py">AgenciesWithCoverageListResponse</a></code>

### Config
# Config

Types:

```python
from open_transit.types.api.where import ConfigRetrieveResponse
from open_transit.types import ConfigRetrieveResponse
```

Methods:

- <code title="get /api/where/config.json">client.api.where.config.<a href="./src/open_transit/resources/api/where/config.py">retrieve</a>() -> <a href="./src/open_transit/types/api/where/config_retrieve_response.py">ConfigRetrieveResponse</a></code>
- <code title="get /api/where/config.json">client.config.<a href="./src/open_transit/resources/config.py">retrieve</a>() -> <a href="./src/open_transit/types/config_retrieve_response.py">ConfigRetrieveResponse</a></code>

### CurrentTime
# CurrentTime

Types:

```python
from open_transit.types.api.where import CurrentTimeRetrieveResponse
from open_transit.types import CurrentTimeRetrieveResponse
```

Methods:

- <code title="get /api/where/current-time.json">client.api.where.current_time.<a href="./src/open_transit/resources/api/where/current_time.py">retrieve</a>() -> <a href="./src/open_transit/types/api/where/current_time_retrieve_response.py">CurrentTimeRetrieveResponse</a></code>
- <code title="get /api/where/current-time.json">client.current_time.<a href="./src/open_transit/resources/current_time.py">retrieve</a>() -> <a href="./src/open_transit/types/current_time_retrieve_response.py">CurrentTimeRetrieveResponse</a></code>

### StopsForLocation
# StopsForLocation

Types:

```python
from open_transit.types.api.where import StopsForLocationListResponse
from open_transit.types import StopsForLocationListResponse
```

Methods:

- <code title="get /api/where/stops-for-location.json">client.api.where.stops_for_location.<a href="./src/open_transit/resources/api/where/stops_for_location.py">list</a>(\*\*<a href="src/open_transit/types/api/where/stops_for_location_list_params.py">params</a>) -> <a href="./src/open_transit/types/api/where/stops_for_location_list_response.py">StopsForLocationListResponse</a></code>
- <code title="get /api/where/stops-for-location.json">client.stops_for_location.<a href="./src/open_transit/resources/stops_for_location.py">list</a>(\*\*<a href="src/open_transit/types/stops_for_location_list_params.py">params</a>) -> <a href="./src/open_transit/types/stops_for_location_list_response.py">StopsForLocationListResponse</a></code>

### ArrivalAndDepartureForStop
# ArrivalAndDepartureForStop

Types:

```python
from open_transit.types.api.where import ArrivalAndDepartureForStopRetrieveResponse
from open_transit.types import ArrivalAndDepartureForStopRetrieveResponse
```

Methods:

- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.api.where.arrival_and_departure_for_stop.<a href="./src/open_transit/resources/api/where/arrival_and_departure_for_stop.py">retrieve</a>(stop_id, \*\*<a href="src/open_transit/types/api/where/arrival_and_departure_for_stop_retrieve_params.py">params</a>) -> <a href="./src/open_transit/types/api/where/arrival_and_departure_for_stop_retrieve_response.py">ArrivalAndDepartureForStopRetrieveResponse</a></code>
- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.arrival_and_departure_for_stop.<a href="./src/open_transit/resources/arrival_and_departure_for_stop.py">retrieve</a>(stop_id, \*\*<a href="src/open_transit/types/arrival_and_departure_for_stop_retrieve_params.py">params</a>) -> <a href="./src/open_transit/types/arrival_and_departure_for_stop_retrieve_response.py">ArrivalAndDepartureForStopRetrieveResponse</a></code>

### ArrivalsAndDeparturesForStop
# ArrivalsAndDeparturesForStop

Types:

```python
from open_transit.types.api.where import ArrivalsAndDeparturesForStopListResponse
from open_transit.types import ArrivalsAndDeparturesForStopListResponse
```

Methods:

- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.api.where.arrivals_and_departures_for_stop.<a href="./src/open_transit/resources/api/where/arrivals_and_departures_for_stop.py">list</a>(stop_id) -> <a href="./src/open_transit/types/api/where/arrivals_and_departures_for_stop_list_response.py">ArrivalsAndDeparturesForStopListResponse</a></code>
- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.arrivals_and_departures_for_stop.<a href="./src/open_transit/resources/arrivals_and_departures_for_stop.py">list</a>(stop_id) -> <a href="./src/open_transit/types/arrivals_and_departures_for_stop_list_response.py">ArrivalsAndDeparturesForStopListResponse</a></code>
84 changes: 76 additions & 8 deletions src/open_transit/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@


class OneBusAway(SyncAPIClient):
api: resources.APIResource
agencies_with_coverage: resources.AgenciesWithCoverageResource
config: resources.ConfigResource
current_time: resources.CurrentTimeResource
stops_for_location: resources.StopsForLocationResource
arrival_and_departure_for_stop: resources.ArrivalAndDepartureForStopResource
arrivals_and_departures_for_stop: resources.ArrivalsAndDeparturesForStopResource
with_raw_response: OneBusAwayWithRawResponse
with_streaming_response: OneBusAwayWithStreamedResponse

Expand Down Expand Up @@ -104,7 +109,12 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.api = resources.APIResource(self)
self.agencies_with_coverage = resources.AgenciesWithCoverageResource(self)
self.config = resources.ConfigResource(self)
self.current_time = resources.CurrentTimeResource(self)
self.stops_for_location = resources.StopsForLocationResource(self)
self.arrival_and_departure_for_stop = resources.ArrivalAndDepartureForStopResource(self)
self.arrivals_and_departures_for_stop = resources.ArrivalsAndDeparturesForStopResource(self)
self.with_raw_response = OneBusAwayWithRawResponse(self)
self.with_streaming_response = OneBusAwayWithStreamedResponse(self)

Expand Down Expand Up @@ -221,7 +231,12 @@ def _make_status_error(


class AsyncOneBusAway(AsyncAPIClient):
api: resources.AsyncAPIResource
agencies_with_coverage: resources.AsyncAgenciesWithCoverageResource
config: resources.AsyncConfigResource
current_time: resources.AsyncCurrentTimeResource
stops_for_location: resources.AsyncStopsForLocationResource
arrival_and_departure_for_stop: resources.AsyncArrivalAndDepartureForStopResource
arrivals_and_departures_for_stop: resources.AsyncArrivalsAndDeparturesForStopResource
with_raw_response: AsyncOneBusAwayWithRawResponse
with_streaming_response: AsyncOneBusAwayWithStreamedResponse

Expand Down Expand Up @@ -279,7 +294,12 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.api = resources.AsyncAPIResource(self)
self.agencies_with_coverage = resources.AsyncAgenciesWithCoverageResource(self)
self.config = resources.AsyncConfigResource(self)
self.current_time = resources.AsyncCurrentTimeResource(self)
self.stops_for_location = resources.AsyncStopsForLocationResource(self)
self.arrival_and_departure_for_stop = resources.AsyncArrivalAndDepartureForStopResource(self)
self.arrivals_and_departures_for_stop = resources.AsyncArrivalsAndDeparturesForStopResource(self)
self.with_raw_response = AsyncOneBusAwayWithRawResponse(self)
self.with_streaming_response = AsyncOneBusAwayWithStreamedResponse(self)

Expand Down Expand Up @@ -397,22 +417,70 @@ def _make_status_error(

class OneBusAwayWithRawResponse:
def __init__(self, client: OneBusAway) -> None:
self.api = resources.APIResourceWithRawResponse(client.api)
self.agencies_with_coverage = resources.AgenciesWithCoverageResourceWithRawResponse(
client.agencies_with_coverage
)
self.config = resources.ConfigResourceWithRawResponse(client.config)
self.current_time = resources.CurrentTimeResourceWithRawResponse(client.current_time)
self.stops_for_location = resources.StopsForLocationResourceWithRawResponse(client.stops_for_location)
self.arrival_and_departure_for_stop = resources.ArrivalAndDepartureForStopResourceWithRawResponse(
client.arrival_and_departure_for_stop
)
self.arrivals_and_departures_for_stop = resources.ArrivalsAndDeparturesForStopResourceWithRawResponse(
client.arrivals_and_departures_for_stop
)


class AsyncOneBusAwayWithRawResponse:
def __init__(self, client: AsyncOneBusAway) -> None:
self.api = resources.AsyncAPIResourceWithRawResponse(client.api)
self.agencies_with_coverage = resources.AsyncAgenciesWithCoverageResourceWithRawResponse(
client.agencies_with_coverage
)
self.config = resources.AsyncConfigResourceWithRawResponse(client.config)
self.current_time = resources.AsyncCurrentTimeResourceWithRawResponse(client.current_time)
self.stops_for_location = resources.AsyncStopsForLocationResourceWithRawResponse(client.stops_for_location)
self.arrival_and_departure_for_stop = resources.AsyncArrivalAndDepartureForStopResourceWithRawResponse(
client.arrival_and_departure_for_stop
)
self.arrivals_and_departures_for_stop = resources.AsyncArrivalsAndDeparturesForStopResourceWithRawResponse(
client.arrivals_and_departures_for_stop
)


class OneBusAwayWithStreamedResponse:
def __init__(self, client: OneBusAway) -> None:
self.api = resources.APIResourceWithStreamingResponse(client.api)
self.agencies_with_coverage = resources.AgenciesWithCoverageResourceWithStreamingResponse(
client.agencies_with_coverage
)
self.config = resources.ConfigResourceWithStreamingResponse(client.config)
self.current_time = resources.CurrentTimeResourceWithStreamingResponse(client.current_time)
self.stops_for_location = resources.StopsForLocationResourceWithStreamingResponse(client.stops_for_location)
self.arrival_and_departure_for_stop = resources.ArrivalAndDepartureForStopResourceWithStreamingResponse(
client.arrival_and_departure_for_stop
)
self.arrivals_and_departures_for_stop = resources.ArrivalsAndDeparturesForStopResourceWithStreamingResponse(
client.arrivals_and_departures_for_stop
)


class AsyncOneBusAwayWithStreamedResponse:
def __init__(self, client: AsyncOneBusAway) -> None:
self.api = resources.AsyncAPIResourceWithStreamingResponse(client.api)
self.agencies_with_coverage = resources.AsyncAgenciesWithCoverageResourceWithStreamingResponse(
client.agencies_with_coverage
)
self.config = resources.AsyncConfigResourceWithStreamingResponse(client.config)
self.current_time = resources.AsyncCurrentTimeResourceWithStreamingResponse(client.current_time)
self.stops_for_location = resources.AsyncStopsForLocationResourceWithStreamingResponse(
client.stops_for_location
)
self.arrival_and_departure_for_stop = resources.AsyncArrivalAndDepartureForStopResourceWithStreamingResponse(
client.arrival_and_departure_for_stop
)
self.arrivals_and_departures_for_stop = (
resources.AsyncArrivalsAndDeparturesForStopResourceWithStreamingResponse(
client.arrivals_and_departures_for_stop
)
)


Client = OneBusAway
Expand Down
96 changes: 83 additions & 13 deletions src/open_transit/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,89 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .api import (
APIResource,
AsyncAPIResource,
APIResourceWithRawResponse,
AsyncAPIResourceWithRawResponse,
APIResourceWithStreamingResponse,
AsyncAPIResourceWithStreamingResponse,
from .config import (
ConfigResource,
AsyncConfigResource,
ConfigResourceWithRawResponse,
AsyncConfigResourceWithRawResponse,
ConfigResourceWithStreamingResponse,
AsyncConfigResourceWithStreamingResponse,
)
from .current_time import (
CurrentTimeResource,
AsyncCurrentTimeResource,
CurrentTimeResourceWithRawResponse,
AsyncCurrentTimeResourceWithRawResponse,
CurrentTimeResourceWithStreamingResponse,
AsyncCurrentTimeResourceWithStreamingResponse,
)
from .stops_for_location import (
StopsForLocationResource,
AsyncStopsForLocationResource,
StopsForLocationResourceWithRawResponse,
AsyncStopsForLocationResourceWithRawResponse,
StopsForLocationResourceWithStreamingResponse,
AsyncStopsForLocationResourceWithStreamingResponse,
)
from .agencies_with_coverage import (
AgenciesWithCoverageResource,
AsyncAgenciesWithCoverageResource,
AgenciesWithCoverageResourceWithRawResponse,
AsyncAgenciesWithCoverageResourceWithRawResponse,
AgenciesWithCoverageResourceWithStreamingResponse,
AsyncAgenciesWithCoverageResourceWithStreamingResponse,
)
from .arrival_and_departure_for_stop import (
ArrivalAndDepartureForStopResource,
AsyncArrivalAndDepartureForStopResource,
ArrivalAndDepartureForStopResourceWithRawResponse,
AsyncArrivalAndDepartureForStopResourceWithRawResponse,
ArrivalAndDepartureForStopResourceWithStreamingResponse,
AsyncArrivalAndDepartureForStopResourceWithStreamingResponse,
)
from .arrivals_and_departures_for_stop import (
ArrivalsAndDeparturesForStopResource,
AsyncArrivalsAndDeparturesForStopResource,
ArrivalsAndDeparturesForStopResourceWithRawResponse,
AsyncArrivalsAndDeparturesForStopResourceWithRawResponse,
ArrivalsAndDeparturesForStopResourceWithStreamingResponse,
AsyncArrivalsAndDeparturesForStopResourceWithStreamingResponse,
)

__all__ = [
"APIResource",
"AsyncAPIResource",
"APIResourceWithRawResponse",
"AsyncAPIResourceWithRawResponse",
"APIResourceWithStreamingResponse",
"AsyncAPIResourceWithStreamingResponse",
"AgenciesWithCoverageResource",
"AsyncAgenciesWithCoverageResource",
"AgenciesWithCoverageResourceWithRawResponse",
"AsyncAgenciesWithCoverageResourceWithRawResponse",
"AgenciesWithCoverageResourceWithStreamingResponse",
"AsyncAgenciesWithCoverageResourceWithStreamingResponse",
"ConfigResource",
"AsyncConfigResource",
"ConfigResourceWithRawResponse",
"AsyncConfigResourceWithRawResponse",
"ConfigResourceWithStreamingResponse",
"AsyncConfigResourceWithStreamingResponse",
"CurrentTimeResource",
"AsyncCurrentTimeResource",
"CurrentTimeResourceWithRawResponse",
"AsyncCurrentTimeResourceWithRawResponse",
"CurrentTimeResourceWithStreamingResponse",
"AsyncCurrentTimeResourceWithStreamingResponse",
"StopsForLocationResource",
"AsyncStopsForLocationResource",
"StopsForLocationResourceWithRawResponse",
"AsyncStopsForLocationResourceWithRawResponse",
"StopsForLocationResourceWithStreamingResponse",
"AsyncStopsForLocationResourceWithStreamingResponse",
"ArrivalAndDepartureForStopResource",
"AsyncArrivalAndDepartureForStopResource",
"ArrivalAndDepartureForStopResourceWithRawResponse",
"AsyncArrivalAndDepartureForStopResourceWithRawResponse",
"ArrivalAndDepartureForStopResourceWithStreamingResponse",
"AsyncArrivalAndDepartureForStopResourceWithStreamingResponse",
"ArrivalsAndDeparturesForStopResource",
"AsyncArrivalsAndDeparturesForStopResource",
"ArrivalsAndDeparturesForStopResourceWithRawResponse",
"AsyncArrivalsAndDeparturesForStopResourceWithRawResponse",
"ArrivalsAndDeparturesForStopResourceWithStreamingResponse",
"AsyncArrivalsAndDeparturesForStopResourceWithStreamingResponse",
]
Loading

0 comments on commit 3beb328

Please sign in to comment.