Skip to content

feat(api): codegen changes #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024
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: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 93
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7ae6544b3567d683dd64c5caff02b49ffc0dc4897d0a91738b0162f36a7ddee7.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-64dd0f92903194da778c07c4d6f30af1dc58586b5870a1c5a2291a420f42e1ae.yml
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ client = AsyncOrb(
api_key=os.environ.get("ORB_API_KEY"),
)


async def main() -> None:
customer = await client.customers.create(
email="[email protected]",
name="My Customer",
)
print(customer.id)
customer = await client.customers.create(
email="[email protected]",
name="My Customer",
)
print(customer.id)


asyncio.run(main())
```
Expand Down Expand Up @@ -104,13 +106,15 @@ from orb import AsyncOrb

client = AsyncOrb()


async def main() -> None:
all_coupons = []
# Iterate through items across all pages, issuing requests as needed.
async for coupon in client.coupons.list():
all_coupons.append(coupon)
print(all_coupons)


asyncio.run(main())
```

Expand All @@ -131,7 +135,9 @@ Or just work directly with the returned data:
```python
first_page = await client.coupons.list()

print(f"next page cursor: {first_page.pagination_metadata.next_cursor}") # => "next page cursor: ..."
print(
f"next page cursor: {first_page.pagination_metadata.next_cursor}"
) # => "next page cursor: ..."
for coupon in first_page.data:
print(coupon.id)

Expand Down Expand Up @@ -181,7 +187,7 @@ try:
)
except orb.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except orb.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except orb.APIStatusError as e:
Expand Down Expand Up @@ -221,7 +227,7 @@ client = Orb(
)

# Or, configure per-request:
client.with_options(max_retries = 5).customers.create(
client.with_options(max_retries=5).customers.create(
email="[email protected]",
name="My Customer",
)
Expand All @@ -247,7 +253,7 @@ client = Orb(
)

# Override per-request:
client.with_options(timeout = 5.0).customers.create(
client.with_options(timeout=5.0).customers.create(
email="[email protected]",
name="My Customer",
)
Expand Down Expand Up @@ -320,11 +326,11 @@ As such, `.with_streaming_response` methods return a different [`APIResponse`](h
with client.customers.with_streaming_response.create(
email="[email protected]",
name="My Customer",
) as response :
print(response.headers.get('X-My-Header'))
) as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
print(line)
print(line)
```

