views {
    dynamic view forgejoGarmInteraction {
        title 'Forgejo <-> Garm'

        include edp, edp.garm
        include edp.forgejo with {
            title 'Forgejo'
        }
        include edp.garm.garm
        include edp.garm.providerEdgeConnect
        include edgeConnect

        edp.forgejo -> edp.garm.garm '(Webhook) A new job is pending'
        edp.garm.garm -> edp.garm.providerEdgeConnect 'Create new runner'
        edp.garm.providerEdgeConnect -> edgeConnect 'Create App (Runner)'
        edp.garm.providerEdgeConnect -> edgeConnect 'Create AppInstance (Runner)'
        edgeConnect -> forgejoRunner 'Deploys'

        forgejoRunner -> edp.garm.garm 'Get runner registration token'
        edp.garm.garm -> edp.forgejo 'Get runner registration token'
        edp.forgejo -> edp.garm.garm 'Token'
        edp.garm.garm -> forgejoRunner 'Token'
        forgejoRunner -> edp.forgejo 'Register runner'
        forgejoRunner -> edp.forgejo 'Fetch job'
        forgejoRunner -> forgejoRunner 'Work on job'
        forgejoRunner -> edp.forgejo 'Send result'
        edp.forgejo -> edp.forgejo 'Deregister Runner'
        forgejoRunner -> forgejoRunner 'Terminate'

        edp.forgejo -> edp.garm.garm '(Webhook) A job finished'
        edp.garm.garm -> edp.garm.providerEdgeConnect 'Delete runner'
        edp.garm.providerEdgeConnect -> edgeConnect 'Delete AppInstance (Runner)'
        edp.garm.providerEdgeConnect -> edgeConnect 'Delete App (Runner)'
    }
}
