Skip to content

chore: lazy load raw resource class properties #144

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
Jan 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
24 changes: 20 additions & 4 deletions src/orb/resources/beta/beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,35 @@ def with_streaming_response(self) -> AsyncBetaWithStreamingResponse:

class BetaWithRawResponse:
def __init__(self, beta: Beta) -> None:
self.price = PriceWithRawResponse(beta.price)
self._beta = beta

@cached_property
def price(self) -> PriceWithRawResponse:
return PriceWithRawResponse(self._beta.price)


class AsyncBetaWithRawResponse:
def __init__(self, beta: AsyncBeta) -> None:
self.price = AsyncPriceWithRawResponse(beta.price)
self._beta = beta

@cached_property
def price(self) -> AsyncPriceWithRawResponse:
return AsyncPriceWithRawResponse(self._beta.price)


class BetaWithStreamingResponse:
def __init__(self, beta: Beta) -> None:
self.price = PriceWithStreamingResponse(beta.price)
self._beta = beta

@cached_property
def price(self) -> PriceWithStreamingResponse:
return PriceWithStreamingResponse(self._beta.price)


class AsyncBetaWithStreamingResponse:
def __init__(self, beta: AsyncBeta) -> None:
self.price = AsyncPriceWithStreamingResponse(beta.price)
self._beta = beta

