1// Copyright 2020 Google LLC. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5// Code generated file. DO NOT EDIT. 6 7// Package oslogin provides access to the Cloud OS Login API. 8// 9// This package is DEPRECATED. Use package cloud.google.com/go/oslogin/apiv1 instead. 10// 11// For product documentation, see: https://cloud.google.com/compute/docs/oslogin/ 12// 13// Creating a client 14// 15// Usage example: 16// 17// import "google.golang.org/api/oslogin/v1beta" 18// ... 19// ctx := context.Background() 20// osloginService, err := oslogin.NewService(ctx) 21// 22// In this example, Google Application Default Credentials are used for authentication. 23// 24// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 25// 26// Other authentication options 27// 28// By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes: 29// 30// osloginService, err := oslogin.NewService(ctx, option.WithScopes(oslogin.ComputeReadonlyScope)) 31// 32// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey: 33// 34// osloginService, err := oslogin.NewService(ctx, option.WithAPIKey("AIza...")) 35// 36// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource: 37// 38// config := &oauth2.Config{...} 39// // ... 40// token, err := config.Exchange(ctx, ...) 41// osloginService, err := oslogin.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 42// 43// See https://godoc.org/google.golang.org/api/option/ for details on options. 44package oslogin // import "google.golang.org/api/oslogin/v1beta" 45 46import ( 47 "bytes" 48 "context" 49 "encoding/json" 50 "errors" 51 "fmt" 52 "io" 53 "net/http" 54 "net/url" 55 "strconv" 56 "strings" 57 58 googleapi "google.golang.org/api/googleapi" 59 gensupport "google.golang.org/api/internal/gensupport" 60 option "google.golang.org/api/option" 61 internaloption "google.golang.org/api/option/internaloption" 62 htransport "google.golang.org/api/transport/http" 63) 64 65// Always reference these packages, just in case the auto-generated code 66// below doesn't. 67var _ = bytes.NewBuffer 68var _ = strconv.Itoa 69var _ = fmt.Sprintf 70var _ = json.NewDecoder 71var _ = io.Copy 72var _ = url.Parse 73var _ = gensupport.MarshalJSON 74var _ = googleapi.Version 75var _ = errors.New 76var _ = strings.Replace 77var _ = context.Canceled 78var _ = internaloption.WithDefaultEndpoint 79 80const apiId = "oslogin:v1beta" 81const apiName = "oslogin" 82const apiVersion = "v1beta" 83const basePath = "https://oslogin.googleapis.com/" 84const mtlsBasePath = "https://oslogin.mtls.googleapis.com/" 85 86// OAuth2 scopes used by this API. 87const ( 88 // View and manage your data across Google Cloud Platform services 89 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 90 91 // View your data across Google Cloud Platform services 92 CloudPlatformReadOnlyScope = "https://www.googleapis.com/auth/cloud-platform.read-only" 93 94 // View and manage your Google Compute Engine resources 95 ComputeScope = "https://www.googleapis.com/auth/compute" 96 97 // View your Google Compute Engine resources 98 ComputeReadonlyScope = "https://www.googleapis.com/auth/compute.readonly" 99) 100 101// NewService creates a new Service. 102func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 103 scopesOption := option.WithScopes( 104 "https://www.googleapis.com/auth/cloud-platform", 105 "https://www.googleapis.com/auth/cloud-platform.read-only", 106 "https://www.googleapis.com/auth/compute", 107 "https://www.googleapis.com/auth/compute.readonly", 108 ) 109 // NOTE: prepend, so we don't override user-specified scopes. 110 opts = append([]option.ClientOption{scopesOption}, opts...) 111 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 112 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 113 client, endpoint, err := htransport.NewClient(ctx, opts...) 114 if err != nil { 115 return nil, err 116 } 117 s, err := New(client) 118 if err != nil { 119 return nil, err 120 } 121 if endpoint != "" { 122 s.BasePath = endpoint 123 } 124 return s, nil 125} 126 127// New creates a new Service. It uses the provided http.Client for requests. 128// 129// Deprecated: please use NewService instead. 130// To provide a custom HTTP client, use option.WithHTTPClient. 131// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 132func New(client *http.Client) (*Service, error) { 133 if client == nil { 134 return nil, errors.New("client is nil") 135 } 136 s := &Service{client: client, BasePath: basePath} 137 s.Users = NewUsersService(s) 138 return s, nil 139} 140 141type Service struct { 142 client *http.Client 143 BasePath string // API endpoint base URL 144 UserAgent string // optional additional User-Agent fragment 145 146 Users *UsersService 147} 148 149func (s *Service) userAgent() string { 150 if s.UserAgent == "" { 151 return googleapi.UserAgent 152 } 153 return googleapi.UserAgent + " " + s.UserAgent 154} 155 156func NewUsersService(s *Service) *UsersService { 157 rs := &UsersService{s: s} 158 rs.Projects = NewUsersProjectsService(s) 159 rs.SshPublicKeys = NewUsersSshPublicKeysService(s) 160 return rs 161} 162 163type UsersService struct { 164 s *Service 165 166 Projects *UsersProjectsService 167 168 SshPublicKeys *UsersSshPublicKeysService 169} 170 171func NewUsersProjectsService(s *Service) *UsersProjectsService { 172 rs := &UsersProjectsService{s: s} 173 return rs 174} 175 176type UsersProjectsService struct { 177 s *Service 178} 179 180func NewUsersSshPublicKeysService(s *Service) *UsersSshPublicKeysService { 181 rs := &UsersSshPublicKeysService{s: s} 182 return rs 183} 184 185type UsersSshPublicKeysService struct { 186 s *Service 187} 188 189// Empty: A generic empty message that you can re-use to avoid defining 190// duplicated 191// empty messages in your APIs. A typical example is to use it as the 192// request 193// or the response type of an API method. For instance: 194// 195// service Foo { 196// rpc Bar(google.protobuf.Empty) returns 197// (google.protobuf.Empty); 198// } 199// 200// The JSON representation for `Empty` is empty JSON object `{}`. 201type Empty struct { 202 // ServerResponse contains the HTTP response code and headers from the 203 // server. 204 googleapi.ServerResponse `json:"-"` 205} 206 207// ImportSshPublicKeyResponse: A response message for importing an SSH 208// public key. 209type ImportSshPublicKeyResponse struct { 210 // LoginProfile: The login profile information for the user. 211 LoginProfile *LoginProfile `json:"loginProfile,omitempty"` 212 213 // ServerResponse contains the HTTP response code and headers from the 214 // server. 215 googleapi.ServerResponse `json:"-"` 216 217 // ForceSendFields is a list of field names (e.g. "LoginProfile") to 218 // unconditionally include in API requests. By default, fields with 219 // empty values are omitted from API requests. However, any non-pointer, 220 // non-interface field appearing in ForceSendFields will be sent to the 221 // server regardless of whether the field is empty or not. This may be 222 // used to include empty fields in Patch requests. 223 ForceSendFields []string `json:"-"` 224 225 // NullFields is a list of field names (e.g. "LoginProfile") to include 226 // in API requests with the JSON null value. By default, fields with 227 // empty values are omitted from API requests. However, any field with 228 // an empty value appearing in NullFields will be sent to the server as 229 // null. It is an error if a field in this list has a non-empty value. 230 // This may be used to include null fields in Patch requests. 231 NullFields []string `json:"-"` 232} 233 234func (s *ImportSshPublicKeyResponse) MarshalJSON() ([]byte, error) { 235 type NoMethod ImportSshPublicKeyResponse 236 raw := NoMethod(*s) 237 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 238} 239 240// LoginProfile: The user profile information used for logging in to a 241// virtual machine on 242// Google Compute Engine. 243type LoginProfile struct { 244 // Name: Required. A unique user ID. 245 Name string `json:"name,omitempty"` 246 247 // PosixAccounts: The list of POSIX accounts associated with the user. 248 PosixAccounts []*PosixAccount `json:"posixAccounts,omitempty"` 249 250 // SshPublicKeys: A map from SSH public key fingerprint to the 251 // associated key object. 252 SshPublicKeys map[string]SshPublicKey `json:"sshPublicKeys,omitempty"` 253 254 // ServerResponse contains the HTTP response code and headers from the 255 // server. 256 googleapi.ServerResponse `json:"-"` 257 258 // ForceSendFields is a list of field names (e.g. "Name") to 259 // unconditionally include in API requests. By default, fields with 260 // empty values are omitted from API requests. However, any non-pointer, 261 // non-interface field appearing in ForceSendFields will be sent to the 262 // server regardless of whether the field is empty or not. This may be 263 // used to include empty fields in Patch requests. 264 ForceSendFields []string `json:"-"` 265 266 // NullFields is a list of field names (e.g. "Name") to include in API 267 // requests with the JSON null value. By default, fields with empty 268 // values are omitted from API requests. However, any field with an 269 // empty value appearing in NullFields will be sent to the server as 270 // null. It is an error if a field in this list has a non-empty value. 271 // This may be used to include null fields in Patch requests. 272 NullFields []string `json:"-"` 273} 274 275func (s *LoginProfile) MarshalJSON() ([]byte, error) { 276 type NoMethod LoginProfile 277 raw := NoMethod(*s) 278 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 279} 280 281// PosixAccount: The POSIX account information associated with a Google 282// account. 283type PosixAccount struct { 284 // AccountId: Output only. A POSIX account identifier. 285 AccountId string `json:"accountId,omitempty"` 286 287 // Gecos: The GECOS (user information) entry for this account. 288 Gecos string `json:"gecos,omitempty"` 289 290 // Gid: The default group ID. 291 Gid int64 `json:"gid,omitempty,string"` 292 293 // HomeDirectory: The path to the home directory for this account. 294 HomeDirectory string `json:"homeDirectory,omitempty"` 295 296 // Name: Output only. The canonical resource name. 297 Name string `json:"name,omitempty"` 298 299 // OperatingSystemType: The operating system type where this account 300 // applies. 301 // 302 // Possible values: 303 // "OPERATING_SYSTEM_TYPE_UNSPECIFIED" - The operating system type 304 // associated with the user account information is 305 // unspecified. 306 // "LINUX" - Linux user account information. 307 // "WINDOWS" - Windows user account information. 308 OperatingSystemType string `json:"operatingSystemType,omitempty"` 309 310 // Primary: Only one POSIX account can be marked as primary. 311 Primary bool `json:"primary,omitempty"` 312 313 // Shell: The path to the logic shell for this account. 314 Shell string `json:"shell,omitempty"` 315 316 // SystemId: System identifier for which account the username or uid 317 // applies to. 318 // By default, the empty value is used. 319 SystemId string `json:"systemId,omitempty"` 320 321 // Uid: The user ID. 322 Uid int64 `json:"uid,omitempty,string"` 323 324 // Username: The username of the POSIX account. 325 Username string `json:"username,omitempty"` 326 327 // ForceSendFields is a list of field names (e.g. "AccountId") to 328 // unconditionally include in API requests. By default, fields with 329 // empty values are omitted from API requests. However, any non-pointer, 330 // non-interface field appearing in ForceSendFields will be sent to the 331 // server regardless of whether the field is empty or not. This may be 332 // used to include empty fields in Patch requests. 333 ForceSendFields []string `json:"-"` 334 335 // NullFields is a list of field names (e.g. "AccountId") to include in 336 // API requests with the JSON null value. By default, fields with empty 337 // values are omitted from API requests. However, any field with an 338 // empty value appearing in NullFields will be sent to the server as 339 // null. It is an error if a field in this list has a non-empty value. 340 // This may be used to include null fields in Patch requests. 341 NullFields []string `json:"-"` 342} 343 344func (s *PosixAccount) MarshalJSON() ([]byte, error) { 345 type NoMethod PosixAccount 346 raw := NoMethod(*s) 347 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 348} 349 350// SshPublicKey: The SSH public key information associated with a Google 351// account. 352type SshPublicKey struct { 353 // ExpirationTimeUsec: An expiration time in microseconds since epoch. 354 ExpirationTimeUsec int64 `json:"expirationTimeUsec,omitempty,string"` 355 356 // Fingerprint: Output only. The SHA-256 fingerprint of the SSH public 357 // key. 358 Fingerprint string `json:"fingerprint,omitempty"` 359 360 // Key: Public key text in SSH format, defined by 361 // <a href="https://www.ietf.org/rfc/rfc4253.txt" 362 // target="_blank">RFC4253</a> 363 // section 6.6. 364 Key string `json:"key,omitempty"` 365 366 // Name: Output only. The canonical resource name. 367 Name string `json:"name,omitempty"` 368 369 // ServerResponse contains the HTTP response code and headers from the 370 // server. 371 googleapi.ServerResponse `json:"-"` 372 373 // ForceSendFields is a list of field names (e.g. "ExpirationTimeUsec") 374 // to unconditionally include in API requests. By default, fields with 375 // empty values are omitted from API requests. However, any non-pointer, 376 // non-interface field appearing in ForceSendFields will be sent to the 377 // server regardless of whether the field is empty or not. This may be 378 // used to include empty fields in Patch requests. 379 ForceSendFields []string `json:"-"` 380 381 // NullFields is a list of field names (e.g. "ExpirationTimeUsec") to 382 // include in API requests with the JSON null value. By default, fields 383 // with empty values are omitted from API requests. However, any field 384 // with an empty value appearing in NullFields will be sent to the 385 // server as null. It is an error if a field in this list has a 386 // non-empty value. This may be used to include null fields in Patch 387 // requests. 388 NullFields []string `json:"-"` 389} 390 391func (s *SshPublicKey) MarshalJSON() ([]byte, error) { 392 type NoMethod SshPublicKey 393 raw := NoMethod(*s) 394 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 395} 396 397// method id "oslogin.users.getLoginProfile": 398 399type UsersGetLoginProfileCall struct { 400 s *Service 401 name string 402 urlParams_ gensupport.URLParams 403 ifNoneMatch_ string 404 ctx_ context.Context 405 header_ http.Header 406} 407 408// GetLoginProfile: Retrieves the profile information used for logging 409// in to a virtual machine 410// on Google Compute Engine. 411func (r *UsersService) GetLoginProfile(name string) *UsersGetLoginProfileCall { 412 c := &UsersGetLoginProfileCall{s: r.s, urlParams_: make(gensupport.URLParams)} 413 c.name = name 414 return c 415} 416 417// ProjectId sets the optional parameter "projectId": The project ID of 418// the Google Cloud Platform project. 419func (c *UsersGetLoginProfileCall) ProjectId(projectId string) *UsersGetLoginProfileCall { 420 c.urlParams_.Set("projectId", projectId) 421 return c 422} 423 424// SystemId sets the optional parameter "systemId": A system ID for 425// filtering the results of the request. 426func (c *UsersGetLoginProfileCall) SystemId(systemId string) *UsersGetLoginProfileCall { 427 c.urlParams_.Set("systemId", systemId) 428 return c 429} 430 431// Fields allows partial responses to be retrieved. See 432// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 433// for more information. 434func (c *UsersGetLoginProfileCall) Fields(s ...googleapi.Field) *UsersGetLoginProfileCall { 435 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 436 return c 437} 438 439// IfNoneMatch sets the optional parameter which makes the operation 440// fail if the object's ETag matches the given value. This is useful for 441// getting updates only after the object has changed since the last 442// request. Use googleapi.IsNotModified to check whether the response 443// error from Do is the result of In-None-Match. 444func (c *UsersGetLoginProfileCall) IfNoneMatch(entityTag string) *UsersGetLoginProfileCall { 445 c.ifNoneMatch_ = entityTag 446 return c 447} 448 449// Context sets the context to be used in this call's Do method. Any 450// pending HTTP request will be aborted if the provided context is 451// canceled. 452func (c *UsersGetLoginProfileCall) Context(ctx context.Context) *UsersGetLoginProfileCall { 453 c.ctx_ = ctx 454 return c 455} 456 457// Header returns an http.Header that can be modified by the caller to 458// add HTTP headers to the request. 459func (c *UsersGetLoginProfileCall) Header() http.Header { 460 if c.header_ == nil { 461 c.header_ = make(http.Header) 462 } 463 return c.header_ 464} 465 466func (c *UsersGetLoginProfileCall) doRequest(alt string) (*http.Response, error) { 467 reqHeaders := make(http.Header) 468 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 469 for k, v := range c.header_ { 470 reqHeaders[k] = v 471 } 472 reqHeaders.Set("User-Agent", c.s.userAgent()) 473 if c.ifNoneMatch_ != "" { 474 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 475 } 476 var body io.Reader = nil 477 c.urlParams_.Set("alt", alt) 478 c.urlParams_.Set("prettyPrint", "false") 479 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}/loginProfile") 480 urls += "?" + c.urlParams_.Encode() 481 req, err := http.NewRequest("GET", urls, body) 482 if err != nil { 483 return nil, err 484 } 485 req.Header = reqHeaders 486 googleapi.Expand(req.URL, map[string]string{ 487 "name": c.name, 488 }) 489 return gensupport.SendRequest(c.ctx_, c.s.client, req) 490} 491 492// Do executes the "oslogin.users.getLoginProfile" call. 493// Exactly one of *LoginProfile or error will be non-nil. Any non-2xx 494// status code is an error. Response headers are in either 495// *LoginProfile.ServerResponse.Header or (if a response was returned at 496// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 497// to check whether the returned error was because 498// http.StatusNotModified was returned. 499func (c *UsersGetLoginProfileCall) Do(opts ...googleapi.CallOption) (*LoginProfile, error) { 500 gensupport.SetOptions(c.urlParams_, opts...) 501 res, err := c.doRequest("json") 502 if res != nil && res.StatusCode == http.StatusNotModified { 503 if res.Body != nil { 504 res.Body.Close() 505 } 506 return nil, &googleapi.Error{ 507 Code: res.StatusCode, 508 Header: res.Header, 509 } 510 } 511 if err != nil { 512 return nil, err 513 } 514 defer googleapi.CloseBody(res) 515 if err := googleapi.CheckResponse(res); err != nil { 516 return nil, err 517 } 518 ret := &LoginProfile{ 519 ServerResponse: googleapi.ServerResponse{ 520 Header: res.Header, 521 HTTPStatusCode: res.StatusCode, 522 }, 523 } 524 target := &ret 525 if err := gensupport.DecodeResponse(target, res); err != nil { 526 return nil, err 527 } 528 return ret, nil 529 // { 530 // "description": "Retrieves the profile information used for logging in to a virtual machine\non Google Compute Engine.", 531 // "flatPath": "v1beta/users/{usersId}/loginProfile", 532 // "httpMethod": "GET", 533 // "id": "oslogin.users.getLoginProfile", 534 // "parameterOrder": [ 535 // "name" 536 // ], 537 // "parameters": { 538 // "name": { 539 // "description": "Required. The unique ID for the user in format `users/{user}`.", 540 // "location": "path", 541 // "pattern": "^users/[^/]+$", 542 // "required": true, 543 // "type": "string" 544 // }, 545 // "projectId": { 546 // "description": "The project ID of the Google Cloud Platform project.", 547 // "location": "query", 548 // "type": "string" 549 // }, 550 // "systemId": { 551 // "description": "A system ID for filtering the results of the request.", 552 // "location": "query", 553 // "type": "string" 554 // } 555 // }, 556 // "path": "v1beta/{+name}/loginProfile", 557 // "response": { 558 // "$ref": "LoginProfile" 559 // }, 560 // "scopes": [ 561 // "https://www.googleapis.com/auth/cloud-platform", 562 // "https://www.googleapis.com/auth/cloud-platform.read-only", 563 // "https://www.googleapis.com/auth/compute", 564 // "https://www.googleapis.com/auth/compute.readonly" 565 // ] 566 // } 567 568} 569 570// method id "oslogin.users.importSshPublicKey": 571 572type UsersImportSshPublicKeyCall struct { 573 s *Service 574 parent string 575 sshpublickey *SshPublicKey 576 urlParams_ gensupport.URLParams 577 ctx_ context.Context 578 header_ http.Header 579} 580 581// ImportSshPublicKey: Adds an SSH public key and returns the profile 582// information. Default POSIX 583// account information is set when no username and UID exist as part of 584// the 585// login profile. 586func (r *UsersService) ImportSshPublicKey(parent string, sshpublickey *SshPublicKey) *UsersImportSshPublicKeyCall { 587 c := &UsersImportSshPublicKeyCall{s: r.s, urlParams_: make(gensupport.URLParams)} 588 c.parent = parent 589 c.sshpublickey = sshpublickey 590 return c 591} 592 593// ProjectId sets the optional parameter "projectId": The project ID of 594// the Google Cloud Platform project. 595func (c *UsersImportSshPublicKeyCall) ProjectId(projectId string) *UsersImportSshPublicKeyCall { 596 c.urlParams_.Set("projectId", projectId) 597 return c 598} 599 600// Fields allows partial responses to be retrieved. See 601// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 602// for more information. 603func (c *UsersImportSshPublicKeyCall) Fields(s ...googleapi.Field) *UsersImportSshPublicKeyCall { 604 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 605 return c 606} 607 608// Context sets the context to be used in this call's Do method. Any 609// pending HTTP request will be aborted if the provided context is 610// canceled. 611func (c *UsersImportSshPublicKeyCall) Context(ctx context.Context) *UsersImportSshPublicKeyCall { 612 c.ctx_ = ctx 613 return c 614} 615 616// Header returns an http.Header that can be modified by the caller to 617// add HTTP headers to the request. 618func (c *UsersImportSshPublicKeyCall) Header() http.Header { 619 if c.header_ == nil { 620 c.header_ = make(http.Header) 621 } 622 return c.header_ 623} 624 625func (c *UsersImportSshPublicKeyCall) doRequest(alt string) (*http.Response, error) { 626 reqHeaders := make(http.Header) 627 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 628 for k, v := range c.header_ { 629 reqHeaders[k] = v 630 } 631 reqHeaders.Set("User-Agent", c.s.userAgent()) 632 var body io.Reader = nil 633 body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey) 634 if err != nil { 635 return nil, err 636 } 637 reqHeaders.Set("Content-Type", "application/json") 638 c.urlParams_.Set("alt", alt) 639 c.urlParams_.Set("prettyPrint", "false") 640 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+parent}:importSshPublicKey") 641 urls += "?" + c.urlParams_.Encode() 642 req, err := http.NewRequest("POST", urls, body) 643 if err != nil { 644 return nil, err 645 } 646 req.Header = reqHeaders 647 googleapi.Expand(req.URL, map[string]string{ 648 "parent": c.parent, 649 }) 650 return gensupport.SendRequest(c.ctx_, c.s.client, req) 651} 652 653// Do executes the "oslogin.users.importSshPublicKey" call. 654// Exactly one of *ImportSshPublicKeyResponse or error will be non-nil. 655// Any non-2xx status code is an error. Response headers are in either 656// *ImportSshPublicKeyResponse.ServerResponse.Header or (if a response 657// was returned at all) in error.(*googleapi.Error).Header. Use 658// googleapi.IsNotModified to check whether the returned error was 659// because http.StatusNotModified was returned. 660func (c *UsersImportSshPublicKeyCall) Do(opts ...googleapi.CallOption) (*ImportSshPublicKeyResponse, error) { 661 gensupport.SetOptions(c.urlParams_, opts...) 662 res, err := c.doRequest("json") 663 if res != nil && res.StatusCode == http.StatusNotModified { 664 if res.Body != nil { 665 res.Body.Close() 666 } 667 return nil, &googleapi.Error{ 668 Code: res.StatusCode, 669 Header: res.Header, 670 } 671 } 672 if err != nil { 673 return nil, err 674 } 675 defer googleapi.CloseBody(res) 676 if err := googleapi.CheckResponse(res); err != nil { 677 return nil, err 678 } 679 ret := &ImportSshPublicKeyResponse{ 680 ServerResponse: googleapi.ServerResponse{ 681 Header: res.Header, 682 HTTPStatusCode: res.StatusCode, 683 }, 684 } 685 target := &ret 686 if err := gensupport.DecodeResponse(target, res); err != nil { 687 return nil, err 688 } 689 return ret, nil 690 // { 691 // "description": "Adds an SSH public key and returns the profile information. Default POSIX\naccount information is set when no username and UID exist as part of the\nlogin profile.", 692 // "flatPath": "v1beta/users/{usersId}:importSshPublicKey", 693 // "httpMethod": "POST", 694 // "id": "oslogin.users.importSshPublicKey", 695 // "parameterOrder": [ 696 // "parent" 697 // ], 698 // "parameters": { 699 // "parent": { 700 // "description": "The unique ID for the user in format `users/{user}`.", 701 // "location": "path", 702 // "pattern": "^users/[^/]+$", 703 // "required": true, 704 // "type": "string" 705 // }, 706 // "projectId": { 707 // "description": "The project ID of the Google Cloud Platform project.", 708 // "location": "query", 709 // "type": "string" 710 // } 711 // }, 712 // "path": "v1beta/{+parent}:importSshPublicKey", 713 // "request": { 714 // "$ref": "SshPublicKey" 715 // }, 716 // "response": { 717 // "$ref": "ImportSshPublicKeyResponse" 718 // }, 719 // "scopes": [ 720 // "https://www.googleapis.com/auth/cloud-platform", 721 // "https://www.googleapis.com/auth/compute" 722 // ] 723 // } 724 725} 726 727// method id "oslogin.users.projects.delete": 728 729type UsersProjectsDeleteCall struct { 730 s *Service 731 name string 732 urlParams_ gensupport.URLParams 733 ctx_ context.Context 734 header_ http.Header 735} 736 737// Delete: Deletes a POSIX account. 738func (r *UsersProjectsService) Delete(name string) *UsersProjectsDeleteCall { 739 c := &UsersProjectsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 740 c.name = name 741 return c 742} 743 744// Fields allows partial responses to be retrieved. See 745// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 746// for more information. 747func (c *UsersProjectsDeleteCall) Fields(s ...googleapi.Field) *UsersProjectsDeleteCall { 748 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 749 return c 750} 751 752// Context sets the context to be used in this call's Do method. Any 753// pending HTTP request will be aborted if the provided context is 754// canceled. 755func (c *UsersProjectsDeleteCall) Context(ctx context.Context) *UsersProjectsDeleteCall { 756 c.ctx_ = ctx 757 return c 758} 759 760// Header returns an http.Header that can be modified by the caller to 761// add HTTP headers to the request. 762func (c *UsersProjectsDeleteCall) Header() http.Header { 763 if c.header_ == nil { 764 c.header_ = make(http.Header) 765 } 766 return c.header_ 767} 768 769func (c *UsersProjectsDeleteCall) doRequest(alt string) (*http.Response, error) { 770 reqHeaders := make(http.Header) 771 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 772 for k, v := range c.header_ { 773 reqHeaders[k] = v 774 } 775 reqHeaders.Set("User-Agent", c.s.userAgent()) 776 var body io.Reader = nil 777 c.urlParams_.Set("alt", alt) 778 c.urlParams_.Set("prettyPrint", "false") 779 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") 780 urls += "?" + c.urlParams_.Encode() 781 req, err := http.NewRequest("DELETE", urls, body) 782 if err != nil { 783 return nil, err 784 } 785 req.Header = reqHeaders 786 googleapi.Expand(req.URL, map[string]string{ 787 "name": c.name, 788 }) 789 return gensupport.SendRequest(c.ctx_, c.s.client, req) 790} 791 792// Do executes the "oslogin.users.projects.delete" call. 793// Exactly one of *Empty or error will be non-nil. Any non-2xx status 794// code is an error. Response headers are in either 795// *Empty.ServerResponse.Header or (if a response was returned at all) 796// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 797// check whether the returned error was because http.StatusNotModified 798// was returned. 799func (c *UsersProjectsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 800 gensupport.SetOptions(c.urlParams_, opts...) 801 res, err := c.doRequest("json") 802 if res != nil && res.StatusCode == http.StatusNotModified { 803 if res.Body != nil { 804 res.Body.Close() 805 } 806 return nil, &googleapi.Error{ 807 Code: res.StatusCode, 808 Header: res.Header, 809 } 810 } 811 if err != nil { 812 return nil, err 813 } 814 defer googleapi.CloseBody(res) 815 if err := googleapi.CheckResponse(res); err != nil { 816 return nil, err 817 } 818 ret := &Empty{ 819 ServerResponse: googleapi.ServerResponse{ 820 Header: res.Header, 821 HTTPStatusCode: res.StatusCode, 822 }, 823 } 824 target := &ret 825 if err := gensupport.DecodeResponse(target, res); err != nil { 826 return nil, err 827 } 828 return ret, nil 829 // { 830 // "description": "Deletes a POSIX account.", 831 // "flatPath": "v1beta/users/{usersId}/projects/{projectsId}", 832 // "httpMethod": "DELETE", 833 // "id": "oslogin.users.projects.delete", 834 // "parameterOrder": [ 835 // "name" 836 // ], 837 // "parameters": { 838 // "name": { 839 // "description": "Required. A reference to the POSIX account to update. POSIX accounts are identified\nby the project ID they are associated with. A reference to the POSIX\naccount is in format `users/{user}/projects/{project}`.", 840 // "location": "path", 841 // "pattern": "^users/[^/]+/projects/[^/]+$", 842 // "required": true, 843 // "type": "string" 844 // } 845 // }, 846 // "path": "v1beta/{+name}", 847 // "response": { 848 // "$ref": "Empty" 849 // }, 850 // "scopes": [ 851 // "https://www.googleapis.com/auth/cloud-platform", 852 // "https://www.googleapis.com/auth/compute" 853 // ] 854 // } 855 856} 857 858// method id "oslogin.users.sshPublicKeys.delete": 859 860type UsersSshPublicKeysDeleteCall struct { 861 s *Service 862 name string 863 urlParams_ gensupport.URLParams 864 ctx_ context.Context 865 header_ http.Header 866} 867 868// Delete: Deletes an SSH public key. 869func (r *UsersSshPublicKeysService) Delete(name string) *UsersSshPublicKeysDeleteCall { 870 c := &UsersSshPublicKeysDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 871 c.name = name 872 return c 873} 874 875// Fields allows partial responses to be retrieved. See 876// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 877// for more information. 878func (c *UsersSshPublicKeysDeleteCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysDeleteCall { 879 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 880 return c 881} 882 883// Context sets the context to be used in this call's Do method. Any 884// pending HTTP request will be aborted if the provided context is 885// canceled. 886func (c *UsersSshPublicKeysDeleteCall) Context(ctx context.Context) *UsersSshPublicKeysDeleteCall { 887 c.ctx_ = ctx 888 return c 889} 890 891// Header returns an http.Header that can be modified by the caller to 892// add HTTP headers to the request. 893func (c *UsersSshPublicKeysDeleteCall) Header() http.Header { 894 if c.header_ == nil { 895 c.header_ = make(http.Header) 896 } 897 return c.header_ 898} 899 900func (c *UsersSshPublicKeysDeleteCall) doRequest(alt string) (*http.Response, error) { 901 reqHeaders := make(http.Header) 902 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 903 for k, v := range c.header_ { 904 reqHeaders[k] = v 905 } 906 reqHeaders.Set("User-Agent", c.s.userAgent()) 907 var body io.Reader = nil 908 c.urlParams_.Set("alt", alt) 909 c.urlParams_.Set("prettyPrint", "false") 910 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") 911 urls += "?" + c.urlParams_.Encode() 912 req, err := http.NewRequest("DELETE", urls, body) 913 if err != nil { 914 return nil, err 915 } 916 req.Header = reqHeaders 917 googleapi.Expand(req.URL, map[string]string{ 918 "name": c.name, 919 }) 920 return gensupport.SendRequest(c.ctx_, c.s.client, req) 921} 922 923// Do executes the "oslogin.users.sshPublicKeys.delete" call. 924// Exactly one of *Empty or error will be non-nil. Any non-2xx status 925// code is an error. Response headers are in either 926// *Empty.ServerResponse.Header or (if a response was returned at all) 927// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 928// check whether the returned error was because http.StatusNotModified 929// was returned. 930func (c *UsersSshPublicKeysDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 931 gensupport.SetOptions(c.urlParams_, opts...) 932 res, err := c.doRequest("json") 933 if res != nil && res.StatusCode == http.StatusNotModified { 934 if res.Body != nil { 935 res.Body.Close() 936 } 937 return nil, &googleapi.Error{ 938 Code: res.StatusCode, 939 Header: res.Header, 940 } 941 } 942 if err != nil { 943 return nil, err 944 } 945 defer googleapi.CloseBody(res) 946 if err := googleapi.CheckResponse(res); err != nil { 947 return nil, err 948 } 949 ret := &Empty{ 950 ServerResponse: googleapi.ServerResponse{ 951 Header: res.Header, 952 HTTPStatusCode: res.StatusCode, 953 }, 954 } 955 target := &ret 956 if err := gensupport.DecodeResponse(target, res); err != nil { 957 return nil, err 958 } 959 return ret, nil 960 // { 961 // "description": "Deletes an SSH public key.", 962 // "flatPath": "v1beta/users/{usersId}/sshPublicKeys/{sshPublicKeysId}", 963 // "httpMethod": "DELETE", 964 // "id": "oslogin.users.sshPublicKeys.delete", 965 // "parameterOrder": [ 966 // "name" 967 // ], 968 // "parameters": { 969 // "name": { 970 // "description": "Required. The fingerprint of the public key to update. Public keys are identified by\ntheir SHA-256 fingerprint. The fingerprint of the public key is in format\n`users/{user}/sshPublicKeys/{fingerprint}`.", 971 // "location": "path", 972 // "pattern": "^users/[^/]+/sshPublicKeys/[^/]+$", 973 // "required": true, 974 // "type": "string" 975 // } 976 // }, 977 // "path": "v1beta/{+name}", 978 // "response": { 979 // "$ref": "Empty" 980 // }, 981 // "scopes": [ 982 // "https://www.googleapis.com/auth/cloud-platform", 983 // "https://www.googleapis.com/auth/compute" 984 // ] 985 // } 986 987} 988 989// method id "oslogin.users.sshPublicKeys.get": 990 991type UsersSshPublicKeysGetCall struct { 992 s *Service 993 name string 994 urlParams_ gensupport.URLParams 995 ifNoneMatch_ string 996 ctx_ context.Context 997 header_ http.Header 998} 999 1000// Get: Retrieves an SSH public key. 1001func (r *UsersSshPublicKeysService) Get(name string) *UsersSshPublicKeysGetCall { 1002 c := &UsersSshPublicKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1003 c.name = name 1004 return c 1005} 1006 1007// Fields allows partial responses to be retrieved. See 1008// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1009// for more information. 1010func (c *UsersSshPublicKeysGetCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysGetCall { 1011 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1012 return c 1013} 1014 1015// IfNoneMatch sets the optional parameter which makes the operation 1016// fail if the object's ETag matches the given value. This is useful for 1017// getting updates only after the object has changed since the last 1018// request. Use googleapi.IsNotModified to check whether the response 1019// error from Do is the result of In-None-Match. 1020func (c *UsersSshPublicKeysGetCall) IfNoneMatch(entityTag string) *UsersSshPublicKeysGetCall { 1021 c.ifNoneMatch_ = entityTag 1022 return c 1023} 1024 1025// Context sets the context to be used in this call's Do method. Any 1026// pending HTTP request will be aborted if the provided context is 1027// canceled. 1028func (c *UsersSshPublicKeysGetCall) Context(ctx context.Context) *UsersSshPublicKeysGetCall { 1029 c.ctx_ = ctx 1030 return c 1031} 1032 1033// Header returns an http.Header that can be modified by the caller to 1034// add HTTP headers to the request. 1035func (c *UsersSshPublicKeysGetCall) Header() http.Header { 1036 if c.header_ == nil { 1037 c.header_ = make(http.Header) 1038 } 1039 return c.header_ 1040} 1041 1042func (c *UsersSshPublicKeysGetCall) doRequest(alt string) (*http.Response, error) { 1043 reqHeaders := make(http.Header) 1044 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 1045 for k, v := range c.header_ { 1046 reqHeaders[k] = v 1047 } 1048 reqHeaders.Set("User-Agent", c.s.userAgent()) 1049 if c.ifNoneMatch_ != "" { 1050 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1051 } 1052 var body io.Reader = nil 1053 c.urlParams_.Set("alt", alt) 1054 c.urlParams_.Set("prettyPrint", "false") 1055 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") 1056 urls += "?" + c.urlParams_.Encode() 1057 req, err := http.NewRequest("GET", urls, body) 1058 if err != nil { 1059 return nil, err 1060 } 1061 req.Header = reqHeaders 1062 googleapi.Expand(req.URL, map[string]string{ 1063 "name": c.name, 1064 }) 1065 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1066} 1067 1068// Do executes the "oslogin.users.sshPublicKeys.get" call. 1069// Exactly one of *SshPublicKey or error will be non-nil. Any non-2xx 1070// status code is an error. Response headers are in either 1071// *SshPublicKey.ServerResponse.Header or (if a response was returned at 1072// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1073// to check whether the returned error was because 1074// http.StatusNotModified was returned. 1075func (c *UsersSshPublicKeysGetCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) { 1076 gensupport.SetOptions(c.urlParams_, opts...) 1077 res, err := c.doRequest("json") 1078 if res != nil && res.StatusCode == http.StatusNotModified { 1079 if res.Body != nil { 1080 res.Body.Close() 1081 } 1082 return nil, &googleapi.Error{ 1083 Code: res.StatusCode, 1084 Header: res.Header, 1085 } 1086 } 1087 if err != nil { 1088 return nil, err 1089 } 1090 defer googleapi.CloseBody(res) 1091 if err := googleapi.CheckResponse(res); err != nil { 1092 return nil, err 1093 } 1094 ret := &SshPublicKey{ 1095 ServerResponse: googleapi.ServerResponse{ 1096 Header: res.Header, 1097 HTTPStatusCode: res.StatusCode, 1098 }, 1099 } 1100 target := &ret 1101 if err := gensupport.DecodeResponse(target, res); err != nil { 1102 return nil, err 1103 } 1104 return ret, nil 1105 // { 1106 // "description": "Retrieves an SSH public key.", 1107 // "flatPath": "v1beta/users/{usersId}/sshPublicKeys/{sshPublicKeysId}", 1108 // "httpMethod": "GET", 1109 // "id": "oslogin.users.sshPublicKeys.get", 1110 // "parameterOrder": [ 1111 // "name" 1112 // ], 1113 // "parameters": { 1114 // "name": { 1115 // "description": "Required. The fingerprint of the public key to retrieve. Public keys are identified\nby their SHA-256 fingerprint. The fingerprint of the public key is in\nformat `users/{user}/sshPublicKeys/{fingerprint}`.", 1116 // "location": "path", 1117 // "pattern": "^users/[^/]+/sshPublicKeys/[^/]+$", 1118 // "required": true, 1119 // "type": "string" 1120 // } 1121 // }, 1122 // "path": "v1beta/{+name}", 1123 // "response": { 1124 // "$ref": "SshPublicKey" 1125 // }, 1126 // "scopes": [ 1127 // "https://www.googleapis.com/auth/cloud-platform", 1128 // "https://www.googleapis.com/auth/compute" 1129 // ] 1130 // } 1131 1132} 1133 1134// method id "oslogin.users.sshPublicKeys.patch": 1135 1136type UsersSshPublicKeysPatchCall struct { 1137 s *Service 1138 name string 1139 sshpublickey *SshPublicKey 1140 urlParams_ gensupport.URLParams 1141 ctx_ context.Context 1142 header_ http.Header 1143} 1144 1145// Patch: Updates an SSH public key and returns the profile information. 1146// This method 1147// supports patch semantics. 1148func (r *UsersSshPublicKeysService) Patch(name string, sshpublickey *SshPublicKey) *UsersSshPublicKeysPatchCall { 1149 c := &UsersSshPublicKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1150 c.name = name 1151 c.sshpublickey = sshpublickey 1152 return c 1153} 1154 1155// UpdateMask sets the optional parameter "updateMask": Mask to control 1156// which fields get updated. Updates all if not present. 1157func (c *UsersSshPublicKeysPatchCall) UpdateMask(updateMask string) *UsersSshPublicKeysPatchCall { 1158 c.urlParams_.Set("updateMask", updateMask) 1159 return c 1160} 1161 1162// Fields allows partial responses to be retrieved. See 1163// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1164// for more information. 1165func (c *UsersSshPublicKeysPatchCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysPatchCall { 1166 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1167 return c 1168} 1169 1170// Context sets the context to be used in this call's Do method. Any 1171// pending HTTP request will be aborted if the provided context is 1172// canceled. 1173func (c *UsersSshPublicKeysPatchCall) Context(ctx context.Context) *UsersSshPublicKeysPatchCall { 1174 c.ctx_ = ctx 1175 return c 1176} 1177 1178// Header returns an http.Header that can be modified by the caller to 1179// add HTTP headers to the request. 1180func (c *UsersSshPublicKeysPatchCall) Header() http.Header { 1181 if c.header_ == nil { 1182 c.header_ = make(http.Header) 1183 } 1184 return c.header_ 1185} 1186 1187func (c *UsersSshPublicKeysPatchCall) doRequest(alt string) (*http.Response, error) { 1188 reqHeaders := make(http.Header) 1189 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 1190 for k, v := range c.header_ { 1191 reqHeaders[k] = v 1192 } 1193 reqHeaders.Set("User-Agent", c.s.userAgent()) 1194 var body io.Reader = nil 1195 body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey) 1196 if err != nil { 1197 return nil, err 1198 } 1199 reqHeaders.Set("Content-Type", "application/json") 1200 c.urlParams_.Set("alt", alt) 1201 c.urlParams_.Set("prettyPrint", "false") 1202 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}") 1203 urls += "?" + c.urlParams_.Encode() 1204 req, err := http.NewRequest("PATCH", urls, body) 1205 if err != nil { 1206 return nil, err 1207 } 1208 req.Header = reqHeaders 1209 googleapi.Expand(req.URL, map[string]string{ 1210 "name": c.name, 1211 }) 1212 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1213} 1214 1215// Do executes the "oslogin.users.sshPublicKeys.patch" call. 1216// Exactly one of *SshPublicKey or error will be non-nil. Any non-2xx 1217// status code is an error. Response headers are in either 1218// *SshPublicKey.ServerResponse.Header or (if a response was returned at 1219// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1220// to check whether the returned error was because 1221// http.StatusNotModified was returned. 1222func (c *UsersSshPublicKeysPatchCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) { 1223 gensupport.SetOptions(c.urlParams_, opts...) 1224 res, err := c.doRequest("json") 1225 if res != nil && res.StatusCode == http.StatusNotModified { 1226 if res.Body != nil { 1227 res.Body.Close() 1228 } 1229 return nil, &googleapi.Error{ 1230 Code: res.StatusCode, 1231 Header: res.Header, 1232 } 1233 } 1234 if err != nil { 1235 return nil, err 1236 } 1237 defer googleapi.CloseBody(res) 1238 if err := googleapi.CheckResponse(res); err != nil { 1239 return nil, err 1240 } 1241 ret := &SshPublicKey{ 1242 ServerResponse: googleapi.ServerResponse{ 1243 Header: res.Header, 1244 HTTPStatusCode: res.StatusCode, 1245 }, 1246 } 1247 target := &ret 1248 if err := gensupport.DecodeResponse(target, res); err != nil { 1249 return nil, err 1250 } 1251 return ret, nil 1252 // { 1253 // "description": "Updates an SSH public key and returns the profile information. This method\nsupports patch semantics.", 1254 // "flatPath": "v1beta/users/{usersId}/sshPublicKeys/{sshPublicKeysId}", 1255 // "httpMethod": "PATCH", 1256 // "id": "oslogin.users.sshPublicKeys.patch", 1257 // "parameterOrder": [ 1258 // "name" 1259 // ], 1260 // "parameters": { 1261 // "name": { 1262 // "description": "Required. The fingerprint of the public key to update. Public keys are identified by\ntheir SHA-256 fingerprint. The fingerprint of the public key is in format\n`users/{user}/sshPublicKeys/{fingerprint}`.", 1263 // "location": "path", 1264 // "pattern": "^users/[^/]+/sshPublicKeys/[^/]+$", 1265 // "required": true, 1266 // "type": "string" 1267 // }, 1268 // "updateMask": { 1269 // "description": "Mask to control which fields get updated. Updates all if not present.", 1270 // "format": "google-fieldmask", 1271 // "location": "query", 1272 // "type": "string" 1273 // } 1274 // }, 1275 // "path": "v1beta/{+name}", 1276 // "request": { 1277 // "$ref": "SshPublicKey" 1278 // }, 1279 // "response": { 1280 // "$ref": "SshPublicKey" 1281 // }, 1282 // "scopes": [ 1283 // "https://www.googleapis.com/auth/cloud-platform", 1284 // "https://www.googleapis.com/auth/compute" 1285 // ] 1286 // } 1287 1288} 1289