Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59651,6 +59651,7 @@ components:
oneOf:
- $ref: "#/components/schemas/SendSlackMessageAction"
- $ref: "#/components/schemas/SendTeamsMessageAction"
- $ref: "#/components/schemas/TriggerWorkflowAutomationAction"
RoutingRuleAttributes:
description: Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency.
properties:
Expand Down Expand Up @@ -79447,6 +79448,28 @@ components:
type: string
x-enum-varnames:
- MONITOR_ALERT_TRIGGER
TriggerWorkflowAutomationAction:
description: "Triggers a Workflow Automation."
properties:
handle:
description: "The handle of the Workflow Automation to trigger."
example: my-workflow-handle
type: string
type:
$ref: "#/components/schemas/TriggerWorkflowAutomationActionType"
required:
- type
- handle
type: object
TriggerWorkflowAutomationActionType:
default: workflow
description: "Indicates that the action triggers a Workflow Automation."
enum:
- workflow
example: workflow
type: string
x-enum-varnames:
- TRIGGER_WORKFLOW_AUTOMATION
UCConfigPair:
description: The definition of `UCConfigPair` object.
example:
Expand Down
36 changes: 34 additions & 2 deletions api/datadogV2/model_routing_rule_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

// RoutingRuleAction - Defines an action that is executed when a routing rule matches certain criteria.
type RoutingRuleAction struct {
SendSlackMessageAction *SendSlackMessageAction
SendTeamsMessageAction *SendTeamsMessageAction
SendSlackMessageAction *SendSlackMessageAction
SendTeamsMessageAction *SendTeamsMessageAction
TriggerWorkflowAutomationAction *TriggerWorkflowAutomationAction

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
Expand All @@ -27,6 +28,11 @@ func SendTeamsMessageActionAsRoutingRuleAction(v *SendTeamsMessageAction) Routin
return RoutingRuleAction{SendTeamsMessageAction: v}
}

// TriggerWorkflowAutomationActionAsRoutingRuleAction is a convenience function that returns TriggerWorkflowAutomationAction wrapped in RoutingRuleAction.
func TriggerWorkflowAutomationActionAsRoutingRuleAction(v *TriggerWorkflowAutomationAction) RoutingRuleAction {
return RoutingRuleAction{TriggerWorkflowAutomationAction: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *RoutingRuleAction) UnmarshalJSON(data []byte) error {
var err error
Expand Down Expand Up @@ -65,10 +71,28 @@ func (obj *RoutingRuleAction) UnmarshalJSON(data []byte) error {
obj.SendTeamsMessageAction = nil
}

// try to unmarshal data into TriggerWorkflowAutomationAction
err = datadog.Unmarshal(data, &obj.TriggerWorkflowAutomationAction)
if err == nil {
if obj.TriggerWorkflowAutomationAction != nil && obj.TriggerWorkflowAutomationAction.UnparsedObject == nil {
jsonTriggerWorkflowAutomationAction, _ := datadog.Marshal(obj.TriggerWorkflowAutomationAction)
if string(jsonTriggerWorkflowAutomationAction) == "{}" { // empty struct
obj.TriggerWorkflowAutomationAction = nil
} else {
match++
}
} else {
obj.TriggerWorkflowAutomationAction = nil
}
} else {
obj.TriggerWorkflowAutomationAction = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.SendSlackMessageAction = nil
obj.SendTeamsMessageAction = nil
obj.TriggerWorkflowAutomationAction = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
Expand All @@ -84,6 +108,10 @@ func (obj RoutingRuleAction) MarshalJSON() ([]byte, error) {
return datadog.Marshal(&obj.SendTeamsMessageAction)
}

if obj.TriggerWorkflowAutomationAction != nil {
return datadog.Marshal(&obj.TriggerWorkflowAutomationAction)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
Expand All @@ -100,6 +128,10 @@ func (obj *RoutingRuleAction) GetActualInstance() interface{} {
return obj.SendTeamsMessageAction
}

if obj.TriggerWorkflowAutomationAction != nil {
return obj.TriggerWorkflowAutomationAction
}

// all schemas are nil
return nil
}
145 changes: 145 additions & 0 deletions api/datadogV2/model_trigger_workflow_automation_action.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// 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"
)

// TriggerWorkflowAutomationAction Triggers a Workflow Automation.
type TriggerWorkflowAutomationAction struct {
// The handle of the Workflow Automation to trigger.
Handle string `json:"handle"`
// Indicates that the action triggers a Workflow Automation.
Type TriggerWorkflowAutomationActionType `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:"-"`
}

// NewTriggerWorkflowAutomationAction instantiates a new TriggerWorkflowAutomationAction 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 NewTriggerWorkflowAutomationAction(handle string, typeVar TriggerWorkflowAutomationActionType) *TriggerWorkflowAutomationAction {
this := TriggerWorkflowAutomationAction{}
this.Handle = handle
this.Type = typeVar
return &this
}

// NewTriggerWorkflowAutomationActionWithDefaults instantiates a new TriggerWorkflowAutomationAction 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 NewTriggerWorkflowAutomationActionWithDefaults() *TriggerWorkflowAutomationAction {
this := TriggerWorkflowAutomationAction{}
var typeVar TriggerWorkflowAutomationActionType = TRIGGERWORKFLOWAUTOMATIONACTIONTYPE_TRIGGER_WORKFLOW_AUTOMATION
this.Type = typeVar
return &this
}

