From 890302677a2d3caa91d41b3abd27e2f226f17835 Mon Sep 17 00:00:00 2001 From: Sebastien Vermeille Date: Thu, 21 Sep 2023 08:02:57 +0200 Subject: [PATCH] Initial setup --- .github/workflows/release.yml | 31 + DEV.md | 21 + Makefile | 12 + README.md | 20 + cirrusci_client.go | 56 + genqlient.yaml | 14 + go.mod | 15 + go.sum | 112 ++ resources/graphql/client/queries.graphql | 5 + .../graphql/schema/cirrus-ci.schema.graphql | 1559 +++++++++++++++++ scripts/build.sh | 6 + 11 files changed, 1851 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 DEV.md create mode 100644 Makefile create mode 100644 README.md create mode 100644 cirrusci_client.go create mode 100644 genqlient.yaml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 resources/graphql/client/queries.graphql create mode 100644 resources/graphql/schema/cirrus-ci.schema.graphql create mode 100755 scripts/build.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c037edd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release Go project + +on: + push: + tags: + - "*" # triggers only if push new tag version, like `0.8.4` or else + +jobs: + build: + name: GoReleaser build + runs-on: ubuntu-latest + + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: 0 # See: https://goreleaser.com/ci/actions/ + + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: 1.14 + id: go + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@master + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/DEV.md b/DEV.md new file mode 100644 index 0000000..afc3db1 --- /dev/null +++ b/DEV.md @@ -0,0 +1,21 @@ +# DEV notes + +## Graphql schema for cirrus ci comes from: +https://github.com/cirruslabs/cirrus-ci-web/blob/master/schema.gql + +This has to be removed: + +``` +""" +A 64-bit signed integer +""" +scalar Int +``` + +## Generate the client: + +Run `go run github.com/Khan/genqlient genqlient.yaml` + +# Note +All of that is automated via commands in the makefile +and then reused by the CI. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..59314a7 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +DEFAULT: build + +# For building the project locally +install: + + +# Cleanup unused dependencies +cleanup: + go mod tidy + +build: + @./scripts/build.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..93219ce --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# GraphQL Client for Cirrus CI written in GO + +## Getting started + +Simply run `go get github.com/sebastienvermeille/gocirrus-graphql-client@v0.0.1` + +Then you can use the client as follows: + +### Example - Authenticate to Cirrus +TODO: document + +### Example - Run a query +TODO: document + + +# Sidenote + +This is my first project using golang, +if you see some good practice not applied here, I would be happy to hear from you. + diff --git a/cirrusci_client.go b/cirrusci_client.go new file mode 100644 index 0000000..b39d838 --- /dev/null +++ b/cirrusci_client.go @@ -0,0 +1,56 @@ +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. + +package client + +import ( + "context" + + "github.com/Khan/genqlient/graphql" +) + +// getViewerResponse is returned by getViewer on success. +type getViewerResponse struct { + Viewer getViewerViewerUser `json:"viewer"` +} + +// GetViewer returns getViewerResponse.Viewer, and is useful for accessing the field via an interface. +func (v *getViewerResponse) GetViewer() getViewerViewerUser { return v.Viewer } + +// getViewerViewerUser includes the requested fields of the GraphQL type User. +type getViewerViewerUser struct { + Id string `json:"id"` +} + +// GetId returns getViewerViewerUser.Id, and is useful for accessing the field via an interface. +func (v *getViewerViewerUser) GetId() string { return v.Id } + +// The query or mutation executed by getViewer. +const getViewer_Operation = ` +query getViewer { + viewer { + id + } +} +` + +func getViewer( + ctx context.Context, + client graphql.Client, +) (*getViewerResponse, error) { + req := &graphql.Request{ + OpName: "getViewer", + Query: getViewer_Operation, + } + var err error + + var data getViewerResponse + resp := &graphql.Response{Data: &data} + + err = client.MakeRequest( + ctx, + req, + resp, + ) + + return &data, err +} diff --git a/genqlient.yaml b/genqlient.yaml new file mode 100644 index 0000000..625e6e5 --- /dev/null +++ b/genqlient.yaml @@ -0,0 +1,14 @@ +schema: resources/graphql/schema/cirrus-ci.schema.graphql +operations: + - resources/graphql/client/queries.graphql +generated: cirrusci_client.go +## needed since it doesn't match the directory name: +package: client + +# We bind github's DateTime scalar type to Go's time.Time (which conveniently +# already defines MarshalJSON and UnmarshalJSON). This means genqlient will +# use time.Time when a query requests a DateTime, and is required for custom +# scalars. +bindings: + DateTime: + type: time.Time diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a9cc210 --- /dev/null +++ b/go.mod @@ -0,0 +1,15 @@ +module github.com/sebastienvermeille/gocirrus-graphql-client + +go 1.14 + +require ( + github.com/Khan/genqlient v0.6.0 // indirect + github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/alexflint/go-arg v1.4.2 // indirect + github.com/alexflint/go-scalar v1.0.0 // indirect + github.com/vektah/gqlparser/v2 v2.5.1 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/tools v0.8.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..be18cb4 --- /dev/null +++ b/go.sum @@ -0,0 +1,112 @@ +github.com/99designs/gqlgen v0.17.31/go.mod h1:i4rEatMrzzu6RXaHydq1nmEPZkb3bKQsnxNRHS4DQB4= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Khan/genqlient v0.6.0 h1:Bwb1170ekuNIVIwTJEqvO8y7RxBxXu639VJOkKSrwAk= +github.com/Khan/genqlient v0.6.0/go.mod h1:rvChwWVTqXhiapdhLDV4bp9tz/Xvtewwkon4DpWWCRM= +github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= +github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= +github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/alexflint/go-arg v1.4.2 h1:lDWZAXxpAnZUq4qwb86p/3rIJJ2Li81EoMbTMujhVa0= +github.com/alexflint/go-arg v1.4.2/go.mod h1:9iRbDxne7LcR/GSvEr7ma++GLpdIU1zrghf2y2768kM= +github.com/alexflint/go-scalar v1.0.0 h1:NGupf1XV/Xb04wXskDFzS0KWOLH632W/EO4fAFi+A70= +github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxjy3MxYW0gjYw= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= +github.com/bradleyjkemp/cupaloy/v2 v2.6.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= +github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4= +github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= +golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/resources/graphql/client/queries.graphql b/resources/graphql/client/queries.graphql new file mode 100644 index 0000000..b51181b --- /dev/null +++ b/resources/graphql/client/queries.graphql @@ -0,0 +1,5 @@ +query getViewer { + viewer { + id + } +} \ No newline at end of file diff --git a/resources/graphql/schema/cirrus-ci.schema.graphql b/resources/graphql/schema/cirrus-ci.schema.graphql new file mode 100644 index 0000000..3e70442 --- /dev/null +++ b/resources/graphql/schema/cirrus-ci.schema.graphql @@ -0,0 +1,1559 @@ +""" +Exposes a URL that specifies the behaviour of this scalar. +""" +directive @specifiedBy( + """ + The URL that specifies the behaviour of this scalar. + """ + url: String! +) on SCALAR + +type ApiAccessToken { + maskedToken: String! + creationTimestamp: Int! +} + +""" +Task architecture. +""" +enum ArchitectureType { + AMD64 + ARM64 +} + +type ArtifactFileInfo { + path: String! + size: Int! +} + +type Artifacts { + name: String! + type: String + format: String + files: [ArtifactFileInfo!]! +} + +""" +An edge in a connection +""" +type AuditEventEdge { + """ + The item at the end of the edge + """ + node: AuditEventType! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type AuditEventsConnection { + """ + a list of edges + """ + edges: [AuditEventEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +type AuditEventType implements Node { + id: ID! + platform: String! + ownerUid: String! + type: String! + data: String! + timestamp: Int! + repository: Repository + actor: UserBasicInfo +} + +type BillingSettings { + platform: String! + ownerUid: String! + enabled: Boolean! + billingCreditsLimit: Int! + billingEmailAddress: String! + invoiceTemplate: String +} + +input BillingSettingsInput { + platform: String! + ownerUid: ID! + enabled: Boolean! + billingEmailAddress: String! + invoiceTemplate: String + clientMutationId: String! +} + +type BillingSettingsPayload { + settings: BillingSettings! + clientMutationId: String! +} + +type Build implements Node { + id: ID! + repositoryId: ID! + branch: String! + tag: String + changeIdInRepo: String! + changeMessageTitle: String! + changeMessage: String! + durationInSeconds: Int + clockDurationInSeconds: Int + pullRequest: Int + pullRequestLabels: [String!]! + isSenderUserCollaborator: Boolean! + senderUserPermissions: String! + changeTimestamp: Int! + buildCreatedTimestamp: Int! + status: BuildStatus! + notifications: [Notification!]! + parsingResult: ParsingResult + hasPausedTasks: Boolean! + tasks: [Task!]! + executingTasks: [Task!]! + taskGroupsAmount: Int! + latestGroupTasks: [Task!]! + repository: Repository! + viewerPermission: PermissionType! + source: String + hooks: [Hook!]! + initializer: UserBasicInfo +} + +input BuildApproveInput { + buildId: ID! + clientMutationId: String! +} + +type BuildApprovePayload { + build: Build! + clientMutationId: String! +} + +input BuildReTriggerInput { + buildId: ID! + clientMutationId: String! +} + +type BuildReTriggerPayload { + build: Build! + clientMutationId: String! +} + +""" +Build status. +""" +enum BuildStatus { + CREATED + NEEDS_APPROVAL + TRIGGERED + EXECUTING + FAILED + COMPLETED + ABORTED + ERRORED +} + +input BuyComputeCreditsInput { + platform: String! + ownerUid: ID! + amountOfCredits: String! + paymentTokenId: String! + receiptEmail: String + clientMutationId: String! +} + +type BuyComputeCreditsPayload { + error: String + info: OwnerInfo! + user: User! + clientMutationId: String! +} + +type CacheRetrievalAttemptError { + key: String! + message: String! +} + +type CacheRetrievalAttemptHit { + key: String! + sizeBytes: Int! + downloadedInMilliseconds: Int! + extractedInMilliseconds: Int! + valid: Boolean! +} + +type CacheRetrievalAttemptMiss { + key: String! + sizeBytes: Int! + populatedInMilliseconds: Int! + archivedInMilliseconds: Int! + uploadedInMilliseconds: Int! +} + +type CacheRetrievalAttempts { + errors: [CacheRetrievalAttemptError!]! + hits: [CacheRetrievalAttemptHit!]! + misses: [CacheRetrievalAttemptMiss!]! +} + +type ComputeUsage { + instancePlatform: PlatformType! + instanceArchitecture: ArchitectureType! + cpuSeconds: Int! + balanceInMicroCredits: Int! +} + +""" +Repository Setting to choose where to look for the configuration file. +""" +enum ConfigResolutionStrategy { + SAME_SHA + MERGE_FOR_PRS + DEFAULT_BRANCH +} + +input CreatePersistentWorkerPoolInput { + platform: String! + ownerUid: ID! + name: String! + enabledForPublic: Boolean! + clientMutationId: String! +} + +type CreatePersistentWorkerPoolPayload { + pool: PersistentWorkerPool! + clientMutationId: String! +} + +type DayDate { + year: Int! + month: Int! + day: Int! +} + +""" +Repository Setting to choose how to decrypt variables. +""" +enum DecryptEnvironmentVariablesFor { + USERS_WITH_WRITE_PERMISSIONS + EVERYONE + COLLABORATORS +} + +input DeletePersistentWorkerInput { + poolId: String! + name: String! + clientMutationId: String! +} + +type DeletePersistentWorkerPayload { + deletedWorker: PersistentWorker! + clientMutationId: String! +} + +input DeletePersistentWorkerPoolInput { + poolId: String! + clientMutationId: String! +} + +type DeletePersistentWorkerPoolPayload { + deletedPoolId: ID! + deletedPool: PersistentWorkerPool! + clientMutationId: String! +} + +input DeleteWebPushConfigurationInput { + endpoint: String! + clientMutationId: String! +} + +type DeleteWebPushConfigurationPayload { + clientMutationId: String! +} + +type ExecutionChart { + maxValue: Float! + minValue: Float! + points: [ExecutionChartPoint!]! +} + +type ExecutionChartPoint { + value: Float! + secondsFromStart: Int! +} + +type ExecutionEvent { + timestamp: Int! + message: String! +} + +type ExecutionInfo { + labels: [String!]! + events: [ExecutionEvent!]! + cpuChart: ExecutionChart + memoryChart: ExecutionChart + cacheRetrievalAttempts: CacheRetrievalAttempts! + agentNotifications: [Notification!]! +} + +input GenerateNewOwnerAccessTokenInput { + platform: ID! + ownerUid: ID! + clientMutationId: String! +} + +type GenerateNewOwnerAccessTokenPayload { + token: String! + clientMutationId: String! +} + +input GenerateNewScopedAccessTokenInput { + platform: ID! + ownerUid: ID! + durationSeconds: Int + permission: PermissionType! + repositoryNames: [String!]! + clientMutationId: String! +} + +type GenerateNewScopedAccessTokenPayload { + token: String! + clientMutationId: String! +} + +input GetPersistentWorkerPoolRegistrationTokenInput { + poolId: ID! + clientMutationId: String! +} + +type GetPersistentWorkerPoolRegistrationTokenPayload { + token: String! + clientMutationId: String! +} + +type Hook implements Node { + id: ID! + repositoryId: ID! + repository: Repository! + buildId: ID! + build: Build! + taskId: ID + task: Task + timestamp: Int! + name: String! + info: HookExecutionInfo! +} + +type HookExecutionInfo { + error: String! + arguments: String! + result: String! + outputLogs: [String!]! + durationNanos: Int! + environment: [String!]! +} + +input HooksReRunInput { + hookIds: [ID!] + clientMutationId: String! +} + +type HooksReRunPayload { + newHooks: [Hook!]! + clientMutationId: String! +} + +type InstanceResources { + cpu: Float! + memory: Int! +} + +input InvalidateCacheEntriesInput { + taskId: ID! + cacheKeys: [String!]! + clientMutationId: String! +} + +type InvalidateCacheEntriesPayload { + clientMutationId: String! +} + +type MetricsChart { + title: String! + points: [TimePoint!]! + dataUnits: String +} + +input MetricsQueryParameters { + status: TaskStatus + platform: PlatformType + type: String + isCommunity: Boolean + isPR: Boolean + usedComputeCredits: Boolean + branch: String +} + +type MonthlyComputeUsage { + date: String! + usageDetails: [ComputeUsage!]! +} + +type Mutation { + securedVariable( + input: RepositorySecuredVariableInput! + ): RepositorySecuredVariablePayload! + securedOwnerVariable( + input: OwnerSecuredVariableInput! + ): OwnerSecuredVariablePayload! + updateSecuredOwnerVariable( + input: UpdateOwnerSecuredVariableInput! + ): UpdateOwnerSecuredVariablePayload! + createBuild(input: RepositoryCreateBuildInput!): RepositoryCreateBuildPayload! + deleteRepository(input: RepositoryDeleteInput!): RepositoryDeletePayload! + rerun(input: TaskReRunInput!): TaskReRunPayload! + batchReRun(input: TasksReRunInput!): TasksReRunPayload! + abortTask(input: TaskAbortInput!): TaskAbortPayload! + batchAbort(input: TaskBatchAbortInput!): TaskBatchAbortPayload! + retrigger(input: BuildReTriggerInput!): BuildReTriggerPayload! + saveSettings(input: RepositorySettingsInput!): RepositorySettingsPayload! + saveCronSettings( + input: RepositorySaveCronSettingsInput! + ): RepositorySaveCronSettingsPayload! + removeCronSettings( + input: RepositoryRemoveCronSettingsInput! + ): RepositoryRemoveCronSettingsPayload! + approve(input: BuildApproveInput!): BuildApprovePayload! + trigger(input: TaskTriggerInput!): TaskTriggerPayload! + saveWebHookSettings( + input: SaveWebHookSettingsInput! + ): SaveWebHookSettingsPayload! + generateNewOwnerAccessToken( + input: GenerateNewOwnerAccessTokenInput! + ): GenerateNewOwnerAccessTokenPayload! + generateNewScopedAccessToken( + input: GenerateNewScopedAccessTokenInput! + ): GenerateNewScopedAccessTokenPayload! + deletePersistentWorker( + input: DeletePersistentWorkerInput! + ): DeletePersistentWorkerPayload! + updatePersistentWorker( + input: UpdatePersistentWorkerInput! + ): UpdatePersistentWorkerPayload! + persistentWorkerPoolRegistrationToken( + input: GetPersistentWorkerPoolRegistrationTokenInput! + ): GetPersistentWorkerPoolRegistrationTokenPayload! + createPersistentWorkerPool( + input: CreatePersistentWorkerPoolInput! + ): CreatePersistentWorkerPoolPayload! + updatePersistentWorkerPool( + input: UpdatePersistentWorkerPoolInput! + ): UpdatePersistentWorkerPoolPayload! + deletePersistentWorkerPool( + input: DeletePersistentWorkerPoolInput! + ): DeletePersistentWorkerPoolPayload! + saveWebPushConfiguration( + input: SaveWebPushConfigurationInput! + ): SaveWebPushConfigurationPayload! + deleteWebPushConfiguration( + input: DeleteWebPushConfigurationInput! + ): DeleteWebPushConfigurationPayload! + rerunHooks(input: HooksReRunInput!): HooksReRunPayload! + repositorySetMetadata( + input: RepositorySetMetadataInput! + ): RepositorySetMetadataPayload! + invalidateCacheEntries( + input: InvalidateCacheEntriesInput! + ): InvalidateCacheEntriesPayload! + saveBillingSettings(input: BillingSettingsInput!): BillingSettingsPayload! + buyComputeCredits(input: BuyComputeCreditsInput!): BuyComputeCreditsPayload! +} + +""" +An object with an ID +""" +interface Node { + """ + The ID of an object + """ + id: ID! +} + +type Notification { + level: NotificationLevel! + message: String! + link: String +} + +""" +Notification level. +""" +enum NotificationLevel { + INFO + WARNING + ERROR +} + +""" +An edge in a connection +""" +type OwnerBuildEdge { + """ + The item at the end of the edge + """ + node: Build! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type OwnerBuildsConnection { + """ + a list of edges + """ + edges: [OwnerBuildEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +type OwnerInfo { + uid: ID! + platform: String! + name: String! + avatarURL: String! + description: OwnerInfoDescription! + viewerPermission: PermissionType! + apiToken: ApiAccessToken + persistentWorkerPools: [PersistentWorkerPool!]! + webhookSettings: WebHookSettings! + webhookDeliveries( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + ): OwnerWebhookDeliveriesConnection! + repositories( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + ): OwnerRepositoriesConnection! + builds( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + + """ + fetching only builds with the specified status + """ + status: BuildStatus + ): OwnerBuildsConnection! + auditEvents( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + ): AuditEventsConnection! + balanceInCredits: String! + billingSettings: BillingSettings! + transactions( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + ): OwnerTransactionsConnection! + monthlyComputeUsage: [MonthlyComputeUsage!]! +} + +type OwnerInfoDescription { + message: String! + actions: [OwnerInfoDescriptionAction!]! +} + +type OwnerInfoDescriptionAction { + title: String! + link: String! + icon: String +} + +""" +A connection to a list of items. +""" +type OwnerRepositoriesConnection { + """ + a list of edges + """ + edges: [OwnerRepositoryEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +""" +An edge in a connection +""" +type OwnerRepositoryEdge { + """ + The item at the end of the edge + """ + node: Repository! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +input OwnerSecuredVariableInput { + platform: String! + ownerUid: ID! + valueToSecure: String! + clientMutationId: String! +} + +type OwnerSecuredVariablePayload { + variableName: String! + clientMutationId: String! +} + +type OwnerTransaction { + platform: String! + ownerUid: String! + taskId: Int! + repositoryId: Int! + timestamp: Int! + microCreditsAmount: Int! + creditsAmount: String! + initialCreditsAmount: String + task: Task! + repository: Repository! +} + +""" +An edge in a connection +""" +type OwnerTransactionEdge { + """ + The item at the end of the edge + """ + node: OwnerTransaction! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type OwnerTransactionsConnection { + """ + a list of edges + """ + edges: [OwnerTransactionEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +""" +A connection to a list of items. +""" +type OwnerWebhookDeliveriesConnection { + """ + a list of edges + """ + edges: [OwnerWebHookDeliveryEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +""" +An edge in a connection +""" +type OwnerWebHookDeliveryEdge { + """ + The item at the end of the edge + """ + node: WebHookDelivery! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +Information about pagination in a connection. +""" +type PageInfo { + """ + When paginating forwards, are there more items? + """ + hasNextPage: Boolean! + + """ + When paginating backwards, are there more items? + """ + hasPreviousPage: Boolean! + + """ + When paginating backwards, the cursor to continue. + """ + startCursor: String + + """ + When paginating forwards, the cursor to continue. + """ + endCursor: String +} + +type ParsingResult { + rawYamlConfig: String! + rawStarlarkConfig: String! + processedYamlConfig: String! + issues: [ParsingResultIssue!]! + affectedFiles: [String!]! + outputLogs: [String!]! + environment: [String!]! +} + +type ParsingResultIssue { + level: ParsingResultIssueLevel! + message: String! + rawDetails: String! + path: String! + line: Int! + column: Int! +} + +enum ParsingResultIssueLevel { + INFO + WARNING + ERROR +} + +""" +User access level. +""" +enum PermissionType { + NONE + READ + WRITE + ADMIN +} + +type PersistentWorker { + id: ID! + name: String! + disabled: Boolean! + arch: String! + hostname: String! + os: String! + version: String! + labels: [String!]! + info: PersistentWorkerInfo + assignedTasks( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + ): PersistentWorkerAssignedTasksConnection! +} + +""" +An edge in a connection +""" +type PersistentWorkerAssignedTaskEdge { + """ + The item at the end of the edge + """ + node: Task! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type PersistentWorkerAssignedTasksConnection { + """ + a list of edges + """ + edges: [PersistentWorkerAssignedTaskEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +type PersistentWorkerInfo { + heartbeatTimestamp: Int! + runningTasks: [Task!]! + resourcesTotal: [PersistentWorkerResource!]! +} + +type PersistentWorkerPool implements Node { + id: ID! + name: String! + enabledForPublic: Boolean! + workers: [PersistentWorker!]! + viewerPermission: PermissionType! +} + +type PersistentWorkerResource { + key: String! + value: Float! +} + +""" +Task platform. +""" +enum PlatformType { + LINUX + DARWIN + WINDOWS + FREEBSD + SOLARIS + OPENBSD + NETBSD +} + +type Query { + node(id: ID!): Node + viewer: User + repository(id: ID!): Repository + ownerRepository(platform: String!, owner: String!, name: String!): Repository + build(id: ID!): Build + searchBuilds( + repositoryOwner: String! + repositoryName: String! + SHA: String + ): [Build!] + task(id: ID!): Task + hook(id: ID!): Hook + webhookDelivery(id: String!): WebHookDelivery + persistentWorkerPool(poolId: ID): PersistentWorkerPool + persistentWorker(poolId: ID, name: String): PersistentWorker + ownerInfo(platform: String, uid: ID): OwnerInfo + ownerInfoByName(platform: String, name: String): OwnerInfo +} + +type Repository implements Node { + id: ID! + platform: String! + owner: String! + name: String! + cloneUrl: String! + defaultBranch: String! + masterBranch: String! + isPrivate: Boolean! + builds( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + + """ + branch to fetch builds for + """ + branch: String + + """ + fetching only builds with the specified status + """ + status: BuildStatus + ): RepositoryBuildsConnection! + settings: RepositorySettings! + cronSettings: [RepositoryCronSettings!]! + viewerPermission: PermissionType! + lastDefaultBranchBuild: Build + metrics(parameters: MetricsQueryParameters): [MetricsChart!]! + visibleMetadata: [RepositoryMetadata!]! + metadata(key: String): RepositoryMetadata +} + +""" +An edge in a connection +""" +type RepositoryBuildEdge { + """ + The item at the end of the edge + """ + node: Build! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type RepositoryBuildsConnection { + """ + a list of edges + """ + edges: [RepositoryBuildEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +input RepositoryCreateBuildInput { + repositoryId: ID! + branch: String! + sha: String + configOverride: String + clientMutationId: String! +} + +type RepositoryCreateBuildPayload { + build: Build! + clientMutationId: String! +} + +type RepositoryCronSettings { + name: String! + expression: String! + branch: String! + nextInvocationTimestamp: Int! + lastInvocationBuild: Build +} + +input RepositoryDeleteInput { + repositoryId: ID! + clientMutationId: String! +} + +type RepositoryDeletePayload { + deleted: Boolean! + deletedRepository: Repository + clientMutationId: String! +} + +type RepositoryMetadata { + key: String! + value: String! + description: String! + hidden: Boolean! +} + +input RepositoryRemoveCronSettingsInput { + repositoryId: ID! + name: String! + clientMutationId: String! +} + +type RepositoryRemoveCronSettingsPayload { + settings: [RepositoryCronSettings!]! + clientMutationId: String! +} + +input RepositorySaveCronSettingsInput { + repositoryId: ID! + name: String! + expression: String! + branch: String! + clientMutationId: String! +} + +type RepositorySaveCronSettingsPayload { + settings: [RepositoryCronSettings!]! + clientMutationId: String! +} + +input RepositorySecuredVariableInput { + repositoryId: ID! + valueToSecure: String! + clientMutationId: String! +} + +type RepositorySecuredVariablePayload { + variableName: String! + clientMutationId: String! +} + +input RepositorySetMetadataInput { + repositoryId: ID! + key: String! + value: String! + description: String + hidden: Boolean + ttlSeconds: Int + clientMutationId: String! +} + +type RepositorySetMetadataPayload { + clientMutationId: String! +} + +type RepositorySettings { + needsApproval: Boolean! + decryptEnvironmentVariables: DecryptEnvironmentVariablesFor! + configResolutionStrategy: ConfigResolutionStrategy! + additionalEnvironment: [String!]! + cacheVersion: Int! + paused: Boolean! + oidcSubIncludeClaimKeys: [String!]! +} + +input RepositorySettingsInput { + repositoryId: ID! + needsApproval: Boolean! + decryptEnvironmentVariables: DecryptEnvironmentVariablesFor! + configResolutionStrategy: ConfigResolutionStrategy + additionalEnvironment: [String!] + cacheVersion: Int + oidcSubIncludeClaimKeys: [String!] + clientMutationId: String! +} + +type RepositorySettingsPayload { + settings: RepositorySettings! + clientMutationId: String! +} + +input SaveWebHookSettingsInput { + platform: String! + ownerUid: ID! + deliveryEndpoints: [WebHookDeliveryEndpointInput!] + clientMutationId: String! +} + +type SaveWebHookSettingsPayload { + error: String + info: OwnerInfo! + settings: WebHookSettings! + clientMutationId: String! +} + +input SaveWebPushConfigurationInput { + endpoint: String! + p256dhKey: String! + authKey: String! + clientMutationId: String! +} + +type SaveWebPushConfigurationPayload { + clientMutationId: String! +} + +type Subscription { + task(id: ID!): Task + build(id: ID!): Build + repository(id: ID!): Repository +} + +type Task implements Node { + id: ID! + buildId: ID! + repositoryId: ID! + name: String! + nameAlias: String + localGroupId: Int! + requiredGroups: [Int!]! + status: TaskStatus! + notifications: [Notification!]! + commands: [TaskCommand!]! + firstFailedCommand: TaskCommand + artifacts: [Artifacts!]! + commandLogsTail(name: String!): [String!]! + statusTimestamp: Int! + creationTimestamp: Int! + scheduledTimestamp: Int + executingTimestamp: Int + finalStatusTimestamp: Int + durationInSeconds: Int! + labels: [String!]! + uniqueLabels: [String!]! + requiredPRLabels: [String!]! + timeoutInSeconds: Int! + optional: Boolean! + statusDurations: [TaskStatusDuration!]! + repository: Repository! + build: Build! + previousRuns: [Task!]! + allOtherRuns: [Task!]! + dependencies: [Task!]! + automaticReRun: Boolean! + automaticallyReRunnable: Boolean! + experimental: Boolean! + stateful: Boolean! + useComputeCredits: Boolean! + usedComputeCredits: Boolean! + triggerType: TaskTriggerType! + instancePlatform: PlatformType + instanceArchitecture: ArchitectureType! + instanceResources: InstanceResources + executionInfo: ExecutionInfo! + baseEnvironment: [String!]! + hooks: [Hook!]! + reranBy: UserBasicInfo + cancelledBy: UserBasicInfo + terminalCredential: TerminalCredential + transaction: OwnerTransaction +} + +input TaskAbortInput { + taskId: ID! + clientMutationId: String! +} + +type TaskAbortPayload { + abortedTask: Task! + clientMutationId: String! +} + +input TaskBatchAbortInput { + taskIds: [ID!]! + clientMutationId: String! +} + +type TaskBatchAbortPayload { + tasks: [Task!]! + clientMutationId: String! +} + +type TaskCommand { + name: String! + type: TaskCommandType! + status: TaskCommandStatus! + durationInSeconds: Int! + logsTail: [String!]! +} + +""" +Task Command status. +""" +enum TaskCommandStatus { + UNDEFINED + SUCCESS + FAILURE + EXECUTING + SKIPPED + ABORTED +} + +""" +Task Command type. +""" +enum TaskCommandType { + WAIT + EXIT + EXECUTE_SCRIPT + CACHE + UPLOAD_CACHE + CLONE + EXECUTE_BACKGROUND_SCRIPT + FILE + ARTIFACTS + WAIT_FOR_TERMINAL +} + +input TaskReRunInput { + taskId: ID! + attachTerminal: Boolean + clientMutationId: String! +} + +type TaskReRunPayload { + newTask: Task! + clientMutationId: String! +} + +input TasksReRunInput { + taskIds: [ID!] + attachTerminal: Boolean + clientMutationId: String! +} + +type TasksReRunPayload { + newTasks: [Task!]! + clientMutationId: String! +} + +""" +Task status. +""" +enum TaskStatus { + CREATED + TRIGGERED + SCHEDULED + EXECUTING + ABORTED + FAILED + COMPLETED + SKIPPED + PAUSED +} + +type TaskStatusDuration { + status: TaskStatus! + durationInSeconds: Int! +} + +input TaskTriggerInput { + taskId: ID! + clientMutationId: String! +} + +type TaskTriggerPayload { + task: Task! + clientMutationId: String! +} + +""" +Task trigger type. +""" +enum TaskTriggerType { + AUTOMATIC + MANUAL +} + +type TerminalCredential { + locator: String! + trustedSecret: String! +} + +type TimePoint { + date: DayDate! + value: Float! +} + +input UpdateOwnerSecuredVariableInput { + platform: String! + ownerUid: ID! + name: String! + updatedValueToSecure: String! + clientMutationId: String! +} + +type UpdateOwnerSecuredVariablePayload { + variableName: String! + clientMutationId: String! +} + +input UpdatePersistentWorkerInput { + poolId: String! + name: String! + disabled: Boolean! + clientMutationId: String! +} + +type UpdatePersistentWorkerPayload { + worker: PersistentWorker! + clientMutationId: String! +} + +input UpdatePersistentWorkerPoolInput { + poolId: String! + name: String! + enabledForPublic: Boolean! + clientMutationId: String! +} + +type UpdatePersistentWorkerPoolPayload { + pool: PersistentWorkerPool! + clientMutationId: String! +} + +type User implements Node & UserBasicInfo { + id: ID! + category: User! + avatarURL: String! + builds( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + + """ + fetching only builds with the specified statuses + """ + statuses: [BuildStatus!] + ): UserBuildsConnection! + topActiveRepositories: [Repository!]! + balanceInCredits: String! + apiToken: ApiAccessToken + webPushServerKey: String! + persistentWorkerPools: [PersistentWorkerPool!]! + relatedOwners: [OwnerInfo!]! + transactions( + """ + fetching only nodes before this node (exclusive) + """ + before: String + + """ + fetching only nodes after this node (exclusive) + """ + after: String + + """ + fetching only the first certain number of nodes + """ + first: Int + + """ + fetching only the last certain number of nodes + """ + last: Int + ): UserTransactionsConnection! +} + +interface UserBasicInfo { + id: ID! + category: User! + avatarURL: String +} + +""" +An edge in a connection +""" +type UserBuildEdge { + """ + The item at the end of the edge + """ + node: Build! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type UserBuildsConnection { + """ + a list of edges + """ + edges: [UserBuildEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +""" +An edge in a connection +""" +type UserTransactionEdge { + """ + The item at the end of the edge + """ + node: OwnerTransaction! + + """ + cursor marks a unique position or index into the connection + """ + cursor: String! +} + +""" +A connection to a list of items. +""" +type UserTransactionsConnection { + """ + a list of edges + """ + edges: [UserTransactionEdge!]! + + """ + details about this specific page + """ + pageInfo: PageInfo! +} + +type WebHookDelivery implements Node { + id: ID! + platform: String! + ownerUid: String! + repositoryId: Int! + timestamp: Int! + payload: WebHookDeliveryPayload! + response: WebHookDeliveryResponse! +} + +type WebHookDeliveryEndpoint { + webhookURL: String! + maskedSecretToken: String +} + +input WebHookDeliveryEndpointInput { + webhookURL: String! + secretToken: String +} + +type WebHookDeliveryPayload { + event: String! + action: String! + data: String! +} + +type WebHookDeliveryResponse { + status: Int! + duration: Int! + data: String! +} + +type WebHookSettings { + ownerUid: ID! + endpoints: [WebHookDeliveryEndpoint!]! +} diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..166c183 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Do not use this script manually, Use makefile + +go run github.com/Khan/genqlient genqlient.yaml + +