Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.1"
".": "0.1.0-alpha.2"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 12
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-d7feb31fedeae9f0af2581bf85d95d374eb2eee635e6823975bc4f419bd8e492.yml
configured_endpoints: 13
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-6c051801071707e025c582891048beeb3c06d10d13c852f8401a71604b81ac5d.yml
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.1.0-alpha.2 (2024-07-22)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/OneBusAway/python-sdk/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)

### Features

* **api:** OpenAPI spec update via Stainless API ([#4](https://github.com/OneBusAway/python-sdk/issues/4)) ([fc1679d](https://github.com/OneBusAway/python-sdk/commit/fc1679d6086747ac91152587e272d6b2b32a97fd))
* **api:** OpenAPI spec update via Stainless API ([#6](https://github.com/OneBusAway/python-sdk/issues/6)) ([b6a54cf](https://github.com/OneBusAway/python-sdk/commit/b6a54cfdac1ecfb398e20a4efa90294bde711490))
* **api:** OpenAPI spec update via Stainless API ([#7](https://github.com/OneBusAway/python-sdk/issues/7)) ([448c0e3](https://github.com/OneBusAway/python-sdk/commit/448c0e3847375dcdb86f9cda1e8206f64910e6e9))
* **api:** OpenAPI spec update via Stainless API ([#8](https://github.com/OneBusAway/python-sdk/issues/8)) ([361ab73](https://github.com/OneBusAway/python-sdk/commit/361ab733efaef27d9553cabde2844ffb95296979))
* refactor: Remove print statement from main_sync function ([b72a7a1](https://github.com/OneBusAway/python-sdk/commit/b72a7a16aaf67c5d265cb995181e1abea6d7fed2))
* refactor: Remove print statement from main_sync function ([dcd9e3b](https://github.com/OneBusAway/python-sdk/commit/dcd9e3b609078c5fcbb9682ae4f92849bc7291cf))

## 0.1.0-alpha.1 (2024-07-14)

Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/OneBusAway/python-sdk/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/).

## Documentation

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).
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).

## Installation

Expand Down Expand Up @@ -277,6 +277,12 @@ client = OnebusawaySDK(
)
```

You can also customize the client on a per-request basis by using `with_options()`:

```python
client.with_options(http_client=DefaultHttpxClient(...))
```

### Managing HTTP resources

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.
Expand Down
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,15 @@ from onebusaway.types import TripDetailRetrieveResponse
Methods:

- <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>

# TripForVehicle

Types:

```python
from onebusaway.types import TripForVehicleRetrieveResponse
```

Methods:

- <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>
1 change: 0 additions & 1 deletion examples/agency.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ def main_sync() -> None:
print("Agency data or entry is None.")

if __name__ == "__main__":
print("Running synchronous main function:")
main_sync()
18 changes: 18 additions & 0 deletions examples/trip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


import onebusaway


def main_sync() -> None:
client = onebusaway.OnebusawaySDK(api_key="TEST")

trip_id = '40_608344966'
trip = client.trip.retrieve(trip_id)

if trip.data and trip.data.entry:
print(trip.data.entry)
else:
print("trip data or entry is None.")

if __name__ == "__main__":
main_sync()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "onebusaway"
version = "0.1.0-alpha.1"
version = "0.1.0-alpha.2"
description = "The official Python library for the onebusaway-sdk API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
12 changes: 6 additions & 6 deletions src/onebusaway/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,9 @@ def __exit__(
def _prepare_options(
self,
options: FinalRequestOptions, # noqa: ARG002
) -> None:
) -> FinalRequestOptions:
"""Hook for mutating the given options"""
return None
return options

def _prepare_request(
self,
Expand Down Expand Up @@ -961,7 +961,7 @@ def _request(
input_options = model_copy(options)

cast_to = self._maybe_override_cast_to(cast_to, options)
self._prepare_options(options)
options = self._prepare_options(options)

retries = self._remaining_retries(remaining_retries, options)
request = self._build_request(options)
Expand Down Expand Up @@ -1442,9 +1442,9 @@ async def __aexit__(
async def _prepare_options(
self,
options: FinalRequestOptions, # noqa: ARG002
) -> None:
) -> FinalRequestOptions:
"""Hook for mutating the given options"""
return None
return options

async def _prepare_request(
self,
Expand Down Expand Up @@ -1529,7 +1529,7 @@ async def _request(
input_options = model_copy(options)

cast_to = self._maybe_override_cast_to(cast_to, options)
await self._prepare_options(options)
options = await self._prepare_options(options)

retries = self._remaining_retries(remaining_retries, options)
request = self._build_request(options)
Expand Down
8 changes: 8 additions & 0 deletions src/onebusaway/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class OnebusawaySDK(SyncAPIClient):
trip: resources.TripResource
trips_for_location: resources.TripsForLocationResource
trip_details: resources.TripDetailsResource
trip_for_vehicle: resources.TripForVehicleResource
with_raw_response: OnebusawaySDKWithRawResponse
with_streaming_response: OnebusawaySDKWithStreamedResponse

Expand Down Expand Up @@ -125,6 +126,7 @@ def __init__(
self.trip = resources.TripResource(self)
self.trips_for_location = resources.TripsForLocationResource(self)
self.trip_details = resources.TripDetailsResource(self)
self.trip_for_vehicle = resources.TripForVehicleResource(self)
self.with_raw_response = OnebusawaySDKWithRawResponse(self)
self.with_streaming_response = OnebusawaySDKWithStreamedResponse(self)

Expand Down Expand Up @@ -253,6 +255,7 @@ class AsyncOnebusawaySDK(AsyncAPIClient):
trip: resources.AsyncTripResource
trips_for_location: resources.AsyncTripsForLocationResource
trip_details: resources.AsyncTripDetailsResource
trip_for_vehicle: resources.AsyncTripForVehicleResource
with_raw_response: AsyncOnebusawaySDKWithRawResponse
with_streaming_response: AsyncOnebusawaySDKWithStreamedResponse

Expand Down Expand Up @@ -321,6 +324,7 @@ def __init__(
self.trip = resources.AsyncTripResource(self)
self.trips_for_location = resources.AsyncTripsForLocationResource(self)
self.trip_details = resources.AsyncTripDetailsResource(self)
self.trip_for_vehicle = resources.AsyncTripForVehicleResource(self)
self.with_raw_response = AsyncOnebusawaySDKWithRawResponse(self)
self.with_streaming_response = AsyncOnebusawaySDKWithStreamedResponse(self)

Expand Down Expand Up @@ -452,6 +456,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
self.trip = resources.TripResourceWithRawResponse(client.trip)
self.trips_for_location = resources.TripsForLocationResourceWithRawResponse(client.trips_for_location)
self.trip_details = resources.TripDetailsResourceWithRawResponse(client.trip_details)
self.trip_for_vehicle = resources.TripForVehicleResourceWithRawResponse(client.trip_for_vehicle)


class AsyncOnebusawaySDKWithRawResponse:
Expand All @@ -471,6 +476,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
self.trip = resources.AsyncTripResourceWithRawResponse(client.trip)
self.trips_for_location = resources.AsyncTripsForLocationResourceWithRawResponse(client.trips_for_location)
self.trip_details = resources.AsyncTripDetailsResourceWithRawResponse(client.trip_details)
self.trip_for_vehicle = resources.AsyncTripForVehicleResourceWithRawResponse(client.trip_for_vehicle)


class OnebusawaySDKWithStreamedResponse:
Expand All @@ -490,6 +496,7 @@ def __init__(self, client: OnebusawaySDK) -> None:
self.trip = resources.TripResourceWithStreamingResponse(client.trip)
self.trips_for_location = resources.TripsForLocationResourceWithStreamingResponse(client.trips_for_location)
self.trip_details = resources.TripDetailsResourceWithStreamingResponse(client.trip_details)
self.trip_for_vehicle = resources.TripForVehicleResourceWithStreamingResponse(client.trip_for_vehicle)


class AsyncOnebusawaySDKWithStreamedResponse:
Expand All @@ -513,6 +520,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None:
client.trips_for_location
)
self.trip_details = resources.AsyncTripDetailsResourceWithStreamingResponse(client.trip_details)
self.trip_for_vehicle = resources.AsyncTripForVehicleResourceWithStreamingResponse(client.trip_for_vehicle)


Client = OnebusawaySDK
Expand Down
6 changes: 3 additions & 3 deletions src/onebusaway/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]:
return model.__fields__ # type: ignore


def model_copy(model: _ModelT) -> _ModelT:
def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT:
if PYDANTIC_V2:
return model.model_copy()
return model.copy() # type: ignore
return model.model_copy(deep=deep)
return model.copy(deep=deep) # type: ignore


def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/onebusaway/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "onebusaway"
__version__ = "0.1.0-alpha.1" # x-release-please-version
__version__ = "0.1.0-alpha.2" # x-release-please-version
14 changes: 14 additions & 0 deletions src/onebusaway/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
StopsForRouteResourceWithStreamingResponse,
AsyncStopsForRouteResourceWithStreamingResponse,
)
from .trip_for_vehicle import (
TripForVehicleResource,
AsyncTripForVehicleResource,
TripForVehicleResourceWithRawResponse,
AsyncTripForVehicleResourceWithRawResponse,
TripForVehicleResourceWithStreamingResponse,
AsyncTripForVehicleResourceWithStreamingResponse,
)
from .stops_for_location import (
StopsForLocationResource,
AsyncStopsForLocationResource,
Expand Down Expand Up @@ -156,4 +164,10 @@
"AsyncTripDetailsResourceWithRawResponse",
"TripDetailsResourceWithStreamingResponse",
"AsyncTripDetailsResourceWithStreamingResponse",
"TripForVehicleResource",
"AsyncTripForVehicleResource",
"TripForVehicleResourceWithRawResponse",
"AsyncTripForVehicleResourceWithRawResponse",
"TripForVehicleResourceWithStreamingResponse",
"AsyncTripForVehicleResourceWithStreamingResponse",
]
Loading