| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
from json.decoder import JSONDecodeError |
| 5 |
|
| 6 |
from ..core.api_error import ApiError |
| 7 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 8 |
from ..core.http_response import AsyncHttpResponse, HttpResponse |
| 9 |
from ..core.parse_error import ParsingError |
| 10 |
from ..core.pydantic_utilities import parse_obj_as |
| 11 |
from ..core.request_options import RequestOptions |
| 12 |
from ..errors.forbidden_error import ForbiddenError |
| 13 |
from ..errors.not_found_error import NotFoundError |
| 14 |
from ..errors.too_many_requests_error import TooManyRequestsError |
| 15 |
from ..errors.unauthorized_error import UnauthorizedError |
| 16 |
from ..types.get_supplemental_signals_response_content import GetSupplementalSignalsResponseContent |
| 17 |
from ..types.patch_supplemental_signals_response_content import PatchSupplementalSignalsResponseContent |
| 18 |
from pydantic import ValidationError |
| 19 |
|
| 20 |
|
| 21 |
OMIT = typing.cast(typing.Any, ...) |
| 22 |
|
| 23 |
|
| 24 |
class RawSupplementalSignalsClient: |
| 25 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 26 |
self._client_wrapper = client_wrapper |
| 27 |
|
| 28 |
def get( |
| 29 |
self, *, request_options: typing.Optional[RequestOptions] = None |
| 30 |
) -> HttpResponse[GetSupplementalSignalsResponseContent]: |
| 31 |
""" |
| 32 |
Get the supplemental signals configuration for a tenant. |
| 33 |
|
| 34 |
Parameters |
| 35 |
---------- |
| 36 |
request_options : typing.Optional[RequestOptions] |
| 37 |
Request-specific configuration. |
| 38 |
|
| 39 |
Returns |
| 40 |
------- |
| 41 |
HttpResponse[GetSupplementalSignalsResponseContent] |
| 42 |
Supplemental Signals configuration successfully retrieved. |
| 43 |
""" |
| 44 |
_response = self._client_wrapper.httpx_client.request( |
| 45 |
"supplemental-signals", |
| 46 |
method="GET", |
| 47 |
request_options=request_options, |
| 48 |
) |
| 49 |
try: |
| 50 |
if 200 <= _response.status_code < 300: |
| 51 |
_data = typing.cast( |
| 52 |
GetSupplementalSignalsResponseContent, |
| 53 |
parse_obj_as( |
| 54 |
type_=GetSupplementalSignalsResponseContent, |
| 55 |
object_=_response.json(), |
| 56 |
), |
| 57 |
) |
| 58 |
return HttpResponse(response=_response, data=_data) |
| 59 |
if _response.status_code == 401: |
| 60 |
raise UnauthorizedError( |
| 61 |
headers=dict(_response.headers), |
| 62 |
body=typing.cast( |
| 63 |
typing.Any, |
| 64 |
parse_obj_as( |
| 65 |
type_=typing.Any, |
| 66 |
object_=_response.json(), |
| 67 |
), |
| 68 |
), |
| 69 |
) |
| 70 |
if _response.status_code == 403: |
| 71 |
raise ForbiddenError( |
| 72 |
headers=dict(_response.headers), |
| 73 |
body=typing.cast( |
| 74 |
typing.Any, |
| 75 |
parse_obj_as( |
| 76 |
type_=typing.Any, |
| 77 |
object_=_response.json(), |
| 78 |
), |
| 79 |
), |
| 80 |
) |
| 81 |
if _response.status_code == 404: |
| 82 |
raise NotFoundError( |
| 83 |
headers=dict(_response.headers), |
| 84 |
body=typing.cast( |
| 85 |
typing.Any, |
| 86 |
parse_obj_as( |
| 87 |
type_=typing.Any, |
| 88 |
object_=_response.json(), |
| 89 |
), |
| 90 |
), |
| 91 |
) |
| 92 |
if _response.status_code == 429: |
| 93 |
raise TooManyRequestsError( |
| 94 |
headers=dict(_response.headers), |
| 95 |
body=typing.cast( |
| 96 |
typing.Any, |
| 97 |
parse_obj_as( |
| 98 |
type_=typing.Any, |
| 99 |
object_=_response.json(), |
| 100 |
), |
| 101 |
), |
| 102 |
) |
| 103 |
_response_json = _response.json() |
| 104 |
except JSONDecodeError: |
| 105 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 106 |
except ValidationError as e: |
| 107 |
raise ParsingError( |
| 108 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 109 |
) |
| 110 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 111 |
|
| 112 |
def patch( |
| 113 |
self, *, akamai_enabled: bool, request_options: typing.Optional[RequestOptions] = None |
| 114 |
) -> HttpResponse[PatchSupplementalSignalsResponseContent]: |
| 115 |
""" |
| 116 |
Update the supplemental signals configuration for a tenant. |
| 117 |
|
| 118 |
Parameters |
| 119 |
---------- |
| 120 |
akamai_enabled : bool |
| 121 |
Indicates if incoming Akamai Headers should be processed |
| 122 |
|
| 123 |
request_options : typing.Optional[RequestOptions] |
| 124 |
Request-specific configuration. |
| 125 |
|
| 126 |
Returns |
| 127 |
------- |
| 128 |
HttpResponse[PatchSupplementalSignalsResponseContent] |
| 129 |
Supplemental Signals configuration successfully updated. |
| 130 |
""" |
| 131 |
_response = self._client_wrapper.httpx_client.request( |
| 132 |
"supplemental-signals", |
| 133 |
method="PATCH", |
| 134 |
json={ |
| 135 |
"akamai_enabled": akamai_enabled, |
| 136 |
}, |
| 137 |
headers={ |
| 138 |
"content-type": "application/json", |
| 139 |
}, |
| 140 |
request_options=request_options, |
| 141 |
omit=OMIT, |
| 142 |
) |
| 143 |
try: |
| 144 |
if 200 <= _response.status_code < 300: |
| 145 |
_data = typing.cast( |
| 146 |
PatchSupplementalSignalsResponseContent, |
| 147 |
parse_obj_as( |
| 148 |
type_=PatchSupplementalSignalsResponseContent, |
| 149 |
object_=_response.json(), |
| 150 |
), |
| 151 |
) |
| 152 |
return HttpResponse(response=_response, data=_data) |
| 153 |
if _response.status_code == 401: |
| 154 |
raise UnauthorizedError( |
| 155 |
headers=dict(_response.headers), |
| 156 |
body=typing.cast( |
| 157 |
typing.Any, |
| 158 |
parse_obj_as( |
| 159 |
type_=typing.Any, |
| 160 |
object_=_response.json(), |
| 161 |
), |
| 162 |
), |
| 163 |
) |
| 164 |
if _response.status_code == 403: |
| 165 |
raise ForbiddenError( |
| 166 |
headers=dict(_response.headers), |
| 167 |
body=typing.cast( |
| 168 |
typing.Any, |
| 169 |
parse_obj_as( |
| 170 |
type_=typing.Any, |
| 171 |
object_=_response.json(), |
| 172 |
), |
| 173 |
), |
| 174 |
) |
| 175 |
if _response.status_code == 404: |
| 176 |
raise NotFoundError( |
| 177 |
headers=dict(_response.headers), |
| 178 |
body=typing.cast( |
| 179 |
typing.Any, |
| 180 |
parse_obj_as( |
| 181 |
type_=typing.Any, |
| 182 |
object_=_response.json(), |
| 183 |
), |
| 184 |
), |
| 185 |
) |
| 186 |
if _response.status_code == 429: |
| 187 |
raise TooManyRequestsError( |
| 188 |
headers=dict(_response.headers), |
| 189 |
body=typing.cast( |
| 190 |
typing.Any, |
| 191 |
parse_obj_as( |
| 192 |
type_=typing.Any, |
| 193 |
object_=_response.json(), |
| 194 |
), |
| 195 |
), |
| 196 |
) |
| 197 |
_response_json = _response.json() |
| 198 |
except JSONDecodeError: |
| 199 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 200 |
except ValidationError as e: |
| 201 |
raise ParsingError( |
| 202 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 203 |
) |
| 204 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 205 |
|
| 206 |
|
| 207 |
class AsyncRawSupplementalSignalsClient: |
| 208 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 209 |
self._client_wrapper = client_wrapper |
| 210 |
|
| 211 |
async def get( |
| 212 |
self, *, request_options: typing.Optional[RequestOptions] = None |
| 213 |
) -> AsyncHttpResponse[GetSupplementalSignalsResponseContent]: |
| 214 |
""" |
| 215 |
Get the supplemental signals configuration for a tenant. |
| 216 |
|
| 217 |
Parameters |
| 218 |
---------- |
| 219 |
request_options : typing.Optional[RequestOptions] |
| 220 |
Request-specific configuration. |
| 221 |
|
| 222 |
Returns |
| 223 |
------- |
| 224 |
AsyncHttpResponse[GetSupplementalSignalsResponseContent] |
| 225 |
Supplemental Signals configuration successfully retrieved. |
| 226 |
""" |
| 227 |
_response = await self._client_wrapper.httpx_client.request( |
| 228 |
"supplemental-signals", |
| 229 |
method="GET", |
| 230 |
request_options=request_options, |
| 231 |
) |
| 232 |
try: |
| 233 |
if 200 <= _response.status_code < 300: |
| 234 |
_data = typing.cast( |
| 235 |
GetSupplementalSignalsResponseContent, |
| 236 |
parse_obj_as( |
| 237 |
type_=GetSupplementalSignalsResponseContent, |
| 238 |
object_=_response.json(), |
| 239 |
), |
| 240 |
) |
| 241 |
return AsyncHttpResponse(response=_response, data=_data) |
| 242 |
if _response.status_code == 401: |
| 243 |
raise UnauthorizedError( |
| 244 |
headers=dict(_response.headers), |
| 245 |
body=typing.cast( |
| 246 |
typing.Any, |
| 247 |
parse_obj_as( |
| 248 |
type_=typing.Any, |
| 249 |
object_=_response.json(), |
| 250 |
), |
| 251 |
), |
| 252 |
) |
| 253 |
if _response.status_code == 403: |
| 254 |
raise ForbiddenError( |
| 255 |
headers=dict(_response.headers), |
| 256 |
body=typing.cast( |
| 257 |
typing.Any, |
| 258 |
parse_obj_as( |
| 259 |
type_=typing.Any, |
| 260 |
object_=_response.json(), |
| 261 |
), |
| 262 |
), |
| 263 |
) |
| 264 |
if _response.status_code == 404: |
| 265 |
raise NotFoundError( |
| 266 |
headers=dict(_response.headers), |
| 267 |
body=typing.cast( |
| 268 |
typing.Any, |
| 269 |
parse_obj_as( |
| 270 |
type_=typing.Any, |
| 271 |
object_=_response.json(), |
| 272 |
), |
| 273 |
), |
| 274 |
) |
| 275 |
if _response.status_code == 429: |
| 276 |
raise TooManyRequestsError( |
| 277 |
headers=dict(_response.headers), |
| 278 |
body=typing.cast( |
| 279 |
typing.Any, |
| 280 |
parse_obj_as( |
| 281 |
type_=typing.Any, |
| 282 |
object_=_response.json(), |
| 283 |
), |
| 284 |
), |
| 285 |
) |
| 286 |
_response_json = _response.json() |
| 287 |
except JSONDecodeError: |
| 288 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 289 |
except ValidationError as e: |
| 290 |
raise ParsingError( |
| 291 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 292 |
) |
| 293 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 294 |
|
| 295 |
async def patch( |
| 296 |
self, *, akamai_enabled: bool, request_options: typing.Optional[RequestOptions] = None |
| 297 |
) -> AsyncHttpResponse[PatchSupplementalSignalsResponseContent]: |
| 298 |
""" |
| 299 |
Update the supplemental signals configuration for a tenant. |
| 300 |
|
| 301 |
Parameters |
| 302 |
---------- |
| 303 |
akamai_enabled : bool |
| 304 |
Indicates if incoming Akamai Headers should be processed |
| 305 |
|
| 306 |
request_options : typing.Optional[RequestOptions] |
| 307 |
Request-specific configuration. |
| 308 |
|
| 309 |
Returns |
| 310 |
------- |
| 311 |
AsyncHttpResponse[PatchSupplementalSignalsResponseContent] |
| 312 |
Supplemental Signals configuration successfully updated. |
| 313 |
""" |
| 314 |
_response = await self._client_wrapper.httpx_client.request( |
| 315 |
"supplemental-signals", |
| 316 |
method="PATCH", |
| 317 |
json={ |
| 318 |
"akamai_enabled": akamai_enabled, |
| 319 |
}, |
| 320 |
headers={ |
| 321 |
"content-type": "application/json", |
| 322 |
}, |
| 323 |
request_options=request_options, |
| 324 |
omit=OMIT, |
| 325 |
) |
| 326 |
try: |
| 327 |
if 200 <= _response.status_code < 300: |
| 328 |
_data = typing.cast( |
| 329 |
PatchSupplementalSignalsResponseContent, |
| 330 |
parse_obj_as( |
| 331 |
type_=PatchSupplementalSignalsResponseContent, |
| 332 |
object_=_response.json(), |
| 333 |
), |
| 334 |
) |
| 335 |
return AsyncHttpResponse(response=_response, data=_data) |
| 336 |
if _response.status_code == 401: |
| 337 |
raise UnauthorizedError( |
| 338 |
headers=dict(_response.headers), |
| 339 |
body=typing.cast( |
| 340 |
typing.Any, |
| 341 |
parse_obj_as( |
| 342 |
type_=typing.Any, |
| 343 |
object_=_response.json(), |
| 344 |
), |
| 345 |
), |
| 346 |
) |
| 347 |
if _response.status_code == 403: |
| 348 |
raise ForbiddenError( |
| 349 |
headers=dict(_response.headers), |
| 350 |
body=typing.cast( |
| 351 |
typing.Any, |
| 352 |
parse_obj_as( |
| 353 |
type_=typing.Any, |
| 354 |
object_=_response.json(), |
| 355 |
), |
| 356 |
), |
| 357 |
) |
| 358 |
if _response.status_code == 404: |
| 359 |
raise NotFoundError( |
| 360 |
headers=dict(_response.headers), |
| 361 |
body=typing.cast( |
| 362 |
typing.Any, |
| 363 |
parse_obj_as( |
| 364 |
type_=typing.Any, |
| 365 |
object_=_response.json(), |
| 366 |
), |
| 367 |
), |
| 368 |
) |
| 369 |
if _response.status_code == 429: |
| 370 |
raise TooManyRequestsError( |
| 371 |
headers=dict(_response.headers), |
| 372 |
body=typing.cast( |
| 373 |
typing.Any, |
| 374 |
parse_obj_as( |
| 375 |
type_=typing.Any, |
| 376 |
object_=_response.json(), |
| 377 |
), |
| 378 |
), |
| 379 |
) |
| 380 |
_response_json = _response.json() |
| 381 |
except JSONDecodeError: |
| 382 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 383 |
except ValidationError as e: |
| 384 |
raise ParsingError( |
| 385 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 386 |
) |
| 387 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |