/
googlenow.go
629 lines (548 loc) · 17.8 KB
/
googlenow.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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
// Code generated by thriftrw v1.23.0. DO NOT EDIT.
// @generated
package googlenow
import (
errors "errors"
fmt "fmt"
strings "strings"
wire "go.uber.org/thriftrw/wire"
zapcore "go.uber.org/zap/zapcore"
)
// GoogleNow_AddCredentials_Args represents the arguments for the GoogleNow.addCredentials function.
//
// The arguments for addCredentials are sent and received over the wire as this struct.
type GoogleNow_AddCredentials_Args struct {
AuthCode string `json:"authCode,required"`
}
// ToWire translates a GoogleNow_AddCredentials_Args struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := v.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (v *GoogleNow_AddCredentials_Args) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
w, err = wire.NewValueString(v.AuthCode), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a GoogleNow_AddCredentials_Args struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a GoogleNow_AddCredentials_Args struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v GoogleNow_AddCredentials_Args
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *GoogleNow_AddCredentials_Args) FromWire(w wire.Value) error {
var err error
authCodeIsSet := false
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TBinary {
v.AuthCode, err = field.Value.GetString(), error(nil)
if err != nil {
return err
}
authCodeIsSet = true
}
}
}
if !authCodeIsSet {
return errors.New("field AuthCode of GoogleNow_AddCredentials_Args is required")
}
return nil
}
// String returns a readable string representation of a GoogleNow_AddCredentials_Args
// struct.
func (v *GoogleNow_AddCredentials_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
fields[i] = fmt.Sprintf("AuthCode: %v", v.AuthCode)
i++
return fmt.Sprintf("GoogleNow_AddCredentials_Args{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this GoogleNow_AddCredentials_Args match the
// provided GoogleNow_AddCredentials_Args.
//
// This function performs a deep comparison.
func (v *GoogleNow_AddCredentials_Args) Equals(rhs *GoogleNow_AddCredentials_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.AuthCode == rhs.AuthCode) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of GoogleNow_AddCredentials_Args.
func (v *GoogleNow_AddCredentials_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("authCode", v.AuthCode)
return err
}
// GetAuthCode returns the value of AuthCode if it is set or its
// zero value if it is unset.
func (v *GoogleNow_AddCredentials_Args) GetAuthCode() (o string) {
if v != nil {
o = v.AuthCode
}
return
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the arguments.
//
// This will always be "addCredentials" for this struct.
func (v *GoogleNow_AddCredentials_Args) MethodName() string {
return "addCredentials"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be Call for this struct.
func (v *GoogleNow_AddCredentials_Args) EnvelopeType() wire.EnvelopeType {
return wire.Call
}
// GoogleNow_AddCredentials_Helper provides functions that aid in handling the
// parameters and return values of the GoogleNow.addCredentials
// function.
var GoogleNow_AddCredentials_Helper = struct {
// Args accepts the parameters of addCredentials in-order and returns
// the arguments struct for the function.
Args func(
authCode string,
) *GoogleNow_AddCredentials_Args
// IsException returns true if the given error can be thrown
// by addCredentials.
//
// An error can be thrown by addCredentials only if the
// corresponding exception type was mentioned in the 'throws'
// section for it in the Thrift file.
IsException func(error) bool
// WrapResponse returns the result struct for addCredentials
// given the error returned by it. The provided error may
// be nil if addCredentials did not fail.
//
// This allows mapping errors returned by addCredentials into a
// serializable result struct. WrapResponse returns a
// non-nil error if the provided error cannot be thrown by
// addCredentials
//
// err := addCredentials(args)
// result, err := GoogleNow_AddCredentials_Helper.WrapResponse(err)
// if err != nil {
// return fmt.Errorf("unexpected error from addCredentials: %v", err)
// }
// serialize(result)
WrapResponse func(error) (*GoogleNow_AddCredentials_Result, error)
// UnwrapResponse takes the result struct for addCredentials
// and returns the erorr returned by it (if any).
//
// The error is non-nil only if addCredentials threw an
// exception.
//
// result := deserialize(bytes)
// err := GoogleNow_AddCredentials_Helper.UnwrapResponse(result)
UnwrapResponse func(*GoogleNow_AddCredentials_Result) error
}{}
func init() {
GoogleNow_AddCredentials_Helper.Args = func(
authCode string,
) *GoogleNow_AddCredentials_Args {
return &GoogleNow_AddCredentials_Args{
AuthCode: authCode,
}
}
GoogleNow_AddCredentials_Helper.IsException = func(err error) bool {
switch err.(type) {
default:
return false
}
}
GoogleNow_AddCredentials_Helper.WrapResponse = func(err error) (*GoogleNow_AddCredentials_Result, error) {
if err == nil {
return &GoogleNow_AddCredentials_Result{}, nil
}
return nil, err
}
GoogleNow_AddCredentials_Helper.UnwrapResponse = func(result *GoogleNow_AddCredentials_Result) (err error) {
return
}
}
// GoogleNow_AddCredentials_Result represents the result of a GoogleNow.addCredentials function call.
//
// The result of a addCredentials execution is sent and received over the wire as this struct.
type GoogleNow_AddCredentials_Result struct {
}
// ToWire translates a GoogleNow_AddCredentials_Result struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := v.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (v *GoogleNow_AddCredentials_Result) ToWire() (wire.Value, error) {
var (
fields [0]wire.Field
i int = 0
)
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a GoogleNow_AddCredentials_Result struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a GoogleNow_AddCredentials_Result struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v GoogleNow_AddCredentials_Result
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *GoogleNow_AddCredentials_Result) FromWire(w wire.Value) error {
for _, field := range w.GetStruct().Fields {
switch field.ID {
}
}
return nil
}
// String returns a readable string representation of a GoogleNow_AddCredentials_Result
// struct.
func (v *GoogleNow_AddCredentials_Result) String() string {
if v == nil {
return "<nil>"
}
var fields [0]string
i := 0
return fmt.Sprintf("GoogleNow_AddCredentials_Result{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this GoogleNow_AddCredentials_Result match the
// provided GoogleNow_AddCredentials_Result.
//
// This function performs a deep comparison.
func (v *GoogleNow_AddCredentials_Result) Equals(rhs *GoogleNow_AddCredentials_Result) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of GoogleNow_AddCredentials_Result.
func (v *GoogleNow_AddCredentials_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
return err
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the result.
//
// This will always be "addCredentials" for this struct.
func (v *GoogleNow_AddCredentials_Result) MethodName() string {
return "addCredentials"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be Reply for this struct.
func (v *GoogleNow_AddCredentials_Result) EnvelopeType() wire.EnvelopeType {
return wire.Reply
}
// GoogleNow_CheckCredentials_Args represents the arguments for the GoogleNow.checkCredentials function.
//
// The arguments for checkCredentials are sent and received over the wire as this struct.
type GoogleNow_CheckCredentials_Args struct {
}
// ToWire translates a GoogleNow_CheckCredentials_Args struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := v.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (v *GoogleNow_CheckCredentials_Args) ToWire() (wire.Value, error) {
var (
fields [0]wire.Field
i int = 0
)
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a GoogleNow_CheckCredentials_Args struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a GoogleNow_CheckCredentials_Args struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v GoogleNow_CheckCredentials_Args
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *GoogleNow_CheckCredentials_Args) FromWire(w wire.Value) error {
for _, field := range w.GetStruct().Fields {
switch field.ID {
}
}
return nil
}
// String returns a readable string representation of a GoogleNow_CheckCredentials_Args
// struct.
func (v *GoogleNow_CheckCredentials_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [0]string
i := 0
return fmt.Sprintf("GoogleNow_CheckCredentials_Args{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this GoogleNow_CheckCredentials_Args match the
// provided GoogleNow_CheckCredentials_Args.
//
// This function performs a deep comparison.
func (v *GoogleNow_CheckCredentials_Args) Equals(rhs *GoogleNow_CheckCredentials_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of GoogleNow_CheckCredentials_Args.
func (v *GoogleNow_CheckCredentials_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
return err
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the arguments.
//
// This will always be "checkCredentials" for this struct.
func (v *GoogleNow_CheckCredentials_Args) MethodName() string {
return "checkCredentials"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be Call for this struct.
func (v *GoogleNow_CheckCredentials_Args) EnvelopeType() wire.EnvelopeType {
return wire.Call
}
// GoogleNow_CheckCredentials_Helper provides functions that aid in handling the
// parameters and return values of the GoogleNow.checkCredentials
// function.
var GoogleNow_CheckCredentials_Helper = struct {
// Args accepts the parameters of checkCredentials in-order and returns
// the arguments struct for the function.
Args func() *GoogleNow_CheckCredentials_Args
// IsException returns true if the given error can be thrown
// by checkCredentials.
//
// An error can be thrown by checkCredentials only if the
// corresponding exception type was mentioned in the 'throws'
// section for it in the Thrift file.
IsException func(error) bool
// WrapResponse returns the result struct for checkCredentials
// given the error returned by it. The provided error may
// be nil if checkCredentials did not fail.
//
// This allows mapping errors returned by checkCredentials into a
// serializable result struct. WrapResponse returns a
// non-nil error if the provided error cannot be thrown by
// checkCredentials
//
// err := checkCredentials(args)
// result, err := GoogleNow_CheckCredentials_Helper.WrapResponse(err)
// if err != nil {
// return fmt.Errorf("unexpected error from checkCredentials: %v", err)
// }
// serialize(result)
WrapResponse func(error) (*GoogleNow_CheckCredentials_Result, error)
// UnwrapResponse takes the result struct for checkCredentials
// and returns the erorr returned by it (if any).
//
// The error is non-nil only if checkCredentials threw an
// exception.
//
// result := deserialize(bytes)
// err := GoogleNow_CheckCredentials_Helper.UnwrapResponse(result)
UnwrapResponse func(*GoogleNow_CheckCredentials_Result) error
}{}
func init() {
GoogleNow_CheckCredentials_Helper.Args = func() *GoogleNow_CheckCredentials_Args {
return &GoogleNow_CheckCredentials_Args{}
}
GoogleNow_CheckCredentials_Helper.IsException = func(err error) bool {
switch err.(type) {
default:
return false
}
}
GoogleNow_CheckCredentials_Helper.WrapResponse = func(err error) (*GoogleNow_CheckCredentials_Result, error) {
if err == nil {
return &GoogleNow_CheckCredentials_Result{}, nil
}
return nil, err
}
GoogleNow_CheckCredentials_Helper.UnwrapResponse = func(result *GoogleNow_CheckCredentials_Result) (err error) {
return
}
}
// GoogleNow_CheckCredentials_Result represents the result of a GoogleNow.checkCredentials function call.
//
// The result of a checkCredentials execution is sent and received over the wire as this struct.
type GoogleNow_CheckCredentials_Result struct {
}
// ToWire translates a GoogleNow_CheckCredentials_Result struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := v.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (v *GoogleNow_CheckCredentials_Result) ToWire() (wire.Value, error) {
var (
fields [0]wire.Field
i int = 0
)
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a GoogleNow_CheckCredentials_Result struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a GoogleNow_CheckCredentials_Result struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v GoogleNow_CheckCredentials_Result
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *GoogleNow_CheckCredentials_Result) FromWire(w wire.Value) error {
for _, field := range w.GetStruct().Fields {
switch field.ID {
}
}
return nil
}
// String returns a readable string representation of a GoogleNow_CheckCredentials_Result
// struct.
func (v *GoogleNow_CheckCredentials_Result) String() string {
if v == nil {
return "<nil>"
}
var fields [0]string
i := 0
return fmt.Sprintf("GoogleNow_CheckCredentials_Result{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this GoogleNow_CheckCredentials_Result match the
// provided GoogleNow_CheckCredentials_Result.
//
// This function performs a deep comparison.
func (v *GoogleNow_CheckCredentials_Result) Equals(rhs *GoogleNow_CheckCredentials_Result) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of GoogleNow_CheckCredentials_Result.
func (v *GoogleNow_CheckCredentials_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
return err
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the result.
//
// This will always be "checkCredentials" for this struct.
func (v *GoogleNow_CheckCredentials_Result) MethodName() string {
return "checkCredentials"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be Reply for this struct.
func (v *GoogleNow_CheckCredentials_Result) EnvelopeType() wire.EnvelopeType {
return wire.Reply
}