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 package runtimeconfig
57
58 import (
59 "bytes"
60 "context"
61 "encoding/json"
62 "errors"
63 "fmt"
64 "io"
65 "net/http"
66 "net/url"
67 "strconv"
68 "strings"
69
70 googleapi "google.golang.org/api/googleapi"
71 internal "google.golang.org/api/internal"
72 gensupport "google.golang.org/api/internal/gensupport"
73 option "google.golang.org/api/option"
74 internaloption "google.golang.org/api/option/internaloption"
75 htransport "google.golang.org/api/transport/http"
76 )
77
78
79
80 var _ = bytes.NewBuffer
81 var _ = strconv.Itoa
82 var _ = fmt.Sprintf
83 var _ = json.NewDecoder
84 var _ = io.Copy
85 var _ = url.Parse
86 var _ = gensupport.MarshalJSON
87 var _ = googleapi.Version
88 var _ = errors.New
89 var _ = strings.Replace
90 var _ = context.Canceled
91 var _ = internaloption.WithDefaultEndpoint
92 var _ = internal.Version
93
94 const apiId = "runtimeconfig:v1"
95 const apiName = "runtimeconfig"
96 const apiVersion = "v1"
97 const basePath = "https://runtimeconfig.googleapis.com/"
98 const basePathTemplate = "https://runtimeconfig.UNIVERSE_DOMAIN/"
99 const mtlsBasePath = "https://runtimeconfig.mtls.googleapis.com/"
100
101
102 const (
103
104
105 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
106
107
108 CloudruntimeconfigScope = "https://www.googleapis.com/auth/cloudruntimeconfig"
109 )
110
111
112 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
113 scopesOption := internaloption.WithDefaultScopes(
114 "https://www.googleapis.com/auth/cloud-platform",
115 "https://www.googleapis.com/auth/cloudruntimeconfig",
116 )
117
118 opts = append([]option.ClientOption{scopesOption}, opts...)
119 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
120 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
121 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
122 opts = append(opts, internaloption.EnableNewAuthLibrary())
123 client, endpoint, err := htransport.NewClient(ctx, opts...)
124 if err != nil {
125 return nil, err
126 }
127 s, err := New(client)
128 if err != nil {
129 return nil, err
130 }
131 if endpoint != "" {
132 s.BasePath = endpoint
133 }
134 return s, nil
135 }
136
137
138
139
140
141
142 func New(client *http.Client) (*Service, error) {
143 if client == nil {
144 return nil, errors.New("client is nil")
145 }
146 s := &Service{client: client, BasePath: basePath}
147 s.Operations = NewOperationsService(s)
148 return s, nil
149 }
150
151 type Service struct {
152 client *http.Client
153 BasePath string
154 UserAgent string
155
156 Operations *OperationsService
157 }
158
159 func (s *Service) userAgent() string {
160 if s.UserAgent == "" {
161 return googleapi.UserAgent
162 }
163 return googleapi.UserAgent + " " + s.UserAgent
164 }
165
166 func NewOperationsService(s *Service) *OperationsService {
167 rs := &OperationsService{s: s}
168 return rs
169 }
170
171 type OperationsService struct {
172 s *Service
173 }
174
175
176 type CancelOperationRequest struct {
177 }
178
179
180
181
182
183 type Empty struct {
184
185 googleapi.ServerResponse `json:"-"`
186 }
187
188
189 type ListOperationsResponse struct {
190
191 NextPageToken string `json:"nextPageToken,omitempty"`
192
193
194 Operations []*Operation `json:"operations,omitempty"`
195
196
197 googleapi.ServerResponse `json:"-"`
198
199
200
201
202
203 ForceSendFields []string `json:"-"`
204
205
206
207
208 NullFields []string `json:"-"`
209 }
210
211 func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
212 type NoMethod ListOperationsResponse
213 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
214 }
215
216
217
218 type Operation struct {
219
220
221
222 Done bool `json:"done,omitempty"`
223
224 Error *Status `json:"error,omitempty"`
225
226
227
228
229 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
230
231
232
233 Name string `json:"name,omitempty"`
234
235
236
237
238
239
240
241 Response googleapi.RawMessage `json:"response,omitempty"`
242
243
244
245
246
247 ForceSendFields []string `json:"-"`
248
249
250
251
252 NullFields []string `json:"-"`
253 }
254
255 func (s *Operation) MarshalJSON() ([]byte, error) {
256 type NoMethod Operation
257 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
258 }
259
260
261
262
263
264
265
266 type Status struct {
267
268 Code int64 `json:"code,omitempty"`
269
270
271 Details []googleapi.RawMessage `json:"details,omitempty"`
272
273
274
275 Message string `json:"message,omitempty"`
276
277
278
279
280
281 ForceSendFields []string `json:"-"`
282
283
284
285
286 NullFields []string `json:"-"`
287 }
288
289 func (s *Status) MarshalJSON() ([]byte, error) {
290 type NoMethod Status
291 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
292 }
293
294 type OperationsCancelCall struct {
295 s *Service
296 name string
297 canceloperationrequest *CancelOperationRequest
298 urlParams_ gensupport.URLParams
299 ctx_ context.Context
300 header_ http.Header
301 }
302
303
304
305
306
307
308
309
310
311
312
313
314 func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall {
315 c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
316 c.name = name
317 c.canceloperationrequest = canceloperationrequest
318 return c
319 }
320
321
322
323
324 func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall {
325 c.urlParams_.Set("fields", googleapi.CombineFields(s))
326 return c
327 }
328
329
330 func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall {
331 c.ctx_ = ctx
332 return c
333 }
334
335
336
337 func (c *OperationsCancelCall) Header() http.Header {
338 if c.header_ == nil {
339 c.header_ = make(http.Header)
340 }
341 return c.header_
342 }
343
344 func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) {
345 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
346 var body io.Reader = nil
347 body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest)
348 if err != nil {
349 return nil, err
350 }
351 c.urlParams_.Set("alt", alt)
352 c.urlParams_.Set("prettyPrint", "false")
353 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel")
354 urls += "?" + c.urlParams_.Encode()
355 req, err := http.NewRequest("POST", urls, body)
356 if err != nil {
357 return nil, err
358 }
359 req.Header = reqHeaders
360 googleapi.Expand(req.URL, map[string]string{
361 "name": c.name,
362 })
363 return gensupport.SendRequest(c.ctx_, c.s.client, req)
364 }
365
366
367
368
369
370
371 func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
372 gensupport.SetOptions(c.urlParams_, opts...)
373 res, err := c.doRequest("json")
374 if res != nil && res.StatusCode == http.StatusNotModified {
375 if res.Body != nil {
376 res.Body.Close()
377 }
378 return nil, gensupport.WrapError(&googleapi.Error{
379 Code: res.StatusCode,
380 Header: res.Header,
381 })
382 }
383 if err != nil {
384 return nil, err
385 }
386 defer googleapi.CloseBody(res)
387 if err := googleapi.CheckResponse(res); err != nil {
388 return nil, gensupport.WrapError(err)
389 }
390 ret := &Empty{
391 ServerResponse: googleapi.ServerResponse{
392 Header: res.Header,
393 HTTPStatusCode: res.StatusCode,
394 },
395 }
396 target := &ret
397 if err := gensupport.DecodeResponse(target, res); err != nil {
398 return nil, err
399 }
400 return ret, nil
401 }
402
403 type OperationsDeleteCall struct {
404 s *Service
405 name string
406 urlParams_ gensupport.URLParams
407 ctx_ context.Context
408 header_ http.Header
409 }
410
411
412
413
414
415
416
417 func (r *OperationsService) Delete(name string) *OperationsDeleteCall {
418 c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
419 c.name = name
420 return c
421 }
422
423
424
425
426 func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall {
427 c.urlParams_.Set("fields", googleapi.CombineFields(s))
428 return c
429 }
430
431
432 func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall {
433 c.ctx_ = ctx
434 return c
435 }
436
437
438
439 func (c *OperationsDeleteCall) Header() http.Header {
440 if c.header_ == nil {
441 c.header_ = make(http.Header)
442 }
443 return c.header_
444 }
445
446 func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) {
447 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
448 var body io.Reader = nil
449 c.urlParams_.Set("alt", alt)
450 c.urlParams_.Set("prettyPrint", "false")
451 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
452 urls += "?" + c.urlParams_.Encode()
453 req, err := http.NewRequest("DELETE", urls, body)
454 if err != nil {
455 return nil, err
456 }
457 req.Header = reqHeaders
458 googleapi.Expand(req.URL, map[string]string{
459 "name": c.name,
460 })
461 return gensupport.SendRequest(c.ctx_, c.s.client, req)
462 }
463
464
465
466
467
468
469 func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
470 gensupport.SetOptions(c.urlParams_, opts...)
471 res, err := c.doRequest("json")
472 if res != nil && res.StatusCode == http.StatusNotModified {
473 if res.Body != nil {
474 res.Body.Close()
475 }
476 return nil, gensupport.WrapError(&googleapi.Error{
477 Code: res.StatusCode,
478 Header: res.Header,
479 })
480 }
481 if err != nil {
482 return nil, err
483 }
484 defer googleapi.CloseBody(res)
485 if err := googleapi.CheckResponse(res); err != nil {
486 return nil, gensupport.WrapError(err)
487 }
488 ret := &Empty{
489 ServerResponse: googleapi.ServerResponse{
490 Header: res.Header,
491 HTTPStatusCode: res.StatusCode,
492 },
493 }
494 target := &ret
495 if err := gensupport.DecodeResponse(target, res); err != nil {
496 return nil, err
497 }
498 return ret, nil
499 }
500
501 type OperationsListCall struct {
502 s *Service
503 name string
504 urlParams_ gensupport.URLParams
505 ifNoneMatch_ string
506 ctx_ context.Context
507 header_ http.Header
508 }
509
510
511
512
513
514 func (r *OperationsService) List(name string) *OperationsListCall {
515 c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
516 c.name = name
517 return c
518 }
519
520
521 func (c *OperationsListCall) Filter(filter string) *OperationsListCall {
522 c.urlParams_.Set("filter", filter)
523 return c
524 }
525
526
527
528 func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall {
529 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
530 return c
531 }
532
533
534
535 func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall {
536 c.urlParams_.Set("pageToken", pageToken)
537 return c
538 }
539
540
541
542
543 func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall {
544 c.urlParams_.Set("fields", googleapi.CombineFields(s))
545 return c
546 }
547
548
549
550
551 func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall {
552 c.ifNoneMatch_ = entityTag
553 return c
554 }
555
556
557 func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall {
558 c.ctx_ = ctx
559 return c
560 }
561
562
563
564 func (c *OperationsListCall) Header() http.Header {
565 if c.header_ == nil {
566 c.header_ = make(http.Header)
567 }
568 return c.header_
569 }
570
571 func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) {
572 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
573 if c.ifNoneMatch_ != "" {
574 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
575 }
576 var body io.Reader = nil
577 c.urlParams_.Set("alt", alt)
578 c.urlParams_.Set("prettyPrint", "false")
579 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
580 urls += "?" + c.urlParams_.Encode()
581 req, err := http.NewRequest("GET", urls, body)
582 if err != nil {
583 return nil, err
584 }
585 req.Header = reqHeaders
586 googleapi.Expand(req.URL, map[string]string{
587 "name": c.name,
588 })
589 return gensupport.SendRequest(c.ctx_, c.s.client, req)
590 }
591
592
593
594
595
596
597
598 func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
599 gensupport.SetOptions(c.urlParams_, opts...)
600 res, err := c.doRequest("json")
601 if res != nil && res.StatusCode == http.StatusNotModified {
602 if res.Body != nil {
603 res.Body.Close()
604 }
605 return nil, gensupport.WrapError(&googleapi.Error{
606 Code: res.StatusCode,
607 Header: res.Header,
608 })
609 }
610 if err != nil {
611 return nil, err
612 }
613 defer googleapi.CloseBody(res)
614 if err := googleapi.CheckResponse(res); err != nil {
615 return nil, gensupport.WrapError(err)
616 }
617 ret := &ListOperationsResponse{
618 ServerResponse: googleapi.ServerResponse{
619 Header: res.Header,
620 HTTPStatusCode: res.StatusCode,
621 },
622 }
623 target := &ret
624 if err := gensupport.DecodeResponse(target, res); err != nil {
625 return nil, err
626 }
627 return ret, nil
628 }
629
630
631
632
633 func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
634 c.ctx_ = ctx
635 defer c.PageToken(c.urlParams_.Get("pageToken"))
636 for {
637 x, err := c.Do()
638 if err != nil {
639 return err
640 }
641 if err := f(x); err != nil {
642 return err
643 }
644 if x.NextPageToken == "" {
645 return nil
646 }
647 c.PageToken(x.NextPageToken)
648 }
649 }
650
View as plain text