Skip to content

Commit 0b1b1ea

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add encoding to file request (#3758)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent f12dc0d commit 0b1b1ea

6 files changed

Lines changed: 51 additions & 10 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18642,6 +18642,10 @@ components:
1864218642
description: Content of the file.
1864318643
maxLength: 3145728
1864418644
type: string
18645+
encoding:
18646+
description: Encoding of the file content. The only supported value is `base64`,
18647+
indicating the `content` field contains base64-encoded data.
18648+
type: string
1864518649
name:
1864618650
description: Name of the file.
1864718651
maxLength: 1500

api/datadogV1/model_synthetics_test_request_body_file.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type SyntheticsTestRequestBodyFile struct {
1414
BucketKey *string `json:"bucketKey,omitempty"`
1515
// Content of the file.
1616
Content *string `json:"content,omitempty"`
17+
// Encoding of the file content. The only supported value is `base64`, indicating the `content` field contains base64-encoded data.
18+
Encoding *string `json:"encoding,omitempty"`
1719
// Name of the file.
1820
Name *string `json:"name,omitempty"`
1921
// Original name of the file.
@@ -100,6 +102,34 @@ func (o *SyntheticsTestRequestBodyFile) SetContent(v string) {
100102
o.Content = &v
101103
}
102104

105+
// GetEncoding returns the Encoding field value if set, zero value otherwise.
106+
func (o *SyntheticsTestRequestBodyFile) GetEncoding() string {
107+
if o == nil || o.Encoding == nil {
108+
var ret string
109+
return ret
110+
}
111+
return *o.Encoding
112+
}
113+
114+
// GetEncodingOk returns a tuple with the Encoding field value if set, nil otherwise
115+
// and a boolean to check if the value has been set.
116+
func (o *SyntheticsTestRequestBodyFile) GetEncodingOk() (*string, bool) {
117+
if o == nil || o.Encoding == nil {
118+
return nil, false
119+
}
120+
return o.Encoding, true
121+
}
122+
123+
// HasEncoding returns a boolean if a field has been set.
124+
func (o *SyntheticsTestRequestBodyFile) HasEncoding() bool {
125+
return o != nil && o.Encoding != nil
126+
}
127+
128+
// SetEncoding gets a reference to the given string and assigns it to the Encoding field.
129+
func (o *SyntheticsTestRequestBodyFile) SetEncoding(v string) {
130+
o.Encoding = &v
131+
}
132+
103133
// GetName returns the Name field value if set, zero value otherwise.
104134
func (o *SyntheticsTestRequestBodyFile) GetName() string {
105135
if o == nil || o.Name == nil {
@@ -224,6 +254,9 @@ func (o SyntheticsTestRequestBodyFile) MarshalJSON() ([]byte, error) {
224254
if o.Content != nil {
225255
toSerialize["content"] = o.Content
226256
}
257+
if o.Encoding != nil {
258+
toSerialize["encoding"] = o.Encoding
259+
}
227260
if o.Name != nil {
228261
toSerialize["name"] = o.Name
229262
}
@@ -248,6 +281,7 @@ func (o *SyntheticsTestRequestBodyFile) UnmarshalJSON(bytes []byte) (err error)
248281
all := struct {
249282
BucketKey *string `json:"bucketKey,omitempty"`
250283
Content *string `json:"content,omitempty"`
284+
Encoding *string `json:"encoding,omitempty"`
251285
Name *string `json:"name,omitempty"`
252286
OriginalFileName *string `json:"originalFileName,omitempty"`
253287
Size *int64 `json:"size,omitempty"`
@@ -258,12 +292,13 @@ func (o *SyntheticsTestRequestBodyFile) UnmarshalJSON(bytes []byte) (err error)
258292
}
259293
additionalProperties := make(map[string]interface{})
260294
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
261-
datadog.DeleteKeys(additionalProperties, &[]string{"bucketKey", "content", "name", "originalFileName", "size", "type"})
295+
datadog.DeleteKeys(additionalProperties, &[]string{"bucketKey", "content", "encoding", "name", "originalFileName", "size", "type"})
262296
} else {
263297
return err
264298
}
265299
o.BucketKey = all.BucketKey
266300
o.Content = all.Content
301+
o.Encoding = all.Encoding
267302
o.Name = all.Name
268303
o.OriginalFileName = all.OriginalFileName
269304
o.Size = all.Size

examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func main() {
9393
OriginalFileName: datadog.PtrString("image.png"),
9494
Content: datadog.PtrString("file content"),
9595
Type: datadog.PtrString("file type"),
96+
Encoding: datadog.PtrString("base64"),
9697
},
9798
},
9899
BasicAuth: &datadogV1.SyntheticsBasicAuth{
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-12-09T11:18:08.137Z
1+
2026-03-03T11:12:53.062Z

tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interactions:
22
- request:
33
body: |
4-
{"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","originalFileName":"image.png","type":"file type"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1733743088"},"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-1733743088","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-1733743088","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}
4+
{"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","encoding":"base64","name":"file name","originalFileName":"image.png","type":"file type"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1772536373"},"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-1772536373","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-1772536373","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}
55
form: {}
66
headers:
77
Accept:
@@ -12,10 +12,10 @@ interactions:
1212
method: POST
1313
url: https://api.datadoghq.com/api/v1/synthetics/tests/api
1414
response:
15-
body: '{"public_id":"pbm-cwk-hzr","name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1733743088","status":"live","type":"api","subtype":"http","tags":["testing:api"],"created_at":"2024-12-09T11:18:08.979546+00:00","modified_at":"2024-12-09T11:18:08.979546+00:00","config":{"assertions":[{"operator":"is","property":"{{
16-
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
17-
name","originalFileName":"image.png","type":"file type","bucketKey":"api-upload-file/pbm-cwk-hzr/2024-12-09T11:18:08.684149_ee770695-2a7a-48ef-aa76-148a8425ce69.json"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1733743088"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"message":"BDD
18-
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-1733743088","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"locations":["aws:us-east-2"],"created_by":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"},"deleted_at":null,"monitor_id":159881040,"org_id":321813,"modified_by":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"}}'
15+
body: '{"public_id":"x96-ukc-pvk","name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1772536373","status":"live","type":"api","subtype":"http","tags":["testing:api"],"created_at":"2026-03-03T11:12:53.933929+00:00","modified_at":"2026-03-03T11:12:53.933929+00:00","config":{"assertions":[{"operator":"is","property":"{{
16+
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":[{"encoding":"base64","name":"file
17+
name","originalFileName":"image.png","type":"file type","bucketKey":"api-upload-file/x96-ukc-pvk/2026-03-03T11:12:53.730968_6541a914-12d5-43ca-8dc6-387726057eb6.json"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1772536373"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"message":"BDD
18+
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-1772536373","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"locations":["aws:us-east-2"],"created_by":{"name":"frog","handle":"frog@datadoghq.com","email":"frog@datadoghq.com"},"deleted_at":null,"monitor_id":263059097,"org_id":321813,"modified_by":{"name":"frog","handle":"frog@datadoghq.com","email":"frog@datadoghq.com"}}'
1919
code: 200
2020
duration: 0ms
2121
headers:
@@ -24,7 +24,7 @@ interactions:
2424
status: 200 OK
2525
- request:
2626
body: |
27-
{"public_ids":["pbm-cwk-hzr"]}
27+
{"public_ids":["x96-ukc-pvk"]}
2828
form: {}
2929
headers:
3030
Accept:
@@ -35,7 +35,7 @@ interactions:
3535
method: POST
3636
url: https://api.datadoghq.com/api/v1/synthetics/tests/delete
3737
response:
38-
body: '{"deleted_tests":[{"public_id":"pbm-cwk-hzr","deleted_at":"2024-12-09T11:18:09.927667+00:00"}]}
38+
body: '{"deleted_tests":[{"public_id":"x96-ukc-pvk","deleted_at":"2026-03-03T11:12:54.336119+00:00"}]}
3939
4040
'
4141
code: 200

tests/scenarios/features/v1/synthetics_api_http_test_with_file_payload.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"name": "file name",
6262
"originalFileName": "image.png",
6363
"content": "file content",
64-
"type": "file type"
64+
"type": "file type",
65+
"encoding": "base64"
6566
}],
6667
"basicAuth": {
6768
"accessTokenUrl": "https://datadog-token.com",

0 commit comments

Comments
 (0)