github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/workflowstep/request.cue (about) 1 import ( 2 "vela/op" 3 "encoding/json" 4 ) 5 6 request: { 7 alias: "" 8 attributes: {} 9 description: "Send request to the url" 10 annotations: { 11 "category": "External Intergration" 12 } 13 labels: {} 14 type: "workflow-step" 15 } 16 17 template: { 18 http: op.#HTTPDo & { 19 method: parameter.method 20 url: parameter.url 21 request: { 22 if parameter.body != _|_ { 23 body: json.Marshal(parameter.body) 24 } 25 if parameter.header != _|_ { 26 header: parameter.header 27 } 28 } 29 } 30 fail: op.#Steps & { 31 if http.response.statusCode > 400 { 32 requestFail: op.#Fail & { 33 message: "request of \(parameter.url) is fail: \(http.response.statusCode)" 34 } 35 } 36 } 37 response: json.Unmarshal(http.response.body) 38 parameter: { 39 url: string 40 method: *"GET" | "POST" | "PUT" | "DELETE" 41 body?: {...} 42 header?: [string]: string 43 } 44 }