mutation submit(
    $manifest: String!
    $tags: [String!]
    $note: String
    $visibility: Visibility,
    $secrets: Boolean!,
) {
    submit(
        manifest: $manifest
        tags: $tags
        note: $note
        visibility: $visibility,
        secrets: $secrets,
    ) {
        id
        owner {
            canonicalName
        }
    }
}

mutation cancel($jobId: Int!) {
    cancel(jobId: $jobId) {
        id
    }
}

mutation createUserWebhook($config: UserWebhookInput!) {
    createUserWebhook(config: $config) {
        id
    }
}

mutation deleteUserWebhook($id: Int!) {
    deleteUserWebhook(id: $id) {
        id
    }
}

mutation shareSecret($uuid: String!, $user: String!) {
    shareSecret(uuid: $uuid, user: $user) {
        uuid
    }
}

mutation update($jobId: Int!, $visibility: Visibility!) {
    update(jobId: $jobId, visibility: $visibility) {
        id
    }
}

query monitor($id: Int!) {
    job(id: $id) {
        status
        log {
            fullURL
        }
        tasks {
            name
            status
            log {
                fullURL
            }
        }
    }
}

query manifest($id: Int!) {
    job(id: $id) {
        manifest
        owner {
            canonicalName
        }
        visibility
    }
}

query jobIDs {
    jobs {
        results {
            id
        }
    }
}

query jobs($cursor: Cursor) {
    jobs(cursor: $cursor) {
        ...jobs
    }
}

query jobsByUser($username: String!, $cursor: Cursor) {
    userByName(username: $username) {
        jobs(cursor: $cursor) {
            ...jobs
        }
    }
}

fragment jobs on JobCursor {
    results {
        id
        status
        note
        tags
        tasks {
            name
            status
        }
    }
    cursor
}

query exportJob($id: Int!) {
    job(id: $id) {
        ...jobExport
    }
}

query exportJobs($cursor: Cursor) {
    jobs(cursor: $cursor) {
        results {
            ...jobExport
        }
        cursor
    }
}

fragment jobExport on Job {
    id
    status
    note
    tags
    visibility
    log {
        fullURL
    }
    tasks {
        name
        status
        log {
            fullURL
        }
    }
}

query show($id: Int!) {
    job(id: $id) {
        id
        status
        note
        tags
        log {
            fullURL
        }
        owner {
            canonicalName
        }
        tasks {
            name
            status
            log {
                fullURL
            }
        }
        group {
            jobs {
                id
                status
            }
        }
    }
}

query secrets($cursor: Cursor) {
    secrets(cursor: $cursor) {
        results {
            created
            uuid
            name
            fromUser {
                canonicalName
            }
            __typename
            ... on SecretFile {
                path
                mode
            }
        }
        cursor
    }
}

query getSSHInfo($id: Int!) {
    job(id: $id) {
        id
        runner
    }

    version {
        settings {
            sshUser
        }
    }
}

query runningJobs {
    jobs {
        results {
            id
            status
            note
            tags
        }
    }
}

query artifacts($id: Int!) {
    job(id: $id) {
        artifacts {
            path
            size
            url
        }
    }
}

query userWebhooks($cursor: Cursor) {
    userWebhooks(cursor: $cursor) {
        results {
            id
            url
        }
        cursor
    }
}

query completeSecrets {
    secrets {
        results {
            uuid
            name
        }
    }
}
