Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type as a required field for the different basic auth types #2029

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-07-09 16:56:58.449260",
"spec_repo_commit": "dff08f2a"
"regenerated": "2024-07-10 13:25:09.444118",
"spec_repo_commit": "50aff559"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-07-09 16:56:58.466383",
"spec_repo_commit": "dff08f2a"
"regenerated": "2024-07-10 13:25:09.461711",
"spec_repo_commit": "50aff559"
}
}
}
3 changes: 3 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14067,6 +14067,7 @@ components:
required:
- password
- username
- type
type: object
SyntheticsBasicAuthDigestType:
default: digest
Expand Down Expand Up @@ -14150,6 +14151,7 @@ components:
- tokenApiAuthentication
- clientId
- clientSecret
- type
type: object
SyntheticsBasicAuthOauthClientType:
default: oauth-client
Expand Down Expand Up @@ -14205,6 +14207,7 @@ components:
- password
- tokenApiAuthentication
- username
- type
type: object
SyntheticsBasicAuthOauthROPType:
default: oauth-rop
Expand Down
197 changes: 197 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_1717840259.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
"""
Create a multi-step api test with every type of basicAuth returns "OK - Returns the created test details." response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
from datadog_api_client.v1.model.synthetics_api_test_step import SyntheticsAPITestStep
from datadog_api_client.v1.model.synthetics_api_test_step_subtype import SyntheticsAPITestStepSubtype
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
from datadog_api_client.v1.model.synthetics_basic_auth_digest import SyntheticsBasicAuthDigest
from datadog_api_client.v1.model.synthetics_basic_auth_digest_type import SyntheticsBasicAuthDigestType
from datadog_api_client.v1.model.synthetics_basic_auth_ntlm import SyntheticsBasicAuthNTLM
from datadog_api_client.v1.model.synthetics_basic_auth_ntlm_type import SyntheticsBasicAuthNTLMType
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client import SyntheticsBasicAuthOauthClient
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type import SyntheticsBasicAuthOauthClientType
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop import SyntheticsBasicAuthOauthROP
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop_type import SyntheticsBasicAuthOauthROPType
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
SyntheticsBasicAuthOauthTokenApiAuthentication,
)
from datadog_api_client.v1.model.synthetics_basic_auth_sigv4 import SyntheticsBasicAuthSigv4
from datadog_api_client.v1.model.synthetics_basic_auth_sigv4_type import SyntheticsBasicAuthSigv4Type
from datadog_api_client.v1.model.synthetics_basic_auth_web import SyntheticsBasicAuthWeb
from datadog_api_client.v1.model.synthetics_basic_auth_web_type import SyntheticsBasicAuthWebType
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest

body = SyntheticsAPITest(
config=SyntheticsAPITestConfig(
steps=[
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthWeb(
password="password",
username="username",
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthWeb(
password="password",
username="username",
type=SyntheticsBasicAuthWebType.WEB,
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthSigv4(
access_key="accessKey",
secret_key="secretKey",
type=SyntheticsBasicAuthSigv4Type.SIGV4,
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthNTLM(
type=SyntheticsBasicAuthNTLMType.NTLM,
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthDigest(
password="password",
username="username",
type=SyntheticsBasicAuthDigestType.DIGEST,
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthOauthClient(
access_token_url="accessTokenUrl",
token_api_authentication=SyntheticsBasicAuthOauthTokenApiAuthentication.HEADER,
client_id="clientId",
client_secret="clientSecret",
type=SyntheticsBasicAuthOauthClientType.OAUTH_CLIENT,
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
SyntheticsAPITestStep(
assertions=[
SyntheticsAssertionTarget(
operator=SyntheticsAssertionOperator.IS,
type=SyntheticsAssertionType.STATUS_CODE,
target=200,
),
],
name="request is sent",
request=SyntheticsTestRequest(
url="https://httpbin.org/status/200",
method="GET",
basic_auth=SyntheticsBasicAuthOauthROP(
access_token_url="accessTokenUrl",
password="password",
token_api_authentication=SyntheticsBasicAuthOauthTokenApiAuthentication.HEADER,
username="username",
type=SyntheticsBasicAuthOauthROPType.OAUTH_ROP,
),
),
subtype=SyntheticsAPITestStepSubtype.HTTP,
),
],
),
locations=[
"aws:us-east-2",
],
message="BDD test payload: synthetics_api_test_multi_step_with_every_type_of_basic_auth.json",
name="Example-Synthetic",
options=SyntheticsTestOptions(
tick_every=60,
),
subtype=SyntheticsTestDetailsSubType.MULTI,
type=SyntheticsAPITestType.API,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = SyntheticsApi(api_client)
response = api_instance.create_synthetics_api_test(body=body)

print(response)
13 changes: 4 additions & 9 deletions src/datadog_api_client/v1/model/synthetics_basic_auth_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING
from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


Expand All @@ -34,24 +32,21 @@ def openapi_types(_):
"username": "username",
}

def __init__(
self_, password: str, username: str, type: Union[SyntheticsBasicAuthDigestType, UnsetType] = unset, **kwargs
):
def __init__(self_, password: str, type: SyntheticsBasicAuthDigestType, username: str, **kwargs):
"""
Object to handle digest authentication when performing the test.

