...

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

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

     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/v1beta2"
    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/v1beta2"
    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:v1beta2"
    90  const apiName = "firebaseml"
    91  const apiVersion = "v1beta2"
    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.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.Models = NewProjectsModelsService(s)
   160  	rs.Operations = NewProjectsOperationsService(s)
   161  	return rs
   162  }
   163  
   164  type ProjectsService struct {
   165  	s *Service
   166  
   167  	Models *ProjectsModelsService
   168  
   169  	Operations *ProjectsOperationsService
   170  }
   171  
   172  func NewProjectsModelsService(s *Service) *ProjectsModelsService {
   173  	rs := &ProjectsModelsService{s: s}
   174  	return rs
   175  }
   176  
   177  type ProjectsModelsService struct {
   178  	s *Service
   179  }
   180  
   181  func NewProjectsOperationsService(s *Service) *ProjectsOperationsService {
   182  	rs := &ProjectsOperationsService{s: s}
   183  	return rs
   184  }
   185  
   186  type ProjectsOperationsService struct {
   187  	s *Service
   188  }
   189  
   190  // DownloadModelResponse: The response for downloading a model to device.
   191  type DownloadModelResponse struct {
   192  	// DownloadUri: Output only. A download URI for the model/zip file.
   193  	DownloadUri string `json:"downloadUri,omitempty"`
   194  	// ExpireTime: Output only. The time that the download URI link expires. If the
   195  	// link has expired, the REST call must be repeated.
   196  	ExpireTime string `json:"expireTime,omitempty"`
   197  	// ModelFormat: Output only. The format of the model being downloaded.
   198  	//
   199  	// Possible values:
   200  	//   "MODEL_FORMAT_UNSPECIFIED" - Unknown format
   201  	//   "TFLITE" - TFLite model
   202  	ModelFormat string `json:"modelFormat,omitempty"`
   203  	// SizeBytes: Output only. The size of the file(s), if this information is
   204  	// available.
   205  	SizeBytes int64 `json:"sizeBytes,omitempty,string"`
   206  
   207  	// ServerResponse contains the HTTP response code and headers from the server.
   208  	googleapi.ServerResponse `json:"-"`
   209  	// ForceSendFields is a list of field names (e.g. "DownloadUri") to
   210  	// unconditionally include in API requests. By default, fields with empty or
   211  	// default values are omitted from API requests. See
   212  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   213  	// details.
   214  	ForceSendFields []string `json:"-"`
   215  	// NullFields is a list of field names (e.g. "DownloadUri") to include in API
   216  	// requests with the JSON null value. By default, fields with empty values are
   217  	// omitted from API requests. See
   218  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   219  	NullFields []string `json:"-"`
   220  }
   221  
   222  func (s *DownloadModelResponse) MarshalJSON() ([]byte, error) {
   223  	type NoMethod DownloadModelResponse
   224  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   225  }
   226  
   227  // Empty: A generic empty message that you can re-use to avoid defining
   228  // duplicated empty messages in your APIs. A typical example is to use it as
   229  // the request or the response type of an API method. For instance: service Foo
   230  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   231  type Empty struct {
   232  	// ServerResponse contains the HTTP response code and headers from the server.
   233  	googleapi.ServerResponse `json:"-"`
   234  }
   235  
   236  // ListModelsResponse: The response for list models
   237  type ListModelsResponse struct {
   238  	// Models: The list of models
   239  	Models []*Model `json:"models,omitempty"`
   240  	// NextPageToken: Token to retrieve the next page of results, or empty if there
   241  	// are no more results in the list.
   242  	NextPageToken string `json:"nextPageToken,omitempty"`
   243  
   244  	// ServerResponse contains the HTTP response code and headers from the server.
   245  	googleapi.ServerResponse `json:"-"`
   246  	// ForceSendFields is a list of field names (e.g. "Models") to unconditionally
   247  	// include in API requests. By default, fields with empty or default values are
   248  	// omitted from API requests. See
   249  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   250  	// details.
   251  	ForceSendFields []string `json:"-"`
   252  	// NullFields is a list of field names (e.g. "Models") to include in API
   253  	// requests with the JSON null value. By default, fields with empty values are
   254  	// omitted from API requests. See
   255  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   256  	NullFields []string `json:"-"`
   257  }
   258  
   259  func (s *ListModelsResponse) MarshalJSON() ([]byte, error) {
   260  	type NoMethod ListModelsResponse
   261  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   262  }
   263  
   264  // Model: An ML model hosted in Firebase ML
   265  type Model struct {
   266  	// ActiveOperations: Output only. Lists operation ids associated with this
   267  	// model whose status is NOT done.
   268  	ActiveOperations []*Operation `json:"activeOperations,omitempty"`
   269  	// CreateTime: Output only. Timestamp when this model was created in Firebase
   270  	// ML.
   271  	CreateTime string `json:"createTime,omitempty"`
   272  	// DisplayName: Required. The name of the model to create. The name can be up
   273  	// to 32 characters long and can consist only of ASCII Latin letters A-Z and
   274  	// a-z, underscores(_) and ASCII digits 0-9. It must start with a letter.
   275  	DisplayName string `json:"displayName,omitempty"`
   276  	// Etag: Output only. See RFC7232
   277  	// https://tools.ietf.org/html/rfc7232#section-2.3
   278  	Etag string `json:"etag,omitempty"`
   279  	// ModelHash: Output only. The model_hash will change if a new file is
   280  	// available for download.
   281  	ModelHash string `json:"modelHash,omitempty"`
   282  	// Name: The resource name of the Model. Model names have the form
   283  	// `projects/{project_id}/models/{model_id}` The name is ignored when creating
   284  	// a model.
   285  	Name string `json:"name,omitempty"`
   286  	// State: State common to all model types. Includes publishing and validation
   287  	// information.
   288  	State *ModelState `json:"state,omitempty"`
   289  	// Tags: User defined tags which can be used to group/filter models during
   290  	// listing
   291  	Tags []string `json:"tags,omitempty"`
   292  	// TfliteModel: A TFLite Model
   293  	TfliteModel *TfLiteModel `json:"tfliteModel,omitempty"`
   294  	// UpdateTime: Output only. Timestamp when this model was updated in Firebase
   295  	// ML.
   296  	UpdateTime string `json:"updateTime,omitempty"`
   297  
   298  	// ServerResponse contains the HTTP response code and headers from the server.
   299  	googleapi.ServerResponse `json:"-"`
   300  	// ForceSendFields is a list of field names (e.g. "ActiveOperations") to
   301  	// unconditionally include in API requests. By default, fields with empty or
   302  	// default values are omitted from API requests. See
   303  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   304  	// details.
   305  	ForceSendFields []string `json:"-"`
   306  	// NullFields is a list of field names (e.g. "ActiveOperations") to include in
   307  	// API requests with the JSON null value. By default, fields with empty values
   308  	// are omitted from API requests. See
   309  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   310  	NullFields []string `json:"-"`
   311  }
   312  
   313  func (s *Model) MarshalJSON() ([]byte, error) {
   314  	type NoMethod Model
   315  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   316  }
   317  
   318  // ModelOperationMetadata: This is returned in the longrunning operations for
   319  // create/update.
   320  type ModelOperationMetadata struct {
   321  	// Possible values:
   322  	//   "BASIC_OPERATION_STATUS_UNSPECIFIED" - The status is unspecified
   323  	//   "BASIC_OPERATION_STATUS_UPLOADING" - The model file is being uploaded
   324  	//   "BASIC_OPERATION_STATUS_VERIFYING" - The model file is being verified
   325  	BasicOperationStatus string `json:"basicOperationStatus,omitempty"`
   326  	// Name: The name of the model we are creating/updating The name must have the
   327  	// form `projects/{project_id}/models/{model_id}`
   328  	Name string `json:"name,omitempty"`
   329  	// ForceSendFields is a list of field names (e.g. "BasicOperationStatus") to
   330  	// unconditionally include in API requests. By default, fields with empty or
   331  	// default values are omitted from API requests. See
   332  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   333  	// details.
   334  	ForceSendFields []string `json:"-"`
   335  	// NullFields is a list of field names (e.g. "BasicOperationStatus") to include
   336  	// in API requests with the JSON null value. By default, fields with empty
   337  	// values are omitted from API requests. See
   338  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   339  	NullFields []string `json:"-"`
   340  }
   341  
   342  func (s *ModelOperationMetadata) MarshalJSON() ([]byte, error) {
   343  	type NoMethod ModelOperationMetadata
   344  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   345  }
   346  
   347  // ModelState: State common to all model types. Includes publishing and
   348  // validation information.
   349  type ModelState struct {
   350  	// Published: Indicates if this model has been published.
   351  	Published bool `json:"published,omitempty"`
   352  	// ValidationError: Output only. Indicates the latest validation error on the
   353  	// model if any. A model may have validation errors if there were problems
   354  	// during the model creation/update. e.g. in the case of a TfLiteModel, if a
   355  	// tflite model file was missing or in the wrong format. This field will be
   356  	// empty for valid models.
   357  	ValidationError *Status `json:"validationError,omitempty"`
   358  	// ForceSendFields is a list of field names (e.g. "Published") to
   359  	// unconditionally include in API requests. By default, fields with empty or
   360  	// default values are omitted from API requests. See
   361  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   362  	// details.
   363  	ForceSendFields []string `json:"-"`
   364  	// NullFields is a list of field names (e.g. "Published") to include in API
   365  	// requests with the JSON null value. By default, fields with empty values are
   366  	// omitted from API requests. See
   367  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   368  	NullFields []string `json:"-"`
   369  }
   370  
   371  func (s *ModelState) MarshalJSON() ([]byte, error) {
   372  	type NoMethod ModelState
   373  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   374  }
   375  
   376  // Operation: This resource represents a long-running operation that is the
   377  // result of a network API call.
   378  type Operation struct {
   379  	// Done: If the value is `false`, it means the operation is still in progress.
   380  	// If `true`, the operation is completed, and either `error` or `response` is
   381  	// available.
   382  	Done bool `json:"done,omitempty"`
   383  	// Error: The error result of the operation in case of failure or cancellation.
   384  	Error *Status `json:"error,omitempty"`
   385  	// Metadata: Service-specific metadata associated with the operation. It
   386  	// typically contains progress information and common metadata such as create
   387  	// time. Some services might not provide such metadata. Any method that returns
   388  	// a long-running operation should document the metadata type, if any.
   389  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   390  	// Name: The server-assigned name, which is only unique within the same service
   391  	// that originally returns it. If you use the default HTTP mapping, the `name`
   392  	// should be a resource name ending with `operations/{unique_id}`.
   393  	Name string `json:"name,omitempty"`
   394  	// Response: The normal, successful response of the operation. If the original
   395  	// method returns no data on success, such as `Delete`, the response is
   396  	// `google.protobuf.Empty`. If the original method is standard
   397  	// `Get`/`Create`/`Update`, the response should be the resource. For other
   398  	// methods, the response should have the type `XxxResponse`, where `Xxx` is the
   399  	// original method name. For example, if the original method name is
   400  	// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
   401  	Response googleapi.RawMessage `json:"response,omitempty"`
   402  
   403  	// ServerResponse contains the HTTP response code and headers from the server.
   404  	googleapi.ServerResponse `json:"-"`
   405  	// ForceSendFields is a list of field names (e.g. "Done") to unconditionally
   406  	// include in API requests. By default, fields with empty or default values are
   407  	// omitted from API requests. See
   408  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   409  	// details.
   410  	ForceSendFields []string `json:"-"`
   411  	// NullFields is a list of field names (e.g. "Done") to include in API requests
   412  	// with the JSON null value. By default, fields with empty values are omitted
   413  	// from API requests. See
   414  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   415  	NullFields []string `json:"-"`
   416  }
   417  
   418  func (s *Operation) MarshalJSON() ([]byte, error) {
   419  	type NoMethod Operation
   420  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   421  }
   422  
   423  // Status: The `Status` type defines a logical error model that is suitable for
   424  // different programming environments, including REST APIs and RPC APIs. It is
   425  // used by gRPC (https://github.com/grpc). Each `Status` message contains three
   426  // pieces of data: error code, error message, and error details. You can find
   427  // out more about this error model and how to work with it in the API Design
   428  // Guide (https://cloud.google.com/apis/design/errors).
   429  type Status struct {
   430  	// Code: The status code, which should be an enum value of google.rpc.Code.
   431  	Code int64 `json:"code,omitempty"`
   432  	// Details: A list of messages that carry the error details. There is a common
   433  	// set of message types for APIs to use.
   434  	Details []googleapi.RawMessage `json:"details,omitempty"`
   435  	// Message: A developer-facing error message, which should be in English. Any
   436  	// user-facing error message should be localized and sent in the
   437  	// google.rpc.Status.details field, or localized by the client.
   438  	Message string `json:"message,omitempty"`
   439  	// ForceSendFields is a list of field names (e.g. "Code") to unconditionally
   440  	// include in API requests. By default, fields with empty or default values are
   441  	// omitted from API requests. See
   442  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   443  	// details.
   444  	ForceSendFields []string `json:"-"`
   445  	// NullFields is a list of field names (e.g. "Code") to include in API requests
   446  	// with the JSON null value. By default, fields with empty values are omitted
   447  	// from API requests. See
   448  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   449  	NullFields []string `json:"-"`
   450  }
   451  
   452  func (s *Status) MarshalJSON() ([]byte, error) {
   453  	type NoMethod Status
   454  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   455  }
   456  
   457  // TfLiteModel: Information that is specific to TfLite models.
   458  type TfLiteModel struct {
   459  	// AutomlModel: The AutoML model id referencing a model you created with the
   460  	// AutoML API. The name should have format 'projects//locations//models/' (This
   461  	// is the model resource name returned from the AutoML API)
   462  	AutomlModel string `json:"automlModel,omitempty"`
   463  	// GcsTfliteUri: The TfLite file containing the model. (Stored in Google
   464  	// Cloud). The gcs_tflite_uri should have form:
   465  	// gs://some-bucket/some-model.tflite Note: If you update the file in the
   466  	// original location, it is necessary to call UpdateModel for ML to pick up and
   467  	// validate the updated file.
   468  	GcsTfliteUri string `json:"gcsTfliteUri,omitempty"`
   469  	// SizeBytes: Output only. The size of the TFLite model
   470  	SizeBytes string `json:"sizeBytes,omitempty"`
   471  	// ForceSendFields is a list of field names (e.g. "AutomlModel") to
   472  	// unconditionally include in API requests. By default, fields with empty or
   473  	// default values are omitted from API requests. See
   474  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   475  	// details.
   476  	ForceSendFields []string `json:"-"`
   477  	// NullFields is a list of field names (e.g. "AutomlModel") to include in API
   478  	// requests with the JSON null value. By default, fields with empty values are
   479  	// omitted from API requests. See
   480  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   481  	NullFields []string `json:"-"`
   482  }
   483  
   484  func (s *TfLiteModel) MarshalJSON() ([]byte, error) {
   485  	type NoMethod TfLiteModel
   486  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   487  }
   488  
   489  type ProjectsModelsCreateCall struct {
   490  	s          *Service
   491  	parent     string
   492  	model      *Model
   493  	urlParams_ gensupport.URLParams
   494  	ctx_       context.Context
   495  	header_    http.Header
   496  }
   497  
   498  // Create: Creates a model in Firebase ML. The longrunning operation will
   499  // eventually return a Model
   500  //
   501  //   - parent: The parent project resource where the model is to be created. The
   502  //     parent must have the form `projects/{project_id}`.
   503  func (r *ProjectsModelsService) Create(parent string, model *Model) *ProjectsModelsCreateCall {
   504  	c := &ProjectsModelsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   505  	c.parent = parent
   506  	c.model = model
   507  	return c
   508  }
   509  
   510  // Fields allows partial responses to be retrieved. See
   511  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   512  // details.
   513  func (c *ProjectsModelsCreateCall) Fields(s ...googleapi.Field) *ProjectsModelsCreateCall {
   514  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   515  	return c
   516  }
   517  
   518  // Context sets the context to be used in this call's Do method.
   519  func (c *ProjectsModelsCreateCall) Context(ctx context.Context) *ProjectsModelsCreateCall {
   520  	c.ctx_ = ctx
   521  	return c
   522  }
   523  
   524  // Header returns a http.Header that can be modified by the caller to add
   525  // headers to the request.
   526  func (c *ProjectsModelsCreateCall) Header() http.Header {
   527  	if c.header_ == nil {
   528  		c.header_ = make(http.Header)
   529  	}
   530  	return c.header_
   531  }
   532  
   533  func (c *ProjectsModelsCreateCall) doRequest(alt string) (*http.Response, error) {
   534  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   535  	var body io.Reader = nil
   536  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.model)
   537  	if err != nil {
   538  		return nil, err
   539  	}
   540  	c.urlParams_.Set("alt", alt)
   541  	c.urlParams_.Set("prettyPrint", "false")
   542  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+parent}/models")
   543  	urls += "?" + c.urlParams_.Encode()
   544  	req, err := http.NewRequest("POST", urls, body)
   545  	if err != nil {
   546  		return nil, err
   547  	}
   548  	req.Header = reqHeaders
   549  	googleapi.Expand(req.URL, map[string]string{
   550  		"parent": c.parent,
   551  	})
   552  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   553  }
   554  
   555  // Do executes the "firebaseml.projects.models.create" call.
   556  // Any non-2xx status code is an error. Response headers are in either
   557  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   558  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   559  // whether the returned error was because http.StatusNotModified was returned.
   560  func (c *ProjectsModelsCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   561  	gensupport.SetOptions(c.urlParams_, opts...)
   562  	res, err := c.doRequest("json")
   563  	if res != nil && res.StatusCode == http.StatusNotModified {
   564  		if res.Body != nil {
   565  			res.Body.Close()
   566  		}
   567  		return nil, gensupport.WrapError(&googleapi.Error{
   568  			Code:   res.StatusCode,
   569  			Header: res.Header,
   570  		})
   571  	}
   572  	if err != nil {
   573  		return nil, err
   574  	}
   575  	defer googleapi.CloseBody(res)
   576  	if err := googleapi.CheckResponse(res); err != nil {
   577  		return nil, gensupport.WrapError(err)
   578  	}
   579  	ret := &Operation{
   580  		ServerResponse: googleapi.ServerResponse{
   581  			Header:         res.Header,
   582  			HTTPStatusCode: res.StatusCode,
   583  		},
   584  	}
   585  	target := &ret
   586  	if err := gensupport.DecodeResponse(target, res); err != nil {
   587  		return nil, err
   588  	}
   589  	return ret, nil
   590  }
   591  
   592  type ProjectsModelsDeleteCall struct {
   593  	s          *Service
   594  	name       string
   595  	urlParams_ gensupport.URLParams
   596  	ctx_       context.Context
   597  	header_    http.Header
   598  }
   599  
   600  // Delete: Deletes a model
   601  //
   602  //   - name: The name of the model to delete. The name must have the form
   603  //     `projects/{project_id}/models/{model_id}`.
   604  func (r *ProjectsModelsService) Delete(name string) *ProjectsModelsDeleteCall {
   605  	c := &ProjectsModelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   606  	c.name = name
   607  	return c
   608  }
   609  
   610  // Fields allows partial responses to be retrieved. See
   611  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   612  // details.
   613  func (c *ProjectsModelsDeleteCall) Fields(s ...googleapi.Field) *ProjectsModelsDeleteCall {
   614  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   615  	return c
   616  }
   617  
   618  // Context sets the context to be used in this call's Do method.
   619  func (c *ProjectsModelsDeleteCall) Context(ctx context.Context) *ProjectsModelsDeleteCall {
   620  	c.ctx_ = ctx
   621  	return c
   622  }
   623  
   624  // Header returns a http.Header that can be modified by the caller to add
   625  // headers to the request.
   626  func (c *ProjectsModelsDeleteCall) Header() http.Header {
   627  	if c.header_ == nil {
   628  		c.header_ = make(http.Header)
   629  	}
   630  	return c.header_
   631  }
   632  
   633  func (c *ProjectsModelsDeleteCall) doRequest(alt string) (*http.Response, error) {
   634  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   635  	var body io.Reader = nil
   636  	c.urlParams_.Set("alt", alt)
   637  	c.urlParams_.Set("prettyPrint", "false")
   638  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
   639  	urls += "?" + c.urlParams_.Encode()
   640  	req, err := http.NewRequest("DELETE", urls, body)
   641  	if err != nil {
   642  		return nil, err
   643  	}
   644  	req.Header = reqHeaders
   645  	googleapi.Expand(req.URL, map[string]string{
   646  		"name": c.name,
   647  	})
   648  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   649  }
   650  
   651  // Do executes the "firebaseml.projects.models.delete" call.
   652  // Any non-2xx status code is an error. Response headers are in either
   653  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   654  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   655  // whether the returned error was because http.StatusNotModified was returned.
   656  func (c *ProjectsModelsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   657  	gensupport.SetOptions(c.urlParams_, opts...)
   658  	res, err := c.doRequest("json")
   659  	if res != nil && res.StatusCode == http.StatusNotModified {
   660  		if res.Body != nil {
   661  			res.Body.Close()
   662  		}
   663  		return nil, gensupport.WrapError(&googleapi.Error{
   664  			Code:   res.StatusCode,
   665  			Header: res.Header,
   666  		})
   667  	}
   668  	if err != nil {
   669  		return nil, err
   670  	}
   671  	defer googleapi.CloseBody(res)
   672  	if err := googleapi.CheckResponse(res); err != nil {
   673  		return nil, gensupport.WrapError(err)
   674  	}
   675  	ret := &Empty{
   676  		ServerResponse: googleapi.ServerResponse{
   677  			Header:         res.Header,
   678  			HTTPStatusCode: res.StatusCode,
   679  		},
   680  	}
   681  	target := &ret
   682  	if err := gensupport.DecodeResponse(target, res); err != nil {
   683  		return nil, err
   684  	}
   685  	return ret, nil
   686  }
   687  
   688  type ProjectsModelsDownloadCall struct {
   689  	s            *Service
   690  	name         string
   691  	urlParams_   gensupport.URLParams
   692  	ifNoneMatch_ string
   693  	ctx_         context.Context
   694  	header_      http.Header
   695  }
   696  
   697  // Download: Gets Download information for a model. This is meant for
   698  // downloading model resources onto devices. It gives very limited information
   699  // about the model.
   700  //
   701  //   - name: The name of the model to download. The name must have the form
   702  //     `projects/{project}/models/{model}`.
   703  func (r *ProjectsModelsService) Download(name string) *ProjectsModelsDownloadCall {
   704  	c := &ProjectsModelsDownloadCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   705  	c.name = name
   706  	return c
   707  }
   708  
   709  // Fields allows partial responses to be retrieved. See
   710  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   711  // details.
   712  func (c *ProjectsModelsDownloadCall) Fields(s ...googleapi.Field) *ProjectsModelsDownloadCall {
   713  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   714  	return c
   715  }
   716  
   717  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   718  // object's ETag matches the given value. This is useful for getting updates
   719  // only after the object has changed since the last request.
   720  func (c *ProjectsModelsDownloadCall) IfNoneMatch(entityTag string) *ProjectsModelsDownloadCall {
   721  	c.ifNoneMatch_ = entityTag
   722  	return c
   723  }
   724  
   725  // Context sets the context to be used in this call's Do method.
   726  func (c *ProjectsModelsDownloadCall) Context(ctx context.Context) *ProjectsModelsDownloadCall {
   727  	c.ctx_ = ctx
   728  	return c
   729  }
   730  
   731  // Header returns a http.Header that can be modified by the caller to add
   732  // headers to the request.
   733  func (c *ProjectsModelsDownloadCall) Header() http.Header {
   734  	if c.header_ == nil {
   735  		c.header_ = make(http.Header)
   736  	}
   737  	return c.header_
   738  }
   739  
   740  func (c *ProjectsModelsDownloadCall) doRequest(alt string) (*http.Response, error) {
   741  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   742  	if c.ifNoneMatch_ != "" {
   743  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   744  	}
   745  	var body io.Reader = nil
   746  	c.urlParams_.Set("alt", alt)
   747  	c.urlParams_.Set("prettyPrint", "false")
   748  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}:download")
   749  	urls += "?" + c.urlParams_.Encode()
   750  	req, err := http.NewRequest("GET", urls, body)
   751  	if err != nil {
   752  		return nil, err
   753  	}
   754  	req.Header = reqHeaders
   755  	googleapi.Expand(req.URL, map[string]string{
   756  		"name": c.name,
   757  	})
   758  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   759  }
   760  
   761  // Do executes the "firebaseml.projects.models.download" call.
   762  // Any non-2xx status code is an error. Response headers are in either
   763  // *DownloadModelResponse.ServerResponse.Header or (if a response was returned
   764  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   765  // check whether the returned error was because http.StatusNotModified was
   766  // returned.
   767  func (c *ProjectsModelsDownloadCall) Do(opts ...googleapi.CallOption) (*DownloadModelResponse, error) {
   768  	gensupport.SetOptions(c.urlParams_, opts...)
   769  	res, err := c.doRequest("json")
   770  	if res != nil && res.StatusCode == http.StatusNotModified {
   771  		if res.Body != nil {
   772  			res.Body.Close()
   773  		}
   774  		return nil, gensupport.WrapError(&googleapi.Error{
   775  			Code:   res.StatusCode,
   776  			Header: res.Header,
   777  		})
   778  	}
   779  	if err != nil {
   780  		return nil, err
   781  	}
   782  	defer googleapi.CloseBody(res)
   783  	if err := googleapi.CheckResponse(res); err != nil {
   784  		return nil, gensupport.WrapError(err)
   785  	}
   786  	ret := &DownloadModelResponse{
   787  		ServerResponse: googleapi.ServerResponse{
   788  			Header:         res.Header,
   789  			HTTPStatusCode: res.StatusCode,
   790  		},
   791  	}
   792  	target := &ret
   793  	if err := gensupport.DecodeResponse(target, res); err != nil {
   794  		return nil, err
   795  	}
   796  	return ret, nil
   797  }
   798  
   799  type ProjectsModelsGetCall struct {
   800  	s            *Service
   801  	name         string
   802  	urlParams_   gensupport.URLParams
   803  	ifNoneMatch_ string
   804  	ctx_         context.Context
   805  	header_      http.Header
   806  }
   807  
   808  // Get: Gets a model resource.
   809  //
   810  //   - name: The name of the model to get. The name must have the form
   811  //     `projects/{project_id}/models/{model_id}`.
   812  func (r *ProjectsModelsService) Get(name string) *ProjectsModelsGetCall {
   813  	c := &ProjectsModelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   814  	c.name = name
   815  	return c
   816  }
   817  
   818  // Fields allows partial responses to be retrieved. See
   819  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   820  // details.
   821  func (c *ProjectsModelsGetCall) Fields(s ...googleapi.Field) *ProjectsModelsGetCall {
   822  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   823  	return c
   824  }
   825  
   826  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   827  // object's ETag matches the given value. This is useful for getting updates
   828  // only after the object has changed since the last request.
   829  func (c *ProjectsModelsGetCall) IfNoneMatch(entityTag string) *ProjectsModelsGetCall {
   830  	c.ifNoneMatch_ = entityTag
   831  	return c
   832  }
   833  
   834  // Context sets the context to be used in this call's Do method.
   835  func (c *ProjectsModelsGetCall) Context(ctx context.Context) *ProjectsModelsGetCall {
   836  	c.ctx_ = ctx
   837  	return c
   838  }
   839  
   840  // Header returns a http.Header that can be modified by the caller to add
   841  // headers to the request.
   842  func (c *ProjectsModelsGetCall) Header() http.Header {
   843  	if c.header_ == nil {
   844  		c.header_ = make(http.Header)
   845  	}
   846  	return c.header_
   847  }
   848  
   849  func (c *ProjectsModelsGetCall) doRequest(alt string) (*http.Response, error) {
   850  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   851  	if c.ifNoneMatch_ != "" {
   852  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   853  	}
   854  	var body io.Reader = nil
   855  	c.urlParams_.Set("alt", alt)
   856  	c.urlParams_.Set("prettyPrint", "false")
   857  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
   858  	urls += "?" + c.urlParams_.Encode()
   859  	req, err := http.NewRequest("GET", urls, body)
   860  	if err != nil {
   861  		return nil, err
   862  	}
   863  	req.Header = reqHeaders
   864  	googleapi.Expand(req.URL, map[string]string{
   865  		"name": c.name,
   866  	})
   867  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   868  }
   869  
   870  // Do executes the "firebaseml.projects.models.get" call.
   871  // Any non-2xx status code is an error. Response headers are in either
   872  // *Model.ServerResponse.Header or (if a response was returned at all) in
   873  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   874  // whether the returned error was because http.StatusNotModified was returned.
   875  func (c *ProjectsModelsGetCall) Do(opts ...googleapi.CallOption) (*Model, error) {
   876  	gensupport.SetOptions(c.urlParams_, opts...)
   877  	res, err := c.doRequest("json")
   878  	if res != nil && res.StatusCode == http.StatusNotModified {
   879  		if res.Body != nil {
   880  			res.Body.Close()
   881  		}
   882  		return nil, gensupport.WrapError(&googleapi.Error{
   883  			Code:   res.StatusCode,
   884  			Header: res.Header,
   885  		})
   886  	}
   887  	if err != nil {
   888  		return nil, err
   889  	}
   890  	defer googleapi.CloseBody(res)
   891  	if err := googleapi.CheckResponse(res); err != nil {
   892  		return nil, gensupport.WrapError(err)
   893  	}
   894  	ret := &Model{
   895  		ServerResponse: googleapi.ServerResponse{
   896  			Header:         res.Header,
   897  			HTTPStatusCode: res.StatusCode,
   898  		},
   899  	}
   900  	target := &ret
   901  	if err := gensupport.DecodeResponse(target, res); err != nil {
   902  		return nil, err
   903  	}
   904  	return ret, nil
   905  }
   906  
   907  type ProjectsModelsListCall struct {
   908  	s            *Service
   909  	parent       string
   910  	urlParams_   gensupport.URLParams
   911  	ifNoneMatch_ string
   912  	ctx_         context.Context
   913  	header_      http.Header
   914  }
   915  
   916  // List: Lists the models
   917  //
   918  //   - parent: The name of the parent to list models for. The parent must have
   919  //     the form `projects/{project_id}'.
   920  func (r *ProjectsModelsService) List(parent string) *ProjectsModelsListCall {
   921  	c := &ProjectsModelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   922  	c.parent = parent
   923  	return c
   924  }
   925  
   926  // Filter sets the optional parameter "filter": A filter for the list e.g.
   927  // 'tags: abc' to list models which are tagged with "abc"
   928  func (c *ProjectsModelsListCall) Filter(filter string) *ProjectsModelsListCall {
   929  	c.urlParams_.Set("filter", filter)
   930  	return c
   931  }
   932  
   933  // PageSize sets the optional parameter "pageSize": The maximum number of items
   934  // to return
   935  func (c *ProjectsModelsListCall) PageSize(pageSize int64) *ProjectsModelsListCall {
   936  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   937  	return c
   938  }
   939  
   940  // PageToken sets the optional parameter "pageToken": The next_page_token value
   941  // returned from a previous List request, if any.
   942  func (c *ProjectsModelsListCall) PageToken(pageToken string) *ProjectsModelsListCall {
   943  	c.urlParams_.Set("pageToken", pageToken)
   944  	return c
   945  }
   946  
   947  // Fields allows partial responses to be retrieved. See
   948  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   949  // details.
   950  func (c *ProjectsModelsListCall) Fields(s ...googleapi.Field) *ProjectsModelsListCall {
   951  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   952  	return c
   953  }
   954  
   955  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   956  // object's ETag matches the given value. This is useful for getting updates
   957  // only after the object has changed since the last request.
   958  func (c *ProjectsModelsListCall) IfNoneMatch(entityTag string) *ProjectsModelsListCall {
   959  	c.ifNoneMatch_ = entityTag
   960  	return c
   961  }
   962  
   963  // Context sets the context to be used in this call's Do method.
   964  func (c *ProjectsModelsListCall) Context(ctx context.Context) *ProjectsModelsListCall {
   965  	c.ctx_ = ctx
   966  	return c
   967  }
   968  
   969  // Header returns a http.Header that can be modified by the caller to add
   970  // headers to the request.
   971  func (c *ProjectsModelsListCall) Header() http.Header {
   972  	if c.header_ == nil {
   973  		c.header_ = make(http.Header)
   974  	}
   975  	return c.header_
   976  }
   977  
   978  func (c *ProjectsModelsListCall) doRequest(alt string) (*http.Response, error) {
   979  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   980  	if c.ifNoneMatch_ != "" {
   981  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   982  	}
   983  	var body io.Reader = nil
   984  	c.urlParams_.Set("alt", alt)
   985  	c.urlParams_.Set("prettyPrint", "false")
   986  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+parent}/models")
   987  	urls += "?" + c.urlParams_.Encode()
   988  	req, err := http.NewRequest("GET", urls, body)
   989  	if err != nil {
   990  		return nil, err
   991  	}
   992  	req.Header = reqHeaders
   993  	googleapi.Expand(req.URL, map[string]string{
   994  		"parent": c.parent,
   995  	})
   996  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   997  }
   998  
   999  // Do executes the "firebaseml.projects.models.list" call.
  1000  // Any non-2xx status code is an error. Response headers are in either
  1001  // *ListModelsResponse.ServerResponse.Header or (if a response was returned at
  1002  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1003  // check whether the returned error was because http.StatusNotModified was
  1004  // returned.
  1005  func (c *ProjectsModelsListCall) Do(opts ...googleapi.CallOption) (*ListModelsResponse, error) {
  1006  	gensupport.SetOptions(c.urlParams_, opts...)
  1007  	res, err := c.doRequest("json")
  1008  	if res != nil && res.StatusCode == http.StatusNotModified {
  1009  		if res.Body != nil {
  1010  			res.Body.Close()
  1011  		}
  1012  		return nil, gensupport.WrapError(&googleapi.Error{
  1013  			Code:   res.StatusCode,
  1014  			Header: res.Header,
  1015  		})
  1016  	}
  1017  	if err != nil {
  1018  		return nil, err
  1019  	}
  1020  	defer googleapi.CloseBody(res)
  1021  	if err := googleapi.CheckResponse(res); err != nil {
  1022  		return nil, gensupport.WrapError(err)
  1023  	}
  1024  	ret := &ListModelsResponse{
  1025  		ServerResponse: googleapi.ServerResponse{
  1026  			Header:         res.Header,
  1027  			HTTPStatusCode: res.StatusCode,
  1028  		},
  1029  	}
  1030  	target := &ret
  1031  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1032  		return nil, err
  1033  	}
  1034  	return ret, nil
  1035  }
  1036  
  1037  // Pages invokes f for each page of results.
  1038  // A non-nil error returned from f will halt the iteration.
  1039  // The provided context supersedes any context provided to the Context method.
  1040  func (c *ProjectsModelsListCall) Pages(ctx context.Context, f func(*ListModelsResponse) error) error {
  1041  	c.ctx_ = ctx
  1042  	defer c.PageToken(c.urlParams_.Get("pageToken"))
  1043  	for {
  1044  		x, err := c.Do()
  1045  		if err != nil {
  1046  			return err
  1047  		}
  1048  		if err := f(x); err != nil {
  1049  			return err
  1050  		}
  1051  		if x.NextPageToken == "" {
  1052  			return nil
  1053  		}
  1054  		c.PageToken(x.NextPageToken)
  1055  	}
  1056  }
  1057  
  1058  type ProjectsModelsPatchCall struct {
  1059  	s          *Service
  1060  	name       string
  1061  	model      *Model
  1062  	urlParams_ gensupport.URLParams
  1063  	ctx_       context.Context
  1064  	header_    http.Header
  1065  }
  1066  
  1067  // Patch: Updates a model. The longrunning operation will eventually return a
  1068  // Model.
  1069  //
  1070  //   - name: The resource name of the Model. Model names have the form
  1071  //     `projects/{project_id}/models/{model_id}` The name is ignored when
  1072  //     creating a model.
  1073  func (r *ProjectsModelsService) Patch(name string, model *Model) *ProjectsModelsPatchCall {
  1074  	c := &ProjectsModelsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1075  	c.name = name
  1076  	c.model = model
  1077  	return c
  1078  }
  1079  
  1080  // UpdateMask sets the optional parameter "updateMask": The update mask
  1081  func (c *ProjectsModelsPatchCall) UpdateMask(updateMask string) *ProjectsModelsPatchCall {
  1082  	c.urlParams_.Set("updateMask", updateMask)
  1083  	return c
  1084  }
  1085  
  1086  // Fields allows partial responses to be retrieved. See
  1087  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1088  // details.
  1089  func (c *ProjectsModelsPatchCall) Fields(s ...googleapi.Field) *ProjectsModelsPatchCall {
  1090  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1091  	return c
  1092  }
  1093  
  1094  // Context sets the context to be used in this call's Do method.
  1095  func (c *ProjectsModelsPatchCall) Context(ctx context.Context) *ProjectsModelsPatchCall {
  1096  	c.ctx_ = ctx
  1097  	return c
  1098  }
  1099  
  1100  // Header returns a http.Header that can be modified by the caller to add
  1101  // headers to the request.
  1102  func (c *ProjectsModelsPatchCall) Header() http.Header {
  1103  	if c.header_ == nil {
  1104  		c.header_ = make(http.Header)
  1105  	}
  1106  	return c.header_
  1107  }
  1108  
  1109  func (c *ProjectsModelsPatchCall) doRequest(alt string) (*http.Response, error) {
  1110  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1111  	var body io.Reader = nil
  1112  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.model)
  1113  	if err != nil {
  1114  		return nil, err
  1115  	}
  1116  	c.urlParams_.Set("alt", alt)
  1117  	c.urlParams_.Set("prettyPrint", "false")
  1118  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
  1119  	urls += "?" + c.urlParams_.Encode()
  1120  	req, err := http.NewRequest("PATCH", urls, body)
  1121  	if err != nil {
  1122  		return nil, err
  1123  	}
  1124  	req.Header = reqHeaders
  1125  	googleapi.Expand(req.URL, map[string]string{
  1126  		"name": c.name,
  1127  	})
  1128  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1129  }
  1130  
  1131  // Do executes the "firebaseml.projects.models.patch" call.
  1132  // Any non-2xx status code is an error. Response headers are in either
  1133  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1134  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1135  // whether the returned error was because http.StatusNotModified was returned.
  1136  func (c *ProjectsModelsPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1137  	gensupport.SetOptions(c.urlParams_, opts...)
  1138  	res, err := c.doRequest("json")
  1139  	if res != nil && res.StatusCode == http.StatusNotModified {
  1140  		if res.Body != nil {
  1141  			res.Body.Close()
  1142  		}
  1143  		return nil, gensupport.WrapError(&googleapi.Error{
  1144  			Code:   res.StatusCode,
  1145  			Header: res.Header,
  1146  		})
  1147  	}
  1148  	if err != nil {
  1149  		return nil, err
  1150  	}
  1151  	defer googleapi.CloseBody(res)
  1152  	if err := googleapi.CheckResponse(res); err != nil {
  1153  		return nil, gensupport.WrapError(err)
  1154  	}
  1155  	ret := &Operation{
  1156  		ServerResponse: googleapi.ServerResponse{
  1157  			Header:         res.Header,
  1158  			HTTPStatusCode: res.StatusCode,
  1159  		},
  1160  	}
  1161  	target := &ret
  1162  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1163  		return nil, err
  1164  	}
  1165  	return ret, nil
  1166  }
  1167  
  1168  type ProjectsOperationsGetCall struct {
  1169  	s            *Service
  1170  	name         string
  1171  	urlParams_   gensupport.URLParams
  1172  	ifNoneMatch_ string
  1173  	ctx_         context.Context
  1174  	header_      http.Header
  1175  }
  1176  
  1177  // Get: Gets the latest state of a long-running operation. Clients can use this
  1178  // method to poll the operation result at intervals as recommended by the API
  1179  // service.
  1180  //
  1181  // - name: The name of the operation resource.
  1182  func (r *ProjectsOperationsService) Get(name string) *ProjectsOperationsGetCall {
  1183  	c := &ProjectsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1184  	c.name = name
  1185  	return c
  1186  }
  1187  
  1188  // Fields allows partial responses to be retrieved. See
  1189  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1190  // details.
  1191  func (c *ProjectsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsOperationsGetCall {
  1192  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1193  	return c
  1194  }
  1195  
  1196  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1197  // object's ETag matches the given value. This is useful for getting updates
  1198  // only after the object has changed since the last request.
  1199  func (c *ProjectsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsOperationsGetCall {
  1200  	c.ifNoneMatch_ = entityTag
  1201  	return c
  1202  }
  1203  
  1204  // Context sets the context to be used in this call's Do method.
  1205  func (c *ProjectsOperationsGetCall) Context(ctx context.Context) *ProjectsOperationsGetCall {
  1206  	c.ctx_ = ctx
  1207  	return c
  1208  }
  1209  
  1210  // Header returns a http.Header that can be modified by the caller to add
  1211  // headers to the request.
  1212  func (c *ProjectsOperationsGetCall) Header() http.Header {
  1213  	if c.header_ == nil {
  1214  		c.header_ = make(http.Header)
  1215  	}
  1216  	return c.header_
  1217  }
  1218  
  1219  func (c *ProjectsOperationsGetCall) doRequest(alt string) (*http.Response, error) {
  1220  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1221  	if c.ifNoneMatch_ != "" {
  1222  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1223  	}
  1224  	var body io.Reader = nil
  1225  	c.urlParams_.Set("alt", alt)
  1226  	c.urlParams_.Set("prettyPrint", "false")
  1227  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
  1228  	urls += "?" + c.urlParams_.Encode()
  1229  	req, err := http.NewRequest("GET", urls, body)
  1230  	if err != nil {
  1231  		return nil, err
  1232  	}
  1233  	req.Header = reqHeaders
  1234  	googleapi.Expand(req.URL, map[string]string{
  1235  		"name": c.name,
  1236  	})
  1237  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1238  }
  1239  
  1240  // Do executes the "firebaseml.projects.operations.get" call.
  1241  // Any non-2xx status code is an error. Response headers are in either
  1242  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1243  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1244  // whether the returned error was because http.StatusNotModified was returned.
  1245  func (c *ProjectsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1246  	gensupport.SetOptions(c.urlParams_, opts...)
  1247  	res, err := c.doRequest("json")
  1248  	if res != nil && res.StatusCode == http.StatusNotModified {
  1249  		if res.Body != nil {
  1250  			res.Body.Close()
  1251  		}
  1252  		return nil, gensupport.WrapError(&googleapi.Error{
  1253  			Code:   res.StatusCode,
  1254  			Header: res.Header,
  1255  		})
  1256  	}
  1257  	if err != nil {
  1258  		return nil, err
  1259  	}
  1260  	defer googleapi.CloseBody(res)
  1261  	if err := googleapi.CheckResponse(res); err != nil {
  1262  		return nil, gensupport.WrapError(err)
  1263  	}
  1264  	ret := &Operation{
  1265  		ServerResponse: googleapi.ServerResponse{
  1266  			Header:         res.Header,
  1267  			HTTPStatusCode: res.StatusCode,
  1268  		},
  1269  	}
  1270  	target := &ret
  1271  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1272  		return nil, err
  1273  	}
  1274  	return ret, nil
  1275  }
  1276  

View as plain text