diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index fade3e9420..ee14633b07 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -19275,6 +19275,9 @@ components: description: Unique identifier of the global variable. readOnly: true type: string + is_email: + description: Whether this global variable is a persistent email variable with an email address generated by Datadog. + type: boolean is_fido: description: Determines if the global variable is a FIDO variable. type: boolean @@ -19365,7 +19368,7 @@ components: - REGEX - X_PATH SyntheticsGlobalVariableRequest: - description: Details of the global variable to create. + description: Details of the global variable to create or update. properties: attributes: $ref: "#/components/schemas/SyntheticsGlobalVariableAttributes" @@ -19377,6 +19380,13 @@ components: description: Unique identifier of the global variable. readOnly: true type: string + is_email: + description: |- + Whether this global variable is a persistent email variable. Set to `true` and omit `value` when creating + a persistent email variable; Datadog generates an immutable email address. When updating an existing + persistent email variable, omit `value` and either keep `is_email` set to `true` or omit it. + The variable cannot be converted to or from a persistent email variable. + type: boolean is_fido: description: Determines if the global variable is a FIDO variable. type: boolean diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 72ff85f159..787d4bcf53 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -123866,6 +123866,9 @@ components: description: Unique identifier of the global variable. readOnly: true type: string + is_email: + description: Whether this global variable is a persistent email variable with an email address generated by Datadog. + type: boolean is_fido: description: Determines if the global variable is a FIDO variable. type: boolean diff --git a/examples/v1/synthetics/CreateGlobalVariable_2215516655.py b/examples/v1/synthetics/CreateGlobalVariable_2215516655.py new file mode 100644 index 0000000000..96548fc3a5 --- /dev/null +++ b/examples/v1/synthetics/CreateGlobalVariable_2215516655.py @@ -0,0 +1,23 @@ +""" +Create a persistent email global variable returns a generated address +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.synthetics_api import SyntheticsApi +from datadog_api_client.v1.model.synthetics_global_variable_request import SyntheticsGlobalVariableRequest + +body = SyntheticsGlobalVariableRequest( + name="PERSISTENT_EMAIL_EXAMPLESYNTHETIC", + description="Persistent email variable", + tags=[], + is_email=True, +) + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = SyntheticsApi(api_client) + response = api_instance.create_global_variable(body=body) + + print(response) diff --git a/examples/v2/synthetics/PatchGlobalVariable_3138656940.py b/examples/v2/synthetics/PatchGlobalVariable_3138656940.py new file mode 100644 index 0000000000..b8b357088b --- /dev/null +++ b/examples/v2/synthetics/PatchGlobalVariable_3138656940.py @@ -0,0 +1,41 @@ +""" +Patch a persistent email global variable preserves its address and type +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.synthetics_api import SyntheticsApi +from datadog_api_client.v2.model.global_variable_json_patch_request import GlobalVariableJsonPatchRequest +from datadog_api_client.v2.model.global_variable_json_patch_request_data import GlobalVariableJsonPatchRequestData +from datadog_api_client.v2.model.global_variable_json_patch_request_data_attributes import ( + GlobalVariableJsonPatchRequestDataAttributes, +) +from datadog_api_client.v2.model.global_variable_json_patch_type import GlobalVariableJsonPatchType +from datadog_api_client.v2.model.json_patch_operation import JsonPatchOperation +from datadog_api_client.v2.model.json_patch_operation_op import JsonPatchOperationOp + +# there is a valid "synthetics_email_global_variable" in the system +SYNTHETICS_EMAIL_GLOBAL_VARIABLE_ID = environ["SYNTHETICS_EMAIL_GLOBAL_VARIABLE_ID"] + +body = GlobalVariableJsonPatchRequest( + data=GlobalVariableJsonPatchRequestData( + type=GlobalVariableJsonPatchType.GLOBAL_VARIABLES_JSON_PATCH, + attributes=GlobalVariableJsonPatchRequestDataAttributes( + json_patch=[ + JsonPatchOperation( + op=JsonPatchOperationOp.REPLACE, + path="/description", + value="Updated persistent email variable", + ), + ], + ), + ), +) + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = SyntheticsApi(api_client) + response = api_instance.patch_global_variable(variable_id=SYNTHETICS_EMAIL_GLOBAL_VARIABLE_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable.py b/src/datadog_api_client/v1/model/synthetics_global_variable.py index c71be448f2..b0d9fd85fb 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable.py @@ -34,6 +34,7 @@ def openapi_types(_): "attributes": (SyntheticsGlobalVariableAttributes,), "description": (str,), "id": (str,), + "is_email": (bool,), "is_fido": (bool,), "is_totp": (bool,), "name": (str,), @@ -47,6 +48,7 @@ def openapi_types(_): "attributes": "attributes", "description": "description", "id": "id", + "is_email": "is_email", "is_fido": "is_fido", "is_totp": "is_totp", "name": "name", @@ -67,6 +69,7 @@ def __init__( value: SyntheticsGlobalVariableValue, attributes: Union[SyntheticsGlobalVariableAttributes, UnsetType] = unset, id: Union[str, UnsetType] = unset, + is_email: Union[bool, UnsetType] = unset, is_fido: Union[bool, UnsetType] = unset, is_totp: Union[bool, UnsetType] = unset, parse_test_options: Union[SyntheticsGlobalVariableParseTestOptions, UnsetType] = unset, @@ -85,6 +88,9 @@ def __init__( :param id: Unique identifier of the global variable. :type id: str, optional + :param is_email: Whether this global variable is a persistent email variable with an email address generated by Datadog. + :type is_email: bool, optional + :param is_fido: Determines if the global variable is a FIDO variable. :type is_fido: bool, optional @@ -110,6 +116,8 @@ def __init__( kwargs["attributes"] = attributes if id is not unset: kwargs["id"] = id + if is_email is not unset: + kwargs["is_email"] = is_email if is_fido is not unset: kwargs["is_fido"] = is_fido if is_totp is not unset: diff --git a/src/datadog_api_client/v1/model/synthetics_global_variable_request.py b/src/datadog_api_client/v1/model/synthetics_global_variable_request.py index c4606d9f1f..8087984eb4 100644 --- a/src/datadog_api_client/v1/model/synthetics_global_variable_request.py +++ b/src/datadog_api_client/v1/model/synthetics_global_variable_request.py @@ -34,6 +34,7 @@ def openapi_types(_): "attributes": (SyntheticsGlobalVariableAttributes,), "description": (str,), "id": (str,), + "is_email": (bool,), "is_fido": (bool,), "is_totp": (bool,), "name": (str,), @@ -47,6 +48,7 @@ def openapi_types(_): "attributes": "attributes", "description": "description", "id": "id", + "is_email": "is_email", "is_fido": "is_fido", "is_totp": "is_totp", "name": "name", @@ -66,6 +68,7 @@ def __init__( tags: List[str], attributes: Union[SyntheticsGlobalVariableAttributes, UnsetType] = unset, id: Union[str, UnsetType] = unset, + is_email: Union[bool, UnsetType] = unset, is_fido: Union[bool, UnsetType] = unset, is_totp: Union[bool, UnsetType] = unset, parse_test_options: Union[SyntheticsGlobalVariableParseTestOptions, UnsetType] = unset, @@ -74,7 +77,7 @@ def __init__( **kwargs, ): """ - Details of the global variable to create. + Details of the global variable to create or update. :param attributes: Attributes of the global variable. :type attributes: SyntheticsGlobalVariableAttributes, optional @@ -85,6 +88,12 @@ def __init__( :param id: Unique identifier of the global variable. :type id: str, optional + :param is_email: Whether this global variable is a persistent email variable. Set to ``true`` and omit ``value`` when creating + a persistent email variable; Datadog generates an immutable email address. When updating an existing + persistent email variable, omit ``value`` and either keep ``is_email`` set to ``true`` or omit it. + The variable cannot be converted to or from a persistent email variable. + :type is_email: bool, optional + :param is_fido: Determines if the global variable is a FIDO variable. :type is_fido: bool, optional @@ -110,6 +119,8 @@ def __init__( kwargs["attributes"] = attributes if id is not unset: kwargs["id"] = id + if is_email is not unset: + kwargs["is_email"] = is_email if is_fido is not unset: kwargs["is_fido"] = is_fido if is_totp is not unset: diff --git a/src/datadog_api_client/v2/model/synthetics_global_variable.py b/src/datadog_api_client/v2/model/synthetics_global_variable.py index 079508ac71..e115eb178f 100644 --- a/src/datadog_api_client/v2/model/synthetics_global_variable.py +++ b/src/datadog_api_client/v2/model/synthetics_global_variable.py @@ -34,6 +34,7 @@ def openapi_types(_): "attributes": (SyntheticsGlobalVariableAttributes,), "description": (str,), "id": (str,), + "is_email": (bool,), "is_fido": (bool,), "is_totp": (bool,), "name": (str,), @@ -47,6 +48,7 @@ def openapi_types(_): "attributes": "attributes", "description": "description", "id": "id", + "is_email": "is_email", "is_fido": "is_fido", "is_totp": "is_totp", "name": "name", @@ -67,6 +69,7 @@ def __init__( value: SyntheticsGlobalVariableValue, attributes: Union[SyntheticsGlobalVariableAttributes, UnsetType] = unset, id: Union[str, UnsetType] = unset, + is_email: Union[bool, UnsetType] = unset, is_fido: Union[bool, UnsetType] = unset, is_totp: Union[bool, UnsetType] = unset, parse_test_options: Union[SyntheticsGlobalVariableParseTestOptions, UnsetType] = unset, @@ -85,6 +88,9 @@ def __init__( :param id: Unique identifier of the global variable. :type id: str, optional + :param is_email: Whether this global variable is a persistent email variable with an email address generated by Datadog. + :type is_email: bool, optional + :param is_fido: Determines if the global variable is a FIDO variable. :type is_fido: bool, optional @@ -110,6 +116,8 @@ def __init__( kwargs["attributes"] = attributes if id is not unset: kwargs["id"] = id + if is_email is not unset: + kwargs["is_email"] = is_email if is_fido is not unset: kwargs["is_fido"] = is_fido if is_totp is not unset: diff --git a/tests/v1/features/given.json b/tests/v1/features/given.json index bf5e92cd59..17e986b36c 100644 --- a/tests/v1/features/given.json +++ b/tests/v1/features/given.json @@ -306,6 +306,18 @@ "tag": "Synthetics", "operationId": "TriggerTests" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"name\": \"PERSISTENT_EMAIL_{{ unique_upper_alnum }}\",\n \"description\": \"Persistent email variable\",\n \"tags\": [],\n \"is_email\": true\n}\n" + } + ], + "step": "there is a valid \"synthetics_email_global_variable\" in the system", + "key": "synthetics_email_global_variable", + "tag": "Synthetics", + "operationId": "CreateGlobalVariable" + }, { "parameters": [ { diff --git a/tests/v1/features/synthetics.feature b/tests/v1/features/synthetics.feature index d171f07181..eb0526f63f 100644 --- a/tests/v1/features/synthetics.feature +++ b/tests/v1/features/synthetics.feature @@ -179,6 +179,16 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @integration-only @team:ddoghq/synthetics-orchestrating-managing + Scenario: Create a persistent email global variable returns a generated address + Given new "CreateGlobalVariable" request + And body with value {"name": "PERSISTENT_EMAIL_{{ unique_upper_alnum }}", "description": "Persistent email variable", "tags": [], "is_email": true} + When the request is sent + Then the response status is 200 OK + And the response "is_email" is equal to true + And the response "value.secure" is equal to false + And the response "value" has field "value" + @replay-only @team:ddoghq/synthetics-orchestrating-managing Scenario: Create a private location returns "OK" response Given there is a valid "role" in the system diff --git a/tests/v1/features/synthetics_global_variable_email_payload.json b/tests/v1/features/synthetics_global_variable_email_payload.json new file mode 100644 index 0000000000..abfee3e86e --- /dev/null +++ b/tests/v1/features/synthetics_global_variable_email_payload.json @@ -0,0 +1,6 @@ +{ + "name": "PERSISTENT_EMAIL_{{ unique_upper_alnum }}", + "description": "Persistent email variable", + "tags": [], + "is_email": true +} diff --git a/tests/v2/features/synthetics.feature b/tests/v2/features/synthetics.feature index 8be0ca8c28..6a86792503 100644 --- a/tests/v2/features/synthetics.feature +++ b/tests/v2/features/synthetics.feature @@ -458,6 +458,20 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @integration-only @team:ddoghq/synthetics-orchestrating-managing + Scenario: Patch a persistent email global variable preserves its address and type + Given there is a valid "synthetics_email_global_variable" in the system + And new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "synthetics_email_global_variable.id" + And body with value {"data": {"type": "global_variables_json_patch", "attributes": {"json_patch": [{"op": "replace", "path": "/description", "value": "Updated persistent email variable"}]}}} + When the request is sent + Then the response status is 200 OK + And the response "data.id" has the same value as "synthetics_email_global_variable.id" + And the response "data.attributes.description" is equal to "Updated persistent email variable" + And the response "data.attributes.is_email" is equal to true + And the response "data.attributes.value.secure" is equal to false + And the response "data.attributes.value.value" has the same value as "synthetics_email_global_variable.value.value" + @generated @skip @team:ddoghq/synthetics-orchestrating-managing Scenario: Patch a test suite returns "API error response." response Given new "PatchTestSuite" request