Skip to content

Commit

Permalink
Add bodyType to Synthetics request (#1743)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Nov 9, 2022
1 parent e9dfeef commit dbe6db6
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 9 deletions.
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:31.345793",
"spec_repo_commit": "9146e44b"
"regenerated": "2022-11-08 20:15:12.663622",
"spec_repo_commit": "ce8fbc1a"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-11-08 09:49:31.358053",
"spec_repo_commit": "9146e44b"
"regenerated": "2022-11-08 20:15:12.681004",
"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
43 changes: 43 additions & 0 deletions api/datadogV1/model_synthetics_test_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type SyntheticsTestRequest struct {
BasicAuth *SyntheticsBasicAuth `json:"basicAuth,omitempty"`
// Body to include in the test.
Body *string `json:"body,omitempty"`
// Type of the request body.
BodyType *SyntheticsTestRequestBodyType `json:"bodyType,omitempty"`
// Client certificate to use when performing the test request.
Certificate *SyntheticsTestRequestCertificate `json:"certificate,omitempty"`
// By default, the client certificate is applied on the domain of the starting URL for browser tests. If you want your client certificate to be applied on other domains instead, add them in `certificateDomains`.
Expand Down Expand Up @@ -164,6 +166,34 @@ func (o *SyntheticsTestRequest) SetBody(v string) {
o.Body = &v
}

// GetBodyType returns the BodyType field value if set, zero value otherwise.
func (o *SyntheticsTestRequest) GetBodyType() SyntheticsTestRequestBodyType {
if o == nil || o.BodyType == nil {
var ret SyntheticsTestRequestBodyType
return ret
}
return *o.BodyType
}

// GetBodyTypeOk returns a tuple with the BodyType field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SyntheticsTestRequest) GetBodyTypeOk() (*SyntheticsTestRequestBodyType, bool) {
if o == nil || o.BodyType == nil {
return nil, false
}
return o.BodyType, true
}

// HasBodyType returns a boolean if a field has been set.
func (o *SyntheticsTestRequest) HasBodyType() bool {
return o != nil && o.BodyType != nil
}

// SetBodyType gets a reference to the given SyntheticsTestRequestBodyType and assigns it to the BodyType field.
func (o *SyntheticsTestRequest) SetBodyType(v SyntheticsTestRequestBodyType) {
o.BodyType = &v
}

// GetCertificate returns the Certificate field value if set, zero value otherwise.
func (o *SyntheticsTestRequest) GetCertificate() SyntheticsTestRequestCertificate {
if o == nil || o.Certificate == nil {
Expand Down Expand Up @@ -739,6 +769,9 @@ func (o SyntheticsTestRequest) MarshalJSON() ([]byte, error) {
if o.Body != nil {
toSerialize["body"] = o.Body
}
if o.BodyType != nil {
toSerialize["bodyType"] = o.BodyType
}
if o.Certificate != nil {
toSerialize["certificate"] = o.Certificate
}
Expand Down Expand Up @@ -813,6 +846,7 @@ func (o *SyntheticsTestRequest) UnmarshalJSON(bytes []byte) (err error) {
AllowInsecure *bool `json:"allow_insecure,omitempty"`
BasicAuth *SyntheticsBasicAuth `json:"basicAuth,omitempty"`
Body *string `json:"body,omitempty"`
BodyType *SyntheticsTestRequestBodyType `json:"bodyType,omitempty"`
Certificate *SyntheticsTestRequestCertificate `json:"certificate,omitempty"`
CertificateDomains []string `json:"certificateDomains,omitempty"`
DnsServer *string `json:"dnsServer,omitempty"`
Expand Down Expand Up @@ -843,6 +877,14 @@ func (o *SyntheticsTestRequest) UnmarshalJSON(bytes []byte) (err error) {
o.UnparsedObject = raw
return nil
}
if v := all.BodyType; v != nil && !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
if v := all.Method; v != nil && !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
Expand All @@ -854,6 +896,7 @@ func (o *SyntheticsTestRequest) UnmarshalJSON(bytes []byte) (err error) {
o.AllowInsecure = all.AllowInsecure
o.BasicAuth = all.BasicAuth
o.Body = all.Body
o.BodyType = all.BodyType
if all.Certificate != nil && all.Certificate.UnparsedObject != nil && o.UnparsedObject == nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
Expand Down
117 changes: 117 additions & 0 deletions api/datadogV1/model_synthetics_test_request_body_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// 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 2019-Present Datadog, Inc.

package datadogV1

import (
"encoding/json"
"fmt"
)

// SyntheticsTestRequestBodyType Type of the request body.
type SyntheticsTestRequestBodyType string

// List of SyntheticsTestRequestBodyType.
const (
SYNTHETICSTESTREQUESTBODYTYPE_TEXT_PLAIN SyntheticsTestRequestBodyType = "text/plain"
SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_JSON SyntheticsTestRequestBodyType = "application/json"
SYNTHETICSTESTREQUESTBODYTYPE_TEXT_XML SyntheticsTestRequestBodyType = "text/xml"
SYNTHETICSTESTREQUESTBODYTYPE_TEXT_HTML SyntheticsTestRequestBodyType = "text/html"
SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_X_WWW_FORM_URLENCODED SyntheticsTestRequestBodyType = "application/x-www-form-urlencoded"
SYNTHETICSTESTREQUESTBODYTYPE_GRAPHQL SyntheticsTestRequestBodyType = "graphql"
)

var allowedSyntheticsTestRequestBodyTypeEnumValues = []SyntheticsTestRequestBodyType{
SYNTHETICSTESTREQUESTBODYTYPE_TEXT_PLAIN,
SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_JSON,
SYNTHETICSTESTREQUESTBODYTYPE_TEXT_XML,
SYNTHETICSTESTREQUESTBODYTYPE_TEXT_HTML,
SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_X_WWW_FORM_URLENCODED,
SYNTHETICSTESTREQUESTBODYTYPE_GRAPHQL,
}

// GetAllowedValues reeturns the list of possible values.
func (v *SyntheticsTestRequestBodyType) GetAllowedValues() []SyntheticsTestRequestBodyType {
return allowedSyntheticsTestRequestBodyTypeEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *SyntheticsTestRequestBodyType) UnmarshalJSON(src []byte) error {
var value string
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
*v = SyntheticsTestRequestBodyType(value)
return nil
}

// NewSyntheticsTestRequestBodyTypeFromValue returns a pointer to a valid SyntheticsTestRequestBodyType
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewSyntheticsTestRequestBodyTypeFromValue(v string) (*SyntheticsTestRequestBodyType, error) {
ev := SyntheticsTestRequestBodyType(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for SyntheticsTestRequestBodyType: valid values are %v", v, allowedSyntheticsTestRequestBodyTypeEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v SyntheticsTestRequestBodyType) IsValid() bool {
for _, existing := range allowedSyntheticsTestRequestBodyTypeEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to SyntheticsTestRequestBodyType value.
func (v SyntheticsTestRequestBodyType) Ptr() *SyntheticsTestRequestBodyType {
return &v
}

// NullableSyntheticsTestRequestBodyType handles when a null is used for SyntheticsTestRequestBodyType.
type NullableSyntheticsTestRequestBodyType struct {
value *SyntheticsTestRequestBodyType
isSet bool
}

// Get returns the associated value.
func (v NullableSyntheticsTestRequestBodyType) Get() *SyntheticsTestRequestBodyType {
return v.value
}

// Set changes the value and indicates it's been called.
func (v *NullableSyntheticsTestRequestBodyType) Set(val *SyntheticsTestRequestBodyType) {
v.value = val
v.isSet = true
}

// IsSet returns whether Set has been called.
func (v NullableSyntheticsTestRequestBodyType) IsSet() bool {
return v.isSet
}

// Unset sets the value to nil and resets the set flag.
func (v *NullableSyntheticsTestRequestBodyType) Unset() {
v.value = nil
v.isSet = false
}

// NewNullableSyntheticsTestRequestBodyType initializes the struct as if Set has been called.
func NewNullableSyntheticsTestRequestBodyType(val *SyntheticsTestRequestBodyType) *NullableSyntheticsTestRequestBodyType {
return &NullableSyntheticsTestRequestBodyType{value: val, isSet: true}
}

// MarshalJSON serializes the associated value.
func (v NullableSyntheticsTestRequestBodyType) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}

// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called.
func (v *NullableSyntheticsTestRequestBodyType) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
1 change: 1 addition & 0 deletions examples/v1/synthetics/UpdateBrowserTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func main() {
Type: datadogV1.SYNTHETICSBASICAUTHWEBTYPE_WEB.Ptr(),
Username: "my_username",
}},
BodyType: datadogV1.SYNTHETICSTESTREQUESTBODYTYPE_TEXT_PLAIN.Ptr(),
Certificate: &datadogV1.SyntheticsTestRequestCertificate{
Cert: &datadogV1.SyntheticsTestRequestCertificateItem{},
Key: &datadogV1.SyntheticsTestRequestCertificateItem{},
Expand Down
Loading

0 comments on commit dbe6db6

Please sign in to comment.