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 package oslogin
59
60 import (
61 "bytes"
62 "context"
63 "encoding/json"
64 "errors"
65 "fmt"
66 "io"
67 "net/http"
68 "net/url"
69 "strconv"
70 "strings"
71
72 googleapi "google.golang.org/api/googleapi"
73 internal "google.golang.org/api/internal"
74 gensupport "google.golang.org/api/internal/gensupport"
75 option "google.golang.org/api/option"
76 internaloption "google.golang.org/api/option/internaloption"
77 htransport "google.golang.org/api/transport/http"
78 )
79
80
81
82 var _ = bytes.NewBuffer
83 var _ = strconv.Itoa
84 var _ = fmt.Sprintf
85 var _ = json.NewDecoder
86 var _ = io.Copy
87 var _ = url.Parse
88 var _ = gensupport.MarshalJSON
89 var _ = googleapi.Version
90 var _ = errors.New
91 var _ = strings.Replace
92 var _ = context.Canceled
93 var _ = internaloption.WithDefaultEndpoint
94 var _ = internal.Version
95
96 const apiId = "oslogin:v1"
97 const apiName = "oslogin"
98 const apiVersion = "v1"
99 const basePath = "https://oslogin.googleapis.com/"
100 const basePathTemplate = "https://oslogin.UNIVERSE_DOMAIN/"
101 const mtlsBasePath = "https://oslogin.mtls.googleapis.com/"
102
103
104 const (
105
106
107 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
108
109
110
111 CloudPlatformReadOnlyScope = "https://www.googleapis.com/auth/cloud-platform.read-only"
112
113
114 ComputeScope = "https://www.googleapis.com/auth/compute"
115
116
117 ComputeReadonlyScope = "https://www.googleapis.com/auth/compute.readonly"
118 )
119
120
121 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
122 scopesOption := internaloption.WithDefaultScopes(
123 "https://www.googleapis.com/auth/cloud-platform",
124 "https://www.googleapis.com/auth/cloud-platform.read-only",
125 "https://www.googleapis.com/auth/compute",
126 "https://www.googleapis.com/auth/compute.readonly",
127 )
128
129 opts = append([]option.ClientOption{scopesOption}, opts...)
130 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
131 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
132 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
133 opts = append(opts, internaloption.EnableNewAuthLibrary())
134 client, endpoint, err := htransport.NewClient(ctx, opts...)
135 if err != nil {
136 return nil, err
137 }
138 s, err := New(client)
139 if err != nil {
140 return nil, err
141 }
142 if endpoint != "" {
143 s.BasePath = endpoint
144 }
145 return s, nil
146 }
147
148
149
150
151
152
153 func New(client *http.Client) (*Service, error) {
154 if client == nil {
155 return nil, errors.New("client is nil")
156 }
157 s := &Service{client: client, BasePath: basePath}
158 s.Users = NewUsersService(s)
159 return s, nil
160 }
161
162 type Service struct {
163 client *http.Client
164 BasePath string
165 UserAgent string
166
167 Users *UsersService
168 }
169
170 func (s *Service) userAgent() string {
171 if s.UserAgent == "" {
172 return googleapi.UserAgent
173 }
174 return googleapi.UserAgent + " " + s.UserAgent
175 }
176
177 func NewUsersService(s *Service) *UsersService {
178 rs := &UsersService{s: s}
179 rs.Projects = NewUsersProjectsService(s)
180 rs.SshPublicKeys = NewUsersSshPublicKeysService(s)
181 return rs
182 }
183
184 type UsersService struct {
185 s *Service
186
187 Projects *UsersProjectsService
188
189 SshPublicKeys *UsersSshPublicKeysService
190 }
191
192 func NewUsersProjectsService(s *Service) *UsersProjectsService {
193 rs := &UsersProjectsService{s: s}
194 return rs
195 }
196
197 type UsersProjectsService struct {
198 s *Service
199 }
200
201 func NewUsersSshPublicKeysService(s *Service) *UsersSshPublicKeysService {
202 rs := &UsersSshPublicKeysService{s: s}
203 return rs
204 }
205
206 type UsersSshPublicKeysService struct {
207 s *Service
208 }
209
210
211
212
213
214 type Empty struct {
215
216 googleapi.ServerResponse `json:"-"`
217 }
218
219
220
221 type ImportSshPublicKeyResponse struct {
222
223 Details string `json:"details,omitempty"`
224
225 LoginProfile *LoginProfile `json:"loginProfile,omitempty"`
226
227
228 googleapi.ServerResponse `json:"-"`
229
230
231
232
233
234 ForceSendFields []string `json:"-"`
235
236
237
238
239 NullFields []string `json:"-"`
240 }
241
242 func (s *ImportSshPublicKeyResponse) MarshalJSON() ([]byte, error) {
243 type NoMethod ImportSshPublicKeyResponse
244 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
245 }
246
247
248
249 type LoginProfile struct {
250
251 Name string `json:"name,omitempty"`
252
253 PosixAccounts []*PosixAccount `json:"posixAccounts,omitempty"`
254
255
256 SshPublicKeys map[string]SshPublicKey `json:"sshPublicKeys,omitempty"`
257
258
259 googleapi.ServerResponse `json:"-"`
260
261
262
263
264
265 ForceSendFields []string `json:"-"`
266
267
268
269
270 NullFields []string `json:"-"`
271 }
272
273 func (s *LoginProfile) MarshalJSON() ([]byte, error) {
274 type NoMethod LoginProfile
275 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
276 }
277
278
279
280 type PosixAccount struct {
281
282 AccountId string `json:"accountId,omitempty"`
283
284 Gecos string `json:"gecos,omitempty"`
285
286 Gid int64 `json:"gid,omitempty,string"`
287
288 HomeDirectory string `json:"homeDirectory,omitempty"`
289
290 Name string `json:"name,omitempty"`
291
292
293
294
295
296
297
298 OperatingSystemType string `json:"operatingSystemType,omitempty"`
299
300 Primary bool `json:"primary,omitempty"`
301
302 Shell string `json:"shell,omitempty"`
303
304
305 SystemId string `json:"systemId,omitempty"`
306
307 Uid int64 `json:"uid,omitempty,string"`
308
309 Username string `json:"username,omitempty"`
310
311
312
313
314
315 ForceSendFields []string `json:"-"`
316
317
318
319
320 NullFields []string `json:"-"`
321 }
322
323 func (s *PosixAccount) MarshalJSON() ([]byte, error) {
324 type NoMethod PosixAccount
325 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
326 }
327
328
329
330 type SshPublicKey struct {
331
332 ExpirationTimeUsec int64 `json:"expirationTimeUsec,omitempty,string"`
333
334 Fingerprint string `json:"fingerprint,omitempty"`
335
336 Key string `json:"key,omitempty"`
337
338 Name string `json:"name,omitempty"`
339
340
341 googleapi.ServerResponse `json:"-"`
342
343
344
345
346
347 ForceSendFields []string `json:"-"`
348
349
350
351
352 NullFields []string `json:"-"`
353 }
354
355 func (s *SshPublicKey) MarshalJSON() ([]byte, error) {
356 type NoMethod SshPublicKey
357 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
358 }
359
360 type UsersGetLoginProfileCall struct {
361 s *Service
362 name string
363 urlParams_ gensupport.URLParams
364 ifNoneMatch_ string
365 ctx_ context.Context
366 header_ http.Header
367 }
368
369
370
371
372
373 func (r *UsersService) GetLoginProfile(name string) *UsersGetLoginProfileCall {
374 c := &UsersGetLoginProfileCall{s: r.s, urlParams_: make(gensupport.URLParams)}
375 c.name = name
376 return c
377 }
378
379
380
381 func (c *UsersGetLoginProfileCall) ProjectId(projectId string) *UsersGetLoginProfileCall {
382 c.urlParams_.Set("projectId", projectId)
383 return c
384 }
385
386
387
388 func (c *UsersGetLoginProfileCall) SystemId(systemId string) *UsersGetLoginProfileCall {
389 c.urlParams_.Set("systemId", systemId)
390 return c
391 }
392
393
394
395
396 func (c *UsersGetLoginProfileCall) Fields(s ...googleapi.Field) *UsersGetLoginProfileCall {
397 c.urlParams_.Set("fields", googleapi.CombineFields(s))
398 return c
399 }
400
401
402
403
404 func (c *UsersGetLoginProfileCall) IfNoneMatch(entityTag string) *UsersGetLoginProfileCall {
405 c.ifNoneMatch_ = entityTag
406 return c
407 }
408
409
410 func (c *UsersGetLoginProfileCall) Context(ctx context.Context) *UsersGetLoginProfileCall {
411 c.ctx_ = ctx
412 return c
413 }
414
415
416
417 func (c *UsersGetLoginProfileCall) Header() http.Header {
418 if c.header_ == nil {
419 c.header_ = make(http.Header)
420 }
421 return c.header_
422 }
423
424 func (c *UsersGetLoginProfileCall) doRequest(alt string) (*http.Response, error) {
425 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
426 if c.ifNoneMatch_ != "" {
427 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
428 }
429 var body io.Reader = nil
430 c.urlParams_.Set("alt", alt)
431 c.urlParams_.Set("prettyPrint", "false")
432 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/loginProfile")
433 urls += "?" + c.urlParams_.Encode()
434 req, err := http.NewRequest("GET", urls, body)
435 if err != nil {
436 return nil, err
437 }
438 req.Header = reqHeaders
439 googleapi.Expand(req.URL, map[string]string{
440 "name": c.name,
441 })
442 return gensupport.SendRequest(c.ctx_, c.s.client, req)
443 }
444
445
446
447
448
449
450 func (c *UsersGetLoginProfileCall) Do(opts ...googleapi.CallOption) (*LoginProfile, error) {
451 gensupport.SetOptions(c.urlParams_, opts...)
452 res, err := c.doRequest("json")
453 if res != nil && res.StatusCode == http.StatusNotModified {
454 if res.Body != nil {
455 res.Body.Close()
456 }
457 return nil, gensupport.WrapError(&googleapi.Error{
458 Code: res.StatusCode,
459 Header: res.Header,
460 })
461 }
462 if err != nil {
463 return nil, err
464 }
465 defer googleapi.CloseBody(res)
466 if err := googleapi.CheckResponse(res); err != nil {
467 return nil, gensupport.WrapError(err)
468 }
469 ret := &LoginProfile{
470 ServerResponse: googleapi.ServerResponse{
471 Header: res.Header,
472 HTTPStatusCode: res.StatusCode,
473 },
474 }
475 target := &ret
476 if err := gensupport.DecodeResponse(target, res); err != nil {
477 return nil, err
478 }
479 return ret, nil
480 }
481
482 type UsersImportSshPublicKeyCall struct {
483 s *Service
484 parent string
485 sshpublickey *SshPublicKey
486 urlParams_ gensupport.URLParams
487 ctx_ context.Context
488 header_ http.Header
489 }
490
491
492
493
494
495
496 func (r *UsersService) ImportSshPublicKey(parent string, sshpublickey *SshPublicKey) *UsersImportSshPublicKeyCall {
497 c := &UsersImportSshPublicKeyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
498 c.parent = parent
499 c.sshpublickey = sshpublickey
500 return c
501 }
502
503
504
505 func (c *UsersImportSshPublicKeyCall) ProjectId(projectId string) *UsersImportSshPublicKeyCall {
506 c.urlParams_.Set("projectId", projectId)
507 return c
508 }
509
510
511
512
513 func (c *UsersImportSshPublicKeyCall) Regions(regions ...string) *UsersImportSshPublicKeyCall {
514 c.urlParams_.SetMulti("regions", append([]string{}, regions...))
515 return c
516 }
517
518
519
520
521 func (c *UsersImportSshPublicKeyCall) Fields(s ...googleapi.Field) *UsersImportSshPublicKeyCall {
522 c.urlParams_.Set("fields", googleapi.CombineFields(s))
523 return c
524 }
525
526
527 func (c *UsersImportSshPublicKeyCall) Context(ctx context.Context) *UsersImportSshPublicKeyCall {
528 c.ctx_ = ctx
529 return c
530 }
531
532
533
534 func (c *UsersImportSshPublicKeyCall) Header() http.Header {
535 if c.header_ == nil {
536 c.header_ = make(http.Header)
537 }
538 return c.header_
539 }
540
541 func (c *UsersImportSshPublicKeyCall) doRequest(alt string) (*http.Response, error) {
542 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
543 var body io.Reader = nil
544 body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey)
545 if err != nil {
546 return nil, err
547 }
548 c.urlParams_.Set("alt", alt)
549 c.urlParams_.Set("prettyPrint", "false")
550 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}:importSshPublicKey")
551 urls += "?" + c.urlParams_.Encode()
552 req, err := http.NewRequest("POST", urls, body)
553 if err != nil {
554 return nil, err
555 }
556 req.Header = reqHeaders
557 googleapi.Expand(req.URL, map[string]string{
558 "parent": c.parent,
559 })
560 return gensupport.SendRequest(c.ctx_, c.s.client, req)
561 }
562
563
564
565
566
567
568
569 func (c *UsersImportSshPublicKeyCall) Do(opts ...googleapi.CallOption) (*ImportSshPublicKeyResponse, error) {
570 gensupport.SetOptions(c.urlParams_, opts...)
571 res, err := c.doRequest("json")
572 if res != nil && res.StatusCode == http.StatusNotModified {
573 if res.Body != nil {
574 res.Body.Close()
575 }
576 return nil, gensupport.WrapError(&googleapi.Error{
577 Code: res.StatusCode,
578 Header: res.Header,
579 })
580 }
581 if err != nil {
582 return nil, err
583 }
584 defer googleapi.CloseBody(res)
585 if err := googleapi.CheckResponse(res); err != nil {
586 return nil, gensupport.WrapError(err)
587 }
588 ret := &ImportSshPublicKeyResponse{
589 ServerResponse: googleapi.ServerResponse{
590 Header: res.Header,
591 HTTPStatusCode: res.StatusCode,
592 },
593 }
594 target := &ret
595 if err := gensupport.DecodeResponse(target, res); err != nil {
596 return nil, err
597 }
598 return ret, nil
599 }
600
601 type UsersProjectsDeleteCall struct {
602 s *Service
603 name string
604 urlParams_ gensupport.URLParams
605 ctx_ context.Context
606 header_ http.Header
607 }
608
609
610
611
612
613
614 func (r *UsersProjectsService) Delete(name string) *UsersProjectsDeleteCall {
615 c := &UsersProjectsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
616 c.name = name
617 return c
618 }
619
620
621
622
623 func (c *UsersProjectsDeleteCall) Fields(s ...googleapi.Field) *UsersProjectsDeleteCall {
624 c.urlParams_.Set("fields", googleapi.CombineFields(s))
625 return c
626 }
627
628
629 func (c *UsersProjectsDeleteCall) Context(ctx context.Context) *UsersProjectsDeleteCall {
630 c.ctx_ = ctx
631 return c
632 }
633
634
635
636 func (c *UsersProjectsDeleteCall) Header() http.Header {
637 if c.header_ == nil {
638 c.header_ = make(http.Header)
639 }
640 return c.header_
641 }
642
643 func (c *UsersProjectsDeleteCall) doRequest(alt string) (*http.Response, error) {
644 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
645 var body io.Reader = nil
646 c.urlParams_.Set("alt", alt)
647 c.urlParams_.Set("prettyPrint", "false")
648 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
649 urls += "?" + c.urlParams_.Encode()
650 req, err := http.NewRequest("DELETE", urls, body)
651 if err != nil {
652 return nil, err
653 }
654 req.Header = reqHeaders
655 googleapi.Expand(req.URL, map[string]string{
656 "name": c.name,
657 })
658 return gensupport.SendRequest(c.ctx_, c.s.client, req)
659 }
660
661
662
663
664
665
666 func (c *UsersProjectsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
667 gensupport.SetOptions(c.urlParams_, opts...)
668 res, err := c.doRequest("json")
669 if res != nil && res.StatusCode == http.StatusNotModified {
670 if res.Body != nil {
671 res.Body.Close()
672 }
673 return nil, gensupport.WrapError(&googleapi.Error{
674 Code: res.StatusCode,
675 Header: res.Header,
676 })
677 }
678 if err != nil {
679 return nil, err
680 }
681 defer googleapi.CloseBody(res)
682 if err := googleapi.CheckResponse(res); err != nil {
683 return nil, gensupport.WrapError(err)
684 }
685 ret := &Empty{
686 ServerResponse: googleapi.ServerResponse{
687 Header: res.Header,
688 HTTPStatusCode: res.StatusCode,
689 },
690 }
691 target := &ret
692 if err := gensupport.DecodeResponse(target, res); err != nil {
693 return nil, err
694 }
695 return ret, nil
696 }
697
698 type UsersSshPublicKeysCreateCall struct {
699 s *Service
700 parent string
701 sshpublickey *SshPublicKey
702 urlParams_ gensupport.URLParams
703 ctx_ context.Context
704 header_ http.Header
705 }
706
707
708
709
710 func (r *UsersSshPublicKeysService) Create(parent string, sshpublickey *SshPublicKey) *UsersSshPublicKeysCreateCall {
711 c := &UsersSshPublicKeysCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
712 c.parent = parent
713 c.sshpublickey = sshpublickey
714 return c
715 }
716
717
718
719
720 func (c *UsersSshPublicKeysCreateCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysCreateCall {
721 c.urlParams_.Set("fields", googleapi.CombineFields(s))
722 return c
723 }
724
725
726 func (c *UsersSshPublicKeysCreateCall) Context(ctx context.Context) *UsersSshPublicKeysCreateCall {
727 c.ctx_ = ctx
728 return c
729 }
730
731
732
733 func (c *UsersSshPublicKeysCreateCall) Header() http.Header {
734 if c.header_ == nil {
735 c.header_ = make(http.Header)
736 }
737 return c.header_
738 }
739
740 func (c *UsersSshPublicKeysCreateCall) doRequest(alt string) (*http.Response, error) {
741 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
742 var body io.Reader = nil
743 body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey)
744 if err != nil {
745 return nil, err
746 }
747 c.urlParams_.Set("alt", alt)
748 c.urlParams_.Set("prettyPrint", "false")
749 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/sshPublicKeys")
750 urls += "?" + c.urlParams_.Encode()
751 req, err := http.NewRequest("POST", urls, body)
752 if err != nil {
753 return nil, err
754 }
755 req.Header = reqHeaders
756 googleapi.Expand(req.URL, map[string]string{
757 "parent": c.parent,
758 })
759 return gensupport.SendRequest(c.ctx_, c.s.client, req)
760 }
761
762
763
764
765
766
767 func (c *UsersSshPublicKeysCreateCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) {
768 gensupport.SetOptions(c.urlParams_, opts...)
769 res, err := c.doRequest("json")
770 if res != nil && res.StatusCode == http.StatusNotModified {
771 if res.Body != nil {
772 res.Body.Close()
773 }
774 return nil, gensupport.WrapError(&googleapi.Error{
775 Code: res.StatusCode,
776 Header: res.Header,
777 })
778 }
779 if err != nil {
780 return nil, err
781 }
782 defer googleapi.CloseBody(res)
783 if err := googleapi.CheckResponse(res); err != nil {
784 return nil, gensupport.WrapError(err)
785 }
786 ret := &SshPublicKey{
787 ServerResponse: googleapi.ServerResponse{
788 Header: res.Header,
789 HTTPStatusCode: res.StatusCode,
790 },
791 }
792 target := &ret
793 if err := gensupport.DecodeResponse(target, res); err != nil {
794 return nil, err
795 }
796 return ret, nil
797 }
798
799 type UsersSshPublicKeysDeleteCall struct {
800 s *Service
801 name string
802 urlParams_ gensupport.URLParams
803 ctx_ context.Context
804 header_ http.Header
805 }
806
807
808
809
810
811
812 func (r *UsersSshPublicKeysService) Delete(name string) *UsersSshPublicKeysDeleteCall {
813 c := &UsersSshPublicKeysDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
814 c.name = name
815 return c
816 }
817
818
819
820
821 func (c *UsersSshPublicKeysDeleteCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysDeleteCall {
822 c.urlParams_.Set("fields", googleapi.CombineFields(s))
823 return c
824 }
825
826
827 func (c *UsersSshPublicKeysDeleteCall) Context(ctx context.Context) *UsersSshPublicKeysDeleteCall {
828 c.ctx_ = ctx
829 return c
830 }
831
832
833
834 func (c *UsersSshPublicKeysDeleteCall) Header() http.Header {
835 if c.header_ == nil {
836 c.header_ = make(http.Header)
837 }
838 return c.header_
839 }
840
841 func (c *UsersSshPublicKeysDeleteCall) doRequest(alt string) (*http.Response, error) {
842 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
843 var body io.Reader = nil
844 c.urlParams_.Set("alt", alt)
845 c.urlParams_.Set("prettyPrint", "false")
846 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
847 urls += "?" + c.urlParams_.Encode()
848 req, err := http.NewRequest("DELETE", urls, body)
849 if err != nil {
850 return nil, err
851 }
852 req.Header = reqHeaders
853 googleapi.Expand(req.URL, map[string]string{
854 "name": c.name,
855 })
856 return gensupport.SendRequest(c.ctx_, c.s.client, req)
857 }
858
859
860
861
862
863
864 func (c *UsersSshPublicKeysDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
865 gensupport.SetOptions(c.urlParams_, opts...)
866 res, err := c.doRequest("json")
867 if res != nil && res.StatusCode == http.StatusNotModified {
868 if res.Body != nil {
869 res.Body.Close()
870 }
871 return nil, gensupport.WrapError(&googleapi.Error{
872 Code: res.StatusCode,
873 Header: res.Header,
874 })
875 }
876 if err != nil {
877 return nil, err
878 }
879 defer googleapi.CloseBody(res)
880 if err := googleapi.CheckResponse(res); err != nil {
881 return nil, gensupport.WrapError(err)
882 }
883 ret := &Empty{
884 ServerResponse: googleapi.ServerResponse{
885 Header: res.Header,
886 HTTPStatusCode: res.StatusCode,
887 },
888 }
889 target := &ret
890 if err := gensupport.DecodeResponse(target, res); err != nil {
891 return nil, err
892 }
893 return ret, nil
894 }
895
896 type UsersSshPublicKeysGetCall struct {
897 s *Service
898 name string
899 urlParams_ gensupport.URLParams
900 ifNoneMatch_ string
901 ctx_ context.Context
902 header_ http.Header
903 }
904
905
906
907
908
909
910 func (r *UsersSshPublicKeysService) Get(name string) *UsersSshPublicKeysGetCall {
911 c := &UsersSshPublicKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
912 c.name = name
913 return c
914 }
915
916
917
918
919 func (c *UsersSshPublicKeysGetCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysGetCall {
920 c.urlParams_.Set("fields", googleapi.CombineFields(s))
921 return c
922 }
923
924
925
926
927 func (c *UsersSshPublicKeysGetCall) IfNoneMatch(entityTag string) *UsersSshPublicKeysGetCall {
928 c.ifNoneMatch_ = entityTag
929 return c
930 }
931
932
933 func (c *UsersSshPublicKeysGetCall) Context(ctx context.Context) *UsersSshPublicKeysGetCall {
934 c.ctx_ = ctx
935 return c
936 }
937
938
939
940 func (c *UsersSshPublicKeysGetCall) Header() http.Header {
941 if c.header_ == nil {
942 c.header_ = make(http.Header)
943 }
944 return c.header_
945 }
946
947 func (c *UsersSshPublicKeysGetCall) doRequest(alt string) (*http.Response, error) {
948 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
949 if c.ifNoneMatch_ != "" {
950 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
951 }
952 var body io.Reader = nil
953 c.urlParams_.Set("alt", alt)
954 c.urlParams_.Set("prettyPrint", "false")
955 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
956 urls += "?" + c.urlParams_.Encode()
957 req, err := http.NewRequest("GET", urls, body)
958 if err != nil {
959 return nil, err
960 }
961 req.Header = reqHeaders
962 googleapi.Expand(req.URL, map[string]string{
963 "name": c.name,
964 })
965 return gensupport.SendRequest(c.ctx_, c.s.client, req)
966 }
967
968
969
970
971
972
973 func (c *UsersSshPublicKeysGetCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) {
974 gensupport.SetOptions(c.urlParams_, opts...)
975 res, err := c.doRequest("json")
976 if res != nil && res.StatusCode == http.StatusNotModified {
977 if res.Body != nil {
978 res.Body.Close()
979 }
980 return nil, gensupport.WrapError(&googleapi.Error{
981 Code: res.StatusCode,
982 Header: res.Header,
983 })
984 }
985 if err != nil {
986 return nil, err
987 }
988 defer googleapi.CloseBody(res)
989 if err := googleapi.CheckResponse(res); err != nil {
990 return nil, gensupport.WrapError(err)
991 }
992 ret := &SshPublicKey{
993 ServerResponse: googleapi.ServerResponse{
994 Header: res.Header,
995 HTTPStatusCode: res.StatusCode,
996 },
997 }
998 target := &ret
999 if err := gensupport.DecodeResponse(target, res); err != nil {
1000 return nil, err
1001 }
1002 return ret, nil
1003 }
1004
1005 type UsersSshPublicKeysPatchCall struct {
1006 s *Service
1007 name string
1008 sshpublickey *SshPublicKey
1009 urlParams_ gensupport.URLParams
1010 ctx_ context.Context
1011 header_ http.Header
1012 }
1013
1014
1015
1016
1017
1018
1019
1020 func (r *UsersSshPublicKeysService) Patch(name string, sshpublickey *SshPublicKey) *UsersSshPublicKeysPatchCall {
1021 c := &UsersSshPublicKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1022 c.name = name
1023 c.sshpublickey = sshpublickey
1024 return c
1025 }
1026
1027
1028
1029 func (c *UsersSshPublicKeysPatchCall) UpdateMask(updateMask string) *UsersSshPublicKeysPatchCall {
1030 c.urlParams_.Set("updateMask", updateMask)
1031 return c
1032 }
1033
1034
1035
1036
1037 func (c *UsersSshPublicKeysPatchCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysPatchCall {
1038 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1039 return c
1040 }
1041
1042
1043 func (c *UsersSshPublicKeysPatchCall) Context(ctx context.Context) *UsersSshPublicKeysPatchCall {
1044 c.ctx_ = ctx
1045 return c
1046 }
1047
1048
1049
1050 func (c *UsersSshPublicKeysPatchCall) Header() http.Header {
1051 if c.header_ == nil {
1052 c.header_ = make(http.Header)
1053 }
1054 return c.header_
1055 }
1056
1057 func (c *UsersSshPublicKeysPatchCall) doRequest(alt string) (*http.Response, error) {
1058 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1059 var body io.Reader = nil
1060 body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey)
1061 if err != nil {
1062 return nil, err
1063 }
1064 c.urlParams_.Set("alt", alt)
1065 c.urlParams_.Set("prettyPrint", "false")
1066 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
1067 urls += "?" + c.urlParams_.Encode()
1068 req, err := http.NewRequest("PATCH", urls, body)
1069 if err != nil {
1070 return nil, err
1071 }
1072 req.Header = reqHeaders
1073 googleapi.Expand(req.URL, map[string]string{
1074 "name": c.name,
1075 })
1076 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1077 }
1078
1079
1080
1081
1082
1083
1084 func (c *UsersSshPublicKeysPatchCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) {
1085 gensupport.SetOptions(c.urlParams_, opts...)
1086 res, err := c.doRequest("json")
1087 if res != nil && res.StatusCode == http.StatusNotModified {
1088 if res.Body != nil {
1089 res.Body.Close()
1090 }
1091 return nil, gensupport.WrapError(&googleapi.Error{
1092 Code: res.StatusCode,
1093 Header: res.Header,
1094 })
1095 }
1096 if err != nil {
1097 return nil, err
1098 }
1099 defer googleapi.CloseBody(res)
1100 if err := googleapi.CheckResponse(res); err != nil {
1101 return nil, gensupport.WrapError(err)
1102 }
1103 ret := &SshPublicKey{
1104 ServerResponse: googleapi.ServerResponse{
1105 Header: res.Header,
1106 HTTPStatusCode: res.StatusCode,
1107 },
1108 }
1109 target := &ret
1110 if err := gensupport.DecodeResponse(target, res); err != nil {
1111 return nil, err
1112 }
1113 return ret, nil
1114 }
1115
View as plain text