1// Copyright 2021 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 apikeys provides access to the API Keys API. 8// 9// For product documentation, see: https://cloud.google.com/api-keys/docs 10// 11// Creating a client 12// 13// Usage example: 14// 15// import "google.golang.org/api/apikeys/v2" 16// ... 17// ctx := context.Background() 18// apikeysService, err := apikeys.NewService(ctx) 19// 20// In this example, Google Application Default Credentials are used for authentication. 21// 22// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 23// 24// Other authentication options 25// 26// By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes: 27// 28// apikeysService, err := apikeys.NewService(ctx, option.WithScopes(apikeys.CloudPlatformReadOnlyScope)) 29// 30// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey: 31// 32// apikeysService, err := apikeys.NewService(ctx, option.WithAPIKey("AIza...")) 33// 34// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource: 35// 36// config := &oauth2.Config{...} 37// // ... 38// token, err := config.Exchange(ctx, ...) 39// apikeysService, err := apikeys.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 40// 41// See https://godoc.org/google.golang.org/api/option/ for details on options. 42package apikeys // import "google.golang.org/api/apikeys/v2" 43 44import ( 45 "bytes" 46 "context" 47 "encoding/json" 48 "errors" 49 "fmt" 50 "io" 51 "net/http" 52 "net/url" 53 "strconv" 54 "strings" 55 56 googleapi "google.golang.org/api/googleapi" 57 gensupport "google.golang.org/api/internal/gensupport" 58 option "google.golang.org/api/option" 59 internaloption "google.golang.org/api/option/internaloption" 60 htransport "google.golang.org/api/transport/http" 61) 62 63// Always reference these packages, just in case the auto-generated code 64// below doesn't. 65var _ = bytes.NewBuffer 66var _ = strconv.Itoa 67var _ = fmt.Sprintf 68var _ = json.NewDecoder 69var _ = io.Copy 70var _ = url.Parse 71var _ = gensupport.MarshalJSON 72var _ = googleapi.Version 73var _ = errors.New 74var _ = strings.Replace 75var _ = context.Canceled 76var _ = internaloption.WithDefaultEndpoint 77 78const apiId = "apikeys:v2" 79const apiName = "apikeys" 80const apiVersion = "v2" 81const basePath = "https://apikeys.googleapis.com/" 82const mtlsBasePath = "https://apikeys.mtls.googleapis.com/" 83 84// OAuth2 scopes used by this API. 85const ( 86 // See, edit, configure, and delete your Google Cloud data and see the 87 // email address for your Google Account. 88 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 89 90 // View your data across Google Cloud services and see the email address 91 // of your Google Account 92 CloudPlatformReadOnlyScope = "https://www.googleapis.com/auth/cloud-platform.read-only" 93) 94 95// NewService creates a new Service. 96func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 97 scopesOption := option.WithScopes( 98 "https://www.googleapis.com/auth/cloud-platform", 99 "https://www.googleapis.com/auth/cloud-platform.read-only", 100 ) 101 // NOTE: prepend, so we don't override user-specified scopes. 102 opts = append([]option.ClientOption{scopesOption}, opts...) 103 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 104 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 105 client, endpoint, err := htransport.NewClient(ctx, opts...) 106 if err != nil { 107 return nil, err 108 } 109 s, err := New(client) 110 if err != nil { 111 return nil, err 112 } 113 if endpoint != "" { 114 s.BasePath = endpoint 115 } 116 return s, nil 117} 118 119// New creates a new Service. It uses the provided http.Client for requests. 120// 121// Deprecated: please use NewService instead. 122// To provide a custom HTTP client, use option.WithHTTPClient. 123// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 124func New(client *http.Client) (*Service, error) { 125 if client == nil { 126 return nil, errors.New("client is nil") 127 } 128 s := &Service{client: client, BasePath: basePath} 129 s.Keys = NewKeysService(s) 130 s.Operations = NewOperationsService(s) 131 s.Projects = NewProjectsService(s) 132 return s, nil 133} 134 135type Service struct { 136 client *http.Client 137 BasePath string // API endpoint base URL 138 UserAgent string // optional additional User-Agent fragment 139 140 Keys *KeysService 141 142 Operations *OperationsService 143 144 Projects *ProjectsService 145} 146 147func (s *Service) userAgent() string { 148 if s.UserAgent == "" { 149 return googleapi.UserAgent 150 } 151 return googleapi.UserAgent + " " + s.UserAgent 152} 153 154func NewKeysService(s *Service) *KeysService { 155 rs := &KeysService{s: s} 156 return rs 157} 158 159type KeysService struct { 160 s *Service 161} 162 163func NewOperationsService(s *Service) *OperationsService { 164 rs := &OperationsService{s: s} 165 return rs 166} 167 168type OperationsService struct { 169 s *Service 170} 171 172func NewProjectsService(s *Service) *ProjectsService { 173 rs := &ProjectsService{s: s} 174 rs.Locations = NewProjectsLocationsService(s) 175 return rs 176} 177 178type ProjectsService struct { 179 s *Service 180 181 Locations *ProjectsLocationsService 182} 183 184func NewProjectsLocationsService(s *Service) *ProjectsLocationsService { 185 rs := &ProjectsLocationsService{s: s} 186 rs.Keys = NewProjectsLocationsKeysService(s) 187 return rs 188} 189 190type ProjectsLocationsService struct { 191 s *Service 192 193 Keys *ProjectsLocationsKeysService 194} 195 196func NewProjectsLocationsKeysService(s *Service) *ProjectsLocationsKeysService { 197 rs := &ProjectsLocationsKeysService{s: s} 198 return rs 199} 200 201type ProjectsLocationsKeysService struct { 202 s *Service 203} 204 205// Operation: This resource represents a long-running operation that is 206// the result of a network API call. 207type Operation struct { 208 // Done: If the value is `false`, it means the operation is still in 209 // progress. If `true`, the operation is completed, and either `error` 210 // or `response` is available. 211 Done bool `json:"done,omitempty"` 212 213 // Error: The error result of the operation in case of failure or 214 // cancellation. 215 Error *Status `json:"error,omitempty"` 216 217 // Metadata: Service-specific metadata associated with the operation. It 218 // typically contains progress information and common metadata such as 219 // create time. Some services might not provide such metadata. Any 220 // method that returns a long-running operation should document the 221 // metadata type, if any. 222 Metadata googleapi.RawMessage `json:"metadata,omitempty"` 223 224 // Name: The server-assigned name, which is only unique within the same 225 // service that originally returns it. If you use the default HTTP 226 // mapping, the `name` should be a resource name ending with 227 // `operations/{unique_id}`. 228 Name string `json:"name,omitempty"` 229 230 // Response: The normal response of the operation in case of success. If 231 // the original method returns no data on success, such as `Delete`, the 232 // response is `google.protobuf.Empty`. If the original method is 233 // standard `Get`/`Create`/`Update`, the response should be the 234 // resource. For other methods, the response should have the type 235 // `XxxResponse`, where `Xxx` is the original method name. For example, 236 // if the original method name is `TakeSnapshot()`, the inferred 237 // response type is `TakeSnapshotResponse`. 238 Response googleapi.RawMessage `json:"response,omitempty"` 239 240 // ServerResponse contains the HTTP response code and headers from the 241 // server. 242 googleapi.ServerResponse `json:"-"` 243 244 // ForceSendFields is a list of field names (e.g. "Done") to 245 // unconditionally include in API requests. By default, fields with 246 // empty or default values are omitted from API requests. However, any 247 // non-pointer, non-interface field appearing in ForceSendFields will be 248 // sent to the server regardless of whether the field is empty or not. 249 // This may be used to include empty fields in Patch requests. 250 ForceSendFields []string `json:"-"` 251 252 // NullFields is a list of field names (e.g. "Done") to include in API 253 // requests with the JSON null value. By default, fields with empty 254 // values are omitted from API requests. However, any field with an 255 // empty value appearing in NullFields will be sent to the server as 256 // null. It is an error if a field in this list has a non-empty value. 257 // This may be used to include null fields in Patch requests. 258 NullFields []string `json:"-"` 259} 260 261func (s *Operation) MarshalJSON() ([]byte, error) { 262 type NoMethod Operation 263 raw := NoMethod(*s) 264 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 265} 266 267// Status: The `Status` type defines a logical error model that is 268// suitable for different programming environments, including REST APIs 269// and RPC APIs. It is used by gRPC (https://github.com/grpc). Each 270// `Status` message contains three pieces of data: error code, error 271// message, and error details. You can find out more about this error 272// model and how to work with it in the API Design Guide 273// (https://cloud.google.com/apis/design/errors). 274type Status struct { 275 // Code: The status code, which should be an enum value of 276 // google.rpc.Code. 277 Code int64 `json:"code,omitempty"` 278 279 // Details: A list of messages that carry the error details. There is a 280 // common set of message types for APIs to use. 281 Details []googleapi.RawMessage `json:"details,omitempty"` 282 283 // Message: A developer-facing error message, which should be in 284 // English. Any user-facing error message should be localized and sent 285 // in the google.rpc.Status.details field, or localized by the client. 286 Message string `json:"message,omitempty"` 287 288 // ForceSendFields is a list of field names (e.g. "Code") to 289 // unconditionally include in API requests. By default, fields with 290 // empty or default values are omitted from API requests. However, any 291 // non-pointer, non-interface field appearing in ForceSendFields will be 292 // sent to the server regardless of whether the field is empty or not. 293 // This may be used to include empty fields in Patch requests. 294 ForceSendFields []string `json:"-"` 295 296 // NullFields is a list of field names (e.g. "Code") to include in API 297 // requests with the JSON null value. By default, fields with empty 298 // values are omitted from API requests. However, any field with an 299 // empty value appearing in NullFields will be sent to the server as 300 // null. It is an error if a field in this list has a non-empty value. 301 // This may be used to include null fields in Patch requests. 302 NullFields []string `json:"-"` 303} 304 305func (s *Status) MarshalJSON() ([]byte, error) { 306 type NoMethod Status 307 raw := NoMethod(*s) 308 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 309} 310 311// V2AndroidApplication: Identifier of an Android application for key 312// use. 313type V2AndroidApplication struct { 314 // PackageName: The package name of the application. 315 PackageName string `json:"packageName,omitempty"` 316 317 // Sha1Fingerprint: The SHA1 fingerprint of the application. For 318 // example, both sha1 formats are acceptable : 319 // DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09 or 320 // DA39A3EE5E6B4B0D3255BFEF95601890AFD80709. Output format is the 321 // latter. 322 Sha1Fingerprint string `json:"sha1Fingerprint,omitempty"` 323 324 // ForceSendFields is a list of field names (e.g. "PackageName") to 325 // unconditionally include in API requests. By default, fields with 326 // empty or default values are omitted from API requests. However, any 327 // non-pointer, non-interface field appearing in ForceSendFields will be 328 // sent to the server regardless of whether the field is empty or not. 329 // This may be used to include empty fields in Patch requests. 330 ForceSendFields []string `json:"-"` 331 332 // NullFields is a list of field names (e.g. "PackageName") to include 333 // in API requests with the JSON null value. By default, fields with 334 // empty values are omitted from API requests. However, any field with 335 // an empty value appearing in NullFields will be sent to the server as 336 // null. It is an error if a field in this list has a non-empty value. 337 // This may be used to include null fields in Patch requests. 338 NullFields []string `json:"-"` 339} 340 341func (s *V2AndroidApplication) MarshalJSON() ([]byte, error) { 342 type NoMethod V2AndroidApplication 343 raw := NoMethod(*s) 344 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 345} 346 347// V2AndroidKeyRestrictions: The Android apps that are allowed to use 348// the key. 349type V2AndroidKeyRestrictions struct { 350 // AllowedApplications: A list of Android applications that are allowed 351 // to make API calls with this key. 352 AllowedApplications []*V2AndroidApplication `json:"allowedApplications,omitempty"` 353 354 // ForceSendFields is a list of field names (e.g. "AllowedApplications") 355 // to unconditionally include in API requests. By default, fields with 356 // empty or default values are omitted from API requests. However, any 357 // non-pointer, non-interface field appearing in ForceSendFields will be 358 // sent to the server regardless of whether the field is empty or not. 359 // This may be used to include empty fields in Patch requests. 360 ForceSendFields []string `json:"-"` 361 362 // NullFields is a list of field names (e.g. "AllowedApplications") to 363 // include in API requests with the JSON null value. By default, fields 364 // with empty values are omitted from API requests. However, any field 365 // with an empty value appearing in NullFields will be sent to the 366 // server as null. It is an error if a field in this list has a 367 // non-empty value. This may be used to include null fields in Patch 368 // requests. 369 NullFields []string `json:"-"` 370} 371 372func (s *V2AndroidKeyRestrictions) MarshalJSON() ([]byte, error) { 373 type NoMethod V2AndroidKeyRestrictions 374 raw := NoMethod(*s) 375 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 376} 377 378// V2ApiTarget: A restriction for a specific service and optionally one 379// or multiple specific methods. Both fields are case insensitive. 380type V2ApiTarget struct { 381 // Methods: Optional. List of one or more methods that can be called. If 382 // empty, all methods for the service are allowed. A wildcard (*) can be 383 // used as the last symbol. Valid examples: 384 // `google.cloud.translate.v2.TranslateService.GetSupportedLanguage` 385 // `TranslateText` `Get*` `translate.googleapis.com.Get*` 386 Methods []string `json:"methods,omitempty"` 387 388 // Service: The service for this restriction. It should be the canonical 389 // service name, for example: `translate.googleapis.com`. You can use 390 // `gcloud services list` (/sdk/gcloud/reference/services/list) to get a 391 // list of services that are enabled in the project. 392 Service string `json:"service,omitempty"` 393 394 // ForceSendFields is a list of field names (e.g. "Methods") to 395 // unconditionally include in API requests. By default, fields with 396 // empty or default values are omitted from API requests. However, any 397 // non-pointer, non-interface field appearing in ForceSendFields will be 398 // sent to the server regardless of whether the field is empty or not. 399 // This may be used to include empty fields in Patch requests. 400 ForceSendFields []string `json:"-"` 401 402 // NullFields is a list of field names (e.g. "Methods") to include in 403 // API requests with the JSON null value. By default, fields with empty 404 // values are omitted from API requests. However, any field with an 405 // empty value appearing in NullFields will be sent to the server as 406 // null. It is an error if a field in this list has a non-empty value. 407 // This may be used to include null fields in Patch requests. 408 NullFields []string `json:"-"` 409} 410 411func (s *V2ApiTarget) MarshalJSON() ([]byte, error) { 412 type NoMethod V2ApiTarget 413 raw := NoMethod(*s) 414 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 415} 416 417// V2BrowserKeyRestrictions: The HTTP referrers (websites) that are 418// allowed to use the key. 419type V2BrowserKeyRestrictions struct { 420 // AllowedReferrers: A list of regular expressions for the referrer URLs 421 // that are allowed to make API calls with this key. 422 AllowedReferrers []string `json:"allowedReferrers,omitempty"` 423 424 // ForceSendFields is a list of field names (e.g. "AllowedReferrers") to 425 // unconditionally include in API requests. By default, fields with 426 // empty or default values are omitted from API requests. However, any 427 // non-pointer, non-interface field appearing in ForceSendFields will be 428 // sent to the server regardless of whether the field is empty or not. 429 // This may be used to include empty fields in Patch requests. 430 ForceSendFields []string `json:"-"` 431 432 // NullFields is a list of field names (e.g. "AllowedReferrers") to 433 // include in API requests with the JSON null value. By default, fields 434 // with empty values are omitted from API requests. However, any field 435 // with an empty value appearing in NullFields will be sent to the 436 // server as null. It is an error if a field in this list has a 437 // non-empty value. This may be used to include null fields in Patch 438 // requests. 439 NullFields []string `json:"-"` 440} 441 442func (s *V2BrowserKeyRestrictions) MarshalJSON() ([]byte, error) { 443 type NoMethod V2BrowserKeyRestrictions 444 raw := NoMethod(*s) 445 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 446} 447 448// V2CloneKeyRequest: Request message for `CloneKey` method. 449type V2CloneKeyRequest struct { 450 // KeyId: User specified key id (optional). If specified, it will become 451 // the final component of the key resource name. The id must be unique 452 // within the project, must conform with RFC-1034, is restricted to 453 // lower-cased letters, and has a maximum length of 63 characters. In 454 // another word, the id must match the regular expression: 455 // `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id must NOT be a UUID-like 456 // string. 457 KeyId string `json:"keyId,omitempty"` 458 459 // ForceSendFields is a list of field names (e.g. "KeyId") to 460 // unconditionally include in API requests. By default, fields with 461 // empty or default values are omitted from API requests. However, any 462 // non-pointer, non-interface field appearing in ForceSendFields will be 463 // sent to the server regardless of whether the field is empty or not. 464 // This may be used to include empty fields in Patch requests. 465 ForceSendFields []string `json:"-"` 466 467 // NullFields is a list of field names (e.g. "KeyId") to include in API 468 // requests with the JSON null value. By default, fields with empty 469 // values are omitted from API requests. However, any field with an 470 // empty value appearing in NullFields will be sent to the server as 471 // null. It is an error if a field in this list has a non-empty value. 472 // This may be used to include null fields in Patch requests. 473 NullFields []string `json:"-"` 474} 475 476func (s *V2CloneKeyRequest) MarshalJSON() ([]byte, error) { 477 type NoMethod V2CloneKeyRequest 478 raw := NoMethod(*s) 479 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 480} 481 482// V2GetKeyStringResponse: Response message for `GetKeyString` method. 483type V2GetKeyStringResponse struct { 484 // KeyString: An encrypted and signed value of the key. 485 KeyString string `json:"keyString,omitempty"` 486 487 // ServerResponse contains the HTTP response code and headers from the 488 // server. 489 googleapi.ServerResponse `json:"-"` 490 491 // ForceSendFields is a list of field names (e.g. "KeyString") to 492 // unconditionally include in API requests. By default, fields with 493 // empty or default values are omitted from API requests. However, any 494 // non-pointer, non-interface field appearing in ForceSendFields will be 495 // sent to the server regardless of whether the field is empty or not. 496 // This may be used to include empty fields in Patch requests. 497 ForceSendFields []string `json:"-"` 498 499 // NullFields is a list of field names (e.g. "KeyString") to include in 500 // API requests with the JSON null value. By default, fields with empty 501 // values are omitted from API requests. However, any field with an 502 // empty value appearing in NullFields will be sent to the server as 503 // null. It is an error if a field in this list has a non-empty value. 504 // This may be used to include null fields in Patch requests. 505 NullFields []string `json:"-"` 506} 507 508func (s *V2GetKeyStringResponse) MarshalJSON() ([]byte, error) { 509 type NoMethod V2GetKeyStringResponse 510 raw := NoMethod(*s) 511 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 512} 513 514// V2IosKeyRestrictions: The iOS apps that are allowed to use the key. 515type V2IosKeyRestrictions struct { 516 // AllowedBundleIds: A list of bundle IDs that are allowed when making 517 // API calls with this key. 518 AllowedBundleIds []string `json:"allowedBundleIds,omitempty"` 519 520 // ForceSendFields is a list of field names (e.g. "AllowedBundleIds") to 521 // unconditionally include in API requests. By default, fields with 522 // empty or default values are omitted from API requests. However, any 523 // non-pointer, non-interface field appearing in ForceSendFields will be 524 // sent to the server regardless of whether the field is empty or not. 525 // This may be used to include empty fields in Patch requests. 526 ForceSendFields []string `json:"-"` 527 528 // NullFields is a list of field names (e.g. "AllowedBundleIds") to 529 // include in API requests with the JSON null value. By default, fields 530 // with empty values are omitted from API requests. However, any field 531 // with an empty value appearing in NullFields will be sent to the 532 // server as null. It is an error if a field in this list has a 533 // non-empty value. This may be used to include null fields in Patch 534 // requests. 535 NullFields []string `json:"-"` 536} 537 538func (s *V2IosKeyRestrictions) MarshalJSON() ([]byte, error) { 539 type NoMethod V2IosKeyRestrictions 540 raw := NoMethod(*s) 541 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 542} 543 544// V2Key: The representation of a key managed by the API Keys API. 545type V2Key struct { 546 // CreateTime: Output only. A timestamp identifying the time this key 547 // was originally created. 548 CreateTime string `json:"createTime,omitempty"` 549 550 // DeleteTime: Output only. A timestamp when this key was deleted. If 551 // the resource is not deleted, this must be empty. 552 DeleteTime string `json:"deleteTime,omitempty"` 553 554 // DisplayName: Human-readable display name of this key that you can 555 // modify. The maximum length is 63 characters. 556 DisplayName string `json:"displayName,omitempty"` 557 558 // Etag: Output only. A checksum computed by the server based on the 559 // current value of the Key resource. This may be sent on update and 560 // delete requests to ensure the client has an up-to-date value before 561 // proceeding. 562 Etag string `json:"etag,omitempty"` 563 564 // KeyString: Output only. An encrypted and signed value held by this 565 // key. This field can be accessed only through the `GetKeyString` 566 // method. 567 KeyString string `json:"keyString,omitempty"` 568 569 // Name: Output only. The resource name of the key. The `name` has the 570 // form: `projects//locations/global/keys/`. For example: 571 // `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3 572 // 855ee9b5dd2` NOTE: Key is a global resource; hence the only supported 573 // value for location is `global`. 574 Name string `json:"name,omitempty"` 575 576 // Restrictions: Key restrictions. 577 Restrictions *V2Restrictions `json:"restrictions,omitempty"` 578 579 // Uid: Output only. Unique id in UUID4 format. 580 Uid string `json:"uid,omitempty"` 581 582 // UpdateTime: Output only. A timestamp identifying the time this key 583 // was last updated. 584 UpdateTime string `json:"updateTime,omitempty"` 585 586 // ServerResponse contains the HTTP response code and headers from the 587 // server. 588 googleapi.ServerResponse `json:"-"` 589 590 // ForceSendFields is a list of field names (e.g. "CreateTime") to 591 // unconditionally include in API requests. By default, fields with 592 // empty or default values are omitted from API requests. However, any 593 // non-pointer, non-interface field appearing in ForceSendFields will be 594 // sent to the server regardless of whether the field is empty or not. 595 // This may be used to include empty fields in Patch requests. 596 ForceSendFields []string `json:"-"` 597 598 // NullFields is a list of field names (e.g. "CreateTime") to include in 599 // API requests with the JSON null value. By default, fields with empty 600 // values are omitted from API requests. However, any field with an 601 // empty value appearing in NullFields will be sent to the server as 602 // null. It is an error if a field in this list has a non-empty value. 603 // This may be used to include null fields in Patch requests. 604 NullFields []string `json:"-"` 605} 606 607func (s *V2Key) MarshalJSON() ([]byte, error) { 608 type NoMethod V2Key 609 raw := NoMethod(*s) 610 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 611} 612 613// V2ListKeysResponse: Response message for `ListKeys` method. 614type V2ListKeysResponse struct { 615 // Keys: A list of API keys. 616 Keys []*V2Key `json:"keys,omitempty"` 617 618 // NextPageToken: The pagination token for the next page of results. 619 NextPageToken string `json:"nextPageToken,omitempty"` 620 621 // ServerResponse contains the HTTP response code and headers from the 622 // server. 623 googleapi.ServerResponse `json:"-"` 624 625 // ForceSendFields is a list of field names (e.g. "Keys") to 626 // unconditionally include in API requests. By default, fields with 627 // empty or default values are omitted from API requests. However, any 628 // non-pointer, non-interface field appearing in ForceSendFields will be 629 // sent to the server regardless of whether the field is empty or not. 630 // This may be used to include empty fields in Patch requests. 631 ForceSendFields []string `json:"-"` 632 633 // NullFields is a list of field names (e.g. "Keys") to include in API 634 // requests with the JSON null value. By default, fields with empty 635 // values are omitted from API requests. However, any field with an 636 // empty value appearing in NullFields will be sent to the server as 637 // null. It is an error if a field in this list has a non-empty value. 638 // This may be used to include null fields in Patch requests. 639 NullFields []string `json:"-"` 640} 641 642func (s *V2ListKeysResponse) MarshalJSON() ([]byte, error) { 643 type NoMethod V2ListKeysResponse 644 raw := NoMethod(*s) 645 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 646} 647 648// V2LookupKeyResponse: Response message for `LookupKey` method. 649type V2LookupKeyResponse struct { 650 // Name: The resource name of the API key. If the API key has been 651 // purged, resource name is empty. 652 Name string `json:"name,omitempty"` 653 654 // Parent: The project that owns the key with the value specified in the 655 // request. 656 Parent string `json:"parent,omitempty"` 657 658 // ServerResponse contains the HTTP response code and headers from the 659 // server. 660 googleapi.ServerResponse `json:"-"` 661 662 // ForceSendFields is a list of field names (e.g. "Name") to 663 // unconditionally include in API requests. By default, fields with 664 // empty or default values are omitted from API requests. However, any 665 // non-pointer, non-interface field appearing in ForceSendFields will be 666 // sent to the server regardless of whether the field is empty or not. 667 // This may be used to include empty fields in Patch requests. 668 ForceSendFields []string `json:"-"` 669 670 // NullFields is a list of field names (e.g. "Name") to include in API 671 // requests with the JSON null value. By default, fields with empty 672 // values are omitted from API requests. However, any field with an 673 // empty value appearing in NullFields will be sent to the server as 674 // null. It is an error if a field in this list has a non-empty value. 675 // This may be used to include null fields in Patch requests. 676 NullFields []string `json:"-"` 677} 678 679func (s *V2LookupKeyResponse) MarshalJSON() ([]byte, error) { 680 type NoMethod V2LookupKeyResponse 681 raw := NoMethod(*s) 682 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 683} 684 685// V2Restrictions: Describes the restrictions on the key. 686type V2Restrictions struct { 687 // AndroidKeyRestrictions: The Android apps that are allowed to use the 688 // key. 689 AndroidKeyRestrictions *V2AndroidKeyRestrictions `json:"androidKeyRestrictions,omitempty"` 690 691 // ApiTargets: A restriction for a specific service and optionally one 692 // or more specific methods. Requests are allowed if they match any of 693 // these restrictions. If no restrictions are specified, all targets are 694 // allowed. 695 ApiTargets []*V2ApiTarget `json:"apiTargets,omitempty"` 696 697 // BrowserKeyRestrictions: The HTTP referrers (websites) that are 698 // allowed to use the key. 699 BrowserKeyRestrictions *V2BrowserKeyRestrictions `json:"browserKeyRestrictions,omitempty"` 700 701 // IosKeyRestrictions: The iOS apps that are allowed to use the key. 702 IosKeyRestrictions *V2IosKeyRestrictions `json:"iosKeyRestrictions,omitempty"` 703 704 // ServerKeyRestrictions: The IP addresses of callers that are allowed 705 // to use the key. 706 ServerKeyRestrictions *V2ServerKeyRestrictions `json:"serverKeyRestrictions,omitempty"` 707 708 // ForceSendFields is a list of field names (e.g. 709 // "AndroidKeyRestrictions") to unconditionally include in API requests. 710 // By default, fields with empty or default values are omitted from API 711 // requests. However, any non-pointer, non-interface field appearing in 712 // ForceSendFields will be sent to the server regardless of whether the 713 // field is empty or not. This may be used to include empty fields in 714 // Patch requests. 715 ForceSendFields []string `json:"-"` 716 717 // NullFields is a list of field names (e.g. "AndroidKeyRestrictions") 718 // to include in API requests with the JSON null value. By default, 719 // fields with empty values are omitted from API requests. However, any 720 // field with an empty value appearing in NullFields will be sent to the 721 // server as null. It is an error if a field in this list has a 722 // non-empty value. This may be used to include null fields in Patch 723 // requests. 724 NullFields []string `json:"-"` 725} 726 727func (s *V2Restrictions) MarshalJSON() ([]byte, error) { 728 type NoMethod V2Restrictions 729 raw := NoMethod(*s) 730 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 731} 732 733// V2ServerKeyRestrictions: The IP addresses of callers that are allowed 734// to use the key. 735type V2ServerKeyRestrictions struct { 736 // AllowedIps: A list of the caller IP addresses that are allowed to 737 // make API calls with this key. 738 AllowedIps []string `json:"allowedIps,omitempty"` 739 740 // ForceSendFields is a list of field names (e.g. "AllowedIps") to 741 // unconditionally include in API requests. By default, fields with 742 // empty or default values are omitted from API requests. However, any 743 // non-pointer, non-interface field appearing in ForceSendFields will be 744 // sent to the server regardless of whether the field is empty or not. 745 // This may be used to include empty fields in Patch requests. 746 ForceSendFields []string `json:"-"` 747 748 // NullFields is a list of field names (e.g. "AllowedIps") to include in 749 // API requests with the JSON null value. By default, fields with empty 750 // values are omitted from API requests. However, any field with an 751 // empty value appearing in NullFields will be sent to the server as 752 // null. It is an error if a field in this list has a non-empty value. 753 // This may be used to include null fields in Patch requests. 754 NullFields []string `json:"-"` 755} 756 757func (s *V2ServerKeyRestrictions) MarshalJSON() ([]byte, error) { 758 type NoMethod V2ServerKeyRestrictions 759 raw := NoMethod(*s) 760 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 761} 762 763// V2UndeleteKeyRequest: Request message for `UndeleteKey` method. 764type V2UndeleteKeyRequest struct { 765} 766 767// method id "apikeys.keys.lookupKey": 768 769type KeysLookupKeyCall struct { 770 s *Service 771 urlParams_ gensupport.URLParams 772 ifNoneMatch_ string 773 ctx_ context.Context 774 header_ http.Header 775} 776 777// LookupKey: Find the parent project and resource name of the API key 778// that matches the key string in the request. If the API key has been 779// purged, resource name will not be set. The service account must have 780// the `apikeys.keys.lookup` permission on the parent project. 781func (r *KeysService) LookupKey() *KeysLookupKeyCall { 782 c := &KeysLookupKeyCall{s: r.s, urlParams_: make(gensupport.URLParams)} 783 return c 784} 785 786// KeyString sets the optional parameter "keyString": Required. Finds 787// the project that owns the key string value. 788func (c *KeysLookupKeyCall) KeyString(keyString string) *KeysLookupKeyCall { 789 c.urlParams_.Set("keyString", keyString) 790 return c 791} 792 793// Fields allows partial responses to be retrieved. See 794// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 795// for more information. 796func (c *KeysLookupKeyCall) Fields(s ...googleapi.Field) *KeysLookupKeyCall { 797 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 798 return c 799} 800 801// IfNoneMatch sets the optional parameter which makes the operation 802// fail if the object's ETag matches the given value. This is useful for 803// getting updates only after the object has changed since the last 804// request. Use googleapi.IsNotModified to check whether the response 805// error from Do is the result of In-None-Match. 806func (c *KeysLookupKeyCall) IfNoneMatch(entityTag string) *KeysLookupKeyCall { 807 c.ifNoneMatch_ = entityTag 808 return c 809} 810 811// Context sets the context to be used in this call's Do method. Any 812// pending HTTP request will be aborted if the provided context is 813// canceled. 814func (c *KeysLookupKeyCall) Context(ctx context.Context) *KeysLookupKeyCall { 815 c.ctx_ = ctx 816 return c 817} 818 819// Header returns an http.Header that can be modified by the caller to 820// add HTTP headers to the request. 821func (c *KeysLookupKeyCall) Header() http.Header { 822 if c.header_ == nil { 823 c.header_ = make(http.Header) 824 } 825 return c.header_ 826} 827 828func (c *KeysLookupKeyCall) doRequest(alt string) (*http.Response, error) { 829 reqHeaders := make(http.Header) 830 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 831 for k, v := range c.header_ { 832 reqHeaders[k] = v 833 } 834 reqHeaders.Set("User-Agent", c.s.userAgent()) 835 if c.ifNoneMatch_ != "" { 836 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 837 } 838 var body io.Reader = nil 839 c.urlParams_.Set("alt", alt) 840 c.urlParams_.Set("prettyPrint", "false") 841 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/keys:lookupKey") 842 urls += "?" + c.urlParams_.Encode() 843 req, err := http.NewRequest("GET", urls, body) 844 if err != nil { 845 return nil, err 846 } 847 req.Header = reqHeaders 848 return gensupport.SendRequest(c.ctx_, c.s.client, req) 849} 850 851// Do executes the "apikeys.keys.lookupKey" call. 852// Exactly one of *V2LookupKeyResponse or error will be non-nil. Any 853// non-2xx status code is an error. Response headers are in either 854// *V2LookupKeyResponse.ServerResponse.Header or (if a response was 855// returned at all) in error.(*googleapi.Error).Header. Use 856// googleapi.IsNotModified to check whether the returned error was 857// because http.StatusNotModified was returned. 858func (c *KeysLookupKeyCall) Do(opts ...googleapi.CallOption) (*V2LookupKeyResponse, error) { 859 gensupport.SetOptions(c.urlParams_, opts...) 860 res, err := c.doRequest("json") 861 if res != nil && res.StatusCode == http.StatusNotModified { 862 if res.Body != nil { 863 res.Body.Close() 864 } 865 return nil, &googleapi.Error{ 866 Code: res.StatusCode, 867 Header: res.Header, 868 } 869 } 870 if err != nil { 871 return nil, err 872 } 873 defer googleapi.CloseBody(res) 874 if err := googleapi.CheckResponse(res); err != nil { 875 return nil, err 876 } 877 ret := &V2LookupKeyResponse{ 878 ServerResponse: googleapi.ServerResponse{ 879 Header: res.Header, 880 HTTPStatusCode: res.StatusCode, 881 }, 882 } 883 target := &ret 884 if err := gensupport.DecodeResponse(target, res); err != nil { 885 return nil, err 886 } 887 return ret, nil 888 // { 889 // "description": "Find the parent project and resource name of the API key that matches the key string in the request. If the API key has been purged, resource name will not be set. The service account must have the `apikeys.keys.lookup` permission on the parent project.", 890 // "flatPath": "v2/keys:lookupKey", 891 // "httpMethod": "GET", 892 // "id": "apikeys.keys.lookupKey", 893 // "parameterOrder": [], 894 // "parameters": { 895 // "keyString": { 896 // "description": "Required. Finds the project that owns the key string value.", 897 // "location": "query", 898 // "type": "string" 899 // } 900 // }, 901 // "path": "v2/keys:lookupKey", 902 // "response": { 903 // "$ref": "V2LookupKeyResponse" 904 // }, 905 // "scopes": [ 906 // "https://www.googleapis.com/auth/cloud-platform", 907 // "https://www.googleapis.com/auth/cloud-platform.read-only" 908 // ] 909 // } 910 911} 912 913// method id "apikeys.operations.get": 914 915type OperationsGetCall struct { 916 s *Service 917 name string 918 urlParams_ gensupport.URLParams 919 ifNoneMatch_ string 920 ctx_ context.Context 921 header_ http.Header 922} 923 924// Get: Gets the latest state of a long-running operation. Clients can 925// use this method to poll the operation result at intervals as 926// recommended by the API service. 927// 928// - name: The name of the operation resource. 929func (r *OperationsService) Get(name string) *OperationsGetCall { 930 c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 931 c.name = name 932 return c 933} 934 935// Fields allows partial responses to be retrieved. See 936// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 937// for more information. 938func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall { 939 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 940 return c 941} 942 943// IfNoneMatch sets the optional parameter which makes the operation 944// fail if the object's ETag matches the given value. This is useful for 945// getting updates only after the object has changed since the last 946// request. Use googleapi.IsNotModified to check whether the response 947// error from Do is the result of In-None-Match. 948func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall { 949 c.ifNoneMatch_ = entityTag 950 return c 951} 952 953// Context sets the context to be used in this call's Do method. Any 954// pending HTTP request will be aborted if the provided context is 955// canceled. 956func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall { 957 c.ctx_ = ctx 958 return c 959} 960 961// Header returns an http.Header that can be modified by the caller to 962// add HTTP headers to the request. 963func (c *OperationsGetCall) Header() http.Header { 964 if c.header_ == nil { 965 c.header_ = make(http.Header) 966 } 967 return c.header_ 968} 969 970func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { 971 reqHeaders := make(http.Header) 972 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 973 for k, v := range c.header_ { 974 reqHeaders[k] = v 975 } 976 reqHeaders.Set("User-Agent", c.s.userAgent()) 977 if c.ifNoneMatch_ != "" { 978 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 979 } 980 var body io.Reader = nil 981 c.urlParams_.Set("alt", alt) 982 c.urlParams_.Set("prettyPrint", "false") 983 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}") 984 urls += "?" + c.urlParams_.Encode() 985 req, err := http.NewRequest("GET", urls, body) 986 if err != nil { 987 return nil, err 988 } 989 req.Header = reqHeaders 990 googleapi.Expand(req.URL, map[string]string{ 991 "name": c.name, 992 }) 993 return gensupport.SendRequest(c.ctx_, c.s.client, req) 994} 995 996// Do executes the "apikeys.operations.get" call. 997// Exactly one of *Operation or error will be non-nil. Any non-2xx 998// status code is an error. Response headers are in either 999// *Operation.ServerResponse.Header or (if a response was returned at 1000// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1001// to check whether the returned error was because 1002// http.StatusNotModified was returned. 1003func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1004 gensupport.SetOptions(c.urlParams_, opts...) 1005 res, err := c.doRequest("json") 1006 if res != nil && res.StatusCode == http.StatusNotModified { 1007 if res.Body != nil { 1008 res.Body.Close() 1009 } 1010 return nil, &googleapi.Error{ 1011 Code: res.StatusCode, 1012 Header: res.Header, 1013 } 1014 } 1015 if err != nil { 1016 return nil, err 1017 } 1018 defer googleapi.CloseBody(res) 1019 if err := googleapi.CheckResponse(res); err != nil { 1020 return nil, err 1021 } 1022 ret := &Operation{ 1023 ServerResponse: googleapi.ServerResponse{ 1024 Header: res.Header, 1025 HTTPStatusCode: res.StatusCode, 1026 }, 1027 } 1028 target := &ret 1029 if err := gensupport.DecodeResponse(target, res); err != nil { 1030 return nil, err 1031 } 1032 return ret, nil 1033 // { 1034 // "description": "Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.", 1035 // "flatPath": "v2/operations/{operationsId}", 1036 // "httpMethod": "GET", 1037 // "id": "apikeys.operations.get", 1038 // "parameterOrder": [ 1039 // "name" 1040 // ], 1041 // "parameters": { 1042 // "name": { 1043 // "description": "The name of the operation resource.", 1044 // "location": "path", 1045 // "pattern": "^operations/[^/]+$", 1046 // "required": true, 1047 // "type": "string" 1048 // } 1049 // }, 1050 // "path": "v2/{+name}", 1051 // "response": { 1052 // "$ref": "Operation" 1053 // }, 1054 // "scopes": [ 1055 // "https://www.googleapis.com/auth/cloud-platform", 1056 // "https://www.googleapis.com/auth/cloud-platform.read-only" 1057 // ] 1058 // } 1059 1060} 1061 1062// method id "apikeys.projects.locations.keys.clone": 1063 1064type ProjectsLocationsKeysCloneCall struct { 1065 s *Service 1066 name string 1067 v2clonekeyrequest *V2CloneKeyRequest 1068 urlParams_ gensupport.URLParams 1069 ctx_ context.Context 1070 header_ http.Header 1071} 1072 1073// Clone: Clones the existing key's restriction and display name to a 1074// new API key. The service account must have the `apikeys.keys.get` and 1075// `apikeys.keys.create` permissions in the project. NOTE: Key is a 1076// global resource; hence the only supported value for location is 1077// `global`. 1078// 1079// - name: The resource name of the API key to be cloned in the same 1080// project. 1081func (r *ProjectsLocationsKeysService) Clone(name string, v2clonekeyrequest *V2CloneKeyRequest) *ProjectsLocationsKeysCloneCall { 1082 c := &ProjectsLocationsKeysCloneCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1083 c.name = name 1084 c.v2clonekeyrequest = v2clonekeyrequest 1085 return c 1086} 1087 1088// Fields allows partial responses to be retrieved. See 1089// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1090// for more information. 1091func (c *ProjectsLocationsKeysCloneCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysCloneCall { 1092 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1093 return c 1094} 1095 1096// Context sets the context to be used in this call's Do method. Any 1097// pending HTTP request will be aborted if the provided context is 1098// canceled. 1099func (c *ProjectsLocationsKeysCloneCall) Context(ctx context.Context) *ProjectsLocationsKeysCloneCall { 1100 c.ctx_ = ctx 1101 return c 1102} 1103 1104// Header returns an http.Header that can be modified by the caller to 1105// add HTTP headers to the request. 1106func (c *ProjectsLocationsKeysCloneCall) Header() http.Header { 1107 if c.header_ == nil { 1108 c.header_ = make(http.Header) 1109 } 1110 return c.header_ 1111} 1112 1113func (c *ProjectsLocationsKeysCloneCall) doRequest(alt string) (*http.Response, error) { 1114 reqHeaders := make(http.Header) 1115 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 1116 for k, v := range c.header_ { 1117 reqHeaders[k] = v 1118 } 1119 reqHeaders.Set("User-Agent", c.s.userAgent()) 1120 var body io.Reader = nil 1121 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2clonekeyrequest) 1122 if err != nil { 1123 return nil, err 1124 } 1125 reqHeaders.Set("Content-Type", "application/json") 1126 c.urlParams_.Set("alt", alt) 1127 c.urlParams_.Set("prettyPrint", "false") 1128 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}:clone") 1129 urls += "?" + c.urlParams_.Encode() 1130 req, err := http.NewRequest("POST", urls, body) 1131 if err != nil { 1132 return nil, err 1133 } 1134 req.Header = reqHeaders 1135 googleapi.Expand(req.URL, map[string]string{ 1136 "name": c.name, 1137 }) 1138 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1139} 1140 1141// Do executes the "apikeys.projects.locations.keys.clone" call. 1142// Exactly one of *Operation or error will be non-nil. Any non-2xx 1143// status code is an error. Response headers are in either 1144// *Operation.ServerResponse.Header or (if a response was returned at 1145// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1146// to check whether the returned error was because 1147// http.StatusNotModified was returned. 1148func (c *ProjectsLocationsKeysCloneCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1149 gensupport.SetOptions(c.urlParams_, opts...) 1150 res, err := c.doRequest("json") 1151 if res != nil && res.StatusCode == http.StatusNotModified { 1152 if res.Body != nil { 1153 res.Body.Close() 1154 } 1155 return nil, &googleapi.Error{ 1156 Code: res.StatusCode, 1157 Header: res.Header, 1158 } 1159 } 1160 if err != nil { 1161 return nil, err 1162 } 1163 defer googleapi.CloseBody(res) 1164 if err := googleapi.CheckResponse(res); err != nil { 1165 return nil, err 1166 } 1167 ret := &Operation{ 1168 ServerResponse: googleapi.ServerResponse{ 1169 Header: res.Header, 1170 HTTPStatusCode: res.StatusCode, 1171 }, 1172 } 1173 target := &ret 1174 if err := gensupport.DecodeResponse(target, res); err != nil { 1175 return nil, err 1176 } 1177 return ret, nil 1178 // { 1179 // "description": "Clones the existing key's restriction and display name to a new API key. The service account must have the `apikeys.keys.get` and `apikeys.keys.create` permissions in the project. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 1180 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys/{keysId}:clone", 1181 // "httpMethod": "POST", 1182 // "id": "apikeys.projects.locations.keys.clone", 1183 // "parameterOrder": [ 1184 // "name" 1185 // ], 1186 // "parameters": { 1187 // "name": { 1188 // "description": "Required. The resource name of the API key to be cloned in the same project.", 1189 // "location": "path", 1190 // "pattern": "^projects/[^/]+/locations/[^/]+/keys/[^/]+$", 1191 // "required": true, 1192 // "type": "string" 1193 // } 1194 // }, 1195 // "path": "v2/{+name}:clone", 1196 // "request": { 1197 // "$ref": "V2CloneKeyRequest" 1198 // }, 1199 // "response": { 1200 // "$ref": "Operation" 1201 // }, 1202 // "scopes": [ 1203 // "https://www.googleapis.com/auth/cloud-platform" 1204 // ] 1205 // } 1206 1207} 1208 1209// method id "apikeys.projects.locations.keys.create": 1210 1211type ProjectsLocationsKeysCreateCall struct { 1212 s *Service 1213 parent string 1214 v2key *V2Key 1215 urlParams_ gensupport.URLParams 1216 ctx_ context.Context 1217 header_ http.Header 1218} 1219 1220// Create: Creates a new API key. NOTE: Key is a global resource; hence 1221// the only supported value for location is `global`. 1222// 1223// - parent: The project in which the API key is created. 1224func (r *ProjectsLocationsKeysService) Create(parent string, v2key *V2Key) *ProjectsLocationsKeysCreateCall { 1225 c := &ProjectsLocationsKeysCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1226 c.parent = parent 1227 c.v2key = v2key 1228 return c 1229} 1230 1231// KeyId sets the optional parameter "keyId": User specified key id 1232// (optional). If specified, it will become the final component of the 1233// key resource name. The id must be unique within the project, must 1234// conform with RFC-1034, is restricted to lower-cased letters, and has 1235// a maximum length of 63 characters. In another word, the id must match 1236// the regular expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id 1237// must NOT be a UUID-like string. 1238func (c *ProjectsLocationsKeysCreateCall) KeyId(keyId string) *ProjectsLocationsKeysCreateCall { 1239 c.urlParams_.Set("keyId", keyId) 1240 return c 1241} 1242 1243// Fields allows partial responses to be retrieved. See 1244// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1245// for more information. 1246func (c *ProjectsLocationsKeysCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysCreateCall { 1247 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1248 return c 1249} 1250 1251// Context sets the context to be used in this call's Do method. Any 1252// pending HTTP request will be aborted if the provided context is 1253// canceled. 1254func (c *ProjectsLocationsKeysCreateCall) Context(ctx context.Context) *ProjectsLocationsKeysCreateCall { 1255 c.ctx_ = ctx 1256 return c 1257} 1258 1259// Header returns an http.Header that can be modified by the caller to 1260// add HTTP headers to the request. 1261func (c *ProjectsLocationsKeysCreateCall) Header() http.Header { 1262 if c.header_ == nil { 1263 c.header_ = make(http.Header) 1264 } 1265 return c.header_ 1266} 1267 1268func (c *ProjectsLocationsKeysCreateCall) doRequest(alt string) (*http.Response, error) { 1269 reqHeaders := make(http.Header) 1270 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 1271 for k, v := range c.header_ { 1272 reqHeaders[k] = v 1273 } 1274 reqHeaders.Set("User-Agent", c.s.userAgent()) 1275 var body io.Reader = nil 1276 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2key) 1277 if err != nil { 1278 return nil, err 1279 } 1280 reqHeaders.Set("Content-Type", "application/json") 1281 c.urlParams_.Set("alt", alt) 1282 c.urlParams_.Set("prettyPrint", "false") 1283 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/keys") 1284 urls += "?" + c.urlParams_.Encode() 1285 req, err := http.NewRequest("POST", urls, body) 1286 if err != nil { 1287 return nil, err 1288 } 1289 req.Header = reqHeaders 1290 googleapi.Expand(req.URL, map[string]string{ 1291 "parent": c.parent, 1292 }) 1293 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1294} 1295 1296// Do executes the "apikeys.projects.locations.keys.create" call. 1297// Exactly one of *Operation or error will be non-nil. Any non-2xx 1298// status code is an error. Response headers are in either 1299// *Operation.ServerResponse.Header or (if a response was returned at 1300// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1301// to check whether the returned error was because 1302// http.StatusNotModified was returned. 1303func (c *ProjectsLocationsKeysCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1304 gensupport.SetOptions(c.urlParams_, opts...) 1305 res, err := c.doRequest("json") 1306 if res != nil && res.StatusCode == http.StatusNotModified { 1307 if res.Body != nil { 1308 res.Body.Close() 1309 } 1310 return nil, &googleapi.Error{ 1311 Code: res.StatusCode, 1312 Header: res.Header, 1313 } 1314 } 1315 if err != nil { 1316 return nil, err 1317 } 1318 defer googleapi.CloseBody(res) 1319 if err := googleapi.CheckResponse(res); err != nil { 1320 return nil, err 1321 } 1322 ret := &Operation{ 1323 ServerResponse: googleapi.ServerResponse{ 1324 Header: res.Header, 1325 HTTPStatusCode: res.StatusCode, 1326 }, 1327 } 1328 target := &ret 1329 if err := gensupport.DecodeResponse(target, res); err != nil { 1330 return nil, err 1331 } 1332 return ret, nil 1333 // { 1334 // "description": "Creates a new API key. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 1335 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys", 1336 // "httpMethod": "POST", 1337 // "id": "apikeys.projects.locations.keys.create", 1338 // "parameterOrder": [ 1339 // "parent" 1340 // ], 1341 // "parameters": { 1342 // "keyId": { 1343 // "description": "User specified key id (optional). If specified, it will become the final component of the key resource name. The id must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the id must match the regular expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id must NOT be a UUID-like string.", 1344 // "location": "query", 1345 // "type": "string" 1346 // }, 1347 // "parent": { 1348 // "description": "Required. The project in which the API key is created.", 1349 // "location": "path", 1350 // "pattern": "^projects/[^/]+/locations/[^/]+$", 1351 // "required": true, 1352 // "type": "string" 1353 // } 1354 // }, 1355 // "path": "v2/{+parent}/keys", 1356 // "request": { 1357 // "$ref": "V2Key" 1358 // }, 1359 // "response": { 1360 // "$ref": "Operation" 1361 // }, 1362 // "scopes": [ 1363 // "https://www.googleapis.com/auth/cloud-platform" 1364 // ] 1365 // } 1366 1367} 1368 1369// method id "apikeys.projects.locations.keys.delete": 1370 1371type ProjectsLocationsKeysDeleteCall struct { 1372 s *Service 1373 name string 1374 urlParams_ gensupport.URLParams 1375 ctx_ context.Context 1376 header_ http.Header 1377} 1378 1379// Delete: Deletes an API key. Deleted key can be retrieved within 30 1380// days of deletion. Afterward, key will be purged from the project. 1381// NOTE: Key is a global resource; hence the only supported value for 1382// location is `global`. 1383// 1384// - name: The resource name of the API key to be deleted. 1385func (r *ProjectsLocationsKeysService) Delete(name string) *ProjectsLocationsKeysDeleteCall { 1386 c := &ProjectsLocationsKeysDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1387 c.name = name 1388 return c 1389} 1390 1391// Etag sets the optional parameter "etag": The etag known to the client 1392// for the expected state of the key. This is to be used for optimistic 1393// concurrency. 1394func (c *ProjectsLocationsKeysDeleteCall) Etag(etag string) *ProjectsLocationsKeysDeleteCall { 1395 c.urlParams_.Set("etag", etag) 1396 return c 1397} 1398 1399// Fields allows partial responses to be retrieved. See 1400// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1401// for more information. 1402func (c *ProjectsLocationsKeysDeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysDeleteCall { 1403 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1404 return c 1405} 1406 1407// Context sets the context to be used in this call's Do method. Any 1408// pending HTTP request will be aborted if the provided context is 1409// canceled. 1410func (c *ProjectsLocationsKeysDeleteCall) Context(ctx context.Context) *ProjectsLocationsKeysDeleteCall { 1411 c.ctx_ = ctx 1412 return c 1413} 1414 1415// Header returns an http.Header that can be modified by the caller to 1416// add HTTP headers to the request. 1417func (c *ProjectsLocationsKeysDeleteCall) Header() http.Header { 1418 if c.header_ == nil { 1419 c.header_ = make(http.Header) 1420 } 1421 return c.header_ 1422} 1423 1424func (c *ProjectsLocationsKeysDeleteCall) doRequest(alt string) (*http.Response, error) { 1425 reqHeaders := make(http.Header) 1426 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 1427 for k, v := range c.header_ { 1428 reqHeaders[k] = v 1429 } 1430 reqHeaders.Set("User-Agent", c.s.userAgent()) 1431 var body io.Reader = nil 1432 c.urlParams_.Set("alt", alt) 1433 c.urlParams_.Set("prettyPrint", "false") 1434 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}") 1435 urls += "?" + c.urlParams_.Encode() 1436 req, err := http.NewRequest("DELETE", urls, body) 1437 if err != nil { 1438 return nil, err 1439 } 1440 req.Header = reqHeaders 1441 googleapi.Expand(req.URL, map[string]string{ 1442 "name": c.name, 1443 }) 1444 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1445} 1446 1447// Do executes the "apikeys.projects.locations.keys.delete" call. 1448// Exactly one of *Operation or error will be non-nil. Any non-2xx 1449// status code is an error. Response headers are in either 1450// *Operation.ServerResponse.Header or (if a response was returned at 1451// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1452// to check whether the returned error was because 1453// http.StatusNotModified was returned. 1454func (c *ProjectsLocationsKeysDeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1455 gensupport.SetOptions(c.urlParams_, opts...) 1456 res, err := c.doRequest("json") 1457 if res != nil && res.StatusCode == http.StatusNotModified { 1458 if res.Body != nil { 1459 res.Body.Close() 1460 } 1461 return nil, &googleapi.Error{ 1462 Code: res.StatusCode, 1463 Header: res.Header, 1464 } 1465 } 1466 if err != nil { 1467 return nil, err 1468 } 1469 defer googleapi.CloseBody(res) 1470 if err := googleapi.CheckResponse(res); err != nil { 1471 return nil, err 1472 } 1473 ret := &Operation{ 1474 ServerResponse: googleapi.ServerResponse{ 1475 Header: res.Header, 1476 HTTPStatusCode: res.StatusCode, 1477 }, 1478 } 1479 target := &ret 1480 if err := gensupport.DecodeResponse(target, res); err != nil { 1481 return nil, err 1482 } 1483 return ret, nil 1484 // { 1485 // "description": "Deletes an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 1486 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys/{keysId}", 1487 // "httpMethod": "DELETE", 1488 // "id": "apikeys.projects.locations.keys.delete", 1489 // "parameterOrder": [ 1490 // "name" 1491 // ], 1492 // "parameters": { 1493 // "etag": { 1494 // "description": "Optional. The etag known to the client for the expected state of the key. This is to be used for optimistic concurrency.", 1495 // "location": "query", 1496 // "type": "string" 1497 // }, 1498 // "name": { 1499 // "description": "Required. The resource name of the API key to be deleted.", 1500 // "location": "path", 1501 // "pattern": "^projects/[^/]+/locations/[^/]+/keys/[^/]+$", 1502 // "required": true, 1503 // "type": "string" 1504 // } 1505 // }, 1506 // "path": "v2/{+name}", 1507 // "response": { 1508 // "$ref": "Operation" 1509 // }, 1510 // "scopes": [ 1511 // "https://www.googleapis.com/auth/cloud-platform" 1512 // ] 1513 // } 1514 1515} 1516 1517// method id "apikeys.projects.locations.keys.get": 1518 1519type ProjectsLocationsKeysGetCall struct { 1520 s *Service 1521 name string 1522 urlParams_ gensupport.URLParams 1523 ifNoneMatch_ string 1524 ctx_ context.Context 1525 header_ http.Header 1526} 1527 1528// Get: Gets the metadata for an API key. The key string of the API key 1529// isn't included in the response. NOTE: Key is a global resource; hence 1530// the only supported value for location is `global`. 1531// 1532// - name: The resource name of the API key to get. 1533func (r *ProjectsLocationsKeysService) Get(name string) *ProjectsLocationsKeysGetCall { 1534 c := &ProjectsLocationsKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1535 c.name = name 1536 return c 1537} 1538 1539// Fields allows partial responses to be retrieved. See 1540// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1541// for more information. 1542func (c *ProjectsLocationsKeysGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysGetCall { 1543 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1544 return c 1545} 1546 1547// IfNoneMatch sets the optional parameter which makes the operation 1548// fail if the object's ETag matches the given value. This is useful for 1549// getting updates only after the object has changed since the last 1550// request. Use googleapi.IsNotModified to check whether the response 1551// error from Do is the result of In-None-Match. 1552func (c *ProjectsLocationsKeysGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysGetCall { 1553 c.ifNoneMatch_ = entityTag 1554 return c 1555} 1556 1557// Context sets the context to be used in this call's Do method. Any 1558// pending HTTP request will be aborted if the provided context is 1559// canceled. 1560func (c *ProjectsLocationsKeysGetCall) Context(ctx context.Context) *ProjectsLocationsKeysGetCall { 1561 c.ctx_ = ctx 1562 return c 1563} 1564 1565// Header returns an http.Header that can be modified by the caller to 1566// add HTTP headers to the request. 1567func (c *ProjectsLocationsKeysGetCall) Header() http.Header { 1568 if c.header_ == nil { 1569 c.header_ = make(http.Header) 1570 } 1571 return c.header_ 1572} 1573 1574func (c *ProjectsLocationsKeysGetCall) doRequest(alt string) (*http.Response, error) { 1575 reqHeaders := make(http.Header) 1576 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 1577 for k, v := range c.header_ { 1578 reqHeaders[k] = v 1579 } 1580 reqHeaders.Set("User-Agent", c.s.userAgent()) 1581 if c.ifNoneMatch_ != "" { 1582 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1583 } 1584 var body io.Reader = nil 1585 c.urlParams_.Set("alt", alt) 1586 c.urlParams_.Set("prettyPrint", "false") 1587 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}") 1588 urls += "?" + c.urlParams_.Encode() 1589 req, err := http.NewRequest("GET", urls, body) 1590 if err != nil { 1591 return nil, err 1592 } 1593 req.Header = reqHeaders 1594 googleapi.Expand(req.URL, map[string]string{ 1595 "name": c.name, 1596 }) 1597 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1598} 1599 1600// Do executes the "apikeys.projects.locations.keys.get" call. 1601// Exactly one of *V2Key or error will be non-nil. Any non-2xx status 1602// code is an error. Response headers are in either 1603// *V2Key.ServerResponse.Header or (if a response was returned at all) 1604// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 1605// check whether the returned error was because http.StatusNotModified 1606// was returned. 1607func (c *ProjectsLocationsKeysGetCall) Do(opts ...googleapi.CallOption) (*V2Key, error) { 1608 gensupport.SetOptions(c.urlParams_, opts...) 1609 res, err := c.doRequest("json") 1610 if res != nil && res.StatusCode == http.StatusNotModified { 1611 if res.Body != nil { 1612 res.Body.Close() 1613 } 1614 return nil, &googleapi.Error{ 1615 Code: res.StatusCode, 1616 Header: res.Header, 1617 } 1618 } 1619 if err != nil { 1620 return nil, err 1621 } 1622 defer googleapi.CloseBody(res) 1623 if err := googleapi.CheckResponse(res); err != nil { 1624 return nil, err 1625 } 1626 ret := &V2Key{ 1627 ServerResponse: googleapi.ServerResponse{ 1628 Header: res.Header, 1629 HTTPStatusCode: res.StatusCode, 1630 }, 1631 } 1632 target := &ret 1633 if err := gensupport.DecodeResponse(target, res); err != nil { 1634 return nil, err 1635 } 1636 return ret, nil 1637 // { 1638 // "description": "Gets the metadata for an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 1639 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys/{keysId}", 1640 // "httpMethod": "GET", 1641 // "id": "apikeys.projects.locations.keys.get", 1642 // "parameterOrder": [ 1643 // "name" 1644 // ], 1645 // "parameters": { 1646 // "name": { 1647 // "description": "Required. The resource name of the API key to get.", 1648 // "location": "path", 1649 // "pattern": "^projects/[^/]+/locations/[^/]+/keys/[^/]+$", 1650 // "required": true, 1651 // "type": "string" 1652 // } 1653 // }, 1654 // "path": "v2/{+name}", 1655 // "response": { 1656 // "$ref": "V2Key" 1657 // }, 1658 // "scopes": [ 1659 // "https://www.googleapis.com/auth/cloud-platform", 1660 // "https://www.googleapis.com/auth/cloud-platform.read-only" 1661 // ] 1662 // } 1663 1664} 1665 1666// method id "apikeys.projects.locations.keys.getKeyString": 1667 1668type ProjectsLocationsKeysGetKeyStringCall struct { 1669 s *Service 1670 name string 1671 urlParams_ gensupport.URLParams 1672 ifNoneMatch_ string 1673 ctx_ context.Context 1674 header_ http.Header 1675} 1676 1677// GetKeyString: Get the key string for an API key. NOTE: Key is a 1678// global resource; hence the only supported value for location is 1679// `global`. 1680// 1681// - name: The resource name of the API key to be retrieved. 1682func (r *ProjectsLocationsKeysService) GetKeyString(name string) *ProjectsLocationsKeysGetKeyStringCall { 1683 c := &ProjectsLocationsKeysGetKeyStringCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1684 c.name = name 1685 return c 1686} 1687 1688// Fields allows partial responses to be retrieved. See 1689// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1690// for more information. 1691func (c *ProjectsLocationsKeysGetKeyStringCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysGetKeyStringCall { 1692 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1693 return c 1694} 1695 1696// IfNoneMatch sets the optional parameter which makes the operation 1697// fail if the object's ETag matches the given value. This is useful for 1698// getting updates only after the object has changed since the last 1699// request. Use googleapi.IsNotModified to check whether the response 1700// error from Do is the result of In-None-Match. 1701func (c *ProjectsLocationsKeysGetKeyStringCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysGetKeyStringCall { 1702 c.ifNoneMatch_ = entityTag 1703 return c 1704} 1705 1706// Context sets the context to be used in this call's Do method. Any 1707// pending HTTP request will be aborted if the provided context is 1708// canceled. 1709func (c *ProjectsLocationsKeysGetKeyStringCall) Context(ctx context.Context) *ProjectsLocationsKeysGetKeyStringCall { 1710 c.ctx_ = ctx 1711 return c 1712} 1713 1714// Header returns an http.Header that can be modified by the caller to 1715// add HTTP headers to the request. 1716func (c *ProjectsLocationsKeysGetKeyStringCall) Header() http.Header { 1717 if c.header_ == nil { 1718 c.header_ = make(http.Header) 1719 } 1720 return c.header_ 1721} 1722 1723func (c *ProjectsLocationsKeysGetKeyStringCall) doRequest(alt string) (*http.Response, error) { 1724 reqHeaders := make(http.Header) 1725 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 1726 for k, v := range c.header_ { 1727 reqHeaders[k] = v 1728 } 1729 reqHeaders.Set("User-Agent", c.s.userAgent()) 1730 if c.ifNoneMatch_ != "" { 1731 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1732 } 1733 var body io.Reader = nil 1734 c.urlParams_.Set("alt", alt) 1735 c.urlParams_.Set("prettyPrint", "false") 1736 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}/keyString") 1737 urls += "?" + c.urlParams_.Encode() 1738 req, err := http.NewRequest("GET", urls, body) 1739 if err != nil { 1740 return nil, err 1741 } 1742 req.Header = reqHeaders 1743 googleapi.Expand(req.URL, map[string]string{ 1744 "name": c.name, 1745 }) 1746 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1747} 1748 1749// Do executes the "apikeys.projects.locations.keys.getKeyString" call. 1750// Exactly one of *V2GetKeyStringResponse or error will be non-nil. Any 1751// non-2xx status code is an error. Response headers are in either 1752// *V2GetKeyStringResponse.ServerResponse.Header or (if a response was 1753// returned at all) in error.(*googleapi.Error).Header. Use 1754// googleapi.IsNotModified to check whether the returned error was 1755// because http.StatusNotModified was returned. 1756func (c *ProjectsLocationsKeysGetKeyStringCall) Do(opts ...googleapi.CallOption) (*V2GetKeyStringResponse, error) { 1757 gensupport.SetOptions(c.urlParams_, opts...) 1758 res, err := c.doRequest("json") 1759 if res != nil && res.StatusCode == http.StatusNotModified { 1760 if res.Body != nil { 1761 res.Body.Close() 1762 } 1763 return nil, &googleapi.Error{ 1764 Code: res.StatusCode, 1765 Header: res.Header, 1766 } 1767 } 1768 if err != nil { 1769 return nil, err 1770 } 1771 defer googleapi.CloseBody(res) 1772 if err := googleapi.CheckResponse(res); err != nil { 1773 return nil, err 1774 } 1775 ret := &V2GetKeyStringResponse{ 1776 ServerResponse: googleapi.ServerResponse{ 1777 Header: res.Header, 1778 HTTPStatusCode: res.StatusCode, 1779 }, 1780 } 1781 target := &ret 1782 if err := gensupport.DecodeResponse(target, res); err != nil { 1783 return nil, err 1784 } 1785 return ret, nil 1786 // { 1787 // "description": "Get the key string for an API key. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 1788 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys/{keysId}/keyString", 1789 // "httpMethod": "GET", 1790 // "id": "apikeys.projects.locations.keys.getKeyString", 1791 // "parameterOrder": [ 1792 // "name" 1793 // ], 1794 // "parameters": { 1795 // "name": { 1796 // "description": "Required. The resource name of the API key to be retrieved.", 1797 // "location": "path", 1798 // "pattern": "^projects/[^/]+/locations/[^/]+/keys/[^/]+$", 1799 // "required": true, 1800 // "type": "string" 1801 // } 1802 // }, 1803 // "path": "v2/{+name}/keyString", 1804 // "response": { 1805 // "$ref": "V2GetKeyStringResponse" 1806 // }, 1807 // "scopes": [ 1808 // "https://www.googleapis.com/auth/cloud-platform", 1809 // "https://www.googleapis.com/auth/cloud-platform.read-only" 1810 // ] 1811 // } 1812 1813} 1814 1815// method id "apikeys.projects.locations.keys.list": 1816 1817type ProjectsLocationsKeysListCall struct { 1818 s *Service 1819 parent string 1820 urlParams_ gensupport.URLParams 1821 ifNoneMatch_ string 1822 ctx_ context.Context 1823 header_ http.Header 1824} 1825 1826// List: Lists the API keys owned by a project. The key string of the 1827// API key isn't included in the response. NOTE: Key is a global 1828// resource; hence the only supported value for location is `global`. 1829// 1830// - parent: Lists all API keys associated with this project. 1831func (r *ProjectsLocationsKeysService) List(parent string) *ProjectsLocationsKeysListCall { 1832 c := &ProjectsLocationsKeysListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1833 c.parent = parent 1834 return c 1835} 1836 1837// Filter sets the optional parameter "filter": Only list keys that 1838// conform to the specified filter. The allowed filter strings are 1839// `state:ACTIVE` and `state:DELETED`. By default, ListKeys returns only 1840// active keys. 1841func (c *ProjectsLocationsKeysListCall) Filter(filter string) *ProjectsLocationsKeysListCall { 1842 c.urlParams_.Set("filter", filter) 1843 return c 1844} 1845 1846// PageSize sets the optional parameter "pageSize": Specifies the 1847// maximum number of results to be returned at a time. 1848func (c *ProjectsLocationsKeysListCall) PageSize(pageSize int64) *ProjectsLocationsKeysListCall { 1849 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 1850 return c 1851} 1852 1853// PageToken sets the optional parameter "pageToken": Requests a 1854// specific page of results. 1855func (c *ProjectsLocationsKeysListCall) PageToken(pageToken string) *ProjectsLocationsKeysListCall { 1856 c.urlParams_.Set("pageToken", pageToken) 1857 return c 1858} 1859 1860// Fields allows partial responses to be retrieved. See 1861// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1862// for more information. 1863func (c *ProjectsLocationsKeysListCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysListCall { 1864 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1865 return c 1866} 1867 1868// IfNoneMatch sets the optional parameter which makes the operation 1869// fail if the object's ETag matches the given value. This is useful for 1870// getting updates only after the object has changed since the last 1871// request. Use googleapi.IsNotModified to check whether the response 1872// error from Do is the result of In-None-Match. 1873func (c *ProjectsLocationsKeysListCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysListCall { 1874 c.ifNoneMatch_ = entityTag 1875 return c 1876} 1877 1878// Context sets the context to be used in this call's Do method. Any 1879// pending HTTP request will be aborted if the provided context is 1880// canceled. 1881func (c *ProjectsLocationsKeysListCall) Context(ctx context.Context) *ProjectsLocationsKeysListCall { 1882 c.ctx_ = ctx 1883 return c 1884} 1885 1886// Header returns an http.Header that can be modified by the caller to 1887// add HTTP headers to the request. 1888func (c *ProjectsLocationsKeysListCall) Header() http.Header { 1889 if c.header_ == nil { 1890 c.header_ = make(http.Header) 1891 } 1892 return c.header_ 1893} 1894 1895func (c *ProjectsLocationsKeysListCall) doRequest(alt string) (*http.Response, error) { 1896 reqHeaders := make(http.Header) 1897 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 1898 for k, v := range c.header_ { 1899 reqHeaders[k] = v 1900 } 1901 reqHeaders.Set("User-Agent", c.s.userAgent()) 1902 if c.ifNoneMatch_ != "" { 1903 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1904 } 1905 var body io.Reader = nil 1906 c.urlParams_.Set("alt", alt) 1907 c.urlParams_.Set("prettyPrint", "false") 1908 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/keys") 1909 urls += "?" + c.urlParams_.Encode() 1910 req, err := http.NewRequest("GET", urls, body) 1911 if err != nil { 1912 return nil, err 1913 } 1914 req.Header = reqHeaders 1915 googleapi.Expand(req.URL, map[string]string{ 1916 "parent": c.parent, 1917 }) 1918 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1919} 1920 1921// Do executes the "apikeys.projects.locations.keys.list" call. 1922// Exactly one of *V2ListKeysResponse or error will be non-nil. Any 1923// non-2xx status code is an error. Response headers are in either 1924// *V2ListKeysResponse.ServerResponse.Header or (if a response was 1925// returned at all) in error.(*googleapi.Error).Header. Use 1926// googleapi.IsNotModified to check whether the returned error was 1927// because http.StatusNotModified was returned. 1928func (c *ProjectsLocationsKeysListCall) Do(opts ...googleapi.CallOption) (*V2ListKeysResponse, error) { 1929 gensupport.SetOptions(c.urlParams_, opts...) 1930 res, err := c.doRequest("json") 1931 if res != nil && res.StatusCode == http.StatusNotModified { 1932 if res.Body != nil { 1933 res.Body.Close() 1934 } 1935 return nil, &googleapi.Error{ 1936 Code: res.StatusCode, 1937 Header: res.Header, 1938 } 1939 } 1940 if err != nil { 1941 return nil, err 1942 } 1943 defer googleapi.CloseBody(res) 1944 if err := googleapi.CheckResponse(res); err != nil { 1945 return nil, err 1946 } 1947 ret := &V2ListKeysResponse{ 1948 ServerResponse: googleapi.ServerResponse{ 1949 Header: res.Header, 1950 HTTPStatusCode: res.StatusCode, 1951 }, 1952 } 1953 target := &ret 1954 if err := gensupport.DecodeResponse(target, res); err != nil { 1955 return nil, err 1956 } 1957 return ret, nil 1958 // { 1959 // "description": "Lists the API keys owned by a project. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 1960 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys", 1961 // "httpMethod": "GET", 1962 // "id": "apikeys.projects.locations.keys.list", 1963 // "parameterOrder": [ 1964 // "parent" 1965 // ], 1966 // "parameters": { 1967 // "filter": { 1968 // "description": "Optional. Only list keys that conform to the specified filter. The allowed filter strings are `state:ACTIVE` and `state:DELETED`. By default, ListKeys returns only active keys.", 1969 // "location": "query", 1970 // "type": "string" 1971 // }, 1972 // "pageSize": { 1973 // "description": "Optional. Specifies the maximum number of results to be returned at a time.", 1974 // "format": "int32", 1975 // "location": "query", 1976 // "type": "integer" 1977 // }, 1978 // "pageToken": { 1979 // "description": "Optional. Requests a specific page of results.", 1980 // "location": "query", 1981 // "type": "string" 1982 // }, 1983 // "parent": { 1984 // "description": "Required. Lists all API keys associated with this project.", 1985 // "location": "path", 1986 // "pattern": "^projects/[^/]+/locations/[^/]+$", 1987 // "required": true, 1988 // "type": "string" 1989 // } 1990 // }, 1991 // "path": "v2/{+parent}/keys", 1992 // "response": { 1993 // "$ref": "V2ListKeysResponse" 1994 // }, 1995 // "scopes": [ 1996 // "https://www.googleapis.com/auth/cloud-platform", 1997 // "https://www.googleapis.com/auth/cloud-platform.read-only" 1998 // ] 1999 // } 2000 2001} 2002 2003// Pages invokes f for each page of results. 2004// A non-nil error returned from f will halt the iteration. 2005// The provided context supersedes any context provided to the Context method. 2006func (c *ProjectsLocationsKeysListCall) Pages(ctx context.Context, f func(*V2ListKeysResponse) error) error { 2007 c.ctx_ = ctx 2008 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 2009 for { 2010 x, err := c.Do() 2011 if err != nil { 2012 return err 2013 } 2014 if err := f(x); err != nil { 2015 return err 2016 } 2017 if x.NextPageToken == "" { 2018 return nil 2019 } 2020 c.PageToken(x.NextPageToken) 2021 } 2022} 2023 2024// method id "apikeys.projects.locations.keys.patch": 2025 2026type ProjectsLocationsKeysPatchCall struct { 2027 s *Service 2028 name string 2029 v2key *V2Key 2030 urlParams_ gensupport.URLParams 2031 ctx_ context.Context 2032 header_ http.Header 2033} 2034 2035// Patch: Patches the modifiable fields of an API key. The key string of 2036// the API key isn't included in the response. NOTE: Key is a global 2037// resource; hence the only supported value for location is `global`. 2038// 2039// - name: Output only. The resource name of the key. The `name` has the 2040// form: `projects//locations/global/keys/`. For example: 2041// `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd 2042// -3855ee9b5dd2` NOTE: Key is a global resource; hence the only 2043// supported value for location is `global`. 2044func (r *ProjectsLocationsKeysService) Patch(name string, v2key *V2Key) *ProjectsLocationsKeysPatchCall { 2045 c := &ProjectsLocationsKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2046 c.name = name 2047 c.v2key = v2key 2048 return c 2049} 2050 2051// UpdateMask sets the optional parameter "updateMask": The field mask 2052// specifies which fields to be updated as part of this request. All 2053// other fields are ignored. Mutable fields are: `display_name` and 2054// `restrictions`. If an update mask is not provided, the service treats 2055// it as an implied mask equivalent to all allowed fields that are set 2056// on the wire. If the field mask has a special value "*", the service 2057// treats it equivalent to replace all allowed mutable fields. 2058func (c *ProjectsLocationsKeysPatchCall) UpdateMask(updateMask string) *ProjectsLocationsKeysPatchCall { 2059 c.urlParams_.Set("updateMask", updateMask) 2060 return c 2061} 2062 2063// Fields allows partial responses to be retrieved. See 2064// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 2065// for more information. 2066func (c *ProjectsLocationsKeysPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysPatchCall { 2067 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2068 return c 2069} 2070 2071// Context sets the context to be used in this call's Do method. Any 2072// pending HTTP request will be aborted if the provided context is 2073// canceled. 2074func (c *ProjectsLocationsKeysPatchCall) Context(ctx context.Context) *ProjectsLocationsKeysPatchCall { 2075 c.ctx_ = ctx 2076 return c 2077} 2078 2079// Header returns an http.Header that can be modified by the caller to 2080// add HTTP headers to the request. 2081func (c *ProjectsLocationsKeysPatchCall) Header() http.Header { 2082 if c.header_ == nil { 2083 c.header_ = make(http.Header) 2084 } 2085 return c.header_ 2086} 2087 2088func (c *ProjectsLocationsKeysPatchCall) doRequest(alt string) (*http.Response, error) { 2089 reqHeaders := make(http.Header) 2090 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 2091 for k, v := range c.header_ { 2092 reqHeaders[k] = v 2093 } 2094 reqHeaders.Set("User-Agent", c.s.userAgent()) 2095 var body io.Reader = nil 2096 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2key) 2097 if err != nil { 2098 return nil, err 2099 } 2100 reqHeaders.Set("Content-Type", "application/json") 2101 c.urlParams_.Set("alt", alt) 2102 c.urlParams_.Set("prettyPrint", "false") 2103 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}") 2104 urls += "?" + c.urlParams_.Encode() 2105 req, err := http.NewRequest("PATCH", urls, body) 2106 if err != nil { 2107 return nil, err 2108 } 2109 req.Header = reqHeaders 2110 googleapi.Expand(req.URL, map[string]string{ 2111 "name": c.name, 2112 }) 2113 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2114} 2115 2116// Do executes the "apikeys.projects.locations.keys.patch" call. 2117// Exactly one of *Operation or error will be non-nil. Any non-2xx 2118// status code is an error. Response headers are in either 2119// *Operation.ServerResponse.Header or (if a response was returned at 2120// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 2121// to check whether the returned error was because 2122// http.StatusNotModified was returned. 2123func (c *ProjectsLocationsKeysPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 2124 gensupport.SetOptions(c.urlParams_, opts...) 2125 res, err := c.doRequest("json") 2126 if res != nil && res.StatusCode == http.StatusNotModified { 2127 if res.Body != nil { 2128 res.Body.Close() 2129 } 2130 return nil, &googleapi.Error{ 2131 Code: res.StatusCode, 2132 Header: res.Header, 2133 } 2134 } 2135 if err != nil { 2136 return nil, err 2137 } 2138 defer googleapi.CloseBody(res) 2139 if err := googleapi.CheckResponse(res); err != nil { 2140 return nil, err 2141 } 2142 ret := &Operation{ 2143 ServerResponse: googleapi.ServerResponse{ 2144 Header: res.Header, 2145 HTTPStatusCode: res.StatusCode, 2146 }, 2147 } 2148 target := &ret 2149 if err := gensupport.DecodeResponse(target, res); err != nil { 2150 return nil, err 2151 } 2152 return ret, nil 2153 // { 2154 // "description": "Patches the modifiable fields of an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 2155 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys/{keysId}", 2156 // "httpMethod": "PATCH", 2157 // "id": "apikeys.projects.locations.keys.patch", 2158 // "parameterOrder": [ 2159 // "name" 2160 // ], 2161 // "parameters": { 2162 // "name": { 2163 // "description": "Output only. The resource name of the key. The `name` has the form: `projects//locations/global/keys/`. For example: `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2` NOTE: Key is a global resource; hence the only supported value for location is `global`.", 2164 // "location": "path", 2165 // "pattern": "^projects/[^/]+/locations/[^/]+/keys/[^/]+$", 2166 // "required": true, 2167 // "type": "string" 2168 // }, 2169 // "updateMask": { 2170 // "description": "The field mask specifies which fields to be updated as part of this request. All other fields are ignored. Mutable fields are: `display_name` and `restrictions`. If an update mask is not provided, the service treats it as an implied mask equivalent to all allowed fields that are set on the wire. If the field mask has a special value \"*\", the service treats it equivalent to replace all allowed mutable fields.", 2171 // "format": "google-fieldmask", 2172 // "location": "query", 2173 // "type": "string" 2174 // } 2175 // }, 2176 // "path": "v2/{+name}", 2177 // "request": { 2178 // "$ref": "V2Key" 2179 // }, 2180 // "response": { 2181 // "$ref": "Operation" 2182 // }, 2183 // "scopes": [ 2184 // "https://www.googleapis.com/auth/cloud-platform" 2185 // ] 2186 // } 2187 2188} 2189 2190// method id "apikeys.projects.locations.keys.undelete": 2191 2192type ProjectsLocationsKeysUndeleteCall struct { 2193 s *Service 2194 name string 2195 v2undeletekeyrequest *V2UndeleteKeyRequest 2196 urlParams_ gensupport.URLParams 2197 ctx_ context.Context 2198 header_ http.Header 2199} 2200 2201// Undelete: Undeletes an API key which was deleted within 30 days. 2202// NOTE: Key is a global resource; hence the only supported value for 2203// location is `global`. 2204// 2205// - name: The resource name of the API key to be undeleted. 2206func (r *ProjectsLocationsKeysService) Undelete(name string, v2undeletekeyrequest *V2UndeleteKeyRequest) *ProjectsLocationsKeysUndeleteCall { 2207 c := &ProjectsLocationsKeysUndeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2208 c.name = name 2209 c.v2undeletekeyrequest = v2undeletekeyrequest 2210 return c 2211} 2212 2213// Fields allows partial responses to be retrieved. See 2214// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 2215// for more information. 2216func (c *ProjectsLocationsKeysUndeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysUndeleteCall { 2217 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2218 return c 2219} 2220 2221// Context sets the context to be used in this call's Do method. Any 2222// pending HTTP request will be aborted if the provided context is 2223// canceled. 2224func (c *ProjectsLocationsKeysUndeleteCall) Context(ctx context.Context) *ProjectsLocationsKeysUndeleteCall { 2225 c.ctx_ = ctx 2226 return c 2227} 2228 2229// Header returns an http.Header that can be modified by the caller to 2230// add HTTP headers to the request. 2231func (c *ProjectsLocationsKeysUndeleteCall) Header() http.Header { 2232 if c.header_ == nil { 2233 c.header_ = make(http.Header) 2234 } 2235 return c.header_ 2236} 2237 2238func (c *ProjectsLocationsKeysUndeleteCall) doRequest(alt string) (*http.Response, error) { 2239 reqHeaders := make(http.Header) 2240 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210812") 2241 for k, v := range c.header_ { 2242 reqHeaders[k] = v 2243 } 2244 reqHeaders.Set("User-Agent", c.s.userAgent()) 2245 var body io.Reader = nil 2246 body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2undeletekeyrequest) 2247 if err != nil { 2248 return nil, err 2249 } 2250 reqHeaders.Set("Content-Type", "application/json") 2251 c.urlParams_.Set("alt", alt) 2252 c.urlParams_.Set("prettyPrint", "false") 2253 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}:undelete") 2254 urls += "?" + c.urlParams_.Encode() 2255 req, err := http.NewRequest("POST", urls, body) 2256 if err != nil { 2257 return nil, err 2258 } 2259 req.Header = reqHeaders 2260 googleapi.Expand(req.URL, map[string]string{ 2261 "name": c.name, 2262 }) 2263 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2264} 2265 2266// Do executes the "apikeys.projects.locations.keys.undelete" call. 2267// Exactly one of *Operation or error will be non-nil. Any non-2xx 2268// status code is an error. Response headers are in either 2269// *Operation.ServerResponse.Header or (if a response was returned at 2270// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 2271// to check whether the returned error was because 2272// http.StatusNotModified was returned. 2273func (c *ProjectsLocationsKeysUndeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 2274 gensupport.SetOptions(c.urlParams_, opts...) 2275 res, err := c.doRequest("json") 2276 if res != nil && res.StatusCode == http.StatusNotModified { 2277 if res.Body != nil { 2278 res.Body.Close() 2279 } 2280 return nil, &googleapi.Error{ 2281 Code: res.StatusCode, 2282 Header: res.Header, 2283 } 2284 } 2285 if err != nil { 2286 return nil, err 2287 } 2288 defer googleapi.CloseBody(res) 2289 if err := googleapi.CheckResponse(res); err != nil { 2290 return nil, err 2291 } 2292 ret := &Operation{ 2293 ServerResponse: googleapi.ServerResponse{ 2294 Header: res.Header, 2295 HTTPStatusCode: res.StatusCode, 2296 }, 2297 } 2298 target := &ret 2299 if err := gensupport.DecodeResponse(target, res); err != nil { 2300 return nil, err 2301 } 2302 return ret, nil 2303 // { 2304 // "description": "Undeletes an API key which was deleted within 30 days. NOTE: Key is a global resource; hence the only supported value for location is `global`.", 2305 // "flatPath": "v2/projects/{projectsId}/locations/{locationsId}/keys/{keysId}:undelete", 2306 // "httpMethod": "POST", 2307 // "id": "apikeys.projects.locations.keys.undelete", 2308 // "parameterOrder": [ 2309 // "name" 2310 // ], 2311 // "parameters": { 2312 // "name": { 2313 // "description": "Required. The resource name of the API key to be undeleted.", 2314 // "location": "path", 2315 // "pattern": "^projects/[^/]+/locations/[^/]+/keys/[^/]+$", 2316 // "required": true, 2317 // "type": "string" 2318 // } 2319 // }, 2320 // "path": "v2/{+name}:undelete", 2321 // "request": { 2322 // "$ref": "V2UndeleteKeyRequest" 2323 // }, 2324 // "response": { 2325 // "$ref": "Operation" 2326 // }, 2327 // "scopes": [ 2328 // "https://www.googleapis.com/auth/cloud-platform" 2329 // ] 2330 // } 2331 2332} 2333