...

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

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

     1  // Copyright 2020 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 firebaseremoteconfig provides access to the Firebase Remote Config API.
     8  //
     9  // For product documentation, see: https://firebase.google.com/docs/remote-config/
    10  //
    11  // # Creating a client
    12  //
    13  // Usage example:
    14  //
    15  //	import "google.golang.org/api/firebaseremoteconfig/v1"
    16  //	...
    17  //	ctx := context.Background()
    18  //	firebaseremoteconfigService, err := firebaseremoteconfig.NewService(ctx)
    19  //
    20  // In this example, Google Application Default Credentials are used for authentication.
    21  //
    22  // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    23  //
    24  // # Other authentication options
    25  //
    26  // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
    27  //
    28  //	firebaseremoteconfigService, err := firebaseremoteconfig.NewService(ctx, option.WithAPIKey("AIza..."))
    29  //
    30  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
    31  //
    32  //	config := &oauth2.Config{...}
    33  //	// ...
    34  //	token, err := config.Exchange(ctx, ...)
    35  //	firebaseremoteconfigService, err := firebaseremoteconfig.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    36  //
    37  // See https://godoc.org/google.golang.org/api/option/ for details on options.
    38  package firebaseremoteconfig // import "google.golang.org/api/firebaseremoteconfig/v1"
    39  
    40  import (
    41  	"bytes"
    42  	"context"
    43  	"encoding/json"
    44  	"errors"
    45  	"fmt"
    46  	"io"
    47  	"net/http"
    48  	"net/url"
    49  	"strconv"
    50  	"strings"
    51  
    52  	googleapi "google.golang.org/api/googleapi"
    53  	gensupport "google.golang.org/api/internal/gensupport"
    54  	option "google.golang.org/api/option"
    55  	htransport "google.golang.org/api/transport/http"
    56  )
    57  
    58  // Always reference these packages, just in case the auto-generated code
    59  // below doesn't.
    60  var _ = bytes.NewBuffer
    61  var _ = strconv.Itoa
    62  var _ = fmt.Sprintf
    63  var _ = json.NewDecoder
    64  var _ = io.Copy
    65  var _ = url.Parse
    66  var _ = gensupport.MarshalJSON
    67  var _ = googleapi.Version
    68  var _ = errors.New
    69  var _ = strings.Replace
    70  var _ = context.Canceled
    71  
    72  const apiId = "firebaseremoteconfig:v1"
    73  const apiName = "firebaseremoteconfig"
    74  const apiVersion = "v1"
    75  const basePath = "https://firebaseremoteconfig.googleapis.com/"
    76  
    77  // NewService creates a new Service.
    78  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    79  	client, endpoint, err := htransport.NewClient(ctx, opts...)
    80  	if err != nil {
    81  		return nil, err
    82  	}
    83  	s, err := New(client)
    84  	if err != nil {
    85  		return nil, err
    86  	}
    87  	if endpoint != "" {
    88  		s.BasePath = endpoint
    89  	}
    90  	return s, nil
    91  }
    92  
    93  // New creates a new Service. It uses the provided http.Client for requests.
    94  //
    95  // Deprecated: please use NewService instead.
    96  // To provide a custom HTTP client, use option.WithHTTPClient.
    97  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
    98  func New(client *http.Client) (*Service, error) {
    99  	if client == nil {
   100  		return nil, errors.New("client is nil")
   101  	}
   102  	s := &Service{client: client, BasePath: basePath}
   103  	s.Projects = NewProjectsService(s)
   104  	return s, nil
   105  }
   106  
   107  type Service struct {
   108  	client    *http.Client
   109  	BasePath  string // API endpoint base URL
   110  	UserAgent string // optional additional User-Agent fragment
   111  
   112  	Projects *ProjectsService
   113  }
   114  
   115  func (s *Service) userAgent() string {
   116  	if s.UserAgent == "" {
   117  		return googleapi.UserAgent
   118  	}
   119  	return googleapi.UserAgent + " " + s.UserAgent
   120  }
   121  
   122  func NewProjectsService(s *Service) *ProjectsService {
   123  	rs := &ProjectsService{s: s}
   124  	return rs
   125  }
   126  
   127  type ProjectsService struct {
   128  	s *Service
   129  }
   130  
   131  // RemoteConfig: *
   132  // The RemoteConfig consists of a list of conditions (which can
   133  // be
   134  // thought of as named "if" statements) and a map of parameters
   135  // (parameter key
   136  // to a structure containing an optional default value, as well as a
   137  // optional
   138  // submap of (condition name to value when that condition is true).
   139  type RemoteConfig struct {
   140  	// Conditions: The list of named conditions. The order *does* affect the
   141  	// semantics.
   142  	// The condition_name values of these entries must be unique.
   143  	//
   144  	// The resolved value of a config parameter P is determined as follow:
   145  	// * Let Y be the set of values from the submap of P that refer to
   146  	// conditions
   147  	//   that evaluate to <code>true</code>.
   148  	// * If Y is non empty, the value is taken from the specific submap in Y
   149  	// whose
   150  	//   condition_name is the earliest in this condition list.
   151  	// * Else, if P has a default value option (condition_name is empty)
   152  	// then
   153  	//   the value is taken from that option.
   154  	// * Else, parameter P has no value and is omitted from the config
   155  	// result.
   156  	//
   157  	// Example: parameter key "p1", default value "v1", submap specified
   158  	// as
   159  	// {"c1": v2, "c2": v3} where "c1" and "c2" are names of conditions in
   160  	// the
   161  	// condition list (where "c1" in this example appears before "c2").
   162  	// The
   163  	// value of p1 would be v2 as long as c1 is true.  Otherwise, if c2 is
   164  	// true,
   165  	// p1 would evaluate to v3, and if c1 and c2 are both false, p1 would
   166  	// evaluate
   167  	// to v1.  If no default value was specified, and c1 and c2 were both
   168  	// false,
   169  	// no value for p1 would be generated.
   170  	Conditions []*RemoteConfigCondition `json:"conditions,omitempty"`
   171  
   172  	// Parameters: Map of parameter keys to their optional default values
   173  	// and optional submap
   174  	// of (condition name : value). Order doesn't affect semantics, and so
   175  	// is
   176  	// sorted by the server. The 'key' values of the params must be unique.
   177  	Parameters map[string]RemoteConfigParameter `json:"parameters,omitempty"`
   178  
   179  	// ServerResponse contains the HTTP response code and headers from the
   180  	// server.
   181  	googleapi.ServerResponse `json:"-"`
   182  
   183  	// ForceSendFields is a list of field names (e.g. "Conditions") to
   184  	// unconditionally include in API requests. By default, fields with
   185  	// empty values are omitted from API requests. However, any non-pointer,
   186  	// non-interface field appearing in ForceSendFields will be sent to the
   187  	// server regardless of whether the field is empty or not. This may be
   188  	// used to include empty fields in Patch requests.
   189  	ForceSendFields []string `json:"-"`
   190  
   191  	// NullFields is a list of field names (e.g. "Conditions") to include in
   192  	// API requests with the JSON null value. By default, fields with empty
   193  	// values are omitted from API requests. However, any field with an
   194  	// empty value appearing in NullFields will be sent to the server as
   195  	// null. It is an error if a field in this list has a non-empty value.
   196  	// This may be used to include null fields in Patch requests.
   197  	NullFields []string `json:"-"`
   198  }
   199  
   200  func (s *RemoteConfig) MarshalJSON() ([]byte, error) {
   201  	type NoMethod RemoteConfig
   202  	raw := NoMethod(*s)
   203  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   204  }
   205  
   206  // RemoteConfigCondition: A single RemoteConfig Condition.  A list of
   207  // these (because order matters) are
   208  // part of a single RemoteConfig template.
   209  type RemoteConfigCondition struct {
   210  	// Description: DO NOT USE. Implementation removed and will not be added
   211  	// unless requested.
   212  	// A description for this Condition. Length must be less than or equal
   213  	// to
   214  	// 100 characters (or more precisely, unicode code points, which is
   215  	// defined
   216  	// in
   217  	// java/com/google/wireless/android/config/ConstsExporter.java).
   218  	// A description may contain any Unicode characters
   219  	Description string `json:"description,omitempty"`
   220  
   221  	// Expression: Required.
   222  	Expression string `json:"expression,omitempty"`
   223  
   224  	// Name: Required.
   225  	// A non empty and unique name of this condition.
   226  	Name string `json:"name,omitempty"`
   227  
   228  	// TagColor: Optional.
   229  	// The display (tag) color of this condition. This serves as part of a
   230  	// tag
   231  	// (in the future, we may add tag text as well as tag color, but that is
   232  	// not
   233  	// yet implemented in the UI).
   234  	// This value has no affect on the semantics of the delivered config and
   235  	// it
   236  	// is ignored by the backend, except for passing it through
   237  	// write/read
   238  	// requests.
   239  	// Not having this value or having the
   240  	// "CONDITION_DISPLAY_COLOR_UNSPECIFIED"
   241  	// value (0) have the same meaning:  Let the UI choose any valid color
   242  	// when
   243  	// displaying the condition.
   244  	//
   245  	// Possible values:
   246  	//   "CONDITION_DISPLAY_COLOR_UNSPECIFIED"
   247  	//   "BLUE" - Blue
   248  	//   "BROWN" - Brown
   249  	//   "CYAN" - Cyan
   250  	//   "DEEP_ORANGE" - aka "Red Orange"
   251  	//   "GREEN" - Green
   252  	//   "INDIGO" - Indigo
   253  	// *
   254  	//   "LIME" - Lime - Approved deviation from Material color palette
   255  	//   "ORANGE" - Orange
   256  	//   "PINK" - Pink
   257  	//   "PURPLE" - Purple
   258  	//   "TEAL" - Teal
   259  	TagColor string `json:"tagColor,omitempty"`
   260  
   261  	// ForceSendFields is a list of field names (e.g. "Description") to
   262  	// unconditionally include in API requests. By default, fields with
   263  	// empty values are omitted from API requests. However, any non-pointer,
   264  	// non-interface field appearing in ForceSendFields will be sent to the
   265  	// server regardless of whether the field is empty or not. This may be
   266  	// used to include empty fields in Patch requests.
   267  	ForceSendFields []string `json:"-"`
   268  
   269  	// NullFields is a list of field names (e.g. "Description") to include
   270  	// in API requests with the JSON null value. By default, fields with
   271  	// empty values are omitted from API requests. However, any field with
   272  	// an empty value appearing in NullFields will be sent to the server as
   273  	// null. It is an error if a field in this list has a non-empty value.
   274  	// This may be used to include null fields in Patch requests.
   275  	NullFields []string `json:"-"`
   276  }
   277  
   278  func (s *RemoteConfigCondition) MarshalJSON() ([]byte, error) {
   279  	type NoMethod RemoteConfigCondition
   280  	raw := NoMethod(*s)
   281  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   282  }
   283  
   284  // RemoteConfigParameter: While default_value and conditional_values are
   285  // each optional, at least one of
   286  // the two is required - otherwise, the parameter is meaningless (and
   287  // an
   288  // exception will be thrown by the validation logic).
   289  type RemoteConfigParameter struct {
   290  	// ConditionalValues: Optional - a map of (condition_name, value). The
   291  	// condition_name of the
   292  	// highest priority (the one listed first in the conditions array)
   293  	// determines
   294  	// the value of this parameter.
   295  	ConditionalValues map[string]RemoteConfigParameterValue `json:"conditionalValues,omitempty"`
   296  
   297  	// DefaultValue: Optional - value to set the parameter to, when none of
   298  	// the named conditions
   299  	// evaluate to <code>true</code>.
   300  	DefaultValue *RemoteConfigParameterValue `json:"defaultValue,omitempty"`
   301  
   302  	// Description: Optional.
   303  	// A description for this Parameter. Length must be less than or equal
   304  	// to
   305  	// 100 characters (or more precisely, unicode code points, which is
   306  	// defined
   307  	// in
   308  	// java/com/google/wireless/android/config/ConstsExporter.java).
   309  	// A description may contain any Unicode characters
   310  	Description string `json:"description,omitempty"`
   311  
   312  	// ForceSendFields is a list of field names (e.g. "ConditionalValues")
   313  	// to unconditionally include in API requests. By default, fields with
   314  	// empty values are omitted from API requests. However, any non-pointer,
   315  	// non-interface field appearing in ForceSendFields will be sent to the
   316  	// server regardless of whether the field is empty or not. This may be
   317  	// used to include empty fields in Patch requests.
   318  	ForceSendFields []string `json:"-"`
   319  
   320  	// NullFields is a list of field names (e.g. "ConditionalValues") to
   321  	// include in API requests with the JSON null value. By default, fields
   322  	// with empty values are omitted from API requests. However, any field
   323  	// with an empty value appearing in NullFields will be sent to the
   324  	// server as null. It is an error if a field in this list has a
   325  	// non-empty value. This may be used to include null fields in Patch
   326  	// requests.
   327  	NullFields []string `json:"-"`
   328  }
   329  
   330  func (s *RemoteConfigParameter) MarshalJSON() ([]byte, error) {
   331  	type NoMethod RemoteConfigParameter
   332  	raw := NoMethod(*s)
   333  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   334  }
   335  
   336  // RemoteConfigParameterValue: A RemoteConfigParameter's "value" (either
   337  // the default value, or the value
   338  // associated with a condition name) is either a string, or
   339  // the
   340  // "use_in_app_default" indicator (which means to leave out the
   341  // parameter from
   342  // the returned <key, value> map that is the output of the parameter
   343  // fetch).
   344  // We represent the "use_in_app_default" as a bool, but (when using the
   345  // boolean
   346  // instead of the string) it should always be <code>true</code>.
   347  type RemoteConfigParameterValue struct {
   348  	// UseInAppDefault: if true, omit the parameter from the map of fetched
   349  	// parameter values
   350  	UseInAppDefault bool `json:"useInAppDefault,omitempty"`
   351  
   352  	// Value: the string to set the parameter to
   353  	Value string `json:"value,omitempty"`
   354  
   355  	// ForceSendFields is a list of field names (e.g. "UseInAppDefault") to
   356  	// unconditionally include in API requests. By default, fields with
   357  	// empty values are omitted from API requests. However, any non-pointer,
   358  	// non-interface field appearing in ForceSendFields will be sent to the
   359  	// server regardless of whether the field is empty or not. This may be
   360  	// used to include empty fields in Patch requests.
   361  	ForceSendFields []string `json:"-"`
   362  
   363  	// NullFields is a list of field names (e.g. "UseInAppDefault") to
   364  	// include in API requests with the JSON null value. By default, fields
   365  	// with empty values are omitted from API requests. However, any field
   366  	// with an empty value appearing in NullFields will be sent to the
   367  	// server as null. It is an error if a field in this list has a
   368  	// non-empty value. This may be used to include null fields in Patch
   369  	// requests.
   370  	NullFields []string `json:"-"`
   371  }
   372  
   373  func (s *RemoteConfigParameterValue) MarshalJSON() ([]byte, error) {
   374  	type NoMethod RemoteConfigParameterValue
   375  	raw := NoMethod(*s)
   376  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   377  }
   378  
   379  // method id "firebaseremoteconfig.projects.getRemoteConfig":
   380  
   381  type ProjectsGetRemoteConfigCall struct {
   382  	s            *Service
   383  	projectid    string
   384  	urlParams_   gensupport.URLParams
   385  	ifNoneMatch_ string
   386  	ctx_         context.Context
   387  	header_      http.Header
   388  }
   389  
   390  // GetRemoteConfig: Get the latest version Remote Configuration for a
   391  // project.
   392  // Returns the RemoteConfig as the payload, and also the eTag as
   393  // a
   394  // response header.
   395  func (r *ProjectsService) GetRemoteConfig(projectid string) *ProjectsGetRemoteConfigCall {
   396  	c := &ProjectsGetRemoteConfigCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   397  	c.projectid = projectid
   398  	return c
   399  }
   400  
   401  // Fields allows partial responses to be retrieved. See
   402  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   403  // for more information.
   404  func (c *ProjectsGetRemoteConfigCall) Fields(s ...googleapi.Field) *ProjectsGetRemoteConfigCall {
   405  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   406  	return c
   407  }
   408  
   409  // IfNoneMatch sets the optional parameter which makes the operation
   410  // fail if the object's ETag matches the given value. This is useful for
   411  // getting updates only after the object has changed since the last
   412  // request. Use googleapi.IsNotModified to check whether the response
   413  // error from Do is the result of In-None-Match.
   414  func (c *ProjectsGetRemoteConfigCall) IfNoneMatch(entityTag string) *ProjectsGetRemoteConfigCall {
   415  	c.ifNoneMatch_ = entityTag
   416  	return c
   417  }
   418  
   419  // Context sets the context to be used in this call's Do method. Any
   420  // pending HTTP request will be aborted if the provided context is
   421  // canceled.
   422  func (c *ProjectsGetRemoteConfigCall) Context(ctx context.Context) *ProjectsGetRemoteConfigCall {
   423  	c.ctx_ = ctx
   424  	return c
   425  }
   426  
   427  // Header returns an http.Header that can be modified by the caller to
   428  // add HTTP headers to the request.
   429  func (c *ProjectsGetRemoteConfigCall) Header() http.Header {
   430  	if c.header_ == nil {
   431  		c.header_ = make(http.Header)
   432  	}
   433  	return c.header_
   434  }
   435  
   436  func (c *ProjectsGetRemoteConfigCall) doRequest(alt string) (*http.Response, error) {
   437  	reqHeaders := make(http.Header)
   438  	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
   439  	for k, v := range c.header_ {
   440  		reqHeaders[k] = v
   441  	}
   442  	reqHeaders.Set("User-Agent", c.s.userAgent())
   443  	if c.ifNoneMatch_ != "" {
   444  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   445  	}
   446  	var body io.Reader = nil
   447  	c.urlParams_.Set("alt", alt)
   448  	c.urlParams_.Set("prettyPrint", "false")
   449  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+project}/remoteConfig")
   450  	urls += "?" + c.urlParams_.Encode()
   451  	req, err := http.NewRequest("GET", urls, body)
   452  	if err != nil {
   453  		return nil, err
   454  	}
   455  	req.Header = reqHeaders
   456  	googleapi.Expand(req.URL, map[string]string{
   457  		"project": c.projectid,
   458  	})
   459  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   460  }
   461  
   462  // Do executes the "firebaseremoteconfig.projects.getRemoteConfig" call.
   463  // Exactly one of *RemoteConfig or error will be non-nil. Any non-2xx
   464  // status code is an error. Response headers are in either
   465  // *RemoteConfig.ServerResponse.Header or (if a response was returned at
   466  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
   467  // to check whether the returned error was because
   468  // http.StatusNotModified was returned.
   469  func (c *ProjectsGetRemoteConfigCall) Do(opts ...googleapi.CallOption) (*RemoteConfig, error) {
   470  	gensupport.SetOptions(c.urlParams_, opts...)
   471  	res, err := c.doRequest("json")
   472  	if res != nil && res.StatusCode == http.StatusNotModified {
   473  		if res.Body != nil {
   474  			res.Body.Close()
   475  		}
   476  		return nil, &googleapi.Error{
   477  			Code:   res.StatusCode,
   478  			Header: res.Header,
   479  		}
   480  	}
   481  	if err != nil {
   482  		return nil, err
   483  	}
   484  	defer googleapi.CloseBody(res)
   485  	if err := googleapi.CheckResponse(res); err != nil {
   486  		return nil, err
   487  	}
   488  	ret := &RemoteConfig{
   489  		ServerResponse: googleapi.ServerResponse{
   490  			Header:         res.Header,
   491  			HTTPStatusCode: res.StatusCode,
   492  		},
   493  	}
   494  	target := &ret
   495  	if err := gensupport.DecodeResponse(target, res); err != nil {
   496  		return nil, err
   497  	}
   498  	return ret, nil
   499  	// {
   500  	//   "description": "Get the latest version Remote Configuration for a project.\nReturns the RemoteConfig as the payload, and also the eTag as a\nresponse header.",
   501  	//   "flatPath": "v1/projects/{projectsId}/remoteConfig",
   502  	//   "httpMethod": "GET",
   503  	//   "id": "firebaseremoteconfig.projects.getRemoteConfig",
   504  	//   "parameterOrder": [
   505  	//     "project"
   506  	//   ],
   507  	//   "parameters": {
   508  	//     "project": {
   509  	//       "description": "The GMP project identifier. Required.\nSee note at the beginning of this file regarding project ids.",
   510  	//       "location": "path",
   511  	//       "pattern": "^projects/[^/]+$",
   512  	//       "required": true,
   513  	//       "type": "string"
   514  	//     }
   515  	//   },
   516  	//   "path": "v1/{+project}/remoteConfig",
   517  	//   "response": {
   518  	//     "$ref": "RemoteConfig"
   519  	//   }
   520  	// }
   521  
   522  }
   523  
   524  // method id "firebaseremoteconfig.projects.updateRemoteConfig":
   525  
   526  type ProjectsUpdateRemoteConfigCall struct {
   527  	s            *Service
   528  	projectid    string
   529  	remoteconfig *RemoteConfig
   530  	urlParams_   gensupport.URLParams
   531  	ctx_         context.Context
   532  	header_      http.Header
   533  }
   534  
   535  // UpdateRemoteConfig: Update a RemoteConfig. We treat this as an
   536  // always-existing
   537  // resource (when it is not found in our data store, we treat it as
   538  // version
   539  // 0, a template with zero conditions and zero parameters). Hence there
   540  // are
   541  // no Create or Delete operations. Returns the updated template
   542  // when
   543  // successful (and the updated eTag as a response header), or an error
   544  // if
   545  // things go wrong.
   546  // Possible error messages:
   547  // * VALIDATION_ERROR (HTTP status 400) with additional details if
   548  // the
   549  // template being passed in can not be validated.
   550  // * AUTHENTICATION_ERROR (HTTP status 401) if the request can not
   551  // be
   552  // authenticate (e.g. no access token, or invalid access token).
   553  // * AUTHORIZATION_ERROR (HTTP status 403) if the request can not
   554  // be
   555  // authorized (e.g. the user has no access to the specified project
   556  // id).
   557  // * VERSION_MISMATCH (HTTP status 412) when trying to update when
   558  // the
   559  // expected eTag (passed in via the "If-match" header) is not specified,
   560  // or
   561  // is specified but does does not match the current eTag.
   562  // * Internal error (HTTP status 500) for Database problems or other
   563  // internal
   564  // errors.
   565  func (r *ProjectsService) UpdateRemoteConfig(projectid string, remoteconfig *RemoteConfig) *ProjectsUpdateRemoteConfigCall {
   566  	c := &ProjectsUpdateRemoteConfigCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   567  	c.projectid = projectid
   568  	c.remoteconfig = remoteconfig
   569  	return c
   570  }
   571  
   572  // ValidateOnly sets the optional parameter "validateOnly": Defaults to
   573  // <code>false</code> (UpdateRemoteConfig call should
   574  // update the backend if there are no validation/interal errors). May be
   575  // set
   576  // to <code>true</code> to indicate that, should no validation errors
   577  // occur,
   578  // the call should return a "200 OK" instead of performing the update.
   579  // Note
   580  // that other error messages (500 Internal Error, 412 Version Mismatch,
   581  // etc)
   582  // may still result after flipping to <code>false</code>, even if
   583  // getting a
   584  // "200 OK" when calling with <code>true</code>.
   585  func (c *ProjectsUpdateRemoteConfigCall) ValidateOnly(validateOnly bool) *ProjectsUpdateRemoteConfigCall {
   586  	c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly))
   587  	return c
   588  }
   589  
   590  // Fields allows partial responses to be retrieved. See
   591  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   592  // for more information.
   593  func (c *ProjectsUpdateRemoteConfigCall) Fields(s ...googleapi.Field) *ProjectsUpdateRemoteConfigCall {
   594  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   595  	return c
   596  }
   597  
   598  // Context sets the context to be used in this call's Do method. Any
   599  // pending HTTP request will be aborted if the provided context is
   600  // canceled.
   601  func (c *ProjectsUpdateRemoteConfigCall) Context(ctx context.Context) *ProjectsUpdateRemoteConfigCall {
   602  	c.ctx_ = ctx
   603  	return c
   604  }
   605  
   606  // Header returns an http.Header that can be modified by the caller to
   607  // add HTTP headers to the request.
   608  func (c *ProjectsUpdateRemoteConfigCall) Header() http.Header {
   609  	if c.header_ == nil {
   610  		c.header_ = make(http.Header)
   611  	}
   612  	return c.header_
   613  }
   614  
   615  func (c *ProjectsUpdateRemoteConfigCall) doRequest(alt string) (*http.Response, error) {
   616  	reqHeaders := make(http.Header)
   617  	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
   618  	for k, v := range c.header_ {
   619  		reqHeaders[k] = v
   620  	}
   621  	reqHeaders.Set("User-Agent", c.s.userAgent())
   622  	var body io.Reader = nil
   623  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.remoteconfig)
   624  	if err != nil {
   625  		return nil, err
   626  	}
   627  	reqHeaders.Set("Content-Type", "application/json")
   628  	c.urlParams_.Set("alt", alt)
   629  	c.urlParams_.Set("prettyPrint", "false")
   630  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+project}/remoteConfig")
   631  	urls += "?" + c.urlParams_.Encode()
   632  	req, err := http.NewRequest("PUT", urls, body)
   633  	if err != nil {
   634  		return nil, err
   635  	}
   636  	req.Header = reqHeaders
   637  	googleapi.Expand(req.URL, map[string]string{
   638  		"project": c.projectid,
   639  	})
   640  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   641  }
   642  
   643  // Do executes the "firebaseremoteconfig.projects.updateRemoteConfig" call.
   644  // Exactly one of *RemoteConfig or error will be non-nil. Any non-2xx
   645  // status code is an error. Response headers are in either
   646  // *RemoteConfig.ServerResponse.Header or (if a response was returned at
   647  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
   648  // to check whether the returned error was because
   649  // http.StatusNotModified was returned.
   650  func (c *ProjectsUpdateRemoteConfigCall) Do(opts ...googleapi.CallOption) (*RemoteConfig, error) {
   651  	gensupport.SetOptions(c.urlParams_, opts...)
   652  	res, err := c.doRequest("json")
   653  	if res != nil && res.StatusCode == http.StatusNotModified {
   654  		if res.Body != nil {
   655  			res.Body.Close()
   656  		}
   657  		return nil, &googleapi.Error{
   658  			Code:   res.StatusCode,
   659  			Header: res.Header,
   660  		}
   661  	}
   662  	if err != nil {
   663  		return nil, err
   664  	}
   665  	defer googleapi.CloseBody(res)
   666  	if err := googleapi.CheckResponse(res); err != nil {
   667  		return nil, err
   668  	}
   669  	ret := &RemoteConfig{
   670  		ServerResponse: googleapi.ServerResponse{
   671  			Header:         res.Header,
   672  			HTTPStatusCode: res.StatusCode,
   673  		},
   674  	}
   675  	target := &ret
   676  	if err := gensupport.DecodeResponse(target, res); err != nil {
   677  		return nil, err
   678  	}
   679  	return ret, nil
   680  	// {
   681  	//   "description": "Update a RemoteConfig. We treat this as an always-existing\nresource (when it is not found in our data store, we treat it as version\n0, a template with zero conditions and zero parameters). Hence there are\nno Create or Delete operations. Returns the updated template when\nsuccessful (and the updated eTag as a response header), or an error if\nthings go wrong.\nPossible error messages:\n* VALIDATION_ERROR (HTTP status 400) with additional details if the\ntemplate being passed in can not be validated.\n* AUTHENTICATION_ERROR (HTTP status 401) if the request can not be\nauthenticate (e.g. no access token, or invalid access token).\n* AUTHORIZATION_ERROR (HTTP status 403) if the request can not be\nauthorized (e.g. the user has no access to the specified project id).\n* VERSION_MISMATCH (HTTP status 412) when trying to update when the\nexpected eTag (passed in via the \"If-match\" header) is not specified, or\nis specified but does does not match the current eTag.\n* Internal error (HTTP status 500) for Database problems or other internal\nerrors.",
   682  	//   "flatPath": "v1/projects/{projectsId}/remoteConfig",
   683  	//   "httpMethod": "PUT",
   684  	//   "id": "firebaseremoteconfig.projects.updateRemoteConfig",
   685  	//   "parameterOrder": [
   686  	//     "project"
   687  	//   ],
   688  	//   "parameters": {
   689  	//     "project": {
   690  	//       "description": "The GMP project identifier. Required.\nSee note at the beginning of this file regarding project ids.",
   691  	//       "location": "path",
   692  	//       "pattern": "^projects/[^/]+$",
   693  	//       "required": true,
   694  	//       "type": "string"
   695  	//     },
   696  	//     "validateOnly": {
   697  	//       "description": "Optional. Defaults to \u003ccode\u003efalse\u003c/code\u003e (UpdateRemoteConfig call should\nupdate the backend if there are no validation/interal errors). May be set\nto \u003ccode\u003etrue\u003c/code\u003e to indicate that, should no validation errors occur,\nthe call should return a \"200 OK\" instead of performing the update. Note\nthat other error messages (500 Internal Error, 412 Version Mismatch, etc)\nmay still result after flipping to \u003ccode\u003efalse\u003c/code\u003e, even if getting a\n\"200 OK\" when calling with \u003ccode\u003etrue\u003c/code\u003e.",
   698  	//       "location": "query",
   699  	//       "type": "boolean"
   700  	//     }
   701  	//   },
   702  	//   "path": "v1/{+project}/remoteConfig",
   703  	//   "request": {
   704  	//     "$ref": "RemoteConfig"
   705  	//   },
   706  	//   "response": {
   707  	//     "$ref": "RemoteConfig"
   708  	//   }
   709  	// }
   710  
   711  }
   712  

View as plain text