Skip to content

Add bodyType to Synthetics request #901

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

Merged
Merged
Show file tree
Hide file tree
Changes from all 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.4",
"regenerated": "2022-11-08 09:49:27.755753",
"spec_repo_commit": "9146e44b"
"regenerated": "2022-11-08 20:15:12.756844",
"spec_repo_commit": "ce8fbc1a"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-11-08 09:49:27.768024",
"spec_repo_commit": "9146e44b"
"regenerated": "2022-11-08 20:15:12.771024",
"spec_repo_commit": "ce8fbc1a"
}
}
}
20 changes: 20 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13231,6 +13231,8 @@ components:
body:
description: Body to include in the test.
type: string
bodyType:
$ref: '#/components/schemas/SyntheticsTestRequestBodyType'
certificate:
$ref: '#/components/schemas/SyntheticsTestRequestCertificate'
certificateDomains:
Expand Down Expand Up @@ -13309,6 +13311,24 @@ components:
example: https://example.com
type: string
type: object
SyntheticsTestRequestBodyType:
description: Type of the request body.
enum:
- text/plain
- application/json
- text/xml
- text/html
- application/x-www-form-urlencoded
- graphql
example: text/plain
type: string
x-enum-varnames:
- TEXT_PLAIN
- APPLICATION_JSON
- TEXT_XML
- TEXT_HTML
- APPLICATION_X_WWW_FORM_URLENCODED
- GRAPHQL
SyntheticsTestRequestCertificate:
description: Client certificate to use when performing the test request.
properties:
Expand Down
1 change: 1 addition & 0 deletions examples/v1/synthetics/UpdateBrowserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const params: v1.SyntheticsApiUpdateBrowserTestRequest = {
type: "web",
username: "my_username",
},
bodyType: "text/plain",
certificate: {
cert: {},
key: {},
Expand Down
10 changes: 5 additions & 5 deletions features/v1/synthetics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: Synthetics
@generated @skip @team:DataDog/synthetics-app
Scenario: Create a browser test returns "- JSON format is wrong" response
Given new "CreateSyntheticsBrowserTest" request
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 400 - JSON format is wrong

Expand All @@ -59,7 +59,7 @@ Feature: Synthetics
@generated @skip @team:DataDog/synthetics-app
Scenario: Create a browser test returns "Test quota is reached" response
Given new "CreateSyntheticsBrowserTest" request
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 402 Test quota is reached

Expand Down Expand Up @@ -241,23 +241,23 @@ Feature: Synthetics
Scenario: Edit a browser test returns "- JSON format is wrong" response
Given new "UpdateBrowserTest" request
And request contains "public_id" parameter from "REPLACE.ME"
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 400 - JSON format is wrong

@generated @skip @team:DataDog/synthetics-app
Scenario: Edit a browser test returns "- Synthetic Monitoring is not activated for the user" response
Given new "UpdateBrowserTest" request
And request contains "public_id" parameter from "REPLACE.ME"
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 404 - Synthetic Monitoring is not activated for the user

@generated @skip @team:DataDog/synthetics-app
Scenario: Edit a browser test returns "OK" response
Given new "UpdateBrowserTest" request
And request contains "public_id" parameter from "REPLACE.ME"
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "method": "GET", "proxy": {"url": "https://example.com"}, "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 200 OK

Expand Down
1 change: 1 addition & 0 deletions packages/datadog-api-client-v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ export { SyntheticsTestOptionsRetry } from "./models/SyntheticsTestOptionsRetry"
export { SyntheticsTestPauseStatus } from "./models/SyntheticsTestPauseStatus";
export { SyntheticsTestProcessStatus } from "./models/SyntheticsTestProcessStatus";
export { SyntheticsTestRequest } from "./models/SyntheticsTestRequest";
export { SyntheticsTestRequestBodyType } from "./models/SyntheticsTestRequestBodyType";
export { SyntheticsTestRequestCertificate } from "./models/SyntheticsTestRequestCertificate";
export { SyntheticsTestRequestCertificateItem } from "./models/SyntheticsTestRequestCertificateItem";
export { SyntheticsTestRequestProxy } from "./models/SyntheticsTestRequestProxy";
Expand Down
8 changes: 8 additions & 0 deletions packages/datadog-api-client-v1/models/ObjectSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,14 @@ const enumsMap: { [key: string]: any[] } = {
"finished",
"finished_with_error",
],
SyntheticsTestRequestBodyType: [
"text/plain",
"application/json",
"text/xml",
"text/html",
"application/x-www-form-urlencoded",
"graphql",
],
SyntheticsWarningType: ["user_locator"],
TableWidgetCellDisplayMode: ["number", "bar"],
TableWidgetDefinitionType: ["query_table"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import { HTTPMethod } from "./HTTPMethod";
import { SyntheticsBasicAuth } from "./SyntheticsBasicAuth";
import { SyntheticsTestRequestBodyType } from "./SyntheticsTestRequestBodyType";
import { SyntheticsTestRequestCertificate } from "./SyntheticsTestRequestCertificate";
import { SyntheticsTestRequestProxy } from "./SyntheticsTestRequestProxy";

Expand All @@ -26,6 +27,10 @@ export class SyntheticsTestRequest {
* Body to include in the test.
*/
"body"?: string;
/**
* Type of the request body.
*/
"bodyType"?: SyntheticsTestRequestBodyType;
/**
* Client certificate to use when performing the test request.
*/
Expand Down Expand Up @@ -130,6 +135,10 @@ export class SyntheticsTestRequest {
baseName: "body",
type: "string",
},
bodyType: {
baseName: "bodyType",
type: "SyntheticsTestRequestBodyType",
},
certificate: {
baseName: "certificate",
type: "SyntheticsTestRequestCertificate",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2020-Present Datadog, Inc.
*/

export type SyntheticsTestRequestBodyType =
| typeof TEXT_PLAIN
| typeof APPLICATION_JSON
| typeof TEXT_XML
| typeof TEXT_HTML
| typeof APPLICATION_X_WWW_FORM_URLENCODED
| typeof GRAPHQL;
export const TEXT_PLAIN = "text/plain";
export const APPLICATION_JSON = "application/json";
export const TEXT_XML = "text/xml";
export const TEXT_HTML = "text/html";
export const APPLICATION_X_WWW_FORM_URLENCODED =
"application/x-www-form-urlencoded";
export const GRAPHQL = "graphql";