:param password: Password to use for the digest authentication.
:type password: str

:param type: The type of basic authentication to use when performing the test.
:type type: SyntheticsBasicAuthDigestType, optional
:type type: SyntheticsBasicAuthDigestType

:param username: Username to use for the digest authentication.
:type username: str
"""
if type is not unset:
kwargs["type"] = type
super().__init__(kwargs)

self_.password = password
self_.type = type
self_.username = username
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def __init__(
client_id: str,
client_secret: str,
token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication,
type: SyntheticsBasicAuthOauthClientType,
audience: Union[str, UnsetType] = unset,
resource: Union[str, UnsetType] = unset,
scope: Union[str, UnsetType] = unset,
type: Union[SyntheticsBasicAuthOauthClientType, UnsetType] = unset,
**kwargs,
):
"""
Expand Down Expand Up @@ -89,19 +89,18 @@ def __init__(
:type token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication

:param type: The type of basic authentication to use when performing the test.
:type type: SyntheticsBasicAuthOauthClientType, optional
:type type: SyntheticsBasicAuthOauthClientType
"""
if audience is not unset:
kwargs["audience"] = audience
if resource is not unset:
kwargs["resource"] = resource
if scope is not unset:
kwargs["scope"] = scope
if type is not unset:
kwargs["type"] = type
super().__init__(kwargs)

self_.access_token_url = access_token_url
self_.client_id = client_id
self_.client_secret = client_secret
self_.token_api_authentication = token_api_authentication
self_.type = type
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def __init__(
access_token_url: str,
password: str,
token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication,
type: SyntheticsBasicAuthOauthROPType,
username: str,
audience: Union[str, UnsetType] = unset,
client_id: Union[str, UnsetType] = unset,
client_secret: Union[str, UnsetType] = unset,
resource: Union[str, UnsetType] = unset,
scope: Union[str, UnsetType] = unset,
type: Union[SyntheticsBasicAuthOauthROPType, UnsetType] = unset,
**kwargs,
):
"""
Expand Down Expand Up @@ -96,7 +96,7 @@ def __init__(
:type token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication

:param type: The type of basic authentication to use when performing the test.
:type type: SyntheticsBasicAuthOauthROPType, optional
:type type: SyntheticsBasicAuthOauthROPType

:param username: Username to use when performing the authentication.
:type username: str
Expand All @@ -111,11 +111,10 @@ def __init__(
kwargs["resource"] = resource
if scope is not unset:
kwargs["scope"] = scope
if type is not unset:
kwargs["type"] = type
super().__init__(kwargs)

self_.access_token_url = access_token_url
self_.password = password
self_.token_api_authentication = token_api_authentication
self_.type = type
self_.username = username
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-07-05T12:58:17.908Z
Loading
Loading