You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

995 line
32 KiB

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