diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 078b9e28..9127b1bd 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.8.0" + ".": "3.9.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 610d8317..da919d93 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 103 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7b65f996788617c2d2f2e8e941d366edd1a2844f15eefec555e220b03bbc6d4c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d4f03b16daf0bae33be634c959dafb0e21b0bcb156beb162f8235394dca88e7c.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 549cce48..6733da71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 3.9.0 (2025-02-27) + +Full Changelog: [v3.8.0...v3.9.0](https://github.com/orbcorp/orb-python/compare/v3.8.0...v3.9.0) + +### Features + +* **api:** api update ([#559](https://github.com/orbcorp/orb-python/issues/559)) ([0ea58b5](https://github.com/orbcorp/orb-python/commit/0ea58b5e7bcd0ded6a04f5875198f73c961acc1e)) + + +### Chores + +* **internal:** properly set __pydantic_private__ ([#557](https://github.com/orbcorp/orb-python/issues/557)) ([5df04a9](https://github.com/orbcorp/orb-python/commit/5df04a9fdffc8eba2dbbe81503f4a8280f8e7dbd)) + ## 3.8.0 (2025-02-25) Full Changelog: [v3.7.0...v3.8.0](https://github.com/orbcorp/orb-python/compare/v3.7.0...v3.8.0) diff --git a/pyproject.toml b/pyproject.toml index d9bb6f56..b91ec64a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "orb-billing" -version = "3.8.0" +version = "3.9.0" description = "The official Python library for the orb API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/orb/_base_client.py b/src/orb/_base_client.py index f1c51f3d..1cace52d 100644 --- a/src/orb/_base_client.py +++ b/src/orb/_base_client.py @@ -63,7 +63,7 @@ ModelBuilderProtocol, ) from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping -from ._compat import model_copy, model_dump +from ._compat import PYDANTIC_V2, model_copy, model_dump from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type from ._response import ( APIResponse, @@ -208,6 +208,9 @@ def _set_private_attributes( model: Type[_T], options: FinalRequestOptions, ) -> None: + if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None: + self.__pydantic_private__ = {} + self._model = model self._client = client self._options = options @@ -293,6 +296,9 @@ def _set_private_attributes( client: AsyncAPIClient, options: FinalRequestOptions, ) -> None: + if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None: + self.__pydantic_private__ = {} + self._model = model self._client = client self._options = options diff --git a/src/orb/_version.py b/src/orb/_version.py index 8d1ad81c..e0ba2562 100644 --- a/src/orb/_version.py +++ b/src/orb/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "orb" -__version__ = "3.8.0" # x-release-please-version +__version__ = "3.9.0" # x-release-please-version diff --git a/src/orb/resources/customers/credits/top_ups.py b/src/orb/resources/customers/credits/top_ups.py index c0fc0a98..e9792791 100644 --- a/src/orb/resources/customers/credits/top_ups.py +++ b/src/orb/resources/customers/credits/top_ups.py @@ -206,7 +206,8 @@ def delete( idempotency_key: str | None = None, ) -> None: """ - Delete top-up + This deactivates the top-up and voids any invoices associated with pending + credit blocks purchased through the top-up. Args: extra_headers: Send extra headers @@ -339,7 +340,8 @@ def delete_by_external_id( idempotency_key: str | None = None, ) -> None: """ - Delete top-up by external ID + This deactivates the top-up and voids any invoices associated with pending + credit blocks purchased through the top-up. Args: extra_headers: Send extra headers @@ -599,7 +601,8 @@ async def delete( idempotency_key: str | None = None, ) -> None: """ - Delete top-up + This deactivates the top-up and voids any invoices associated with pending + credit blocks purchased through the top-up. Args: extra_headers: Send extra headers @@ -732,7 +735,8 @@ async def delete_by_external_id( idempotency_key: str | None = None, ) -> None: """ - Delete top-up by external ID + This deactivates the top-up and voids any invoices associated with pending + credit blocks purchased through the top-up. Args: extra_headers: Send extra headers diff --git a/src/orb/types/subscription.py b/src/orb/types/subscription.py index 6af398ea..f6118f04 100644 --- a/src/orb/types/subscription.py +++ b/src/orb/types/subscription.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_cancel_response.py b/src/orb/types/subscription_cancel_response.py index 16d83f53..797ecfe3 100644 --- a/src/orb/types/subscription_cancel_response.py +++ b/src/orb/types/subscription_cancel_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_create_response.py b/src/orb/types/subscription_create_response.py index f1aca973..5a494c5f 100644 --- a/src/orb/types/subscription_create_response.py +++ b/src/orb/types/subscription_create_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_price_intervals_params.py b/src/orb/types/subscription_price_intervals_params.py index 49e58257..0ae10958 100644 --- a/src/orb/types/subscription_price_intervals_params.py +++ b/src/orb/types/subscription_price_intervals_params.py @@ -2666,6 +2666,14 @@ class Add(TypedDict, total=False): external_price_id: Optional[str] """The external price id of the price to add to the subscription.""" + filter: Optional[str] + """An additional filter to apply to usage queries. + + This filter must be expressed as a boolean + [computed property](/extensibility/advanced-metrics#computed-properties). If + null, usage queries will not include any additional filter. + """ + fixed_fee_quantity_transitions: Optional[Iterable[AddFixedFeeQuantityTransition]] """A list of fixed fee quantity transitions to initialize on the price interval.""" @@ -2687,6 +2695,16 @@ class Add(TypedDict, total=False): price_id: Optional[str] """The id of the price to add to the subscription.""" + usage_customer_ids: Optional[List[str]] + """ + A list of customer IDs whose usage events will be aggregated and billed under + this subscription. By default, a subscription only considers usage events + associated with its attached customer's customer_id. When usage_customer_ids is + provided, the subscription includes usage events from the specified customers + only. Provided usage_customer_ids must be either the customer for this + subscription itself, or any of that customer's children. + """ + class AddAdjustmentAdjustmentNewPercentageDiscount(TypedDict, total=False): adjustment_type: Required[Literal["percentage_discount"]] @@ -2821,6 +2839,14 @@ class Edit(TypedDict, total=False): If not specified, the start date will not be updated. """ + filter: Optional[str] + """An additional filter to apply to usage queries. + + This filter must be expressed as a boolean + [computed property](/extensibility/advanced-metrics#computed-properties). If + null, usage queries will not include any additional filter. + """ + fixed_fee_quantity_transitions: Optional[Iterable[EditFixedFeeQuantityTransition]] """A list of fixed fee quantity transitions to use for this price interval. @@ -2834,6 +2860,16 @@ class Edit(TypedDict, total=False): If not specified, the start date will not be updated. """ + usage_customer_ids: Optional[List[str]] + """ + A list of customer IDs whose usage events will be aggregated and billed under + this subscription. By default, a subscription only considers usage events + associated with its attached customer's customer_id. When usage_customer_ids is + provided, the subscription includes usage events from the specified customers + only. Provided usage_customer_ids must be either the customer for this + subscription itself, or any of that customer's children. + """ + class EditAdjustment(TypedDict, total=False): adjustment_interval_id: Required[str] diff --git a/src/orb/types/subscription_price_intervals_response.py b/src/orb/types/subscription_price_intervals_response.py index 37823cba..0dc1d984 100644 --- a/src/orb/types/subscription_price_intervals_response.py +++ b/src/orb/types/subscription_price_intervals_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_schedule_plan_change_response.py b/src/orb/types/subscription_schedule_plan_change_response.py index bce88950..5549771f 100644 --- a/src/orb/types/subscription_schedule_plan_change_response.py +++ b/src/orb/types/subscription_schedule_plan_change_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_trigger_phase_response.py b/src/orb/types/subscription_trigger_phase_response.py index 1389c7db..a0891557 100644 --- a/src/orb/types/subscription_trigger_phase_response.py +++ b/src/orb/types/subscription_trigger_phase_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_unschedule_cancellation_response.py b/src/orb/types/subscription_unschedule_cancellation_response.py index b0f5ffee..f084f56a 100644 --- a/src/orb/types/subscription_unschedule_cancellation_response.py +++ b/src/orb/types/subscription_unschedule_cancellation_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_unschedule_fixed_fee_quantity_updates_response.py b/src/orb/types/subscription_unschedule_fixed_fee_quantity_updates_response.py index 589339ca..6e27be58 100644 --- a/src/orb/types/subscription_unschedule_fixed_fee_quantity_updates_response.py +++ b/src/orb/types/subscription_unschedule_fixed_fee_quantity_updates_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_unschedule_pending_plan_changes_response.py b/src/orb/types/subscription_unschedule_pending_plan_changes_response.py index 0e4dc3a1..3d5943a6 100644 --- a/src/orb/types/subscription_unschedule_pending_plan_changes_response.py +++ b/src/orb/types/subscription_unschedule_pending_plan_changes_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_update_fixed_fee_quantity_response.py b/src/orb/types/subscription_update_fixed_fee_quantity_response.py index a9209366..4be85ee3 100644 --- a/src/orb/types/subscription_update_fixed_fee_quantity_response.py +++ b/src/orb/types/subscription_update_fixed_fee_quantity_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/src/orb/types/subscription_update_trial_response.py b/src/orb/types/subscription_update_trial_response.py index 40a211ba..c56975f6 100644 --- a/src/orb/types/subscription_update_trial_response.py +++ b/src/orb/types/subscription_update_trial_response.py @@ -381,6 +381,9 @@ class PriceInterval(BaseModel): This is the date that Orb stops billing for this price. """ + filter: Optional[str] = None + """An additional filter to apply to usage queries.""" + fixed_fee_quantity_transitions: Optional[List[PriceIntervalFixedFeeQuantityTransition]] = None """The fixed fee quantity transitions for this price interval. @@ -407,6 +410,12 @@ class PriceInterval(BaseModel): This is the date that Orb starts billing for this price. """ + usage_customer_ids: Optional[List[str]] = None + """ + A list of customer IDs whose usage events will be aggregated and billed under + this price interval. + """ + class RedeemedCoupon(BaseModel): coupon_id: str diff --git a/tests/api_resources/test_subscriptions.py b/tests/api_resources/test_subscriptions.py index 8ce86e5a..89ac2bab 100644 --- a/tests/api_resources/test_subscriptions.py +++ b/tests/api_resources/test_subscriptions.py @@ -592,6 +592,7 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: ], "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "external_price_id": "external_price_id", + "filter": "my_property > 100 AND my_other_property = 'bar'", "fixed_fee_quantity_transitions": [ { "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -624,6 +625,7 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: "metadata": {"foo": "string"}, }, "price_id": "h74gfhdjvn7ujokd", + "usage_customer_ids": ["string"], } ], add_adjustments=[ @@ -644,6 +646,7 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: "price_interval_id": "sdfs6wdjvn7ujokd", "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "filter": "my_property > 100 AND my_other_property = 'bar'", "fixed_fee_quantity_transitions": [ { "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -651,6 +654,7 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: } ], "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "usage_customer_ids": ["string"], } ], edit_adjustments=[ @@ -1734,6 +1738,7 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO ], "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "external_price_id": "external_price_id", + "filter": "my_property > 100 AND my_other_property = 'bar'", "fixed_fee_quantity_transitions": [ { "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1766,6 +1771,7 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO "metadata": {"foo": "string"}, }, "price_id": "h74gfhdjvn7ujokd", + "usage_customer_ids": ["string"], } ], add_adjustments=[ @@ -1786,6 +1792,7 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO "price_interval_id": "sdfs6wdjvn7ujokd", "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "filter": "my_property > 100 AND my_other_property = 'bar'", "fixed_fee_quantity_transitions": [ { "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1793,6 +1800,7 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO } ], "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "usage_customer_ids": ["string"], } ], edit_adjustments=[