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.
 
 
 

1078 lines
34 KiB

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