Skip to content
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

chore(internal): codegen related update #32

Merged
merged 1 commit into from
Dec 17, 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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ client.with_options(http_client=DefaultHttpxClient(...))

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.

```py
from prelude_python_sdk import Prelude

with Prelude() as client:
# make requests here
...

# HTTP client is now closed
```

## Versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
Expand Down
63 changes: 27 additions & 36 deletions src/prelude_python_sdk/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import httpx

from . import resources, _exceptions
from . import _exceptions
from ._qs import Querystring
from ._types import (
NOT_GIVEN,
Expand All @@ -24,6 +24,7 @@
get_async_library,
)
from ._version import __version__
from .resources import watch, verification, transactional
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import PreludeError, APIStatusError
from ._base_client import (
Expand All @@ -32,23 +33,13 @@
AsyncAPIClient,
)

__all__ = [
"Timeout",
"Transport",
"ProxiesTypes",
"RequestOptions",
"resources",
"Prelude",
"AsyncPrelude",
"Client",
"AsyncClient",
]
__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Prelude", "AsyncPrelude", "Client", "AsyncClient"]


class Prelude(SyncAPIClient):
transactional: resources.TransactionalResource
verification: resources.VerificationResource
watch: resources.WatchResource
transactional: transactional.TransactionalResource
verification: verification.VerificationResource
watch: watch.WatchResource
with_raw_response: PreludeWithRawResponse
with_streaming_response: PreludeWithStreamedResponse

Expand Down Expand Up @@ -106,9 +97,9 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.transactional = resources.TransactionalResource(self)
self.verification = resources.VerificationResource(self)
self.watch = resources.WatchResource(self)
self.transactional = transactional.TransactionalResource(self)
self.verification = verification.VerificationResource(self)
self.watch = watch.WatchResource(self)
self.with_raw_response = PreludeWithRawResponse(self)
self.with_streaming_response = PreludeWithStreamedResponse(self)

Expand Down Expand Up @@ -218,9 +209,9 @@ def _make_status_error(


class AsyncPrelude(AsyncAPIClient):
transactional: resources.AsyncTransactionalResource
verification: resources.AsyncVerificationResource
watch: resources.AsyncWatchResource
transactional: transactional.AsyncTransactionalResource
verification: verification.AsyncVerificationResource
watch: watch.AsyncWatchResource
with_raw_response: AsyncPreludeWithRawResponse
with_streaming_response: AsyncPreludeWithStreamedResponse

Expand Down Expand Up @@ -278,9 +269,9 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.transactional = resources.AsyncTransactionalResource(self)
self.verification = resources.AsyncVerificationResource(self)
self.watch = resources.AsyncWatchResource(self)
self.transactional = transactional.AsyncTransactionalResource(self)
self.verification = verification.AsyncVerificationResource(self)
self.watch = watch.AsyncWatchResource(self)
self.with_raw_response = AsyncPreludeWithRawResponse(self)
self.with_streaming_response = AsyncPreludeWithStreamedResponse(self)

Expand Down Expand Up @@ -391,30 +382,30 @@ def _make_status_error(

class PreludeWithRawResponse:
def __init__(self, client: Prelude) -> None:
self.transactional = resources.TransactionalResourceWithRawResponse(client.transactional)
self.verification = resources.VerificationResourceWithRawResponse(client.verification)
self.watch = resources.WatchResourceWithRawResponse(client.watch)
self.transactional = transactional.TransactionalResourceWithRawResponse(client.transactional)
self.verification = verification.VerificationResourceWithRawResponse(client.verification)
self.watch = watch.WatchResourceWithRawResponse(client.watch)


class AsyncPreludeWithRawResponse:
def __init__(self, client: AsyncPrelude) -> None:
self.transactional = resources.AsyncTransactionalResourceWithRawResponse(client.transactional)
self.verification = resources.AsyncVerificationResourceWithRawResponse(client.verification)
self.watch = resources.AsyncWatchResourceWithRawResponse(client.watch)
self.transactional = transactional.AsyncTransactionalResourceWithRawResponse(client.transactional)
self.verification = verification.AsyncVerificationResourceWithRawResponse(client.verification)
self.watch = watch.AsyncWatchResourceWithRawResponse(client.watch)


class PreludeWithStreamedResponse:
def __init__(self, client: Prelude) -> None:
self.transactional = resources.TransactionalResourceWithStreamingResponse(client.transactional)
self.verification = resources.VerificationResourceWithStreamingResponse(client.verification)
self.watch = resources.WatchResourceWithStreamingResponse(client.watch)
self.transactional = transactional.TransactionalResourceWithStreamingResponse(client.transactional)
self.verification = verification.VerificationResourceWithStreamingResponse(client.verification)
self.watch = watch.WatchResourceWithStreamingResponse(client.watch)


class AsyncPreludeWithStreamedResponse:
def __init__(self, client: AsyncPrelude) -> None:
self.transactional = resources.AsyncTransactionalResourceWithStreamingResponse(client.transactional)
self.verification = resources.AsyncVerificationResourceWithStreamingResponse(client.verification)
self.watch = resources.AsyncWatchResourceWithStreamingResponse(client.watch)
self.transactional = transactional.AsyncTransactionalResourceWithStreamingResponse(client.transactional)
self.verification = verification.AsyncVerificationResourceWithStreamingResponse(client.verification)
self.watch = watch.AsyncWatchResourceWithStreamingResponse(client.watch)


Client = Prelude
Expand Down