Skip to content

Commit cf49252

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add OAuth support for Synthetics tests (#1247)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 52c8f80 commit cf49252

23 files changed

+582
-48
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-11-22 09:27:34.695235",
8-
"spec_repo_commit": "b67ecba8"
7+
"regenerated": "2022-11-22 13:48:52.624197",
8+
"spec_repo_commit": "dad9f2c8"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-11-22 09:27:34.706182",
13-
"spec_repo_commit": "b67ecba8"
12+
"regenerated": "2022-11-22 13:48:52.635220",
13+
"spec_repo_commit": "dad9f2c8"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11523,6 +11523,8 @@ components:
1152311523
- $ref: '#/components/schemas/SyntheticsBasicAuthSigv4'
1152411524
- $ref: '#/components/schemas/SyntheticsBasicAuthNTLM'
1152511525
- $ref: '#/components/schemas/SyntheticsBasicAuthDigest'
11526+
- $ref: '#/components/schemas/SyntheticsBasicAuthOauthClient'
11527+
- $ref: '#/components/schemas/SyntheticsBasicAuthOauthROP'
1152611528
type: object
1152711529
SyntheticsBasicAuthDigest:
1152811530
description: Object to handle digest authentication when performing the test.
@@ -11586,6 +11588,115 @@ components:
1158611588
type: string
1158711589
x-enum-varnames:
1158811590
- NTLM
11591+
SyntheticsBasicAuthOauthClient:
11592+
description: Object to handle `oauth client` authentication when performing
11593+
the test.
11594+
properties:
11595+
accessTokenUrl:
11596+
description: Access token URL to use when performing the authentication.
11597+
example: https://example.com
11598+
type: string
11599+
audience:
11600+
description: Audience to use when performing the authentication.
11601+
example: audience
11602+
type: string
11603+
clientId:
11604+
description: Client ID to use when performing the authentication.
11605+
example: oauth-username
11606+
type: string
11607+
clientSecret:
11608+
description: Client secret to use when performing the authentication.
11609+
example: oauth-password
11610+
type: string
11611+
resource:
11612+
description: Resource to use when performing the authentication.
11613+
example: resource
11614+
type: string
11615+
scope:
11616+
description: Scope to use when performing the authentication.
11617+
example: scope
11618+
type: string
11619+
tokenApiAuthentication:
11620+
$ref: '#/components/schemas/SyntheticsBasicAuthOauthTokenApiAuthentication'
11621+
type:
11622+
$ref: '#/components/schemas/SyntheticsBasicAuthOauthClientType'
11623+
required:
11624+
- accessTokenUrl
11625+
- tokenApiAuthentication
11626+
- clientId
11627+
- clientSecret
11628+
type: object
11629+
SyntheticsBasicAuthOauthClientType:
11630+
default: oauth-client
11631+
description: The type of basic authentication to use when performing the test.
11632+
enum:
11633+
- oauth-client
11634+
example: oauth-client
11635+
type: string
11636+
x-enum-varnames:
11637+
- OAUTH_CLIENT
11638+
SyntheticsBasicAuthOauthROP:
11639+
description: Object to handle `oauth rop` authentication when performing the
11640+
test.
11641+
properties:
11642+
accessTokenUrl:
11643+
description: Access token URL to use when performing the authentication.
11644+
example: https://example.com
11645+
type: string
11646+
audience:
11647+
description: Audience to use when performing the authentication.
11648+
example: audience
11649+
type: string
11650+
clientId:
11651+
description: Client ID to use when performing the authentication.
11652+
example: client-id
11653+
type: string
11654+
clientSecret:
11655+
description: Client secret to use when performing the authentication.
11656+
example: client-secret
11657+
type: string
11658+
password:
11659+
description: Password to use when performing the authentication.
11660+
example: password
11661+
type: string
11662+
resource:
11663+
description: Resource to use when performing the authentication.
11664+
example: resource
11665+
type: string
11666+
scope:
11667+
description: Scope to use when performing the authentication.
11668+
example: scope
11669+
type: string
11670+
type:
11671+
$ref: '#/components/schemas/SyntheticsBasicAuthOauthROPType'
11672+
username:
11673+
description: Username to use when performing the authentication.
11674+
example: username
11675+
type: string
11676+
required:
11677+
- accessTokenUrl
11678+
- password
11679+
- username
11680+
type: object
11681+
SyntheticsBasicAuthOauthROPType:
11682+
default: oauth-rop
11683+
description: The type of basic authentication to use when performing the test.
11684+
enum:
11685+
- oauth-rop
11686+
example: oauth-rop
11687+
type: string
11688+
x-enum-varnames:
11689+
- OAUTH_ROP
11690+
SyntheticsBasicAuthOauthTokenApiAuthentication:
11691+
description: Type of token to use when performing the authentication.
11692+
enum:
11693+
- header
11694+
- body
11695+
example: header
11696+
type: string
11697+
x-enum-varnames:
11698+
- HEADER
11699+
- BODY
1158911700
SyntheticsBasicAuthSigv4:
1159011701
description: Object to handle `SIGV4` authentication when performing the test.
1159111702
properties:

docs/datadog_api_client.v1.model.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,6 +3431,41 @@ synthetics\_basic\_auth\_ntlm\_type
34313431
:members:
34323432
:show-inheritance:
34333433

3434+
synthetics\_basic\_auth\_oauth\_client
3435+
--------------------------------------
3436+
3437+
.. automodule:: datadog_api_client.v1.model.synthetics_basic_auth_oauth_client
3438+
:members:
3439+
:show-inheritance:
3440+
3441+
synthetics\_basic\_auth\_oauth\_client\_type
3442+
--------------------------------------------
3443+
3444+
.. automodule:: datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type
3445+
:members:
3446+
:show-inheritance:
3447+
3448+
synthetics\_basic\_auth\_oauth\_rop
3449+
-----------------------------------
3450+
3451+
.. automodule:: datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop
3452+
:members:
3453+
:show-inheritance:
3454+
3455+
synthetics\_basic\_auth\_oauth\_rop\_type
3456+
-----------------------------------------
3457+
3458+
.. automodule:: datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop_type
3459+
:members:
3460+
:show-inheritance:
3461+
3462+
synthetics\_basic\_auth\_oauth\_token\_api\_authentication
3463+
----------------------------------------------------------
3464+
3465+
.. automodule:: datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication
3466+
:members:
3467+
:show-inheritance:
3468+
34343469
synthetics\_basic\_auth\_sigv4
34353470
------------------------------
34363471

examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator
2020
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
2121
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import SyntheticsAssertionXPathTargetTarget
22+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client import SyntheticsBasicAuthOauthClient
23+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type import SyntheticsBasicAuthOauthClientType
24+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
25+
SyntheticsBasicAuthOauthTokenApiAuthentication,
26+
)
2227
from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable
2328
from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType
2429
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
@@ -94,6 +99,16 @@
9499
url="https://datadoghq.com",
95100
headers=SyntheticsTestHeaders(),
96101
),
102+
basic_auth=SyntheticsBasicAuthOauthClient(
103+
access_token_url="https://datadog-token.com",
104+
audience="audience",
105+
client_id="client-id",
106+
client_secret="client-secret",
107+
resource="resource",
108+
scope="yoyo",
109+
token_api_authentication=SyntheticsBasicAuthOauthTokenApiAuthentication.HEADER,
110+
type=SyntheticsBasicAuthOauthClientType.OAUTH_CLIENT,
111+
),
97112
),
98113
),
99114
locations=[

src/datadog_api_client/v1/model/synthetics_basic_auth.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,27 @@ def __init__(self, **kwargs):
4444
4545
:param workstation: Workstation for the authentication to use when performing the test.
4646
:type workstation: str, optional
47+
48+
:param access_token_url: Access token URL to use when performing the authentication.
49+
:type access_token_url: str
50+
51+
:param audience: Audience to use when performing the authentication.
52+
:type audience: str, optional
53+
54+
:param client_id: Client ID to use when performing the authentication.
55+
:type client_id: str
56+
57+
:param client_secret: Client secret to use when performing the authentication.
58+
:type client_secret: str
59+
60+
:param resource: Resource to use when performing the authentication.
61+
:type resource: str, optional
62+
63+
:param scope: Scope to use when performing the authentication.
64+
:type scope: str, optional
65+
66+
:param token_api_authentication: Type of token to use when performing the authentication.
67+
:type token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication
4768
"""
4869
super().__init__(kwargs)
4970

@@ -60,12 +81,16 @@ def _composed_schemas(_):
6081
from datadog_api_client.v1.model.synthetics_basic_auth_sigv4 import SyntheticsBasicAuthSigv4
6182
from datadog_api_client.v1.model.synthetics_basic_auth_ntlm import SyntheticsBasicAuthNTLM
6283
from datadog_api_client.v1.model.synthetics_basic_auth_digest import SyntheticsBasicAuthDigest
84+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client import SyntheticsBasicAuthOauthClient
85+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop import SyntheticsBasicAuthOauthROP
6386

6487
return {
6588
"oneOf": [
6689
SyntheticsBasicAuthWeb,
6790
SyntheticsBasicAuthSigv4,
6891
SyntheticsBasicAuthNTLM,
6992
SyntheticsBasicAuthDigest,
93+
SyntheticsBasicAuthOauthClient,
94+
SyntheticsBasicAuthOauthROP,
7095
],
7196
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 TYPE_CHECKING, Union
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_oauth_token_api_authentication import (
18+
SyntheticsBasicAuthOauthTokenApiAuthentication,
19+
)
20+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type import SyntheticsBasicAuthOauthClientType
21+
22+
23+
class SyntheticsBasicAuthOauthClient(ModelNormal):
24+
@cached_property
25+
def openapi_types(_):
26+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
27+
SyntheticsBasicAuthOauthTokenApiAuthentication,
28+
)
29+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type import (
30+
SyntheticsBasicAuthOauthClientType,
31+
)
32+
33+
return {
34+
"access_token_url": (str,),
35+
"audience": (str,),
36+
"client_id": (str,),
37+
"client_secret": (str,),
38+
"resource": (str,),
39+
"scope": (str,),
40+
"token_api_authentication": (SyntheticsBasicAuthOauthTokenApiAuthentication,),
41+
"type": (SyntheticsBasicAuthOauthClientType,),
42+
}
43+
44+
attribute_map = {
45+
"access_token_url": "accessTokenUrl",
46+
"audience": "audience",
47+
"client_id": "clientId",
48+
"client_secret": "clientSecret",
49+
"resource": "resource",
50+
"scope": "scope",
51+
"token_api_authentication": "tokenApiAuthentication",
52+
"type": "type",
53+
}
54+
55+
def __init__(
56+
self_,
57+
access_token_url: str,
58+
client_id: str,
59+
client_secret: str,
60+
token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication,
61+
audience: Union[str, UnsetType] = unset,
62+
resource: Union[str, UnsetType] = unset,
63+
scope: Union[str, UnsetType] = unset,
64+
type: Union[SyntheticsBasicAuthOauthClientType, UnsetType] = unset,
65+
**kwargs,
66+
):
67+
"""
68+
Object to handle ``oauth client`` authentication when performing the test.
69+
70+
:param access_token_url: Access token URL to use when performing the authentication.
71+
:type access_token_url: str
72+
73+
:param audience: Audience to use when performing the authentication.
74+
:type audience: str, optional
75+
76+
:param client_id: Client ID to use when performing the authentication.
77+
:type client_id: str
78+
79+
:param client_secret: Client secret to use when performing the authentication.
80+
:type client_secret: str
81+
82+
:param resource: Resource to use when performing the authentication.
83+
:type resource: str, optional
84+
85+
:param scope: Scope to use when performing the authentication.
86+
:type scope: str, optional
87+
88+
:param token_api_authentication: Type of token to use when performing the authentication.
89+
:type token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication
90+
91+
:param type: The type of basic authentication to use when performing the test.
92+
:type type: SyntheticsBasicAuthOauthClientType, optional
93+
"""
94+
if audience is not unset:
95+
kwargs["audience"] = audience
96+
if resource is not unset:
97+
kwargs["resource"] = resource
98+
if scope is not unset:
99+
kwargs["scope"] = scope
100+
if type is not unset:
101+
kwargs["type"] = type
102+
super().__init__(kwargs)
103+
104+
self_.access_token_url = access_token_url
105+
self_.client_id = client_id
106+
self_.client_secret = client_secret
107+
self_.token_api_authentication = token_api_authentication

0 commit comments

Comments
 (0)