project: connector_plain_list_project_id: [] created_at: '2021-11-19 06:58:38.476164+00:00' created_by_identity: id: d68b747c-682f-485e-bddc-5d906eab09dd identity_type: GIT_CONFIG description: a simple TODO app based on a Cloudomation webhook extension_id: null file_plain_list_project_id: [] flow_plain_list_project_id: - name: todo-flow resource_wrapper_plain_list_resource_id: [] script: |- import uuid import chevron import flow_api MAIN = ''' Cloudomation TODO

Cloudomation TODO app

{{#debug}}
      method: {{method}}
      json: {{json}}
      path: {{path}}
      query: {{query}}
          
{{/debug}}
 
{{#todos}}
{{^done}} {{/done}} {{#done}} {{/done}}
{{/todos}}
{{count}} TODOs
''' def handler(system: flow_api.System, this: flow_api.Execution): inputs = this.get('input_value') method = inputs['method'] store = system.setting('todo-store') try: todos = store.get('value') except flow_api.ResourceNotFoundError: todos = [] if not todos: todos = [] if method == 'POST': json = inputs['json'] action = json.get('action') if action == 'todoNew': todos.append({ 'id': str(uuid.uuid4()), 'label': json['newTodoLabel'], }) elif action == 'todoDone': todos = [ { **todo, 'done': True, } if todo['id'] == json['id'] else todo for todo in todos ] elif action == 'todoUndone': todos = [ { **todo, 'done': False, } if todo['id'] == json['id'] else todo for todo in todos ] elif action == 'todoRemove': todos = [ todo for todo in todos if todo['id'] != json['id'] ] store.save(value=todos) return this.success('all done') data = { 'count': len(todos), 'todos': todos, } return this.webhook_html_response( chevron.render(MAIN, data) ) icon: data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTMsNUg5VjExSDNWNU01LDdWOUg3VjdINU0xMSw3SDIxVjlIMTFWN00xMSwxNUgyMVYxN0gxMVYxNU01LDIwTDEuNSwxNi41TDIuOTEsMTUuMDlMNSwxNy4xN0w5LjU5LDEyLjU5TDExLDE0TDUsMjBaIiAvPjwvc3ZnPg== is_archived: false modified_at: '2022-10-06 10:35:20.864325+00:00' modified_by_identity: id: d68b747c-682f-485e-bddc-5d906eab09dd identity_type: GIT_CONFIG name: ToDo-App organization_id_organization: name: cloudomation plugin_plain_list_project_id: [] project_id_project: name: Default project project_plain_list_project_id: [] resource_tag_plain_list_resource_id: [] schedule_plain_list_project_id: [] scheduler_plain_list_project_id: [] schema_plain_list_project_id: [] setting_plain_list_project_id: [] version: null webhook_plain_list_project_id: - flow_id_flow: name: todo-flow is_enabled: false is_productive: true key: name: todo require_login: true workspace_id_workspace: name: wrapper_plain_list_project_id: []