added ghn_client delete

master
Marco Lettere 2 years ago
parent ff546c3405
commit 65e1c2709e

@ -20,9 +20,10 @@ workflows:
# - add_workspace_client_to_context
# - enable_workspace_clients_for_context
# - add_workspace_client_to_contexts
- ghn_client_add_to_context
- ghn_client_add_to_contexts
- ghn_client_create
# - ghn_client_add_to_context
# - ghn_client_add_to_contexts
# - ghn_client_create
- ghn_client_delete
keycloak_host: "https://accounts.dev.d4science.org/auth"
keycloak: "{{ keycloak_host }}/realms"

@ -0,0 +1,74 @@
{
"ownerApp" : "Orchestrator",
"name" : "ghn_client_delete",
"createBy" : "Marco Lettere",
"description": "Delete a GHN client from IAM",
"version" : 1,
"ownerEmail" : "marco.lettere@nubisware.com",
"inputParameters" : ["client_id"],
"tasks" : [
{
"name": "LAMBDA_TASK",
"taskReferenceName": "init",
"type": "LAMBDA",
"inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}",
"scriptExpression" : "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id)) throw('Client ID must not be empty');"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "authorize",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak}/protocol/openid-connect/token",
"method" : "POST",
"headers" : {
"Accept" : "application/json"
},
"body" : {
"client_id" : "orchestrator",
"client_secret" : "{{ keycloak_auth }}",
"grant_type" : "client_credentials"
}
}
},
{
"name" : "pyrest",
"taskReferenceName" : "lookup_client",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/clients",
"params" : { "clientId" : "${workflow.input.client_id}"},
"method" : "GET",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Accept" : "application/json"
}
}
},
{
"name": "LAMBDA_TASK",
"taskReferenceName": "check",
"type": "LAMBDA",
"inputParameters": {
"list" : "${lookup_client.output.body}",
"scriptExpression" : "if($.list.length === 0 || $.list.length > 1) throw('No client found with client_id or ambiguous query returned multiple clients.')"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "delete_client",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/clients/${lookup_client.output.body[0].id}",
"method" : "DELETE",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}"
}
}
}
]
}
Loading…
Cancel
Save