-
Notifications
You must be signed in to change notification settings - Fork 0
/
generated.go
390 lines (325 loc) · 17.4 KB
/
generated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
package cirrus
import (
"context"
"encoding/json"
"fmt"
"github.com/Khan/genqlient/graphql"
)
// Build status.
type BuildStatus string
const (
BuildStatusCreated BuildStatus = "CREATED"
BuildStatusNeedsApproval BuildStatus = "NEEDS_APPROVAL"
BuildStatusTriggered BuildStatus = "TRIGGERED"
BuildStatusExecuting BuildStatus = "EXECUTING"
BuildStatusFailed BuildStatus = "FAILED"
BuildStatusCompleted BuildStatus = "COMPLETED"
BuildStatusAborted BuildStatus = "ABORTED"
BuildStatusErrored BuildStatus = "ERRORED"
)
// __getRepositoryBranchStatusInput is used internally by genqlient
type __getRepositoryBranchStatusInput struct {
Platform string `json:"Platform"`
Owner string `json:"Owner"`
RepositoryName string `json:"RepositoryName"`
Branch string `json:"Branch"`
}
// GetPlatform returns __getRepositoryBranchStatusInput.Platform, and is useful for accessing the field via an interface.
func (v *__getRepositoryBranchStatusInput) GetPlatform() string { return v.Platform }
// GetOwner returns __getRepositoryBranchStatusInput.Owner, and is useful for accessing the field via an interface.
func (v *__getRepositoryBranchStatusInput) GetOwner() string { return v.Owner }
// GetRepositoryName returns __getRepositoryBranchStatusInput.RepositoryName, and is useful for accessing the field via an interface.
func (v *__getRepositoryBranchStatusInput) GetRepositoryName() string { return v.RepositoryName }
// GetBranch returns __getRepositoryBranchStatusInput.Branch, and is useful for accessing the field via an interface.
func (v *__getRepositoryBranchStatusInput) GetBranch() string { return v.Branch }
// getRepositoryBranchStatusOwnerRepository includes the requested fields of the GraphQL type Repository.
type getRepositoryBranchStatusOwnerRepository struct {
Id string `json:"id"`
Builds getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnection `json:"builds"`
}
// GetId returns getRepositoryBranchStatusOwnerRepository.Id, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepository) GetId() string { return v.Id }
// GetBuilds returns getRepositoryBranchStatusOwnerRepository.Builds, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepository) GetBuilds() getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnection {
return v.Builds
}
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnection includes the requested fields of the GraphQL type RepositoryBuildsConnection.
// The GraphQL type's documentation follows.
//
// A connection to a list of items.
type getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnection struct {
// a list of edges
Edges []getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdge `json:"edges"`
}
// GetEdges returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnection.Edges, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnection) GetEdges() []getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdge {
return v.Edges
}
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdge includes the requested fields of the GraphQL type RepositoryBuildEdge.
// The GraphQL type's documentation follows.
//
// An edge in a connection
type getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdge struct {
// The item at the end of the edge
Node getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild `json:"node"`
}
// GetNode returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdge.Node, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdge) GetNode() getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild {
return v.Node
}
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild includes the requested fields of the GraphQL type Build.
type getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild struct {
Status BuildStatus `json:"status"`
BuildCreatedTimestamp int `json:"buildCreatedTimestamp"`
ChangeMessage string `json:"changeMessage"`
DurationInSeconds int `json:"durationInSeconds"`
Initializer getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo `json:"-"`
}
// GetStatus returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.Status, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) GetStatus() BuildStatus {
return v.Status
}
// GetBuildCreatedTimestamp returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.BuildCreatedTimestamp, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) GetBuildCreatedTimestamp() int {
return v.BuildCreatedTimestamp
}
// GetChangeMessage returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.ChangeMessage, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) GetChangeMessage() string {
return v.ChangeMessage
}
// GetDurationInSeconds returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.DurationInSeconds, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) GetDurationInSeconds() int {
return v.DurationInSeconds
}
// GetInitializer returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.Initializer, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) GetInitializer() getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo {
return v.Initializer
}
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild
Initializer json.RawMessage `json:"initializer"`
graphql.NoUnmarshalJSON
}
firstPass.getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Initializer
src := firstPass.Initializer
if len(src) != 0 && string(src) != "null" {
err = __unmarshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo(
src, dst)
if err != nil {
return fmt.Errorf(
"unable to unmarshal getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.Initializer: %w", err)
}
}
}
return nil
}
type __premarshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild struct {
Status BuildStatus `json:"status"`
BuildCreatedTimestamp int `json:"buildCreatedTimestamp"`
ChangeMessage string `json:"changeMessage"`
DurationInSeconds int `json:"durationInSeconds"`
Initializer json.RawMessage `json:"initializer"`
}
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild) __premarshalJSON() (*__premarshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild, error) {
var retval __premarshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild
retval.Status = v.Status
retval.BuildCreatedTimestamp = v.BuildCreatedTimestamp
retval.ChangeMessage = v.ChangeMessage
retval.DurationInSeconds = v.DurationInSeconds
{
dst := &retval.Initializer
src := v.Initializer
var err error
*dst, err = __marshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo(
&src)
if err != nil {
return nil, fmt.Errorf(
"unable to marshal getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuild.Initializer: %w", err)
}
}
return &retval, nil
}
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser includes the requested fields of the GraphQL type User.
type getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser struct {
Typename string `json:"__typename"`
AvatarURL string `json:"avatarURL"`
}
// GetTypename returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser.Typename, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser) GetTypename() string {
return v.Typename
}
// GetAvatarURL returns getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser.AvatarURL, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser) GetAvatarURL() string {
return v.AvatarURL
}
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo includes the requested fields of the GraphQL interface UserBasicInfo.
//
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo is implemented by the following types:
// getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser
type getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo interface {
implementsGraphQLInterfacegetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo()
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
GetTypename() string
// GetAvatarURL returns the interface-field "avatarURL" from its implementation.
GetAvatarURL() string
}
func (v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser) implementsGraphQLInterfacegetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo() {
}
func __unmarshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo(b []byte, v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"response was missing UserBasicInfo.__typename")
default:
return fmt.Errorf(
`unexpected concrete type for getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo: "%v"`, tn.TypeName)
}
}
func __marshalgetRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo(v *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser:
typename = "User"
result := struct {
TypeName string `json:"__typename"`
*getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUser
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`unexpected concrete type for getRepositoryBranchStatusOwnerRepositoryBuildsRepositoryBuildsConnectionEdgesRepositoryBuildEdgeNodeBuildInitializerUserBasicInfo: "%T"`, v)
}
}
// getRepositoryBranchStatusResponse is returned by getRepositoryBranchStatus on success.
type getRepositoryBranchStatusResponse struct {
OwnerRepository getRepositoryBranchStatusOwnerRepository `json:"ownerRepository"`
}
// GetOwnerRepository returns getRepositoryBranchStatusResponse.OwnerRepository, and is useful for accessing the field via an interface.
func (v *getRepositoryBranchStatusResponse) GetOwnerRepository() getRepositoryBranchStatusOwnerRepository {
return v.OwnerRepository
}
// 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"`
AvatarURL string `json:"avatarURL"`
}
// GetId returns getViewerViewerUser.Id, and is useful for accessing the field via an interface.
func (v *getViewerViewerUser) GetId() string { return v.Id }
// GetAvatarURL returns getViewerViewerUser.AvatarURL, and is useful for accessing the field via an interface.
func (v *getViewerViewerUser) GetAvatarURL() string { return v.AvatarURL }
// The query or mutation executed by getRepositoryBranchStatus.
const getRepositoryBranchStatus_Operation = `
query getRepositoryBranchStatus ($Platform: String!, $Owner: String!, $RepositoryName: String!, $Branch: String!) {
ownerRepository(platform: $Platform, owner: $Owner, name: $RepositoryName) {
id
builds(branch: $Branch, last: 1) {
edges {
node {
status
buildCreatedTimestamp
changeMessage
durationInSeconds
initializer {
__typename
avatarURL
}
}
}
}
}
}
`
func getRepositoryBranchStatus(
ctx context.Context,
client graphql.Client,
Platform string,
Owner string,
RepositoryName string,
Branch string,
) (*getRepositoryBranchStatusResponse, error) {
req := &graphql.Request{
OpName: "getRepositoryBranchStatus",
Query: getRepositoryBranchStatus_Operation,
Variables: &__getRepositoryBranchStatusInput{
Platform: Platform,
Owner: Owner,
RepositoryName: RepositoryName,
Branch: Branch,
},
}
var err error
var data getRepositoryBranchStatusResponse
resp := &graphql.Response{Data: &data}
err = client.MakeRequest(
ctx,
req,
resp,
)
return &data, err
}
// The query or mutation executed by getViewer.
const getViewer_Operation = `
query getViewer {
viewer {
id
avatarURL
}
}
`
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
}