Skip to content

Instantly share code, notes, and snippets.

@pepetox
Last active September 11, 2020 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepetox/006949b226a5f0a837ba32f353d7f7f2 to your computer and use it in GitHub Desktop.
Save pepetox/006949b226a5f0a837ba32f353d7f7f2 to your computer and use it in GitHub Desktop.
Post workflows ejemplo 1
- getCurrentTime:
call: http.get
args:
url: http://worldtimeapi.org/api/timezone/Europe/Madrid
result: CurrentDateTime
- readWikipedia:
call: http.get
args:
url: https://en.wikipedia.org/w/api.php
query:
action: opensearch
search: ${CurrentDateTime.body.abbreviation}
result: WikiResult
- returnOutput:
return: ${WikiResult.body[1]}
#{"dep":"MKT","name":"jtbucket"}
- conditionalSwitch:
switch:
- condition: ${args.dep == "MKT"}
next: createBucket
- condition: ${args.dep != "MKT"}
next: normalExit
next: normalExit
- normalExit:
return: "No necesita bucket"
- createBucket:
call: http.post
args:
url: https://storage.googleapis.com/storage/v1/b?project=sandbox-262410
auth:
type: OAuth2
body:
name: ${"sandbox-262410-" + args.name}
location: europe-west1
storageClass: STANDARD
result: createResponse
next: endstep
- endstep:
return: "Creado el bucket con éxito"
- getHashFromEmail:
call: http.get
args:
url: ${"https://europe-west1-sandbox-262410.cloudfunctions.net/md5en?message=" + args.email}
result: md5hash
- getGravatarInfo:
call: http.get
args:
url: ${"https://en.gravatar.com/" + md5hash.body.hash + ".json"}
result: resultGravatar
- returnOutput:
return: ${resultGravatar.body.entry[0].thumbnailUrl}
main:
steps:
- getCurrentTime:
call: http.request #http.get|http.post|http.request
args:
method: GET
headers:
key: value
url: http://worldtimeapi.org/api/timezone/Europe/Madrid
query:
data: hey
#body:
#key: value
#auth:
#type: OAuth2 #OIDC|OAuth2
#timeout: VALUE_IN_SECONDS
result: currentDateTime
- assign_vars_example:
assign:
- number: 5
- number_plus_one: ${number+1}
- other_number: 10
- string: "hello"
- num_array: ["zero","one","two"]
next: call_subworkflow
- sleep_example:
call: sys.sleep
args:
seconds: 100
- call_subworkflow:
call: name_message
args:
first_name: "Sherlock"
last_name: "Holmes"
result: output
- readWikipedia:
call: http.get
args:
url: https://en.wikipedia.org/w/api.php
query:
action: opensearch
search: ${currentDateTime.body.abbreviation}
#auth:
#type: OIDC
result: WikiResult
- getCurrentTimeAux:
call: http.get
args:
url: https://us-central1-workflowsample.cloudfunctions.net/datetime
result: currentTime
- conditionalSwitch:
switch:
- condition: ${currentTime.body.dayOfTheWeek == "Friday"}
next: "friday"
- condition: ${currentTime.body.dayOfTheWeek == "Saturday" OR currentTime.body.dayOfTheWeek == "Sunday"}
next: weekend
next: workWeek
- friday:
assign:
- string: "It's friday"
- weekend:
assign:
- string: "It's weekday"
- workWeek:
assign:
- string: "It's normal day"
- returnOutput:
return: ${string + WikiResult.body[1][0]} #finish the wf
name_message:
params: [first_name, last_name]
steps:
- prepareMessage:
return: ${"Hello " + first_name + " " + last_name + ". "}
loop_print:
params: [myArray]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment