forked from sensu/sensu-go
/
mutator.gql.go
421 lines (390 loc) · 13.9 KB
/
mutator.gql.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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
// Code generated by scripts/gengraphql.go. DO NOT EDIT.
package schema
import (
errors "errors"
graphql1 "github.com/graphql-go/graphql"
graphql "github.com/sensu/sensu-go/graphql"
)
// MutatorIDFieldResolver implement to resolve requests for the Mutator's id field.
type MutatorIDFieldResolver interface {
// ID implements response to request for id field.
ID(p graphql.ResolveParams) (string, error)
}
// MutatorNamespaceFieldResolver implement to resolve requests for the Mutator's namespace field.
type MutatorNamespaceFieldResolver interface {
// Namespace implements response to request for namespace field.
Namespace(p graphql.ResolveParams) (string, error)
}
// MutatorNameFieldResolver implement to resolve requests for the Mutator's name field.
type MutatorNameFieldResolver interface {
// Name implements response to request for name field.
Name(p graphql.ResolveParams) (string, error)
}
// MutatorMetadataFieldResolver implement to resolve requests for the Mutator's metadata field.
type MutatorMetadataFieldResolver interface {
// Metadata implements response to request for metadata field.
Metadata(p graphql.ResolveParams) (interface{}, error)
}
// MutatorCommandFieldResolver implement to resolve requests for the Mutator's command field.
type MutatorCommandFieldResolver interface {
// Command implements response to request for command field.
Command(p graphql.ResolveParams) (string, error)
}
// MutatorTimeoutFieldResolver implement to resolve requests for the Mutator's timeout field.
type MutatorTimeoutFieldResolver interface {
// Timeout implements response to request for timeout field.
Timeout(p graphql.ResolveParams) (int, error)
}
// MutatorEnvVarsFieldResolver implement to resolve requests for the Mutator's envVars field.
type MutatorEnvVarsFieldResolver interface {
// EnvVars implements response to request for envVars field.
EnvVars(p graphql.ResolveParams) ([]string, error)
}
// MutatorToJSONFieldResolver implement to resolve requests for the Mutator's toJSON field.
type MutatorToJSONFieldResolver interface {
// ToJSON implements response to request for toJSON field.
ToJSON(p graphql.ResolveParams) (interface{}, error)
}
//
// MutatorFieldResolvers represents a collection of methods whose products represent the
// response values of the 'Mutator' type.
//
// == Example SDL
//
// """
// Dog's are not hooman.
// """
// type Dog implements Pet {
// "name of this fine beast."
// name: String!
//
// "breed of this silly animal; probably shibe."
// breed: [Breed]
// }
//
// == Example generated interface
//
// // DogResolver ...
// type DogFieldResolvers interface {
// DogNameFieldResolver
// DogBreedFieldResolver
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// IsTypeOf(interface{}, graphql.IsTypeOfParams) bool
// }
//
// == Example implementation ...
//
// // DogResolver implements DogFieldResolvers interface
// type DogResolver struct {
// logger logrus.LogEntry
// store interface{
// store.BreedStore
// store.DogStore
// }
// }
//
// // Name implements response to request for name field.
// func (r *DogResolver) Name(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// return dog.GetName()
// }
//
// // Breed implements response to request for breed field.
// func (r *DogResolver) Breed(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// breed := r.store.GetBreed(dog.GetBreedName())
// return breed
// }
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// func (r *DogResolver) IsTypeOf(p graphql.IsTypeOfParams) bool {
// // ... implementation details ...
// _, ok := p.Value.(DogGetter)
// return ok
// }
//
type MutatorFieldResolvers interface {
MutatorIDFieldResolver
MutatorNamespaceFieldResolver
MutatorNameFieldResolver
MutatorMetadataFieldResolver
MutatorCommandFieldResolver
MutatorTimeoutFieldResolver
MutatorEnvVarsFieldResolver
MutatorToJSONFieldResolver
}
// MutatorAliases implements all methods on MutatorFieldResolvers interface by using reflection to
// match name of field to a field on the given value. Intent is reduce friction
// of writing new resolvers by removing all the instances where you would simply
// have the resolvers method return a field.
//
// == Example SDL
//
// type Dog {
// name: String!
// weight: Float!
// dob: DateTime
// breed: [Breed]
// }
//
// == Example generated aliases
//
// type DogAliases struct {}
// func (_ DogAliases) Name(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Weight(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Dob(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Breed(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
//
// == Example Implementation
//
// type DogResolver struct { // Implements DogResolver
// DogAliases
// store store.BreedStore
// }
//
// // NOTE:
// // All other fields are satisified by DogAliases but since this one
// // requires hitting the store we implement it in our resolver.
// func (r *DogResolver) Breed(p graphql.ResolveParams) interface{} {
// dog := v.(*Dog)
// return r.BreedsById(dog.BreedIDs)
// }
//
type MutatorAliases struct{}
// ID implements response to request for 'id' field.
func (_ MutatorAliases) ID(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'id'")
}
return ret, err
}
// Namespace implements response to request for 'namespace' field.
func (_ MutatorAliases) Namespace(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'namespace'")
}
return ret, err
}
// Name implements response to request for 'name' field.
func (_ MutatorAliases) Name(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'name'")
}
return ret, err
}
// Metadata implements response to request for 'metadata' field.
func (_ MutatorAliases) Metadata(p graphql.ResolveParams) (interface{}, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
return val, err
}
// Command implements response to request for 'command' field.
func (_ MutatorAliases) Command(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'command'")
}
return ret, err
}
// Timeout implements response to request for 'timeout' field.
func (_ MutatorAliases) Timeout(p graphql.ResolveParams) (int, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := graphql1.Int.ParseValue(val).(int)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'timeout'")
}
return ret, err
}
// EnvVars implements response to request for 'envVars' field.
func (_ MutatorAliases) EnvVars(p graphql.ResolveParams) ([]string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.([]string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'envVars'")
}
return ret, err
}
// ToJSON implements response to request for 'toJSON' field.
func (_ MutatorAliases) ToJSON(p graphql.ResolveParams) (interface{}, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
return val, err
}
// MutatorType A Mutator is a mutator specification.
var MutatorType = graphql.NewType("Mutator", graphql.ObjectKind)
// RegisterMutator registers Mutator object type with given service.
func RegisterMutator(svc *graphql.Service, impl MutatorFieldResolvers) {
svc.RegisterObject(_ObjectTypeMutatorDesc, impl)
}
func _ObjTypeMutatorIDHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorIDFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.ID(frp)
}
}
func _ObjTypeMutatorNamespaceHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorNamespaceFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Namespace(frp)
}
}
func _ObjTypeMutatorNameHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorNameFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Name(frp)
}
}
func _ObjTypeMutatorMetadataHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorMetadataFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Metadata(frp)
}
}
func _ObjTypeMutatorCommandHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorCommandFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Command(frp)
}
}
func _ObjTypeMutatorTimeoutHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorTimeoutFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Timeout(frp)
}
}
func _ObjTypeMutatorEnvVarsHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorEnvVarsFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.EnvVars(frp)
}
}
func _ObjTypeMutatorToJSONHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(MutatorToJSONFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.ToJSON(frp)
}
}
func _ObjectTypeMutatorConfigFn() graphql1.ObjectConfig {
return graphql1.ObjectConfig{
Description: "A Mutator is a mutator specification.",
Fields: graphql1.Fields{
"command": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Command is the command to be executed.",
Name: "command",
Type: graphql1.NewNonNull(graphql1.String),
},
"envVars": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Env is a list of environment variables to use with command execution",
Name: "envVars",
Type: graphql1.NewList(graphql1.NewNonNull(graphql1.String)),
},
"id": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "The globally unique identifier of the record",
Name: "id",
Type: graphql1.NewNonNull(graphql1.ID),
},
"metadata": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "metadata contains name, namespace, labels and annotations of the record",
Name: "metadata",
Type: graphql1.NewNonNull(graphql.OutputType("ObjectMeta")),
},
"name": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Name is the unique identifier for a mutator.",
Name: "name",
Type: graphql1.NewNonNull(graphql1.String),
},
"namespace": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Namespace in which this record resides",
Name: "namespace",
Type: graphql1.NewNonNull(graphql1.String),
},
"timeout": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Timeout is the command execution timeout in seconds.",
Name: "timeout",
Type: graphql1.Int,
},
"toJSON": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "toJSON returns a REST API compatible representation of the resource. Handy for\nsharing snippets that can then be imported with `sensuctl create`.",
Name: "toJSON",
Type: graphql1.NewNonNull(graphql.OutputType("JSON")),
},
},
Interfaces: []*graphql1.Interface{
graphql.Interface("Node"),
graphql.Interface("Namespaced"),
graphql.Interface("Resource")},
IsTypeOf: func(_ graphql1.IsTypeOfParams) bool {
// NOTE:
// Panic by default. Intent is that when Service is invoked, values of
// these fields are updated with instantiated resolvers. If these
// defaults are called it is most certainly programmer err.
// If you're see this comment then: 'Whoops! Sorry, my bad.'
panic("Unimplemented; see MutatorFieldResolvers.")
},
Name: "Mutator",
}
}
// describe Mutator's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _ObjectTypeMutatorDesc = graphql.ObjectDesc{
Config: _ObjectTypeMutatorConfigFn,
FieldHandlers: map[string]graphql.FieldHandler{
"command": _ObjTypeMutatorCommandHandler,
"envVars": _ObjTypeMutatorEnvVarsHandler,
"id": _ObjTypeMutatorIDHandler,
"metadata": _ObjTypeMutatorMetadataHandler,
"name": _ObjTypeMutatorNameHandler,
"namespace": _ObjTypeMutatorNamespaceHandler,
"timeout": _ObjTypeMutatorTimeoutHandler,
"toJSON": _ObjTypeMutatorToJSONHandler,
},
}