| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# File generated from our OpenAPI spec |
| 3 |
from stripe._stripe_service import StripeService |
| 4 |
from stripe._util import sanitize_id |
| 5 |
from typing import Optional, cast |
| 6 |
from typing_extensions import TYPE_CHECKING |
| 7 |
|
| 8 |
if TYPE_CHECKING: |
| 9 |
from stripe._list_object import ListObject |
| 10 |
from stripe._request_options import RequestOptions |
| 11 |
from stripe.billing._alert import Alert |
| 12 |
from stripe.params.billing._alert_activate_params import ( |
| 13 |
AlertActivateParams, |
| 14 |
) |
| 15 |
from stripe.params.billing._alert_archive_params import AlertArchiveParams |
| 16 |
from stripe.params.billing._alert_create_params import AlertCreateParams |
| 17 |
from stripe.params.billing._alert_deactivate_params import ( |
| 18 |
AlertDeactivateParams, |
| 19 |
) |
| 20 |
from stripe.params.billing._alert_list_params import AlertListParams |
| 21 |
from stripe.params.billing._alert_retrieve_params import ( |
| 22 |
AlertRetrieveParams, |
| 23 |
) |
| 24 |
|
| 25 |
|
| 26 |
class AlertService(StripeService): |
| 27 |
def list( |
| 28 |
self, |
| 29 |
params: Optional["AlertListParams"] = None, |
| 30 |
options: Optional["RequestOptions"] = None, |
| 31 |
) -> "ListObject[Alert]": |
| 32 |
""" |
| 33 |
Lists billing active and inactive alerts |
| 34 |
""" |
| 35 |
return cast( |
| 36 |
"ListObject[Alert]", |
| 37 |
self._request( |
| 38 |
"get", |
| 39 |
"/v1/billing/alerts", |
| 40 |
base_address="api", |
| 41 |
params=params, |
| 42 |
options=options, |
| 43 |
), |
| 44 |
) |
| 45 |
|
| 46 |
async def list_async( |
| 47 |
self, |
| 48 |
params: Optional["AlertListParams"] = None, |
| 49 |
options: Optional["RequestOptions"] = None, |
| 50 |
) -> "ListObject[Alert]": |
| 51 |
""" |
| 52 |
Lists billing active and inactive alerts |
| 53 |
""" |
| 54 |
return cast( |
| 55 |
"ListObject[Alert]", |
| 56 |
await self._request_async( |
| 57 |
"get", |
| 58 |
"/v1/billing/alerts", |
| 59 |
base_address="api", |
| 60 |
params=params, |
| 61 |
options=options, |
| 62 |
), |
| 63 |
) |
| 64 |
|
| 65 |
def create( |
| 66 |
self, |
| 67 |
params: "AlertCreateParams", |
| 68 |
options: Optional["RequestOptions"] = None, |
| 69 |
) -> "Alert": |
| 70 |
""" |
| 71 |
Creates a billing alert |
| 72 |
""" |
| 73 |
return cast( |
| 74 |
"Alert", |
| 75 |
self._request( |
| 76 |
"post", |
| 77 |
"/v1/billing/alerts", |
| 78 |
base_address="api", |
| 79 |
params=params, |
| 80 |
options=options, |
| 81 |
), |
| 82 |
) |
| 83 |
|
| 84 |
async def create_async( |
| 85 |
self, |
| 86 |
params: "AlertCreateParams", |
| 87 |
options: Optional["RequestOptions"] = None, |
| 88 |
) -> "Alert": |
| 89 |
""" |
| 90 |
Creates a billing alert |
| 91 |
""" |
| 92 |
return cast( |
| 93 |
"Alert", |
| 94 |
await self._request_async( |
| 95 |
"post", |
| 96 |
"/v1/billing/alerts", |
| 97 |
base_address="api", |
| 98 |
params=params, |
| 99 |
options=options, |
| 100 |
), |
| 101 |
) |
| 102 |
|
| 103 |
def retrieve( |
| 104 |
self, |
| 105 |
id: str, |
| 106 |
params: Optional["AlertRetrieveParams"] = None, |
| 107 |
options: Optional["RequestOptions"] = None, |
| 108 |
) -> "Alert": |
| 109 |
""" |
| 110 |
Retrieves a billing alert given an ID |
| 111 |
""" |
| 112 |
return cast( |
| 113 |
"Alert", |
| 114 |
self._request( |
| 115 |
"get", |
| 116 |
"/v1/billing/alerts/{id}".format(id=sanitize_id(id)), |
| 117 |
base_address="api", |
| 118 |
params=params, |
| 119 |
options=options, |
| 120 |
), |
| 121 |
) |
| 122 |
|
| 123 |
async def retrieve_async( |
| 124 |
self, |
| 125 |
id: str, |
| 126 |
params: Optional["AlertRetrieveParams"] = None, |
| 127 |
options: Optional["RequestOptions"] = None, |
| 128 |
) -> "Alert": |
| 129 |
""" |
| 130 |
Retrieves a billing alert given an ID |
| 131 |
""" |
| 132 |
return cast( |
| 133 |
"Alert", |
| 134 |
await self._request_async( |
| 135 |
"get", |
| 136 |
"/v1/billing/alerts/{id}".format(id=sanitize_id(id)), |
| 137 |
base_address="api", |
| 138 |
params=params, |
| 139 |
options=options, |
| 140 |
), |
| 141 |
) |
| 142 |
|
| 143 |
def activate( |
| 144 |
self, |
| 145 |
id: str, |
| 146 |
params: Optional["AlertActivateParams"] = None, |
| 147 |
options: Optional["RequestOptions"] = None, |
| 148 |
) -> "Alert": |
| 149 |
""" |
| 150 |
Reactivates this alert, allowing it to trigger again. |
| 151 |
""" |
| 152 |
return cast( |
| 153 |
"Alert", |
| 154 |
self._request( |
| 155 |
"post", |
| 156 |
"/v1/billing/alerts/{id}/activate".format(id=sanitize_id(id)), |
| 157 |
base_address="api", |
| 158 |
params=params, |
| 159 |
options=options, |
| 160 |
), |
| 161 |
) |
| 162 |
|
| 163 |
async def activate_async( |
| 164 |
self, |
| 165 |
id: str, |
| 166 |
params: Optional["AlertActivateParams"] = None, |
| 167 |
options: Optional["RequestOptions"] = None, |
| 168 |
) -> "Alert": |
| 169 |
""" |
| 170 |
Reactivates this alert, allowing it to trigger again. |
| 171 |
""" |
| 172 |
return cast( |
| 173 |
"Alert", |
| 174 |
await self._request_async( |
| 175 |
"post", |
| 176 |
"/v1/billing/alerts/{id}/activate".format(id=sanitize_id(id)), |
| 177 |
base_address="api", |
| 178 |
params=params, |
| 179 |
options=options, |
| 180 |
), |
| 181 |
) |
| 182 |
|
| 183 |
def archive( |
| 184 |
self, |
| 185 |
id: str, |
| 186 |
params: Optional["AlertArchiveParams"] = None, |
| 187 |
options: Optional["RequestOptions"] = None, |
| 188 |
) -> "Alert": |
| 189 |
""" |
| 190 |
Archives this alert, removing it from the list view and APIs. This is non-reversible. |
| 191 |
""" |
| 192 |
return cast( |
| 193 |
"Alert", |
| 194 |
self._request( |
| 195 |
"post", |
| 196 |
"/v1/billing/alerts/{id}/archive".format(id=sanitize_id(id)), |
| 197 |
base_address="api", |
| 198 |
params=params, |
| 199 |
options=options, |
| 200 |
), |
| 201 |
) |
| 202 |
|
| 203 |
async def archive_async( |
| 204 |
self, |
| 205 |
id: str, |
| 206 |
params: Optional["AlertArchiveParams"] = None, |
| 207 |
options: Optional["RequestOptions"] = None, |
| 208 |
) -> "Alert": |
| 209 |
""" |
| 210 |
Archives this alert, removing it from the list view and APIs. This is non-reversible. |
| 211 |
""" |
| 212 |
return cast( |
| 213 |
"Alert", |
| 214 |
await self._request_async( |
| 215 |
"post", |
| 216 |
"/v1/billing/alerts/{id}/archive".format(id=sanitize_id(id)), |
| 217 |
base_address="api", |
| 218 |
params=params, |
| 219 |
options=options, |
| 220 |
), |
| 221 |
) |
| 222 |
|
| 223 |
def deactivate( |
| 224 |
self, |
| 225 |
id: str, |
| 226 |
params: Optional["AlertDeactivateParams"] = None, |
| 227 |
options: Optional["RequestOptions"] = None, |
| 228 |
) -> "Alert": |
| 229 |
""" |
| 230 |
Deactivates this alert, preventing it from triggering. |
| 231 |
""" |
| 232 |
return cast( |
| 233 |
"Alert", |
| 234 |
self._request( |
| 235 |
"post", |
| 236 |
"/v1/billing/alerts/{id}/deactivate".format( |
| 237 |
id=sanitize_id(id) |
| 238 |
), |
| 239 |
base_address="api", |
| 240 |
params=params, |
| 241 |
options=options, |
| 242 |
), |
| 243 |
) |
| 244 |
|
| 245 |
async def deactivate_async( |
| 246 |
self, |
| 247 |
id: str, |
| 248 |
params: Optional["AlertDeactivateParams"] = None, |
| 249 |
options: Optional["RequestOptions"] = None, |
| 250 |
) -> "Alert": |
| 251 |
""" |
| 252 |
Deactivates this alert, preventing it from triggering. |
| 253 |
""" |
| 254 |
return cast( |
| 255 |
"Alert", |
| 256 |
await self._request_async( |
| 257 |
"post", |
| 258 |
"/v1/billing/alerts/{id}/deactivate".format( |
| 259 |
id=sanitize_id(id) |
| 260 |
), |
| 261 |
base_address="api", |
| 262 |
params=params, |
| 263 |
options=options, |
| 264 |
), |
| 265 |
) |