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 appstate provides access to the Google App State API.
8//
9// For product documentation, see: https://developers.google.com/games/services/web/api/states
10//
11// Creating a client
12//
13// Usage example:
14//
15//   import "google.golang.org/api/appstate/v1"
16//   ...
17//   ctx := context.Background()
18//   appstateService, err := appstate.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//   appstateService, err := appstate.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//   appstateService, err := appstate.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
36//
37// See https://godoc.org/google.golang.org/api/option/ for details on options.
38package appstate // import "google.golang.org/api/appstate/v1"
39
40import (
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.
60var _ = bytes.NewBuffer
61var _ = strconv.Itoa
62var _ = fmt.Sprintf
63var _ = json.NewDecoder
64var _ = io.Copy
65var _ = url.Parse
66var _ = gensupport.MarshalJSON
67var _ = googleapi.Version
68var _ = errors.New
69var _ = strings.Replace
70var _ = context.Canceled
71
72const apiId = "appstate:v1"
73const apiName = "appstate"
74const apiVersion = "v1"
75const basePath = "https://www.googleapis.com/appstate/v1/"
76
77// OAuth2 scopes used by this API.
78const (
79	// View and manage your data for this application
80	AppstateScope = "https://www.googleapis.com/auth/appstate"
81)
82
83// NewService creates a new Service.
84func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
85	scopesOption := option.WithScopes(
86		"https://www.googleapis.com/auth/appstate",
87	)
88	// NOTE: prepend, so we don't override user-specified scopes.
89	opts = append([]option.ClientOption{scopesOption}, opts...)
90	client, endpoint, err := htransport.NewClient(ctx, opts...)
91	if err != nil {
92		return nil, err
93	}
94	s, err := New(client)
95	if err != nil {
96		return nil, err
97	}
98	if endpoint != "" {
99		s.BasePath = endpoint
100	}
101	return s, nil
102}
103
104// New creates a new Service. It uses the provided http.Client for requests.
105//
106// Deprecated: please use NewService instead.
107// To provide a custom HTTP client, use option.WithHTTPClient.
108// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
109func New(client *http.Client) (*Service, error) {
110	if client == nil {
111		return nil, errors.New("client is nil")
112	}
113	s := &Service{client: client, BasePath: basePath}
114	s.States = NewStatesService(s)
115	return s, nil
116}
117
118type Service struct {
119	client    *http.Client
120	BasePath  string // API endpoint base URL
121	UserAgent string // optional additional User-Agent fragment
122
123	States *StatesService
124}
125
126func (s *Service) userAgent() string {
127	if s.UserAgent == "" {
128		return googleapi.UserAgent
129	}
130	return googleapi.UserAgent + " " + s.UserAgent
131}
132
133func NewStatesService(s *Service) *StatesService {
134	rs := &StatesService{s: s}
135	return rs
136}
137
138type StatesService struct {
139	s *Service
140}
141
142// GetResponse: This is a JSON template for an app state resource.
143type GetResponse struct {
144	// CurrentStateVersion: The current app state version.
145	CurrentStateVersion string `json:"currentStateVersion,omitempty"`
146
147	// Data: The requested data.
148	Data string `json:"data,omitempty"`
149
150	// Kind: Uniquely identifies the type of this resource. Value is always
151	// the fixed string appstate#getResponse.
152	Kind string `json:"kind,omitempty"`
153
154	// StateKey: The key for the data.
155	StateKey int64 `json:"stateKey,omitempty"`
156
157	// ServerResponse contains the HTTP response code and headers from the
158	// server.
159	googleapi.ServerResponse `json:"-"`
160
161	// ForceSendFields is a list of field names (e.g. "CurrentStateVersion")
162	// to unconditionally include in API requests. By default, fields with
163	// empty values are omitted from API requests. However, any non-pointer,
164	// non-interface field appearing in ForceSendFields will be sent to the
165	// server regardless of whether the field is empty or not. This may be
166	// used to include empty fields in Patch requests.
167	ForceSendFields []string `json:"-"`
168
169	// NullFields is a list of field names (e.g. "CurrentStateVersion") to
170	// include in API requests with the JSON null value. By default, fields
171	// with empty values are omitted from API requests. However, any field
172	// with an empty value appearing in NullFields will be sent to the
173	// server as null. It is an error if a field in this list has a
174	// non-empty value. This may be used to include null fields in Patch
175	// requests.
176	NullFields []string `json:"-"`
177}
178
179func (s *GetResponse) MarshalJSON() ([]byte, error) {
180	type NoMethod GetResponse
181	raw := NoMethod(*s)
182	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
183}
184
185// ListResponse: This is a JSON template to convert a list-response for
186// app state.
187type ListResponse struct {
188	// Items: The app state data.
189	Items []*GetResponse `json:"items,omitempty"`
190
191	// Kind: Uniquely identifies the type of this resource. Value is always
192	// the fixed string appstate#listResponse.
193	Kind string `json:"kind,omitempty"`
194
195	// MaximumKeyCount: The maximum number of keys allowed for this user.
196	MaximumKeyCount int64 `json:"maximumKeyCount,omitempty"`
197
198	// ServerResponse contains the HTTP response code and headers from the
199	// server.
200	googleapi.ServerResponse `json:"-"`
201
202	// ForceSendFields is a list of field names (e.g. "Items") to
203	// unconditionally include in API requests. By default, fields with
204	// empty values are omitted from API requests. However, any non-pointer,
205	// non-interface field appearing in ForceSendFields will be sent to the
206	// server regardless of whether the field is empty or not. This may be
207	// used to include empty fields in Patch requests.
208	ForceSendFields []string `json:"-"`
209
210	// NullFields is a list of field names (e.g. "Items") to include in API
211	// requests with the JSON null value. By default, fields with empty
212	// values are omitted from API requests. However, any field with an
213	// empty value appearing in NullFields will be sent to the server as
214	// null. It is an error if a field in this list has a non-empty value.
215	// This may be used to include null fields in Patch requests.
216	NullFields []string `json:"-"`
217}
218
219func (s *ListResponse) MarshalJSON() ([]byte, error) {
220	type NoMethod ListResponse
221	raw := NoMethod(*s)
222	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
223}
224
225// UpdateRequest: This is a JSON template for a requests which update
226// app state
227type UpdateRequest struct {
228	// Data: The new app state data that your application is trying to
229	// update with.
230	Data string `json:"data,omitempty"`
231
232	// Kind: Uniquely identifies the type of this resource. Value is always
233	// the fixed string appstate#updateRequest.
234	Kind string `json:"kind,omitempty"`
235
236	// ForceSendFields is a list of field names (e.g. "Data") to
237	// unconditionally include in API requests. By default, fields with
238	// empty values are omitted from API requests. However, any non-pointer,
239	// non-interface field appearing in ForceSendFields will be sent to the
240	// server regardless of whether the field is empty or not. This may be
241	// used to include empty fields in Patch requests.
242	ForceSendFields []string `json:"-"`
243
244	// NullFields is a list of field names (e.g. "Data") to include in API
245	// requests with the JSON null value. By default, fields with empty
246	// values are omitted from API requests. However, any field with an
247	// empty value appearing in NullFields will be sent to the server as
248	// null. It is an error if a field in this list has a non-empty value.
249	// This may be used to include null fields in Patch requests.
250	NullFields []string `json:"-"`
251}
252
253func (s *UpdateRequest) MarshalJSON() ([]byte, error) {
254	type NoMethod UpdateRequest
255	raw := NoMethod(*s)
256	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
257}
258
259// WriteResult: This is a JSON template for an app state write result.
260type WriteResult struct {
261	// CurrentStateVersion: The version of the data for this key on the
262	// server.
263	CurrentStateVersion string `json:"currentStateVersion,omitempty"`
264
265	// Kind: Uniquely identifies the type of this resource. Value is always
266	// the fixed string appstate#writeResult.
267	Kind string `json:"kind,omitempty"`
268
269	// StateKey: The written key.
270	StateKey int64 `json:"stateKey,omitempty"`
271
272	// ServerResponse contains the HTTP response code and headers from the
273	// server.
274	googleapi.ServerResponse `json:"-"`
275
276	// ForceSendFields is a list of field names (e.g. "CurrentStateVersion")
277	// to unconditionally include in API requests. By default, fields with
278	// empty values are omitted from API requests. However, any non-pointer,
279	// non-interface field appearing in ForceSendFields will be sent to the
280	// server regardless of whether the field is empty or not. This may be
281	// used to include empty fields in Patch requests.
282	ForceSendFields []string `json:"-"`
283
284	// NullFields is a list of field names (e.g. "CurrentStateVersion") to
285	// include in API requests with the JSON null value. By default, fields
286	// with empty values are omitted from API requests. However, any field
287	// with an empty value appearing in NullFields will be sent to the
288	// server as null. It is an error if a field in this list has a
289	// non-empty value. This may be used to include null fields in Patch
290	// requests.
291	NullFields []string `json:"-"`
292}
293
294func (s *WriteResult) MarshalJSON() ([]byte, error) {
295	type NoMethod WriteResult
296	raw := NoMethod(*s)
297	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
298}
299
300// method id "appstate.states.clear":
301
302type StatesClearCall struct {
303	s          *Service
304	stateKey   int64
305	urlParams_ gensupport.URLParams
306	ctx_       context.Context
307	header_    http.Header
308}
309
310// Clear: Clears (sets to empty) the data for the passed key if and only
311// if the passed version matches the currently stored version. This
312// method results in a conflict error on version mismatch.
313func (r *StatesService) Clear(stateKey int64) *StatesClearCall {
314	c := &StatesClearCall{s: r.s, urlParams_: make(gensupport.URLParams)}
315	c.stateKey = stateKey
316	return c
317}
318
319// CurrentDataVersion sets the optional parameter "currentDataVersion":
320// The version of the data to be cleared. Version strings are returned
321// by the server.
322func (c *StatesClearCall) CurrentDataVersion(currentDataVersion string) *StatesClearCall {
323	c.urlParams_.Set("currentDataVersion", currentDataVersion)
324	return c
325}
326
327// Fields allows partial responses to be retrieved. See
328// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
329// for more information.
330func (c *StatesClearCall) Fields(s ...googleapi.Field) *StatesClearCall {
331	c.urlParams_.Set("fields", googleapi.CombineFields(s))
332	return c
333}
334
335// Context sets the context to be used in this call's Do method. Any
336// pending HTTP request will be aborted if the provided context is
337// canceled.
338func (c *StatesClearCall) Context(ctx context.Context) *StatesClearCall {
339	c.ctx_ = ctx
340	return c
341}
342
343// Header returns an http.Header that can be modified by the caller to
344// add HTTP headers to the request.
345func (c *StatesClearCall) Header() http.Header {
346	if c.header_ == nil {
347		c.header_ = make(http.Header)
348	}
349	return c.header_
350}
351
352func (c *StatesClearCall) doRequest(alt string) (*http.Response, error) {
353	reqHeaders := make(http.Header)
354	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
355	for k, v := range c.header_ {
356		reqHeaders[k] = v
357	}
358	reqHeaders.Set("User-Agent", c.s.userAgent())
359	var body io.Reader = nil
360	c.urlParams_.Set("alt", alt)
361	c.urlParams_.Set("prettyPrint", "false")
362	urls := googleapi.ResolveRelative(c.s.BasePath, "states/{stateKey}/clear")
363	urls += "?" + c.urlParams_.Encode()
364	req, err := http.NewRequest("POST", urls, body)
365	if err != nil {
366		return nil, err
367	}
368	req.Header = reqHeaders
369	googleapi.Expand(req.URL, map[string]string{
370		"stateKey": strconv.FormatInt(c.stateKey, 10),
371	})
372	return gensupport.SendRequest(c.ctx_, c.s.client, req)
373}
374
375// Do executes the "appstate.states.clear" call.
376// Exactly one of *WriteResult or error will be non-nil. Any non-2xx
377// status code is an error. Response headers are in either
378// *WriteResult.ServerResponse.Header or (if a response was returned at
379// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
380// to check whether the returned error was because
381// http.StatusNotModified was returned.
382func (c *StatesClearCall) Do(opts ...googleapi.CallOption) (*WriteResult, error) {
383	gensupport.SetOptions(c.urlParams_, opts...)
384	res, err := c.doRequest("json")
385	if res != nil && res.StatusCode == http.StatusNotModified {
386		if res.Body != nil {
387			res.Body.Close()
388		}
389		return nil, &googleapi.Error{
390			Code:   res.StatusCode,
391			Header: res.Header,
392		}
393	}
394	if err != nil {
395		return nil, err
396	}
397	defer googleapi.CloseBody(res)
398	if err := googleapi.CheckResponse(res); err != nil {
399		return nil, err
400	}
401	ret := &WriteResult{
402		ServerResponse: googleapi.ServerResponse{
403			Header:         res.Header,
404			HTTPStatusCode: res.StatusCode,
405		},
406	}
407	target := &ret
408	if err := gensupport.DecodeResponse(target, res); err != nil {
409		return nil, err
410	}
411	return ret, nil
412	// {
413	//   "description": "Clears (sets to empty) the data for the passed key if and only if the passed version matches the currently stored version. This method results in a conflict error on version mismatch.",
414	//   "httpMethod": "POST",
415	//   "id": "appstate.states.clear",
416	//   "parameterOrder": [
417	//     "stateKey"
418	//   ],
419	//   "parameters": {
420	//     "currentDataVersion": {
421	//       "description": "The version of the data to be cleared. Version strings are returned by the server.",
422	//       "location": "query",
423	//       "type": "string"
424	//     },
425	//     "stateKey": {
426	//       "description": "The key for the data to be retrieved.",
427	//       "format": "int32",
428	//       "location": "path",
429	//       "maximum": "3",
430	//       "minimum": "0",
431	//       "required": true,
432	//       "type": "integer"
433	//     }
434	//   },
435	//   "path": "states/{stateKey}/clear",
436	//   "response": {
437	//     "$ref": "WriteResult"
438	//   },
439	//   "scopes": [
440	//     "https://www.googleapis.com/auth/appstate"
441	//   ]
442	// }
443
444}
445
446// method id "appstate.states.delete":
447
448type StatesDeleteCall struct {
449	s          *Service
450	stateKey   int64
451	urlParams_ gensupport.URLParams
452	ctx_       context.Context
453	header_    http.Header
454}
455
456// Delete: Deletes a key and the data associated with it. The key is
457// removed and no longer counts against the key quota. Note that since
458// this method is not safe in the face of concurrent modifications, it
459// should only be used for development and testing purposes. Invoking
460// this method in shipping code can result in data loss and data
461// corruption.
462func (r *StatesService) Delete(stateKey int64) *StatesDeleteCall {
463	c := &StatesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
464	c.stateKey = stateKey
465	return c
466}
467
468// Fields allows partial responses to be retrieved. See
469// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
470// for more information.
471func (c *StatesDeleteCall) Fields(s ...googleapi.Field) *StatesDeleteCall {
472	c.urlParams_.Set("fields", googleapi.CombineFields(s))
473	return c
474}
475
476// Context sets the context to be used in this call's Do method. Any
477// pending HTTP request will be aborted if the provided context is
478// canceled.
479func (c *StatesDeleteCall) Context(ctx context.Context) *StatesDeleteCall {
480	c.ctx_ = ctx
481	return c
482}
483
484// Header returns an http.Header that can be modified by the caller to
485// add HTTP headers to the request.
486func (c *StatesDeleteCall) Header() http.Header {
487	if c.header_ == nil {
488		c.header_ = make(http.Header)
489	}
490	return c.header_
491}
492
493func (c *StatesDeleteCall) doRequest(alt string) (*http.Response, error) {
494	reqHeaders := make(http.Header)
495	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
496	for k, v := range c.header_ {
497		reqHeaders[k] = v
498	}
499	reqHeaders.Set("User-Agent", c.s.userAgent())
500	var body io.Reader = nil
501	c.urlParams_.Set("alt", alt)
502	c.urlParams_.Set("prettyPrint", "false")
503	urls := googleapi.ResolveRelative(c.s.BasePath, "states/{stateKey}")
504	urls += "?" + c.urlParams_.Encode()
505	req, err := http.NewRequest("DELETE", urls, body)
506	if err != nil {
507		return nil, err
508	}
509	req.Header = reqHeaders
510	googleapi.Expand(req.URL, map[string]string{
511		"stateKey": strconv.FormatInt(c.stateKey, 10),
512	})
513	return gensupport.SendRequest(c.ctx_, c.s.client, req)
514}
515
516// Do executes the "appstate.states.delete" call.
517func (c *StatesDeleteCall) Do(opts ...googleapi.CallOption) error {
518	gensupport.SetOptions(c.urlParams_, opts...)
519	res, err := c.doRequest("json")
520	if err != nil {
521		return err
522	}
523	defer googleapi.CloseBody(res)
524	if err := googleapi.CheckResponse(res); err != nil {
525		return err
526	}
527	return nil
528	// {
529	//   "description": "Deletes a key and the data associated with it. The key is removed and no longer counts against the key quota. Note that since this method is not safe in the face of concurrent modifications, it should only be used for development and testing purposes. Invoking this method in shipping code can result in data loss and data corruption.",
530	//   "httpMethod": "DELETE",
531	//   "id": "appstate.states.delete",
532	//   "parameterOrder": [
533	//     "stateKey"
534	//   ],
535	//   "parameters": {
536	//     "stateKey": {
537	//       "description": "The key for the data to be retrieved.",
538	//       "format": "int32",
539	//       "location": "path",
540	//       "maximum": "3",
541	//       "minimum": "0",
542	//       "required": true,
543	//       "type": "integer"
544	//     }
545	//   },
546	//   "path": "states/{stateKey}",
547	//   "scopes": [
548	//     "https://www.googleapis.com/auth/appstate"
549	//   ]
550	// }
551
552}
553
554// method id "appstate.states.get":
555
556type StatesGetCall struct {
557	s            *Service
558	stateKey     int64
559	urlParams_   gensupport.URLParams
560	ifNoneMatch_ string
561	ctx_         context.Context
562	header_      http.Header
563}
564
565// Get: Retrieves the data corresponding to the passed key. If the key
566// does not exist on the server, an HTTP 404 will be returned.
567func (r *StatesService) Get(stateKey int64) *StatesGetCall {
568	c := &StatesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
569	c.stateKey = stateKey
570	return c
571}
572
573// Fields allows partial responses to be retrieved. See
574// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
575// for more information.
576func (c *StatesGetCall) Fields(s ...googleapi.Field) *StatesGetCall {
577	c.urlParams_.Set("fields", googleapi.CombineFields(s))
578	return c
579}
580
581// IfNoneMatch sets the optional parameter which makes the operation
582// fail if the object's ETag matches the given value. This is useful for
583// getting updates only after the object has changed since the last
584// request. Use googleapi.IsNotModified to check whether the response
585// error from Do is the result of In-None-Match.
586func (c *StatesGetCall) IfNoneMatch(entityTag string) *StatesGetCall {
587	c.ifNoneMatch_ = entityTag
588	return c
589}
590
591// Context sets the context to be used in this call's Do method. Any
592// pending HTTP request will be aborted if the provided context is
593// canceled.
594func (c *StatesGetCall) Context(ctx context.Context) *StatesGetCall {
595	c.ctx_ = ctx
596	return c
597}
598
599// Header returns an http.Header that can be modified by the caller to
600// add HTTP headers to the request.
601func (c *StatesGetCall) Header() http.Header {
602	if c.header_ == nil {
603		c.header_ = make(http.Header)
604	}
605	return c.header_
606}
607
608func (c *StatesGetCall) doRequest(alt string) (*http.Response, error) {
609	reqHeaders := make(http.Header)
610	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
611	for k, v := range c.header_ {
612		reqHeaders[k] = v
613	}
614	reqHeaders.Set("User-Agent", c.s.userAgent())
615	if c.ifNoneMatch_ != "" {
616		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
617	}
618	var body io.Reader = nil
619	c.urlParams_.Set("alt", alt)
620	c.urlParams_.Set("prettyPrint", "false")
621	urls := googleapi.ResolveRelative(c.s.BasePath, "states/{stateKey}")
622	urls += "?" + c.urlParams_.Encode()
623	req, err := http.NewRequest("GET", urls, body)
624	if err != nil {
625		return nil, err
626	}
627	req.Header = reqHeaders
628	googleapi.Expand(req.URL, map[string]string{
629		"stateKey": strconv.FormatInt(c.stateKey, 10),
630	})
631	return gensupport.SendRequest(c.ctx_, c.s.client, req)
632}
633
634// Do executes the "appstate.states.get" call.
635// Exactly one of *GetResponse or error will be non-nil. Any non-2xx
636// status code is an error. Response headers are in either
637// *GetResponse.ServerResponse.Header or (if a response was returned at
638// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
639// to check whether the returned error was because
640// http.StatusNotModified was returned.
641func (c *StatesGetCall) Do(opts ...googleapi.CallOption) (*GetResponse, error) {
642	gensupport.SetOptions(c.urlParams_, opts...)
643	res, err := c.doRequest("json")
644	if res != nil && res.StatusCode == http.StatusNotModified {
645		if res.Body != nil {
646			res.Body.Close()
647		}
648		return nil, &googleapi.Error{
649			Code:   res.StatusCode,
650			Header: res.Header,
651		}
652	}
653	if err != nil {
654		return nil, err
655	}
656	defer googleapi.CloseBody(res)
657	if err := googleapi.CheckResponse(res); err != nil {
658		return nil, err
659	}
660	ret := &GetResponse{
661		ServerResponse: googleapi.ServerResponse{
662			Header:         res.Header,
663			HTTPStatusCode: res.StatusCode,
664		},
665	}
666	target := &ret
667	if err := gensupport.DecodeResponse(target, res); err != nil {
668		return nil, err
669	}
670	return ret, nil
671	// {
672	//   "description": "Retrieves the data corresponding to the passed key. If the key does not exist on the server, an HTTP 404 will be returned.",
673	//   "httpMethod": "GET",
674	//   "id": "appstate.states.get",
675	//   "parameterOrder": [
676	//     "stateKey"
677	//   ],
678	//   "parameters": {
679	//     "stateKey": {
680	//       "description": "The key for the data to be retrieved.",
681	//       "format": "int32",
682	//       "location": "path",
683	//       "maximum": "3",
684	//       "minimum": "0",
685	//       "required": true,
686	//       "type": "integer"
687	//     }
688	//   },
689	//   "path": "states/{stateKey}",
690	//   "response": {
691	//     "$ref": "GetResponse"
692	//   },
693	//   "scopes": [
694	//     "https://www.googleapis.com/auth/appstate"
695	//   ]
696	// }
697
698}
699
700// method id "appstate.states.list":
701
702type StatesListCall struct {
703	s            *Service
704	urlParams_   gensupport.URLParams
705	ifNoneMatch_ string
706	ctx_         context.Context
707	header_      http.Header
708}
709
710// List: Lists all the states keys, and optionally the state data.
711func (r *StatesService) List() *StatesListCall {
712	c := &StatesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
713	return c
714}
715
716// IncludeData sets the optional parameter "includeData": Whether to
717// include the full data in addition to the version number
718func (c *StatesListCall) IncludeData(includeData bool) *StatesListCall {
719	c.urlParams_.Set("includeData", fmt.Sprint(includeData))
720	return c
721}
722
723// Fields allows partial responses to be retrieved. See
724// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
725// for more information.
726func (c *StatesListCall) Fields(s ...googleapi.Field) *StatesListCall {
727	c.urlParams_.Set("fields", googleapi.CombineFields(s))
728	return c
729}
730
731// IfNoneMatch sets the optional parameter which makes the operation
732// fail if the object's ETag matches the given value. This is useful for
733// getting updates only after the object has changed since the last
734// request. Use googleapi.IsNotModified to check whether the response
735// error from Do is the result of In-None-Match.
736func (c *StatesListCall) IfNoneMatch(entityTag string) *StatesListCall {
737	c.ifNoneMatch_ = entityTag
738	return c
739}
740
741// Context sets the context to be used in this call's Do method. Any
742// pending HTTP request will be aborted if the provided context is
743// canceled.
744func (c *StatesListCall) Context(ctx context.Context) *StatesListCall {
745	c.ctx_ = ctx
746	return c
747}
748
749// Header returns an http.Header that can be modified by the caller to
750// add HTTP headers to the request.
751func (c *StatesListCall) Header() http.Header {
752	if c.header_ == nil {
753		c.header_ = make(http.Header)
754	}
755	return c.header_
756}
757
758func (c *StatesListCall) doRequest(alt string) (*http.Response, error) {
759	reqHeaders := make(http.Header)
760	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
761	for k, v := range c.header_ {
762		reqHeaders[k] = v
763	}
764	reqHeaders.Set("User-Agent", c.s.userAgent())
765	if c.ifNoneMatch_ != "" {
766		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
767	}
768	var body io.Reader = nil
769	c.urlParams_.Set("alt", alt)
770	c.urlParams_.Set("prettyPrint", "false")
771	urls := googleapi.ResolveRelative(c.s.BasePath, "states")
772	urls += "?" + c.urlParams_.Encode()
773	req, err := http.NewRequest("GET", urls, body)
774	if err != nil {
775		return nil, err
776	}
777	req.Header = reqHeaders
778	return gensupport.SendRequest(c.ctx_, c.s.client, req)
779}
780
781// Do executes the "appstate.states.list" call.
782// Exactly one of *ListResponse or error will be non-nil. Any non-2xx
783// status code is an error. Response headers are in either
784// *ListResponse.ServerResponse.Header or (if a response was returned at
785// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
786// to check whether the returned error was because
787// http.StatusNotModified was returned.
788func (c *StatesListCall) Do(opts ...googleapi.CallOption) (*ListResponse, error) {
789	gensupport.SetOptions(c.urlParams_, opts...)
790	res, err := c.doRequest("json")
791	if res != nil && res.StatusCode == http.StatusNotModified {
792		if res.Body != nil {
793			res.Body.Close()
794		}
795		return nil, &googleapi.Error{
796			Code:   res.StatusCode,
797			Header: res.Header,
798		}
799	}
800	if err != nil {
801		return nil, err
802	}
803	defer googleapi.CloseBody(res)
804	if err := googleapi.CheckResponse(res); err != nil {
805		return nil, err
806	}
807	ret := &ListResponse{
808		ServerResponse: googleapi.ServerResponse{
809			Header:         res.Header,
810			HTTPStatusCode: res.StatusCode,
811		},
812	}
813	target := &ret
814	if err := gensupport.DecodeResponse(target, res); err != nil {
815		return nil, err
816	}
817	return ret, nil
818	// {
819	//   "description": "Lists all the states keys, and optionally the state data.",
820	//   "httpMethod": "GET",
821	//   "id": "appstate.states.list",
822	//   "parameters": {
823	//     "includeData": {
824	//       "default": "false",
825	//       "description": "Whether to include the full data in addition to the version number",
826	//       "location": "query",
827	//       "type": "boolean"
828	//     }
829	//   },
830	//   "path": "states",
831	//   "response": {
832	//     "$ref": "ListResponse"
833	//   },
834	//   "scopes": [
835	//     "https://www.googleapis.com/auth/appstate"
836	//   ]
837	// }
838
839}
840
841// method id "appstate.states.update":
842
843type StatesUpdateCall struct {
844	s             *Service
845	stateKey      int64
846	updaterequest *UpdateRequest
847	urlParams_    gensupport.URLParams
848	ctx_          context.Context
849	header_       http.Header
850}
851
852// Update: Update the data associated with the input key if and only if
853// the passed version matches the currently stored version. This method
854// is safe in the face of concurrent writes. Maximum per-key size is
855// 128KB.
856func (r *StatesService) Update(stateKey int64, updaterequest *UpdateRequest) *StatesUpdateCall {
857	c := &StatesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
858	c.stateKey = stateKey
859	c.updaterequest = updaterequest
860	return c
861}
862
863// CurrentStateVersion sets the optional parameter
864// "currentStateVersion": The version of the app state your application
865// is attempting to update. If this does not match the current version,
866// this method will return a conflict error. If there is no data stored
867// on the server for this key, the update will succeed irrespective of
868// the value of this parameter.
869func (c *StatesUpdateCall) CurrentStateVersion(currentStateVersion string) *StatesUpdateCall {
870	c.urlParams_.Set("currentStateVersion", currentStateVersion)
871	return c
872}
873
874// Fields allows partial responses to be retrieved. See
875// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
876// for more information.
877func (c *StatesUpdateCall) Fields(s ...googleapi.Field) *StatesUpdateCall {
878	c.urlParams_.Set("fields", googleapi.CombineFields(s))
879	return c
880}
881
882// Context sets the context to be used in this call's Do method. Any
883// pending HTTP request will be aborted if the provided context is
884// canceled.
885func (c *StatesUpdateCall) Context(ctx context.Context) *StatesUpdateCall {
886	c.ctx_ = ctx
887	return c
888}
889
890// Header returns an http.Header that can be modified by the caller to
891// add HTTP headers to the request.
892func (c *StatesUpdateCall) Header() http.Header {
893	if c.header_ == nil {
894		c.header_ = make(http.Header)
895	}
896	return c.header_
897}
898
899func (c *StatesUpdateCall) doRequest(alt string) (*http.Response, error) {
900	reqHeaders := make(http.Header)
901	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
902	for k, v := range c.header_ {
903		reqHeaders[k] = v
904	}
905	reqHeaders.Set("User-Agent", c.s.userAgent())
906	var body io.Reader = nil
907	body, err := googleapi.WithoutDataWrapper.JSONReader(c.updaterequest)
908	if err != nil {
909		return nil, err
910	}
911	reqHeaders.Set("Content-Type", "application/json")
912	c.urlParams_.Set("alt", alt)
913	c.urlParams_.Set("prettyPrint", "false")
914	urls := googleapi.ResolveRelative(c.s.BasePath, "states/{stateKey}")
915	urls += "?" + c.urlParams_.Encode()
916	req, err := http.NewRequest("PUT", urls, body)
917	if err != nil {
918		return nil, err
919	}
920	req.Header = reqHeaders
921	googleapi.Expand(req.URL, map[string]string{
922		"stateKey": strconv.FormatInt(c.stateKey, 10),
923	})
924	return gensupport.SendRequest(c.ctx_, c.s.client, req)
925}
926
927// Do executes the "appstate.states.update" call.
928// Exactly one of *WriteResult or error will be non-nil. Any non-2xx
929// status code is an error. Response headers are in either
930// *WriteResult.ServerResponse.Header or (if a response was returned at
931// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
932// to check whether the returned error was because
933// http.StatusNotModified was returned.
934func (c *StatesUpdateCall) Do(opts ...googleapi.CallOption) (*WriteResult, error) {
935	gensupport.SetOptions(c.urlParams_, opts...)
936	res, err := c.doRequest("json")
937	if res != nil && res.StatusCode == http.StatusNotModified {
938		if res.Body != nil {
939			res.Body.Close()
940		}
941		return nil, &googleapi.Error{
942			Code:   res.StatusCode,
943			Header: res.Header,
944		}
945	}
946	if err != nil {
947		return nil, err
948	}
949	defer googleapi.CloseBody(res)
950	if err := googleapi.CheckResponse(res); err != nil {
951		return nil, err
952	}
953	ret := &WriteResult{
954		ServerResponse: googleapi.ServerResponse{
955			Header:         res.Header,
956			HTTPStatusCode: res.StatusCode,
957		},
958	}
959	target := &ret
960	if err := gensupport.DecodeResponse(target, res); err != nil {
961		return nil, err
962	}
963	return ret, nil
964	// {
965	//   "description": "Update the data associated with the input key if and only if the passed version matches the currently stored version. This method is safe in the face of concurrent writes. Maximum per-key size is 128KB.",
966	//   "httpMethod": "PUT",
967	//   "id": "appstate.states.update",
968	//   "parameterOrder": [
969	//     "stateKey"
970	//   ],
971	//   "parameters": {
972	//     "currentStateVersion": {
973	//       "description": "The version of the app state your application is attempting to update. If this does not match the current version, this method will return a conflict error. If there is no data stored on the server for this key, the update will succeed irrespective of the value of this parameter.",
974	//       "location": "query",
975	//       "type": "string"
976	//     },
977	//     "stateKey": {
978	//       "description": "The key for the data to be retrieved.",
979	//       "format": "int32",
980	//       "location": "path",
981	//       "maximum": "3",
982	//       "minimum": "0",
983	//       "required": true,
984	//       "type": "integer"
985	//     }
986	//   },
987	//   "path": "states/{stateKey}",
988	//   "request": {
989	//     "$ref": "UpdateRequest"
990	//   },
991	//   "response": {
992	//     "$ref": "WriteResult"
993	//   },
994	//   "scopes": [
995	//     "https://www.googleapis.com/auth/appstate"
996	//   ]
997	// }
998
999}
1000