Skip to content

feat(api): add method to enable alerts #255

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
May 8, 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
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 82
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-e0338fed09226882fc7e89ae7249ca67d95217701cba0c91b68c7a6cc102fd7f.yml
configured_endpoints: 83
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-2eaf3a96bd08daefaae73e68bb28d49e8f1e0aa6cc308ef67a42be62d7eb049f.yml
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,15 @@ Methods:
- <code title="post /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">unschedule_fixed_fee_quantity_updates</a>(subscription_id, \*\*<a href="src/orb/types/subscription_unschedule_fixed_fee_quantity_updates_params.py">params</a>) -> <a href="./src/orb/types/subscription.py">Subscription</a></code>
- <code title="post /subscriptions/{subscription_id}/unschedule_pending_plan_changes">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">unschedule_pending_plan_changes</a>(subscription_id) -> <a href="./src/orb/types/subscription.py">Subscription</a></code>
- <code title="post /subscriptions/{subscription_id}/update_fixed_fee_quantity">client.subscriptions.<a href="./src/orb/resources/subscriptions.py">update_fixed_fee_quantity</a>(subscription_id, \*\*<a href="src/orb/types/subscription_update_fixed_fee_quantity_params.py">params</a>) -> <a href="./src/orb/types/subscription.py">Subscription</a></code>

# Alerts

Types:

```python
from orb.types import Alert
```

Methods:

- <code title="post /alerts/{alert_configuration_id}/enable">client.alerts.<a href="./src/orb/resources/alerts.py">enable</a>(alert_configuration_id) -> <a href="./src/orb/types/alert.py">Alert</a></code>
8 changes: 8 additions & 0 deletions src/orb/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Orb(SyncAPIClient):
plans: resources.Plans
prices: resources.Prices
subscriptions: resources.Subscriptions
alerts: resources.Alerts
with_raw_response: OrbWithRawResponse
with_streaming_response: OrbWithStreamedResponse