@cached_property
def price(self) -> AsyncPriceWithStreamingResponse:
return AsyncPriceWithStreamingResponse(self._beta.price)
8 changes: 8 additions & 0 deletions src/orb/resources/beta/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,27 +229,35 @@ async def evaluate(

class PriceWithRawResponse:
def __init__(self, price: Price) -> None:
self._price = price

self.evaluate = _legacy_response.to_raw_response_wrapper(
price.evaluate,
)


class AsyncPriceWithRawResponse:
def __init__(self, price: AsyncPrice) -> None:
self._price = price

self.evaluate = _legacy_response.async_to_raw_response_wrapper(
price.evaluate,
)


class PriceWithStreamingResponse:
def __init__(self, price: Price) -> None:
self._price = price

self.evaluate = to_streamed_response_wrapper(
price.evaluate,
)


class AsyncPriceWithStreamingResponse:
def __init__(self, price: AsyncPrice) -> None:
self._price = price

self.evaluate = async_to_streamed_response_wrapper(
price.evaluate,
)
24 changes: 20 additions & 4 deletions src/orb/resources/coupons/coupons.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ async def fetch(

class CouponsWithRawResponse:
def __init__(self, coupons: Coupons) -> None:
self.subscriptions = SubscriptionsWithRawResponse(coupons.subscriptions)
self._coupons = coupons

self.create = _legacy_response.to_raw_response_wrapper(
coupons.create,
Expand All @@ -475,10 +475,14 @@ def __init__(self, coupons: Coupons) -> None:
coupons.fetch,
)

@cached_property
def subscriptions(self) -> SubscriptionsWithRawResponse:
return SubscriptionsWithRawResponse(self._coupons.subscriptions)


class AsyncCouponsWithRawResponse:
def __init__(self, coupons: AsyncCoupons) -> None:
self.subscriptions = AsyncSubscriptionsWithRawResponse(coupons.subscriptions)
self._coupons = coupons

self.create = _legacy_response.async_to_raw_response_wrapper(
coupons.create,
Expand All @@ -493,10 +497,14 @@ def __init__(self, coupons: AsyncCoupons) -> None:
coupons.fetch,
)

@cached_property
def subscriptions(self) -> AsyncSubscriptionsWithRawResponse:
return AsyncSubscriptionsWithRawResponse(self._coupons.subscriptions)


class CouponsWithStreamingResponse:
def __init__(self, coupons: Coupons) -> None:
self.subscriptions = SubscriptionsWithStreamingResponse(coupons.subscriptions)
self._coupons = coupons

self.create = to_streamed_response_wrapper(
coupons.create,
Expand All @@ -511,10 +519,14 @@ def __init__(self, coupons: Coupons) -> None:
coupons.fetch,
)

@cached_property
def subscriptions(self) -> SubscriptionsWithStreamingResponse:
return SubscriptionsWithStreamingResponse(self._coupons.subscriptions)


class AsyncCouponsWithStreamingResponse:
def __init__(self, coupons: AsyncCoupons) -> None:
self.subscriptions = AsyncSubscriptionsWithStreamingResponse(coupons.subscriptions)
self._coupons = coupons

self.create = async_to_streamed_response_wrapper(
coupons.create,
Expand All @@ -528,3 +540,7 @@ def __init__(self, coupons: AsyncCoupons) -> None:
self.fetch = async_to_streamed_response_wrapper(
coupons.fetch,
)

@cached_property
def subscriptions(self) -> AsyncSubscriptionsWithStreamingResponse:
return AsyncSubscriptionsWithStreamingResponse(self._coupons.subscriptions)
8 changes: 8 additions & 0 deletions src/orb/resources/coupons/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,35 @@ def list(

class SubscriptionsWithRawResponse:
def __init__(self, subscriptions: Subscriptions) -> None:
self._subscriptions = subscriptions

self.list = _legacy_response.to_raw_response_wrapper(
subscriptions.list,
)


class AsyncSubscriptionsWithRawResponse:
def __init__(self, subscriptions: AsyncSubscriptions) -> None:
self._subscriptions = subscriptions

self.list = _legacy_response.async_to_raw_response_wrapper(
subscriptions.list,
)


class SubscriptionsWithStreamingResponse:
def __init__(self, subscriptions: Subscriptions) -> None:
self._subscriptions = subscriptions

self.list = to_streamed_response_wrapper(
subscriptions.list,
)


class AsyncSubscriptionsWithStreamingResponse:
def __init__(self, subscriptions: AsyncSubscriptions) -> None:
self._subscriptions = subscriptions

self.list = async_to_streamed_response_wrapper(
subscriptions.list,
)
8 changes: 8 additions & 0 deletions src/orb/resources/credit_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ async def fetch(

class CreditNotesWithRawResponse:
def __init__(self, credit_notes: CreditNotes) -> None:
self._credit_notes = credit_notes

self.list = _legacy_response.to_raw_response_wrapper(
credit_notes.list,
)
Expand All @@ -224,6 +226,8 @@ def __init__(self, credit_notes: CreditNotes) -> None:

class AsyncCreditNotesWithRawResponse:
def __init__(self, credit_notes: AsyncCreditNotes) -> None:
self._credit_notes = credit_notes

self.list = _legacy_response.async_to_raw_response_wrapper(
credit_notes.list,
)
Expand All @@ -234,6 +238,8 @@ def __init__(self, credit_notes: AsyncCreditNotes) -> None:

class CreditNotesWithStreamingResponse:
def __init__(self, credit_notes: CreditNotes) -> None:
self._credit_notes = credit_notes

self.list = to_streamed_response_wrapper(
credit_notes.list,
)
Expand All @@ -244,6 +250,8 @@ def __init__(self, credit_notes: CreditNotes) -> None:

class AsyncCreditNotesWithStreamingResponse:
def __init__(self, credit_notes: AsyncCreditNotes) -> None:
self._credit_notes = credit_notes

self.list = async_to_streamed_response_wrapper(
credit_notes.list,
)
Expand Down
8 changes: 8 additions & 0 deletions src/orb/resources/customers/balance_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ def list(

class BalanceTransactionsWithRawResponse:
def __init__(self, balance_transactions: BalanceTransactions) -> None:
self._balance_transactions = balance_transactions

self.create = _legacy_response.to_raw_response_wrapper(
balance_transactions.create,
)
Expand All @@ -341,6 +343,8 @@ def __init__(self, balance_transactions: BalanceTransactions) -> None:

class AsyncBalanceTransactionsWithRawResponse:
def __init__(self, balance_transactions: AsyncBalanceTransactions) -> None:
self._balance_transactions = balance_transactions

self.create = _legacy_response.async_to_raw_response_wrapper(
balance_transactions.create,
)
Expand All @@ -351,6 +355,8 @@ def __init__(self, balance_transactions: AsyncBalanceTransactions) -> None:

class BalanceTransactionsWithStreamingResponse:
def __init__(self, balance_transactions: BalanceTransactions) -> None:
self._balance_transactions = balance_transactions

self.create = to_streamed_response_wrapper(
balance_transactions.create,
)
Expand All @@ -361,6 +367,8 @@ def __init__(self, balance_transactions: BalanceTransactions) -> None:

class AsyncBalanceTransactionsWithStreamingResponse:
def __init__(self, balance_transactions: AsyncBalanceTransactions) -> None:
self._balance_transactions = balance_transactions

self.create = async_to_streamed_response_wrapper(
balance_transactions.create,
)
Expand Down
8 changes: 8 additions & 0 deletions src/orb/resources/customers/costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,8 @@ async def list_by_external_id(

class CostsWithRawResponse:
def __init__(self, costs: Costs) -> None:
self._costs = costs

self.list = _legacy_response.to_raw_response_wrapper(
costs.list,
)
Expand All @@ -835,6 +837,8 @@ def __init__(self, costs: Costs) -> None:

class AsyncCostsWithRawResponse:
def __init__(self, costs: AsyncCosts) -> None:
self._costs = costs

self.list = _legacy_response.async_to_raw_response_wrapper(
costs.list,
)
Expand All @@ -845,6 +849,8 @@ def __init__(self, costs: AsyncCosts) -> None:

class CostsWithStreamingResponse:
def __init__(self, costs: Costs) -> None:
self._costs = costs

self.list = to_streamed_response_wrapper(
costs.list,
)
Expand All @@ -855,6 +861,8 @@ def __init__(self, costs: Costs) -> None:

class AsyncCostsWithStreamingResponse:
def __init__(self, costs: AsyncCosts) -> None:
self._costs = costs

self.list = async_to_streamed_response_wrapper(
costs.list,
)
Expand Down
24 changes: 20 additions & 4 deletions src/orb/resources/customers/credits/credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def list_by_external_id(

class CreditsWithRawResponse:
def __init__(self, credits: Credits) -> None:
self.ledger = LedgerWithRawResponse(credits.ledger)
self._credits = credits

self.list = _legacy_response.to_raw_response_wrapper(
credits.list,
Expand All @@ -298,10 +298,14 @@ def __init__(self, credits: Credits) -> None:
credits.list_by_external_id,
)

@cached_property
def ledger(self) -> LedgerWithRawResponse:
return LedgerWithRawResponse(self._credits.ledger)


class AsyncCreditsWithRawResponse:
def __init__(self, credits: AsyncCredits) -> None:
self.ledger = AsyncLedgerWithRawResponse(credits.ledger)
self._credits = credits

self.list = _legacy_response.async_to_raw_response_wrapper(
credits.list,
Expand All @@ -310,10 +314,14 @@ def __init__(self, credits: AsyncCredits) -> None:
credits.list_by_external_id,
)

@cached_property
def ledger(self) -> AsyncLedgerWithRawResponse:
return AsyncLedgerWithRawResponse(self._credits.ledger)


class CreditsWithStreamingResponse:
def __init__(self, credits: Credits) -> None:
self.ledger = LedgerWithStreamingResponse(credits.ledger)
self._credits = credits

self.list = to_streamed_response_wrapper(
credits.list,
Expand All @@ -322,14 +330,22 @@ def __init__(self, credits: Credits) -> None:
credits.list_by_external_id,
)

@cached_property
def ledger(self) -> LedgerWithStreamingResponse:
return LedgerWithStreamingResponse(self._credits.ledger)


class AsyncCreditsWithStreamingResponse:
def __init__(self, credits: AsyncCredits) -> None:
self.ledger = AsyncLedgerWithStreamingResponse(credits.ledger)
self._credits = credits

self.list = async_to_streamed_response_wrapper(
credits.list,
)
self.list_by_external_id = async_to_streamed_response_wrapper(
credits.list_by_external_id,
)

@cached_property
def ledger(self) -> AsyncLedgerWithStreamingResponse:
return AsyncLedgerWithStreamingResponse(self._credits.ledger)
8 changes: 8 additions & 0 deletions src/orb/resources/customers/credits/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4279,6 +4279,8 @@ def list_by_external_id(

class LedgerWithRawResponse:
def __init__(self, ledger: Ledger) -> None:
self._ledger = ledger

self.list = _legacy_response.to_raw_response_wrapper(
ledger.list,
)
Expand All @@ -4295,6 +4297,8 @@ def __init__(self, ledger: Ledger) -> None:

class AsyncLedgerWithRawResponse:
def __init__(self, ledger: AsyncLedger) -> None:
self._ledger = ledger

self.list = _legacy_response.async_to_raw_response_wrapper(
ledger.list,
)
Expand All @@ -4311,6 +4315,8 @@ def __init__(self, ledger: AsyncLedger) -> None:

class LedgerWithStreamingResponse:
def __init__(self, ledger: Ledger) -> None:
self._ledger = ledger

self.list = to_streamed_response_wrapper(
ledger.list,
)
Expand All @@ -4327,6 +4333,8 @@ def __init__(self, ledger: Ledger) -> None:

class AsyncLedgerWithStreamingResponse:
def __init__(self, ledger: AsyncLedger) -> None:
self._ledger = ledger

self.list = async_to_streamed_response_wrapper(
ledger.list,
)
Expand Down
Loading