|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import httpx |
| 6 | + |
| 7 | +from .. import _legacy_response |
| 8 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 9 | +from .._compat import cached_property |
| 10 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 11 | +from .._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper |
| 12 | +from ..types.alert import Alert |
| 13 | +from .._base_client import ( |
| 14 | + make_request_options, |
| 15 | +) |
| 16 | + |
| 17 | +__all__ = ["Alerts", "AsyncAlerts"] |
| 18 | + |
| 19 | + |
| 20 | +class Alerts(SyncAPIResource): |
| 21 | + @cached_property |
| 22 | + def with_raw_response(self) -> AlertsWithRawResponse: |
| 23 | + return AlertsWithRawResponse(self) |
| 24 | + |
| 25 | + @cached_property |
| 26 | + def with_streaming_response(self) -> AlertsWithStreamingResponse: |
| 27 | + return AlertsWithStreamingResponse(self) |
| 28 | + |
| 29 | + def enable( |
| 30 | + self, |
| 31 | + alert_configuration_id: str, |
| 32 | + *, |
| 33 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 34 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 35 | + extra_headers: Headers | None = None, |
| 36 | + extra_query: Query | None = None, |
| 37 | + extra_body: Body | None = None, |
| 38 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 39 | + idempotency_key: str | None = None, |
| 40 | + ) -> Alert: |
| 41 | + """ |
| 42 | + This endpoint can be used to enable an alert. |
| 43 | +
|
| 44 | + Args: |
| 45 | + extra_headers: Send extra headers |
| 46 | +
|
| 47 | + extra_query: Add additional query parameters to the request |
| 48 | +
|
| 49 | + extra_body: Add additional JSON properties to the request |
| 50 | +
|
| 51 | + timeout: Override the client-level default timeout for this request, in seconds |
| 52 | +
|
| 53 | + idempotency_key: Specify a custom idempotency key for this request |
| 54 | + """ |
| 55 | + if not alert_configuration_id: |
| 56 | + raise ValueError( |
| 57 | + f"Expected a non-empty value for `alert_configuration_id` but received {alert_configuration_id!r}" |
| 58 | + ) |
| 59 | + return self._post( |
| 60 | + f"/alerts/{alert_configuration_id}/enable", |
| 61 | + options=make_request_options( |
| 62 | + extra_headers=extra_headers, |
| 63 | + extra_query=extra_query, |
| 64 | + extra_body=extra_body, |
| 65 | + timeout=timeout, |
| 66 | + idempotency_key=idempotency_key, |
| 67 | + ), |
| 68 | + cast_to=Alert, |
| 69 | + ) |
| 70 | + |
| 71 | + |
| 72 | +class AsyncAlerts(AsyncAPIResource): |
| 73 | + @cached_property |
| 74 | + def with_raw_response(self) -> AsyncAlertsWithRawResponse: |
| 75 | + return AsyncAlertsWithRawResponse(self) |
| 76 | + |
| 77 | + @cached_property |
| 78 | + def with_streaming_response(self) -> AsyncAlertsWithStreamingResponse: |
| 79 | + return AsyncAlertsWithStreamingResponse(self) |
| 80 | + |
| 81 | + async def enable( |
| 82 | + self, |
| 83 | + alert_configuration_id: str, |
| 84 | + *, |
| 85 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 86 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 87 | + extra_headers: Headers | None = None, |
| 88 | + extra_query: Query | None = None, |
| 89 | + extra_body: Body | None = None, |
| 90 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 91 | + idempotency_key: str | None = None, |
| 92 | + ) -> Alert: |
| 93 | + """ |
| 94 | + This endpoint can be used to enable an alert. |
| 95 | +
|
| 96 | + Args: |
| 97 | + extra_headers: Send extra headers |
| 98 | +
|
| 99 | + extra_query: Add additional query parameters to the request |
| 100 | +
|
| 101 | + extra_body: Add additional JSON properties to the request |
| 102 | +
|
| 103 | + timeout: Override the client-level default timeout for this request, in seconds |
| 104 | +
|
| 105 | + idempotency_key: Specify a custom idempotency key for this request |
| 106 | + """ |
| 107 | + if not alert_configuration_id: |
| 108 | + raise ValueError( |
| 109 | + f"Expected a non-empty value for `alert_configuration_id` but received {alert_configuration_id!r}" |
| 110 | + ) |
| 111 | + return await self._post( |
| 112 | + f"/alerts/{alert_configuration_id}/enable", |
| 113 | + options=make_request_options( |
| 114 | + extra_headers=extra_headers, |
| 115 | + extra_query=extra_query, |
| 116 | + extra_body=extra_body, |
| 117 | + timeout=timeout, |
| 118 | + idempotency_key=idempotency_key, |
| 119 | + ), |
| 120 | + cast_to=Alert, |
| 121 | + ) |
| 122 | + |
| 123 | + |
| 124 | +class AlertsWithRawResponse: |
| 125 | + def __init__(self, alerts: Alerts) -> None: |
| 126 | + self._alerts = alerts |
| 127 | + |
| 128 | + self.enable = _legacy_response.to_raw_response_wrapper( |
| 129 | + alerts.enable, |
| 130 | + ) |
| 131 | + |
| 132 | + |
| 133 | +class AsyncAlertsWithRawResponse: |
| 134 | + def __init__(self, alerts: AsyncAlerts) -> None: |
| 135 | + self._alerts = alerts |
| 136 | + |
| 137 | + self.enable = _legacy_response.async_to_raw_response_wrapper( |
| 138 | + alerts.enable, |
| 139 | + ) |
| 140 | + |
| 141 | + |
| 142 | +class AlertsWithStreamingResponse: |
| 143 | + def __init__(self, alerts: Alerts) -> None: |
| 144 | + self._alerts = alerts |
| 145 | + |
| 146 | + self.enable = to_streamed_response_wrapper( |
| 147 | + alerts.enable, |
| 148 | + ) |
| 149 | + |
| 150 | + |
| 151 | +class AsyncAlertsWithStreamingResponse: |
| 152 | + def __init__(self, alerts: AsyncAlerts) -> None: |
| 153 | + self._alerts = alerts |
| 154 | + |
| 155 | + self.enable = async_to_streamed_response_wrapper( |
| 156 | + alerts.enable, |
| 157 | + ) |
0 commit comments