taskqueue-gen.go 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. // Package taskqueue provides access to the TaskQueue API.
  2. //
  3. // See https://developers.google.com/appengine/docs/python/taskqueue/rest
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/taskqueue/v1beta1"
  8. // ...
  9. // taskqueueService, err := taskqueue.New(oauthHttpClient)
  10. package taskqueue // import "google.golang.org/api/taskqueue/v1beta1"
  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 = "taskqueue:v1beta1"
  41. const apiName = "taskqueue"
  42. const apiVersion = "v1beta1"
  43. const basePath = "https://www.googleapis.com/taskqueue/v1beta1/projects/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Manage your Tasks and Taskqueues
  47. TaskqueueScope = "https://www.googleapis.com/auth/taskqueue"
  48. // Consume Tasks from your Taskqueues
  49. TaskqueueConsumerScope = "https://www.googleapis.com/auth/taskqueue.consumer"
  50. )
  51. func New(client *http.Client) (*Service, error) {
  52. if client == nil {
  53. return nil, errors.New("client is nil")
  54. }
  55. s := &Service{client: client, BasePath: basePath}
  56. s.Taskqueues = NewTaskqueuesService(s)
  57. s.Tasks = NewTasksService(s)
  58. return s, nil
  59. }
  60. type Service struct {
  61. client *http.Client
  62. BasePath string // API endpoint base URL
  63. UserAgent string // optional additional User-Agent fragment
  64. Taskqueues *TaskqueuesService
  65. Tasks *TasksService
  66. }
  67. func (s *Service) userAgent() string {
  68. if s.UserAgent == "" {
  69. return googleapi.UserAgent
  70. }
  71. return googleapi.UserAgent + " " + s.UserAgent
  72. }
  73. func NewTaskqueuesService(s *Service) *TaskqueuesService {
  74. rs := &TaskqueuesService{s: s}
  75. return rs
  76. }
  77. type TaskqueuesService struct {
  78. s *Service
  79. }
  80. func NewTasksService(s *Service) *TasksService {
  81. rs := &TasksService{s: s}
  82. return rs
  83. }
  84. type TasksService struct {
  85. s *Service
  86. }
  87. type Task struct {
  88. // EnqueueTimestamp: Time (in seconds since the epoch) at which the task
  89. // was enqueued.
  90. EnqueueTimestamp int64 `json:"enqueueTimestamp,omitempty,string"`
  91. // Id: Name of the task.
  92. Id string `json:"id,omitempty"`
  93. // Kind: The kind of object returned, in this case set to task.
  94. Kind string `json:"kind,omitempty"`
  95. // LeaseTimestamp: Time (in seconds since the epoch) at which the task
  96. // lease will expire. This value is 0 if the task isnt currently leased
  97. // out to a worker.
  98. LeaseTimestamp int64 `json:"leaseTimestamp,omitempty,string"`
  99. // PayloadBase64: A bag of bytes which is the task payload. The payload
  100. // on the JSON side is always Base64 encoded.
  101. PayloadBase64 string `json:"payloadBase64,omitempty"`
  102. // QueueName: Name of the queue that the task is in.
  103. QueueName string `json:"queueName,omitempty"`
  104. // ServerResponse contains the HTTP response code and headers from the
  105. // server.
  106. googleapi.ServerResponse `json:"-"`
  107. // ForceSendFields is a list of field names (e.g. "EnqueueTimestamp") to
  108. // unconditionally include in API requests. By default, fields with
  109. // empty values are omitted from API requests. However, any non-pointer,
  110. // non-interface field appearing in ForceSendFields will be sent to the
  111. // server regardless of whether the field is empty or not. This may be
  112. // used to include empty fields in Patch requests.
  113. ForceSendFields []string `json:"-"`
  114. }
  115. func (s *Task) MarshalJSON() ([]byte, error) {
  116. type noMethod Task
  117. raw := noMethod(*s)
  118. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  119. }
  120. type TaskQueue struct {
  121. // Acl: ACLs that are applicable to this TaskQueue object.
  122. Acl *TaskQueueAcl `json:"acl,omitempty"`
  123. // Id: Name of the taskqueue.
  124. Id string `json:"id,omitempty"`
  125. // Kind: The kind of REST object returned, in this case taskqueue.
  126. Kind string `json:"kind,omitempty"`
  127. // MaxLeases: The number of times we should lease out tasks before
  128. // giving up on them. If unset we lease them out forever until a worker
  129. // deletes the task.
  130. MaxLeases int64 `json:"maxLeases,omitempty"`
  131. // Stats: Statistics for the TaskQueue object in question.
  132. Stats *TaskQueueStats `json:"stats,omitempty"`
  133. // ServerResponse contains the HTTP response code and headers from the
  134. // server.
  135. googleapi.ServerResponse `json:"-"`
  136. // ForceSendFields is a list of field names (e.g. "Acl") to
  137. // unconditionally include in API requests. By default, fields with
  138. // empty values are omitted from API requests. However, any non-pointer,
  139. // non-interface field appearing in ForceSendFields will be sent to the
  140. // server regardless of whether the field is empty or not. This may be
  141. // used to include empty fields in Patch requests.
  142. ForceSendFields []string `json:"-"`
  143. }
  144. func (s *TaskQueue) MarshalJSON() ([]byte, error) {
  145. type noMethod TaskQueue
  146. raw := noMethod(*s)
  147. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  148. }
  149. // TaskQueueAcl: ACLs that are applicable to this TaskQueue object.
  150. type TaskQueueAcl struct {
  151. // AdminEmails: Email addresses of users who are "admins" of the
  152. // TaskQueue. This means they can control the queue, eg set ACLs for the
  153. // queue.
  154. AdminEmails []string `json:"adminEmails,omitempty"`
  155. // ConsumerEmails: Email addresses of users who can "consume" tasks from
  156. // the TaskQueue. This means they can Dequeue and Delete tasks from the
  157. // queue.
  158. ConsumerEmails []string `json:"consumerEmails,omitempty"`
  159. // ProducerEmails: Email addresses of users who can "produce" tasks into
  160. // the TaskQueue. This means they can Insert tasks into the queue.
  161. ProducerEmails []string `json:"producerEmails,omitempty"`
  162. // ForceSendFields is a list of field names (e.g. "AdminEmails") to
  163. // unconditionally include in API requests. By default, fields with
  164. // empty values are omitted from API requests. However, any non-pointer,
  165. // non-interface field appearing in ForceSendFields will be sent to the
  166. // server regardless of whether the field is empty or not. This may be
  167. // used to include empty fields in Patch requests.
  168. ForceSendFields []string `json:"-"`
  169. }
  170. func (s *TaskQueueAcl) MarshalJSON() ([]byte, error) {
  171. type noMethod TaskQueueAcl
  172. raw := noMethod(*s)
  173. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  174. }
  175. // TaskQueueStats: Statistics for the TaskQueue object in question.
  176. type TaskQueueStats struct {
  177. // LeasedLastHour: Number of tasks leased in the last hour.
  178. LeasedLastHour int64 `json:"leasedLastHour,omitempty,string"`
  179. // LeasedLastMinute: Number of tasks leased in the last minute.
  180. LeasedLastMinute int64 `json:"leasedLastMinute,omitempty,string"`
  181. // OldestTask: The timestamp (in seconds since the epoch) of the oldest
  182. // unfinished task.
  183. OldestTask int64 `json:"oldestTask,omitempty,string"`
  184. // TotalTasks: Number of tasks in the queue.
  185. TotalTasks int64 `json:"totalTasks,omitempty"`
  186. // ForceSendFields is a list of field names (e.g. "LeasedLastHour") to
  187. // unconditionally include in API requests. By default, fields with
  188. // empty values are omitted from API requests. However, any non-pointer,
  189. // non-interface field appearing in ForceSendFields will be sent to the
  190. // server regardless of whether the field is empty or not. This may be
  191. // used to include empty fields in Patch requests.
  192. ForceSendFields []string `json:"-"`
  193. }
  194. func (s *TaskQueueStats) MarshalJSON() ([]byte, error) {
  195. type noMethod TaskQueueStats
  196. raw := noMethod(*s)
  197. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  198. }
  199. type Tasks struct {
  200. // Items: The actual list of tasks returned as a result of the lease
  201. // operation.
  202. Items []*Task `json:"items,omitempty"`
  203. // Kind: The kind of object returned, a list of tasks.
  204. Kind string `json:"kind,omitempty"`
  205. // ServerResponse contains the HTTP response code and headers from the
  206. // server.
  207. googleapi.ServerResponse `json:"-"`
  208. // ForceSendFields is a list of field names (e.g. "Items") to
  209. // unconditionally include in API requests. By default, fields with
  210. // empty values are omitted from API requests. However, any non-pointer,
  211. // non-interface field appearing in ForceSendFields will be sent to the
  212. // server regardless of whether the field is empty or not. This may be
  213. // used to include empty fields in Patch requests.
  214. ForceSendFields []string `json:"-"`
  215. }
  216. func (s *Tasks) MarshalJSON() ([]byte, error) {
  217. type noMethod Tasks
  218. raw := noMethod(*s)
  219. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  220. }
  221. type Tasks2 struct {
  222. // Items: The actual list of tasks currently active in the TaskQueue.
  223. Items []*Task `json:"items,omitempty"`
  224. // Kind: The kind of object returned, a list of tasks.
  225. Kind string `json:"kind,omitempty"`
  226. // ServerResponse contains the HTTP response code and headers from the
  227. // server.
  228. googleapi.ServerResponse `json:"-"`
  229. // ForceSendFields is a list of field names (e.g. "Items") to
  230. // unconditionally include in API requests. By default, fields with
  231. // empty values are omitted from API requests. However, any non-pointer,
  232. // non-interface field appearing in ForceSendFields will be sent to the
  233. // server regardless of whether the field is empty or not. This may be
  234. // used to include empty fields in Patch requests.
  235. ForceSendFields []string `json:"-"`
  236. }
  237. func (s *Tasks2) MarshalJSON() ([]byte, error) {
  238. type noMethod Tasks2
  239. raw := noMethod(*s)
  240. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  241. }
  242. // method id "taskqueue.taskqueues.get":
  243. type TaskqueuesGetCall struct {
  244. s *Service
  245. project string
  246. taskqueue string
  247. urlParams_ gensupport.URLParams
  248. ifNoneMatch_ string
  249. ctx_ context.Context
  250. }
  251. // Get: Get detailed information about a TaskQueue.
  252. func (r *TaskqueuesService) Get(project string, taskqueue string) *TaskqueuesGetCall {
  253. c := &TaskqueuesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  254. c.project = project
  255. c.taskqueue = taskqueue
  256. return c
  257. }
  258. // GetStats sets the optional parameter "getStats": Whether to get
  259. // stats.
  260. func (c *TaskqueuesGetCall) GetStats(getStats bool) *TaskqueuesGetCall {
  261. c.urlParams_.Set("getStats", fmt.Sprint(getStats))
  262. return c
  263. }
  264. // Fields allows partial responses to be retrieved. See
  265. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  266. // for more information.
  267. func (c *TaskqueuesGetCall) Fields(s ...googleapi.Field) *TaskqueuesGetCall {
  268. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  269. return c
  270. }
  271. // IfNoneMatch sets the optional parameter which makes the operation
  272. // fail if the object's ETag matches the given value. This is useful for
  273. // getting updates only after the object has changed since the last
  274. // request. Use googleapi.IsNotModified to check whether the response
  275. // error from Do is the result of In-None-Match.
  276. func (c *TaskqueuesGetCall) IfNoneMatch(entityTag string) *TaskqueuesGetCall {
  277. c.ifNoneMatch_ = entityTag
  278. return c
  279. }
  280. // Context sets the context to be used in this call's Do method. Any
  281. // pending HTTP request will be aborted if the provided context is
  282. // canceled.
  283. func (c *TaskqueuesGetCall) Context(ctx context.Context) *TaskqueuesGetCall {
  284. c.ctx_ = ctx
  285. return c
  286. }
  287. func (c *TaskqueuesGetCall) doRequest(alt string) (*http.Response, error) {
  288. var body io.Reader = nil
  289. c.urlParams_.Set("alt", alt)
  290. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}")
  291. urls += "?" + c.urlParams_.Encode()
  292. req, _ := http.NewRequest("GET", urls, body)
  293. googleapi.Expand(req.URL, map[string]string{
  294. "project": c.project,
  295. "taskqueue": c.taskqueue,
  296. })
  297. req.Header.Set("User-Agent", c.s.userAgent())
  298. if c.ifNoneMatch_ != "" {
  299. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  300. }
  301. if c.ctx_ != nil {
  302. return ctxhttp.Do(c.ctx_, c.s.client, req)
  303. }
  304. return c.s.client.Do(req)
  305. }
  306. // Do executes the "taskqueue.taskqueues.get" call.
  307. // Exactly one of *TaskQueue or error will be non-nil. Any non-2xx
  308. // status code is an error. Response headers are in either
  309. // *TaskQueue.ServerResponse.Header or (if a response was returned at
  310. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  311. // to check whether the returned error was because
  312. // http.StatusNotModified was returned.
  313. func (c *TaskqueuesGetCall) Do(opts ...googleapi.CallOption) (*TaskQueue, error) {
  314. gensupport.SetOptions(c.urlParams_, opts...)
  315. res, err := c.doRequest("json")
  316. if res != nil && res.StatusCode == http.StatusNotModified {
  317. if res.Body != nil {
  318. res.Body.Close()
  319. }
  320. return nil, &googleapi.Error{
  321. Code: res.StatusCode,
  322. Header: res.Header,
  323. }
  324. }
  325. if err != nil {
  326. return nil, err
  327. }
  328. defer googleapi.CloseBody(res)
  329. if err := googleapi.CheckResponse(res); err != nil {
  330. return nil, err
  331. }
  332. ret := &TaskQueue{
  333. ServerResponse: googleapi.ServerResponse{
  334. Header: res.Header,
  335. HTTPStatusCode: res.StatusCode,
  336. },
  337. }
  338. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  339. return nil, err
  340. }
  341. return ret, nil
  342. // {
  343. // "description": "Get detailed information about a TaskQueue.",
  344. // "httpMethod": "GET",
  345. // "id": "taskqueue.taskqueues.get",
  346. // "parameterOrder": [
  347. // "project",
  348. // "taskqueue"
  349. // ],
  350. // "parameters": {
  351. // "getStats": {
  352. // "description": "Whether to get stats. Optional.",
  353. // "location": "query",
  354. // "type": "boolean"
  355. // },
  356. // "project": {
  357. // "description": "The project under which the queue lies.",
  358. // "location": "path",
  359. // "required": true,
  360. // "type": "string"
  361. // },
  362. // "taskqueue": {
  363. // "description": "The id of the taskqueue to get the properties of.",
  364. // "location": "path",
  365. // "required": true,
  366. // "type": "string"
  367. // }
  368. // },
  369. // "path": "{project}/taskqueues/{taskqueue}",
  370. // "response": {
  371. // "$ref": "TaskQueue"
  372. // },
  373. // "scopes": [
  374. // "https://www.googleapis.com/auth/taskqueue",
  375. // "https://www.googleapis.com/auth/taskqueue.consumer"
  376. // ]
  377. // }
  378. }
  379. // method id "taskqueue.tasks.delete":
  380. type TasksDeleteCall struct {
  381. s *Service
  382. project string
  383. taskqueue string
  384. task string
  385. urlParams_ gensupport.URLParams
  386. ctx_ context.Context
  387. }
  388. // Delete: Delete a task from a TaskQueue.
  389. func (r *TasksService) Delete(project string, taskqueue string, task string) *TasksDeleteCall {
  390. c := &TasksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  391. c.project = project
  392. c.taskqueue = taskqueue
  393. c.task = task
  394. return c
  395. }
  396. // Fields allows partial responses to be retrieved. See
  397. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  398. // for more information.
  399. func (c *TasksDeleteCall) Fields(s ...googleapi.Field) *TasksDeleteCall {
  400. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  401. return c
  402. }
  403. // Context sets the context to be used in this call's Do method. Any
  404. // pending HTTP request will be aborted if the provided context is
  405. // canceled.
  406. func (c *TasksDeleteCall) Context(ctx context.Context) *TasksDeleteCall {
  407. c.ctx_ = ctx
  408. return c
  409. }
  410. func (c *TasksDeleteCall) doRequest(alt string) (*http.Response, error) {
  411. var body io.Reader = nil
  412. c.urlParams_.Set("alt", alt)
  413. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
  414. urls += "?" + c.urlParams_.Encode()
  415. req, _ := http.NewRequest("DELETE", urls, body)
  416. googleapi.Expand(req.URL, map[string]string{
  417. "project": c.project,
  418. "taskqueue": c.taskqueue,
  419. "task": c.task,
  420. })
  421. req.Header.Set("User-Agent", c.s.userAgent())
  422. if c.ctx_ != nil {
  423. return ctxhttp.Do(c.ctx_, c.s.client, req)
  424. }
  425. return c.s.client.Do(req)
  426. }
  427. // Do executes the "taskqueue.tasks.delete" call.
  428. func (c *TasksDeleteCall) Do(opts ...googleapi.CallOption) error {
  429. gensupport.SetOptions(c.urlParams_, opts...)
  430. res, err := c.doRequest("json")
  431. if err != nil {
  432. return err
  433. }
  434. defer googleapi.CloseBody(res)
  435. if err := googleapi.CheckResponse(res); err != nil {
  436. return err
  437. }
  438. return nil
  439. // {
  440. // "description": "Delete a task from a TaskQueue.",
  441. // "httpMethod": "DELETE",
  442. // "id": "taskqueue.tasks.delete",
  443. // "parameterOrder": [
  444. // "project",
  445. // "taskqueue",
  446. // "task"
  447. // ],
  448. // "parameters": {
  449. // "project": {
  450. // "description": "The project under which the queue lies.",
  451. // "location": "path",
  452. // "required": true,
  453. // "type": "string"
  454. // },
  455. // "task": {
  456. // "description": "The id of the task to delete.",
  457. // "location": "path",
  458. // "required": true,
  459. // "type": "string"
  460. // },
  461. // "taskqueue": {
  462. // "description": "The taskqueue to delete a task from.",
  463. // "location": "path",
  464. // "required": true,
  465. // "type": "string"
  466. // }
  467. // },
  468. // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
  469. // "scopes": [
  470. // "https://www.googleapis.com/auth/taskqueue",
  471. // "https://www.googleapis.com/auth/taskqueue.consumer"
  472. // ]
  473. // }
  474. }
  475. // method id "taskqueue.tasks.get":
  476. type TasksGetCall struct {
  477. s *Service
  478. project string
  479. taskqueue string
  480. task string
  481. urlParams_ gensupport.URLParams
  482. ifNoneMatch_ string
  483. ctx_ context.Context
  484. }
  485. // Get: Get a particular task from a TaskQueue.
  486. func (r *TasksService) Get(project string, taskqueue string, task string) *TasksGetCall {
  487. c := &TasksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  488. c.project = project
  489. c.taskqueue = taskqueue
  490. c.task = task
  491. return c
  492. }
  493. // Fields allows partial responses to be retrieved. See
  494. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  495. // for more information.
  496. func (c *TasksGetCall) Fields(s ...googleapi.Field) *TasksGetCall {
  497. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  498. return c
  499. }
  500. // IfNoneMatch sets the optional parameter which makes the operation
  501. // fail if the object's ETag matches the given value. This is useful for
  502. // getting updates only after the object has changed since the last
  503. // request. Use googleapi.IsNotModified to check whether the response
  504. // error from Do is the result of In-None-Match.
  505. func (c *TasksGetCall) IfNoneMatch(entityTag string) *TasksGetCall {
  506. c.ifNoneMatch_ = entityTag
  507. return c
  508. }
  509. // Context sets the context to be used in this call's Do method. Any
  510. // pending HTTP request will be aborted if the provided context is
  511. // canceled.
  512. func (c *TasksGetCall) Context(ctx context.Context) *TasksGetCall {
  513. c.ctx_ = ctx
  514. return c
  515. }
  516. func (c *TasksGetCall) doRequest(alt string) (*http.Response, error) {
  517. var body io.Reader = nil
  518. c.urlParams_.Set("alt", alt)
  519. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
  520. urls += "?" + c.urlParams_.Encode()
  521. req, _ := http.NewRequest("GET", urls, body)
  522. googleapi.Expand(req.URL, map[string]string{
  523. "project": c.project,
  524. "taskqueue": c.taskqueue,
  525. "task": c.task,
  526. })
  527. req.Header.Set("User-Agent", c.s.userAgent())
  528. if c.ifNoneMatch_ != "" {
  529. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  530. }
  531. if c.ctx_ != nil {
  532. return ctxhttp.Do(c.ctx_, c.s.client, req)
  533. }
  534. return c.s.client.Do(req)
  535. }
  536. // Do executes the "taskqueue.tasks.get" call.
  537. // Exactly one of *Task or error will be non-nil. Any non-2xx status
  538. // code is an error. Response headers are in either
  539. // *Task.ServerResponse.Header or (if a response was returned at all) in
  540. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  541. // whether the returned error was because http.StatusNotModified was
  542. // returned.
  543. func (c *TasksGetCall) Do(opts ...googleapi.CallOption) (*Task, error) {
  544. gensupport.SetOptions(c.urlParams_, opts...)
  545. res, err := c.doRequest("json")
  546. if res != nil && res.StatusCode == http.StatusNotModified {
  547. if res.Body != nil {
  548. res.Body.Close()
  549. }
  550. return nil, &googleapi.Error{
  551. Code: res.StatusCode,
  552. Header: res.Header,
  553. }
  554. }
  555. if err != nil {
  556. return nil, err
  557. }
  558. defer googleapi.CloseBody(res)
  559. if err := googleapi.CheckResponse(res); err != nil {
  560. return nil, err
  561. }
  562. ret := &Task{
  563. ServerResponse: googleapi.ServerResponse{
  564. Header: res.Header,
  565. HTTPStatusCode: res.StatusCode,
  566. },
  567. }
  568. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  569. return nil, err
  570. }
  571. return ret, nil
  572. // {
  573. // "description": "Get a particular task from a TaskQueue.",
  574. // "httpMethod": "GET",
  575. // "id": "taskqueue.tasks.get",
  576. // "parameterOrder": [
  577. // "project",
  578. // "taskqueue",
  579. // "task"
  580. // ],
  581. // "parameters": {
  582. // "project": {
  583. // "description": "The project under which the queue lies.",
  584. // "location": "path",
  585. // "required": true,
  586. // "type": "string"
  587. // },
  588. // "task": {
  589. // "description": "The task to get properties of.",
  590. // "location": "path",
  591. // "required": true,
  592. // "type": "string"
  593. // },
  594. // "taskqueue": {
  595. // "description": "The taskqueue in which the task belongs.",
  596. // "location": "path",
  597. // "required": true,
  598. // "type": "string"
  599. // }
  600. // },
  601. // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
  602. // "response": {
  603. // "$ref": "Task"
  604. // },
  605. // "scopes": [
  606. // "https://www.googleapis.com/auth/taskqueue",
  607. // "https://www.googleapis.com/auth/taskqueue.consumer"
  608. // ]
  609. // }
  610. }
  611. // method id "taskqueue.tasks.lease":
  612. type TasksLeaseCall struct {
  613. s *Service
  614. project string
  615. taskqueue string
  616. urlParams_ gensupport.URLParams
  617. ctx_ context.Context
  618. }
  619. // Lease: Lease 1 or more tasks from a TaskQueue.
  620. func (r *TasksService) Lease(project string, taskqueue string, numTasks int64, leaseSecs int64) *TasksLeaseCall {
  621. c := &TasksLeaseCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  622. c.project = project
  623. c.taskqueue = taskqueue
  624. c.urlParams_.Set("numTasks", fmt.Sprint(numTasks))
  625. c.urlParams_.Set("leaseSecs", fmt.Sprint(leaseSecs))
  626. return c
  627. }
  628. // Fields allows partial responses to be retrieved. See
  629. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  630. // for more information.
  631. func (c *TasksLeaseCall) Fields(s ...googleapi.Field) *TasksLeaseCall {
  632. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  633. return c
  634. }
  635. // Context sets the context to be used in this call's Do method. Any
  636. // pending HTTP request will be aborted if the provided context is
  637. // canceled.
  638. func (c *TasksLeaseCall) Context(ctx context.Context) *TasksLeaseCall {
  639. c.ctx_ = ctx
  640. return c
  641. }
  642. func (c *TasksLeaseCall) doRequest(alt string) (*http.Response, error) {
  643. var body io.Reader = nil
  644. c.urlParams_.Set("alt", alt)
  645. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/lease")
  646. urls += "?" + c.urlParams_.Encode()
  647. req, _ := http.NewRequest("POST", urls, body)
  648. googleapi.Expand(req.URL, map[string]string{
  649. "project": c.project,
  650. "taskqueue": c.taskqueue,
  651. })
  652. req.Header.Set("User-Agent", c.s.userAgent())
  653. if c.ctx_ != nil {
  654. return ctxhttp.Do(c.ctx_, c.s.client, req)
  655. }
  656. return c.s.client.Do(req)
  657. }
  658. // Do executes the "taskqueue.tasks.lease" call.
  659. // Exactly one of *Tasks or error will be non-nil. Any non-2xx status
  660. // code is an error. Response headers are in either
  661. // *Tasks.ServerResponse.Header or (if a response was returned at all)
  662. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  663. // check whether the returned error was because http.StatusNotModified
  664. // was returned.
  665. func (c *TasksLeaseCall) Do(opts ...googleapi.CallOption) (*Tasks, error) {
  666. gensupport.SetOptions(c.urlParams_, opts...)
  667. res, err := c.doRequest("json")
  668. if res != nil && res.StatusCode == http.StatusNotModified {
  669. if res.Body != nil {
  670. res.Body.Close()
  671. }
  672. return nil, &googleapi.Error{
  673. Code: res.StatusCode,
  674. Header: res.Header,
  675. }
  676. }
  677. if err != nil {
  678. return nil, err
  679. }
  680. defer googleapi.CloseBody(res)
  681. if err := googleapi.CheckResponse(res); err != nil {
  682. return nil, err
  683. }
  684. ret := &Tasks{
  685. ServerResponse: googleapi.ServerResponse{
  686. Header: res.Header,
  687. HTTPStatusCode: res.StatusCode,
  688. },
  689. }
  690. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  691. return nil, err
  692. }
  693. return ret, nil
  694. // {
  695. // "description": "Lease 1 or more tasks from a TaskQueue.",
  696. // "httpMethod": "POST",
  697. // "id": "taskqueue.tasks.lease",
  698. // "parameterOrder": [
  699. // "project",
  700. // "taskqueue",
  701. // "numTasks",
  702. // "leaseSecs"
  703. // ],
  704. // "parameters": {
  705. // "leaseSecs": {
  706. // "description": "The lease in seconds.",
  707. // "format": "int32",
  708. // "location": "query",
  709. // "required": true,
  710. // "type": "integer"
  711. // },
  712. // "numTasks": {
  713. // "description": "The number of tasks to lease.",
  714. // "format": "int32",
  715. // "location": "query",
  716. // "required": true,
  717. // "type": "integer"
  718. // },
  719. // "project": {
  720. // "description": "The project under which the queue lies.",
  721. // "location": "path",
  722. // "required": true,
  723. // "type": "string"
  724. // },
  725. // "taskqueue": {
  726. // "description": "The taskqueue to lease a task from.",
  727. // "location": "path",
  728. // "required": true,
  729. // "type": "string"
  730. // }
  731. // },
  732. // "path": "{project}/taskqueues/{taskqueue}/tasks/lease",
  733. // "response": {
  734. // "$ref": "Tasks"
  735. // },
  736. // "scopes": [
  737. // "https://www.googleapis.com/auth/taskqueue",
  738. // "https://www.googleapis.com/auth/taskqueue.consumer"
  739. // ]
  740. // }
  741. }
  742. // method id "taskqueue.tasks.list":
  743. type TasksListCall struct {
  744. s *Service
  745. project string
  746. taskqueue string
  747. urlParams_ gensupport.URLParams
  748. ifNoneMatch_ string
  749. ctx_ context.Context
  750. }
  751. // List: List Tasks in a TaskQueue
  752. func (r *TasksService) List(project string, taskqueue string) *TasksListCall {
  753. c := &TasksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  754. c.project = project
  755. c.taskqueue = taskqueue
  756. return c
  757. }
  758. // Fields allows partial responses to be retrieved. See
  759. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  760. // for more information.
  761. func (c *TasksListCall) Fields(s ...googleapi.Field) *TasksListCall {
  762. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  763. return c
  764. }
  765. // IfNoneMatch sets the optional parameter which makes the operation
  766. // fail if the object's ETag matches the given value. This is useful for
  767. // getting updates only after the object has changed since the last
  768. // request. Use googleapi.IsNotModified to check whether the response
  769. // error from Do is the result of In-None-Match.
  770. func (c *TasksListCall) IfNoneMatch(entityTag string) *TasksListCall {
  771. c.ifNoneMatch_ = entityTag
  772. return c
  773. }
  774. // Context sets the context to be used in this call's Do method. Any
  775. // pending HTTP request will be aborted if the provided context is
  776. // canceled.
  777. func (c *TasksListCall) Context(ctx context.Context) *TasksListCall {
  778. c.ctx_ = ctx
  779. return c
  780. }
  781. func (c *TasksListCall) doRequest(alt string) (*http.Response, error) {
  782. var body io.Reader = nil
  783. c.urlParams_.Set("alt", alt)
  784. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks")
  785. urls += "?" + c.urlParams_.Encode()
  786. req, _ := http.NewRequest("GET", urls, body)
  787. googleapi.Expand(req.URL, map[string]string{
  788. "project": c.project,
  789. "taskqueue": c.taskqueue,
  790. })
  791. req.Header.Set("User-Agent", c.s.userAgent())
  792. if c.ifNoneMatch_ != "" {
  793. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  794. }
  795. if c.ctx_ != nil {
  796. return ctxhttp.Do(c.ctx_, c.s.client, req)
  797. }
  798. return c.s.client.Do(req)
  799. }
  800. // Do executes the "taskqueue.tasks.list" call.
  801. // Exactly one of *Tasks2 or error will be non-nil. Any non-2xx status
  802. // code is an error. Response headers are in either
  803. // *Tasks2.ServerResponse.Header or (if a response was returned at all)
  804. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  805. // check whether the returned error was because http.StatusNotModified
  806. // was returned.
  807. func (c *TasksListCall) Do(opts ...googleapi.CallOption) (*Tasks2, error) {
  808. gensupport.SetOptions(c.urlParams_, opts...)
  809. res, err := c.doRequest("json")
  810. if res != nil && res.StatusCode == http.StatusNotModified {
  811. if res.Body != nil {
  812. res.Body.Close()
  813. }
  814. return nil, &googleapi.Error{
  815. Code: res.StatusCode,
  816. Header: res.Header,
  817. }
  818. }
  819. if err != nil {
  820. return nil, err
  821. }
  822. defer googleapi.CloseBody(res)
  823. if err := googleapi.CheckResponse(res); err != nil {
  824. return nil, err
  825. }
  826. ret := &Tasks2{
  827. ServerResponse: googleapi.ServerResponse{
  828. Header: res.Header,
  829. HTTPStatusCode: res.StatusCode,
  830. },
  831. }
  832. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  833. return nil, err
  834. }
  835. return ret, nil
  836. // {
  837. // "description": "List Tasks in a TaskQueue",
  838. // "httpMethod": "GET",
  839. // "id": "taskqueue.tasks.list",
  840. // "parameterOrder": [
  841. // "project",
  842. // "taskqueue"
  843. // ],
  844. // "parameters": {
  845. // "project": {
  846. // "description": "The project under which the queue lies.",
  847. // "location": "path",
  848. // "required": true,
  849. // "type": "string"
  850. // },
  851. // "taskqueue": {
  852. // "description": "The id of the taskqueue to list tasks from.",
  853. // "location": "path",
  854. // "required": true,
  855. // "type": "string"
  856. // }
  857. // },
  858. // "path": "{project}/taskqueues/{taskqueue}/tasks",
  859. // "response": {
  860. // "$ref": "Tasks2"
  861. // },
  862. // "scopes": [
  863. // "https://www.googleapis.com/auth/taskqueue",
  864. // "https://www.googleapis.com/auth/taskqueue.consumer"
  865. // ]
  866. // }
  867. }