...

Source file src/google.golang.org/api/firebasestorage/v1beta/firebasestorage-gen.go

Documentation: google.golang.org/api/firebasestorage/v1beta

     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 firebasestorage provides access to the Cloud Storage for Firebase API.
     8  //
     9  // For product documentation, see: https://firebase.google.com/docs/storage
    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/firebasestorage/v1beta"
    27  //	...
    28  //	ctx := context.Background()
    29  //	firebasestorageService, err := firebasestorage.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	firebasestorageService, err := firebasestorage.NewService(ctx, option.WithScopes(firebasestorage.FirebaseScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	firebasestorageService, err := firebasestorage.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	firebasestorageService, err := firebasestorage.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package firebasestorage // import "google.golang.org/api/firebasestorage/v1beta"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "firebasestorage:v1beta"
    95  const apiName = "firebasestorage"
    96  const apiVersion = "v1beta"
    97  const basePath = "https://firebasestorage.googleapis.com/"
    98  const basePathTemplate = "https://firebasestorage.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://firebasestorage.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// See, edit, configure, and delete your Google Cloud data and see the email
   104  	// address for your Google Account.
   105  	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
   106  
   107  	// View and administer all your Firebase data and settings
   108  	FirebaseScope = "https://www.googleapis.com/auth/firebase"
   109  )
   110  
   111  // NewService creates a new Service.
   112  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   113  	scopesOption := internaloption.WithDefaultScopes(
   114  		"https://www.googleapis.com/auth/cloud-platform",
   115  		"https://www.googleapis.com/auth/firebase",
   116  	)
   117  	// NOTE: prepend, so we don't override user-specified scopes.
   118  	opts = append([]option.ClientOption{scopesOption}, opts...)
   119  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   120  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   121  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   122  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   123  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  	s, err := New(client)
   128  	if err != nil {
   129  		return nil, err
   130  	}
   131  	if endpoint != "" {
   132  		s.BasePath = endpoint
   133  	}
   134  	return s, nil
   135  }
   136  
   137  // New creates a new Service. It uses the provided http.Client for requests.
   138  //
   139  // Deprecated: please use NewService instead.
   140  // To provide a custom HTTP client, use option.WithHTTPClient.
   141  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   142  func New(client *http.Client) (*Service, error) {
   143  	if client == nil {
   144  		return nil, errors.New("client is nil")
   145  	}
   146  	s := &Service{client: client, BasePath: basePath}
   147  	s.Projects = NewProjectsService(s)
   148  	return s, nil
   149  }
   150  
   151  type Service struct {
   152  	client    *http.Client
   153  	BasePath  string // API endpoint base URL
   154  	UserAgent string // optional additional User-Agent fragment
   155  
   156  	Projects *ProjectsService
   157  }
   158  
   159  func (s *Service) userAgent() string {
   160  	if s.UserAgent == "" {
   161  		return googleapi.UserAgent
   162  	}
   163  	return googleapi.UserAgent + " " + s.UserAgent
   164  }
   165  
   166  func NewProjectsService(s *Service) *ProjectsService {
   167  	rs := &ProjectsService{s: s}
   168  	rs.Buckets = NewProjectsBucketsService(s)
   169  	return rs
   170  }
   171  
   172  type ProjectsService struct {
   173  	s *Service
   174  
   175  	Buckets *ProjectsBucketsService
   176  }
   177  
   178  func NewProjectsBucketsService(s *Service) *ProjectsBucketsService {
   179  	rs := &ProjectsBucketsService{s: s}
   180  	return rs
   181  }
   182  
   183  type ProjectsBucketsService struct {
   184  	s *Service
   185  }
   186  
   187  // AddFirebaseRequest: The request used to link a Google Cloud Storage bucket
   188  // to a Firebase project.
   189  type AddFirebaseRequest struct {
   190  }
   191  
   192  // Bucket: A storage bucket and its relation to a parent Firebase project.
   193  type Bucket struct {
   194  	// Name: Output only. Resource name of the bucket.
   195  	Name string `json:"name,omitempty"`
   196  
   197  	// ServerResponse contains the HTTP response code and headers from the server.
   198  	googleapi.ServerResponse `json:"-"`
   199  	// ForceSendFields is a list of field names (e.g. "Name") to unconditionally
   200  	// include in API requests. By default, fields with empty or default values are
   201  	// omitted from API requests. See
   202  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   203  	// details.
   204  	ForceSendFields []string `json:"-"`
   205  	// NullFields is a list of field names (e.g. "Name") to include in API requests
   206  	// with the JSON null value. By default, fields with empty values are omitted
   207  	// from API requests. See
   208  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   209  	NullFields []string `json:"-"`
   210  }
   211  
   212  func (s *Bucket) MarshalJSON() ([]byte, error) {
   213  	type NoMethod Bucket
   214  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   215  }
   216  
   217  // Empty: A generic empty message that you can re-use to avoid defining
   218  // duplicated empty messages in your APIs. A typical example is to use it as
   219  // the request or the response type of an API method. For instance: service Foo
   220  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   221  type Empty struct {
   222  	// ServerResponse contains the HTTP response code and headers from the server.
   223  	googleapi.ServerResponse `json:"-"`
   224  }
   225  
   226  // GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata:
   227  //
   228  //	Metadata for MigrateLocationDestructively LRO.
   229  type GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata struct {
   230  	// CreateTime: The time the LRO was created.
   231  	CreateTime string `json:"createTime,omitempty"`
   232  	// LastUpdateTime: The time the LRO was last updated.
   233  	LastUpdateTime string `json:"lastUpdateTime,omitempty"`
   234  	// State: The current state of the migration.
   235  	//
   236  	// Possible values:
   237  	//   "STATE_UNSPECIFIED" - Unspecified state. Should not be used.
   238  	//   "PENDING" - The MigrateLocationDestructively request has passed
   239  	// precondition checks and the bucket migration will begin soon.
   240  	//   "CREATING_TEMP_BUCKET" - Generating a unique bucket name, storing the
   241  	// source -> temp mapping in Spanner, and actually creating the temporary
   242  	// bucket via Bigstore.
   243  	//   "TRANSFERRING_TO_TEMP" - The first STS transfer to move all objects from
   244  	// the source bucket to the temp bucket is underway.
   245  	//   "DELETING_SOURCE_BUCKET" - The source bucket is being emptied and deleted.
   246  	//   "CREATING_DESTINATION_BUCKET" - The source bucket is being recreated in
   247  	// the new location.
   248  	//   "TRANSFERRING_TO_DESTINATION" - The second STS transfer to move all
   249  	// objects from the temp bucket to the final bucket is underway.
   250  	//   "DELETING_TEMP_BUCKET" - The temp bucket is being emptied and deleted.
   251  	//   "SUCCEEDED" - All stages of the migration have completed and the operation
   252  	// has been marked done and updated with a response.
   253  	//   "FAILED" - The migration failed at some stage and it is not possible to
   254  	// continue retrying that stage. Manual recovery may be needed. Rollback is
   255  	// either impossible at this stage, or has been attempted and failed.
   256  	//   "ROLLING_BACK" - The migration has encountered a permanent failure and is
   257  	// now being rolled back so that the source bucket is restored to its original
   258  	// state.
   259  	//   "ROLLED_BACK" - The migration has been successfully rolled back.
   260  	State string `json:"state,omitempty"`
   261  	// ForceSendFields is a list of field names (e.g. "CreateTime") to
   262  	// unconditionally include in API requests. By default, fields with empty or
   263  	// default values are omitted from API requests. See
   264  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   265  	// details.
   266  	ForceSendFields []string `json:"-"`
   267  	// NullFields is a list of field names (e.g. "CreateTime") to include in API
   268  	// requests with the JSON null value. By default, fields with empty values are
   269  	// omitted from API requests. See
   270  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   271  	NullFields []string `json:"-"`
   272  }
   273  
   274  func (s *GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata) MarshalJSON() ([]byte, error) {
   275  	type NoMethod GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata
   276  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   277  }
   278  
   279  // GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata:
   280  // Metadata for MigrateLocationDestructively LRO.
   281  type GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata struct {
   282  	// CreateTime: The time the LRO was created.
   283  	CreateTime string `json:"createTime,omitempty"`
   284  	// LastUpdateTime: The time the LRO was last updated.
   285  	LastUpdateTime string `json:"lastUpdateTime,omitempty"`
   286  	// State: The current state of the migration.
   287  	//
   288  	// Possible values:
   289  	//   "STATE_UNSPECIFIED" - Unspecified state. Should not be used.
   290  	//   "PENDING" - The MigrateLocationDestructively request has passed
   291  	// precondition checks and the bucket migration will begin soon.
   292  	//   "CREATING_TEMP_BUCKET" - Generating a unique bucket name, storing the
   293  	// source -> temp mapping in Spanner, and actually creating the temporary
   294  	// bucket via Bigstore.
   295  	//   "TRANSFERRING_TO_TEMP" - The first STS transfer to move all objects from
   296  	// the source bucket to the temp bucket is underway.
   297  	//   "DELETING_SOURCE_BUCKET" - The source bucket is being emptied and deleted.
   298  	//   "CREATING_DESTINATION_BUCKET" - The source bucket is being recreated in
   299  	// the new location.
   300  	//   "TRANSFERRING_TO_DESTINATION" - The second STS transfer to move all
   301  	// objects from the temp bucket to the final bucket is underway.
   302  	//   "DELETING_TEMP_BUCKET" - The temp bucket is being emptied and deleted.
   303  	//   "SUCCEEDED" - All stages of the migration have completed and the operation
   304  	// has been marked done and updated with a response.
   305  	//   "FAILED" - The migration failed at some stage and it is not possible to
   306  	// continue retrying that stage. Manual recovery may be needed. Rollback is
   307  	// either impossible at this stage, or has been attempted and failed.
   308  	//   "ROLLING_BACK" - The migration has encountered a permanent failure and is
   309  	// now being rolled back so that the source bucket is restored to its original
   310  	// state.
   311  	//   "ROLLED_BACK" - The migration has been successfully rolled back.
   312  	State string `json:"state,omitempty"`
   313  	// ForceSendFields is a list of field names (e.g. "CreateTime") 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. "CreateTime") 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 *GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata) MarshalJSON() ([]byte, error) {
   327  	type NoMethod GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata
   328  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   329  }
   330  
   331  // ListBucketsResponse: The response returned by `ListBuckets`.
   332  type ListBucketsResponse struct {
   333  	// Buckets: The list of linked buckets.
   334  	Buckets []*Bucket `json:"buckets,omitempty"`
   335  	// NextPageToken: A token that can be sent as `page_token` to retrieve the next
   336  	// page. If this field is omitted, there are no subsequent pages.
   337  	NextPageToken string `json:"nextPageToken,omitempty"`
   338  
   339  	// ServerResponse contains the HTTP response code and headers from the server.
   340  	googleapi.ServerResponse `json:"-"`
   341  	// ForceSendFields is a list of field names (e.g. "Buckets") to unconditionally
   342  	// include in API requests. By default, fields with empty or default values are
   343  	// omitted from API requests. See
   344  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   345  	// details.
   346  	ForceSendFields []string `json:"-"`
   347  	// NullFields is a list of field names (e.g. "Buckets") to include in API
   348  	// requests with the JSON null value. By default, fields with empty values are
   349  	// omitted from API requests. See
   350  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   351  	NullFields []string `json:"-"`
   352  }
   353  
   354  func (s *ListBucketsResponse) MarshalJSON() ([]byte, error) {
   355  	type NoMethod ListBucketsResponse
   356  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   357  }
   358  
   359  // RemoveFirebaseRequest: The request used to unlink a Google Cloud Storage
   360  // bucket from a Firebase project.
   361  type RemoveFirebaseRequest struct {
   362  }
   363  
   364  type ProjectsBucketsAddFirebaseCall struct {
   365  	s                  *Service
   366  	bucket             string
   367  	addfirebaserequest *AddFirebaseRequest
   368  	urlParams_         gensupport.URLParams
   369  	ctx_               context.Context
   370  	header_            http.Header
   371  }
   372  
   373  // AddFirebase: Links a Google Cloud Storage bucket to a Firebase project.
   374  //
   375  //   - bucket: Resource name of the bucket, mirrors the ID of the underlying
   376  //     Google Cloud Storage bucket,
   377  //     `projects/{project_id_or_number}/buckets/{bucket_id}`.
   378  func (r *ProjectsBucketsService) AddFirebase(bucket string, addfirebaserequest *AddFirebaseRequest) *ProjectsBucketsAddFirebaseCall {
   379  	c := &ProjectsBucketsAddFirebaseCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   380  	c.bucket = bucket
   381  	c.addfirebaserequest = addfirebaserequest
   382  	return c
   383  }
   384  
   385  // Fields allows partial responses to be retrieved. See
   386  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   387  // details.
   388  func (c *ProjectsBucketsAddFirebaseCall) Fields(s ...googleapi.Field) *ProjectsBucketsAddFirebaseCall {
   389  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   390  	return c
   391  }
   392  
   393  // Context sets the context to be used in this call's Do method.
   394  func (c *ProjectsBucketsAddFirebaseCall) Context(ctx context.Context) *ProjectsBucketsAddFirebaseCall {
   395  	c.ctx_ = ctx
   396  	return c
   397  }
   398  
   399  // Header returns a http.Header that can be modified by the caller to add
   400  // headers to the request.
   401  func (c *ProjectsBucketsAddFirebaseCall) Header() http.Header {
   402  	if c.header_ == nil {
   403  		c.header_ = make(http.Header)
   404  	}
   405  	return c.header_
   406  }
   407  
   408  func (c *ProjectsBucketsAddFirebaseCall) doRequest(alt string) (*http.Response, error) {
   409  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   410  	var body io.Reader = nil
   411  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.addfirebaserequest)
   412  	if err != nil {
   413  		return nil, err
   414  	}
   415  	c.urlParams_.Set("alt", alt)
   416  	c.urlParams_.Set("prettyPrint", "false")
   417  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+bucket}:addFirebase")
   418  	urls += "?" + c.urlParams_.Encode()
   419  	req, err := http.NewRequest("POST", urls, body)
   420  	if err != nil {
   421  		return nil, err
   422  	}
   423  	req.Header = reqHeaders
   424  	googleapi.Expand(req.URL, map[string]string{
   425  		"bucket": c.bucket,
   426  	})
   427  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   428  }
   429  
   430  // Do executes the "firebasestorage.projects.buckets.addFirebase" call.
   431  // Any non-2xx status code is an error. Response headers are in either
   432  // *Bucket.ServerResponse.Header or (if a response was returned at all) in
   433  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   434  // whether the returned error was because http.StatusNotModified was returned.
   435  func (c *ProjectsBucketsAddFirebaseCall) Do(opts ...googleapi.CallOption) (*Bucket, error) {
   436  	gensupport.SetOptions(c.urlParams_, opts...)
   437  	res, err := c.doRequest("json")
   438  	if res != nil && res.StatusCode == http.StatusNotModified {
   439  		if res.Body != nil {
   440  			res.Body.Close()
   441  		}
   442  		return nil, gensupport.WrapError(&googleapi.Error{
   443  			Code:   res.StatusCode,
   444  			Header: res.Header,
   445  		})
   446  	}
   447  	if err != nil {
   448  		return nil, err
   449  	}
   450  	defer googleapi.CloseBody(res)
   451  	if err := googleapi.CheckResponse(res); err != nil {
   452  		return nil, gensupport.WrapError(err)
   453  	}
   454  	ret := &Bucket{
   455  		ServerResponse: googleapi.ServerResponse{
   456  			Header:         res.Header,
   457  			HTTPStatusCode: res.StatusCode,
   458  		},
   459  	}
   460  	target := &ret
   461  	if err := gensupport.DecodeResponse(target, res); err != nil {
   462  		return nil, err
   463  	}
   464  	return ret, nil
   465  }
   466  
   467  type ProjectsBucketsGetCall struct {
   468  	s            *Service
   469  	name         string
   470  	urlParams_   gensupport.URLParams
   471  	ifNoneMatch_ string
   472  	ctx_         context.Context
   473  	header_      http.Header
   474  }
   475  
   476  // Get: Gets a single linked storage bucket.
   477  //
   478  //   - name: Resource name of the bucket, mirrors the ID of the underlying Google
   479  //     Cloud Storage bucket,
   480  //     `projects/{project_id_or_number}/buckets/{bucket_id}`.
   481  func (r *ProjectsBucketsService) Get(name string) *ProjectsBucketsGetCall {
   482  	c := &ProjectsBucketsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   483  	c.name = name
   484  	return c
   485  }
   486  
   487  // Fields allows partial responses to be retrieved. See
   488  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   489  // details.
   490  func (c *ProjectsBucketsGetCall) Fields(s ...googleapi.Field) *ProjectsBucketsGetCall {
   491  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   492  	return c
   493  }
   494  
   495  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   496  // object's ETag matches the given value. This is useful for getting updates
   497  // only after the object has changed since the last request.
   498  func (c *ProjectsBucketsGetCall) IfNoneMatch(entityTag string) *ProjectsBucketsGetCall {
   499  	c.ifNoneMatch_ = entityTag
   500  	return c
   501  }
   502  
   503  // Context sets the context to be used in this call's Do method.
   504  func (c *ProjectsBucketsGetCall) Context(ctx context.Context) *ProjectsBucketsGetCall {
   505  	c.ctx_ = ctx
   506  	return c
   507  }
   508  
   509  // Header returns a http.Header that can be modified by the caller to add
   510  // headers to the request.
   511  func (c *ProjectsBucketsGetCall) Header() http.Header {
   512  	if c.header_ == nil {
   513  		c.header_ = make(http.Header)
   514  	}
   515  	return c.header_
   516  }
   517  
   518  func (c *ProjectsBucketsGetCall) doRequest(alt string) (*http.Response, error) {
   519  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   520  	if c.ifNoneMatch_ != "" {
   521  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   522  	}
   523  	var body io.Reader = nil
   524  	c.urlParams_.Set("alt", alt)
   525  	c.urlParams_.Set("prettyPrint", "false")
   526  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
   527  	urls += "?" + c.urlParams_.Encode()
   528  	req, err := http.NewRequest("GET", urls, body)
   529  	if err != nil {
   530  		return nil, err
   531  	}
   532  	req.Header = reqHeaders
   533  	googleapi.Expand(req.URL, map[string]string{
   534  		"name": c.name,
   535  	})
   536  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   537  }
   538  
   539  // Do executes the "firebasestorage.projects.buckets.get" call.
   540  // Any non-2xx status code is an error. Response headers are in either
   541  // *Bucket.ServerResponse.Header or (if a response was returned at all) in
   542  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   543  // whether the returned error was because http.StatusNotModified was returned.
   544  func (c *ProjectsBucketsGetCall) Do(opts ...googleapi.CallOption) (*Bucket, error) {
   545  	gensupport.SetOptions(c.urlParams_, opts...)
   546  	res, err := c.doRequest("json")
   547  	if res != nil && res.StatusCode == http.StatusNotModified {
   548  		if res.Body != nil {
   549  			res.Body.Close()
   550  		}
   551  		return nil, gensupport.WrapError(&googleapi.Error{
   552  			Code:   res.StatusCode,
   553  			Header: res.Header,
   554  		})
   555  	}
   556  	if err != nil {
   557  		return nil, err
   558  	}
   559  	defer googleapi.CloseBody(res)
   560  	if err := googleapi.CheckResponse(res); err != nil {
   561  		return nil, gensupport.WrapError(err)
   562  	}
   563  	ret := &Bucket{
   564  		ServerResponse: googleapi.ServerResponse{
   565  			Header:         res.Header,
   566  			HTTPStatusCode: res.StatusCode,
   567  		},
   568  	}
   569  	target := &ret
   570  	if err := gensupport.DecodeResponse(target, res); err != nil {
   571  		return nil, err
   572  	}
   573  	return ret, nil
   574  }
   575  
   576  type ProjectsBucketsListCall struct {
   577  	s            *Service
   578  	parent       string
   579  	urlParams_   gensupport.URLParams
   580  	ifNoneMatch_ string
   581  	ctx_         context.Context
   582  	header_      http.Header
   583  }
   584  
   585  // List: Lists the linked storage buckets for a project.
   586  //
   587  //   - parent: Resource name of the parent Firebase project,
   588  //     `projects/{project_id_or_number}`.
   589  func (r *ProjectsBucketsService) List(parent string) *ProjectsBucketsListCall {
   590  	c := &ProjectsBucketsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   591  	c.parent = parent
   592  	return c
   593  }
   594  
   595  // PageSize sets the optional parameter "pageSize": The maximum number of
   596  // buckets to return. If not set, the server will use a reasonable default.
   597  func (c *ProjectsBucketsListCall) PageSize(pageSize int64) *ProjectsBucketsListCall {
   598  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   599  	return c
   600  }
   601  
   602  // PageToken sets the optional parameter "pageToken": A page token, received
   603  // from a previous `ListBuckets` call. Provide this to retrieve the subsequent
   604  // page. When paginating, all other parameters provided to `ListBuckets` must
   605  // match the call that provided the page token.
   606  func (c *ProjectsBucketsListCall) PageToken(pageToken string) *ProjectsBucketsListCall {
   607  	c.urlParams_.Set("pageToken", pageToken)
   608  	return c
   609  }
   610  
   611  // Fields allows partial responses to be retrieved. See
   612  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   613  // details.
   614  func (c *ProjectsBucketsListCall) Fields(s ...googleapi.Field) *ProjectsBucketsListCall {
   615  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   616  	return c
   617  }
   618  
   619  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   620  // object's ETag matches the given value. This is useful for getting updates
   621  // only after the object has changed since the last request.
   622  func (c *ProjectsBucketsListCall) IfNoneMatch(entityTag string) *ProjectsBucketsListCall {
   623  	c.ifNoneMatch_ = entityTag
   624  	return c
   625  }
   626  
   627  // Context sets the context to be used in this call's Do method.
   628  func (c *ProjectsBucketsListCall) Context(ctx context.Context) *ProjectsBucketsListCall {
   629  	c.ctx_ = ctx
   630  	return c
   631  }
   632  
   633  // Header returns a http.Header that can be modified by the caller to add
   634  // headers to the request.
   635  func (c *ProjectsBucketsListCall) Header() http.Header {
   636  	if c.header_ == nil {
   637  		c.header_ = make(http.Header)
   638  	}
   639  	return c.header_
   640  }
   641  
   642  func (c *ProjectsBucketsListCall) doRequest(alt string) (*http.Response, error) {
   643  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   644  	if c.ifNoneMatch_ != "" {
   645  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   646  	}
   647  	var body io.Reader = nil
   648  	c.urlParams_.Set("alt", alt)
   649  	c.urlParams_.Set("prettyPrint", "false")
   650  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+parent}/buckets")
   651  	urls += "?" + c.urlParams_.Encode()
   652  	req, err := http.NewRequest("GET", urls, body)
   653  	if err != nil {
   654  		return nil, err
   655  	}
   656  	req.Header = reqHeaders
   657  	googleapi.Expand(req.URL, map[string]string{
   658  		"parent": c.parent,
   659  	})
   660  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   661  }
   662  
   663  // Do executes the "firebasestorage.projects.buckets.list" call.
   664  // Any non-2xx status code is an error. Response headers are in either
   665  // *ListBucketsResponse.ServerResponse.Header or (if a response was returned at
   666  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   667  // check whether the returned error was because http.StatusNotModified was
   668  // returned.
   669  func (c *ProjectsBucketsListCall) Do(opts ...googleapi.CallOption) (*ListBucketsResponse, error) {
   670  	gensupport.SetOptions(c.urlParams_, opts...)
   671  	res, err := c.doRequest("json")
   672  	if res != nil && res.StatusCode == http.StatusNotModified {
   673  		if res.Body != nil {
   674  			res.Body.Close()
   675  		}
   676  		return nil, gensupport.WrapError(&googleapi.Error{
   677  			Code:   res.StatusCode,
   678  			Header: res.Header,
   679  		})
   680  	}
   681  	if err != nil {
   682  		return nil, err
   683  	}
   684  	defer googleapi.CloseBody(res)
   685  	if err := googleapi.CheckResponse(res); err != nil {
   686  		return nil, gensupport.WrapError(err)
   687  	}
   688  	ret := &ListBucketsResponse{
   689  		ServerResponse: googleapi.ServerResponse{
   690  			Header:         res.Header,
   691  			HTTPStatusCode: res.StatusCode,
   692  		},
   693  	}
   694  	target := &ret
   695  	if err := gensupport.DecodeResponse(target, res); err != nil {
   696  		return nil, err
   697  	}
   698  	return ret, nil
   699  }
   700  
   701  // Pages invokes f for each page of results.
   702  // A non-nil error returned from f will halt the iteration.
   703  // The provided context supersedes any context provided to the Context method.
   704  func (c *ProjectsBucketsListCall) Pages(ctx context.Context, f func(*ListBucketsResponse) error) error {
   705  	c.ctx_ = ctx
   706  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   707  	for {
   708  		x, err := c.Do()
   709  		if err != nil {
   710  			return err
   711  		}
   712  		if err := f(x); err != nil {
   713  			return err
   714  		}
   715  		if x.NextPageToken == "" {
   716  			return nil
   717  		}
   718  		c.PageToken(x.NextPageToken)
   719  	}
   720  }
   721  
   722  type ProjectsBucketsRemoveFirebaseCall struct {
   723  	s                     *Service
   724  	bucket                string
   725  	removefirebaserequest *RemoveFirebaseRequest
   726  	urlParams_            gensupport.URLParams
   727  	ctx_                  context.Context
   728  	header_               http.Header
   729  }
   730  
   731  // RemoveFirebase: Unlinks a linked Google Cloud Storage bucket from a Firebase
   732  // project.
   733  //
   734  //   - bucket: Resource name of the bucket, mirrors the ID of the underlying
   735  //     Google Cloud Storage bucket,
   736  //     `projects/{project_id_or_number}/buckets/{bucket_id}`.
   737  func (r *ProjectsBucketsService) RemoveFirebase(bucket string, removefirebaserequest *RemoveFirebaseRequest) *ProjectsBucketsRemoveFirebaseCall {
   738  	c := &ProjectsBucketsRemoveFirebaseCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   739  	c.bucket = bucket
   740  	c.removefirebaserequest = removefirebaserequest
   741  	return c
   742  }
   743  
   744  // Fields allows partial responses to be retrieved. See
   745  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   746  // details.
   747  func (c *ProjectsBucketsRemoveFirebaseCall) Fields(s ...googleapi.Field) *ProjectsBucketsRemoveFirebaseCall {
   748  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   749  	return c
   750  }
   751  
   752  // Context sets the context to be used in this call's Do method.
   753  func (c *ProjectsBucketsRemoveFirebaseCall) Context(ctx context.Context) *ProjectsBucketsRemoveFirebaseCall {
   754  	c.ctx_ = ctx
   755  	return c
   756  }
   757  
   758  // Header returns a http.Header that can be modified by the caller to add
   759  // headers to the request.
   760  func (c *ProjectsBucketsRemoveFirebaseCall) Header() http.Header {
   761  	if c.header_ == nil {
   762  		c.header_ = make(http.Header)
   763  	}
   764  	return c.header_
   765  }
   766  
   767  func (c *ProjectsBucketsRemoveFirebaseCall) doRequest(alt string) (*http.Response, error) {
   768  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   769  	var body io.Reader = nil
   770  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.removefirebaserequest)
   771  	if err != nil {
   772  		return nil, err
   773  	}
   774  	c.urlParams_.Set("alt", alt)
   775  	c.urlParams_.Set("prettyPrint", "false")
   776  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+bucket}:removeFirebase")
   777  	urls += "?" + c.urlParams_.Encode()
   778  	req, err := http.NewRequest("POST", urls, body)
   779  	if err != nil {
   780  		return nil, err
   781  	}
   782  	req.Header = reqHeaders
   783  	googleapi.Expand(req.URL, map[string]string{
   784  		"bucket": c.bucket,
   785  	})
   786  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   787  }
   788  
   789  // Do executes the "firebasestorage.projects.buckets.removeFirebase" call.
   790  // Any non-2xx status code is an error. Response headers are in either
   791  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   792  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   793  // whether the returned error was because http.StatusNotModified was returned.
   794  func (c *ProjectsBucketsRemoveFirebaseCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   795  	gensupport.SetOptions(c.urlParams_, opts...)
   796  	res, err := c.doRequest("json")
   797  	if res != nil && res.StatusCode == http.StatusNotModified {
   798  		if res.Body != nil {
   799  			res.Body.Close()
   800  		}
   801  		return nil, gensupport.WrapError(&googleapi.Error{
   802  			Code:   res.StatusCode,
   803  			Header: res.Header,
   804  		})
   805  	}
   806  	if err != nil {
   807  		return nil, err
   808  	}
   809  	defer googleapi.CloseBody(res)
   810  	if err := googleapi.CheckResponse(res); err != nil {
   811  		return nil, gensupport.WrapError(err)
   812  	}
   813  	ret := &Empty{
   814  		ServerResponse: googleapi.ServerResponse{
   815  			Header:         res.Header,
   816  			HTTPStatusCode: res.StatusCode,
   817  		},
   818  	}
   819  	target := &ret
   820  	if err := gensupport.DecodeResponse(target, res); err != nil {
   821  		return nil, err
   822  	}
   823  	return ret, nil
   824  }
   825  

View as plain text