Skip to content
Open
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
130 changes: 130 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26764,6 +26764,9 @@ components:
description: "A sample workflow."
name: "Example Workflow"
published: true
runAs:
id: 00000000-0000-0000-0000-000000000007
type: service_account
spec:
annotations:
- display:
Expand Down Expand Up @@ -121033,6 +121036,9 @@ components:
description: "A sample workflow."
name: "Example Workflow"
published: true
runAs:
id: 00000000-0000-0000-0000-000000000007
type: service_account
spec:
annotations:
- display:
Expand Down Expand Up @@ -124116,6 +124122,12 @@ components:
published:
description: Set the workflow to published or unpublished. Workflows in an unpublished state will only be executable via manual runs. Automatic triggers such as Schedule will not execute the workflow until it is published.
type: boolean
runAs:
$ref: "#/components/schemas/WorkflowRunAs"
writeOnly: true
runAsUserMode:
$ref: "#/components/schemas/WorkflowRunAsUserMode"
readOnly: true
spec:
$ref: "#/components/schemas/Spec"
tags:
Expand Down Expand Up @@ -124144,6 +124156,9 @@ components:
$ref: "#/components/schemas/WorkflowUserRelationship"
owner:
$ref: "#/components/schemas/WorkflowUserRelationship"
runAs:
$ref: "#/components/schemas/WorkflowUserRelationship"
description: The service account used to run the workflow. Present when `runAsUserMode` is `service_account`.
readOnly: true
type: object
WorkflowDataType:
Expand Down Expand Up @@ -124187,6 +124202,12 @@ components:
published:
description: Set the workflow to published or unpublished. Workflows in an unpublished state will only be executable via manual runs. Automatic triggers such as Schedule will not execute the workflow until it is published.
type: boolean
runAs:
$ref: "#/components/schemas/WorkflowRunAs"
writeOnly: true
runAsUserMode:
$ref: "#/components/schemas/WorkflowRunAsUserMode"
readOnly: true
spec:
$ref: "#/components/schemas/Spec"
tags:
Expand Down Expand Up @@ -124305,6 +124326,9 @@ components:
published:
description: Whether the workflow is published. Unpublished workflows can only be run manually. Automatic triggers such as Schedule do not fire until the workflow is published.
type: boolean
runAsUserMode:
$ref: "#/components/schemas/WorkflowRunAsUserMode"
readOnly: true
spec:
$ref: "#/components/schemas/Spec"
nullable: true
Expand All @@ -124322,6 +124346,83 @@ components:
required:
- name
type: object
WorkflowRunAs:
description: Identity used to run the workflow.
example:
id: 00000000-0000-0000-0000-000000000007
type: service_account
oneOf:
- $ref: "#/components/schemas/WorkflowRunAsOwner"
- $ref: "#/components/schemas/WorkflowRunAsServiceAccount"
- $ref: "#/components/schemas/WorkflowRunAsInitiator"
WorkflowRunAsInitiator:
additionalProperties: false
description: Run the workflow as the user who initiates the execution.
properties:
type:
$ref: "#/components/schemas/WorkflowRunAsInitiatorType"
required:
- type
type: object
WorkflowRunAsInitiatorType:
description: The initiator run-as type.
enum:
- initiator
example: initiator
type: string
x-enum-varnames:
- INITIATOR
WorkflowRunAsOwner:
additionalProperties: false
description: Run the workflow as its owner.
properties:
type:
$ref: "#/components/schemas/WorkflowRunAsOwnerType"
required:
- type
type: object
WorkflowRunAsOwnerType:
description: The owner run-as type.
enum:
- owner
example: owner
type: string
x-enum-varnames:
- OWNER
WorkflowRunAsServiceAccount:
additionalProperties: false
description: Run the workflow as a service account.
properties:
id:
description: The service account identifier.
example: 00000000-0000-0000-0000-000000000007
type: string
type:
$ref: "#/components/schemas/WorkflowRunAsServiceAccountType"
required:
- type
- id
type: object
WorkflowRunAsServiceAccountType:
description: The service account run-as type.
enum:
- service_account
example: service_account
type: string
x-enum-varnames:
- SERVICE_ACCOUNT
WorkflowRunAsUserMode:
description: The effective type of identity used to run the workflow.
enum:
- owner
- service_account
- initiator
example: service_account
type: string
x-enum-varnames:
- OWNER
- SERVICE_ACCOUNT
- INITIATOR
WorkflowTriggerWrapper:
description: "Schema for a Workflow-based trigger."
properties:
Expand Down Expand Up @@ -220369,6 +220470,7 @@ paths:
description: A sample workflow.
name: Example Workflow
published: true
runAsUserMode: service_account
spec: {}
tags:
- team:infra
Expand All @@ -220383,6 +220485,10 @@ paths:
data:
id: 00000000-0000-0000-0000-000000000009
type: users
runAs:
data:
id: 00000000-0000-0000-0000-000000000007
type: users
type: workflows
meta:
page:
Expand Down Expand Up @@ -220423,6 +220529,9 @@ paths:
description: A sample workflow.
name: Example Workflow
published: true
runAs:
id: 00000000-0000-0000-0000-000000000007
type: service_account
spec:
annotations:
- display:
Expand Down Expand Up @@ -220489,8 +220598,14 @@ paths:
data:
attributes:
name: Example Workflow
runAsUserMode: service_account
spec: {}
id: 00000000-0000-0000-0000-000000000001
relationships:
runAs:
data:
id: 00000000-0000-0000-0000-000000000007
type: users
type: workflows
schema:
$ref: "#/components/schemas/CreateWorkflowResponse"
Expand Down Expand Up @@ -220572,11 +220687,17 @@ paths:
description: A sample workflow.
name: Example Workflow
published: true
runAsUserMode: service_account
spec: {}
tags:
- team:infra
updatedAt: "2024-01-01T00:00:00+00:00"
id: 00000000-0000-0000-0000-000000000002
relationships:
runAs:
data:
id: 00000000-0000-0000-0000-000000000007
type: users
type: workflows
schema:
$ref: "#/components/schemas/GetWorkflowResponse"
Expand Down Expand Up @@ -220628,6 +220749,9 @@ paths:
description: A sample workflow.
name: Example Workflow
published: true
runAs:
id: 00000000-0000-0000-0000-000000000007
type: service_account
spec:
annotations:
- display:
Expand Down Expand Up @@ -220695,7 +220819,13 @@ paths:
data:
attributes:
name: Example Workflow
runAsUserMode: service_account
id: 00000000-0000-0000-0000-000000000003
relationships:
runAs:
data:
id: 00000000-0000-0000-0000-000000000007
type: users
type: workflows
schema:
$ref: "#/components/schemas/UpdateWorkflowResponse"
Expand Down
7 changes: 7 additions & 0 deletions examples/v2/workflow-automation/CreateWorkflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::WorkflowAutomationAPI.new

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = ENV["SERVICE_ACCOUNT_USER_DATA_ID"]

