diff --git a/.apigentools-info b/.apigentools-info index 5fcb0aac8eb0..4d7e74e268bf 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-04 19:22:31.282078", - "spec_repo_commit": "fd06108d" + "regenerated": "2024-04-05 17:05:05.529697", + "spec_repo_commit": "9b7c8967" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-04 19:22:31.300867", - "spec_repo_commit": "fd06108d" + "regenerated": "2024-04-05 17:05:05.547209", + "spec_repo_commit": "9b7c8967" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 228f2933623b..e08c005f4265 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -15871,6 +15871,11 @@ components: maximum: 65535 minimum: 1 type: integer + files: + description: Files to be used as part of the request in the test. + items: + $ref: '#/components/schemas/SyntheticsTestRequestBodyFile' + type: array follow_redirects: description: Specifies whether or not the request follows redirects. type: boolean @@ -15937,6 +15942,32 @@ components: example: https://example.com type: string type: object + SyntheticsTestRequestBodyFile: + description: Object describing a file to be used as part of the request in the + test. + properties: + bucketKey: + description: Bucket key of the file. + type: string + content: + description: Content of the file. + maxLength: 3145728 + type: string + name: + description: Name of the file. + maxLength: 1500 + type: string + size: + description: Size of the file. + format: int64 + maximum: 3145728 + minimum: 1 + type: integer + type: + description: Type of the file. + maxLength: 1500 + type: string + type: object SyntheticsTestRequestBodyType: description: Type of the request body. enum: @@ -15946,6 +15977,8 @@ components: - text/html - application/x-www-form-urlencoded - graphql + - application/octet-stream + - multipart/form-data example: text/plain type: string x-enum-varnames: @@ -15955,6 +15988,8 @@ components: - TEXT_HTML - APPLICATION_X_WWW_FORM_URLENCODED - GRAPHQL + - APPLICATION_OCTET_STREAM + - MULTIPART_FORM_DATA SyntheticsTestRequestCertificate: description: Client certificate to use when performing the test request. properties: diff --git a/cassettes/features/v1/synthetics/Create-an-API-test-with-a-file-payload-returns-OK-Returns-the-created-test-details-response.frozen b/cassettes/features/v1/synthetics/Create-an-API-test-with-a-file-payload-returns-OK-Returns-the-created-test-details-response.frozen new file mode 100644 index 000000000000..42decaa9400d --- /dev/null +++ b/cassettes/features/v1/synthetics/Create-an-API-test-with-a-file-payload-returns-OK-Returns-the-created-test-details-response.frozen @@ -0,0 +1 @@ +2024-04-02T15:35:39.188Z \ No newline at end of file diff --git a/cassettes/features/v1/synthetics/Create-an-API-test-with-a-file-payload-returns-OK-Returns-the-created-test-details-response.yml b/cassettes/features/v1/synthetics/Create-an-API-test-with-a-file-payload-returns-OK-Returns-the-created-test-details-response.yml new file mode 100644 index 000000000000..f2d864bf9cdb --- /dev/null +++ b/cassettes/features/v1/synthetics/Create-an-API-test-with-a-file-payload-returns-OK-Returns-the-created-test-details-response.yml @@ -0,0 +1,53 @@ +http_interactions: +- recorded_at: Tue, 02 Apr 2024 15:35:39 GMT + request: + body: + encoding: UTF-8 + string: '{"config":{"assertions":[{"operator":"is","property":"{{ PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"bodyType":"application/octet-stream","certificate":{"cert":{"content":"cert-content","filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"content":"key-content","filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"files":[{"content":"file + content","name":"file name","type":"file type"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1712072139"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"locations":["aws:us-east-2"],"message":"BDD + test payload: synthetics_api_http_test_payload.json","name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/synthetics/tests/api + response: + body: + encoding: UTF-8 + string: '{"public_id":"sxp-kz5-mk7","name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","status":"live","type":"api","tags":["testing:api"],"created_at":"2024-04-02T15:35:40.509801+00:00","modified_at":"2024-04-02T15:35:40.509801+00:00","config":{"assertions":[{"operator":"is","property":"{{ + PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"bodyType":"application/octet-stream","certificate":{"cert":{"filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"files":[{"name":"file + name","type":"file type","bucketKey":"api-upload-file/sxp-kz5-mk7/2024-04-02T15:35:40.363501_da19b48f-1756-453d-a03d-90526e629d7e.json"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1712072139"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"message":"BDD + test payload: synthetics_api_http_test_payload.json","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"locations":["aws:us-east-2"],"subtype":"http","created_by":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"},"deleted_at":null,"monitor_id":142439982,"org_id":321813,"modified_by":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"}}' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 02 Apr 2024 15:35:39 GMT + request: + body: + encoding: UTF-8 + string: '{"public_ids":["sxp-kz5-mk7"]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/synthetics/tests/delete + response: + body: + encoding: UTF-8 + string: '{"deleted_tests":[{"public_id":"sxp-kz5-mk7","deleted_at":"2024-04-02T15:35:41.326918+00:00"}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.rb b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.rb new file mode 100644 index 000000000000..c9ac6f15829d --- /dev/null +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.rb @@ -0,0 +1,118 @@ +# Create an API test with a file payload returns "OK - Returns the created test details." response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::SyntheticsAPI.new + +body = DatadogAPIClient::V1::SyntheticsAPITest.new({ + config: DatadogAPIClient::V1::SyntheticsAPITestConfig.new({ + assertions: [ + DatadogAPIClient::V1::SyntheticsAssertionTarget.new({ + operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::IS, + property: "{{ PROPERTY }}", + target: "text/html", + type: DatadogAPIClient::V1::SyntheticsAssertionType::HEADER, + }), + DatadogAPIClient::V1::SyntheticsAssertionTarget.new({ + operator: DatadogAPIClient::V1::SyntheticsAssertionOperator::LESS_THAN, + target: 2000, + type: DatadogAPIClient::V1::SyntheticsAssertionType::RESPONSE_TIME, + timings_scope: DatadogAPIClient::V1::SyntheticsAssertionTimingsScope::WITHOUT_DNS, + }), + DatadogAPIClient::V1::SyntheticsAssertionJSONPathTarget.new({ + operator: DatadogAPIClient::V1::SyntheticsAssertionJSONPathOperator::VALIDATES_JSON_PATH, + target: DatadogAPIClient::V1::SyntheticsAssertionJSONPathTargetTarget.new({ + json_path: "topKey", + operator: "isNot", + target_value: "0", + }), + type: DatadogAPIClient::V1::SyntheticsAssertionType::BODY, + }), + DatadogAPIClient::V1::SyntheticsAssertionXPathTarget.new({ + operator: DatadogAPIClient::V1::SyntheticsAssertionXPathOperator::VALIDATES_X_PATH, + target: DatadogAPIClient::V1::SyntheticsAssertionXPathTargetTarget.new({ + x_path: "target-xpath", + target_value: "0", + operator: "contains", + }), + type: DatadogAPIClient::V1::SyntheticsAssertionType::BODY, + }), + ], + config_variables: [ + DatadogAPIClient::V1::SyntheticsConfigVariable.new({ + example: "content-type", + name: "PROPERTY", + pattern: "content-type", + type: DatadogAPIClient::V1::SyntheticsConfigVariableType::TEXT, + }), + ], + request: DatadogAPIClient::V1::SyntheticsTestRequest.new({ + certificate: DatadogAPIClient::V1::SyntheticsTestRequestCertificate.new({ + cert: DatadogAPIClient::V1::SyntheticsTestRequestCertificateItem.new({ + content: "cert-content", + filename: "cert-filename", + updated_at: "2020-10-16T09:23:24.857Z", + }), + key: DatadogAPIClient::V1::SyntheticsTestRequestCertificateItem.new({ + content: "key-content", + filename: "key-filename", + updated_at: "2020-10-16T09:23:24.857Z", + }), + }), + headers: { + unique: "examplesynthetic", + }, + method: "GET", + timeout: 10, + url: "https://datadoghq.com", + proxy: DatadogAPIClient::V1::SyntheticsTestRequestProxy.new({ + url: "https://datadoghq.com", + headers: {}, + }), + body_type: DatadogAPIClient::V1::SyntheticsTestRequestBodyType::APPLICATION_OCTET_STREAM, + files: [ + DatadogAPIClient::V1::SyntheticsTestRequestBodyFile.new({ + name: "file name", + content: "file content", + type: "file type", + }), + ], + basic_auth: DatadogAPIClient::V1::SyntheticsBasicAuthOauthClient.new({ + access_token_url: "https://datadog-token.com", + audience: "audience", + client_id: "client-id", + client_secret: "client-secret", + resource: "resource", + scope: "yoyo", + token_api_authentication: DatadogAPIClient::V1::SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER, + type: DatadogAPIClient::V1::SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT, + }), + persist_cookies: true, + }), + }), + locations: [ + "aws:us-east-2", + ], + message: "BDD test payload: synthetics_api_http_test_payload.json", + name: "Example-Synthetic", + options: DatadogAPIClient::V1::SyntheticsTestOptions.new({ + accept_self_signed: false, + allow_insecure: true, + follow_redirects: true, + min_failure_duration: 10, + min_location_failed: 1, + monitor_name: "Example-Synthetic", + monitor_priority: 5, + _retry: DatadogAPIClient::V1::SyntheticsTestOptionsRetry.new({ + count: 3, + interval: 10, + }), + tick_every: 60, + http_version: DatadogAPIClient::V1::SyntheticsTestOptionsHTTPVersion::HTTP2, + }), + subtype: DatadogAPIClient::V1::SyntheticsTestDetailsSubType::HTTP, + tags: [ + "testing:api", + ], + type: DatadogAPIClient::V1::SyntheticsAPITestType::API, +}) +p api_instance.create_synthetics_api_test(body) diff --git a/examples/v1/synthetics/UpdateBrowserTest.rb b/examples/v1/synthetics/UpdateBrowserTest.rb index eae83bf390b7..fbe012167160 100644 --- a/examples/v1/synthetics/UpdateBrowserTest.rb +++ b/examples/v1/synthetics/UpdateBrowserTest.rb @@ -26,6 +26,9 @@ key: DatadogAPIClient::V1::SyntheticsTestRequestCertificateItem.new({}), }), certificate_domains: [], + files: [ + DatadogAPIClient::V1::SyntheticsTestRequestBodyFile.new({}), + ], http_version: DatadogAPIClient::V1::SyntheticsTestOptionsHTTPVersion::HTTP1, proxy: DatadogAPIClient::V1::SyntheticsTestRequestProxy.new({ url: "https://example.com", diff --git a/features/v1/synthetics.feature b/features/v1/synthetics.feature index 4942cb45e286..64ccdb946957 100644 --- a/features/v1/synthetics.feature +++ b/features/v1/synthetics.feature @@ -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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} + And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "files": [{}], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -61,7 +61,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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} + And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "files": [{}], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -193,6 +193,17 @@ Feature: Synthetics Then the response status is 200 OK - Returns the created test details. And the response "name" is equal to "{{ unique }}" + @team:DataDog/synthetics-app + Scenario: Create an API test with a file payload returns "OK - Returns the created test details." response + Given new "CreateSyntheticsAPITest" request + And body from file "synthetics_api_http_test_with_file_payload.json" + When the request is sent + Then the response status is 200 OK - Returns the created test details. + And the response "name" is equal to "{{ unique }}" + And the response "config.request.files[0].name" is equal to "file name" + And the response "config.request.files[0].type" is equal to "file type" + And the response "config.request.files[0]" has field "bucketKey" + @team:DataDog/synthetics-app Scenario: Create an API test with multi subtype returns "OK - Returns the created test details." response Given new "CreateSyntheticsAPITest" request @@ -205,6 +216,7 @@ Feature: Synthetics And the response "config.steps[0].request.httpVersion" is equal to "http2" And the response "config.steps[0].extractedValues[0].secure" is equal to true And the response "config.steps[1].request.host" is equal to "grpcbin.test.k6.io" + And the response "config.steps[1].request.host" is equal to "grpcbin.test.k6.io" @generated @skip @team:DataDog/synthetics-app Scenario: Delete a global variable returns "JSON format is wrong" response @@ -268,7 +280,7 @@ 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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} + And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "files": [{}], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -276,7 +288,7 @@ Feature: Synthetics 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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} + And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "files": [{}], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -284,7 +296,7 @@ Feature: Synthetics 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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} + And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "files": [{}], "httpVersion": "http1", "proxy": {"url": "https://example.com"}, "service": "Greeter", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} When the request is sent Then the response status is 200 OK diff --git a/features/v1/synthetics_api_http_test_with_file_payload.json b/features/v1/synthetics_api_http_test_with_file_payload.json new file mode 100644 index 000000000000..bf4f0e4ad95f --- /dev/null +++ b/features/v1/synthetics_api_http_test_with_file_payload.json @@ -0,0 +1,96 @@ +{ + "config": { + "assertions": [ + { + "operator": "is", + "property": "{{ '{{ PROPERTY }}' }}", + "target": "text/html", + "type": "header" + }, + { "operator": "lessThan", "target": 2000, "type": "responseTime", "timingsScope": "withoutDNS" }, + { + "operator": "validatesJSONPath", + "target": { + "jsonPath": "topKey", + "operator": "isNot", + "targetValue": "0" + }, + "type": "body" + }, + { + "operator": "validatesXPath", + "target": { + "xPath": "target-xpath", + "targetValue": "0", + "operator": "contains" + }, + "type": "body" + } + ], + "configVariables": [ + { + "example": "content-type", + "name": "PROPERTY", + "pattern": "content-type", + "type": "text" + } + ], + "request": { + "certificate": { + "cert": { + "content": "cert-content", + "filename": "cert-filename", + "updatedAt": "2020-10-16T09:23:24.857Z" + }, + "key": { + "content": "key-content", + "filename": "key-filename", + "updatedAt": "2020-10-16T09:23:24.857Z" + } + }, + "headers": { "unique": "{{ unique_lower_alnum }}" }, + "method": "GET", + "timeout": 10, + "url": "https://datadoghq.com", + "proxy": { + "url": "https://datadoghq.com", + "headers": {} + }, + "bodyType": "application/octet-stream", + "files": [{ + "name": "file name", + "content": "file content", + "type": "file type" + }], + "basicAuth": { + "accessTokenUrl": "https://datadog-token.com", + "audience": "audience", + "clientId": "client-id", + "clientSecret": "client-secret", + "resource": "resource", + "scope": "yoyo", + "tokenApiAuthentication": "header", + "type": "oauth-client" + }, + "persistCookies": true + } + }, + "locations": ["aws:us-east-2"], + "message": "BDD test payload: synthetics_api_http_test_payload.json", + "name": "{{ unique }}", + "options": { + "accept_self_signed": false, + "allow_insecure": true, + "follow_redirects": true, + "min_failure_duration": 10, + "min_location_failed": 1, + "monitor_name": "{{ unique }}", + "monitor_priority": 5, + "retry": { "count": 3, "interval": 10 }, + "tick_every": 60, + "httpVersion": "http2" + }, + "subtype": "http", + "tags": ["testing:api"], + "type": "api" + } diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 60a0c41b15d3..f48ac28fd0e0 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -655,6 +655,7 @@ def overrides "v1.synthetics_test_pause_status" => "SyntheticsTestPauseStatus", "v1.synthetics_test_process_status" => "SyntheticsTestProcessStatus", "v1.synthetics_test_request" => "SyntheticsTestRequest", + "v1.synthetics_test_request_body_file" => "SyntheticsTestRequestBodyFile", "v1.synthetics_test_request_body_type" => "SyntheticsTestRequestBodyType", "v1.synthetics_test_request_certificate" => "SyntheticsTestRequestCertificate", "v1.synthetics_test_request_certificate_item" => "SyntheticsTestRequestCertificateItem", diff --git a/lib/datadog_api_client/v1/models/synthetics_test_request.rb b/lib/datadog_api_client/v1/models/synthetics_test_request.rb index 8ab0186d32aa..ee0f71024202 100644 --- a/lib/datadog_api_client/v1/models/synthetics_test_request.rb +++ b/lib/datadog_api_client/v1/models/synthetics_test_request.rb @@ -54,6 +54,9 @@ class SyntheticsTestRequest # DNS server port to use for DNS tests. attr_reader :dns_server_port + # Files to be used as part of the request in the test. + attr_accessor :files + # Specifies whether or not the request follows redirects. attr_accessor :follow_redirects @@ -125,6 +128,7 @@ def self.attribute_map :'compressed_proto_file' => :'compressedProtoFile', :'dns_server' => :'dnsServer', :'dns_server_port' => :'dnsServerPort', + :'files' => :'files', :'follow_redirects' => :'follow_redirects', :'headers' => :'headers', :'host' => :'host', @@ -161,6 +165,7 @@ def self.openapi_types :'compressed_proto_file' => :'String', :'dns_server' => :'String', :'dns_server_port' => :'Integer', + :'files' => :'Array', :'follow_redirects' => :'Boolean', :'headers' => :'Hash', :'host' => :'String', @@ -244,6 +249,12 @@ def initialize(attributes = {}) self.dns_server_port = attributes[:'dns_server_port'] end + if attributes.key?(:'files') + if (value = attributes[:'files']).is_a?(Array) + self.files = value + end + end + if attributes.key?(:'follow_redirects') self.follow_redirects = attributes[:'follow_redirects'] end @@ -371,6 +382,7 @@ def ==(o) compressed_proto_file == o.compressed_proto_file && dns_server == o.dns_server && dns_server_port == o.dns_server_port && + files == o.files && follow_redirects == o.follow_redirects && headers == o.headers && host == o.host && @@ -395,7 +407,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [allow_insecure, basic_auth, body, body_type, call_type, certificate, certificate_domains, compressed_json_descriptor, compressed_proto_file, dns_server, dns_server_port, follow_redirects, headers, host, http_version, message, metadata, method, no_saving_response_body, number_of_packets, persist_cookies, port, proxy, query, servername, service, should_track_hops, timeout, url].hash + [allow_insecure, basic_auth, body, body_type, call_type, certificate, certificate_domains, compressed_json_descriptor, compressed_proto_file, dns_server, dns_server_port, files, follow_redirects, headers, host, http_version, message, metadata, method, no_saving_response_body, number_of_packets, persist_cookies, port, proxy, query, servername, service, should_track_hops, timeout, url].hash end end end diff --git a/lib/datadog_api_client/v1/models/synthetics_test_request_body_file.rb b/lib/datadog_api_client/v1/models/synthetics_test_request_body_file.rb new file mode 100644 index 000000000000..27a7bd2ceecb --- /dev/null +++ b/lib/datadog_api_client/v1/models/synthetics_test_request_body_file.rb @@ -0,0 +1,175 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Object describing a file to be used as part of the request in the test. + class SyntheticsTestRequestBodyFile + include BaseGenericModel + + # Bucket key of the file. + attr_accessor :bucket_key + + # Content of the file. + attr_reader :content + + # Name of the file. + attr_reader :name + + # Size of the file. + attr_reader :size + + # Type of the file. + attr_reader :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'bucket_key' => :'bucketKey', + :'content' => :'content', + :'name' => :'name', + :'size' => :'size', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'bucket_key' => :'String', + :'content' => :'String', + :'name' => :'String', + :'size' => :'Integer', + :'type' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::SyntheticsTestRequestBodyFile` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::SyntheticsTestRequestBodyFile`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'bucket_key') + self.bucket_key = attributes[:'bucket_key'] + end + + if attributes.key?(:'content') + self.content = attributes[:'content'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'size') + self.size = attributes[:'size'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if !@content.nil? && @content.to_s.length > 3145728 + return false if !@name.nil? && @name.to_s.length > 1500 + return false if !@size.nil? && @size > 3145728 + return false if !@size.nil? && @size < 1 + return false if !@type.nil? && @type.to_s.length > 1500 + true + end + + # Custom attribute writer method with validation + # @param content [Object] Object to be assigned + # @!visibility private + def content=(content) + if !content.nil? && content.to_s.length > 3145728 + fail ArgumentError, 'invalid value for "content", the character length must be smaller than or equal to 3145728.' + end + @content = content + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if !name.nil? && name.to_s.length > 1500 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 1500.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param size [Object] Object to be assigned + # @!visibility private + def size=(size) + if !size.nil? && size > 3145728 + fail ArgumentError, 'invalid value for "size", must be smaller than or equal to 3145728.' + end + if !size.nil? && size < 1 + fail ArgumentError, 'invalid value for "size", must be greater than or equal to 1.' + end + @size = size + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if !type.nil? && type.to_s.length > 1500 + fail ArgumentError, 'invalid value for "type", the character length must be smaller than or equal to 1500.' + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bucket_key == o.bucket_key && + content == o.content && + name == o.name && + size == o.size && + type == o.type + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [bucket_key, content, name, size, type].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/synthetics_test_request_body_type.rb b/lib/datadog_api_client/v1/models/synthetics_test_request_body_type.rb index 913af36184bc..bd5093dd452e 100644 --- a/lib/datadog_api_client/v1/models/synthetics_test_request_body_type.rb +++ b/lib/datadog_api_client/v1/models/synthetics_test_request_body_type.rb @@ -27,5 +27,7 @@ class SyntheticsTestRequestBodyType TEXT_HTML = "text/html".freeze APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded".freeze GRAPHQL = "graphql".freeze + APPLICATION_OCTET_STREAM = "application/octet-stream".freeze + MULTIPART_FORM_DATA = "multipart/form-data".freeze end end