The context manager is required so that the response will reliably be closed.
Expand Down Expand Up @@ -378,7 +384,10 @@ from orb import Orb, DefaultHttpxClient
client = Orb(
# Or use the `ORB_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(proxies="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),
http_client=DefaultHttpxClient(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
```

Expand Down
37 changes: 32 additions & 5 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ Methods:
Types:

```python
from orb.types.customers.credits import LedgerListResponse, LedgerCreateEntryResponse, LedgerCreateEntryByExternalIDResponse, LedgerListByExternalIDResponse
from orb.types.customers.credits import (
LedgerListResponse,
LedgerCreateEntryResponse,
LedgerCreateEntryByExternalIDResponse,
LedgerListByExternalIDResponse,
)
```

Methods:
Expand All @@ -114,7 +119,12 @@ Methods:
Types:

```python
from orb.types.customers.credits import TopUpCreateResponse, TopUpListResponse, TopUpCreateByExternalIDResponse, TopUpListByExternalIDResponse
from orb.types.customers.credits import (
TopUpCreateResponse,
TopUpListResponse,
TopUpCreateByExternalIDResponse,
TopUpListByExternalIDResponse,
)
```

Methods:
Expand Down Expand Up @@ -144,7 +154,12 @@ Methods:
Types:

```python
from orb.types import EventUpdateResponse, EventDeprecateResponse, EventIngestResponse, EventSearchResponse
from orb.types import (
EventUpdateResponse,
EventDeprecateResponse,
EventIngestResponse,
EventSearchResponse,
)
```

Methods:
Expand All @@ -159,7 +174,13 @@ Methods:
Types:

```python
from orb.types.events import BackfillCreateResponse, BackfillListResponse, BackfillCloseResponse, BackfillFetchResponse, BackfillRevertResponse
from orb.types.events import (
BackfillCreateResponse,
BackfillListResponse,
BackfillCloseResponse,
BackfillFetchResponse,
BackfillRevertResponse,
)
```

Methods:
Expand Down Expand Up @@ -281,7 +302,13 @@ Methods:
Types:

```python
from orb.types import Subscription, SubscriptionUsage, Subscriptions, SubscriptionFetchCostsResponse, SubscriptionFetchScheduleResponse
from orb.types import (
Subscription,
SubscriptionUsage,
Subscriptions,
SubscriptionFetchCostsResponse,
SubscriptionFetchScheduleResponse,
)
```

Methods:
Expand Down
52 changes: 26 additions & 26 deletions src/orb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from . import types
from ._version import __version__, __title__
from ._client import Timeout, Transport, RequestOptions, Client, AsyncClient, Stream, AsyncStream, Orb, AsyncOrb
from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
from ._utils import file_from_path
from ._client import Orb, Client, Stream, Timeout, AsyncOrb, Transport, AsyncClient, AsyncStream, RequestOptions
from ._models import BaseModel
from ._version import __title__, __version__
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
from ._exceptions import (
OrbError,
APIError,
OrbError,
URLNotFound,
ConflictError,
NotFoundError,
APIStatusError,
RateLimitError,
APITimeoutError,
APIConnectionError,
APIResponseValidationError,
BadRequestError,
RequestTooLarge,
TooManyRequests,
ResourceConflict,
ResourceNotFound,
ResourceTooLarge,
APIConnectionError,
AuthenticationError,
PermissionDeniedError,
NotFoundError,
ConflictError,
UnprocessableEntityError,
RateLimitError,
InternalServerError,
ConstraintViolation,
DuplicateResourceCreation,
RequestValidationError,
OrbAuthenticationError,
FeatureNotAvailable,
ResourceNotFound,
URLNotFound,
ResourceConflict,
RequestTooLarge,
ResourceTooLarge,
TooManyRequests,
InternalServerError,
PermissionDeniedError,
OrbAuthenticationError,
OrbInternalServerError,
RequestValidationError,
UnprocessableEntityError,
DuplicateResourceCreation,
APIResponseValidationError,
)
from ._types import NoneType, Transport, ProxiesTypes, NotGiven, NOT_GIVEN
from ._utils import file_from_path
from ._models import BaseModel
from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse

__all__ = [
"types",
Expand Down Expand Up @@ -101,7 +101,7 @@
for __name in __all__:
if not __name.startswith("__"):
try:
setattr(__locals[__name], "__module__", "orb")
__locals[__name].__module__ = "orb"
except (TypeError, AttributeError):
# Some of our exported symbols are builtins which we can't set attributes for.
pass
57 changes: 13 additions & 44 deletions src/orb/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,36 @@

from __future__ import annotations

import httpx

import os

from ._streaming import AsyncStream as AsyncStream, Stream as Stream

from ._exceptions import OrbError, APIStatusError

from typing_extensions import override, Self

from typing import Any

from ._utils import is_mapping, get_async_library

from . import _exceptions

import os
import asyncio
import warnings
from typing import Optional, Union, Dict, Any, Mapping, overload, cast
from typing_extensions import Literal
from typing import Any, Union, Mapping
from typing_extensions import Self, override

import httpx

from ._version import __version__
from . import resources, _exceptions
from ._qs import Querystring
from ._utils import (
extract_files,
maybe_transform,
required_args,
deepcopy_minimal,
maybe_coerce_integer,
maybe_coerce_float,
maybe_coerce_boolean,
is_given,
)
from ._types import (
NOT_GIVEN,
Omit,
NotGiven,
Timeout,
NotGiven,
Transport,
ProxiesTypes,
RequestOptions,
Headers,
NoneType,
Query,
Body,
NOT_GIVEN,
)
from ._utils import (
is_given,
is_mapping,
get_async_library,
)
from ._version import __version__
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import OrbError, APIStatusError
from ._base_client import (
DEFAULT_CONNECTION_LIMITS,
DEFAULT_TIMEOUT,
DEFAULT_MAX_RETRIES,
ResponseT,
SyncHttpxClientWrapper,
AsyncHttpxClientWrapper,
SyncAPIClient,
AsyncAPIClient,
make_request_options,
)
from . import resources

__all__ = [
"Timeout",
Expand Down
Loading