Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

1578 rader
48 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/v1beta2"
  8. // ...
  9. // taskqueueService, err := taskqueue.New(oauthHttpClient)
  10. package taskqueue // import "google.golang.org/api/taskqueue/v1beta2"
  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:v1beta2"
  41. const apiName = "taskqueue"
  42. const apiVersion = "v1beta2"
  43. const basePath = "https://www.googleapis.com/taskqueue/v1beta2/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. // RetryCount: The number of leases applied to this task.
  105. RetryCount int64 `json:"retry_count,omitempty"`
  106. // Tag: Tag for the task, could be used later to lease tasks grouped by
  107. // a specific tag.
  108. Tag string `json:"tag,omitempty"`
  109. // ServerResponse contains the HTTP response code and headers from the
  110. // server.
  111. googleapi.ServerResponse `json:"-"`
  112. // ForceSendFields is a list of field names (e.g. "EnqueueTimestamp") to
  113. // unconditionally include in API requests. By default, fields with
  114. // empty values are omitted from API requests. However, any non-pointer,
  115. // non-interface field appearing in ForceSendFields will be sent to the
  116. // server regardless of whether the field is empty or not. This may be
  117. // used to include empty fields in Patch requests.
  118. ForceSendFields []string `json:"-"`
  119. // NullFields is a list of field names (e.g. "EnqueueTimestamp") to
  120. // include in API requests with the JSON null value. By default, fields
  121. // with empty values are omitted from API requests. However, any field
  122. // with an empty value appearing in NullFields will be sent to the
  123. // server as null. It is an error if a field in this list has a
  124. // non-empty value. This may be used to include null fields in Patch
  125. // requests.
  126. NullFields []string `json:"-"`
  127. }
  128. func (s *Task) MarshalJSON() ([]byte, error) {
  129. type NoMethod Task
  130. raw := NoMethod(*s)
  131. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  132. }
  133. type TaskQueue struct {
  134. // Acl: ACLs that are applicable to this TaskQueue object.
  135. Acl *TaskQueueAcl `json:"acl,omitempty"`
  136. // Id: Name of the taskqueue.
  137. Id string `json:"id,omitempty"`
  138. // Kind: The kind of REST object returned, in this case taskqueue.
  139. Kind string `json:"kind,omitempty"`
  140. // MaxLeases: The number of times we should lease out tasks before
  141. // giving up on them. If unset we lease them out forever until a worker
  142. // deletes the task.
  143. MaxLeases int64 `json:"maxLeases,omitempty"`
  144. // Stats: Statistics for the TaskQueue object in question.
  145. Stats *TaskQueueStats `json:"stats,omitempty"`
  146. // ServerResponse contains the HTTP response code and headers from the
  147. // server.
  148. googleapi.ServerResponse `json:"-"`
  149. // ForceSendFields is a list of field names (e.g. "Acl") to
  150. // unconditionally include in API requests. By default, fields with
  151. // empty values are omitted from API requests. However, any non-pointer,
  152. // non-interface field appearing in ForceSendFields will be sent to the
  153. // server regardless of whether the field is empty or not. This may be
  154. // used to include empty fields in Patch requests.
  155. ForceSendFields []string `json:"-"`
  156. // NullFields is a list of field names (e.g. "Acl") to include in API
  157. // requests with the JSON null value. By default, fields with empty
  158. // values are omitted from API requests. However, any field with an
  159. // empty value appearing in NullFields will be sent to the server as
  160. // null. It is an error if a field in this list has a non-empty value.
  161. // This may be used to include null fields in Patch requests.
  162. NullFields []string `json:"-"`
  163. }
  164. func (s *TaskQueue) MarshalJSON() ([]byte, error) {
  165. type NoMethod TaskQueue
  166. raw := NoMethod(*s)
  167. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  168. }
  169. // TaskQueueAcl: ACLs that are applicable to this TaskQueue object.
  170. type TaskQueueAcl struct {
  171. // AdminEmails: Email addresses of users who are "admins" of the
  172. // TaskQueue. This means they can control the queue, eg set ACLs for the
  173. // queue.
  174. AdminEmails []string `json:"adminEmails,omitempty"`
  175. // ConsumerEmails: Email addresses of users who can "consume" tasks from
  176. // the TaskQueue. This means they can Dequeue and Delete tasks from the
  177. // queue.
  178. ConsumerEmails []string `json:"consumerEmails,omitempty"`
  179. // ProducerEmails: Email addresses of users who can "produce" tasks into
  180. // the TaskQueue. This means they can Insert tasks into the queue.
  181. ProducerEmails []string `json:"producerEmails,omitempty"`
  182. // ForceSendFields is a list of field names (e.g. "AdminEmails") to
  183. // unconditionally include in API requests. By default, fields with
  184. // empty values are omitted from API requests. However, any non-pointer,
  185. // non-interface field appearing in ForceSendFields will be sent to the
  186. // server regardless of whether the field is empty or not. This may be
  187. // used to include empty fields in Patch requests.
  188. ForceSendFields []string `json:"-"`
  189. // NullFields is a list of field names (e.g. "AdminEmails") to include
  190. // in API requests with the JSON null value. By default, fields with
  191. // empty values are omitted from API requests. However, any field with
  192. // an empty value appearing in NullFields will be sent to the server as
  193. // null. It is an error if a field in this list has a non-empty value.
  194. // This may be used to include null fields in Patch requests.
  195. NullFields []string `json:"-"`
  196. }
  197. func (s *TaskQueueAcl) MarshalJSON() ([]byte, error) {
  198. type NoMethod TaskQueueAcl
  199. raw := NoMethod(*s)
  200. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  201. }
  202. // TaskQueueStats: Statistics for the TaskQueue object in question.
  203. type TaskQueueStats struct {
  204. // LeasedLastHour: Number of tasks leased in the last hour.
  205. LeasedLastHour int64 `json:"leasedLastHour,omitempty,string"`
  206. // LeasedLastMinute: Number of tasks leased in the last minute.
  207. LeasedLastMinute int64 `json:"leasedLastMinute,omitempty,string"`
  208. // OldestTask: The timestamp (in seconds since the epoch) of the oldest
  209. // unfinished task.
  210. OldestTask int64 `json:"oldestTask,omitempty,string"`
  211. // TotalTasks: Number of tasks in the queue.
  212. TotalTasks int64 `json:"totalTasks,omitempty"`
  213. // ForceSendFields is a list of field names (e.g. "LeasedLastHour") to
  214. // unconditionally include in API requests. By default, fields with
  215. // empty values are omitted from API requests. However, any non-pointer,
  216. // non-interface field appearing in ForceSendFields will be sent to the
  217. // server regardless of whether the field is empty or not. This may be
  218. // used to include empty fields in Patch requests.
  219. ForceSendFields []string `json:"-"`
  220. // NullFields is a list of field names (e.g. "LeasedLastHour") to
  221. // include in API requests with the JSON null value. By default, fields
  222. // with empty values are omitted from API requests. However, any field
  223. // with an empty value appearing in NullFields will be sent to the
  224. // server as null. It is an error if a field in this list has a
  225. // non-empty value. This may be used to include null fields in Patch
  226. // requests.
  227. NullFields []string `json:"-"`
  228. }
  229. func (s *TaskQueueStats) MarshalJSON() ([]byte, error) {
  230. type NoMethod TaskQueueStats
  231. raw := NoMethod(*s)
  232. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  233. }
  234. type Tasks struct {
  235. // Items: The actual list of tasks returned as a result of the lease
  236. // operation.
  237. Items []*Task `json:"items,omitempty"`
  238. // Kind: The kind of object returned, a list of tasks.
  239. Kind string `json:"kind,omitempty"`
  240. // ServerResponse contains the HTTP response code and headers from the
  241. // server.
  242. googleapi.ServerResponse `json:"-"`
  243. // ForceSendFields is a list of field names (e.g. "Items") to
  244. // unconditionally include in API requests. By default, fields with
  245. // empty values are omitted from API requests. However, any non-pointer,
  246. // non-interface field appearing in ForceSendFields will be sent to the
  247. // server regardless of whether the field is empty or not. This may be
  248. // used to include empty fields in Patch requests.
  249. ForceSendFields []string `json:"-"`
  250. // NullFields is a list of field names (e.g. "Items") to include in API
  251. // requests with the JSON null value. By default, fields with empty
  252. // values are omitted from API requests. However, any field with an
  253. // empty value appearing in NullFields will be sent to the server as
  254. // null. It is an error if a field in this list has a non-empty value.
  255. // This may be used to include null fields in Patch requests.
  256. NullFields []string `json:"-"`
  257. }
  258. func (s *Tasks) MarshalJSON() ([]byte, error) {
  259. type NoMethod Tasks
  260. raw := NoMethod(*s)
  261. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  262. }
  263. type Tasks2 struct {
  264. // Items: The actual list of tasks currently active in the TaskQueue.
  265. Items []*Task `json:"items,omitempty"`
  266. // Kind: The kind of object returned, a list of tasks.
  267. Kind string `json:"kind,omitempty"`
  268. // ServerResponse contains the HTTP response code and headers from the
  269. // server.
  270. googleapi.ServerResponse `json:"-"`
  271. // ForceSendFields is a list of field names (e.g. "Items") to
  272. // unconditionally include in API requests. By default, fields with
  273. // empty values are omitted from API requests. However, any non-pointer,
  274. // non-interface field appearing in ForceSendFields will be sent to the
  275. // server regardless of whether the field is empty or not. This may be
  276. // used to include empty fields in Patch requests.
  277. ForceSendFields []string `json:"-"`
  278. // NullFields is a list of field names (e.g. "Items") to include in API
  279. // requests with the JSON null value. By default, fields with empty
  280. // values are omitted from API requests. However, any field with an
  281. // empty value appearing in NullFields will be sent to the server as
  282. // null. It is an error if a field in this list has a non-empty value.
  283. // This may be used to include null fields in Patch requests.
  284. NullFields []string `json:"-"`
  285. }
  286. func (s *Tasks2) MarshalJSON() ([]byte, error) {
  287. type NoMethod Tasks2
  288. raw := NoMethod(*s)
  289. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  290. }
  291. // method id "taskqueue.taskqueues.get":
  292. type TaskqueuesGetCall struct {
  293. s *Service
  294. project string
  295. taskqueue string
  296. urlParams_ gensupport.URLParams
  297. ifNoneMatch_ string
  298. ctx_ context.Context
  299. header_ http.Header
  300. }
  301. // Get: Get detailed information about a TaskQueue.
  302. func (r *TaskqueuesService) Get(project string, taskqueue string) *TaskqueuesGetCall {
  303. c := &TaskqueuesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  304. c.project = project
  305. c.taskqueue = taskqueue
  306. return c
  307. }
  308. // GetStats sets the optional parameter "getStats": Whether to get
  309. // stats.
  310. func (c *TaskqueuesGetCall) GetStats(getStats bool) *TaskqueuesGetCall {
  311. c.urlParams_.Set("getStats", fmt.Sprint(getStats))
  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 *TaskqueuesGetCall) Fields(s ...googleapi.Field) *TaskqueuesGetCall {
  318. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  319. return c
  320. }
  321. // IfNoneMatch sets the optional parameter which makes the operation
  322. // fail if the object's ETag matches the given value. This is useful for
  323. // getting updates only after the object has changed since the last
  324. // request. Use googleapi.IsNotModified to check whether the response
  325. // error from Do is the result of In-None-Match.
  326. func (c *TaskqueuesGetCall) IfNoneMatch(entityTag string) *TaskqueuesGetCall {
  327. c.ifNoneMatch_ = entityTag
  328. return c
  329. }
  330. // Context sets the context to be used in this call's Do method. Any
  331. // pending HTTP request will be aborted if the provided context is
  332. // canceled.
  333. func (c *TaskqueuesGetCall) Context(ctx context.Context) *TaskqueuesGetCall {
  334. c.ctx_ = ctx
  335. return c
  336. }
  337. // Header returns an http.Header that can be modified by the caller to
  338. // add HTTP headers to the request.
  339. func (c *TaskqueuesGetCall) Header() http.Header {
  340. if c.header_ == nil {
  341. c.header_ = make(http.Header)
  342. }
  343. return c.header_
  344. }
  345. func (c *TaskqueuesGetCall) doRequest(alt string) (*http.Response, error) {
  346. reqHeaders := make(http.Header)
  347. for k, v := range c.header_ {
  348. reqHeaders[k] = v
  349. }
  350. reqHeaders.Set("User-Agent", c.s.userAgent())
  351. if c.ifNoneMatch_ != "" {
  352. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  353. }
  354. var body io.Reader = nil
  355. c.urlParams_.Set("alt", alt)
  356. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}")
  357. urls += "?" + c.urlParams_.Encode()
  358. req, _ := http.NewRequest("GET", urls, body)
  359. req.Header = reqHeaders
  360. googleapi.Expand(req.URL, map[string]string{
  361. "project": c.project,
  362. "taskqueue": c.taskqueue,
  363. })
  364. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  365. }
  366. // Do executes the "taskqueue.taskqueues.get" call.
  367. // Exactly one of *TaskQueue or error will be non-nil. Any non-2xx
  368. // status code is an error. Response headers are in either
  369. // *TaskQueue.ServerResponse.Header or (if a response was returned at
  370. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  371. // to check whether the returned error was because
  372. // http.StatusNotModified was returned.
  373. func (c *TaskqueuesGetCall) Do(opts ...googleapi.CallOption) (*TaskQueue, error) {
  374. gensupport.SetOptions(c.urlParams_, opts...)
  375. res, err := c.doRequest("json")
  376. if res != nil && res.StatusCode == http.StatusNotModified {
  377. if res.Body != nil {
  378. res.Body.Close()
  379. }
  380. return nil, &googleapi.Error{
  381. Code: res.StatusCode,
  382. Header: res.Header,
  383. }
  384. }
  385. if err != nil {
  386. return nil, err
  387. }
  388. defer googleapi.CloseBody(res)
  389. if err := googleapi.CheckResponse(res); err != nil {
  390. return nil, err
  391. }
  392. ret := &TaskQueue{
  393. ServerResponse: googleapi.ServerResponse{
  394. Header: res.Header,
  395. HTTPStatusCode: res.StatusCode,
  396. },
  397. }
  398. target := &ret
  399. if err := gensupport.DecodeResponse(target, res); err != nil {
  400. return nil, err
  401. }
  402. return ret, nil
  403. // {
  404. // "description": "Get detailed information about a TaskQueue.",
  405. // "httpMethod": "GET",
  406. // "id": "taskqueue.taskqueues.get",
  407. // "parameterOrder": [
  408. // "project",
  409. // "taskqueue"
  410. // ],
  411. // "parameters": {
  412. // "getStats": {
  413. // "description": "Whether to get stats. Optional.",
  414. // "location": "query",
  415. // "type": "boolean"
  416. // },
  417. // "project": {
  418. // "description": "The project under which the queue lies.",
  419. // "location": "path",
  420. // "required": true,
  421. // "type": "string"
  422. // },
  423. // "taskqueue": {
  424. // "description": "The id of the taskqueue to get the properties of.",
  425. // "location": "path",
  426. // "required": true,
  427. // "type": "string"
  428. // }
  429. // },
  430. // "path": "{project}/taskqueues/{taskqueue}",
  431. // "response": {
  432. // "$ref": "TaskQueue"
  433. // },
  434. // "scopes": [
  435. // "https://www.googleapis.com/auth/taskqueue",
  436. // "https://www.googleapis.com/auth/taskqueue.consumer"
  437. // ]
  438. // }
  439. }
  440. // method id "taskqueue.tasks.delete":
  441. type TasksDeleteCall struct {
  442. s *Service
  443. project string
  444. taskqueue string
  445. task string
  446. urlParams_ gensupport.URLParams
  447. ctx_ context.Context
  448. header_ http.Header
  449. }
  450. // Delete: Delete a task from a TaskQueue.
  451. func (r *TasksService) Delete(project string, taskqueue string, task string) *TasksDeleteCall {
  452. c := &TasksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  453. c.project = project
  454. c.taskqueue = taskqueue
  455. c.task = task
  456. return c
  457. }
  458. // Fields allows partial responses to be retrieved. See
  459. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  460. // for more information.
  461. func (c *TasksDeleteCall) Fields(s ...googleapi.Field) *TasksDeleteCall {
  462. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  463. return c
  464. }
  465. // Context sets the context to be used in this call's Do method. Any
  466. // pending HTTP request will be aborted if the provided context is
  467. // canceled.
  468. func (c *TasksDeleteCall) Context(ctx context.Context) *TasksDeleteCall {
  469. c.ctx_ = ctx
  470. return c
  471. }
  472. // Header returns an http.Header that can be modified by the caller to
  473. // add HTTP headers to the request.
  474. func (c *TasksDeleteCall) Header() http.Header {
  475. if c.header_ == nil {
  476. c.header_ = make(http.Header)
  477. }
  478. return c.header_
  479. }
  480. func (c *TasksDeleteCall) doRequest(alt string) (*http.Response, error) {
  481. reqHeaders := make(http.Header)
  482. for k, v := range c.header_ {
  483. reqHeaders[k] = v
  484. }
  485. reqHeaders.Set("User-Agent", c.s.userAgent())
  486. var body io.Reader = nil
  487. c.urlParams_.Set("alt", alt)
  488. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
  489. urls += "?" + c.urlParams_.Encode()
  490. req, _ := http.NewRequest("DELETE", urls, body)
  491. req.Header = reqHeaders
  492. googleapi.Expand(req.URL, map[string]string{
  493. "project": c.project,
  494. "taskqueue": c.taskqueue,
  495. "task": c.task,
  496. })
  497. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  498. }
  499. // Do executes the "taskqueue.tasks.delete" call.
  500. func (c *TasksDeleteCall) Do(opts ...googleapi.CallOption) error {
  501. gensupport.SetOptions(c.urlParams_, opts...)
  502. res, err := c.doRequest("json")
  503. if err != nil {
  504. return err
  505. }
  506. defer googleapi.CloseBody(res)
  507. if err := googleapi.CheckResponse(res); err != nil {
  508. return err
  509. }
  510. return nil
  511. // {
  512. // "description": "Delete a task from a TaskQueue.",
  513. // "httpMethod": "DELETE",
  514. // "id": "taskqueue.tasks.delete",
  515. // "parameterOrder": [
  516. // "project",
  517. // "taskqueue",
  518. // "task"
  519. // ],
  520. // "parameters": {
  521. // "project": {
  522. // "description": "The project under which the queue lies.",
  523. // "location": "path",
  524. // "required": true,
  525. // "type": "string"
  526. // },
  527. // "task": {
  528. // "description": "The id of the task to delete.",
  529. // "location": "path",
  530. // "required": true,
  531. // "type": "string"
  532. // },
  533. // "taskqueue": {
  534. // "description": "The taskqueue to delete a task from.",
  535. // "location": "path",
  536. // "required": true,
  537. // "type": "string"
  538. // }
  539. // },
  540. // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
  541. // "scopes": [
  542. // "https://www.googleapis.com/auth/taskqueue",
  543. // "https://www.googleapis.com/auth/taskqueue.consumer"
  544. // ]
  545. // }
  546. }
  547. // method id "taskqueue.tasks.get":
  548. type TasksGetCall struct {
  549. s *Service
  550. project string
  551. taskqueue string
  552. task string
  553. urlParams_ gensupport.URLParams
  554. ifNoneMatch_ string
  555. ctx_ context.Context
  556. header_ http.Header
  557. }
  558. // Get: Get a particular task from a TaskQueue.
  559. func (r *TasksService) Get(project string, taskqueue string, task string) *TasksGetCall {
  560. c := &TasksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  561. c.project = project
  562. c.taskqueue = taskqueue
  563. c.task = task
  564. return c
  565. }
  566. // Fields allows partial responses to be retrieved. See
  567. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  568. // for more information.
  569. func (c *TasksGetCall) Fields(s ...googleapi.Field) *TasksGetCall {
  570. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  571. return c
  572. }
  573. // IfNoneMatch sets the optional parameter which makes the operation
  574. // fail if the object's ETag matches the given value. This is useful for
  575. // getting updates only after the object has changed since the last
  576. // request. Use googleapi.IsNotModified to check whether the response
  577. // error from Do is the result of In-None-Match.
  578. func (c *TasksGetCall) IfNoneMatch(entityTag string) *TasksGetCall {
  579. c.ifNoneMatch_ = entityTag
  580. return c
  581. }
  582. // Context sets the context to be used in this call's Do method. Any
  583. // pending HTTP request will be aborted if the provided context is
  584. // canceled.
  585. func (c *TasksGetCall) Context(ctx context.Context) *TasksGetCall {
  586. c.ctx_ = ctx
  587. return c
  588. }
  589. // Header returns an http.Header that can be modified by the caller to
  590. // add HTTP headers to the request.
  591. func (c *TasksGetCall) Header() http.Header {
  592. if c.header_ == nil {
  593. c.header_ = make(http.Header)
  594. }
  595. return c.header_
  596. }
  597. func (c *TasksGetCall) doRequest(alt string) (*http.Response, error) {
  598. reqHeaders := make(http.Header)
  599. for k, v := range c.header_ {
  600. reqHeaders[k] = v
  601. }
  602. reqHeaders.Set("User-Agent", c.s.userAgent())
  603. if c.ifNoneMatch_ != "" {
  604. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  605. }
  606. var body io.Reader = nil
  607. c.urlParams_.Set("alt", alt)
  608. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
  609. urls += "?" + c.urlParams_.Encode()
  610. req, _ := http.NewRequest("GET", urls, body)
  611. req.Header = reqHeaders
  612. googleapi.Expand(req.URL, map[string]string{
  613. "project": c.project,
  614. "taskqueue": c.taskqueue,
  615. "task": c.task,
  616. })
  617. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  618. }
  619. // Do executes the "taskqueue.tasks.get" call.
  620. // Exactly one of *Task or error will be non-nil. Any non-2xx status
  621. // code is an error. Response headers are in either
  622. // *Task.ServerResponse.Header or (if a response was returned at all) in
  623. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  624. // whether the returned error was because http.StatusNotModified was
  625. // returned.
  626. func (c *TasksGetCall) Do(opts ...googleapi.CallOption) (*Task, error) {
  627. gensupport.SetOptions(c.urlParams_, opts...)
  628. res, err := c.doRequest("json")
  629. if res != nil && res.StatusCode == http.StatusNotModified {
  630. if res.Body != nil {
  631. res.Body.Close()
  632. }
  633. return nil, &googleapi.Error{
  634. Code: res.StatusCode,
  635. Header: res.Header,
  636. }
  637. }
  638. if err != nil {
  639. return nil, err
  640. }
  641. defer googleapi.CloseBody(res)
  642. if err := googleapi.CheckResponse(res); err != nil {
  643. return nil, err
  644. }
  645. ret := &Task{
  646. ServerResponse: googleapi.ServerResponse{
  647. Header: res.Header,
  648. HTTPStatusCode: res.StatusCode,
  649. },
  650. }
  651. target := &ret
  652. if err := gensupport.DecodeResponse(target, res); err != nil {
  653. return nil, err
  654. }
  655. return ret, nil
  656. // {
  657. // "description": "Get a particular task from a TaskQueue.",
  658. // "httpMethod": "GET",
  659. // "id": "taskqueue.tasks.get",
  660. // "parameterOrder": [
  661. // "project",
  662. // "taskqueue",
  663. // "task"
  664. // ],
  665. // "parameters": {
  666. // "project": {
  667. // "description": "The project under which the queue lies.",
  668. // "location": "path",
  669. // "required": true,
  670. // "type": "string"
  671. // },
  672. // "task": {
  673. // "description": "The task to get properties of.",
  674. // "location": "path",
  675. // "required": true,
  676. // "type": "string"
  677. // },
  678. // "taskqueue": {
  679. // "description": "The taskqueue in which the task belongs.",
  680. // "location": "path",
  681. // "required": true,
  682. // "type": "string"
  683. // }
  684. // },
  685. // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
  686. // "response": {
  687. // "$ref": "Task"
  688. // },
  689. // "scopes": [
  690. // "https://www.googleapis.com/auth/taskqueue",
  691. // "https://www.googleapis.com/auth/taskqueue.consumer"
  692. // ]
  693. // }
  694. }
  695. // method id "taskqueue.tasks.insert":
  696. type TasksInsertCall struct {
  697. s *Service
  698. project string
  699. taskqueue string
  700. task *Task
  701. urlParams_ gensupport.URLParams
  702. ctx_ context.Context
  703. header_ http.Header
  704. }
  705. // Insert: Insert a new task in a TaskQueue
  706. func (r *TasksService) Insert(project string, taskqueue string, task *Task) *TasksInsertCall {
  707. c := &TasksInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  708. c.project = project
  709. c.taskqueue = taskqueue
  710. c.task = task
  711. return c
  712. }
  713. // Fields allows partial responses to be retrieved. See
  714. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  715. // for more information.
  716. func (c *TasksInsertCall) Fields(s ...googleapi.Field) *TasksInsertCall {
  717. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  718. return c
  719. }
  720. // Context sets the context to be used in this call's Do method. Any
  721. // pending HTTP request will be aborted if the provided context is
  722. // canceled.
  723. func (c *TasksInsertCall) Context(ctx context.Context) *TasksInsertCall {
  724. c.ctx_ = ctx
  725. return c
  726. }
  727. // Header returns an http.Header that can be modified by the caller to
  728. // add HTTP headers to the request.
  729. func (c *TasksInsertCall) Header() http.Header {
  730. if c.header_ == nil {
  731. c.header_ = make(http.Header)
  732. }
  733. return c.header_
  734. }
  735. func (c *TasksInsertCall) doRequest(alt string) (*http.Response, error) {
  736. reqHeaders := make(http.Header)
  737. for k, v := range c.header_ {
  738. reqHeaders[k] = v
  739. }
  740. reqHeaders.Set("User-Agent", c.s.userAgent())
  741. var body io.Reader = nil
  742. body, err := googleapi.WithoutDataWrapper.JSONReader(c.task)
  743. if err != nil {
  744. return nil, err
  745. }
  746. reqHeaders.Set("Content-Type", "application/json")
  747. c.urlParams_.Set("alt", alt)
  748. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks")
  749. urls += "?" + c.urlParams_.Encode()
  750. req, _ := http.NewRequest("POST", urls, body)
  751. req.Header = reqHeaders
  752. googleapi.Expand(req.URL, map[string]string{
  753. "project": c.project,
  754. "taskqueue": c.taskqueue,
  755. })
  756. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  757. }
  758. // Do executes the "taskqueue.tasks.insert" call.
  759. // Exactly one of *Task or error will be non-nil. Any non-2xx status
  760. // code is an error. Response headers are in either
  761. // *Task.ServerResponse.Header or (if a response was returned at all) in
  762. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  763. // whether the returned error was because http.StatusNotModified was
  764. // returned.
  765. func (c *TasksInsertCall) Do(opts ...googleapi.CallOption) (*Task, error) {
  766. gensupport.SetOptions(c.urlParams_, opts...)
  767. res, err := c.doRequest("json")
  768. if res != nil && res.StatusCode == http.StatusNotModified {
  769. if res.Body != nil {
  770. res.Body.Close()
  771. }
  772. return nil, &googleapi.Error{
  773. Code: res.StatusCode,
  774. Header: res.Header,
  775. }
  776. }
  777. if err != nil {
  778. return nil, err
  779. }
  780. defer googleapi.CloseBody(res)
  781. if err := googleapi.CheckResponse(res); err != nil {
  782. return nil, err
  783. }
  784. ret := &Task{
  785. ServerResponse: googleapi.ServerResponse{
  786. Header: res.Header,
  787. HTTPStatusCode: res.StatusCode,
  788. },
  789. }
  790. target := &ret
  791. if err := gensupport.DecodeResponse(target, res); err != nil {
  792. return nil, err
  793. }
  794. return ret, nil
  795. // {
  796. // "description": "Insert a new task in a TaskQueue",
  797. // "httpMethod": "POST",
  798. // "id": "taskqueue.tasks.insert",
  799. // "parameterOrder": [
  800. // "project",
  801. // "taskqueue"
  802. // ],
  803. // "parameters": {
  804. // "project": {
  805. // "description": "The project under which the queue lies",
  806. // "location": "path",
  807. // "required": true,
  808. // "type": "string"
  809. // },
  810. // "taskqueue": {
  811. // "description": "The taskqueue to insert the task into",
  812. // "location": "path",
  813. // "required": true,
  814. // "type": "string"
  815. // }
  816. // },
  817. // "path": "{project}/taskqueues/{taskqueue}/tasks",
  818. // "request": {
  819. // "$ref": "Task"
  820. // },
  821. // "response": {
  822. // "$ref": "Task"
  823. // },
  824. // "scopes": [
  825. // "https://www.googleapis.com/auth/taskqueue",
  826. // "https://www.googleapis.com/auth/taskqueue.consumer"
  827. // ]
  828. // }
  829. }
  830. // method id "taskqueue.tasks.lease":
  831. type TasksLeaseCall struct {
  832. s *Service
  833. project string
  834. taskqueue string
  835. urlParams_ gensupport.URLParams
  836. ctx_ context.Context
  837. header_ http.Header
  838. }
  839. // Lease: Lease 1 or more tasks from a TaskQueue.
  840. func (r *TasksService) Lease(project string, taskqueue string, numTasks int64, leaseSecs int64) *TasksLeaseCall {
  841. c := &TasksLeaseCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  842. c.project = project
  843. c.taskqueue = taskqueue
  844. c.urlParams_.Set("numTasks", fmt.Sprint(numTasks))
  845. c.urlParams_.Set("leaseSecs", fmt.Sprint(leaseSecs))
  846. return c
  847. }
  848. // GroupByTag sets the optional parameter "groupByTag": When true, all
  849. // returned tasks will have the same tag
  850. func (c *TasksLeaseCall) GroupByTag(groupByTag bool) *TasksLeaseCall {
  851. c.urlParams_.Set("groupByTag", fmt.Sprint(groupByTag))
  852. return c
  853. }
  854. // Tag sets the optional parameter "tag": The tag allowed for tasks in
  855. // the response. Must only be specified if group_by_tag is true. If
  856. // group_by_tag is true and tag is not specified the tag will be that of
  857. // the oldest task by eta, i.e. the first available tag
  858. func (c *TasksLeaseCall) Tag(tag string) *TasksLeaseCall {
  859. c.urlParams_.Set("tag", tag)
  860. return c
  861. }
  862. // Fields allows partial responses to be retrieved. See
  863. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  864. // for more information.
  865. func (c *TasksLeaseCall) Fields(s ...googleapi.Field) *TasksLeaseCall {
  866. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  867. return c
  868. }
  869. // Context sets the context to be used in this call's Do method. Any
  870. // pending HTTP request will be aborted if the provided context is
  871. // canceled.
  872. func (c *TasksLeaseCall) Context(ctx context.Context) *TasksLeaseCall {
  873. c.ctx_ = ctx
  874. return c
  875. }
  876. // Header returns an http.Header that can be modified by the caller to
  877. // add HTTP headers to the request.
  878. func (c *TasksLeaseCall) Header() http.Header {
  879. if c.header_ == nil {
  880. c.header_ = make(http.Header)
  881. }
  882. return c.header_
  883. }
  884. func (c *TasksLeaseCall) doRequest(alt string) (*http.Response, error) {
  885. reqHeaders := make(http.Header)
  886. for k, v := range c.header_ {
  887. reqHeaders[k] = v
  888. }
  889. reqHeaders.Set("User-Agent", c.s.userAgent())
  890. var body io.Reader = nil
  891. c.urlParams_.Set("alt", alt)
  892. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/lease")
  893. urls += "?" + c.urlParams_.Encode()
  894. req, _ := http.NewRequest("POST", 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.lease" call.
  903. // Exactly one of *Tasks or error will be non-nil. Any non-2xx status
  904. // code is an error. Response headers are in either
  905. // *Tasks.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 *TasksLeaseCall) Do(opts ...googleapi.CallOption) (*Tasks, 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 := &Tasks{
  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": "Lease 1 or more tasks from a TaskQueue.",
  941. // "httpMethod": "POST",
  942. // "id": "taskqueue.tasks.lease",
  943. // "parameterOrder": [
  944. // "project",
  945. // "taskqueue",
  946. // "numTasks",
  947. // "leaseSecs"
  948. // ],
  949. // "parameters": {
  950. // "groupByTag": {
  951. // "description": "When true, all returned tasks will have the same tag",
  952. // "location": "query",
  953. // "type": "boolean"
  954. // },
  955. // "leaseSecs": {
  956. // "description": "The lease in seconds.",
  957. // "format": "int32",
  958. // "location": "query",
  959. // "required": true,
  960. // "type": "integer"
  961. // },
  962. // "numTasks": {
  963. // "description": "The number of tasks to lease.",
  964. // "format": "int32",
  965. // "location": "query",
  966. // "required": true,
  967. // "type": "integer"
  968. // },
  969. // "project": {
  970. // "description": "The project under which the queue lies.",
  971. // "location": "path",
  972. // "required": true,
  973. // "type": "string"
  974. // },
  975. // "tag": {
  976. // "description": "The tag allowed for tasks in the response. Must only be specified if group_by_tag is true. If group_by_tag is true and tag is not specified the tag will be that of the oldest task by eta, i.e. the first available tag",
  977. // "location": "query",
  978. // "type": "string"
  979. // },
  980. // "taskqueue": {
  981. // "description": "The taskqueue to lease a task from.",
  982. // "location": "path",
  983. // "required": true,
  984. // "type": "string"
  985. // }
  986. // },
  987. // "path": "{project}/taskqueues/{taskqueue}/tasks/lease",
  988. // "response": {
  989. // "$ref": "Tasks"
  990. // },
  991. // "scopes": [
  992. // "https://www.googleapis.com/auth/taskqueue",
  993. // "https://www.googleapis.com/auth/taskqueue.consumer"
  994. // ]
  995. // }
  996. }
  997. // method id "taskqueue.tasks.list":
  998. type TasksListCall struct {
  999. s *Service
  1000. project string
  1001. taskqueue string
  1002. urlParams_ gensupport.URLParams
  1003. ifNoneMatch_ string
  1004. ctx_ context.Context
  1005. header_ http.Header
  1006. }
  1007. // List: List Tasks in a TaskQueue
  1008. func (r *TasksService) List(project string, taskqueue string) *TasksListCall {
  1009. c := &TasksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1010. c.project = project
  1011. c.taskqueue = taskqueue
  1012. return c
  1013. }
  1014. // Fields allows partial responses to be retrieved. See
  1015. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1016. // for more information.
  1017. func (c *TasksListCall) Fields(s ...googleapi.Field) *TasksListCall {
  1018. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1019. return c
  1020. }
  1021. // IfNoneMatch sets the optional parameter which makes the operation
  1022. // fail if the object's ETag matches the given value. This is useful for
  1023. // getting updates only after the object has changed since the last
  1024. // request. Use googleapi.IsNotModified to check whether the response
  1025. // error from Do is the result of In-None-Match.
  1026. func (c *TasksListCall) IfNoneMatch(entityTag string) *TasksListCall {
  1027. c.ifNoneMatch_ = entityTag
  1028. return c
  1029. }
  1030. // Context sets the context to be used in this call's Do method. Any
  1031. // pending HTTP request will be aborted if the provided context is
  1032. // canceled.
  1033. func (c *TasksListCall) Context(ctx context.Context) *TasksListCall {
  1034. c.ctx_ = ctx
  1035. return c
  1036. }
  1037. // Header returns an http.Header that can be modified by the caller to
  1038. // add HTTP headers to the request.
  1039. func (c *TasksListCall) Header() http.Header {
  1040. if c.header_ == nil {
  1041. c.header_ = make(http.Header)
  1042. }
  1043. return c.header_
  1044. }
  1045. func (c *TasksListCall) doRequest(alt string) (*http.Response, error) {
  1046. reqHeaders := make(http.Header)
  1047. for k, v := range c.header_ {
  1048. reqHeaders[k] = v
  1049. }
  1050. reqHeaders.Set("User-Agent", c.s.userAgent())
  1051. if c.ifNoneMatch_ != "" {
  1052. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1053. }
  1054. var body io.Reader = nil
  1055. c.urlParams_.Set("alt", alt)
  1056. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks")
  1057. urls += "?" + c.urlParams_.Encode()
  1058. req, _ := http.NewRequest("GET", urls, body)
  1059. req.Header = reqHeaders
  1060. googleapi.Expand(req.URL, map[string]string{
  1061. "project": c.project,
  1062. "taskqueue": c.taskqueue,
  1063. })
  1064. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1065. }
  1066. // Do executes the "taskqueue.tasks.list" call.
  1067. // Exactly one of *Tasks2 or error will be non-nil. Any non-2xx status
  1068. // code is an error. Response headers are in either
  1069. // *Tasks2.ServerResponse.Header or (if a response was returned at all)
  1070. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1071. // check whether the returned error was because http.StatusNotModified
  1072. // was returned.
  1073. func (c *TasksListCall) Do(opts ...googleapi.CallOption) (*Tasks2, error) {
  1074. gensupport.SetOptions(c.urlParams_, opts...)
  1075. res, err := c.doRequest("json")
  1076. if res != nil && res.StatusCode == http.StatusNotModified {
  1077. if res.Body != nil {
  1078. res.Body.Close()
  1079. }
  1080. return nil, &googleapi.Error{
  1081. Code: res.StatusCode,
  1082. Header: res.Header,
  1083. }
  1084. }
  1085. if err != nil {
  1086. return nil, err
  1087. }
  1088. defer googleapi.CloseBody(res)
  1089. if err := googleapi.CheckResponse(res); err != nil {
  1090. return nil, err
  1091. }
  1092. ret := &Tasks2{
  1093. ServerResponse: googleapi.ServerResponse{
  1094. Header: res.Header,
  1095. HTTPStatusCode: res.StatusCode,
  1096. },
  1097. }
  1098. target := &ret
  1099. if err := gensupport.DecodeResponse(target, res); err != nil {
  1100. return nil, err
  1101. }
  1102. return ret, nil
  1103. // {
  1104. // "description": "List Tasks in a TaskQueue",
  1105. // "httpMethod": "GET",
  1106. // "id": "taskqueue.tasks.list",
  1107. // "parameterOrder": [
  1108. // "project",
  1109. // "taskqueue"
  1110. // ],
  1111. // "parameters": {
  1112. // "project": {
  1113. // "description": "The project under which the queue lies.",
  1114. // "location": "path",
  1115. // "required": true,
  1116. // "type": "string"
  1117. // },
  1118. // "taskqueue": {
  1119. // "description": "The id of the taskqueue to list tasks from.",
  1120. // "location": "path",
  1121. // "required": true,
  1122. // "type": "string"
  1123. // }
  1124. // },
  1125. // "path": "{project}/taskqueues/{taskqueue}/tasks",
  1126. // "response": {
  1127. // "$ref": "Tasks2"
  1128. // },
  1129. // "scopes": [
  1130. // "https://www.googleapis.com/auth/taskqueue",
  1131. // "https://www.googleapis.com/auth/taskqueue.consumer"
  1132. // ]
  1133. // }
  1134. }
  1135. // method id "taskqueue.tasks.patch":
  1136. type TasksPatchCall struct {
  1137. s *Service
  1138. project string
  1139. taskqueue string
  1140. task string
  1141. task2 *Task
  1142. urlParams_ gensupport.URLParams
  1143. ctx_ context.Context
  1144. header_ http.Header
  1145. }
  1146. // Patch: Update tasks that are leased out of a TaskQueue. This method
  1147. // supports patch semantics.
  1148. func (r *TasksService) Patch(project string, taskqueue string, task string, newLeaseSeconds int64, task2 *Task) *TasksPatchCall {
  1149. c := &TasksPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1150. c.project = project
  1151. c.taskqueue = taskqueue
  1152. c.task = task
  1153. c.urlParams_.Set("newLeaseSeconds", fmt.Sprint(newLeaseSeconds))
  1154. c.task2 = task2
  1155. return c
  1156. }
  1157. // Fields allows partial responses to be retrieved. See
  1158. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1159. // for more information.
  1160. func (c *TasksPatchCall) Fields(s ...googleapi.Field) *TasksPatchCall {
  1161. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1162. return c
  1163. }
  1164. // Context sets the context to be used in this call's Do method. Any
  1165. // pending HTTP request will be aborted if the provided context is
  1166. // canceled.
  1167. func (c *TasksPatchCall) Context(ctx context.Context) *TasksPatchCall {
  1168. c.ctx_ = ctx
  1169. return c
  1170. }
  1171. // Header returns an http.Header that can be modified by the caller to
  1172. // add HTTP headers to the request.
  1173. func (c *TasksPatchCall) Header() http.Header {
  1174. if c.header_ == nil {
  1175. c.header_ = make(http.Header)
  1176. }
  1177. return c.header_
  1178. }
  1179. func (c *TasksPatchCall) doRequest(alt string) (*http.Response, error) {
  1180. reqHeaders := make(http.Header)
  1181. for k, v := range c.header_ {
  1182. reqHeaders[k] = v
  1183. }
  1184. reqHeaders.Set("User-Agent", c.s.userAgent())
  1185. var body io.Reader = nil
  1186. body, err := googleapi.WithoutDataWrapper.JSONReader(c.task2)
  1187. if err != nil {
  1188. return nil, err
  1189. }
  1190. reqHeaders.Set("Content-Type", "application/json")
  1191. c.urlParams_.Set("alt", alt)
  1192. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
  1193. urls += "?" + c.urlParams_.Encode()
  1194. req, _ := http.NewRequest("PATCH", urls, body)
  1195. req.Header = reqHeaders
  1196. googleapi.Expand(req.URL, map[string]string{
  1197. "project": c.project,
  1198. "taskqueue": c.taskqueue,
  1199. "task": c.task,
  1200. })
  1201. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1202. }
  1203. // Do executes the "taskqueue.tasks.patch" call.
  1204. // Exactly one of *Task or error will be non-nil. Any non-2xx status
  1205. // code is an error. Response headers are in either
  1206. // *Task.ServerResponse.Header or (if a response was returned at all) in
  1207. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1208. // whether the returned error was because http.StatusNotModified was
  1209. // returned.
  1210. func (c *TasksPatchCall) Do(opts ...googleapi.CallOption) (*Task, error) {
  1211. gensupport.SetOptions(c.urlParams_, opts...)
  1212. res, err := c.doRequest("json")
  1213. if res != nil && res.StatusCode == http.StatusNotModified {
  1214. if res.Body != nil {
  1215. res.Body.Close()
  1216. }
  1217. return nil, &googleapi.Error{
  1218. Code: res.StatusCode,
  1219. Header: res.Header,
  1220. }
  1221. }
  1222. if err != nil {
  1223. return nil, err
  1224. }
  1225. defer googleapi.CloseBody(res)
  1226. if err := googleapi.CheckResponse(res); err != nil {
  1227. return nil, err
  1228. }
  1229. ret := &Task{
  1230. ServerResponse: googleapi.ServerResponse{
  1231. Header: res.Header,
  1232. HTTPStatusCode: res.StatusCode,
  1233. },
  1234. }
  1235. target := &ret
  1236. if err := gensupport.DecodeResponse(target, res); err != nil {
  1237. return nil, err
  1238. }
  1239. return ret, nil
  1240. // {
  1241. // "description": "Update tasks that are leased out of a TaskQueue. This method supports patch semantics.",
  1242. // "httpMethod": "PATCH",
  1243. // "id": "taskqueue.tasks.patch",
  1244. // "parameterOrder": [
  1245. // "project",
  1246. // "taskqueue",
  1247. // "task",
  1248. // "newLeaseSeconds"
  1249. // ],
  1250. // "parameters": {
  1251. // "newLeaseSeconds": {
  1252. // "description": "The new lease in seconds.",
  1253. // "format": "int32",
  1254. // "location": "query",
  1255. // "required": true,
  1256. // "type": "integer"
  1257. // },
  1258. // "project": {
  1259. // "description": "The project under which the queue lies.",
  1260. // "location": "path",
  1261. // "required": true,
  1262. // "type": "string"
  1263. // },
  1264. // "task": {
  1265. // "location": "path",
  1266. // "required": true,
  1267. // "type": "string"
  1268. // },
  1269. // "taskqueue": {
  1270. // "location": "path",
  1271. // "required": true,
  1272. // "type": "string"
  1273. // }
  1274. // },
  1275. // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
  1276. // "request": {
  1277. // "$ref": "Task"
  1278. // },
  1279. // "response": {
  1280. // "$ref": "Task"
  1281. // },
  1282. // "scopes": [
  1283. // "https://www.googleapis.com/auth/taskqueue",
  1284. // "https://www.googleapis.com/auth/taskqueue.consumer"
  1285. // ]
  1286. // }
  1287. }
  1288. // method id "taskqueue.tasks.update":
  1289. type TasksUpdateCall struct {
  1290. s *Service
  1291. project string
  1292. taskqueue string
  1293. task string
  1294. task2 *Task
  1295. urlParams_ gensupport.URLParams
  1296. ctx_ context.Context
  1297. header_ http.Header
  1298. }
  1299. // Update: Update tasks that are leased out of a TaskQueue.
  1300. func (r *TasksService) Update(project string, taskqueue string, task string, newLeaseSeconds int64, task2 *Task) *TasksUpdateCall {
  1301. c := &TasksUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1302. c.project = project
  1303. c.taskqueue = taskqueue
  1304. c.task = task
  1305. c.urlParams_.Set("newLeaseSeconds", fmt.Sprint(newLeaseSeconds))
  1306. c.task2 = task2
  1307. return c
  1308. }
  1309. // Fields allows partial responses to be retrieved. See
  1310. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1311. // for more information.
  1312. func (c *TasksUpdateCall) Fields(s ...googleapi.Field) *TasksUpdateCall {
  1313. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1314. return c
  1315. }
  1316. // Context sets the context to be used in this call's Do method. Any
  1317. // pending HTTP request will be aborted if the provided context is
  1318. // canceled.
  1319. func (c *TasksUpdateCall) Context(ctx context.Context) *TasksUpdateCall {
  1320. c.ctx_ = ctx
  1321. return c
  1322. }
  1323. // Header returns an http.Header that can be modified by the caller to
  1324. // add HTTP headers to the request.
  1325. func (c *TasksUpdateCall) Header() http.Header {
  1326. if c.header_ == nil {
  1327. c.header_ = make(http.Header)
  1328. }
  1329. return c.header_
  1330. }
  1331. func (c *TasksUpdateCall) doRequest(alt string) (*http.Response, error) {
  1332. reqHeaders := make(http.Header)
  1333. for k, v := range c.header_ {
  1334. reqHeaders[k] = v
  1335. }
  1336. reqHeaders.Set("User-Agent", c.s.userAgent())
  1337. var body io.Reader = nil
  1338. body, err := googleapi.WithoutDataWrapper.JSONReader(c.task2)
  1339. if err != nil {
  1340. return nil, err
  1341. }
  1342. reqHeaders.Set("Content-Type", "application/json")
  1343. c.urlParams_.Set("alt", alt)
  1344. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
  1345. urls += "?" + c.urlParams_.Encode()
  1346. req, _ := http.NewRequest("POST", urls, body)
  1347. req.Header = reqHeaders
  1348. googleapi.Expand(req.URL, map[string]string{
  1349. "project": c.project,
  1350. "taskqueue": c.taskqueue,
  1351. "task": c.task,
  1352. })
  1353. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1354. }
  1355. // Do executes the "taskqueue.tasks.update" call.
  1356. // Exactly one of *Task or error will be non-nil. Any non-2xx status
  1357. // code is an error. Response headers are in either
  1358. // *Task.ServerResponse.Header or (if a response was returned at all) in
  1359. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1360. // whether the returned error was because http.StatusNotModified was
  1361. // returned.
  1362. func (c *TasksUpdateCall) Do(opts ...googleapi.CallOption) (*Task, error) {
  1363. gensupport.SetOptions(c.urlParams_, opts...)
  1364. res, err := c.doRequest("json")
  1365. if res != nil && res.StatusCode == http.StatusNotModified {
  1366. if res.Body != nil {
  1367. res.Body.Close()
  1368. }
  1369. return nil, &googleapi.Error{
  1370. Code: res.StatusCode,
  1371. Header: res.Header,
  1372. }
  1373. }
  1374. if err != nil {
  1375. return nil, err
  1376. }
  1377. defer googleapi.CloseBody(res)
  1378. if err := googleapi.CheckResponse(res); err != nil {
  1379. return nil, err
  1380. }
  1381. ret := &Task{
  1382. ServerResponse: googleapi.ServerResponse{
  1383. Header: res.Header,
  1384. HTTPStatusCode: res.StatusCode,
  1385. },
  1386. }
  1387. target := &ret
  1388. if err := gensupport.DecodeResponse(target, res); err != nil {
  1389. return nil, err
  1390. }
  1391. return ret, nil
  1392. // {
  1393. // "description": "Update tasks that are leased out of a TaskQueue.",
  1394. // "httpMethod": "POST",
  1395. // "id": "taskqueue.tasks.update",
  1396. // "parameterOrder": [
  1397. // "project",
  1398. // "taskqueue",
  1399. // "task",
  1400. // "newLeaseSeconds"
  1401. // ],
  1402. // "parameters": {
  1403. // "newLeaseSeconds": {
  1404. // "description": "The new lease in seconds.",
  1405. // "format": "int32",
  1406. // "location": "query",
  1407. // "required": true,
  1408. // "type": "integer"
  1409. // },
  1410. // "project": {
  1411. // "description": "The project under which the queue lies.",
  1412. // "location": "path",
  1413. // "required": true,
  1414. // "type": "string"
  1415. // },
  1416. // "task": {
  1417. // "location": "path",
  1418. // "required": true,
  1419. // "type": "string"
  1420. // },
  1421. // "taskqueue": {
  1422. // "location": "path",
  1423. // "required": true,
  1424. // "type": "string"
  1425. // }
  1426. // },
  1427. // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
  1428. // "request": {
  1429. // "$ref": "Task"
  1430. // },
  1431. // "response": {
  1432. // "$ref": "Task"
  1433. // },
  1434. // "scopes": [
  1435. // "https://www.googleapis.com/auth/taskqueue",
  1436. // "https://www.googleapis.com/auth/taskqueue.consumer"
  1437. // ]
  1438. // }
  1439. }