|
| 1 | +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +# This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +# Copyright 2019-Present Datadog, Inc. |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +from typing import Union, TYPE_CHECKING |
| 7 | + |
| 8 | +from datadog_api_client.model_utils import ( |
| 9 | + ModelNormal, |
| 10 | + cached_property, |
| 11 | + unset, |
| 12 | + UnsetType, |
| 13 | +) |
| 14 | + |
| 15 | + |
| 16 | +if TYPE_CHECKING: |
| 17 | + from datadog_api_client.v1.model.synthetics_basic_auth_jwt_add_claims import SyntheticsBasicAuthJWTAddClaims |
| 18 | + from datadog_api_client.v1.model.synthetics_basic_auth_jwt_algorithm import SyntheticsBasicAuthJWTAlgorithm |
| 19 | + from datadog_api_client.v1.model.synthetics_basic_auth_jwt_type import SyntheticsBasicAuthJWTType |
| 20 | + |
| 21 | + |
| 22 | +class SyntheticsBasicAuthJWT(ModelNormal): |
| 23 | + validations = { |
| 24 | + "expires_in": { |
| 25 | + "inclusive_minimum": 1, |
| 26 | + }, |
| 27 | + } |
| 28 | + |
| 29 | + @cached_property |
| 30 | + def openapi_types(_): |
| 31 | + from datadog_api_client.v1.model.synthetics_basic_auth_jwt_add_claims import SyntheticsBasicAuthJWTAddClaims |
| 32 | + from datadog_api_client.v1.model.synthetics_basic_auth_jwt_algorithm import SyntheticsBasicAuthJWTAlgorithm |
| 33 | + from datadog_api_client.v1.model.synthetics_basic_auth_jwt_type import SyntheticsBasicAuthJWTType |
| 34 | + |
| 35 | + return { |
| 36 | + "add_claims": (SyntheticsBasicAuthJWTAddClaims,), |
| 37 | + "algorithm": (SyntheticsBasicAuthJWTAlgorithm,), |
| 38 | + "expires_in": (int,), |
| 39 | + "header": (str,), |
| 40 | + "payload": (str,), |
| 41 | + "secret": (str,), |
| 42 | + "token_prefix": (str,), |
| 43 | + "type": (SyntheticsBasicAuthJWTType,), |
| 44 | + } |
| 45 | + |
| 46 | + attribute_map = { |
| 47 | + "add_claims": "addClaims", |
| 48 | + "algorithm": "algorithm", |
| 49 | + "expires_in": "expiresIn", |
| 50 | + "header": "header", |
| 51 | + "payload": "payload", |
| 52 | + "secret": "secret", |
| 53 | + "token_prefix": "tokenPrefix", |
| 54 | + "type": "type", |
| 55 | + } |
| 56 | + |
| 57 | + def __init__( |
| 58 | + self_, |
| 59 | + algorithm: SyntheticsBasicAuthJWTAlgorithm, |
| 60 | + payload: str, |
| 61 | + secret: str, |
| 62 | + type: SyntheticsBasicAuthJWTType, |
| 63 | + add_claims: Union[SyntheticsBasicAuthJWTAddClaims, UnsetType] = unset, |
| 64 | + expires_in: Union[int, UnsetType] = unset, |
| 65 | + header: Union[str, UnsetType] = unset, |
| 66 | + token_prefix: Union[str, UnsetType] = unset, |
| 67 | + **kwargs, |
| 68 | + ): |
| 69 | + """ |
| 70 | + Object to handle JWT authentication when performing the test. |
| 71 | +
|
| 72 | + :param add_claims: Standard JWT claims to automatically inject. |
| 73 | + :type add_claims: SyntheticsBasicAuthJWTAddClaims, optional |
| 74 | +
|
| 75 | + :param algorithm: Algorithm to use for the JWT authentication. |
| 76 | + :type algorithm: SyntheticsBasicAuthJWTAlgorithm |
| 77 | +
|
| 78 | + :param expires_in: Token time-to-live in seconds. |
| 79 | + :type expires_in: int, optional |
| 80 | +
|
| 81 | + :param header: Custom JWT header as a JSON string. |
| 82 | + :type header: str, optional |
| 83 | +
|
| 84 | + :param payload: JWT claims as a JSON string. |
| 85 | + :type payload: str |
| 86 | +
|
| 87 | + :param secret: Signing key for the JWT authentication. Use the shared secret for ``HS256`` |
| 88 | + or the private key (PEM format) for ``RS256`` and ``ES256``. |
| 89 | + :type secret: str |
| 90 | +
|
| 91 | + :param token_prefix: Prefix added before the token in the ``Authorization`` header. Defaults to ``Bearer``. |
| 92 | + :type token_prefix: str, optional |
| 93 | +
|
| 94 | + :param type: The type of authentication to use when performing the test. |
| 95 | + :type type: SyntheticsBasicAuthJWTType |
| 96 | + """ |
| 97 | + if add_claims is not unset: |
| 98 | + kwargs["add_claims"] = add_claims |
| 99 | + if expires_in is not unset: |
| 100 | + kwargs["expires_in"] = expires_in |
| 101 | + if header is not unset: |
| 102 | + kwargs["header"] = header |
| 103 | + if token_prefix is not unset: |
| 104 | + kwargs["token_prefix"] = token_prefix |
| 105 | + super().__init__(kwargs) |
| 106 | + |
| 107 | + self_.algorithm = algorithm |
| 108 | + self_.payload = payload |
| 109 | + self_.secret = secret |
| 110 | + self_.type = type |
0 commit comments