github.com/kubevela/workflow@v0.6.0/charts/vela-workflow/templates/definitions/request.yaml (about)

     1  # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
     2  # Definition source cue file: vela-templates/definitions/internal/request.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: WorkflowStepDefinition
     5  metadata:
     6    annotations:
     7      definition.oam.dev/alias: ""
     8      definition.oam.dev/description: Send request to the url
     9      definition.oam.dev/example-url: https://raw.githubusercontent.com/kubevela/workflow/main/examples/workflow-run/request.yaml
    10    name: request
    11    namespace: {{ include "systemDefinitionNamespace" . }}
    12  spec:
    13    schematic:
    14      cue:
    15        template: |
    16          import (
    17          	"vela/op"
    18          	"encoding/json"
    19          )
    20  
    21          http: op.#HTTPDo & {
    22          	method: parameter.method
    23          	url:    parameter.url
    24          	request: {
    25          		if parameter.body != _|_ {
    26          			body: json.Marshal(parameter.body)
    27          		}
    28          		if parameter.header != _|_ {
    29          			header: parameter.header
    30          		}
    31          	}
    32          }
    33          fail: op.#Steps & {
    34          	if http.response.statusCode > 400 {
    35          		requestFail: op.#Fail & {
    36          			message: "request of \(parameter.url) is fail: \(http.response.statusCode)"
    37          		}
    38          	}
    39          }
    40          response: json.Unmarshal(http.response.body)
    41          parameter: {
    42          	url:    string
    43          	method: *"GET" | "POST" | "PUT" | "DELETE"
    44          	body?: {...}
    45          	header?: [string]: string
    46          }
    47