...

Source file src/google.golang.org/api/apikeys/v2/apikeys-gen.go

Documentation: google.golang.org/api/apikeys/v2

     1  // Copyright 2024 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  // # Library status
    12  //
    13  // These client libraries are officially supported by Google. However, this
    14  // library is considered complete and is in maintenance mode. This means
    15  // that we will address critical bugs and security issues but will not add
    16  // any new features.
    17  //
    18  // When possible, we recommend using our newer
    19  // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20  // that are still actively being worked and iterated on.
    21  //
    22  // # Creating a client
    23  //
    24  // Usage example:
    25  //
    26  //	import "google.golang.org/api/apikeys/v2"
    27  //	...
    28  //	ctx := context.Background()
    29  //	apikeysService, err := apikeys.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	apikeysService, err := apikeys.NewService(ctx, option.WithScopes(apikeys.CloudPlatformReadOnlyScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	apikeysService, err := apikeys.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	apikeysService, err := apikeys.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package apikeys // import "google.golang.org/api/apikeys/v2"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "apikeys:v2"
    95  const apiName = "apikeys"
    96  const apiVersion = "v2"
    97  const basePath = "https://apikeys.googleapis.com/"
    98  const basePathTemplate = "https://apikeys.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://apikeys.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// See, edit, configure, and delete your Google Cloud data and see the email
   104  	// address for your Google Account.
   105  	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
   106  
   107  	// View your data across Google Cloud services and see the email address of
   108  	// your Google Account
   109  	CloudPlatformReadOnlyScope = "https://www.googleapis.com/auth/cloud-platform.read-only"
   110  )
   111  
   112  // NewService creates a new Service.
   113  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   114  	scopesOption := internaloption.WithDefaultScopes(
   115  		"https://www.googleapis.com/auth/cloud-platform",
   116  		"https://www.googleapis.com/auth/cloud-platform.read-only",
   117  	)
   118  	// NOTE: prepend, so we don't override user-specified scopes.
   119  	opts = append([]option.ClientOption{scopesOption}, opts...)
   120  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   121  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   122  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   123  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   124  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	s, err := New(client)
   129  	if err != nil {
   130  		return nil, err
   131  	}
   132  	if endpoint != "" {
   133  		s.BasePath = endpoint
   134  	}
   135  	return s, nil
   136  }
   137  
   138  // New creates a new Service. It uses the provided http.Client for requests.
   139  //
   140  // Deprecated: please use NewService instead.
   141  // To provide a custom HTTP client, use option.WithHTTPClient.
   142  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   143  func New(client *http.Client) (*Service, error) {
   144  	if client == nil {
   145  		return nil, errors.New("client is nil")
   146  	}
   147  	s := &Service{client: client, BasePath: basePath}
   148  	s.Keys = NewKeysService(s)
   149  	s.Operations = NewOperationsService(s)
   150  	s.Projects = NewProjectsService(s)
   151  	return s, nil
   152  }
   153  
   154  type Service struct {
   155  	client    *http.Client
   156  	BasePath  string // API endpoint base URL
   157  	UserAgent string // optional additional User-Agent fragment
   158  
   159  	Keys *KeysService
   160  
   161  	Operations *OperationsService
   162  
   163  	Projects *ProjectsService
   164  }
   165  
   166  func (s *Service) userAgent() string {
   167  	if s.UserAgent == "" {
   168  		return googleapi.UserAgent
   169  	}
   170  	return googleapi.UserAgent + " " + s.UserAgent
   171  }
   172  
   173  func NewKeysService(s *Service) *KeysService {
   174  	rs := &KeysService{s: s}
   175  	return rs
   176  }
   177  
   178  type KeysService struct {
   179  	s *Service
   180  }
   181  
   182  func NewOperationsService(s *Service) *OperationsService {
   183  	rs := &OperationsService{s: s}
   184  	return rs
   185  }
   186  
   187  type OperationsService struct {
   188  	s *Service
   189  }
   190  
   191  func NewProjectsService(s *Service) *ProjectsService {
   192  	rs := &ProjectsService{s: s}
   193  	rs.Locations = NewProjectsLocationsService(s)
   194  	return rs
   195  }
   196  
   197  type ProjectsService struct {
   198  	s *Service
   199  
   200  	Locations *ProjectsLocationsService
   201  }
   202  
   203  func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
   204  	rs := &ProjectsLocationsService{s: s}
   205  	rs.Keys = NewProjectsLocationsKeysService(s)
   206  	return rs
   207  }
   208  
   209  type ProjectsLocationsService struct {
   210  	s *Service
   211  
   212  	Keys *ProjectsLocationsKeysService
   213  }
   214  
   215  func NewProjectsLocationsKeysService(s *Service) *ProjectsLocationsKeysService {
   216  	rs := &ProjectsLocationsKeysService{s: s}
   217  	return rs
   218  }
   219  
   220  type ProjectsLocationsKeysService struct {
   221  	s *Service
   222  }
   223  
   224  // Operation: This resource represents a long-running operation that is the
   225  // result of a network API call.
   226  type Operation struct {
   227  	// Done: If the value is `false`, it means the operation is still in progress.
   228  	// If `true`, the operation is completed, and either `error` or `response` is
   229  	// available.
   230  	Done bool `json:"done,omitempty"`
   231  	// Error: The error result of the operation in case of failure or cancellation.
   232  	Error *Status `json:"error,omitempty"`
   233  	// Metadata: Service-specific metadata associated with the operation. It
   234  	// typically contains progress information and common metadata such as create
   235  	// time. Some services might not provide such metadata. Any method that returns
   236  	// a long-running operation should document the metadata type, if any.
   237  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   238  	// Name: The server-assigned name, which is only unique within the same service
   239  	// that originally returns it. If you use the default HTTP mapping, the `name`
   240  	// should be a resource name ending with `operations/{unique_id}`.
   241  	Name string `json:"name,omitempty"`
   242  	// Response: The normal, successful response of the operation. If the original
   243  	// method returns no data on success, such as `Delete`, the response is
   244  	// `google.protobuf.Empty`. If the original method is standard
   245  	// `Get`/`Create`/`Update`, the response should be the resource. For other
   246  	// methods, the response should have the type `XxxResponse`, where `Xxx` is the
   247  	// original method name. For example, if the original method name is
   248  	// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
   249  	Response googleapi.RawMessage `json:"response,omitempty"`
   250  
   251  	// ServerResponse contains the HTTP response code and headers from the server.
   252  	googleapi.ServerResponse `json:"-"`
   253  	// ForceSendFields is a list of field names (e.g. "Done") to unconditionally
   254  	// include in API requests. By default, fields with empty or default values are
   255  	// omitted from API requests. See
   256  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   257  	// details.
   258  	ForceSendFields []string `json:"-"`
   259  	// NullFields is a list of field names (e.g. "Done") to include in API requests
   260  	// with the JSON null value. By default, fields with empty values are omitted
   261  	// from API requests. See
   262  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   263  	NullFields []string `json:"-"`
   264  }
   265  
   266  func (s *Operation) MarshalJSON() ([]byte, error) {
   267  	type NoMethod Operation
   268  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   269  }
   270  
   271  // Status: The `Status` type defines a logical error model that is suitable for
   272  // different programming environments, including REST APIs and RPC APIs. It is
   273  // used by gRPC (https://github.com/grpc). Each `Status` message contains three
   274  // pieces of data: error code, error message, and error details. You can find
   275  // out more about this error model and how to work with it in the API Design
   276  // Guide (https://cloud.google.com/apis/design/errors).
   277  type Status struct {
   278  	// Code: The status code, which should be an enum value of google.rpc.Code.
   279  	Code int64 `json:"code,omitempty"`
   280  	// Details: A list of messages that carry the error details. There is a common
   281  	// set of message types for APIs to use.
   282  	Details []googleapi.RawMessage `json:"details,omitempty"`
   283  	// Message: A developer-facing error message, which should be in English. Any
   284  	// user-facing error message should be localized and sent in the
   285  	// google.rpc.Status.details field, or localized by the client.
   286  	Message string `json:"message,omitempty"`
   287  	// ForceSendFields is a list of field names (e.g. "Code") to unconditionally
   288  	// include in API requests. By default, fields with empty or default values are
   289  	// omitted from API requests. See
   290  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   291  	// details.
   292  	ForceSendFields []string `json:"-"`
   293  	// NullFields is a list of field names (e.g. "Code") to include in API requests
   294  	// with the JSON null value. By default, fields with empty values are omitted
   295  	// from API requests. See
   296  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   297  	NullFields []string `json:"-"`
   298  }
   299  
   300  func (s *Status) MarshalJSON() ([]byte, error) {
   301  	type NoMethod Status
   302  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   303  }
   304  
   305  // V2AndroidApplication: Identifier of an Android application for key use.
   306  type V2AndroidApplication struct {
   307  	// PackageName: The package name of the application.
   308  	PackageName string `json:"packageName,omitempty"`
   309  	// Sha1Fingerprint: The SHA1 fingerprint of the application. For example, both
   310  	// sha1 formats are acceptable :
   311  	// DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09 or
   312  	// DA39A3EE5E6B4B0D3255BFEF95601890AFD80709. Output format is the latter.
   313  	Sha1Fingerprint string `json:"sha1Fingerprint,omitempty"`
   314  	// ForceSendFields is a list of field names (e.g. "PackageName") to
   315  	// unconditionally include in API requests. By default, fields with empty or
   316  	// default values are omitted from API requests. See
   317  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   318  	// details.
   319  	ForceSendFields []string `json:"-"`
   320  	// NullFields is a list of field names (e.g. "PackageName") to include in API
   321  	// requests with the JSON null value. By default, fields with empty values are
   322  	// omitted from API requests. See
   323  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   324  	NullFields []string `json:"-"`
   325  }
   326  
   327  func (s *V2AndroidApplication) MarshalJSON() ([]byte, error) {
   328  	type NoMethod V2AndroidApplication
   329  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   330  }
   331  
   332  // V2AndroidKeyRestrictions: The Android apps that are allowed to use the key.
   333  type V2AndroidKeyRestrictions struct {
   334  	// AllowedApplications: A list of Android applications that are allowed to make
   335  	// API calls with this key.
   336  	AllowedApplications []*V2AndroidApplication `json:"allowedApplications,omitempty"`
   337  	// ForceSendFields is a list of field names (e.g. "AllowedApplications") to
   338  	// unconditionally include in API requests. By default, fields with empty or
   339  	// default values are omitted from API requests. See
   340  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   341  	// details.
   342  	ForceSendFields []string `json:"-"`
   343  	// NullFields is a list of field names (e.g. "AllowedApplications") to include
   344  	// in API requests with the JSON null value. By default, fields with empty
   345  	// values are omitted from API requests. See
   346  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   347  	NullFields []string `json:"-"`
   348  }
   349  
   350  func (s *V2AndroidKeyRestrictions) MarshalJSON() ([]byte, error) {
   351  	type NoMethod V2AndroidKeyRestrictions
   352  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   353  }
   354  
   355  // V2ApiTarget: A restriction for a specific service and optionally one or
   356  // multiple specific methods. Both fields are case insensitive.
   357  type V2ApiTarget struct {
   358  	// Methods: Optional. List of one or more methods that can be called. If empty,
   359  	// all methods for the service are allowed. A wildcard (*) can be used as the
   360  	// last symbol. Valid examples:
   361  	// `google.cloud.translate.v2.TranslateService.GetSupportedLanguage`
   362  	// `TranslateText` `Get*` `translate.googleapis.com.Get*`
   363  	Methods []string `json:"methods,omitempty"`
   364  	// Service: The service for this restriction. It should be the canonical
   365  	// service name, for example: `translate.googleapis.com`. You can use `gcloud
   366  	// services list` (/sdk/gcloud/reference/services/list) to get a list of
   367  	// services that are enabled in the project.
   368  	Service string `json:"service,omitempty"`
   369  	// ForceSendFields is a list of field names (e.g. "Methods") to unconditionally
   370  	// include in API requests. By default, fields with empty or default values are
   371  	// omitted from API requests. See
   372  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   373  	// details.
   374  	ForceSendFields []string `json:"-"`
   375  	// NullFields is a list of field names (e.g. "Methods") to include in API
   376  	// requests with the JSON null value. By default, fields with empty values are
   377  	// omitted from API requests. See
   378  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   379  	NullFields []string `json:"-"`
   380  }
   381  
   382  func (s *V2ApiTarget) MarshalJSON() ([]byte, error) {
   383  	type NoMethod V2ApiTarget
   384  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   385  }
   386  
   387  // V2BrowserKeyRestrictions: The HTTP referrers (websites) that are allowed to
   388  // use the key.
   389  type V2BrowserKeyRestrictions struct {
   390  	// AllowedReferrers: A list of regular expressions for the referrer URLs that
   391  	// are allowed to make API calls with this key.
   392  	AllowedReferrers []string `json:"allowedReferrers,omitempty"`
   393  	// ForceSendFields is a list of field names (e.g. "AllowedReferrers") to
   394  	// unconditionally include in API requests. By default, fields with empty or
   395  	// default values are omitted from API requests. See
   396  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   397  	// details.
   398  	ForceSendFields []string `json:"-"`
   399  	// NullFields is a list of field names (e.g. "AllowedReferrers") to include in
   400  	// API requests with the JSON null value. By default, fields with empty values
   401  	// are omitted from API requests. See
   402  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   403  	NullFields []string `json:"-"`
   404  }
   405  
   406  func (s *V2BrowserKeyRestrictions) MarshalJSON() ([]byte, error) {
   407  	type NoMethod V2BrowserKeyRestrictions
   408  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   409  }
   410  
   411  // V2GetKeyStringResponse: Response message for `GetKeyString` method.
   412  type V2GetKeyStringResponse struct {
   413  	// KeyString: An encrypted and signed value of the key.
   414  	KeyString string `json:"keyString,omitempty"`
   415  
   416  	// ServerResponse contains the HTTP response code and headers from the server.
   417  	googleapi.ServerResponse `json:"-"`
   418  	// ForceSendFields is a list of field names (e.g. "KeyString") to
   419  	// unconditionally include in API requests. By default, fields with empty or
   420  	// default values are omitted from API requests. See
   421  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   422  	// details.
   423  	ForceSendFields []string `json:"-"`
   424  	// NullFields is a list of field names (e.g. "KeyString") to include in API
   425  	// requests with the JSON null value. By default, fields with empty values are
   426  	// omitted from API requests. See
   427  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   428  	NullFields []string `json:"-"`
   429  }
   430  
   431  func (s *V2GetKeyStringResponse) MarshalJSON() ([]byte, error) {
   432  	type NoMethod V2GetKeyStringResponse
   433  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   434  }
   435  
   436  // V2IosKeyRestrictions: The iOS apps that are allowed to use the key.
   437  type V2IosKeyRestrictions struct {
   438  	// AllowedBundleIds: A list of bundle IDs that are allowed when making API
   439  	// calls with this key.
   440  	AllowedBundleIds []string `json:"allowedBundleIds,omitempty"`
   441  	// ForceSendFields is a list of field names (e.g. "AllowedBundleIds") to
   442  	// unconditionally include in API requests. By default, fields with empty or
   443  	// default values are omitted from API requests. See
   444  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   445  	// details.
   446  	ForceSendFields []string `json:"-"`
   447  	// NullFields is a list of field names (e.g. "AllowedBundleIds") to include in
   448  	// API requests with the JSON null value. By default, fields with empty values
   449  	// are omitted from API requests. See
   450  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   451  	NullFields []string `json:"-"`
   452  }
   453  
   454  func (s *V2IosKeyRestrictions) MarshalJSON() ([]byte, error) {
   455  	type NoMethod V2IosKeyRestrictions
   456  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   457  }
   458  
   459  // V2Key: The representation of a key managed by the API Keys API.
   460  type V2Key struct {
   461  	// Annotations: Annotations is an unstructured key-value map stored with a
   462  	// policy that may be set by external tools to store and retrieve arbitrary
   463  	// metadata. They are not queryable and should be preserved when modifying
   464  	// objects.
   465  	Annotations map[string]string `json:"annotations,omitempty"`
   466  	// CreateTime: Output only. A timestamp identifying the time this key was
   467  	// originally created.
   468  	CreateTime string `json:"createTime,omitempty"`
   469  	// DeleteTime: Output only. A timestamp when this key was deleted. If the
   470  	// resource is not deleted, this must be empty.
   471  	DeleteTime string `json:"deleteTime,omitempty"`
   472  	// DisplayName: Human-readable display name of this key that you can modify.
   473  	// The maximum length is 63 characters.
   474  	DisplayName string `json:"displayName,omitempty"`
   475  	// Etag: Output only. A checksum computed by the server based on the current
   476  	// value of the Key resource. This may be sent on update and delete requests to
   477  	// ensure the client has an up-to-date value before proceeding. See
   478  	// https://google.aip.dev/154.
   479  	Etag string `json:"etag,omitempty"`
   480  	// KeyString: Output only. An encrypted and signed value held by this key. This
   481  	// field can be accessed only through the `GetKeyString` method.
   482  	KeyString string `json:"keyString,omitempty"`
   483  	// Name: Output only. The resource name of the key. The `name` has the form:
   484  	// `projects//locations/global/keys/`. For example:
   485  	// `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b
   486  	// 5dd2` NOTE: Key is a global resource; hence the only supported value for
   487  	// location is `global`.
   488  	Name string `json:"name,omitempty"`
   489  	// Restrictions: Key restrictions.
   490  	Restrictions *V2Restrictions `json:"restrictions,omitempty"`
   491  	// Uid: Output only. Unique id in UUID4 format.
   492  	Uid string `json:"uid,omitempty"`
   493  	// UpdateTime: Output only. A timestamp identifying the time this key was last
   494  	// updated.
   495  	UpdateTime string `json:"updateTime,omitempty"`
   496  
   497  	// ServerResponse contains the HTTP response code and headers from the server.
   498  	googleapi.ServerResponse `json:"-"`
   499  	// ForceSendFields is a list of field names (e.g. "Annotations") to
   500  	// unconditionally include in API requests. By default, fields with empty or
   501  	// default values are omitted from API requests. See
   502  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   503  	// details.
   504  	ForceSendFields []string `json:"-"`
   505  	// NullFields is a list of field names (e.g. "Annotations") to include in API
   506  	// requests with the JSON null value. By default, fields with empty values are
   507  	// omitted from API requests. See
   508  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   509  	NullFields []string `json:"-"`
   510  }
   511  
   512  func (s *V2Key) MarshalJSON() ([]byte, error) {
   513  	type NoMethod V2Key
   514  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   515  }
   516  
   517  // V2ListKeysResponse: Response message for `ListKeys` method.
   518  type V2ListKeysResponse struct {
   519  	// Keys: A list of API keys.
   520  	Keys []*V2Key `json:"keys,omitempty"`
   521  	// NextPageToken: The pagination token for the next page of results.
   522  	NextPageToken string `json:"nextPageToken,omitempty"`
   523  
   524  	// ServerResponse contains the HTTP response code and headers from the server.
   525  	googleapi.ServerResponse `json:"-"`
   526  	// ForceSendFields is a list of field names (e.g. "Keys") to unconditionally
   527  	// include in API requests. By default, fields with empty or default values are
   528  	// omitted from API requests. See
   529  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   530  	// details.
   531  	ForceSendFields []string `json:"-"`
   532  	// NullFields is a list of field names (e.g. "Keys") to include in API requests
   533  	// with the JSON null value. By default, fields with empty values are omitted
   534  	// from API requests. See
   535  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   536  	NullFields []string `json:"-"`
   537  }
   538  
   539  func (s *V2ListKeysResponse) MarshalJSON() ([]byte, error) {
   540  	type NoMethod V2ListKeysResponse
   541  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   542  }
   543  
   544  // V2LookupKeyResponse: Response message for `LookupKey` method.
   545  type V2LookupKeyResponse struct {
   546  	// Name: The resource name of the API key. If the API key has been purged,
   547  	// resource name is empty.
   548  	Name string `json:"name,omitempty"`
   549  	// Parent: The project that owns the key with the value specified in the
   550  	// request.
   551  	Parent string `json:"parent,omitempty"`
   552  
   553  	// ServerResponse contains the HTTP response code and headers from the server.
   554  	googleapi.ServerResponse `json:"-"`
   555  	// ForceSendFields is a list of field names (e.g. "Name") to unconditionally
   556  	// include in API requests. By default, fields with empty or default values are
   557  	// omitted from API requests. See
   558  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   559  	// details.
   560  	ForceSendFields []string `json:"-"`
   561  	// NullFields is a list of field names (e.g. "Name") to include in API requests
   562  	// with the JSON null value. By default, fields with empty values are omitted
   563  	// from API requests. See
   564  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   565  	NullFields []string `json:"-"`
   566  }
   567  
   568  func (s *V2LookupKeyResponse) MarshalJSON() ([]byte, error) {
   569  	type NoMethod V2LookupKeyResponse
   570  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   571  }
   572  
   573  // V2Restrictions: Describes the restrictions on the key.
   574  type V2Restrictions struct {
   575  	// AndroidKeyRestrictions: The Android apps that are allowed to use the key.
   576  	AndroidKeyRestrictions *V2AndroidKeyRestrictions `json:"androidKeyRestrictions,omitempty"`
   577  	// ApiTargets: A restriction for a specific service and optionally one or more
   578  	// specific methods. Requests are allowed if they match any of these
   579  	// restrictions. If no restrictions are specified, all targets are allowed.
   580  	ApiTargets []*V2ApiTarget `json:"apiTargets,omitempty"`
   581  	// BrowserKeyRestrictions: The HTTP referrers (websites) that are allowed to
   582  	// use the key.
   583  	BrowserKeyRestrictions *V2BrowserKeyRestrictions `json:"browserKeyRestrictions,omitempty"`
   584  	// IosKeyRestrictions: The iOS apps that are allowed to use the key.
   585  	IosKeyRestrictions *V2IosKeyRestrictions `json:"iosKeyRestrictions,omitempty"`
   586  	// ServerKeyRestrictions: The IP addresses of callers that are allowed to use
   587  	// the key.
   588  	ServerKeyRestrictions *V2ServerKeyRestrictions `json:"serverKeyRestrictions,omitempty"`
   589  	// ForceSendFields is a list of field names (e.g. "AndroidKeyRestrictions") to
   590  	// unconditionally include in API requests. By default, fields with empty or
   591  	// default values are omitted from API requests. See
   592  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   593  	// details.
   594  	ForceSendFields []string `json:"-"`
   595  	// NullFields is a list of field names (e.g. "AndroidKeyRestrictions") to
   596  	// include in API requests with the JSON null value. By default, fields with
   597  	// empty values are omitted from API requests. See
   598  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   599  	NullFields []string `json:"-"`
   600  }
   601  
   602  func (s *V2Restrictions) MarshalJSON() ([]byte, error) {
   603  	type NoMethod V2Restrictions
   604  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   605  }
   606  
   607  // V2ServerKeyRestrictions: The IP addresses of callers that are allowed to use
   608  // the key.
   609  type V2ServerKeyRestrictions struct {
   610  	// AllowedIps: A list of the caller IP addresses that are allowed to make API
   611  	// calls with this key.
   612  	AllowedIps []string `json:"allowedIps,omitempty"`
   613  	// ForceSendFields is a list of field names (e.g. "AllowedIps") to
   614  	// unconditionally include in API requests. By default, fields with empty or
   615  	// default values are omitted from API requests. See
   616  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   617  	// details.
   618  	ForceSendFields []string `json:"-"`
   619  	// NullFields is a list of field names (e.g. "AllowedIps") to include in API
   620  	// requests with the JSON null value. By default, fields with empty values are
   621  	// omitted from API requests. See
   622  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   623  	NullFields []string `json:"-"`
   624  }
   625  
   626  func (s *V2ServerKeyRestrictions) MarshalJSON() ([]byte, error) {
   627  	type NoMethod V2ServerKeyRestrictions
   628  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   629  }
   630  
   631  // V2UndeleteKeyRequest: Request message for `UndeleteKey` method.
   632  type V2UndeleteKeyRequest struct {
   633  }
   634  
   635  type KeysLookupKeyCall struct {
   636  	s            *Service
   637  	urlParams_   gensupport.URLParams
   638  	ifNoneMatch_ string
   639  	ctx_         context.Context
   640  	header_      http.Header
   641  }
   642  
   643  // LookupKey: Find the parent project and resource name of the API key that
   644  // matches the key string in the request. If the API key has been purged,
   645  // resource name will not be set. The service account must have the
   646  // `apikeys.keys.lookup` permission on the parent project.
   647  func (r *KeysService) LookupKey() *KeysLookupKeyCall {
   648  	c := &KeysLookupKeyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   649  	return c
   650  }
   651  
   652  // KeyString sets the optional parameter "keyString": Required. Finds the
   653  // project that owns the key string value.
   654  func (c *KeysLookupKeyCall) KeyString(keyString string) *KeysLookupKeyCall {
   655  	c.urlParams_.Set("keyString", keyString)
   656  	return c
   657  }
   658  
   659  // Fields allows partial responses to be retrieved. See
   660  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   661  // details.
   662  func (c *KeysLookupKeyCall) Fields(s ...googleapi.Field) *KeysLookupKeyCall {
   663  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   664  	return c
   665  }
   666  
   667  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   668  // object's ETag matches the given value. This is useful for getting updates
   669  // only after the object has changed since the last request.
   670  func (c *KeysLookupKeyCall) IfNoneMatch(entityTag string) *KeysLookupKeyCall {
   671  	c.ifNoneMatch_ = entityTag
   672  	return c
   673  }
   674  
   675  // Context sets the context to be used in this call's Do method.
   676  func (c *KeysLookupKeyCall) Context(ctx context.Context) *KeysLookupKeyCall {
   677  	c.ctx_ = ctx
   678  	return c
   679  }
   680  
   681  // Header returns a http.Header that can be modified by the caller to add
   682  // headers to the request.
   683  func (c *KeysLookupKeyCall) Header() http.Header {
   684  	if c.header_ == nil {
   685  		c.header_ = make(http.Header)
   686  	}
   687  	return c.header_
   688  }
   689  
   690  func (c *KeysLookupKeyCall) doRequest(alt string) (*http.Response, error) {
   691  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   692  	if c.ifNoneMatch_ != "" {
   693  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   694  	}
   695  	var body io.Reader = nil
   696  	c.urlParams_.Set("alt", alt)
   697  	c.urlParams_.Set("prettyPrint", "false")
   698  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/keys:lookupKey")
   699  	urls += "?" + c.urlParams_.Encode()
   700  	req, err := http.NewRequest("GET", urls, body)
   701  	if err != nil {
   702  		return nil, err
   703  	}
   704  	req.Header = reqHeaders
   705  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   706  }
   707  
   708  // Do executes the "apikeys.keys.lookupKey" call.
   709  // Any non-2xx status code is an error. Response headers are in either
   710  // *V2LookupKeyResponse.ServerResponse.Header or (if a response was returned at
   711  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   712  // check whether the returned error was because http.StatusNotModified was
   713  // returned.
   714  func (c *KeysLookupKeyCall) Do(opts ...googleapi.CallOption) (*V2LookupKeyResponse, error) {
   715  	gensupport.SetOptions(c.urlParams_, opts...)
   716  	res, err := c.doRequest("json")
   717  	if res != nil && res.StatusCode == http.StatusNotModified {
   718  		if res.Body != nil {
   719  			res.Body.Close()
   720  		}
   721  		return nil, gensupport.WrapError(&googleapi.Error{
   722  			Code:   res.StatusCode,
   723  			Header: res.Header,
   724  		})
   725  	}
   726  	if err != nil {
   727  		return nil, err
   728  	}
   729  	defer googleapi.CloseBody(res)
   730  	if err := googleapi.CheckResponse(res); err != nil {
   731  		return nil, gensupport.WrapError(err)
   732  	}
   733  	ret := &V2LookupKeyResponse{
   734  		ServerResponse: googleapi.ServerResponse{
   735  			Header:         res.Header,
   736  			HTTPStatusCode: res.StatusCode,
   737  		},
   738  	}
   739  	target := &ret
   740  	if err := gensupport.DecodeResponse(target, res); err != nil {
   741  		return nil, err
   742  	}
   743  	return ret, nil
   744  }
   745  
   746  type OperationsGetCall struct {
   747  	s            *Service
   748  	name         string
   749  	urlParams_   gensupport.URLParams
   750  	ifNoneMatch_ string
   751  	ctx_         context.Context
   752  	header_      http.Header
   753  }
   754  
   755  // Get: Gets the latest state of a long-running operation. Clients can use this
   756  // method to poll the operation result at intervals as recommended by the API
   757  // service.
   758  //
   759  // - name: The name of the operation resource.
   760  func (r *OperationsService) Get(name string) *OperationsGetCall {
   761  	c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   762  	c.name = name
   763  	return c
   764  }
   765  
   766  // Fields allows partial responses to be retrieved. See
   767  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   768  // details.
   769  func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall {
   770  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   771  	return c
   772  }
   773  
   774  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   775  // object's ETag matches the given value. This is useful for getting updates
   776  // only after the object has changed since the last request.
   777  func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall {
   778  	c.ifNoneMatch_ = entityTag
   779  	return c
   780  }
   781  
   782  // Context sets the context to be used in this call's Do method.
   783  func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall {
   784  	c.ctx_ = ctx
   785  	return c
   786  }
   787  
   788  // Header returns a http.Header that can be modified by the caller to add
   789  // headers to the request.
   790  func (c *OperationsGetCall) Header() http.Header {
   791  	if c.header_ == nil {
   792  		c.header_ = make(http.Header)
   793  	}
   794  	return c.header_
   795  }
   796  
   797  func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) {
   798  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   799  	if c.ifNoneMatch_ != "" {
   800  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   801  	}
   802  	var body io.Reader = nil
   803  	c.urlParams_.Set("alt", alt)
   804  	c.urlParams_.Set("prettyPrint", "false")
   805  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
   806  	urls += "?" + c.urlParams_.Encode()
   807  	req, err := http.NewRequest("GET", urls, body)
   808  	if err != nil {
   809  		return nil, err
   810  	}
   811  	req.Header = reqHeaders
   812  	googleapi.Expand(req.URL, map[string]string{
   813  		"name": c.name,
   814  	})
   815  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   816  }
   817  
   818  // Do executes the "apikeys.operations.get" call.
   819  // Any non-2xx status code is an error. Response headers are in either
   820  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   821  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   822  // whether the returned error was because http.StatusNotModified was returned.
   823  func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   824  	gensupport.SetOptions(c.urlParams_, opts...)
   825  	res, err := c.doRequest("json")
   826  	if res != nil && res.StatusCode == http.StatusNotModified {
   827  		if res.Body != nil {
   828  			res.Body.Close()
   829  		}
   830  		return nil, gensupport.WrapError(&googleapi.Error{
   831  			Code:   res.StatusCode,
   832  			Header: res.Header,
   833  		})
   834  	}
   835  	if err != nil {
   836  		return nil, err
   837  	}
   838  	defer googleapi.CloseBody(res)
   839  	if err := googleapi.CheckResponse(res); err != nil {
   840  		return nil, gensupport.WrapError(err)
   841  	}
   842  	ret := &Operation{
   843  		ServerResponse: googleapi.ServerResponse{
   844  			Header:         res.Header,
   845  			HTTPStatusCode: res.StatusCode,
   846  		},
   847  	}
   848  	target := &ret
   849  	if err := gensupport.DecodeResponse(target, res); err != nil {
   850  		return nil, err
   851  	}
   852  	return ret, nil
   853  }
   854  
   855  type ProjectsLocationsKeysCreateCall struct {
   856  	s          *Service
   857  	parent     string
   858  	v2key      *V2Key
   859  	urlParams_ gensupport.URLParams
   860  	ctx_       context.Context
   861  	header_    http.Header
   862  }
   863  
   864  // Create: Creates a new API key. NOTE: Key is a global resource; hence the
   865  // only supported value for location is `global`.
   866  //
   867  // - parent: The project in which the API key is created.
   868  func (r *ProjectsLocationsKeysService) Create(parent string, v2key *V2Key) *ProjectsLocationsKeysCreateCall {
   869  	c := &ProjectsLocationsKeysCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   870  	c.parent = parent
   871  	c.v2key = v2key
   872  	return c
   873  }
   874  
   875  // KeyId sets the optional parameter "keyId": User specified key id (optional).
   876  // If specified, it will become the final component of the key resource name.
   877  // The id must be unique within the project, must conform with RFC-1034, is
   878  // restricted to lower-cased letters, and has a maximum length of 63
   879  // characters. In another word, the id must match the regular expression:
   880  // `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id must NOT be a UUID-like string.
   881  func (c *ProjectsLocationsKeysCreateCall) KeyId(keyId string) *ProjectsLocationsKeysCreateCall {
   882  	c.urlParams_.Set("keyId", keyId)
   883  	return c
   884  }
   885  
   886  // Fields allows partial responses to be retrieved. See
   887  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   888  // details.
   889  func (c *ProjectsLocationsKeysCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysCreateCall {
   890  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   891  	return c
   892  }
   893  
   894  // Context sets the context to be used in this call's Do method.
   895  func (c *ProjectsLocationsKeysCreateCall) Context(ctx context.Context) *ProjectsLocationsKeysCreateCall {
   896  	c.ctx_ = ctx
   897  	return c
   898  }
   899  
   900  // Header returns a http.Header that can be modified by the caller to add
   901  // headers to the request.
   902  func (c *ProjectsLocationsKeysCreateCall) Header() http.Header {
   903  	if c.header_ == nil {
   904  		c.header_ = make(http.Header)
   905  	}
   906  	return c.header_
   907  }
   908  
   909  func (c *ProjectsLocationsKeysCreateCall) doRequest(alt string) (*http.Response, error) {
   910  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   911  	var body io.Reader = nil
   912  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2key)
   913  	if err != nil {
   914  		return nil, err
   915  	}
   916  	c.urlParams_.Set("alt", alt)
   917  	c.urlParams_.Set("prettyPrint", "false")
   918  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/keys")
   919  	urls += "?" + c.urlParams_.Encode()
   920  	req, err := http.NewRequest("POST", urls, body)
   921  	if err != nil {
   922  		return nil, err
   923  	}
   924  	req.Header = reqHeaders
   925  	googleapi.Expand(req.URL, map[string]string{
   926  		"parent": c.parent,
   927  	})
   928  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   929  }
   930  
   931  // Do executes the "apikeys.projects.locations.keys.create" call.
   932  // Any non-2xx status code is an error. Response headers are in either
   933  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   934  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   935  // whether the returned error was because http.StatusNotModified was returned.
   936  func (c *ProjectsLocationsKeysCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   937  	gensupport.SetOptions(c.urlParams_, opts...)
   938  	res, err := c.doRequest("json")
   939  	if res != nil && res.StatusCode == http.StatusNotModified {
   940  		if res.Body != nil {
   941  			res.Body.Close()
   942  		}
   943  		return nil, gensupport.WrapError(&googleapi.Error{
   944  			Code:   res.StatusCode,
   945  			Header: res.Header,
   946  		})
   947  	}
   948  	if err != nil {
   949  		return nil, err
   950  	}
   951  	defer googleapi.CloseBody(res)
   952  	if err := googleapi.CheckResponse(res); err != nil {
   953  		return nil, gensupport.WrapError(err)
   954  	}
   955  	ret := &Operation{
   956  		ServerResponse: googleapi.ServerResponse{
   957  			Header:         res.Header,
   958  			HTTPStatusCode: res.StatusCode,
   959  		},
   960  	}
   961  	target := &ret
   962  	if err := gensupport.DecodeResponse(target, res); err != nil {
   963  		return nil, err
   964  	}
   965  	return ret, nil
   966  }
   967  
   968  type ProjectsLocationsKeysDeleteCall struct {
   969  	s          *Service
   970  	name       string
   971  	urlParams_ gensupport.URLParams
   972  	ctx_       context.Context
   973  	header_    http.Header
   974  }
   975  
   976  // Delete: Deletes an API key. Deleted key can be retrieved within 30 days of
   977  // deletion. Afterward, key will be purged from the project. NOTE: Key is a
   978  // global resource; hence the only supported value for location is `global`.
   979  //
   980  // - name: The resource name of the API key to be deleted.
   981  func (r *ProjectsLocationsKeysService) Delete(name string) *ProjectsLocationsKeysDeleteCall {
   982  	c := &ProjectsLocationsKeysDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   983  	c.name = name
   984  	return c
   985  }
   986  
   987  // Etag sets the optional parameter "etag": The etag known to the client for
   988  // the expected state of the key. This is to be used for optimistic
   989  // concurrency.
   990  func (c *ProjectsLocationsKeysDeleteCall) Etag(etag string) *ProjectsLocationsKeysDeleteCall {
   991  	c.urlParams_.Set("etag", etag)
   992  	return c
   993  }
   994  
   995  // Fields allows partial responses to be retrieved. See
   996  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   997  // details.
   998  func (c *ProjectsLocationsKeysDeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysDeleteCall {
   999  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1000  	return c
  1001  }
  1002  
  1003  // Context sets the context to be used in this call's Do method.
  1004  func (c *ProjectsLocationsKeysDeleteCall) Context(ctx context.Context) *ProjectsLocationsKeysDeleteCall {
  1005  	c.ctx_ = ctx
  1006  	return c
  1007  }
  1008  
  1009  // Header returns a http.Header that can be modified by the caller to add
  1010  // headers to the request.
  1011  func (c *ProjectsLocationsKeysDeleteCall) Header() http.Header {
  1012  	if c.header_ == nil {
  1013  		c.header_ = make(http.Header)
  1014  	}
  1015  	return c.header_
  1016  }
  1017  
  1018  func (c *ProjectsLocationsKeysDeleteCall) doRequest(alt string) (*http.Response, error) {
  1019  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1020  	var body io.Reader = nil
  1021  	c.urlParams_.Set("alt", alt)
  1022  	c.urlParams_.Set("prettyPrint", "false")
  1023  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
  1024  	urls += "?" + c.urlParams_.Encode()
  1025  	req, err := http.NewRequest("DELETE", urls, body)
  1026  	if err != nil {
  1027  		return nil, err
  1028  	}
  1029  	req.Header = reqHeaders
  1030  	googleapi.Expand(req.URL, map[string]string{
  1031  		"name": c.name,
  1032  	})
  1033  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1034  }
  1035  
  1036  // Do executes the "apikeys.projects.locations.keys.delete" call.
  1037  // Any non-2xx status code is an error. Response headers are in either
  1038  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1039  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1040  // whether the returned error was because http.StatusNotModified was returned.
  1041  func (c *ProjectsLocationsKeysDeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1042  	gensupport.SetOptions(c.urlParams_, opts...)
  1043  	res, err := c.doRequest("json")
  1044  	if res != nil && res.StatusCode == http.StatusNotModified {
  1045  		if res.Body != nil {
  1046  			res.Body.Close()
  1047  		}
  1048  		return nil, gensupport.WrapError(&googleapi.Error{
  1049  			Code:   res.StatusCode,
  1050  			Header: res.Header,
  1051  		})
  1052  	}
  1053  	if err != nil {
  1054  		return nil, err
  1055  	}
  1056  	defer googleapi.CloseBody(res)
  1057  	if err := googleapi.CheckResponse(res); err != nil {
  1058  		return nil, gensupport.WrapError(err)
  1059  	}
  1060  	ret := &Operation{
  1061  		ServerResponse: googleapi.ServerResponse{
  1062  			Header:         res.Header,
  1063  			HTTPStatusCode: res.StatusCode,
  1064  		},
  1065  	}
  1066  	target := &ret
  1067  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1068  		return nil, err
  1069  	}
  1070  	return ret, nil
  1071  }
  1072  
  1073  type ProjectsLocationsKeysGetCall struct {
  1074  	s            *Service
  1075  	name         string
  1076  	urlParams_   gensupport.URLParams
  1077  	ifNoneMatch_ string
  1078  	ctx_         context.Context
  1079  	header_      http.Header
  1080  }
  1081  
  1082  // Get: Gets the metadata for an API key. The key string of the API key isn't
  1083  // included in the response. NOTE: Key is a global resource; hence the only
  1084  // supported value for location is `global`.
  1085  //
  1086  // - name: The resource name of the API key to get.
  1087  func (r *ProjectsLocationsKeysService) Get(name string) *ProjectsLocationsKeysGetCall {
  1088  	c := &ProjectsLocationsKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1089  	c.name = name
  1090  	return c
  1091  }
  1092  
  1093  // Fields allows partial responses to be retrieved. See
  1094  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1095  // details.
  1096  func (c *ProjectsLocationsKeysGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysGetCall {
  1097  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1098  	return c
  1099  }
  1100  
  1101  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1102  // object's ETag matches the given value. This is useful for getting updates
  1103  // only after the object has changed since the last request.
  1104  func (c *ProjectsLocationsKeysGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysGetCall {
  1105  	c.ifNoneMatch_ = entityTag
  1106  	return c
  1107  }
  1108  
  1109  // Context sets the context to be used in this call's Do method.
  1110  func (c *ProjectsLocationsKeysGetCall) Context(ctx context.Context) *ProjectsLocationsKeysGetCall {
  1111  	c.ctx_ = ctx
  1112  	return c
  1113  }
  1114  
  1115  // Header returns a http.Header that can be modified by the caller to add
  1116  // headers to the request.
  1117  func (c *ProjectsLocationsKeysGetCall) Header() http.Header {
  1118  	if c.header_ == nil {
  1119  		c.header_ = make(http.Header)
  1120  	}
  1121  	return c.header_
  1122  }
  1123  
  1124  func (c *ProjectsLocationsKeysGetCall) doRequest(alt string) (*http.Response, error) {
  1125  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1126  	if c.ifNoneMatch_ != "" {
  1127  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1128  	}
  1129  	var body io.Reader = nil
  1130  	c.urlParams_.Set("alt", alt)
  1131  	c.urlParams_.Set("prettyPrint", "false")
  1132  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
  1133  	urls += "?" + c.urlParams_.Encode()
  1134  	req, err := http.NewRequest("GET", urls, body)
  1135  	if err != nil {
  1136  		return nil, err
  1137  	}
  1138  	req.Header = reqHeaders
  1139  	googleapi.Expand(req.URL, map[string]string{
  1140  		"name": c.name,
  1141  	})
  1142  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1143  }
  1144  
  1145  // Do executes the "apikeys.projects.locations.keys.get" call.
  1146  // Any non-2xx status code is an error. Response headers are in either
  1147  // *V2Key.ServerResponse.Header or (if a response was returned at all) in
  1148  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1149  // whether the returned error was because http.StatusNotModified was returned.
  1150  func (c *ProjectsLocationsKeysGetCall) Do(opts ...googleapi.CallOption) (*V2Key, error) {
  1151  	gensupport.SetOptions(c.urlParams_, opts...)
  1152  	res, err := c.doRequest("json")
  1153  	if res != nil && res.StatusCode == http.StatusNotModified {
  1154  		if res.Body != nil {
  1155  			res.Body.Close()
  1156  		}
  1157  		return nil, gensupport.WrapError(&googleapi.Error{
  1158  			Code:   res.StatusCode,
  1159  			Header: res.Header,
  1160  		})
  1161  	}
  1162  	if err != nil {
  1163  		return nil, err
  1164  	}
  1165  	defer googleapi.CloseBody(res)
  1166  	if err := googleapi.CheckResponse(res); err != nil {
  1167  		return nil, gensupport.WrapError(err)
  1168  	}
  1169  	ret := &V2Key{
  1170  		ServerResponse: googleapi.ServerResponse{
  1171  			Header:         res.Header,
  1172  			HTTPStatusCode: res.StatusCode,
  1173  		},
  1174  	}
  1175  	target := &ret
  1176  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1177  		return nil, err
  1178  	}
  1179  	return ret, nil
  1180  }
  1181  
  1182  type ProjectsLocationsKeysGetKeyStringCall struct {
  1183  	s            *Service
  1184  	name         string
  1185  	urlParams_   gensupport.URLParams
  1186  	ifNoneMatch_ string
  1187  	ctx_         context.Context
  1188  	header_      http.Header
  1189  }
  1190  
  1191  // GetKeyString: Get the key string for an API key. NOTE: Key is a global
  1192  // resource; hence the only supported value for location is `global`.
  1193  //
  1194  // - name: The resource name of the API key to be retrieved.
  1195  func (r *ProjectsLocationsKeysService) GetKeyString(name string) *ProjectsLocationsKeysGetKeyStringCall {
  1196  	c := &ProjectsLocationsKeysGetKeyStringCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1197  	c.name = name
  1198  	return c
  1199  }
  1200  
  1201  // Fields allows partial responses to be retrieved. See
  1202  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1203  // details.
  1204  func (c *ProjectsLocationsKeysGetKeyStringCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysGetKeyStringCall {
  1205  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1206  	return c
  1207  }
  1208  
  1209  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1210  // object's ETag matches the given value. This is useful for getting updates
  1211  // only after the object has changed since the last request.
  1212  func (c *ProjectsLocationsKeysGetKeyStringCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysGetKeyStringCall {
  1213  	c.ifNoneMatch_ = entityTag
  1214  	return c
  1215  }
  1216  
  1217  // Context sets the context to be used in this call's Do method.
  1218  func (c *ProjectsLocationsKeysGetKeyStringCall) Context(ctx context.Context) *ProjectsLocationsKeysGetKeyStringCall {
  1219  	c.ctx_ = ctx
  1220  	return c
  1221  }
  1222  
  1223  // Header returns a http.Header that can be modified by the caller to add
  1224  // headers to the request.
  1225  func (c *ProjectsLocationsKeysGetKeyStringCall) Header() http.Header {
  1226  	if c.header_ == nil {
  1227  		c.header_ = make(http.Header)
  1228  	}
  1229  	return c.header_
  1230  }
  1231  
  1232  func (c *ProjectsLocationsKeysGetKeyStringCall) doRequest(alt string) (*http.Response, error) {
  1233  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1234  	if c.ifNoneMatch_ != "" {
  1235  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1236  	}
  1237  	var body io.Reader = nil
  1238  	c.urlParams_.Set("alt", alt)
  1239  	c.urlParams_.Set("prettyPrint", "false")
  1240  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}/keyString")
  1241  	urls += "?" + c.urlParams_.Encode()
  1242  	req, err := http.NewRequest("GET", urls, body)
  1243  	if err != nil {
  1244  		return nil, err
  1245  	}
  1246  	req.Header = reqHeaders
  1247  	googleapi.Expand(req.URL, map[string]string{
  1248  		"name": c.name,
  1249  	})
  1250  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1251  }
  1252  
  1253  // Do executes the "apikeys.projects.locations.keys.getKeyString" call.
  1254  // Any non-2xx status code is an error. Response headers are in either
  1255  // *V2GetKeyStringResponse.ServerResponse.Header or (if a response was returned
  1256  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1257  // check whether the returned error was because http.StatusNotModified was
  1258  // returned.
  1259  func (c *ProjectsLocationsKeysGetKeyStringCall) Do(opts ...googleapi.CallOption) (*V2GetKeyStringResponse, error) {
  1260  	gensupport.SetOptions(c.urlParams_, opts...)
  1261  	res, err := c.doRequest("json")
  1262  	if res != nil && res.StatusCode == http.StatusNotModified {
  1263  		if res.Body != nil {
  1264  			res.Body.Close()
  1265  		}
  1266  		return nil, gensupport.WrapError(&googleapi.Error{
  1267  			Code:   res.StatusCode,
  1268  			Header: res.Header,
  1269  		})
  1270  	}
  1271  	if err != nil {
  1272  		return nil, err
  1273  	}
  1274  	defer googleapi.CloseBody(res)
  1275  	if err := googleapi.CheckResponse(res); err != nil {
  1276  		return nil, gensupport.WrapError(err)
  1277  	}
  1278  	ret := &V2GetKeyStringResponse{
  1279  		ServerResponse: googleapi.ServerResponse{
  1280  			Header:         res.Header,
  1281  			HTTPStatusCode: res.StatusCode,
  1282  		},
  1283  	}
  1284  	target := &ret
  1285  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1286  		return nil, err
  1287  	}
  1288  	return ret, nil
  1289  }
  1290  
  1291  type ProjectsLocationsKeysListCall struct {
  1292  	s            *Service
  1293  	parent       string
  1294  	urlParams_   gensupport.URLParams
  1295  	ifNoneMatch_ string
  1296  	ctx_         context.Context
  1297  	header_      http.Header
  1298  }
  1299  
  1300  // List: Lists the API keys owned by a project. The key string of the API key
  1301  // isn't included in the response. NOTE: Key is a global resource; hence the
  1302  // only supported value for location is `global`.
  1303  //
  1304  // - parent: Lists all API keys associated with this project.
  1305  func (r *ProjectsLocationsKeysService) List(parent string) *ProjectsLocationsKeysListCall {
  1306  	c := &ProjectsLocationsKeysListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1307  	c.parent = parent
  1308  	return c
  1309  }
  1310  
  1311  // PageSize sets the optional parameter "pageSize": Specifies the maximum
  1312  // number of results to be returned at a time.
  1313  func (c *ProjectsLocationsKeysListCall) PageSize(pageSize int64) *ProjectsLocationsKeysListCall {
  1314  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1315  	return c
  1316  }
  1317  
  1318  // PageToken sets the optional parameter "pageToken": Requests a specific page
  1319  // of results.
  1320  func (c *ProjectsLocationsKeysListCall) PageToken(pageToken string) *ProjectsLocationsKeysListCall {
  1321  	c.urlParams_.Set("pageToken", pageToken)
  1322  	return c
  1323  }
  1324  
  1325  // ShowDeleted sets the optional parameter "showDeleted": Indicate that keys
  1326  // deleted in the past 30 days should also be returned.
  1327  func (c *ProjectsLocationsKeysListCall) ShowDeleted(showDeleted bool) *ProjectsLocationsKeysListCall {
  1328  	c.urlParams_.Set("showDeleted", fmt.Sprint(showDeleted))
  1329  	return c
  1330  }
  1331  
  1332  // Fields allows partial responses to be retrieved. See
  1333  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1334  // details.
  1335  func (c *ProjectsLocationsKeysListCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysListCall {
  1336  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1337  	return c
  1338  }
  1339  
  1340  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1341  // object's ETag matches the given value. This is useful for getting updates
  1342  // only after the object has changed since the last request.
  1343  func (c *ProjectsLocationsKeysListCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeysListCall {
  1344  	c.ifNoneMatch_ = entityTag
  1345  	return c
  1346  }
  1347  
  1348  // Context sets the context to be used in this call's Do method.
  1349  func (c *ProjectsLocationsKeysListCall) Context(ctx context.Context) *ProjectsLocationsKeysListCall {
  1350  	c.ctx_ = ctx
  1351  	return c
  1352  }
  1353  
  1354  // Header returns a http.Header that can be modified by the caller to add
  1355  // headers to the request.
  1356  func (c *ProjectsLocationsKeysListCall) Header() http.Header {
  1357  	if c.header_ == nil {
  1358  		c.header_ = make(http.Header)
  1359  	}
  1360  	return c.header_
  1361  }
  1362  
  1363  func (c *ProjectsLocationsKeysListCall) doRequest(alt string) (*http.Response, error) {
  1364  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1365  	if c.ifNoneMatch_ != "" {
  1366  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1367  	}
  1368  	var body io.Reader = nil
  1369  	c.urlParams_.Set("alt", alt)
  1370  	c.urlParams_.Set("prettyPrint", "false")
  1371  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/keys")
  1372  	urls += "?" + c.urlParams_.Encode()
  1373  	req, err := http.NewRequest("GET", urls, body)
  1374  	if err != nil {
  1375  		return nil, err
  1376  	}
  1377  	req.Header = reqHeaders
  1378  	googleapi.Expand(req.URL, map[string]string{
  1379  		"parent": c.parent,
  1380  	})
  1381  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1382  }
  1383  
  1384  // Do executes the "apikeys.projects.locations.keys.list" call.
  1385  // Any non-2xx status code is an error. Response headers are in either
  1386  // *V2ListKeysResponse.ServerResponse.Header or (if a response was returned at
  1387  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1388  // check whether the returned error was because http.StatusNotModified was
  1389  // returned.
  1390  func (c *ProjectsLocationsKeysListCall) Do(opts ...googleapi.CallOption) (*V2ListKeysResponse, error) {
  1391  	gensupport.SetOptions(c.urlParams_, opts...)
  1392  	res, err := c.doRequest("json")
  1393  	if res != nil && res.StatusCode == http.StatusNotModified {
  1394  		if res.Body != nil {
  1395  			res.Body.Close()
  1396  		}
  1397  		return nil, gensupport.WrapError(&googleapi.Error{
  1398  			Code:   res.StatusCode,
  1399  			Header: res.Header,
  1400  		})
  1401  	}
  1402  	if err != nil {
  1403  		return nil, err
  1404  	}
  1405  	defer googleapi.CloseBody(res)
  1406  	if err := googleapi.CheckResponse(res); err != nil {
  1407  		return nil, gensupport.WrapError(err)
  1408  	}
  1409  	ret := &V2ListKeysResponse{
  1410  		ServerResponse: googleapi.ServerResponse{
  1411  			Header:         res.Header,
  1412  			HTTPStatusCode: res.StatusCode,
  1413  		},
  1414  	}
  1415  	target := &ret
  1416  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1417  		return nil, err
  1418  	}
  1419  	return ret, nil
  1420  }
  1421  
  1422  // Pages invokes f for each page of results.
  1423  // A non-nil error returned from f will halt the iteration.
  1424  // The provided context supersedes any context provided to the Context method.
  1425  func (c *ProjectsLocationsKeysListCall) Pages(ctx context.Context, f func(*V2ListKeysResponse) error) error {
  1426  	c.ctx_ = ctx
  1427  	defer c.PageToken(c.urlParams_.Get("pageToken"))
  1428  	for {
  1429  		x, err := c.Do()
  1430  		if err != nil {
  1431  			return err
  1432  		}
  1433  		if err := f(x); err != nil {
  1434  			return err
  1435  		}
  1436  		if x.NextPageToken == "" {
  1437  			return nil
  1438  		}
  1439  		c.PageToken(x.NextPageToken)
  1440  	}
  1441  }
  1442  
  1443  type ProjectsLocationsKeysPatchCall struct {
  1444  	s          *Service
  1445  	name       string
  1446  	v2key      *V2Key
  1447  	urlParams_ gensupport.URLParams
  1448  	ctx_       context.Context
  1449  	header_    http.Header
  1450  }
  1451  
  1452  // Patch: Patches the modifiable fields of an API key. The key string of the
  1453  // API key isn't included in the response. NOTE: Key is a global resource;
  1454  // hence the only supported value for location is `global`.
  1455  //
  1456  //   - name: Output only. The resource name of the key. The `name` has the form:
  1457  //     `projects//locations/global/keys/`. For example:
  1458  //     `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee
  1459  //     9b5dd2` NOTE: Key is a global resource; hence the only supported value for
  1460  //     location is `global`.
  1461  func (r *ProjectsLocationsKeysService) Patch(name string, v2key *V2Key) *ProjectsLocationsKeysPatchCall {
  1462  	c := &ProjectsLocationsKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1463  	c.name = name
  1464  	c.v2key = v2key
  1465  	return c
  1466  }
  1467  
  1468  // UpdateMask sets the optional parameter "updateMask": The field mask
  1469  // specifies which fields to be updated as part of this request. All other
  1470  // fields are ignored. Mutable fields are: `display_name`, `restrictions`, and
  1471  // `annotations`. If an update mask is not provided, the service treats it as
  1472  // an implied mask equivalent to all allowed fields that are set on the wire.
  1473  // If the field mask has a special value "*", the service treats it equivalent
  1474  // to replace all allowed mutable fields.
  1475  func (c *ProjectsLocationsKeysPatchCall) UpdateMask(updateMask string) *ProjectsLocationsKeysPatchCall {
  1476  	c.urlParams_.Set("updateMask", updateMask)
  1477  	return c
  1478  }
  1479  
  1480  // Fields allows partial responses to be retrieved. See
  1481  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1482  // details.
  1483  func (c *ProjectsLocationsKeysPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysPatchCall {
  1484  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1485  	return c
  1486  }
  1487  
  1488  // Context sets the context to be used in this call's Do method.
  1489  func (c *ProjectsLocationsKeysPatchCall) Context(ctx context.Context) *ProjectsLocationsKeysPatchCall {
  1490  	c.ctx_ = ctx
  1491  	return c
  1492  }
  1493  
  1494  // Header returns a http.Header that can be modified by the caller to add
  1495  // headers to the request.
  1496  func (c *ProjectsLocationsKeysPatchCall) Header() http.Header {
  1497  	if c.header_ == nil {
  1498  		c.header_ = make(http.Header)
  1499  	}
  1500  	return c.header_
  1501  }
  1502  
  1503  func (c *ProjectsLocationsKeysPatchCall) doRequest(alt string) (*http.Response, error) {
  1504  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1505  	var body io.Reader = nil
  1506  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2key)
  1507  	if err != nil {
  1508  		return nil, err
  1509  	}
  1510  	c.urlParams_.Set("alt", alt)
  1511  	c.urlParams_.Set("prettyPrint", "false")
  1512  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
  1513  	urls += "?" + c.urlParams_.Encode()
  1514  	req, err := http.NewRequest("PATCH", urls, body)
  1515  	if err != nil {
  1516  		return nil, err
  1517  	}
  1518  	req.Header = reqHeaders
  1519  	googleapi.Expand(req.URL, map[string]string{
  1520  		"name": c.name,
  1521  	})
  1522  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1523  }
  1524  
  1525  // Do executes the "apikeys.projects.locations.keys.patch" call.
  1526  // Any non-2xx status code is an error. Response headers are in either
  1527  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1528  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1529  // whether the returned error was because http.StatusNotModified was returned.
  1530  func (c *ProjectsLocationsKeysPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1531  	gensupport.SetOptions(c.urlParams_, opts...)
  1532  	res, err := c.doRequest("json")
  1533  	if res != nil && res.StatusCode == http.StatusNotModified {
  1534  		if res.Body != nil {
  1535  			res.Body.Close()
  1536  		}
  1537  		return nil, gensupport.WrapError(&googleapi.Error{
  1538  			Code:   res.StatusCode,
  1539  			Header: res.Header,
  1540  		})
  1541  	}
  1542  	if err != nil {
  1543  		return nil, err
  1544  	}
  1545  	defer googleapi.CloseBody(res)
  1546  	if err := googleapi.CheckResponse(res); err != nil {
  1547  		return nil, gensupport.WrapError(err)
  1548  	}
  1549  	ret := &Operation{
  1550  		ServerResponse: googleapi.ServerResponse{
  1551  			Header:         res.Header,
  1552  			HTTPStatusCode: res.StatusCode,
  1553  		},
  1554  	}
  1555  	target := &ret
  1556  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1557  		return nil, err
  1558  	}
  1559  	return ret, nil
  1560  }
  1561  
  1562  type ProjectsLocationsKeysUndeleteCall struct {
  1563  	s                    *Service
  1564  	name                 string
  1565  	v2undeletekeyrequest *V2UndeleteKeyRequest
  1566  	urlParams_           gensupport.URLParams
  1567  	ctx_                 context.Context
  1568  	header_              http.Header
  1569  }
  1570  
  1571  // Undelete: Undeletes an API key which was deleted within 30 days. NOTE: Key
  1572  // is a global resource; hence the only supported value for location is
  1573  // `global`.
  1574  //
  1575  // - name: The resource name of the API key to be undeleted.
  1576  func (r *ProjectsLocationsKeysService) Undelete(name string, v2undeletekeyrequest *V2UndeleteKeyRequest) *ProjectsLocationsKeysUndeleteCall {
  1577  	c := &ProjectsLocationsKeysUndeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1578  	c.name = name
  1579  	c.v2undeletekeyrequest = v2undeletekeyrequest
  1580  	return c
  1581  }
  1582  
  1583  // Fields allows partial responses to be retrieved. See
  1584  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1585  // details.
  1586  func (c *ProjectsLocationsKeysUndeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeysUndeleteCall {
  1587  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1588  	return c
  1589  }
  1590  
  1591  // Context sets the context to be used in this call's Do method.
  1592  func (c *ProjectsLocationsKeysUndeleteCall) Context(ctx context.Context) *ProjectsLocationsKeysUndeleteCall {
  1593  	c.ctx_ = ctx
  1594  	return c
  1595  }
  1596  
  1597  // Header returns a http.Header that can be modified by the caller to add
  1598  // headers to the request.
  1599  func (c *ProjectsLocationsKeysUndeleteCall) Header() http.Header {
  1600  	if c.header_ == nil {
  1601  		c.header_ = make(http.Header)
  1602  	}
  1603  	return c.header_
  1604  }
  1605  
  1606  func (c *ProjectsLocationsKeysUndeleteCall) doRequest(alt string) (*http.Response, error) {
  1607  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1608  	var body io.Reader = nil
  1609  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.v2undeletekeyrequest)
  1610  	if err != nil {
  1611  		return nil, err
  1612  	}
  1613  	c.urlParams_.Set("alt", alt)
  1614  	c.urlParams_.Set("prettyPrint", "false")
  1615  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}:undelete")
  1616  	urls += "?" + c.urlParams_.Encode()
  1617  	req, err := http.NewRequest("POST", urls, body)
  1618  	if err != nil {
  1619  		return nil, err
  1620  	}
  1621  	req.Header = reqHeaders
  1622  	googleapi.Expand(req.URL, map[string]string{
  1623  		"name": c.name,
  1624  	})
  1625  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1626  }
  1627  
  1628  // Do executes the "apikeys.projects.locations.keys.undelete" call.
  1629  // Any non-2xx status code is an error. Response headers are in either
  1630  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1631  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1632  // whether the returned error was because http.StatusNotModified was returned.
  1633  func (c *ProjectsLocationsKeysUndeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1634  	gensupport.SetOptions(c.urlParams_, opts...)
  1635  	res, err := c.doRequest("json")
  1636  	if res != nil && res.StatusCode == http.StatusNotModified {
  1637  		if res.Body != nil {
  1638  			res.Body.Close()
  1639  		}
  1640  		return nil, gensupport.WrapError(&googleapi.Error{
  1641  			Code:   res.StatusCode,
  1642  			Header: res.Header,
  1643  		})
  1644  	}
  1645  	if err != nil {
  1646  		return nil, err
  1647  	}
  1648  	defer googleapi.CloseBody(res)
  1649  	if err := googleapi.CheckResponse(res); err != nil {
  1650  		return nil, gensupport.WrapError(err)
  1651  	}
  1652  	ret := &Operation{
  1653  		ServerResponse: googleapi.ServerResponse{
  1654  			Header:         res.Header,
  1655  			HTTPStatusCode: res.StatusCode,
  1656  		},
  1657  	}
  1658  	target := &ret
  1659  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1660  		return nil, err
  1661  	}
  1662  	return ret, nil
  1663  }
  1664  

View as plain text