Skip to content

Commit ff005e5

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#338)
1 parent d8a0d01 commit ff005e5

18 files changed

+790
-720
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
lint:
1313
name: lint
1414
runs-on: ubuntu-latest
15-
if: github.repository == 'orbcorp/orb-python'
15+
1616

1717
steps:
1818
- uses: actions/checkout@v4
@@ -33,7 +33,6 @@ jobs:
3333
test:
3434
name: test
3535
runs-on: ubuntu-latest
36-
if: github.repository == 'orbcorp/orb-python'
3736

3837
steps:
3938
- uses: actions/checkout@v4

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 91
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-83ae433113181f3839cc63db01cc7c815de1fff597a1cbaf8ffda48ba98268c9.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-67c238400cda65d40994581c7d37ad182a7d737e8abf3accfbc5ac5b04f64f07.yml

pyproject.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ format = { chain = [
7676
"lint" = { chain = [
7777
"check:ruff",
7878
"typecheck",
79+
"check:importable",
7980
]}
8081
"check:ruff" = "ruff check ."
8182
"fix:ruff" = "ruff check --fix ."
8283

84+
"check:importable" = "python -c 'import orb'"
85+
8386
typecheck = { chain = [
8487
"typecheck:pyright",
8588
"typecheck:mypy"
@@ -195,7 +198,6 @@ unfixable = [
195198
"T201",
196199
"T203",
197200
]
198-
ignore-init-module-imports = true
199201

200202
[tool.ruff.lint.flake8-tidy-imports.banned-api]
201203
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"
@@ -207,7 +209,7 @@ combine-as-imports = true
207209
extra-standard-library = ["typing_extensions"]
208210
known-first-party = ["orb", "tests"]
209211

210-
[tool.ruff.per-file-ignores]
212+
[tool.ruff.lint.per-file-ignores]
211213
"bin/**.py" = ["T201", "T203"]
212214
"scripts/**.py" = ["T201", "T203"]
213215
"tests/**.py" = ["T201", "T203"]

scripts/mock

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"
2121

2222
# Run prism mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
24-
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL" &> .prism.log &
24+
npm exec --package=@stainless-api/[email protected].5 -- prism mock "$URL" &> .prism.log &
2525

2626
# Wait for server to come online
2727
echo -n "Waiting for server"
@@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then
3737

3838
echo
3939
else
40-
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL"
40+
npm exec --package=@stainless-api/[email protected].5 -- prism mock "$URL"
4141
fi

src/orb/resources/alerts.py

+55-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from typing import Union, Iterable, Optional
66
from datetime import datetime
7+
from typing_extensions import Literal
78

89
import httpx
910

@@ -154,7 +155,13 @@ def create_for_customer(
154155
customer_id: str,
155156
*,
156157
currency: str,
157-
type: str,
158+
type: Literal[
159+
"usage_exceeded",
160+
"cost_exceeded",
161+
"credit_balance_depleted",
162+
"credit_balance_dropped",
163+
"credit_balance_recovered",
164+
],
158165
thresholds: Optional[Iterable[alert_create_for_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
159166
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
160167
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -179,9 +186,9 @@ def create_for_customer(
179186
Args:
180187
currency: The case sensitive currency or custom pricing unit to use for this alert.
181188
182-
type: The thresholds that define the values at which the alert will be triggered.
189+
type: The type of alert to create. This must be a valid alert type.
183190
184-
thresholds: The thresholds for the alert.
191+
thresholds: The thresholds that define the values at which the alert will be triggered.
185192
186193
extra_headers: Send extra headers
187194
@@ -220,7 +227,13 @@ def create_for_external_customer(
220227
external_customer_id: str,
221228
*,
222229
currency: str,
223-
type: str,
230+
type: Literal[
231+
"usage_exceeded",
232+
"cost_exceeded",
233+
"credit_balance_depleted",
234+
"credit_balance_dropped",
235+
"credit_balance_recovered",
236+
],
224237
thresholds: Optional[Iterable[alert_create_for_external_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
225238
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
226239
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -245,9 +258,9 @@ def create_for_external_customer(
245258
Args:
246259
currency: The case sensitive currency or custom pricing unit to use for this alert.
247260
248-
type: The thresholds that define the values at which the alert will be triggered.
261+
type: The type of alert to create. This must be a valid alert type.
249262
250-
thresholds: The thresholds for the alert.
263+
thresholds: The thresholds that define the values at which the alert will be triggered.
251264
252265
extra_headers: Send extra headers
253266
@@ -288,7 +301,13 @@ def create_for_subscription(
288301
subscription_id: str,
289302
*,
290303
thresholds: Iterable[alert_create_for_subscription_params.Threshold],
291-
type: str,
304+
type: Literal[
305+
"usage_exceeded",
306+
"cost_exceeded",
307+
"credit_balance_depleted",
308+
"credit_balance_dropped",
309+
"credit_balance_recovered",
310+
],
292311
metric_id: Optional[str] | NotGiven = NOT_GIVEN,
293312
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
294313
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -312,9 +331,9 @@ def create_for_subscription(
312331
usage or cost conditions met during the current billing cycle.
313332
314333
Args:
315-
thresholds: The thresholds for the alert.
334+
thresholds: The thresholds that define the values at which the alert will be triggered.
316335
317-
type: The thresholds that define the values at which the alert will be triggered.
336+
type: The type of alert to create. This must be a valid alert type.
318337
319338
metric_id: The metric to track usage for.
320339
@@ -560,7 +579,13 @@ async def create_for_customer(
560579
customer_id: str,
561580
*,
562581
currency: str,
563-
type: str,
582+
type: Literal[
583+
"usage_exceeded",
584+
"cost_exceeded",
585+
"credit_balance_depleted",
586+
"credit_balance_dropped",
587+
"credit_balance_recovered",
588+
],
564589
thresholds: Optional[Iterable[alert_create_for_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
565590
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
566591
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -585,9 +610,9 @@ async def create_for_customer(
585610
Args:
586611
currency: The case sensitive currency or custom pricing unit to use for this alert.
587612
588-
type: The thresholds that define the values at which the alert will be triggered.
613+
type: The type of alert to create. This must be a valid alert type.
589614
590-
thresholds: The thresholds for the alert.
615+
thresholds: The thresholds that define the values at which the alert will be triggered.
591616
592617
extra_headers: Send extra headers
593618
@@ -626,7 +651,13 @@ async def create_for_external_customer(
626651
external_customer_id: str,
627652
*,
628653
currency: str,
629-
type: str,
654+
type: Literal[
655+
"usage_exceeded",
656+
"cost_exceeded",
657+
"credit_balance_depleted",
658+
"credit_balance_dropped",
659+
"credit_balance_recovered",
660+
],
630661
thresholds: Optional[Iterable[alert_create_for_external_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
631662
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
632663
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -651,9 +682,9 @@ async def create_for_external_customer(
651682
Args:
652683
currency: The case sensitive currency or custom pricing unit to use for this alert.
653684
654-
type: The thresholds that define the values at which the alert will be triggered.
685+
type: The type of alert to create. This must be a valid alert type.
655686
656-
thresholds: The thresholds for the alert.
687+
thresholds: The thresholds that define the values at which the alert will be triggered.
657688
658689
extra_headers: Send extra headers
659690
@@ -694,7 +725,13 @@ async def create_for_subscription(
694725
subscription_id: str,
695726
*,
696727
thresholds: Iterable[alert_create_for_subscription_params.Threshold],
697-
type: str,
728+
type: Literal[
729+
"usage_exceeded",
730+
"cost_exceeded",
731+
"credit_balance_depleted",
732+
"credit_balance_dropped",
733+
"credit_balance_recovered",
734+
],
698735
metric_id: Optional[str] | NotGiven = NOT_GIVEN,
699736
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
700737
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -718,9 +755,9 @@ async def create_for_subscription(
718755
usage or cost conditions met during the current billing cycle.
719756
720757
Args:
721-
thresholds: The thresholds for the alert.
758+
thresholds: The thresholds that define the values at which the alert will be triggered.
722759
723-
type: The thresholds that define the values at which the alert will be triggered.
760+
type: The type of alert to create. This must be a valid alert type.
724761
725762
metric_id: The metric to track usage for.
726763

src/orb/resources/events/events.py

+8
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ def ingest(
367367
accurately map usage to the correct billing cycle and ensure that all usage is
368368
billed for in the corresponding billing period.
369369
370+
In general, Orb does not expect events with future dated timestamps. In cases
371+
where the timestamp is at least 24 hours ahead of the current time, the event
372+
will not be accepted as a valid event, and will throw validation errors.
373+
370374
## Event validation
371375
372376
Orb’s validation ensures that you recognize errors in your events as quickly as
@@ -897,6 +901,10 @@ async def ingest(
897901
accurately map usage to the correct billing cycle and ensure that all usage is
898902
billed for in the corresponding billing period.
899903
904+
In general, Orb does not expect events with future dated timestamps. In cases
905+
where the timestamp is at least 24 hours ahead of the current time, the event
906+
will not be accepted as a valid event, and will throw validation errors.
907+
900908
## Event validation
901909
902910
Orb’s validation ensures that you recognize errors in your events as quickly as

src/orb/resources/invoices.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from .. import _legacy_response
1212
from ..types import (
13-
shared_params,
1413
invoice_list_params,
1514
invoice_create_params,
1615
invoice_update_params,
@@ -28,6 +27,7 @@
2827
from ..pagination import SyncPage, AsyncPage
2928
from .._base_client import AsyncPaginator, make_request_options
3029
from ..types.invoice import Invoice
30+
from ..types.shared_params.discount import Discount
3131
from ..types.invoice_fetch_upcoming_response import InvoiceFetchUpcomingResponse
3232

3333
__all__ = ["Invoices", "AsyncInvoices"]
@@ -50,7 +50,7 @@ def create(
5050
line_items: Iterable[invoice_create_params.LineItem],
5151
net_terms: int,
5252
customer_id: Optional[str] | NotGiven = NOT_GIVEN,
53-
discount: Optional[shared_params.Discount] | NotGiven = NOT_GIVEN,
53+
discount: Optional[Discount] | NotGiven = NOT_GIVEN,
5454
external_customer_id: Optional[str] | NotGiven = NOT_GIVEN,
5555
memo: Optional[str] | NotGiven = NOT_GIVEN,
5656
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
@@ -516,7 +516,7 @@ async def create(
516516
line_items: Iterable[invoice_create_params.LineItem],
517517
net_terms: int,
518518
customer_id: Optional[str] | NotGiven = NOT_GIVEN,
519-
discount: Optional[shared_params.Discount] | NotGiven = NOT_GIVEN,
519+
discount: Optional[Discount] | NotGiven = NOT_GIVEN,
520520
external_customer_id: Optional[str] | NotGiven = NOT_GIVEN,
521521
memo: Optional[str] | NotGiven = NOT_GIVEN,
522522
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,

src/orb/types/alert_create_for_customer_params.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Iterable, Optional
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
__all__ = ["AlertCreateForCustomerParams", "Threshold"]
99

@@ -12,11 +12,19 @@ class AlertCreateForCustomerParams(TypedDict, total=False):
1212
currency: Required[str]
1313
"""The case sensitive currency or custom pricing unit to use for this alert."""
1414

15-
type: Required[str]
16-
"""The thresholds that define the values at which the alert will be triggered."""
15+
type: Required[
16+
Literal[
17+
"usage_exceeded",
18+
"cost_exceeded",
19+
"credit_balance_depleted",
20+
"credit_balance_dropped",
21+
"credit_balance_recovered",
22+
]
23+
]
24+
"""The type of alert to create. This must be a valid alert type."""
1725

1826
thresholds: Optional[Iterable[Threshold]]
19-
"""The thresholds for the alert."""
27+
"""The thresholds that define the values at which the alert will be triggered."""
2028

2129

2230
class Threshold(TypedDict, total=False):

src/orb/types/alert_create_for_external_customer_params.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Iterable, Optional
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
__all__ = ["AlertCreateForExternalCustomerParams", "Threshold"]
99

@@ -12,11 +12,19 @@ class AlertCreateForExternalCustomerParams(TypedDict, total=False):
1212
currency: Required[str]
1313
"""The case sensitive currency or custom pricing unit to use for this alert."""
1414

15-
type: Required[str]
16-
"""The thresholds that define the values at which the alert will be triggered."""
15+
type: Required[
16+
Literal[
17+
"usage_exceeded",
18+
"cost_exceeded",
19+
"credit_balance_depleted",
20+
"credit_balance_dropped",
21+
"credit_balance_recovered",
22+
]
23+
]
24+
"""The type of alert to create. This must be a valid alert type."""
1725

1826
thresholds: Optional[Iterable[Threshold]]
19-
"""The thresholds for the alert."""
27+
"""The thresholds that define the values at which the alert will be triggered."""
2028

2129

2230
class Threshold(TypedDict, total=False):

src/orb/types/alert_create_for_subscription_params.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
from __future__ import annotations
44

55
from typing import Iterable, Optional
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
__all__ = ["AlertCreateForSubscriptionParams", "Threshold"]
99

1010

1111
class AlertCreateForSubscriptionParams(TypedDict, total=False):
1212
thresholds: Required[Iterable[Threshold]]
13-
"""The thresholds for the alert."""
14-
15-
type: Required[str]
1613
"""The thresholds that define the values at which the alert will be triggered."""
1714

15+
type: Required[
16+
Literal[
17+
"usage_exceeded",
18+
"cost_exceeded",
19+
"credit_balance_depleted",
20+
"credit_balance_dropped",
21+
"credit_balance_recovered",
22+
]
23+
]
24+
"""The type of alert to create. This must be a valid alert type."""
25+
1826
metric_id: Optional[str]
1927
"""The metric to track usage for."""
2028

0 commit comments

Comments
 (0)