diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 122c27ff508..cc2d8329b08 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29382,6 +29382,25 @@ components: data: $ref: "#/components/schemas/ListDeploymentRuleResponseData" type: object + DeploymentGatesEvaluationConfiguration: + description: |- + Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + directly from this configuration instead of using the pre-configured gate rules. + At least one rule is required. + properties: + dry_run: + description: Gate-level dry run. When enabled, the rules are evaluated normally but the gate always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + rules: + description: The list of rules to evaluate. At least one rule is required. + items: + $ref: "#/components/schemas/DeploymentGatesEvaluationRule" + minItems: 1 + type: array + required: + - rules + type: object DeploymentGatesEvaluationRequest: description: Request body for triggering a deployment gate evaluation. properties: @@ -29391,8 +29410,13 @@ components: - data type: object DeploymentGatesEvaluationRequestAttributes: - description: Attributes for a deployment gate evaluation request. + description: |- + Attributes for a deployment gate evaluation request. + When `configuration` is provided, rules are evaluated inline from that configuration. + When omitted, rules are resolved from the pre-configured gate for the given service and environment. properties: + configuration: + $ref: "#/components/schemas/DeploymentGatesEvaluationConfiguration" env: description: The environment of the deployment. example: "staging" @@ -29562,6 +29586,60 @@ components: type: string x-enum-varnames: - DEPLOYMENT_GATES_EVALUATION_RESULT_RESPONSE + DeploymentGatesEvaluationRule: + description: A rule to evaluate as part of a deployment gate evaluation. + discriminator: + mapping: + faulty_deployment_detection: "#/components/schemas/DeploymentGatesFDDRule" + monitor: "#/components/schemas/DeploymentGatesMonitorRule" + propertyName: type + oneOf: + - $ref: "#/components/schemas/DeploymentGatesMonitorRule" + - $ref: "#/components/schemas/DeploymentGatesFDDRule" + DeploymentGatesFDDRule: + description: A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. + properties: + dry_run: + description: Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + name: + description: Human-readable name for this rule. + example: "apm faulty deployment" + type: string + options: + $ref: "#/components/schemas/DeploymentGatesFDDRuleOptions" + type: + $ref: "#/components/schemas/DeploymentGatesFDDRuleType" + required: + - type + - name + type: object + DeploymentGatesFDDRuleOptions: + description: Options for a `faulty_deployment_detection` rule. + properties: + duration: + description: Evaluation window in seconds. Maximum 7200 (2 hours). + example: 900 + format: int64 + maximum: 7200 + type: integer + excluded_resources: + description: APM resource names to exclude from analysis. + example: + - "GET /healthcheck" + items: + type: string + type: array + type: object + DeploymentGatesFDDRuleType: + description: The type identifier for a faulty deployment detection rule. + enum: + - faulty_deployment_detection + example: faulty_deployment_detection + type: string + x-enum-varnames: + - FAULTY_DEPLOYMENT_DETECTION DeploymentGatesListResponse: description: Response containing a paginated list of deployment gates. properties: @@ -29596,6 +29674,49 @@ components: minimum: 1 type: integer type: object + DeploymentGatesMonitorRule: + description: A monitor rule to evaluate as part of a deployment gate evaluation. + properties: + dry_run: + description: Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + name: + description: Human-readable name for this rule. + example: "error rate monitors" + type: string + options: + $ref: "#/components/schemas/DeploymentGatesMonitorRuleOptions" + type: + $ref: "#/components/schemas/DeploymentGatesMonitorRuleType" + required: + - type + - name + type: object + DeploymentGatesMonitorRuleOptions: + description: Options for a `monitor` rule. + properties: + duration: + description: Evaluation window in seconds. Maximum 7200 (2 hours). + example: 300 + format: int64 + maximum: 7200 + type: integer + query: + description: Monitor search query. + example: "service:transaction-backend env:production" + type: string + required: + - query + type: object + DeploymentGatesMonitorRuleType: + description: The type identifier for a monitor rule. + enum: + - monitor + example: monitor + type: string + x-enum-varnames: + - MONITOR DeploymentGatesRuleResponse: description: The result of a single rule evaluation. properties: @@ -121740,12 +121861,17 @@ paths: Triggers an asynchronous deployment gate evaluation for the given service and environment. Returns an evaluation ID that can be used to poll for the result via the `GET /api/v2/deployments/gates/evaluation/{id}` endpoint. + + When the `configuration` attribute is provided, rules are evaluated inline from that configuration + and no pre-configured gate is required. When `configuration` is omitted, rules are resolved from the + gate pre-configured for the given service and environment via the Datadog UI, API, or Terraform. operationId: TriggerDeploymentGatesEvaluation requestBody: content: application/json: examples: default: + summary: Evaluate a pre-configured gate value: data: attributes: @@ -121755,6 +121881,31 @@ paths: service: transaction-backend version: v1.2.3 type: deployment_gates_evaluation_request + with-configuration: + summary: Evaluate with inline rule configuration + value: + data: + attributes: + configuration: + dry_run: false + rules: + - dry_run: false + name: error rate monitors + options: + duration: 300 + query: "service:transaction-backend env:production" + type: monitor + - dry_run: false + name: apm faulty deployment + options: + duration: 900 + excluded_resources: + - "GET /healthcheck" + type: faulty_deployment_detection + env: production + service: transaction-backend + version: 1.2.3 + type: deployment_gates_evaluation_request schema: $ref: "#/components/schemas/DeploymentGatesEvaluationRequest" required: true diff --git a/api/datadogV2/api_deployment_gates.go b/api/datadogV2/api_deployment_gates.go index eb39a2dad7e..6e5c612aa1c 100644 --- a/api/datadogV2/api_deployment_gates.go +++ b/api/datadogV2/api_deployment_gates.go @@ -1041,6 +1041,10 @@ func (a *DeploymentGatesApi) ListDeploymentGates(ctx _context.Context, o ...List // Triggers an asynchronous deployment gate evaluation for the given service and environment. // Returns an evaluation ID that can be used to poll for the result via the // `GET /api/v2/deployments/gates/evaluation/{id}` endpoint. +// +// When the `configuration` attribute is provided, rules are evaluated inline from that configuration +// and no pre-configured gate is required. When `configuration` is omitted, rules are resolved from the +// gate pre-configured for the given service and environment via the Datadog UI, API, or Terraform. func (a *DeploymentGatesApi) TriggerDeploymentGatesEvaluation(ctx _context.Context, body DeploymentGatesEvaluationRequest) (DeploymentGatesEvaluationResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPost diff --git a/api/datadogV2/model_deployment_gates_evaluation_configuration.go b/api/datadogV2/model_deployment_gates_evaluation_configuration.go new file mode 100644 index 00000000000..c2afa7e3c46 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_evaluation_configuration.go @@ -0,0 +1,138 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesEvaluationConfiguration Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated +// directly from this configuration instead of using the pre-configured gate rules. +// At least one rule is required. +type DeploymentGatesEvaluationConfiguration struct { + // Gate-level dry run. When enabled, the rules are evaluated normally but the gate always returns `pass`. The real result is visible in the Datadog UI. + DryRun *bool `json:"dry_run,omitempty"` + // The list of rules to evaluate. At least one rule is required. + Rules []DeploymentGatesEvaluationRule `json:"rules"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeploymentGatesEvaluationConfiguration instantiates a new DeploymentGatesEvaluationConfiguration object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeploymentGatesEvaluationConfiguration(rules []DeploymentGatesEvaluationRule) *DeploymentGatesEvaluationConfiguration { + this := DeploymentGatesEvaluationConfiguration{} + this.Rules = rules + return &this +} + +// NewDeploymentGatesEvaluationConfigurationWithDefaults instantiates a new DeploymentGatesEvaluationConfiguration object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeploymentGatesEvaluationConfigurationWithDefaults() *DeploymentGatesEvaluationConfiguration { + this := DeploymentGatesEvaluationConfiguration{} + return &this +} + +// GetDryRun returns the DryRun field value if set, zero value otherwise. +func (o *DeploymentGatesEvaluationConfiguration) GetDryRun() bool { + if o == nil || o.DryRun == nil { + var ret bool + return ret + } + return *o.DryRun +} + +// GetDryRunOk returns a tuple with the DryRun field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesEvaluationConfiguration) GetDryRunOk() (*bool, bool) { + if o == nil || o.DryRun == nil { + return nil, false + } + return o.DryRun, true +} + +// HasDryRun returns a boolean if a field has been set. +func (o *DeploymentGatesEvaluationConfiguration) HasDryRun() bool { + return o != nil && o.DryRun != nil +} + +// SetDryRun gets a reference to the given bool and assigns it to the DryRun field. +func (o *DeploymentGatesEvaluationConfiguration) SetDryRun(v bool) { + o.DryRun = &v +} + +// GetRules returns the Rules field value. +func (o *DeploymentGatesEvaluationConfiguration) GetRules() []DeploymentGatesEvaluationRule { + if o == nil { + var ret []DeploymentGatesEvaluationRule + return ret + } + return o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value +// and a boolean to check if the value has been set. +func (o *DeploymentGatesEvaluationConfiguration) GetRulesOk() (*[]DeploymentGatesEvaluationRule, bool) { + if o == nil { + return nil, false + } + return &o.Rules, true +} + +// SetRules sets field value. +func (o *DeploymentGatesEvaluationConfiguration) SetRules(v []DeploymentGatesEvaluationRule) { + o.Rules = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeploymentGatesEvaluationConfiguration) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DryRun != nil { + toSerialize["dry_run"] = o.DryRun + } + toSerialize["rules"] = o.Rules + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeploymentGatesEvaluationConfiguration) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DryRun *bool `json:"dry_run,omitempty"` + Rules *[]DeploymentGatesEvaluationRule `json:"rules"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Rules == nil { + return fmt.Errorf("required field rules missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"dry_run", "rules"}) + } else { + return err + } + o.DryRun = all.DryRun + o.Rules = *all.Rules + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_deployment_gates_evaluation_request_attributes.go b/api/datadogV2/model_deployment_gates_evaluation_request_attributes.go index c49078ee65e..78ca944ad7b 100644 --- a/api/datadogV2/model_deployment_gates_evaluation_request_attributes.go +++ b/api/datadogV2/model_deployment_gates_evaluation_request_attributes.go @@ -11,7 +11,13 @@ import ( ) // DeploymentGatesEvaluationRequestAttributes Attributes for a deployment gate evaluation request. +// When `configuration` is provided, rules are evaluated inline from that configuration. +// When omitted, rules are resolved from the pre-configured gate for the given service and environment. type DeploymentGatesEvaluationRequestAttributes struct { + // Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + // directly from this configuration instead of using the pre-configured gate rules. + // At least one rule is required. + Configuration *DeploymentGatesEvaluationConfiguration `json:"configuration,omitempty"` // The environment of the deployment. Env string `json:"env"` // The identifier of the deployment gate. Defaults to "default". @@ -50,6 +56,34 @@ func NewDeploymentGatesEvaluationRequestAttributesWithDefaults() *DeploymentGate return &this } +// GetConfiguration returns the Configuration field value if set, zero value otherwise. +func (o *DeploymentGatesEvaluationRequestAttributes) GetConfiguration() DeploymentGatesEvaluationConfiguration { + if o == nil || o.Configuration == nil { + var ret DeploymentGatesEvaluationConfiguration + return ret + } + return *o.Configuration +} + +// GetConfigurationOk returns a tuple with the Configuration field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesEvaluationRequestAttributes) GetConfigurationOk() (*DeploymentGatesEvaluationConfiguration, bool) { + if o == nil || o.Configuration == nil { + return nil, false + } + return o.Configuration, true +} + +// HasConfiguration returns a boolean if a field has been set. +func (o *DeploymentGatesEvaluationRequestAttributes) HasConfiguration() bool { + return o != nil && o.Configuration != nil +} + +// SetConfiguration gets a reference to the given DeploymentGatesEvaluationConfiguration and assigns it to the Configuration field. +func (o *DeploymentGatesEvaluationRequestAttributes) SetConfiguration(v DeploymentGatesEvaluationConfiguration) { + o.Configuration = &v +} + // GetEnv returns the Env field value. func (o *DeploymentGatesEvaluationRequestAttributes) GetEnv() string { if o == nil { @@ -186,6 +220,9 @@ func (o DeploymentGatesEvaluationRequestAttributes) MarshalJSON() ([]byte, error if o.UnparsedObject != nil { return datadog.Marshal(o.UnparsedObject) } + if o.Configuration != nil { + toSerialize["configuration"] = o.Configuration + } toSerialize["env"] = o.Env if o.Identifier != nil { toSerialize["identifier"] = o.Identifier @@ -207,11 +244,12 @@ func (o DeploymentGatesEvaluationRequestAttributes) MarshalJSON() ([]byte, error // UnmarshalJSON deserializes the given payload. func (o *DeploymentGatesEvaluationRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Env *string `json:"env"` - Identifier *string `json:"identifier,omitempty"` - PrimaryTag *string `json:"primary_tag,omitempty"` - Service *string `json:"service"` - Version *string `json:"version,omitempty"` + Configuration *DeploymentGatesEvaluationConfiguration `json:"configuration,omitempty"` + Env *string `json:"env"` + Identifier *string `json:"identifier,omitempty"` + PrimaryTag *string `json:"primary_tag,omitempty"` + Service *string `json:"service"` + Version *string `json:"version,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -224,10 +262,16 @@ func (o *DeploymentGatesEvaluationRequestAttributes) UnmarshalJSON(bytes []byte) } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"env", "identifier", "primary_tag", "service", "version"}) + datadog.DeleteKeys(additionalProperties, &[]string{"configuration", "env", "identifier", "primary_tag", "service", "version"}) } else { return err } + + hasInvalidField := false + if all.Configuration != nil && all.Configuration.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Configuration = all.Configuration o.Env = *all.Env o.Identifier = all.Identifier o.PrimaryTag = all.PrimaryTag @@ -238,5 +282,9 @@ func (o *DeploymentGatesEvaluationRequestAttributes) UnmarshalJSON(bytes []byte) o.AdditionalProperties = additionalProperties } + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + return nil } diff --git a/api/datadogV2/model_deployment_gates_evaluation_request_data.go b/api/datadogV2/model_deployment_gates_evaluation_request_data.go index e5ddb0fca83..e15c8c84a5a 100644 --- a/api/datadogV2/model_deployment_gates_evaluation_request_data.go +++ b/api/datadogV2/model_deployment_gates_evaluation_request_data.go @@ -13,6 +13,8 @@ import ( // DeploymentGatesEvaluationRequestData Data for a deployment gate evaluation request. type DeploymentGatesEvaluationRequestData struct { // Attributes for a deployment gate evaluation request. + // When `configuration` is provided, rules are evaluated inline from that configuration. + // When omitted, rules are resolved from the pre-configured gate for the given service and environment. Attributes DeploymentGatesEvaluationRequestAttributes `json:"attributes"` // JSON:API type for a deployment gate evaluation request. Type DeploymentGatesEvaluationRequestDataType `json:"type"` diff --git a/api/datadogV2/model_deployment_gates_evaluation_rule.go b/api/datadogV2/model_deployment_gates_evaluation_rule.go new file mode 100644 index 00000000000..d879682cd96 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_evaluation_rule.go @@ -0,0 +1,63 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesEvaluationRule - A rule to evaluate as part of a deployment gate evaluation. +type DeploymentGatesEvaluationRule struct { + DeploymentGatesMonitorRule *DeploymentGatesMonitorRule + DeploymentGatesFDDRule *DeploymentGatesFDDRule + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// DeploymentGatesMonitorRuleAsDeploymentGatesEvaluationRule is a convenience function that returns DeploymentGatesMonitorRule wrapped in DeploymentGatesEvaluationRule. +func DeploymentGatesMonitorRuleAsDeploymentGatesEvaluationRule(v *DeploymentGatesMonitorRule) DeploymentGatesEvaluationRule { + return DeploymentGatesEvaluationRule{DeploymentGatesMonitorRule: v} +} + +// DeploymentGatesFDDRuleAsDeploymentGatesEvaluationRule is a convenience function that returns DeploymentGatesFDDRule wrapped in DeploymentGatesEvaluationRule. +func DeploymentGatesFDDRuleAsDeploymentGatesEvaluationRule(v *DeploymentGatesFDDRule) DeploymentGatesEvaluationRule { + return DeploymentGatesEvaluationRule{DeploymentGatesFDDRule: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *DeploymentGatesEvaluationRule) UnmarshalJSON(data []byte) error { + var err error +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj DeploymentGatesEvaluationRule) MarshalJSON() ([]byte, error) { + if obj.DeploymentGatesMonitorRule != nil { + return datadog.Marshal(&obj.DeploymentGatesMonitorRule) + } + + if obj.DeploymentGatesFDDRule != nil { + return datadog.Marshal(&obj.DeploymentGatesFDDRule) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *DeploymentGatesEvaluationRule) GetActualInstance() interface{} { + if obj.DeploymentGatesMonitorRule != nil { + return obj.DeploymentGatesMonitorRule + } + + if obj.DeploymentGatesFDDRule != nil { + return obj.DeploymentGatesFDDRule + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_deployment_gates_fdd_rule.go b/api/datadogV2/model_deployment_gates_fdd_rule.go new file mode 100644 index 00000000000..9c6d753b3aa --- /dev/null +++ b/api/datadogV2/model_deployment_gates_fdd_rule.go @@ -0,0 +1,216 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesFDDRule A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. +type DeploymentGatesFDDRule struct { + // Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + DryRun *bool `json:"dry_run,omitempty"` + // Human-readable name for this rule. + Name string `json:"name"` + // Options for a `faulty_deployment_detection` rule. + Options *DeploymentGatesFDDRuleOptions `json:"options,omitempty"` + // The type identifier for a faulty deployment detection rule. + Type DeploymentGatesFDDRuleType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeploymentGatesFDDRule instantiates a new DeploymentGatesFDDRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeploymentGatesFDDRule(name string, typeVar DeploymentGatesFDDRuleType) *DeploymentGatesFDDRule { + this := DeploymentGatesFDDRule{} + this.Name = name + this.Type = typeVar + return &this +} + +// NewDeploymentGatesFDDRuleWithDefaults instantiates a new DeploymentGatesFDDRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeploymentGatesFDDRuleWithDefaults() *DeploymentGatesFDDRule { + this := DeploymentGatesFDDRule{} + return &this +} + +// GetDryRun returns the DryRun field value if set, zero value otherwise. +func (o *DeploymentGatesFDDRule) GetDryRun() bool { + if o == nil || o.DryRun == nil { + var ret bool + return ret + } + return *o.DryRun +} + +// GetDryRunOk returns a tuple with the DryRun field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesFDDRule) GetDryRunOk() (*bool, bool) { + if o == nil || o.DryRun == nil { + return nil, false + } + return o.DryRun, true +} + +// HasDryRun returns a boolean if a field has been set. +func (o *DeploymentGatesFDDRule) HasDryRun() bool { + return o != nil && o.DryRun != nil +} + +// SetDryRun gets a reference to the given bool and assigns it to the DryRun field. +func (o *DeploymentGatesFDDRule) SetDryRun(v bool) { + o.DryRun = &v +} + +// GetName returns the Name field value. +func (o *DeploymentGatesFDDRule) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *DeploymentGatesFDDRule) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *DeploymentGatesFDDRule) SetName(v string) { + o.Name = v +} + +// GetOptions returns the Options field value if set, zero value otherwise. +func (o *DeploymentGatesFDDRule) GetOptions() DeploymentGatesFDDRuleOptions { + if o == nil || o.Options == nil { + var ret DeploymentGatesFDDRuleOptions + return ret + } + return *o.Options +} + +// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesFDDRule) GetOptionsOk() (*DeploymentGatesFDDRuleOptions, bool) { + if o == nil || o.Options == nil { + return nil, false + } + return o.Options, true +} + +// HasOptions returns a boolean if a field has been set. +func (o *DeploymentGatesFDDRule) HasOptions() bool { + return o != nil && o.Options != nil +} + +// SetOptions gets a reference to the given DeploymentGatesFDDRuleOptions and assigns it to the Options field. +func (o *DeploymentGatesFDDRule) SetOptions(v DeploymentGatesFDDRuleOptions) { + o.Options = &v +} + +// GetType returns the Type field value. +func (o *DeploymentGatesFDDRule) GetType() DeploymentGatesFDDRuleType { + if o == nil { + var ret DeploymentGatesFDDRuleType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *DeploymentGatesFDDRule) GetTypeOk() (*DeploymentGatesFDDRuleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DeploymentGatesFDDRule) SetType(v DeploymentGatesFDDRuleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeploymentGatesFDDRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DryRun != nil { + toSerialize["dry_run"] = o.DryRun + } + toSerialize["name"] = o.Name + if o.Options != nil { + toSerialize["options"] = o.Options + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeploymentGatesFDDRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DryRun *bool `json:"dry_run,omitempty"` + Name *string `json:"name"` + Options *DeploymentGatesFDDRuleOptions `json:"options,omitempty"` + Type *DeploymentGatesFDDRuleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"dry_run", "name", "options", "type"}) + } else { + return err + } + + hasInvalidField := false + o.DryRun = all.DryRun + o.Name = *all.Name + if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Options = all.Options + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_deployment_gates_fdd_rule_options.go b/api/datadogV2/model_deployment_gates_fdd_rule_options.go new file mode 100644 index 00000000000..09ced058017 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_fdd_rule_options.go @@ -0,0 +1,137 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesFDDRuleOptions Options for a `faulty_deployment_detection` rule. +type DeploymentGatesFDDRuleOptions struct { + // Evaluation window in seconds. Maximum 7200 (2 hours). + Duration *int64 `json:"duration,omitempty"` + // APM resource names to exclude from analysis. + ExcludedResources []string `json:"excluded_resources,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeploymentGatesFDDRuleOptions instantiates a new DeploymentGatesFDDRuleOptions object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeploymentGatesFDDRuleOptions() *DeploymentGatesFDDRuleOptions { + this := DeploymentGatesFDDRuleOptions{} + return &this +} + +// NewDeploymentGatesFDDRuleOptionsWithDefaults instantiates a new DeploymentGatesFDDRuleOptions object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeploymentGatesFDDRuleOptionsWithDefaults() *DeploymentGatesFDDRuleOptions { + this := DeploymentGatesFDDRuleOptions{} + return &this +} + +// GetDuration returns the Duration field value if set, zero value otherwise. +func (o *DeploymentGatesFDDRuleOptions) GetDuration() int64 { + if o == nil || o.Duration == nil { + var ret int64 + return ret + } + return *o.Duration +} + +// GetDurationOk returns a tuple with the Duration field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesFDDRuleOptions) GetDurationOk() (*int64, bool) { + if o == nil || o.Duration == nil { + return nil, false + } + return o.Duration, true +} + +// HasDuration returns a boolean if a field has been set. +func (o *DeploymentGatesFDDRuleOptions) HasDuration() bool { + return o != nil && o.Duration != nil +} + +// SetDuration gets a reference to the given int64 and assigns it to the Duration field. +func (o *DeploymentGatesFDDRuleOptions) SetDuration(v int64) { + o.Duration = &v +} + +// GetExcludedResources returns the ExcludedResources field value if set, zero value otherwise. +func (o *DeploymentGatesFDDRuleOptions) GetExcludedResources() []string { + if o == nil || o.ExcludedResources == nil { + var ret []string + return ret + } + return o.ExcludedResources +} + +// GetExcludedResourcesOk returns a tuple with the ExcludedResources field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesFDDRuleOptions) GetExcludedResourcesOk() (*[]string, bool) { + if o == nil || o.ExcludedResources == nil { + return nil, false + } + return &o.ExcludedResources, true +} + +// HasExcludedResources returns a boolean if a field has been set. +func (o *DeploymentGatesFDDRuleOptions) HasExcludedResources() bool { + return o != nil && o.ExcludedResources != nil +} + +// SetExcludedResources gets a reference to the given []string and assigns it to the ExcludedResources field. +func (o *DeploymentGatesFDDRuleOptions) SetExcludedResources(v []string) { + o.ExcludedResources = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeploymentGatesFDDRuleOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Duration != nil { + toSerialize["duration"] = o.Duration + } + if o.ExcludedResources != nil { + toSerialize["excluded_resources"] = o.ExcludedResources + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeploymentGatesFDDRuleOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Duration *int64 `json:"duration,omitempty"` + ExcludedResources []string `json:"excluded_resources,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"duration", "excluded_resources"}) + } else { + return err + } + o.Duration = all.Duration + o.ExcludedResources = all.ExcludedResources + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_deployment_gates_fdd_rule_type.go b/api/datadogV2/model_deployment_gates_fdd_rule_type.go new file mode 100644 index 00000000000..2419e6217a7 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_fdd_rule_type.go @@ -0,0 +1,64 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesFDDRuleType The type identifier for a faulty deployment detection rule. +type DeploymentGatesFDDRuleType string + +// List of DeploymentGatesFDDRuleType. +const ( + DEPLOYMENTGATESFDDRULETYPE_FAULTY_DEPLOYMENT_DETECTION DeploymentGatesFDDRuleType = "faulty_deployment_detection" +) + +var allowedDeploymentGatesFDDRuleTypeEnumValues = []DeploymentGatesFDDRuleType{ + DEPLOYMENTGATESFDDRULETYPE_FAULTY_DEPLOYMENT_DETECTION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DeploymentGatesFDDRuleType) GetAllowedValues() []DeploymentGatesFDDRuleType { + return allowedDeploymentGatesFDDRuleTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DeploymentGatesFDDRuleType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DeploymentGatesFDDRuleType(value) + return nil +} + +// NewDeploymentGatesFDDRuleTypeFromValue returns a pointer to a valid DeploymentGatesFDDRuleType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDeploymentGatesFDDRuleTypeFromValue(v string) (*DeploymentGatesFDDRuleType, error) { + ev := DeploymentGatesFDDRuleType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DeploymentGatesFDDRuleType: valid values are %v", v, allowedDeploymentGatesFDDRuleTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DeploymentGatesFDDRuleType) IsValid() bool { + for _, existing := range allowedDeploymentGatesFDDRuleTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DeploymentGatesFDDRuleType value. +func (v DeploymentGatesFDDRuleType) Ptr() *DeploymentGatesFDDRuleType { + return &v +} diff --git a/api/datadogV2/model_deployment_gates_monitor_rule.go b/api/datadogV2/model_deployment_gates_monitor_rule.go new file mode 100644 index 00000000000..6115a6e7a96 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_monitor_rule.go @@ -0,0 +1,216 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesMonitorRule A monitor rule to evaluate as part of a deployment gate evaluation. +type DeploymentGatesMonitorRule struct { + // Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + DryRun *bool `json:"dry_run,omitempty"` + // Human-readable name for this rule. + Name string `json:"name"` + // Options for a `monitor` rule. + Options *DeploymentGatesMonitorRuleOptions `json:"options,omitempty"` + // The type identifier for a monitor rule. + Type DeploymentGatesMonitorRuleType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeploymentGatesMonitorRule instantiates a new DeploymentGatesMonitorRule object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeploymentGatesMonitorRule(name string, typeVar DeploymentGatesMonitorRuleType) *DeploymentGatesMonitorRule { + this := DeploymentGatesMonitorRule{} + this.Name = name + this.Type = typeVar + return &this +} + +// NewDeploymentGatesMonitorRuleWithDefaults instantiates a new DeploymentGatesMonitorRule object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeploymentGatesMonitorRuleWithDefaults() *DeploymentGatesMonitorRule { + this := DeploymentGatesMonitorRule{} + return &this +} + +// GetDryRun returns the DryRun field value if set, zero value otherwise. +func (o *DeploymentGatesMonitorRule) GetDryRun() bool { + if o == nil || o.DryRun == nil { + var ret bool + return ret + } + return *o.DryRun +} + +// GetDryRunOk returns a tuple with the DryRun field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesMonitorRule) GetDryRunOk() (*bool, bool) { + if o == nil || o.DryRun == nil { + return nil, false + } + return o.DryRun, true +} + +// HasDryRun returns a boolean if a field has been set. +func (o *DeploymentGatesMonitorRule) HasDryRun() bool { + return o != nil && o.DryRun != nil +} + +// SetDryRun gets a reference to the given bool and assigns it to the DryRun field. +func (o *DeploymentGatesMonitorRule) SetDryRun(v bool) { + o.DryRun = &v +} + +// GetName returns the Name field value. +func (o *DeploymentGatesMonitorRule) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *DeploymentGatesMonitorRule) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *DeploymentGatesMonitorRule) SetName(v string) { + o.Name = v +} + +// GetOptions returns the Options field value if set, zero value otherwise. +func (o *DeploymentGatesMonitorRule) GetOptions() DeploymentGatesMonitorRuleOptions { + if o == nil || o.Options == nil { + var ret DeploymentGatesMonitorRuleOptions + return ret + } + return *o.Options +} + +// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesMonitorRule) GetOptionsOk() (*DeploymentGatesMonitorRuleOptions, bool) { + if o == nil || o.Options == nil { + return nil, false + } + return o.Options, true +} + +// HasOptions returns a boolean if a field has been set. +func (o *DeploymentGatesMonitorRule) HasOptions() bool { + return o != nil && o.Options != nil +} + +// SetOptions gets a reference to the given DeploymentGatesMonitorRuleOptions and assigns it to the Options field. +func (o *DeploymentGatesMonitorRule) SetOptions(v DeploymentGatesMonitorRuleOptions) { + o.Options = &v +} + +// GetType returns the Type field value. +func (o *DeploymentGatesMonitorRule) GetType() DeploymentGatesMonitorRuleType { + if o == nil { + var ret DeploymentGatesMonitorRuleType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *DeploymentGatesMonitorRule) GetTypeOk() (*DeploymentGatesMonitorRuleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DeploymentGatesMonitorRule) SetType(v DeploymentGatesMonitorRuleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeploymentGatesMonitorRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DryRun != nil { + toSerialize["dry_run"] = o.DryRun + } + toSerialize["name"] = o.Name + if o.Options != nil { + toSerialize["options"] = o.Options + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeploymentGatesMonitorRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DryRun *bool `json:"dry_run,omitempty"` + Name *string `json:"name"` + Options *DeploymentGatesMonitorRuleOptions `json:"options,omitempty"` + Type *DeploymentGatesMonitorRuleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"dry_run", "name", "options", "type"}) + } else { + return err + } + + hasInvalidField := false + o.DryRun = all.DryRun + o.Name = *all.Name + if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Options = all.Options + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_deployment_gates_monitor_rule_options.go b/api/datadogV2/model_deployment_gates_monitor_rule_options.go new file mode 100644 index 00000000000..b38a630ada0 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_monitor_rule_options.go @@ -0,0 +1,136 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesMonitorRuleOptions Options for a `monitor` rule. +type DeploymentGatesMonitorRuleOptions struct { + // Evaluation window in seconds. Maximum 7200 (2 hours). + Duration *int64 `json:"duration,omitempty"` + // Monitor search query. + Query string `json:"query"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeploymentGatesMonitorRuleOptions instantiates a new DeploymentGatesMonitorRuleOptions object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeploymentGatesMonitorRuleOptions(query string) *DeploymentGatesMonitorRuleOptions { + this := DeploymentGatesMonitorRuleOptions{} + this.Query = query + return &this +} + +// NewDeploymentGatesMonitorRuleOptionsWithDefaults instantiates a new DeploymentGatesMonitorRuleOptions object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeploymentGatesMonitorRuleOptionsWithDefaults() *DeploymentGatesMonitorRuleOptions { + this := DeploymentGatesMonitorRuleOptions{} + return &this +} + +// GetDuration returns the Duration field value if set, zero value otherwise. +func (o *DeploymentGatesMonitorRuleOptions) GetDuration() int64 { + if o == nil || o.Duration == nil { + var ret int64 + return ret + } + return *o.Duration +} + +// GetDurationOk returns a tuple with the Duration field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeploymentGatesMonitorRuleOptions) GetDurationOk() (*int64, bool) { + if o == nil || o.Duration == nil { + return nil, false + } + return o.Duration, true +} + +// HasDuration returns a boolean if a field has been set. +func (o *DeploymentGatesMonitorRuleOptions) HasDuration() bool { + return o != nil && o.Duration != nil +} + +// SetDuration gets a reference to the given int64 and assigns it to the Duration field. +func (o *DeploymentGatesMonitorRuleOptions) SetDuration(v int64) { + o.Duration = &v +} + +// GetQuery returns the Query field value. +func (o *DeploymentGatesMonitorRuleOptions) GetQuery() string { + if o == nil { + var ret string + return ret + } + return o.Query +} + +// GetQueryOk returns a tuple with the Query field value +// and a boolean to check if the value has been set. +func (o *DeploymentGatesMonitorRuleOptions) GetQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Query, true +} + +// SetQuery sets field value. +func (o *DeploymentGatesMonitorRuleOptions) SetQuery(v string) { + o.Query = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeploymentGatesMonitorRuleOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Duration != nil { + toSerialize["duration"] = o.Duration + } + toSerialize["query"] = o.Query + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeploymentGatesMonitorRuleOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Duration *int64 `json:"duration,omitempty"` + Query *string `json:"query"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Query == nil { + return fmt.Errorf("required field query missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"duration", "query"}) + } else { + return err + } + o.Duration = all.Duration + o.Query = *all.Query + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_deployment_gates_monitor_rule_type.go b/api/datadogV2/model_deployment_gates_monitor_rule_type.go new file mode 100644 index 00000000000..3dfe8458cf6 --- /dev/null +++ b/api/datadogV2/model_deployment_gates_monitor_rule_type.go @@ -0,0 +1,64 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeploymentGatesMonitorRuleType The type identifier for a monitor rule. +type DeploymentGatesMonitorRuleType string + +// List of DeploymentGatesMonitorRuleType. +const ( + DEPLOYMENTGATESMONITORRULETYPE_MONITOR DeploymentGatesMonitorRuleType = "monitor" +) + +var allowedDeploymentGatesMonitorRuleTypeEnumValues = []DeploymentGatesMonitorRuleType{ + DEPLOYMENTGATESMONITORRULETYPE_MONITOR, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DeploymentGatesMonitorRuleType) GetAllowedValues() []DeploymentGatesMonitorRuleType { + return allowedDeploymentGatesMonitorRuleTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DeploymentGatesMonitorRuleType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DeploymentGatesMonitorRuleType(value) + return nil +} + +// NewDeploymentGatesMonitorRuleTypeFromValue returns a pointer to a valid DeploymentGatesMonitorRuleType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDeploymentGatesMonitorRuleTypeFromValue(v string) (*DeploymentGatesMonitorRuleType, error) { + ev := DeploymentGatesMonitorRuleType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DeploymentGatesMonitorRuleType: valid values are %v", v, allowedDeploymentGatesMonitorRuleTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DeploymentGatesMonitorRuleType) IsValid() bool { + for _, existing := range allowedDeploymentGatesMonitorRuleTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DeploymentGatesMonitorRuleType value. +func (v DeploymentGatesMonitorRuleType) Ptr() *DeploymentGatesMonitorRuleType { + return &v +} diff --git a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.go b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.go index d1c4883c9da..36060bb0de8 100644 --- a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.go +++ b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.go @@ -16,6 +16,21 @@ func main() { body := datadogV2.DeploymentGatesEvaluationRequest{ Data: datadogV2.DeploymentGatesEvaluationRequestData{ Attributes: datadogV2.DeploymentGatesEvaluationRequestAttributes{ + Configuration: &datadogV2.DeploymentGatesEvaluationConfiguration{ + DryRun: datadog.PtrBool(false), + Rules: []datadogV2.DeploymentGatesEvaluationRule{ + datadogV2.DeploymentGatesEvaluationRule{ + DeploymentGatesMonitorRule: &datadogV2.DeploymentGatesMonitorRule{ + DryRun: datadog.PtrBool(false), + Name: "error rate monitors", + Options: &datadogV2.DeploymentGatesMonitorRuleOptions{ + Duration: datadog.PtrInt64(300), + Query: "service:transaction-backend env:production", + }, + Type: datadogV2.DEPLOYMENTGATESMONITORRULETYPE_MONITOR, + }}, + }, + }, Env: "staging", Identifier: datadog.PtrString("pre-deploy"), PrimaryTag: datadog.PtrString("region:us-east-1"), diff --git a/tests/scenarios/features/v2/deployment_gates.feature b/tests/scenarios/features/v2/deployment_gates.feature index df9494d2aed..de5ceaeaa3d 100644 --- a/tests/scenarios/features/v2/deployment_gates.feature +++ b/tests/scenarios/features/v2/deployment_gates.feature @@ -286,7 +286,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Accepted" response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 202 Accepted @@ -294,7 +294,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Bad request." response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 400 Bad request. @@ -302,7 +302,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Deployment gate not found." response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 404 Deployment gate not found.