Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Aug 14, 2024
1 parent d8a0d01 commit ff005e5
Show file tree
Hide file tree
Showing 18 changed files with 790 additions and 720 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
lint:
name: lint
runs-on: ubuntu-latest
if: github.repository == 'orbcorp/orb-python'


steps:
- uses: actions/checkout@v4
Expand All @@ -33,7 +33,6 @@ jobs:
test:
name: test
runs-on: ubuntu-latest
if: github.repository == 'orbcorp/orb-python'

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-83ae433113181f3839cc63db01cc7c815de1fff597a1cbaf8ffda48ba98268c9.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-67c238400cda65d40994581c7d37ad182a7d737e8abf3accfbc5ac5b04f64f07.yml
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ format = { chain = [
"lint" = { chain = [
"check:ruff",
"typecheck",
"check:importable",
]}
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."

"check:importable" = "python -c 'import orb'"

typecheck = { chain = [
"typecheck:pyright",
"typecheck:mypy"
Expand Down Expand Up @@ -195,7 +198,6 @@ unfixable = [
"T201",
"T203",
]
ignore-init-module-imports = true

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"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"
Expand All @@ -207,7 +209,7 @@ combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["orb", "tests"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
"scripts/**.py" = ["T201", "T203"]
"tests/**.py" = ["T201", "T203"]
Expand Down
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &

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

echo
else
npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL"
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
fi
73 changes: 55 additions & 18 deletions src/orb/resources/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from typing import Union, Iterable, Optional
from datetime import datetime
from typing_extensions import Literal

import httpx

Expand Down Expand Up @@ -154,7 +155,13 @@ def create_for_customer(
customer_id: str,
*,
currency: str,
type: str,
type: Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
],
thresholds: Optional[Iterable[alert_create_for_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -179,9 +186,9 @@ def create_for_customer(
Args:
currency: The case sensitive currency or custom pricing unit to use for this alert.
type: The thresholds that define the values at which the alert will be triggered.
type: The type of alert to create. This must be a valid alert type.
thresholds: The thresholds for the alert.
thresholds: The thresholds that define the values at which the alert will be triggered.
extra_headers: Send extra headers
Expand Down Expand Up @@ -220,7 +227,13 @@ def create_for_external_customer(
external_customer_id: str,
*,
currency: str,
type: str,
type: Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
],
thresholds: Optional[Iterable[alert_create_for_external_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -245,9 +258,9 @@ def create_for_external_customer(
Args:
currency: The case sensitive currency or custom pricing unit to use for this alert.
type: The thresholds that define the values at which the alert will be triggered.
type: The type of alert to create. This must be a valid alert type.
thresholds: The thresholds for the alert.
thresholds: The thresholds that define the values at which the alert will be triggered.
extra_headers: Send extra headers
Expand Down Expand Up @@ -288,7 +301,13 @@ def create_for_subscription(
subscription_id: str,
*,
thresholds: Iterable[alert_create_for_subscription_params.Threshold],
type: str,
type: Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
],
metric_id: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -312,9 +331,9 @@ def create_for_subscription(
usage or cost conditions met during the current billing cycle.
Args:
thresholds: The thresholds for the alert.
thresholds: The thresholds that define the values at which the alert will be triggered.
type: The thresholds that define the values at which the alert will be triggered.
type: The type of alert to create. This must be a valid alert type.
metric_id: The metric to track usage for.
Expand Down Expand Up @@ -560,7 +579,13 @@ async def create_for_customer(
customer_id: str,
*,
currency: str,
type: str,
type: Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
],
thresholds: Optional[Iterable[alert_create_for_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -585,9 +610,9 @@ async def create_for_customer(
Args:
currency: The case sensitive currency or custom pricing unit to use for this alert.
type: The thresholds that define the values at which the alert will be triggered.
type: The type of alert to create. This must be a valid alert type.
thresholds: The thresholds for the alert.
thresholds: The thresholds that define the values at which the alert will be triggered.
extra_headers: Send extra headers
Expand Down Expand Up @@ -626,7 +651,13 @@ async def create_for_external_customer(
external_customer_id: str,
*,
currency: str,
type: str,
type: Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
],
thresholds: Optional[Iterable[alert_create_for_external_customer_params.Threshold]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -651,9 +682,9 @@ async def create_for_external_customer(
Args:
currency: The case sensitive currency or custom pricing unit to use for this alert.
type: The thresholds that define the values at which the alert will be triggered.
type: The type of alert to create. This must be a valid alert type.
thresholds: The thresholds for the alert.
thresholds: The thresholds that define the values at which the alert will be triggered.
extra_headers: Send extra headers
Expand Down Expand Up @@ -694,7 +725,13 @@ async def create_for_subscription(
subscription_id: str,
*,
thresholds: Iterable[alert_create_for_subscription_params.Threshold],
type: str,
type: Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
],
metric_id: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -718,9 +755,9 @@ async def create_for_subscription(
usage or cost conditions met during the current billing cycle.
Args:
thresholds: The thresholds for the alert.
thresholds: The thresholds that define the values at which the alert will be triggered.
type: The thresholds that define the values at which the alert will be triggered.
type: The type of alert to create. This must be a valid alert type.
metric_id: The metric to track usage for.
Expand Down
8 changes: 8 additions & 0 deletions src/orb/resources/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ def ingest(
accurately map usage to the correct billing cycle and ensure that all usage is
billed for in the corresponding billing period.
In general, Orb does not expect events with future dated timestamps. In cases
where the timestamp is at least 24 hours ahead of the current time, the event
will not be accepted as a valid event, and will throw validation errors.
## Event validation
Orb’s validation ensures that you recognize errors in your events as quickly as
Expand Down Expand Up @@ -897,6 +901,10 @@ async def ingest(
accurately map usage to the correct billing cycle and ensure that all usage is
billed for in the corresponding billing period.
In general, Orb does not expect events with future dated timestamps. In cases
where the timestamp is at least 24 hours ahead of the current time, the event
will not be accepted as a valid event, and will throw validation errors.
## Event validation
Orb’s validation ensures that you recognize errors in your events as quickly as
Expand Down
6 changes: 3 additions & 3 deletions src/orb/resources/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from .. import _legacy_response
from ..types import (
shared_params,
invoice_list_params,
invoice_create_params,
invoice_update_params,
Expand All @@ -28,6 +27,7 @@
from ..pagination import SyncPage, AsyncPage
from .._base_client import AsyncPaginator, make_request_options
from ..types.invoice import Invoice
from ..types.shared_params.discount import Discount
from ..types.invoice_fetch_upcoming_response import InvoiceFetchUpcomingResponse

__all__ = ["Invoices", "AsyncInvoices"]
Expand All @@ -50,7 +50,7 @@ def create(
line_items: Iterable[invoice_create_params.LineItem],
net_terms: int,
customer_id: Optional[str] | NotGiven = NOT_GIVEN,
discount: Optional[shared_params.Discount] | NotGiven = NOT_GIVEN,
discount: Optional[Discount] | NotGiven = NOT_GIVEN,
external_customer_id: Optional[str] | NotGiven = NOT_GIVEN,
memo: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -516,7 +516,7 @@ async def create(
line_items: Iterable[invoice_create_params.LineItem],
net_terms: int,
customer_id: Optional[str] | NotGiven = NOT_GIVEN,
discount: Optional[shared_params.Discount] | NotGiven = NOT_GIVEN,
discount: Optional[Discount] | NotGiven = NOT_GIVEN,
external_customer_id: Optional[str] | NotGiven = NOT_GIVEN,
memo: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
Expand Down
16 changes: 12 additions & 4 deletions src/orb/types/alert_create_for_customer_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from typing import Iterable, Optional
from typing_extensions import Required, TypedDict
from typing_extensions import Literal, Required, TypedDict

__all__ = ["AlertCreateForCustomerParams", "Threshold"]

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

type: Required[str]
"""The thresholds that define the values at which the alert will be triggered."""
type: Required[
Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
]
]
"""The type of alert to create. This must be a valid alert type."""

thresholds: Optional[Iterable[Threshold]]
"""The thresholds for the alert."""
"""The thresholds that define the values at which the alert will be triggered."""


class Threshold(TypedDict, total=False):
Expand Down
16 changes: 12 additions & 4 deletions src/orb/types/alert_create_for_external_customer_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from typing import Iterable, Optional
from typing_extensions import Required, TypedDict
from typing_extensions import Literal, Required, TypedDict

__all__ = ["AlertCreateForExternalCustomerParams", "Threshold"]

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

type: Required[str]
"""The thresholds that define the values at which the alert will be triggered."""
type: Required[
Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
]
]
"""The type of alert to create. This must be a valid alert type."""

thresholds: Optional[Iterable[Threshold]]
"""The thresholds for the alert."""
"""The thresholds that define the values at which the alert will be triggered."""


class Threshold(TypedDict, total=False):
Expand Down
16 changes: 12 additions & 4 deletions src/orb/types/alert_create_for_subscription_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
from __future__ import annotations

from typing import Iterable, Optional
from typing_extensions import Required, TypedDict
from typing_extensions import Literal, Required, TypedDict

__all__ = ["AlertCreateForSubscriptionParams", "Threshold"]


class AlertCreateForSubscriptionParams(TypedDict, total=False):
thresholds: Required[Iterable[Threshold]]
"""The thresholds for the alert."""

type: Required[str]
"""The thresholds that define the values at which the alert will be triggered."""

type: Required[
Literal[
"usage_exceeded",
"cost_exceeded",
"credit_balance_depleted",
"credit_balance_dropped",
"credit_balance_recovered",
]
]
"""The type of alert to create. This must be a valid alert type."""

metric_id: Optional[str]
"""The metric to track usage for."""

Expand Down
Loading

0 comments on commit ff005e5

Please sign in to comment.