...

Source file src/google.golang.org/api/gkehub/v2alpha/gkehub-gen.go

Documentation: google.golang.org/api/gkehub/v2alpha

     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 gkehub provides access to the GKE Hub API.
     8  //
     9  // For product documentation, see: https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster
    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/gkehub/v2alpha"
    27  //	...
    28  //	ctx := context.Background()
    29  //	gkehubService, err := gkehub.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  // To use an API key for authentication (note: some APIs do not support API
    38  // keys), use [google.golang.org/api/option.WithAPIKey]:
    39  //
    40  //	gkehubService, err := gkehub.NewService(ctx, option.WithAPIKey("AIza..."))
    41  //
    42  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    43  // flow, use [google.golang.org/api/option.WithTokenSource]:
    44  //
    45  //	config := &oauth2.Config{...}
    46  //	// ...
    47  //	token, err := config.Exchange(ctx, ...)
    48  //	gkehubService, err := gkehub.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package gkehub // import "google.golang.org/api/gkehub/v2alpha"
    52  
    53  import (
    54  	"bytes"
    55  	"context"
    56  	"encoding/json"
    57  	"errors"
    58  	"fmt"
    59  	"io"
    60  	"net/http"
    61  	"net/url"
    62  	"strconv"
    63  	"strings"
    64  
    65  	googleapi "google.golang.org/api/googleapi"
    66  	internal "google.golang.org/api/internal"
    67  	gensupport "google.golang.org/api/internal/gensupport"
    68  	option "google.golang.org/api/option"
    69  	internaloption "google.golang.org/api/option/internaloption"
    70  	htransport "google.golang.org/api/transport/http"
    71  )
    72  
    73  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    75  var _ = bytes.NewBuffer
    76  var _ = strconv.Itoa
    77  var _ = fmt.Sprintf
    78  var _ = json.NewDecoder
    79  var _ = io.Copy
    80  var _ = url.Parse
    81  var _ = gensupport.MarshalJSON
    82  var _ = googleapi.Version
    83  var _ = errors.New
    84  var _ = strings.Replace
    85  var _ = context.Canceled
    86  var _ = internaloption.WithDefaultEndpoint
    87  var _ = internal.Version
    88  
    89  const apiId = "gkehub:v2alpha"
    90  const apiName = "gkehub"
    91  const apiVersion = "v2alpha"
    92  const basePath = "https://gkehub.googleapis.com/"
    93  const basePathTemplate = "https://gkehub.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://gkehub.mtls.googleapis.com/"
    95  
    96  // OAuth2 scopes used by this API.
    97  const (
    98  	// See, edit, configure, and delete your Google Cloud data and see the email
    99  	// address for your Google Account.
   100  	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
   101  )
   102  
   103  // NewService creates a new Service.
   104  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   105  	scopesOption := internaloption.WithDefaultScopes(
   106  		"https://www.googleapis.com/auth/cloud-platform",
   107  	)
   108  	// NOTE: prepend, so we don't override user-specified scopes.
   109  	opts = append([]option.ClientOption{scopesOption}, opts...)
   110  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   111  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   112  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   113  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   114  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	s, err := New(client)
   119  	if err != nil {
   120  		return nil, err
   121  	}
   122  	if endpoint != "" {
   123  		s.BasePath = endpoint
   124  	}
   125  	return s, nil
   126  }
   127  
   128  // New creates a new Service. It uses the provided http.Client for requests.
   129  //
   130  // Deprecated: please use NewService instead.
   131  // To provide a custom HTTP client, use option.WithHTTPClient.
   132  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   133  func New(client *http.Client) (*Service, error) {
   134  	if client == nil {
   135  		return nil, errors.New("client is nil")
   136  	}
   137  	s := &Service{client: client, BasePath: basePath}
   138  	s.Projects = NewProjectsService(s)
   139  	return s, nil
   140  }
   141  
   142  type Service struct {
   143  	client    *http.Client
   144  	BasePath  string // API endpoint base URL
   145  	UserAgent string // optional additional User-Agent fragment
   146  
   147  	Projects *ProjectsService
   148  }
   149  
   150  func (s *Service) userAgent() string {
   151  	if s.UserAgent == "" {
   152  		return googleapi.UserAgent
   153  	}
   154  	return googleapi.UserAgent + " " + s.UserAgent
   155  }
   156  
   157  func NewProjectsService(s *Service) *ProjectsService {
   158  	rs := &ProjectsService{s: s}
   159  	rs.Locations = NewProjectsLocationsService(s)
   160  	return rs
   161  }
   162  
   163  type ProjectsService struct {
   164  	s *Service
   165  
   166  	Locations *ProjectsLocationsService
   167  }
   168  
   169  func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
   170  	rs := &ProjectsLocationsService{s: s}
   171  	rs.Operations = NewProjectsLocationsOperationsService(s)
   172  	return rs
   173  }
   174  
   175  type ProjectsLocationsService struct {
   176  	s *Service
   177  
   178  	Operations *ProjectsLocationsOperationsService
   179  }
   180  
   181  func NewProjectsLocationsOperationsService(s *Service) *ProjectsLocationsOperationsService {
   182  	rs := &ProjectsLocationsOperationsService{s: s}
   183  	return rs
   184  }
   185  
   186  type ProjectsLocationsOperationsService struct {
   187  	s *Service
   188  }
   189  
   190  // CancelOperationRequest: The request message for Operations.CancelOperation.
   191  type CancelOperationRequest struct {
   192  }
   193  
   194  // Empty: A generic empty message that you can re-use to avoid defining
   195  // duplicated empty messages in your APIs. A typical example is to use it as
   196  // the request or the response type of an API method. For instance: service Foo
   197  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   198  type Empty struct {
   199  	// ServerResponse contains the HTTP response code and headers from the server.
   200  	googleapi.ServerResponse `json:"-"`
   201  }
   202  
   203  // GoogleRpcStatus: The `Status` type defines a logical error model that is
   204  // suitable for different programming environments, including REST APIs and RPC
   205  // APIs. It is used by gRPC (https://github.com/grpc). Each `Status` message
   206  // contains three pieces of data: error code, error message, and error details.
   207  // You can find out more about this error model and how to work with it in the
   208  // API Design Guide (https://cloud.google.com/apis/design/errors).
   209  type GoogleRpcStatus struct {
   210  	// Code: The status code, which should be an enum value of google.rpc.Code.
   211  	Code int64 `json:"code,omitempty"`
   212  	// Details: A list of messages that carry the error details. There is a common
   213  	// set of message types for APIs to use.
   214  	Details []googleapi.RawMessage `json:"details,omitempty"`
   215  	// Message: A developer-facing error message, which should be in English. Any
   216  	// user-facing error message should be localized and sent in the
   217  	// google.rpc.Status.details field, or localized by the client.
   218  	Message string `json:"message,omitempty"`
   219  	// ForceSendFields is a list of field names (e.g. "Code") to unconditionally
   220  	// include in API requests. By default, fields with empty or default values are
   221  	// omitted from API requests. See
   222  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   223  	// details.
   224  	ForceSendFields []string `json:"-"`
   225  	// NullFields is a list of field names (e.g. "Code") to include in API requests
   226  	// with the JSON null value. By default, fields with empty values are omitted
   227  	// from API requests. See
   228  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   229  	NullFields []string `json:"-"`
   230  }
   231  
   232  func (s *GoogleRpcStatus) MarshalJSON() ([]byte, error) {
   233  	type NoMethod GoogleRpcStatus
   234  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   235  }
   236  
   237  // ListLocationsResponse: The response message for Locations.ListLocations.
   238  type ListLocationsResponse struct {
   239  	// Locations: A list of locations that matches the specified filter in the
   240  	// request.
   241  	Locations []*Location `json:"locations,omitempty"`
   242  	// NextPageToken: The standard List next-page token.
   243  	NextPageToken string `json:"nextPageToken,omitempty"`
   244  
   245  	// ServerResponse contains the HTTP response code and headers from the server.
   246  	googleapi.ServerResponse `json:"-"`
   247  	// ForceSendFields is a list of field names (e.g. "Locations") to
   248  	// unconditionally include in API requests. By default, fields with empty or
   249  	// default values are omitted from API requests. See
   250  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   251  	// details.
   252  	ForceSendFields []string `json:"-"`
   253  	// NullFields is a list of field names (e.g. "Locations") to include in API
   254  	// requests with the JSON null value. By default, fields with empty values are
   255  	// omitted from API requests. See
   256  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   257  	NullFields []string `json:"-"`
   258  }
   259  
   260  func (s *ListLocationsResponse) MarshalJSON() ([]byte, error) {
   261  	type NoMethod ListLocationsResponse
   262  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   263  }
   264  
   265  // ListOperationsResponse: The response message for Operations.ListOperations.
   266  type ListOperationsResponse struct {
   267  	// NextPageToken: The standard List next-page token.
   268  	NextPageToken string `json:"nextPageToken,omitempty"`
   269  	// Operations: A list of operations that matches the specified filter in the
   270  	// request.
   271  	Operations []*Operation `json:"operations,omitempty"`
   272  
   273  	// ServerResponse contains the HTTP response code and headers from the server.
   274  	googleapi.ServerResponse `json:"-"`
   275  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   276  	// unconditionally include in API requests. By default, fields with empty or
   277  	// default values are omitted from API requests. See
   278  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   279  	// details.
   280  	ForceSendFields []string `json:"-"`
   281  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   282  	// requests with the JSON null value. By default, fields with empty values are
   283  	// omitted from API requests. See
   284  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   285  	NullFields []string `json:"-"`
   286  }
   287  
   288  func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
   289  	type NoMethod ListOperationsResponse
   290  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   291  }
   292  
   293  // Location: A resource that represents a Google Cloud location.
   294  type Location struct {
   295  	// DisplayName: The friendly name for this location, typically a nearby city
   296  	// name. For example, "Tokyo".
   297  	DisplayName string `json:"displayName,omitempty"`
   298  	// Labels: Cross-service attributes for the location. For example
   299  	// {"cloud.googleapis.com/region": "us-east1"}
   300  	Labels map[string]string `json:"labels,omitempty"`
   301  	// LocationId: The canonical id for this location. For example: "us-east1".
   302  	LocationId string `json:"locationId,omitempty"`
   303  	// Metadata: Service-specific metadata. For example the available capacity at
   304  	// the given location.
   305  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   306  	// Name: Resource name for the location, which may vary between
   307  	// implementations. For example:
   308  	// "projects/example-project/locations/us-east1"
   309  	Name string `json:"name,omitempty"`
   310  
   311  	// ServerResponse contains the HTTP response code and headers from the server.
   312  	googleapi.ServerResponse `json:"-"`
   313  	// ForceSendFields is a list of field names (e.g. "DisplayName") to
   314  	// unconditionally include in API requests. By default, fields with empty or
   315  	// default values are omitted from API requests. See
   316  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   317  	// details.
   318  	ForceSendFields []string `json:"-"`
   319  	// NullFields is a list of field names (e.g. "DisplayName") to include in API
   320  	// requests with the JSON null value. By default, fields with empty values are
   321  	// omitted from API requests. See
   322  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   323  	NullFields []string `json:"-"`
   324  }
   325  
   326  func (s *Location) MarshalJSON() ([]byte, error) {
   327  	type NoMethod Location
   328  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   329  }
   330  
   331  // Operation: This resource represents a long-running operation that is the
   332  // result of a network API call.
   333  type Operation struct {
   334  	// Done: If the value is `false`, it means the operation is still in progress.
   335  	// If `true`, the operation is completed, and either `error` or `response` is
   336  	// available.
   337  	Done bool `json:"done,omitempty"`
   338  	// Error: The error result of the operation in case of failure or cancellation.
   339  	Error *GoogleRpcStatus `json:"error,omitempty"`
   340  	// Metadata: Service-specific metadata associated with the operation. It
   341  	// typically contains progress information and common metadata such as create
   342  	// time. Some services might not provide such metadata. Any method that returns
   343  	// a long-running operation should document the metadata type, if any.
   344  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   345  	// Name: The server-assigned name, which is only unique within the same service
   346  	// that originally returns it. If you use the default HTTP mapping, the `name`
   347  	// should be a resource name ending with `operations/{unique_id}`.
   348  	Name string `json:"name,omitempty"`
   349  	// Response: The normal, successful response of the operation. If the original
   350  	// method returns no data on success, such as `Delete`, the response is
   351  	// `google.protobuf.Empty`. If the original method is standard
   352  	// `Get`/`Create`/`Update`, the response should be the resource. For other
   353  	// methods, the response should have the type `XxxResponse`, where `Xxx` is the
   354  	// original method name. For example, if the original method name is
   355  	// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
   356  	Response googleapi.RawMessage `json:"response,omitempty"`
   357  
   358  	// ServerResponse contains the HTTP response code and headers from the server.
   359  	googleapi.ServerResponse `json:"-"`
   360  	// ForceSendFields is a list of field names (e.g. "Done") to unconditionally
   361  	// include in API requests. By default, fields with empty or default values are
   362  	// omitted from API requests. See
   363  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   364  	// details.
   365  	ForceSendFields []string `json:"-"`
   366  	// NullFields is a list of field names (e.g. "Done") to include in API requests
   367  	// with the JSON null value. By default, fields with empty values are omitted
   368  	// from API requests. See
   369  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   370  	NullFields []string `json:"-"`
   371  }
   372  
   373  func (s *Operation) MarshalJSON() ([]byte, error) {
   374  	type NoMethod Operation
   375  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   376  }
   377  
   378  type ProjectsLocationsGetCall struct {
   379  	s            *Service
   380  	name         string
   381  	urlParams_   gensupport.URLParams
   382  	ifNoneMatch_ string
   383  	ctx_         context.Context
   384  	header_      http.Header
   385  }
   386  
   387  // Get: Gets information about a location.
   388  //
   389  // - name: Resource name for the location.
   390  func (r *ProjectsLocationsService) Get(name string) *ProjectsLocationsGetCall {
   391  	c := &ProjectsLocationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   392  	c.name = name
   393  	return c
   394  }
   395  
   396  // Fields allows partial responses to be retrieved. See
   397  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   398  // details.
   399  func (c *ProjectsLocationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsGetCall {
   400  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   401  	return c
   402  }
   403  
   404  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   405  // object's ETag matches the given value. This is useful for getting updates
   406  // only after the object has changed since the last request.
   407  func (c *ProjectsLocationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsGetCall {
   408  	c.ifNoneMatch_ = entityTag
   409  	return c
   410  }
   411  
   412  // Context sets the context to be used in this call's Do method.
   413  func (c *ProjectsLocationsGetCall) Context(ctx context.Context) *ProjectsLocationsGetCall {
   414  	c.ctx_ = ctx
   415  	return c
   416  }
   417  
   418  // Header returns a http.Header that can be modified by the caller to add
   419  // headers to the request.
   420  func (c *ProjectsLocationsGetCall) Header() http.Header {
   421  	if c.header_ == nil {
   422  		c.header_ = make(http.Header)
   423  	}
   424  	return c.header_
   425  }
   426  
   427  func (c *ProjectsLocationsGetCall) doRequest(alt string) (*http.Response, error) {
   428  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   429  	if c.ifNoneMatch_ != "" {
   430  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   431  	}
   432  	var body io.Reader = nil
   433  	c.urlParams_.Set("alt", alt)
   434  	c.urlParams_.Set("prettyPrint", "false")
   435  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2alpha/{+name}")
   436  	urls += "?" + c.urlParams_.Encode()
   437  	req, err := http.NewRequest("GET", urls, body)
   438  	if err != nil {
   439  		return nil, err
   440  	}
   441  	req.Header = reqHeaders
   442  	googleapi.Expand(req.URL, map[string]string{
   443  		"name": c.name,
   444  	})
   445  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   446  }
   447  
   448  // Do executes the "gkehub.projects.locations.get" call.
   449  // Any non-2xx status code is an error. Response headers are in either
   450  // *Location.ServerResponse.Header or (if a response was returned at all) in
   451  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   452  // whether the returned error was because http.StatusNotModified was returned.
   453  func (c *ProjectsLocationsGetCall) Do(opts ...googleapi.CallOption) (*Location, error) {
   454  	gensupport.SetOptions(c.urlParams_, opts...)
   455  	res, err := c.doRequest("json")
   456  	if res != nil && res.StatusCode == http.StatusNotModified {
   457  		if res.Body != nil {
   458  			res.Body.Close()
   459  		}
   460  		return nil, gensupport.WrapError(&googleapi.Error{
   461  			Code:   res.StatusCode,
   462  			Header: res.Header,
   463  		})
   464  	}
   465  	if err != nil {
   466  		return nil, err
   467  	}
   468  	defer googleapi.CloseBody(res)
   469  	if err := googleapi.CheckResponse(res); err != nil {
   470  		return nil, gensupport.WrapError(err)
   471  	}
   472  	ret := &Location{
   473  		ServerResponse: googleapi.ServerResponse{
   474  			Header:         res.Header,
   475  			HTTPStatusCode: res.StatusCode,
   476  		},
   477  	}
   478  	target := &ret
   479  	if err := gensupport.DecodeResponse(target, res); err != nil {
   480  		return nil, err
   481  	}
   482  	return ret, nil
   483  }
   484  
   485  type ProjectsLocationsListCall struct {
   486  	s            *Service
   487  	name         string
   488  	urlParams_   gensupport.URLParams
   489  	ifNoneMatch_ string
   490  	ctx_         context.Context
   491  	header_      http.Header
   492  }
   493  
   494  // List: Lists information about the supported locations for this service.
   495  //
   496  // - name: The resource that owns the locations collection, if applicable.
   497  func (r *ProjectsLocationsService) List(name string) *ProjectsLocationsListCall {
   498  	c := &ProjectsLocationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   499  	c.name = name
   500  	return c
   501  }
   502  
   503  // Filter sets the optional parameter "filter": A filter to narrow down results
   504  // to a preferred subset. The filtering language accepts strings like
   505  // "displayName=tokyo", and is documented in more detail in AIP-160
   506  // (https://google.aip.dev/160).
   507  func (c *ProjectsLocationsListCall) Filter(filter string) *ProjectsLocationsListCall {
   508  	c.urlParams_.Set("filter", filter)
   509  	return c
   510  }
   511  
   512  // PageSize sets the optional parameter "pageSize": The maximum number of
   513  // results to return. If not set, the service selects a default.
   514  func (c *ProjectsLocationsListCall) PageSize(pageSize int64) *ProjectsLocationsListCall {
   515  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   516  	return c
   517  }
   518  
   519  // PageToken sets the optional parameter "pageToken": A page token received
   520  // from the `next_page_token` field in the response. Send that page token to
   521  // receive the subsequent page.
   522  func (c *ProjectsLocationsListCall) PageToken(pageToken string) *ProjectsLocationsListCall {
   523  	c.urlParams_.Set("pageToken", pageToken)
   524  	return c
   525  }
   526  
   527  // Fields allows partial responses to be retrieved. See
   528  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   529  // details.
   530  func (c *ProjectsLocationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsListCall {
   531  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   532  	return c
   533  }
   534  
   535  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   536  // object's ETag matches the given value. This is useful for getting updates
   537  // only after the object has changed since the last request.
   538  func (c *ProjectsLocationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsListCall {
   539  	c.ifNoneMatch_ = entityTag
   540  	return c
   541  }
   542  
   543  // Context sets the context to be used in this call's Do method.
   544  func (c *ProjectsLocationsListCall) Context(ctx context.Context) *ProjectsLocationsListCall {
   545  	c.ctx_ = ctx
   546  	return c
   547  }
   548  
   549  // Header returns a http.Header that can be modified by the caller to add
   550  // headers to the request.
   551  func (c *ProjectsLocationsListCall) Header() http.Header {
   552  	if c.header_ == nil {
   553  		c.header_ = make(http.Header)
   554  	}
   555  	return c.header_
   556  }
   557  
   558  func (c *ProjectsLocationsListCall) doRequest(alt string) (*http.Response, error) {
   559  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   560  	if c.ifNoneMatch_ != "" {
   561  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   562  	}
   563  	var body io.Reader = nil
   564  	c.urlParams_.Set("alt", alt)
   565  	c.urlParams_.Set("prettyPrint", "false")
   566  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2alpha/{+name}/locations")
   567  	urls += "?" + c.urlParams_.Encode()
   568  	req, err := http.NewRequest("GET", urls, body)
   569  	if err != nil {
   570  		return nil, err
   571  	}
   572  	req.Header = reqHeaders
   573  	googleapi.Expand(req.URL, map[string]string{
   574  		"name": c.name,
   575  	})
   576  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   577  }
   578  
   579  // Do executes the "gkehub.projects.locations.list" call.
   580  // Any non-2xx status code is an error. Response headers are in either
   581  // *ListLocationsResponse.ServerResponse.Header or (if a response was returned
   582  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   583  // check whether the returned error was because http.StatusNotModified was
   584  // returned.
   585  func (c *ProjectsLocationsListCall) Do(opts ...googleapi.CallOption) (*ListLocationsResponse, error) {
   586  	gensupport.SetOptions(c.urlParams_, opts...)
   587  	res, err := c.doRequest("json")
   588  	if res != nil && res.StatusCode == http.StatusNotModified {
   589  		if res.Body != nil {
   590  			res.Body.Close()
   591  		}
   592  		return nil, gensupport.WrapError(&googleapi.Error{
   593  			Code:   res.StatusCode,
   594  			Header: res.Header,
   595  		})
   596  	}
   597  	if err != nil {
   598  		return nil, err
   599  	}
   600  	defer googleapi.CloseBody(res)
   601  	if err := googleapi.CheckResponse(res); err != nil {
   602  		return nil, gensupport.WrapError(err)
   603  	}
   604  	ret := &ListLocationsResponse{
   605  		ServerResponse: googleapi.ServerResponse{
   606  			Header:         res.Header,
   607  			HTTPStatusCode: res.StatusCode,
   608  		},
   609  	}
   610  	target := &ret
   611  	if err := gensupport.DecodeResponse(target, res); err != nil {
   612  		return nil, err
   613  	}
   614  	return ret, nil
   615  }
   616  
   617  // Pages invokes f for each page of results.
   618  // A non-nil error returned from f will halt the iteration.
   619  // The provided context supersedes any context provided to the Context method.
   620  func (c *ProjectsLocationsListCall) Pages(ctx context.Context, f func(*ListLocationsResponse) error) error {
   621  	c.ctx_ = ctx
   622  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   623  	for {
   624  		x, err := c.Do()
   625  		if err != nil {
   626  			return err
   627  		}
   628  		if err := f(x); err != nil {
   629  			return err
   630  		}
   631  		if x.NextPageToken == "" {
   632  			return nil
   633  		}
   634  		c.PageToken(x.NextPageToken)
   635  	}
   636  }
   637  
   638  type ProjectsLocationsOperationsCancelCall struct {
   639  	s                      *Service
   640  	name                   string
   641  	canceloperationrequest *CancelOperationRequest
   642  	urlParams_             gensupport.URLParams
   643  	ctx_                   context.Context
   644  	header_                http.Header
   645  }
   646  
   647  // Cancel: Starts asynchronous cancellation on a long-running operation. The
   648  // server makes a best effort to cancel the operation, but success is not
   649  // guaranteed. If the server doesn't support this method, it returns
   650  // `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or
   651  // other methods to check whether the cancellation succeeded or whether the
   652  // operation completed despite cancellation. On successful cancellation, the
   653  // operation is not deleted; instead, it becomes an operation with an
   654  // Operation.error value with a google.rpc.Status.code of 1, corresponding to
   655  // `Code.CANCELLED`.
   656  //
   657  // - name: The name of the operation resource to be cancelled.
   658  func (r *ProjectsLocationsOperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *ProjectsLocationsOperationsCancelCall {
   659  	c := &ProjectsLocationsOperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   660  	c.name = name
   661  	c.canceloperationrequest = canceloperationrequest
   662  	return c
   663  }
   664  
   665  // Fields allows partial responses to be retrieved. See
   666  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   667  // details.
   668  func (c *ProjectsLocationsOperationsCancelCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsCancelCall {
   669  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   670  	return c
   671  }
   672  
   673  // Context sets the context to be used in this call's Do method.
   674  func (c *ProjectsLocationsOperationsCancelCall) Context(ctx context.Context) *ProjectsLocationsOperationsCancelCall {
   675  	c.ctx_ = ctx
   676  	return c
   677  }
   678  
   679  // Header returns a http.Header that can be modified by the caller to add
   680  // headers to the request.
   681  func (c *ProjectsLocationsOperationsCancelCall) Header() http.Header {
   682  	if c.header_ == nil {
   683  		c.header_ = make(http.Header)
   684  	}
   685  	return c.header_
   686  }
   687  
   688  func (c *ProjectsLocationsOperationsCancelCall) doRequest(alt string) (*http.Response, error) {
   689  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   690  	var body io.Reader = nil
   691  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest)
   692  	if err != nil {
   693  		return nil, err
   694  	}
   695  	c.urlParams_.Set("alt", alt)
   696  	c.urlParams_.Set("prettyPrint", "false")
   697  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2alpha/{+name}:cancel")
   698  	urls += "?" + c.urlParams_.Encode()
   699  	req, err := http.NewRequest("POST", urls, body)
   700  	if err != nil {
   701  		return nil, err
   702  	}
   703  	req.Header = reqHeaders
   704  	googleapi.Expand(req.URL, map[string]string{
   705  		"name": c.name,
   706  	})
   707  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   708  }
   709  
   710  // Do executes the "gkehub.projects.locations.operations.cancel" call.
   711  // Any non-2xx status code is an error. Response headers are in either
   712  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   713  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   714  // whether the returned error was because http.StatusNotModified was returned.
   715  func (c *ProjectsLocationsOperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   716  	gensupport.SetOptions(c.urlParams_, opts...)
   717  	res, err := c.doRequest("json")
   718  	if res != nil && res.StatusCode == http.StatusNotModified {
   719  		if res.Body != nil {
   720  			res.Body.Close()
   721  		}
   722  		return nil, gensupport.WrapError(&googleapi.Error{
   723  			Code:   res.StatusCode,
   724  			Header: res.Header,
   725  		})
   726  	}
   727  	if err != nil {
   728  		return nil, err
   729  	}
   730  	defer googleapi.CloseBody(res)
   731  	if err := googleapi.CheckResponse(res); err != nil {
   732  		return nil, gensupport.WrapError(err)
   733  	}
   734  	ret := &Empty{
   735  		ServerResponse: googleapi.ServerResponse{
   736  			Header:         res.Header,
   737  			HTTPStatusCode: res.StatusCode,
   738  		},
   739  	}
   740  	target := &ret
   741  	if err := gensupport.DecodeResponse(target, res); err != nil {
   742  		return nil, err
   743  	}
   744  	return ret, nil
   745  }
   746  
   747  type ProjectsLocationsOperationsGetCall struct {
   748  	s            *Service
   749  	name         string
   750  	urlParams_   gensupport.URLParams
   751  	ifNoneMatch_ string
   752  	ctx_         context.Context
   753  	header_      http.Header
   754  }
   755  
   756  // Get: Gets the latest state of a long-running operation. Clients can use this
   757  // method to poll the operation result at intervals as recommended by the API
   758  // service.
   759  //
   760  // - name: The name of the operation resource.
   761  func (r *ProjectsLocationsOperationsService) Get(name string) *ProjectsLocationsOperationsGetCall {
   762  	c := &ProjectsLocationsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   763  	c.name = name
   764  	return c
   765  }
   766  
   767  // Fields allows partial responses to be retrieved. See
   768  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   769  // details.
   770  func (c *ProjectsLocationsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsGetCall {
   771  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   772  	return c
   773  }
   774  
   775  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   776  // object's ETag matches the given value. This is useful for getting updates
   777  // only after the object has changed since the last request.
   778  func (c *ProjectsLocationsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsGetCall {
   779  	c.ifNoneMatch_ = entityTag
   780  	return c
   781  }
   782  
   783  // Context sets the context to be used in this call's Do method.
   784  func (c *ProjectsLocationsOperationsGetCall) Context(ctx context.Context) *ProjectsLocationsOperationsGetCall {
   785  	c.ctx_ = ctx
   786  	return c
   787  }
   788  
   789  // Header returns a http.Header that can be modified by the caller to add
   790  // headers to the request.
   791  func (c *ProjectsLocationsOperationsGetCall) Header() http.Header {
   792  	if c.header_ == nil {
   793  		c.header_ = make(http.Header)
   794  	}
   795  	return c.header_
   796  }
   797  
   798  func (c *ProjectsLocationsOperationsGetCall) doRequest(alt string) (*http.Response, error) {
   799  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   800  	if c.ifNoneMatch_ != "" {
   801  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   802  	}
   803  	var body io.Reader = nil
   804  	c.urlParams_.Set("alt", alt)
   805  	c.urlParams_.Set("prettyPrint", "false")
   806  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2alpha/{+name}")
   807  	urls += "?" + c.urlParams_.Encode()
   808  	req, err := http.NewRequest("GET", urls, body)
   809  	if err != nil {
   810  		return nil, err
   811  	}
   812  	req.Header = reqHeaders
   813  	googleapi.Expand(req.URL, map[string]string{
   814  		"name": c.name,
   815  	})
   816  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   817  }
   818  
   819  // Do executes the "gkehub.projects.locations.operations.get" call.
   820  // Any non-2xx status code is an error. Response headers are in either
   821  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   822  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   823  // whether the returned error was because http.StatusNotModified was returned.
   824  func (c *ProjectsLocationsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   825  	gensupport.SetOptions(c.urlParams_, opts...)
   826  	res, err := c.doRequest("json")
   827  	if res != nil && res.StatusCode == http.StatusNotModified {
   828  		if res.Body != nil {
   829  			res.Body.Close()
   830  		}
   831  		return nil, gensupport.WrapError(&googleapi.Error{
   832  			Code:   res.StatusCode,
   833  			Header: res.Header,
   834  		})
   835  	}
   836  	if err != nil {
   837  		return nil, err
   838  	}
   839  	defer googleapi.CloseBody(res)
   840  	if err := googleapi.CheckResponse(res); err != nil {
   841  		return nil, gensupport.WrapError(err)
   842  	}
   843  	ret := &Operation{
   844  		ServerResponse: googleapi.ServerResponse{
   845  			Header:         res.Header,
   846  			HTTPStatusCode: res.StatusCode,
   847  		},
   848  	}
   849  	target := &ret
   850  	if err := gensupport.DecodeResponse(target, res); err != nil {
   851  		return nil, err
   852  	}
   853  	return ret, nil
   854  }
   855  
   856  type ProjectsLocationsOperationsListCall struct {
   857  	s            *Service
   858  	name         string
   859  	urlParams_   gensupport.URLParams
   860  	ifNoneMatch_ string
   861  	ctx_         context.Context
   862  	header_      http.Header
   863  }
   864  
   865  // List: Lists operations that match the specified filter in the request. If
   866  // the server doesn't support this method, it returns `UNIMPLEMENTED`.
   867  //
   868  // - name: The name of the operation's parent resource.
   869  func (r *ProjectsLocationsOperationsService) List(name string) *ProjectsLocationsOperationsListCall {
   870  	c := &ProjectsLocationsOperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   871  	c.name = name
   872  	return c
   873  }
   874  
   875  // Filter sets the optional parameter "filter": The standard list filter.
   876  func (c *ProjectsLocationsOperationsListCall) Filter(filter string) *ProjectsLocationsOperationsListCall {
   877  	c.urlParams_.Set("filter", filter)
   878  	return c
   879  }
   880  
   881  // PageSize sets the optional parameter "pageSize": The standard list page
   882  // size.
   883  func (c *ProjectsLocationsOperationsListCall) PageSize(pageSize int64) *ProjectsLocationsOperationsListCall {
   884  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   885  	return c
   886  }
   887  
   888  // PageToken sets the optional parameter "pageToken": The standard list page
   889  // token.
   890  func (c *ProjectsLocationsOperationsListCall) PageToken(pageToken string) *ProjectsLocationsOperationsListCall {
   891  	c.urlParams_.Set("pageToken", pageToken)
   892  	return c
   893  }
   894  
   895  // Fields allows partial responses to be retrieved. See
   896  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   897  // details.
   898  func (c *ProjectsLocationsOperationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsListCall {
   899  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   900  	return c
   901  }
   902  
   903  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   904  // object's ETag matches the given value. This is useful for getting updates
   905  // only after the object has changed since the last request.
   906  func (c *ProjectsLocationsOperationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsListCall {
   907  	c.ifNoneMatch_ = entityTag
   908  	return c
   909  }
   910  
   911  // Context sets the context to be used in this call's Do method.
   912  func (c *ProjectsLocationsOperationsListCall) Context(ctx context.Context) *ProjectsLocationsOperationsListCall {
   913  	c.ctx_ = ctx
   914  	return c
   915  }
   916  
   917  // Header returns a http.Header that can be modified by the caller to add
   918  // headers to the request.
   919  func (c *ProjectsLocationsOperationsListCall) Header() http.Header {
   920  	if c.header_ == nil {
   921  		c.header_ = make(http.Header)
   922  	}
   923  	return c.header_
   924  }
   925  
   926  func (c *ProjectsLocationsOperationsListCall) doRequest(alt string) (*http.Response, error) {
   927  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   928  	if c.ifNoneMatch_ != "" {
   929  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   930  	}
   931  	var body io.Reader = nil
   932  	c.urlParams_.Set("alt", alt)
   933  	c.urlParams_.Set("prettyPrint", "false")
   934  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2alpha/{+name}/operations")
   935  	urls += "?" + c.urlParams_.Encode()
   936  	req, err := http.NewRequest("GET", urls, body)
   937  	if err != nil {
   938  		return nil, err
   939  	}
   940  	req.Header = reqHeaders
   941  	googleapi.Expand(req.URL, map[string]string{
   942  		"name": c.name,
   943  	})
   944  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   945  }
   946  
   947  // Do executes the "gkehub.projects.locations.operations.list" call.
   948  // Any non-2xx status code is an error. Response headers are in either
   949  // *ListOperationsResponse.ServerResponse.Header or (if a response was returned
   950  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   951  // check whether the returned error was because http.StatusNotModified was
   952  // returned.
   953  func (c *ProjectsLocationsOperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
   954  	gensupport.SetOptions(c.urlParams_, opts...)
   955  	res, err := c.doRequest("json")
   956  	if res != nil && res.StatusCode == http.StatusNotModified {
   957  		if res.Body != nil {
   958  			res.Body.Close()
   959  		}
   960  		return nil, gensupport.WrapError(&googleapi.Error{
   961  			Code:   res.StatusCode,
   962  			Header: res.Header,
   963  		})
   964  	}
   965  	if err != nil {
   966  		return nil, err
   967  	}
   968  	defer googleapi.CloseBody(res)
   969  	if err := googleapi.CheckResponse(res); err != nil {
   970  		return nil, gensupport.WrapError(err)
   971  	}
   972  	ret := &ListOperationsResponse{
   973  		ServerResponse: googleapi.ServerResponse{
   974  			Header:         res.Header,
   975  			HTTPStatusCode: res.StatusCode,
   976  		},
   977  	}
   978  	target := &ret
   979  	if err := gensupport.DecodeResponse(target, res); err != nil {
   980  		return nil, err
   981  	}
   982  	return ret, nil
   983  }
   984  
   985  // Pages invokes f for each page of results.
   986  // A non-nil error returned from f will halt the iteration.
   987  // The provided context supersedes any context provided to the Context method.
   988  func (c *ProjectsLocationsOperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
   989  	c.ctx_ = ctx
   990  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   991  	for {
   992  		x, err := c.Do()
   993  		if err != nil {
   994  			return err
   995  		}
   996  		if err := f(x); err != nil {
   997  			return err
   998  		}
   999  		if x.NextPageToken == "" {
  1000  			return nil
  1001  		}
  1002  		c.PageToken(x.NextPageToken)
  1003  	}
  1004  }
  1005  

View as plain text