Expand Down Expand Up @@ -138,6 +139,7 @@ def __init__(
self.plans = resources.Plans(self)
self.prices = resources.Prices(self)
self.subscriptions = resources.Subscriptions(self)
self.alerts = resources.Alerts(self)
self.with_raw_response = OrbWithRawResponse(self)
self.with_streaming_response = OrbWithStreamedResponse(self)

Expand Down Expand Up @@ -309,6 +311,7 @@ class AsyncOrb(AsyncAPIClient):
plans: resources.AsyncPlans
prices: resources.AsyncPrices
subscriptions: resources.AsyncSubscriptions
alerts: resources.AsyncAlerts
with_raw_response: AsyncOrbWithRawResponse
with_streaming_response: AsyncOrbWithStreamedResponse

Expand Down Expand Up @@ -388,6 +391,7 @@ def __init__(
self.plans = resources.AsyncPlans(self)
self.prices = resources.AsyncPrices(self)
self.subscriptions = resources.AsyncSubscriptions(self)
self.alerts = resources.AsyncAlerts(self)
self.with_raw_response = AsyncOrbWithRawResponse(self)
self.with_streaming_response = AsyncOrbWithStreamedResponse(self)

Expand Down Expand Up @@ -560,6 +564,7 @@ def __init__(self, client: Orb) -> None:
self.plans = resources.PlansWithRawResponse(client.plans)
self.prices = resources.PricesWithRawResponse(client.prices)
self.subscriptions = resources.SubscriptionsWithRawResponse(client.subscriptions)
self.alerts = resources.AlertsWithRawResponse(client.alerts)


class AsyncOrbWithRawResponse:
Expand All @@ -576,6 +581,7 @@ def __init__(self, client: AsyncOrb) -> None:
self.plans = resources.AsyncPlansWithRawResponse(client.plans)
self.prices = resources.AsyncPricesWithRawResponse(client.prices)
self.subscriptions = resources.AsyncSubscriptionsWithRawResponse(client.subscriptions)
self.alerts = resources.AsyncAlertsWithRawResponse(client.alerts)


class OrbWithStreamedResponse:
Expand All @@ -592,6 +598,7 @@ def __init__(self, client: Orb) -> None:
self.plans = resources.PlansWithStreamingResponse(client.plans)
self.prices = resources.PricesWithStreamingResponse(client.prices)
self.subscriptions = resources.SubscriptionsWithStreamingResponse(client.subscriptions)
self.alerts = resources.AlertsWithStreamingResponse(client.alerts)


class AsyncOrbWithStreamedResponse:
Expand All @@ -608,6 +615,7 @@ def __init__(self, client: AsyncOrb) -> None:
self.plans = resources.AsyncPlansWithStreamingResponse(client.plans)
self.prices = resources.AsyncPricesWithStreamingResponse(client.prices)
self.subscriptions = resources.AsyncSubscriptionsWithStreamingResponse(client.subscriptions)
self.alerts = resources.AsyncAlertsWithStreamingResponse(client.alerts)


Client = Orb
Expand Down
14 changes: 14 additions & 0 deletions src/orb/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
PlansWithStreamingResponse,
AsyncPlansWithStreamingResponse,
)
from .alerts import (
Alerts,
AsyncAlerts,
AlertsWithRawResponse,
AsyncAlertsWithRawResponse,
AlertsWithStreamingResponse,
AsyncAlertsWithStreamingResponse,
)
from .events import (
Events,
AsyncEvents,
Expand Down Expand Up @@ -170,4 +178,10 @@
"AsyncSubscriptionsWithRawResponse",
"SubscriptionsWithStreamingResponse",
"AsyncSubscriptionsWithStreamingResponse",
"Alerts",
"AsyncAlerts",
"AlertsWithRawResponse",
"AsyncAlertsWithRawResponse",
"AlertsWithStreamingResponse",
"AsyncAlertsWithStreamingResponse",
]
157 changes: 157 additions & 0 deletions src/orb/resources/alerts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import httpx

from .. import _legacy_response
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ..types.alert import Alert
from .._base_client import (
make_request_options,
)

__all__ = ["Alerts", "AsyncAlerts"]


class Alerts(SyncAPIResource):
@cached_property
def with_raw_response(self) -> AlertsWithRawResponse:
return AlertsWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AlertsWithStreamingResponse:
return AlertsWithStreamingResponse(self)

def enable(
self,
alert_configuration_id: str,
*,
# 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.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
idempotency_key: str | None = None,
) -> Alert:
"""
This endpoint can be used to enable an alert.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds

idempotency_key: Specify a custom idempotency key for this request
"""
if not alert_configuration_id:
raise ValueError(
f"Expected a non-empty value for `alert_configuration_id` but received {alert_configuration_id!r}"
)
return self._post(
f"/alerts/{alert_configuration_id}/enable",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
idempotency_key=idempotency_key,
),
cast_to=Alert,
)


class AsyncAlerts(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncAlertsWithRawResponse:
return AsyncAlertsWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncAlertsWithStreamingResponse:
return AsyncAlertsWithStreamingResponse(self)

async def enable(
self,
alert_configuration_id: str,
*,
# 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.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
idempotency_key: str | None = None,
) -> Alert:
"""
This endpoint can be used to enable an alert.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds

idempotency_key: Specify a custom idempotency key for this request
"""
if not alert_configuration_id:
raise ValueError(
f"Expected a non-empty value for `alert_configuration_id` but received {alert_configuration_id!r}"
)
return await self._post(
f"/alerts/{alert_configuration_id}/enable",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
idempotency_key=idempotency_key,
),
cast_to=Alert,
)


class AlertsWithRawResponse:
def __init__(self, alerts: Alerts) -> None:
self._alerts = alerts

self.enable = _legacy_response.to_raw_response_wrapper(
alerts.enable,
)


class AsyncAlertsWithRawResponse:
def __init__(self, alerts: AsyncAlerts) -> None:
self._alerts = alerts

self.enable = _legacy_response.async_to_raw_response_wrapper(
alerts.enable,
)


class AlertsWithStreamingResponse:
def __init__(self, alerts: Alerts) -> None:
self._alerts = alerts

self.enable = to_streamed_response_wrapper(
alerts.enable,
)


class AsyncAlertsWithStreamingResponse:
def __init__(self, alerts: AsyncAlerts) -> None:
self._alerts = alerts

self.enable = async_to_streamed_response_wrapper(
alerts.enable,
)
Loading