...

Source file src/google.golang.org/api/firebaseml/v1/firebaseml-gen.go

Documentation: google.golang.org/api/firebaseml/v1

     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 firebaseml provides access to the Firebase ML API.
     8  //
     9  // For product documentation, see: https://firebase.google.com
    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/firebaseml/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	firebasemlService, err := firebaseml.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  //	firebasemlService, err := firebaseml.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  //	firebasemlService, err := firebaseml.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package firebaseml // import "google.golang.org/api/firebaseml/v1"
    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 = "firebaseml:v1"
    90  const apiName = "firebaseml"
    91  const apiVersion = "v1"
    92  const basePath = "https://firebaseml.googleapis.com/"
    93  const basePathTemplate = "https://firebaseml.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://firebaseml.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.Operations = NewOperationsService(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  	Operations *OperationsService
   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 NewOperationsService(s *Service) *OperationsService {
   158  	rs := &OperationsService{s: s}
   159  	return rs
   160  }
   161  
   162  type OperationsService struct {
   163  	s *Service
   164  }
   165  
   166  // CancelOperationRequest: The request message for Operations.CancelOperation.
   167  type CancelOperationRequest struct {
   168  }
   169  
   170  // Empty: A generic empty message that you can re-use to avoid defining
   171  // duplicated empty messages in your APIs. A typical example is to use it as
   172  // the request or the response type of an API method. For instance: service Foo
   173  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   174  type Empty struct {
   175  	// ServerResponse contains the HTTP response code and headers from the server.
   176  	googleapi.ServerResponse `json:"-"`
   177  }
   178  
   179  // ListOperationsResponse: The response message for Operations.ListOperations.
   180  type ListOperationsResponse struct {
   181  	// NextPageToken: The standard List next-page token.
   182  	NextPageToken string `json:"nextPageToken,omitempty"`
   183  	// Operations: A list of operations that matches the specified filter in the
   184  	// request.
   185  	Operations []*Operation `json:"operations,omitempty"`
   186  
   187  	// ServerResponse contains the HTTP response code and headers from the server.
   188  	googleapi.ServerResponse `json:"-"`
   189  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   190  	// unconditionally include in API requests. By default, fields with empty or
   191  	// default values are omitted from API requests. See
   192  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   193  	// details.
   194  	ForceSendFields []string `json:"-"`
   195  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   196  	// requests with the JSON null value. By default, fields with empty values are
   197  	// omitted from API requests. See
   198  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   199  	NullFields []string `json:"-"`
   200  }
   201  
   202  func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
   203  	type NoMethod ListOperationsResponse
   204  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   205  }
   206  
   207  // ModelOperationMetadata: This is returned in the longrunning operations for
   208  // create/update.
   209  type ModelOperationMetadata struct {
   210  	// Possible values:
   211  	//   "BASIC_OPERATION_STATUS_UNSPECIFIED" - The status is unspecified
   212  	//   "BASIC_OPERATION_STATUS_UPLOADING" - The model file is being uploaded
   213  	//   "BASIC_OPERATION_STATUS_VERIFYING" - The model file is being verified
   214  	BasicOperationStatus string `json:"basicOperationStatus,omitempty"`
   215  	// Name: The name of the model we are creating/updating The name must have the
   216  	// form `projects/{project_id}/models/{model_id}`
   217  	Name string `json:"name,omitempty"`
   218  	// ForceSendFields is a list of field names (e.g. "BasicOperationStatus") to
   219  	// unconditionally include in API requests. By default, fields with empty or
   220  	// default values are omitted from API requests. See
   221  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   222  	// details.
   223  	ForceSendFields []string `json:"-"`
   224  	// NullFields is a list of field names (e.g. "BasicOperationStatus") to include
   225  	// in API requests with the JSON null value. By default, fields with empty
   226  	// values are omitted from API requests. See
   227  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   228  	NullFields []string `json:"-"`
   229  }
   230  
   231  func (s *ModelOperationMetadata) MarshalJSON() ([]byte, error) {
   232  	type NoMethod ModelOperationMetadata
   233  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   234  }
   235  
   236  // Operation: This resource represents a long-running operation that is the
   237  // result of a network API call.
   238  type Operation struct {
   239  	// Done: If the value is `false`, it means the operation is still in progress.
   240  	// If `true`, the operation is completed, and either `error` or `response` is
   241  	// available.
   242  	Done bool `json:"done,omitempty"`
   243  	// Error: The error result of the operation in case of failure or cancellation.
   244  	Error *Status `json:"error,omitempty"`
   245  	// Metadata: Service-specific metadata associated with the operation. It
   246  	// typically contains progress information and common metadata such as create
   247  	// time. Some services might not provide such metadata. Any method that returns
   248  	// a long-running operation should document the metadata type, if any.
   249  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   250  	// Name: The server-assigned name, which is only unique within the same service
   251  	// that originally returns it. If you use the default HTTP mapping, the `name`
   252  	// should be a resource name ending with `operations/{unique_id}`.
   253  	Name string `json:"name,omitempty"`
   254  	// Response: The normal, successful response of the operation. If the original
   255  	// method returns no data on success, such as `Delete`, the response is
   256  	// `google.protobuf.Empty`. If the original method is standard
   257  	// `Get`/`Create`/`Update`, the response should be the resource. For other
   258  	// methods, the response should have the type `XxxResponse`, where `Xxx` is the
   259  	// original method name. For example, if the original method name is
   260  	// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
   261  	Response googleapi.RawMessage `json:"response,omitempty"`
   262  	// ForceSendFields is a list of field names (e.g. "Done") to unconditionally
   263  	// include in API requests. By default, fields with empty or default values are
   264  	// omitted from API requests. See
   265  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   266  	// details.
   267  	ForceSendFields []string `json:"-"`
   268  	// NullFields is a list of field names (e.g. "Done") to include in API requests
   269  	// with the JSON null value. By default, fields with empty values are omitted
   270  	// from API requests. See
   271  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   272  	NullFields []string `json:"-"`
   273  }
   274  
   275  func (s *Operation) MarshalJSON() ([]byte, error) {
   276  	type NoMethod Operation
   277  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   278  }
   279  
   280  // Status: The `Status` type defines a logical error model that is suitable for
   281  // different programming environments, including REST APIs and RPC APIs. It is
   282  // used by gRPC (https://github.com/grpc). Each `Status` message contains three
   283  // pieces of data: error code, error message, and error details. You can find
   284  // out more about this error model and how to work with it in the API Design
   285  // Guide (https://cloud.google.com/apis/design/errors).
   286  type Status struct {
   287  	// Code: The status code, which should be an enum value of google.rpc.Code.
   288  	Code int64 `json:"code,omitempty"`
   289  	// Details: A list of messages that carry the error details. There is a common
   290  	// set of message types for APIs to use.
   291  	Details []googleapi.RawMessage `json:"details,omitempty"`
   292  	// Message: A developer-facing error message, which should be in English. Any
   293  	// user-facing error message should be localized and sent in the
   294  	// google.rpc.Status.details field, or localized by the client.
   295  	Message string `json:"message,omitempty"`
   296  	// ForceSendFields is a list of field names (e.g. "Code") to unconditionally
   297  	// include in API requests. By default, fields with empty or default values are
   298  	// omitted from API requests. See
   299  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   300  	// details.
   301  	ForceSendFields []string `json:"-"`
   302  	// NullFields is a list of field names (e.g. "Code") to include in API requests
   303  	// with the JSON null value. By default, fields with empty values are omitted
   304  	// from API requests. See
   305  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   306  	NullFields []string `json:"-"`
   307  }
   308  
   309  func (s *Status) MarshalJSON() ([]byte, error) {
   310  	type NoMethod Status
   311  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   312  }
   313  
   314  type OperationsCancelCall struct {
   315  	s                      *Service
   316  	name                   string
   317  	canceloperationrequest *CancelOperationRequest
   318  	urlParams_             gensupport.URLParams
   319  	ctx_                   context.Context
   320  	header_                http.Header
   321  }
   322  
   323  // Cancel: Starts asynchronous cancellation on a long-running operation. The
   324  // server makes a best effort to cancel the operation, but success is not
   325  // guaranteed. If the server doesn't support this method, it returns
   326  // `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or
   327  // other methods to check whether the cancellation succeeded or whether the
   328  // operation completed despite cancellation. On successful cancellation, the
   329  // operation is not deleted; instead, it becomes an operation with an
   330  // Operation.error value with a google.rpc.Status.code of 1, corresponding to
   331  // `Code.CANCELLED`.
   332  //
   333  // - name: The name of the operation resource to be cancelled.
   334  func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall {
   335  	c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   336  	c.name = name
   337  	c.canceloperationrequest = canceloperationrequest
   338  	return c
   339  }
   340  
   341  // Fields allows partial responses to be retrieved. See
   342  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   343  // details.
   344  func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall {
   345  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   346  	return c
   347  }
   348  
   349  // Context sets the context to be used in this call's Do method.
   350  func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall {
   351  	c.ctx_ = ctx
   352  	return c
   353  }
   354  
   355  // Header returns a http.Header that can be modified by the caller to add
   356  // headers to the request.
   357  func (c *OperationsCancelCall) Header() http.Header {
   358  	if c.header_ == nil {
   359  		c.header_ = make(http.Header)
   360  	}
   361  	return c.header_
   362  }
   363  
   364  func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) {
   365  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   366  	var body io.Reader = nil
   367  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest)
   368  	if err != nil {
   369  		return nil, err
   370  	}
   371  	c.urlParams_.Set("alt", alt)
   372  	c.urlParams_.Set("prettyPrint", "false")
   373  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel")
   374  	urls += "?" + c.urlParams_.Encode()
   375  	req, err := http.NewRequest("POST", urls, body)
   376  	if err != nil {
   377  		return nil, err
   378  	}
   379  	req.Header = reqHeaders
   380  	googleapi.Expand(req.URL, map[string]string{
   381  		"name": c.name,
   382  	})
   383  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   384  }
   385  
   386  // Do executes the "firebaseml.operations.cancel" call.
   387  // Any non-2xx status code is an error. Response headers are in either
   388  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   389  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   390  // whether the returned error was because http.StatusNotModified was returned.
   391  func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   392  	gensupport.SetOptions(c.urlParams_, opts...)
   393  	res, err := c.doRequest("json")
   394  	if res != nil && res.StatusCode == http.StatusNotModified {
   395  		if res.Body != nil {
   396  			res.Body.Close()
   397  		}
   398  		return nil, gensupport.WrapError(&googleapi.Error{
   399  			Code:   res.StatusCode,
   400  			Header: res.Header,
   401  		})
   402  	}
   403  	if err != nil {
   404  		return nil, err
   405  	}
   406  	defer googleapi.CloseBody(res)
   407  	if err := googleapi.CheckResponse(res); err != nil {
   408  		return nil, gensupport.WrapError(err)
   409  	}
   410  	ret := &Empty{
   411  		ServerResponse: googleapi.ServerResponse{
   412  			Header:         res.Header,
   413  			HTTPStatusCode: res.StatusCode,
   414  		},
   415  	}
   416  	target := &ret
   417  	if err := gensupport.DecodeResponse(target, res); err != nil {
   418  		return nil, err
   419  	}
   420  	return ret, nil
   421  }
   422  
   423  type OperationsDeleteCall struct {
   424  	s          *Service
   425  	name       string
   426  	urlParams_ gensupport.URLParams
   427  	ctx_       context.Context
   428  	header_    http.Header
   429  }
   430  
   431  // Delete: Deletes a long-running operation. This method indicates that the
   432  // client is no longer interested in the operation result. It does not cancel
   433  // the operation. If the server doesn't support this method, it returns
   434  // `google.rpc.Code.UNIMPLEMENTED`.
   435  //
   436  // - name: The name of the operation resource to be deleted.
   437  func (r *OperationsService) Delete(name string) *OperationsDeleteCall {
   438  	c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   439  	c.name = name
   440  	return c
   441  }
   442  
   443  // Fields allows partial responses to be retrieved. See
   444  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   445  // details.
   446  func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall {
   447  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   448  	return c
   449  }
   450  
   451  // Context sets the context to be used in this call's Do method.
   452  func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall {
   453  	c.ctx_ = ctx
   454  	return c
   455  }
   456  
   457  // Header returns a http.Header that can be modified by the caller to add
   458  // headers to the request.
   459  func (c *OperationsDeleteCall) Header() http.Header {
   460  	if c.header_ == nil {
   461  		c.header_ = make(http.Header)
   462  	}
   463  	return c.header_
   464  }
   465  
   466  func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) {
   467  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   468  	var body io.Reader = nil
   469  	c.urlParams_.Set("alt", alt)
   470  	c.urlParams_.Set("prettyPrint", "false")
   471  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   472  	urls += "?" + c.urlParams_.Encode()
   473  	req, err := http.NewRequest("DELETE", urls, body)
   474  	if err != nil {
   475  		return nil, err
   476  	}
   477  	req.Header = reqHeaders
   478  	googleapi.Expand(req.URL, map[string]string{
   479  		"name": c.name,
   480  	})
   481  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   482  }
   483  
   484  // Do executes the "firebaseml.operations.delete" call.
   485  // Any non-2xx status code is an error. Response headers are in either
   486  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   487  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   488  // whether the returned error was because http.StatusNotModified was returned.
   489  func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   490  	gensupport.SetOptions(c.urlParams_, opts...)
   491  	res, err := c.doRequest("json")
   492  	if res != nil && res.StatusCode == http.StatusNotModified {
   493  		if res.Body != nil {
   494  			res.Body.Close()
   495  		}
   496  		return nil, gensupport.WrapError(&googleapi.Error{
   497  			Code:   res.StatusCode,
   498  			Header: res.Header,
   499  		})
   500  	}
   501  	if err != nil {
   502  		return nil, err
   503  	}
   504  	defer googleapi.CloseBody(res)
   505  	if err := googleapi.CheckResponse(res); err != nil {
   506  		return nil, gensupport.WrapError(err)
   507  	}
   508  	ret := &Empty{
   509  		ServerResponse: googleapi.ServerResponse{
   510  			Header:         res.Header,
   511  			HTTPStatusCode: res.StatusCode,
   512  		},
   513  	}
   514  	target := &ret
   515  	if err := gensupport.DecodeResponse(target, res); err != nil {
   516  		return nil, err
   517  	}
   518  	return ret, nil
   519  }
   520  
   521  type OperationsListCall struct {
   522  	s            *Service
   523  	name         string
   524  	urlParams_   gensupport.URLParams
   525  	ifNoneMatch_ string
   526  	ctx_         context.Context
   527  	header_      http.Header
   528  }
   529  
   530  // List: Lists operations that match the specified filter in the request. If
   531  // the server doesn't support this method, it returns `UNIMPLEMENTED`.
   532  //
   533  // - name: The name of the operation's parent resource.
   534  func (r *OperationsService) List(name string) *OperationsListCall {
   535  	c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   536  	c.name = name
   537  	return c
   538  }
   539  
   540  // Filter sets the optional parameter "filter": The standard list filter.
   541  func (c *OperationsListCall) Filter(filter string) *OperationsListCall {
   542  	c.urlParams_.Set("filter", filter)
   543  	return c
   544  }
   545  
   546  // PageSize sets the optional parameter "pageSize": The standard list page
   547  // size.
   548  func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall {
   549  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   550  	return c
   551  }
   552  
   553  // PageToken sets the optional parameter "pageToken": The standard list page
   554  // token.
   555  func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall {
   556  	c.urlParams_.Set("pageToken", pageToken)
   557  	return c
   558  }
   559  
   560  // Fields allows partial responses to be retrieved. See
   561  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   562  // details.
   563  func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall {
   564  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   565  	return c
   566  }
   567  
   568  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   569  // object's ETag matches the given value. This is useful for getting updates
   570  // only after the object has changed since the last request.
   571  func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall {
   572  	c.ifNoneMatch_ = entityTag
   573  	return c
   574  }
   575  
   576  // Context sets the context to be used in this call's Do method.
   577  func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall {
   578  	c.ctx_ = ctx
   579  	return c
   580  }
   581  
   582  // Header returns a http.Header that can be modified by the caller to add
   583  // headers to the request.
   584  func (c *OperationsListCall) Header() http.Header {
   585  	if c.header_ == nil {
   586  		c.header_ = make(http.Header)
   587  	}
   588  	return c.header_
   589  }
   590  
   591  func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) {
   592  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   593  	if c.ifNoneMatch_ != "" {
   594  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   595  	}
   596  	var body io.Reader = nil
   597  	c.urlParams_.Set("alt", alt)
   598  	c.urlParams_.Set("prettyPrint", "false")
   599  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   600  	urls += "?" + c.urlParams_.Encode()
   601  	req, err := http.NewRequest("GET", urls, body)
   602  	if err != nil {
   603  		return nil, err
   604  	}
   605  	req.Header = reqHeaders
   606  	googleapi.Expand(req.URL, map[string]string{
   607  		"name": c.name,
   608  	})
   609  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   610  }
   611  
   612  // Do executes the "firebaseml.operations.list" call.
   613  // Any non-2xx status code is an error. Response headers are in either
   614  // *ListOperationsResponse.ServerResponse.Header or (if a response was returned
   615  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   616  // check whether the returned error was because http.StatusNotModified was
   617  // returned.
   618  func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
   619  	gensupport.SetOptions(c.urlParams_, opts...)
   620  	res, err := c.doRequest("json")
   621  	if res != nil && res.StatusCode == http.StatusNotModified {
   622  		if res.Body != nil {
   623  			res.Body.Close()
   624  		}
   625  		return nil, gensupport.WrapError(&googleapi.Error{
   626  			Code:   res.StatusCode,
   627  			Header: res.Header,
   628  		})
   629  	}
   630  	if err != nil {
   631  		return nil, err
   632  	}
   633  	defer googleapi.CloseBody(res)
   634  	if err := googleapi.CheckResponse(res); err != nil {
   635  		return nil, gensupport.WrapError(err)
   636  	}
   637  	ret := &ListOperationsResponse{
   638  		ServerResponse: googleapi.ServerResponse{
   639  			Header:         res.Header,
   640  			HTTPStatusCode: res.StatusCode,
   641  		},
   642  	}
   643  	target := &ret
   644  	if err := gensupport.DecodeResponse(target, res); err != nil {
   645  		return nil, err
   646  	}
   647  	return ret, nil
   648  }
   649  
   650  // Pages invokes f for each page of results.
   651  // A non-nil error returned from f will halt the iteration.
   652  // The provided context supersedes any context provided to the Context method.
   653  func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
   654  	c.ctx_ = ctx
   655  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   656  	for {
   657  		x, err := c.Do()
   658  		if err != nil {
   659  			return err
   660  		}
   661  		if err := f(x); err != nil {
   662  			return err
   663  		}
   664  		if x.NextPageToken == "" {
   665  			return nil
   666  		}
   667  		c.PageToken(x.NextPageToken)
   668  	}
   669  }
   670  

View as plain text