123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963 |
- // Package taskqueue provides access to the TaskQueue API.
- //
- // See https://developers.google.com/appengine/docs/python/taskqueue/rest
- //
- // Usage example:
- //
- // import "google.golang.org/api/taskqueue/v1beta1"
- // ...
- // taskqueueService, err := taskqueue.New(oauthHttpClient)
- package taskqueue // import "google.golang.org/api/taskqueue/v1beta1"
- import (
- "bytes"
- "encoding/json"
- "errors"
- "fmt"
- context "golang.org/x/net/context"
- ctxhttp "golang.org/x/net/context/ctxhttp"
- gensupport "google.golang.org/api/gensupport"
- googleapi "google.golang.org/api/googleapi"
- "io"
- "net/http"
- "net/url"
- "strconv"
- "strings"
- )
- // Always reference these packages, just in case the auto-generated code
- // below doesn't.
- var _ = bytes.NewBuffer
- var _ = strconv.Itoa
- var _ = fmt.Sprintf
- var _ = json.NewDecoder
- var _ = io.Copy
- var _ = url.Parse
- var _ = gensupport.MarshalJSON
- var _ = googleapi.Version
- var _ = errors.New
- var _ = strings.Replace
- var _ = context.Canceled
- var _ = ctxhttp.Do
- const apiId = "taskqueue:v1beta1"
- const apiName = "taskqueue"
- const apiVersion = "v1beta1"
- const basePath = "https://www.googleapis.com/taskqueue/v1beta1/projects/"
- // OAuth2 scopes used by this API.
- const (
- // Manage your Tasks and Taskqueues
- TaskqueueScope = "https://www.googleapis.com/auth/taskqueue"
- // Consume Tasks from your Taskqueues
- TaskqueueConsumerScope = "https://www.googleapis.com/auth/taskqueue.consumer"
- )
- func New(client *http.Client) (*Service, error) {
- if client == nil {
- return nil, errors.New("client is nil")
- }
- s := &Service{client: client, BasePath: basePath}
- s.Taskqueues = NewTaskqueuesService(s)
- s.Tasks = NewTasksService(s)
- return s, nil
- }
- type Service struct {
- client *http.Client
- BasePath string // API endpoint base URL
- UserAgent string // optional additional User-Agent fragment
- Taskqueues *TaskqueuesService
- Tasks *TasksService
- }
- func (s *Service) userAgent() string {
- if s.UserAgent == "" {
- return googleapi.UserAgent
- }
- return googleapi.UserAgent + " " + s.UserAgent
- }
- func NewTaskqueuesService(s *Service) *TaskqueuesService {
- rs := &TaskqueuesService{s: s}
- return rs
- }
- type TaskqueuesService struct {
- s *Service
- }
- func NewTasksService(s *Service) *TasksService {
- rs := &TasksService{s: s}
- return rs
- }
- type TasksService struct {
- s *Service
- }
- type Task struct {
- // EnqueueTimestamp: Time (in seconds since the epoch) at which the task
- // was enqueued.
- EnqueueTimestamp int64 `json:"enqueueTimestamp,omitempty,string"`
- // Id: Name of the task.
- Id string `json:"id,omitempty"`
- // Kind: The kind of object returned, in this case set to task.
- Kind string `json:"kind,omitempty"`
- // LeaseTimestamp: Time (in seconds since the epoch) at which the task
- // lease will expire. This value is 0 if the task isnt currently leased
- // out to a worker.
- LeaseTimestamp int64 `json:"leaseTimestamp,omitempty,string"`
- // PayloadBase64: A bag of bytes which is the task payload. The payload
- // on the JSON side is always Base64 encoded.
- PayloadBase64 string `json:"payloadBase64,omitempty"`
- // QueueName: Name of the queue that the task is in.
- QueueName string `json:"queueName,omitempty"`
- // ServerResponse contains the HTTP response code and headers from the
- // server.
- googleapi.ServerResponse `json:"-"`
- // ForceSendFields is a list of field names (e.g. "EnqueueTimestamp") to
- // unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
- }
- func (s *Task) MarshalJSON() ([]byte, error) {
- type noMethod Task
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
- }
- type TaskQueue struct {
- // Acl: ACLs that are applicable to this TaskQueue object.
- Acl *TaskQueueAcl `json:"acl,omitempty"`
- // Id: Name of the taskqueue.
- Id string `json:"id,omitempty"`
- // Kind: The kind of REST object returned, in this case taskqueue.
- Kind string `json:"kind,omitempty"`
- // MaxLeases: The number of times we should lease out tasks before
- // giving up on them. If unset we lease them out forever until a worker
- // deletes the task.
- MaxLeases int64 `json:"maxLeases,omitempty"`
- // Stats: Statistics for the TaskQueue object in question.
- Stats *TaskQueueStats `json:"stats,omitempty"`
- // ServerResponse contains the HTTP response code and headers from the
- // server.
- googleapi.ServerResponse `json:"-"`
- // ForceSendFields is a list of field names (e.g. "Acl") to
- // unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
- }
- func (s *TaskQueue) MarshalJSON() ([]byte, error) {
- type noMethod TaskQueue
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
- }
- // TaskQueueAcl: ACLs that are applicable to this TaskQueue object.
- type TaskQueueAcl struct {
- // AdminEmails: Email addresses of users who are "admins" of the
- // TaskQueue. This means they can control the queue, eg set ACLs for the
- // queue.
- AdminEmails []string `json:"adminEmails,omitempty"`
- // ConsumerEmails: Email addresses of users who can "consume" tasks from
- // the TaskQueue. This means they can Dequeue and Delete tasks from the
- // queue.
- ConsumerEmails []string `json:"consumerEmails,omitempty"`
- // ProducerEmails: Email addresses of users who can "produce" tasks into
- // the TaskQueue. This means they can Insert tasks into the queue.
- ProducerEmails []string `json:"producerEmails,omitempty"`
- // ForceSendFields is a list of field names (e.g. "AdminEmails") to
- // unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
- }
- func (s *TaskQueueAcl) MarshalJSON() ([]byte, error) {
- type noMethod TaskQueueAcl
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
- }
- // TaskQueueStats: Statistics for the TaskQueue object in question.
- type TaskQueueStats struct {
- // LeasedLastHour: Number of tasks leased in the last hour.
- LeasedLastHour int64 `json:"leasedLastHour,omitempty,string"`
- // LeasedLastMinute: Number of tasks leased in the last minute.
- LeasedLastMinute int64 `json:"leasedLastMinute,omitempty,string"`
- // OldestTask: The timestamp (in seconds since the epoch) of the oldest
- // unfinished task.
- OldestTask int64 `json:"oldestTask,omitempty,string"`
- // TotalTasks: Number of tasks in the queue.
- TotalTasks int64 `json:"totalTasks,omitempty"`
- // ForceSendFields is a list of field names (e.g. "LeasedLastHour") to
- // unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
- }
- func (s *TaskQueueStats) MarshalJSON() ([]byte, error) {
- type noMethod TaskQueueStats
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
- }
- type Tasks struct {
- // Items: The actual list of tasks returned as a result of the lease
- // operation.
- Items []*Task `json:"items,omitempty"`
- // Kind: The kind of object returned, a list of tasks.
- Kind string `json:"kind,omitempty"`
- // ServerResponse contains the HTTP response code and headers from the
- // server.
- googleapi.ServerResponse `json:"-"`
- // ForceSendFields is a list of field names (e.g. "Items") to
- // unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
- }
- func (s *Tasks) MarshalJSON() ([]byte, error) {
- type noMethod Tasks
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
- }
- type Tasks2 struct {
- // Items: The actual list of tasks currently active in the TaskQueue.
- Items []*Task `json:"items,omitempty"`
- // Kind: The kind of object returned, a list of tasks.
- Kind string `json:"kind,omitempty"`
- // ServerResponse contains the HTTP response code and headers from the
- // server.
- googleapi.ServerResponse `json:"-"`
- // ForceSendFields is a list of field names (e.g. "Items") to
- // unconditionally include in API requests. By default, fields with
- // empty values are omitted from API requests. However, any non-pointer,
- // non-interface field appearing in ForceSendFields will be sent to the
- // server regardless of whether the field is empty or not. This may be
- // used to include empty fields in Patch requests.
- ForceSendFields []string `json:"-"`
- }
- func (s *Tasks2) MarshalJSON() ([]byte, error) {
- type noMethod Tasks2
- raw := noMethod(*s)
- return gensupport.MarshalJSON(raw, s.ForceSendFields)
- }
- // method id "taskqueue.taskqueues.get":
- type TaskqueuesGetCall struct {
- s *Service
- project string
- taskqueue string
- urlParams_ gensupport.URLParams
- ifNoneMatch_ string
- ctx_ context.Context
- }
- // Get: Get detailed information about a TaskQueue.
- func (r *TaskqueuesService) Get(project string, taskqueue string) *TaskqueuesGetCall {
- c := &TaskqueuesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
- c.project = project
- c.taskqueue = taskqueue
- return c
- }
- // GetStats sets the optional parameter "getStats": Whether to get
- // stats.
- func (c *TaskqueuesGetCall) GetStats(getStats bool) *TaskqueuesGetCall {
- c.urlParams_.Set("getStats", fmt.Sprint(getStats))
- return c
- }
- // Fields allows partial responses to be retrieved. See
- // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
- // for more information.
- func (c *TaskqueuesGetCall) Fields(s ...googleapi.Field) *TaskqueuesGetCall {
- c.urlParams_.Set("fields", googleapi.CombineFields(s))
- return c
- }
- // IfNoneMatch sets the optional parameter which makes the operation
- // fail if the object's ETag matches the given value. This is useful for
- // getting updates only after the object has changed since the last
- // request. Use googleapi.IsNotModified to check whether the response
- // error from Do is the result of In-None-Match.
- func (c *TaskqueuesGetCall) IfNoneMatch(entityTag string) *TaskqueuesGetCall {
- c.ifNoneMatch_ = entityTag
- return c
- }
- // Context sets the context to be used in this call's Do method. Any
- // pending HTTP request will be aborted if the provided context is
- // canceled.
- func (c *TaskqueuesGetCall) Context(ctx context.Context) *TaskqueuesGetCall {
- c.ctx_ = ctx
- return c
- }
- func (c *TaskqueuesGetCall) doRequest(alt string) (*http.Response, error) {
- var body io.Reader = nil
- c.urlParams_.Set("alt", alt)
- urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}")
- urls += "?" + c.urlParams_.Encode()
- req, _ := http.NewRequest("GET", urls, body)
- googleapi.Expand(req.URL, map[string]string{
- "project": c.project,
- "taskqueue": c.taskqueue,
- })
- req.Header.Set("User-Agent", c.s.userAgent())
- if c.ifNoneMatch_ != "" {
- req.Header.Set("If-None-Match", c.ifNoneMatch_)
- }
- if c.ctx_ != nil {
- return ctxhttp.Do(c.ctx_, c.s.client, req)
- }
- return c.s.client.Do(req)
- }
- // Do executes the "taskqueue.taskqueues.get" call.
- // Exactly one of *TaskQueue or error will be non-nil. Any non-2xx
- // status code is an error. Response headers are in either
- // *TaskQueue.ServerResponse.Header or (if a response was returned at
- // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
- // to check whether the returned error was because
- // http.StatusNotModified was returned.
- func (c *TaskqueuesGetCall) Do(opts ...googleapi.CallOption) (*TaskQueue, error) {
- gensupport.SetOptions(c.urlParams_, opts...)
- res, err := c.doRequest("json")
- if res != nil && res.StatusCode == http.StatusNotModified {
- if res.Body != nil {
- res.Body.Close()
- }
- return nil, &googleapi.Error{
- Code: res.StatusCode,
- Header: res.Header,
- }
- }
- if err != nil {
- return nil, err
- }
- defer googleapi.CloseBody(res)
- if err := googleapi.CheckResponse(res); err != nil {
- return nil, err
- }
- ret := &TaskQueue{
- ServerResponse: googleapi.ServerResponse{
- Header: res.Header,
- HTTPStatusCode: res.StatusCode,
- },
- }
- if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
- return nil, err
- }
- return ret, nil
- // {
- // "description": "Get detailed information about a TaskQueue.",
- // "httpMethod": "GET",
- // "id": "taskqueue.taskqueues.get",
- // "parameterOrder": [
- // "project",
- // "taskqueue"
- // ],
- // "parameters": {
- // "getStats": {
- // "description": "Whether to get stats. Optional.",
- // "location": "query",
- // "type": "boolean"
- // },
- // "project": {
- // "description": "The project under which the queue lies.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "taskqueue": {
- // "description": "The id of the taskqueue to get the properties of.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // }
- // },
- // "path": "{project}/taskqueues/{taskqueue}",
- // "response": {
- // "$ref": "TaskQueue"
- // },
- // "scopes": [
- // "https://www.googleapis.com/auth/taskqueue",
- // "https://www.googleapis.com/auth/taskqueue.consumer"
- // ]
- // }
- }
- // method id "taskqueue.tasks.delete":
- type TasksDeleteCall struct {
- s *Service
- project string
- taskqueue string
- task string
- urlParams_ gensupport.URLParams
- ctx_ context.Context
- }
- // Delete: Delete a task from a TaskQueue.
- func (r *TasksService) Delete(project string, taskqueue string, task string) *TasksDeleteCall {
- c := &TasksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
- c.project = project
- c.taskqueue = taskqueue
- c.task = task
- return c
- }
- // Fields allows partial responses to be retrieved. See
- // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
- // for more information.
- func (c *TasksDeleteCall) Fields(s ...googleapi.Field) *TasksDeleteCall {
- c.urlParams_.Set("fields", googleapi.CombineFields(s))
- return c
- }
- // Context sets the context to be used in this call's Do method. Any
- // pending HTTP request will be aborted if the provided context is
- // canceled.
- func (c *TasksDeleteCall) Context(ctx context.Context) *TasksDeleteCall {
- c.ctx_ = ctx
- return c
- }
- func (c *TasksDeleteCall) doRequest(alt string) (*http.Response, error) {
- var body io.Reader = nil
- c.urlParams_.Set("alt", alt)
- urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
- urls += "?" + c.urlParams_.Encode()
- req, _ := http.NewRequest("DELETE", urls, body)
- googleapi.Expand(req.URL, map[string]string{
- "project": c.project,
- "taskqueue": c.taskqueue,
- "task": c.task,
- })
- req.Header.Set("User-Agent", c.s.userAgent())
- if c.ctx_ != nil {
- return ctxhttp.Do(c.ctx_, c.s.client, req)
- }
- return c.s.client.Do(req)
- }
- // Do executes the "taskqueue.tasks.delete" call.
- func (c *TasksDeleteCall) Do(opts ...googleapi.CallOption) error {
- gensupport.SetOptions(c.urlParams_, opts...)
- res, err := c.doRequest("json")
- if err != nil {
- return err
- }
- defer googleapi.CloseBody(res)
- if err := googleapi.CheckResponse(res); err != nil {
- return err
- }
- return nil
- // {
- // "description": "Delete a task from a TaskQueue.",
- // "httpMethod": "DELETE",
- // "id": "taskqueue.tasks.delete",
- // "parameterOrder": [
- // "project",
- // "taskqueue",
- // "task"
- // ],
- // "parameters": {
- // "project": {
- // "description": "The project under which the queue lies.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "task": {
- // "description": "The id of the task to delete.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "taskqueue": {
- // "description": "The taskqueue to delete a task from.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // }
- // },
- // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
- // "scopes": [
- // "https://www.googleapis.com/auth/taskqueue",
- // "https://www.googleapis.com/auth/taskqueue.consumer"
- // ]
- // }
- }
- // method id "taskqueue.tasks.get":
- type TasksGetCall struct {
- s *Service
- project string
- taskqueue string
- task string
- urlParams_ gensupport.URLParams
- ifNoneMatch_ string
- ctx_ context.Context
- }
- // Get: Get a particular task from a TaskQueue.
- func (r *TasksService) Get(project string, taskqueue string, task string) *TasksGetCall {
- c := &TasksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
- c.project = project
- c.taskqueue = taskqueue
- c.task = task
- return c
- }
- // Fields allows partial responses to be retrieved. See
- // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
- // for more information.
- func (c *TasksGetCall) Fields(s ...googleapi.Field) *TasksGetCall {
- c.urlParams_.Set("fields", googleapi.CombineFields(s))
- return c
- }
- // IfNoneMatch sets the optional parameter which makes the operation
- // fail if the object's ETag matches the given value. This is useful for
- // getting updates only after the object has changed since the last
- // request. Use googleapi.IsNotModified to check whether the response
- // error from Do is the result of In-None-Match.
- func (c *TasksGetCall) IfNoneMatch(entityTag string) *TasksGetCall {
- c.ifNoneMatch_ = entityTag
- return c
- }
- // Context sets the context to be used in this call's Do method. Any
- // pending HTTP request will be aborted if the provided context is
- // canceled.
- func (c *TasksGetCall) Context(ctx context.Context) *TasksGetCall {
- c.ctx_ = ctx
- return c
- }
- func (c *TasksGetCall) doRequest(alt string) (*http.Response, error) {
- var body io.Reader = nil
- c.urlParams_.Set("alt", alt)
- urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/{task}")
- urls += "?" + c.urlParams_.Encode()
- req, _ := http.NewRequest("GET", urls, body)
- googleapi.Expand(req.URL, map[string]string{
- "project": c.project,
- "taskqueue": c.taskqueue,
- "task": c.task,
- })
- req.Header.Set("User-Agent", c.s.userAgent())
- if c.ifNoneMatch_ != "" {
- req.Header.Set("If-None-Match", c.ifNoneMatch_)
- }
- if c.ctx_ != nil {
- return ctxhttp.Do(c.ctx_, c.s.client, req)
- }
- return c.s.client.Do(req)
- }
- // Do executes the "taskqueue.tasks.get" call.
- // Exactly one of *Task or error will be non-nil. Any non-2xx status
- // code is an error. Response headers are in either
- // *Task.ServerResponse.Header or (if a response was returned at all) in
- // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
- // whether the returned error was because http.StatusNotModified was
- // returned.
- func (c *TasksGetCall) Do(opts ...googleapi.CallOption) (*Task, error) {
- gensupport.SetOptions(c.urlParams_, opts...)
- res, err := c.doRequest("json")
- if res != nil && res.StatusCode == http.StatusNotModified {
- if res.Body != nil {
- res.Body.Close()
- }
- return nil, &googleapi.Error{
- Code: res.StatusCode,
- Header: res.Header,
- }
- }
- if err != nil {
- return nil, err
- }
- defer googleapi.CloseBody(res)
- if err := googleapi.CheckResponse(res); err != nil {
- return nil, err
- }
- ret := &Task{
- ServerResponse: googleapi.ServerResponse{
- Header: res.Header,
- HTTPStatusCode: res.StatusCode,
- },
- }
- if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
- return nil, err
- }
- return ret, nil
- // {
- // "description": "Get a particular task from a TaskQueue.",
- // "httpMethod": "GET",
- // "id": "taskqueue.tasks.get",
- // "parameterOrder": [
- // "project",
- // "taskqueue",
- // "task"
- // ],
- // "parameters": {
- // "project": {
- // "description": "The project under which the queue lies.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "task": {
- // "description": "The task to get properties of.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "taskqueue": {
- // "description": "The taskqueue in which the task belongs.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // }
- // },
- // "path": "{project}/taskqueues/{taskqueue}/tasks/{task}",
- // "response": {
- // "$ref": "Task"
- // },
- // "scopes": [
- // "https://www.googleapis.com/auth/taskqueue",
- // "https://www.googleapis.com/auth/taskqueue.consumer"
- // ]
- // }
- }
- // method id "taskqueue.tasks.lease":
- type TasksLeaseCall struct {
- s *Service
- project string
- taskqueue string
- urlParams_ gensupport.URLParams
- ctx_ context.Context
- }
- // Lease: Lease 1 or more tasks from a TaskQueue.
- func (r *TasksService) Lease(project string, taskqueue string, numTasks int64, leaseSecs int64) *TasksLeaseCall {
- c := &TasksLeaseCall{s: r.s, urlParams_: make(gensupport.URLParams)}
- c.project = project
- c.taskqueue = taskqueue
- c.urlParams_.Set("numTasks", fmt.Sprint(numTasks))
- c.urlParams_.Set("leaseSecs", fmt.Sprint(leaseSecs))
- return c
- }
- // Fields allows partial responses to be retrieved. See
- // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
- // for more information.
- func (c *TasksLeaseCall) Fields(s ...googleapi.Field) *TasksLeaseCall {
- c.urlParams_.Set("fields", googleapi.CombineFields(s))
- return c
- }
- // Context sets the context to be used in this call's Do method. Any
- // pending HTTP request will be aborted if the provided context is
- // canceled.
- func (c *TasksLeaseCall) Context(ctx context.Context) *TasksLeaseCall {
- c.ctx_ = ctx
- return c
- }
- func (c *TasksLeaseCall) doRequest(alt string) (*http.Response, error) {
- var body io.Reader = nil
- c.urlParams_.Set("alt", alt)
- urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks/lease")
- urls += "?" + c.urlParams_.Encode()
- req, _ := http.NewRequest("POST", urls, body)
- googleapi.Expand(req.URL, map[string]string{
- "project": c.project,
- "taskqueue": c.taskqueue,
- })
- req.Header.Set("User-Agent", c.s.userAgent())
- if c.ctx_ != nil {
- return ctxhttp.Do(c.ctx_, c.s.client, req)
- }
- return c.s.client.Do(req)
- }
- // Do executes the "taskqueue.tasks.lease" call.
- // Exactly one of *Tasks or error will be non-nil. Any non-2xx status
- // code is an error. Response headers are in either
- // *Tasks.ServerResponse.Header or (if a response was returned at all)
- // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
- // check whether the returned error was because http.StatusNotModified
- // was returned.
- func (c *TasksLeaseCall) Do(opts ...googleapi.CallOption) (*Tasks, error) {
- gensupport.SetOptions(c.urlParams_, opts...)
- res, err := c.doRequest("json")
- if res != nil && res.StatusCode == http.StatusNotModified {
- if res.Body != nil {
- res.Body.Close()
- }
- return nil, &googleapi.Error{
- Code: res.StatusCode,
- Header: res.Header,
- }
- }
- if err != nil {
- return nil, err
- }
- defer googleapi.CloseBody(res)
- if err := googleapi.CheckResponse(res); err != nil {
- return nil, err
- }
- ret := &Tasks{
- ServerResponse: googleapi.ServerResponse{
- Header: res.Header,
- HTTPStatusCode: res.StatusCode,
- },
- }
- if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
- return nil, err
- }
- return ret, nil
- // {
- // "description": "Lease 1 or more tasks from a TaskQueue.",
- // "httpMethod": "POST",
- // "id": "taskqueue.tasks.lease",
- // "parameterOrder": [
- // "project",
- // "taskqueue",
- // "numTasks",
- // "leaseSecs"
- // ],
- // "parameters": {
- // "leaseSecs": {
- // "description": "The lease in seconds.",
- // "format": "int32",
- // "location": "query",
- // "required": true,
- // "type": "integer"
- // },
- // "numTasks": {
- // "description": "The number of tasks to lease.",
- // "format": "int32",
- // "location": "query",
- // "required": true,
- // "type": "integer"
- // },
- // "project": {
- // "description": "The project under which the queue lies.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "taskqueue": {
- // "description": "The taskqueue to lease a task from.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // }
- // },
- // "path": "{project}/taskqueues/{taskqueue}/tasks/lease",
- // "response": {
- // "$ref": "Tasks"
- // },
- // "scopes": [
- // "https://www.googleapis.com/auth/taskqueue",
- // "https://www.googleapis.com/auth/taskqueue.consumer"
- // ]
- // }
- }
- // method id "taskqueue.tasks.list":
- type TasksListCall struct {
- s *Service
- project string
- taskqueue string
- urlParams_ gensupport.URLParams
- ifNoneMatch_ string
- ctx_ context.Context
- }
- // List: List Tasks in a TaskQueue
- func (r *TasksService) List(project string, taskqueue string) *TasksListCall {
- c := &TasksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
- c.project = project
- c.taskqueue = taskqueue
- return c
- }
- // Fields allows partial responses to be retrieved. See
- // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
- // for more information.
- func (c *TasksListCall) Fields(s ...googleapi.Field) *TasksListCall {
- c.urlParams_.Set("fields", googleapi.CombineFields(s))
- return c
- }
- // IfNoneMatch sets the optional parameter which makes the operation
- // fail if the object's ETag matches the given value. This is useful for
- // getting updates only after the object has changed since the last
- // request. Use googleapi.IsNotModified to check whether the response
- // error from Do is the result of In-None-Match.
- func (c *TasksListCall) IfNoneMatch(entityTag string) *TasksListCall {
- c.ifNoneMatch_ = entityTag
- return c
- }
- // Context sets the context to be used in this call's Do method. Any
- // pending HTTP request will be aborted if the provided context is
- // canceled.
- func (c *TasksListCall) Context(ctx context.Context) *TasksListCall {
- c.ctx_ = ctx
- return c
- }
- func (c *TasksListCall) doRequest(alt string) (*http.Response, error) {
- var body io.Reader = nil
- c.urlParams_.Set("alt", alt)
- urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/taskqueues/{taskqueue}/tasks")
- urls += "?" + c.urlParams_.Encode()
- req, _ := http.NewRequest("GET", urls, body)
- googleapi.Expand(req.URL, map[string]string{
- "project": c.project,
- "taskqueue": c.taskqueue,
- })
- req.Header.Set("User-Agent", c.s.userAgent())
- if c.ifNoneMatch_ != "" {
- req.Header.Set("If-None-Match", c.ifNoneMatch_)
- }
- if c.ctx_ != nil {
- return ctxhttp.Do(c.ctx_, c.s.client, req)
- }
- return c.s.client.Do(req)
- }
- // Do executes the "taskqueue.tasks.list" call.
- // Exactly one of *Tasks2 or error will be non-nil. Any non-2xx status
- // code is an error. Response headers are in either
- // *Tasks2.ServerResponse.Header or (if a response was returned at all)
- // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
- // check whether the returned error was because http.StatusNotModified
- // was returned.
- func (c *TasksListCall) Do(opts ...googleapi.CallOption) (*Tasks2, error) {
- gensupport.SetOptions(c.urlParams_, opts...)
- res, err := c.doRequest("json")
- if res != nil && res.StatusCode == http.StatusNotModified {
- if res.Body != nil {
- res.Body.Close()
- }
- return nil, &googleapi.Error{
- Code: res.StatusCode,
- Header: res.Header,
- }
- }
- if err != nil {
- return nil, err
- }
- defer googleapi.CloseBody(res)
- if err := googleapi.CheckResponse(res); err != nil {
- return nil, err
- }
- ret := &Tasks2{
- ServerResponse: googleapi.ServerResponse{
- Header: res.Header,
- HTTPStatusCode: res.StatusCode,
- },
- }
- if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
- return nil, err
- }
- return ret, nil
- // {
- // "description": "List Tasks in a TaskQueue",
- // "httpMethod": "GET",
- // "id": "taskqueue.tasks.list",
- // "parameterOrder": [
- // "project",
- // "taskqueue"
- // ],
- // "parameters": {
- // "project": {
- // "description": "The project under which the queue lies.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // },
- // "taskqueue": {
- // "description": "The id of the taskqueue to list tasks from.",
- // "location": "path",
- // "required": true,
- // "type": "string"
- // }
- // },
- // "path": "{project}/taskqueues/{taskqueue}/tasks",
- // "response": {
- // "$ref": "Tasks2"
- // },
- // "scopes": [
- // "https://www.googleapis.com/auth/taskqueue",
- // "https://www.googleapis.com/auth/taskqueue.consumer"
- // ]
- // }
- }
|