// GetHandle returns the Handle field value.
func (o *TriggerWorkflowAutomationAction) GetHandle() string {
if o == nil {
var ret string
return ret
}
return o.Handle
}

// GetHandleOk returns a tuple with the Handle field value
// and a boolean to check if the value has been set.
func (o *TriggerWorkflowAutomationAction) GetHandleOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Handle, true
}

// SetHandle sets field value.
func (o *TriggerWorkflowAutomationAction) SetHandle(v string) {
o.Handle = v
}

// GetType returns the Type field value.
func (o *TriggerWorkflowAutomationAction) GetType() TriggerWorkflowAutomationActionType {
if o == nil {
var ret TriggerWorkflowAutomationActionType
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 *TriggerWorkflowAutomationAction) GetTypeOk() (*TriggerWorkflowAutomationActionType, bool) {
if o == nil {
return nil, false
}
return &o.Type, true
}

// SetType sets field value.
func (o *TriggerWorkflowAutomationAction) SetType(v TriggerWorkflowAutomationActionType) {
o.Type = v
}

// MarshalJSON serializes the struct using spec logic.
func (o TriggerWorkflowAutomationAction) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["handle"] = o.Handle
toSerialize["type"] = o.Type

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *TriggerWorkflowAutomationAction) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Handle *string `json:"handle"`
Type *TriggerWorkflowAutomationActionType `json:"type"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Handle == nil {
return fmt.Errorf("required field handle missing")
}
if all.Type == nil {
return fmt.Errorf("required field type missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"handle", "type"})
} else {
return err
}

hasInvalidField := false
o.Handle = *all.Handle
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
}
64 changes: 64 additions & 0 deletions api/datadogV2/model_trigger_workflow_automation_action_type.go
Original file line number Diff line number Diff line change
@@ -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"
)

// TriggerWorkflowAutomationActionType Indicates that the action triggers a Workflow Automation.
type TriggerWorkflowAutomationActionType string

// List of TriggerWorkflowAutomationActionType.
const (
TRIGGERWORKFLOWAUTOMATIONACTIONTYPE_TRIGGER_WORKFLOW_AUTOMATION TriggerWorkflowAutomationActionType = "workflow"
)

var allowedTriggerWorkflowAutomationActionTypeEnumValues = []TriggerWorkflowAutomationActionType{
TRIGGERWORKFLOWAUTOMATIONACTIONTYPE_TRIGGER_WORKFLOW_AUTOMATION,
}

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

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

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

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

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