appstate-gen.go 26 KB

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