body = DatadogAPIClient::V2::CreateWorkflowRequest.new({
data: DatadogAPIClient::V2::WorkflowData.new({
attributes: DatadogAPIClient::V2::WorkflowDataAttributes.new({
description: "A sample workflow.",
name: "Example Workflow",
published: true,
run_as: DatadogAPIClient::V2::WorkflowRunAsServiceAccount.new({
type: DatadogAPIClient::V2::WorkflowRunAsServiceAccountType::SERVICE_ACCOUNT,
id: SERVICE_ACCOUNT_USER_DATA_ID,
}),
spec: DatadogAPIClient::V2::Spec.new({
connection_envs: [
DatadogAPIClient::V2::ConnectionEnv.new({
Expand Down
7 changes: 7 additions & 0 deletions examples/v2/workflow-automation/UpdateWorkflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
# there is a valid "workflow" in the system
WORKFLOW_DATA_ID = ENV["WORKFLOW_DATA_ID"]

# there is a valid "service_account_user" in the system
SERVICE_ACCOUNT_USER_DATA_ID = ENV["SERVICE_ACCOUNT_USER_DATA_ID"]

body = DatadogAPIClient::V2::UpdateWorkflowRequest.new({
data: DatadogAPIClient::V2::WorkflowDataUpdate.new({
attributes: DatadogAPIClient::V2::WorkflowDataUpdateAttributes.new({
description: "A sample workflow.",
name: "Example Workflow",
published: true,
run_as: DatadogAPIClient::V2::WorkflowRunAsServiceAccount.new({
type: DatadogAPIClient::V2::WorkflowRunAsServiceAccountType::SERVICE_ACCOUNT,
id: SERVICE_ACCOUNT_USER_DATA_ID,
}),
spec: DatadogAPIClient::V2::Spec.new({
connection_envs: [
DatadogAPIClient::V2::ConnectionEnv.new({
Expand Down
2 changes: 1 addition & 1 deletion features/v2/given.json
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@
"parameters": [
{
"name": "body",
"value": "{\n \"data\": {\n \"type\": \"workflows\",\n \"attributes\": {\n \"name\": \"Cassette Workflow x-given\",\n \"spec\": {\n \"triggers\": [\n {\n \"startStepNames\": [\"No_op\"],\n \"workflowTrigger\": {}\n }\n ],\n \"steps\": [\n {\n \"name\": \"No_op\",\n \"actionId\": \"com.datadoghq.core.noop\"\n }\n ]\n }\n }\n }\n}"
"value": "{\n \"data\": {\n \"type\": \"workflows\",\n \"attributes\": {\n \"name\": \"Cassette Workflow x-given\",\n \"runAs\": {\"type\": \"owner\"},\n \"spec\": {\n \"triggers\": [\n {\n \"startStepNames\": [\"No_op\"],\n \"workflowTrigger\": {}\n }\n ],\n \"steps\": [\n {\n \"name\": \"No_op\",\n \"actionId\": \"com.datadoghq.core.noop\"\n }\n ]\n }\n }\n }\n}"
}
],
"step": "there is a valid \"workflow\" in the system",
Expand Down
14 changes: 11 additions & 3 deletions features/v2/workflow_automation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ Feature: Workflow Automation

@team:DataDog/workflow-automation-dev
Scenario: Create a Workflow returns "Successfully created a workflow." response
Given new "CreateWorkflow" request
And body with value {"data": {"attributes": {"description": "A sample workflow.", "name": "Example Workflow", "published": true, "spec": {"connectionEnvs": [{"connections": [{"connectionId": "e1e64943-c7c5-4487-aece-25aaec7d3aad", "label": "INTEGRATION_DATADOG"}], "env": "default"}], "inputSchema": {"parameters": [{"defaultValue": "default", "name": "input", "type": "STRING"}]}, "outputSchema": {"parameters": [{"name": "output", "type": "ARRAY_OBJECT", "value": "outputValue"}]}, "steps": [{"actionId": "com.datadoghq.dd.monitor.listMonitors", "connectionLabel": "INTEGRATION_DATADOG", "name": "Step1", "outboundEdges": [{"branchName": "main", "nextStepName": "Step2"}], "parameters": [{"name": "tags", "value": "service:monitoring"}]}, {"actionId": "com.datadoghq.core.noop", "name": "Step2"}], "triggers": [{"monitorTrigger": {"rateLimit": {"count": 1, "interval": "3600s"}}, "startStepNames": ["Step1"]}, {"startStepNames": ["Step1"], "githubWebhookTrigger": {}}]}, "tags": ["team:infra", "service:monitoring", "foo:bar"]}, "type": "workflows"}}
Given there is a valid "service_account_user" in the system
And new "CreateWorkflow" request
And body with value {"data": {"attributes": {"description": "A sample workflow.", "name": "Example Workflow", "published": true, "runAs": {"type": "service_account", "id": "{{ service_account_user.data.id }}"}, "spec": {"connectionEnvs": [{"connections": [{"connectionId": "e1e64943-c7c5-4487-aece-25aaec7d3aad", "label": "INTEGRATION_DATADOG"}], "env": "default"}], "inputSchema": {"parameters": [{"defaultValue": "default", "name": "input", "type": "STRING"}]}, "outputSchema": {"parameters": [{"name": "output", "type": "ARRAY_OBJECT", "value": "outputValue"}]}, "steps": [{"actionId": "com.datadoghq.dd.monitor.listMonitors", "connectionLabel": "INTEGRATION_DATADOG", "name": "Step1", "outboundEdges": [{"branchName": "main", "nextStepName": "Step2"}], "parameters": [{"name": "tags", "value": "service:monitoring"}]}, {"actionId": "com.datadoghq.core.noop", "name": "Step2"}], "triggers": [{"monitorTrigger": {"rateLimit": {"count": 1, "interval": "3600s"}}, "startStepNames": ["Step1"]}, {"startStepNames": ["Step1"], "githubWebhookTrigger": {}}]}, "tags": ["team:infra", "service:monitoring", "foo:bar"]}, "type": "workflows"}}
When the request is sent
Then the response status is 201 Successfully created a workflow.
And the response "data.attributes.runAsUserMode" is equal to "service_account"
And the response "data.relationships.runAs.data.id" has the same value as "service_account_user.data.id"

@team:DataDog/workflow-automation-dev
Scenario: Delete an existing Workflow returns "Not found" response
Expand Down Expand Up @@ -127,6 +130,7 @@ Feature: Workflow Automation
And request contains "workflow_id" parameter from "workflow.data.id"
When the request is sent
Then the response status is 200 Successfully got a workflow.
And the response "data.attributes.runAsUserMode" is equal to "owner"

@replay-only @team:DataDog/workflow-automation-dev
Scenario: List workflow instances returns "Bad Request" response
Expand Down Expand Up @@ -154,6 +158,7 @@ Feature: Workflow Automation
And new "ListWorkflows" request
When the request is sent
Then the response status is 200 OK
And the response "data" has item with field "attributes.runAsUserMode" with value "owner"

@replay-only @skip-validation @team:DataDog/workflow-automation-dev @with-pagination
Scenario: List workflows returns "OK" response with pagination
Expand Down Expand Up @@ -184,8 +189,11 @@ Feature: Workflow Automation
@team:DataDog/workflow-automation-dev
Scenario: Update an existing Workflow returns "Successfully updated a workflow." response
Given there is a valid "workflow" in the system
And there is a valid "service_account_user" in the system
And new "UpdateWorkflow" request
And request contains "workflow_id" parameter from "workflow.data.id"
And body with value {"data": {"attributes": {"description": "A sample workflow.", "name": "Example Workflow", "published": true, "spec": {"connectionEnvs": [{"connections": [{"connectionId": "e1e64943-c7c5-4487-aece-25aaec7d3aad", "label": "INTEGRATION_DATADOG"}], "env": "default"}], "inputSchema": {"parameters": [{"defaultValue": "default", "name": "input", "type": "STRING"}]}, "outputSchema": {"parameters": [{"name": "output", "type": "ARRAY_OBJECT", "value": "outputValue"}]}, "steps": [{"actionId": "com.datadoghq.dd.monitor.listMonitors", "connectionLabel": "INTEGRATION_DATADOG", "name": "Step1", "outboundEdges": [{"branchName": "main", "nextStepName": "Step2"}], "parameters": [{"name": "tags", "value": "service:monitoring"}]}, {"actionId": "com.datadoghq.core.noop", "name": "Step2"}], "triggers": [{"monitorTrigger": {"rateLimit": {"count": 1, "interval": "3600s"}}, "startStepNames": ["Step1"]}, {"startStepNames": ["Step1"], "githubWebhookTrigger": {}}]}, "tags": ["team:infra", "service:monitoring", "foo:bar"]}, "id": "22222222-2222-2222-2222-222222222222", "type": "workflows"}}
And body with value {"data": {"attributes": {"description": "A sample workflow.", "name": "Example Workflow", "published": true, "runAs": {"type": "service_account", "id": "{{ service_account_user.data.id }}"}, "spec": {"connectionEnvs": [{"connections": [{"connectionId": "e1e64943-c7c5-4487-aece-25aaec7d3aad", "label": "INTEGRATION_DATADOG"}], "env": "default"}], "inputSchema": {"parameters": [{"defaultValue": "default", "name": "input", "type": "STRING"}]}, "outputSchema": {"parameters": [{"name": "output", "type": "ARRAY_OBJECT", "value": "outputValue"}]}, "steps": [{"actionId": "com.datadoghq.dd.monitor.listMonitors", "connectionLabel": "INTEGRATION_DATADOG", "name": "Step1", "outboundEdges": [{"branchName": "main", "nextStepName": "Step2"}], "parameters": [{"name": "tags", "value": "service:monitoring"}]}, {"actionId": "com.datadoghq.core.noop", "name": "Step2"}], "triggers": [{"monitorTrigger": {"rateLimit": {"count": 1, "interval": "3600s"}}, "startStepNames": ["Step1"]}, {"startStepNames": ["Step1"], "githubWebhookTrigger": {}}]}, "tags": ["team:infra", "service:monitoring", "foo:bar"]}, "id": "22222222-2222-2222-2222-222222222222", "type": "workflows"}}
When the request is sent
Then the response status is 200 Successfully updated a workflow.
And the response "data.attributes.runAsUserMode" is equal to "service_account"
And the response "data.relationships.runAs.data.id" has the same value as "service_account_user.data.id"
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"description": "A sample workflow.",
"name": "Example Workflow",
"published": true,
"runAs": {
"id": "{{ service_account_user.data.id }}",
"type": "service_account"
},
"spec": {
"connectionEnvs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"description": "A sample workflow.",
"name": "Example Workflow",
"published": true,
"runAs": {
"id": "{{ service_account_user.data.id }}",
"type": "service_account"
},
"spec": {
"connectionEnvs": [
{
Expand Down
Loading
Loading