taskqueue-gen.go 43 KB

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