// Copyright 2026 Google LLC.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Code generated file. DO NOT EDIT.

// Package tasks provides access to the Google Tasks API.
//
// For product documentation, see: https://developers.google.com/workspace/tasks/
//
// # Library status
//
// These client libraries are officially supported by Google. However, this
// library is considered complete and is in maintenance mode. This means
// that we will address critical bugs and security issues but will not add
// any new features.
//
// When possible, we recommend using our newer
// [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
// that are still actively being worked and iterated on.
//
// # Creating a client
//
// Usage example:
//
//	import "google.golang.org/api/tasks/v1"
//	...
//	ctx := context.Background()
//	tasksService, err := tasks.NewService(ctx)
//
// In this example, Google Application Default Credentials are used for
// authentication. For information on how to create and obtain Application
// Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
//
// # Other authentication options
//
// By default, all available scopes (see "Constants") are used to authenticate.
// To restrict scopes, use [google.golang.org/api/option.WithScopes]:
//
//	tasksService, err := tasks.NewService(ctx, option.WithScopes(tasks.TasksReadonlyScope))
//
// To use an API key for authentication (note: some APIs do not support API
// keys), use [google.golang.org/api/option.WithAPIKey]:
//
//	tasksService, err := tasks.NewService(ctx, option.WithAPIKey("AIza..."))
//
// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
// flow, use [google.golang.org/api/option.WithTokenSource]:
//
//	config := &oauth2.Config{...}
//	// ...
//	token, err := config.Exchange(ctx, ...)
//	tasksService, err := tasks.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
//
// See [google.golang.org/api/option.ClientOption] for details on options.
package tasks // import "google.golang.org/api/tasks/v1"

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"log/slog"
	"net/http"
	"net/url"
	"strconv"
	"strings"

	"github.com/googleapis/gax-go/v2/internallog"
	googleapi "google.golang.org/api/googleapi"
	internal "google.golang.org/api/internal"
	gensupport "google.golang.org/api/internal/gensupport"
	option "google.golang.org/api/option"
	internaloption "google.golang.org/api/option/internaloption"
	htransport "google.golang.org/api/transport/http"
)

// 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 _ = internaloption.WithDefaultEndpoint
var _ = internal.Version
var _ = internallog.New

const apiId = "tasks:v1"
const apiName = "tasks"
const apiVersion = "v1"
const basePath = "https://tasks.googleapis.com/"
const basePathTemplate = "https://tasks.UNIVERSE_DOMAIN/"
const mtlsBasePath = "https://tasks.mtls.googleapis.com/"

// OAuth2 scopes used by this API.
const (
	// Create, edit, organize, and delete all your tasks
	TasksScope = "https://www.googleapis.com/auth/tasks"

	// View your tasks
	TasksReadonlyScope = "https://www.googleapis.com/auth/tasks.readonly"
)

// NewService creates a new Service.
func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
	scopesOption := internaloption.WithDefaultScopes(
		"https://www.googleapis.com/auth/tasks",
		"https://www.googleapis.com/auth/tasks.readonly",
	)
	// NOTE: prepend, so we don't override user-specified scopes.
	opts = append([]option.ClientOption{scopesOption}, opts...)
	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
	opts = append(opts, internaloption.EnableNewAuthLibrary())
	client, endpoint, err := htransport.NewClient(ctx, opts...)
	if err != nil {
		return nil, err
	}
	s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
	s.Tasklists = NewTasklistsService(s)
	s.Tasks = NewTasksService(s)
	if endpoint != "" {
		s.BasePath = endpoint
	}
	return s, nil
}

// New creates a new Service. It uses the provided http.Client for requests.
//
// Deprecated: please use NewService instead.
// To provide a custom HTTP client, use option.WithHTTPClient.
// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
func New(client *http.Client) (*Service, error) {
	if client == nil {
		return nil, errors.New("client is nil")
	}
	return NewService(context.TODO(), option.WithHTTPClient(client))
}

type Service struct {
	client    *http.Client
	logger    *slog.Logger
	BasePath  string // API endpoint base URL
	UserAgent string // optional additional User-Agent fragment

	Tasklists *TasklistsService

	Tasks *TasksService
}

func (s *Service) userAgent() string {
	if s.UserAgent == "" {
		return googleapi.UserAgent
	}
	return googleapi.UserAgent + " " + s.UserAgent
}

func NewTasklistsService(s *Service) *TasklistsService {
	rs := &TasklistsService{s: s}
	return rs
}

type TasklistsService struct {
	s *Service
}

func NewTasksService(s *Service) *TasksService {
	rs := &TasksService{s: s}
	return rs
}

type TasksService struct {
	s *Service
}

// AssignmentInfo: Information about the source of the task assignment
// (Document, Chat Space).
type AssignmentInfo struct {
	// DriveResourceInfo: Output only. Information about the Drive file where this
	// task originates from. Currently, the Drive file can only be a document. This
	// field is read-only.
	DriveResourceInfo *DriveResourceInfo `json:"driveResourceInfo,omitempty"`
	// LinkToTask: Output only. An absolute link to the original task in the
	// surface of assignment (Docs, Chat spaces, etc.).
	LinkToTask string `json:"linkToTask,omitempty"`
	// SpaceInfo: Output only. Information about the Chat Space where this task
	// originates from. This field is read-only.
	SpaceInfo *SpaceInfo `json:"spaceInfo,omitempty"`
	// SurfaceType: Output only. The type of surface this assigned task originates
	// from. Currently limited to DOCUMENT or SPACE.
	//
	// Possible values:
	//   "CONTEXT_TYPE_UNSPECIFIED" - Unknown value for this task's context.
	//   "GMAIL" - The task is created from Gmail.
	//   "DOCUMENT" - The task is assigned from a document.
	//   "SPACE" - The task is assigned from a Chat Space.
	SurfaceType string `json:"surfaceType,omitempty"`
	// ForceSendFields is a list of field names (e.g. "DriveResourceInfo") to
	// unconditionally include in API requests. By default, fields with empty or
	// default values are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "DriveResourceInfo") to include in
	// API requests with the JSON null value. By default, fields with empty values
	// are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s AssignmentInfo) MarshalJSON() ([]byte, error) {
	type NoMethod AssignmentInfo
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

// DriveResourceInfo: Information about the Drive resource where a task was
// assigned from (the document, sheet, etc.).
type DriveResourceInfo struct {
	// DriveFileId: Output only. Identifier of the file in the Drive API.
	DriveFileId string `json:"driveFileId,omitempty"`
	// ResourceKey: Output only. Resource key required to access files shared via a
	// shared link. Not required for all files. See also
	// developers.google.com/drive/api/guides/resource-keys.
	ResourceKey string `json:"resourceKey,omitempty"`
	// ForceSendFields is a list of field names (e.g. "DriveFileId") to
	// unconditionally include in API requests. By default, fields with empty or
	// default values are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "DriveFileId") to include in API
	// requests with the JSON null value. By default, fields with empty values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s DriveResourceInfo) MarshalJSON() ([]byte, error) {
	type NoMethod DriveResourceInfo
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

// SpaceInfo: Information about the Chat Space where a task was assigned from.
type SpaceInfo struct {
	// Space: Output only. The Chat space where this task originates from. The
	// format is "spaces/{space}".
	Space string `json:"space,omitempty"`
	// ForceSendFields is a list of field names (e.g. "Space") to unconditionally
	// include in API requests. By default, fields with empty or default values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "Space") to include in API
	// requests with the JSON null value. By default, fields with empty values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s SpaceInfo) MarshalJSON() ([]byte, error) {
	type NoMethod SpaceInfo
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

type Task struct {
	// AssignmentInfo: Output only. Context information for assigned tasks. A task
	// can be assigned to a user, currently possible from surfaces like Docs and
	// Chat Spaces. This field is populated for tasks assigned to the current user
	// and identifies where the task was assigned from. This field is read-only.
	AssignmentInfo *AssignmentInfo `json:"assignmentInfo,omitempty"`
	// Completed: Completion date of the task (as a RFC 3339 timestamp). This field
	// is omitted if the task has not been completed.
	Completed *string `json:"completed,omitempty"`
	// Deleted: Flag indicating whether the task has been deleted. For assigned
	// tasks this field is read-only. They can only be deleted by calling
	// tasks.delete, in which case both the assigned task and the original task (in
	// Docs or Chat Spaces) are deleted. To delete the assigned task only, navigate
	// to the assignment surface and unassign the task from there. The default is
	// False.
	Deleted bool `json:"deleted,omitempty"`
	// Due: Scheduled date for the task (as an RFC 3339 timestamp). Optional. This
	// represents the day that the task should be done, or that the task is visible
	// on the calendar grid. It doesn't represent the deadline of the task. Only
	// date information is recorded; the time portion of the timestamp is discarded
	// when setting this field. It isn't possible to read or write the time that a
	// task is scheduled for using the API.
	Due string `json:"due,omitempty"`
	// Etag: ETag of the resource.
	Etag string `json:"etag,omitempty"`
	// Hidden: Flag indicating whether the task is hidden. This is the case if the
	// task had been marked completed when the task list was last cleared. The
	// default is False. This field is read-only.
	Hidden bool `json:"hidden,omitempty"`
	// Id: Task identifier.
	Id string `json:"id,omitempty"`
	// Kind: Output only. Type of the resource. This is always "tasks#task".
	Kind string `json:"kind,omitempty"`
	// Links: Output only. Collection of links. This collection is read-only.
	Links []*TaskLinks `json:"links,omitempty"`
	// Notes: Notes describing the task. Tasks assigned from Google Docs cannot
	// have notes. Optional. Maximum length allowed: 8192 characters.
	Notes string `json:"notes,omitempty"`
	// Parent: Output only. Parent task identifier. This field is omitted if it is
	// a top-level task. Use the "move" method to move the task under a different
	// parent or to the top level. A parent task can never be an assigned task
	// (from Chat Spaces, Docs). This field is read-only.
	Parent string `json:"parent,omitempty"`
	// Position: Output only. String indicating the position of the task among its
	// sibling tasks under the same parent task or at the top level. If this string
	// is greater than another task's corresponding position string according to
	// lexicographical ordering, the task is positioned after the other task under
	// the same parent task (or at the top level). Use the "move" method to move
	// the task to another position.
	Position string `json:"position,omitempty"`
	// SelfLink: Output only. URL pointing to this task. Used to retrieve, update,
	// or delete this task.
	SelfLink string `json:"selfLink,omitempty"`
	// Status: Status of the task. This is either "needsAction" or "completed".
	Status string `json:"status,omitempty"`
	// Title: Title of the task. Maximum length allowed: 1024 characters.
	Title string `json:"title,omitempty"`
	// Updated: Output only. Last modification time of the task (as a RFC 3339
	// timestamp).
	Updated string `json:"updated,omitempty"`
	// WebViewLink: Output only. An absolute link to the task in the Google Tasks
	// Web UI.
	WebViewLink string `json:"webViewLink,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the server.
	googleapi.ServerResponse `json:"-"`
	// ForceSendFields is a list of field names (e.g. "AssignmentInfo") to
	// unconditionally include in API requests. By default, fields with empty or
	// default values are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "AssignmentInfo") to include in
	// API requests with the JSON null value. By default, fields with empty values
	// are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s Task) MarshalJSON() ([]byte, error) {
	type NoMethod Task
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

type TaskLinks struct {
	// Description: The description (might be empty).
	Description string `json:"description,omitempty"`
	// Link: The URL.
	Link string `json:"link,omitempty"`
	// Type: Type of the link, e.g. "email", "generic", "chat_message",
	// "keep_note".
	Type string `json:"type,omitempty"`
	// ForceSendFields is a list of field names (e.g. "Description") to
	// unconditionally include in API requests. By default, fields with empty or
	// default values are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "Description") to include in API
	// requests with the JSON null value. By default, fields with empty values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s TaskLinks) MarshalJSON() ([]byte, error) {
	type NoMethod TaskLinks
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

type TaskList struct {
	// Etag: ETag of the resource.
	Etag string `json:"etag,omitempty"`
	// Id: Task list identifier.
	Id string `json:"id,omitempty"`
	// Kind: Output only. Type of the resource. This is always "tasks#taskList".
	Kind string `json:"kind,omitempty"`
	// SelfLink: Output only. URL pointing to this task list. Used to retrieve,
	// update, or delete this task list.
	SelfLink string `json:"selfLink,omitempty"`
	// Title: Title of the task list. Maximum length allowed: 1024 characters.
	Title string `json:"title,omitempty"`
	// Updated: Output only. Last modification time of the task list (as a RFC 3339
	// timestamp).
	Updated string `json:"updated,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the server.
	googleapi.ServerResponse `json:"-"`
	// ForceSendFields is a list of field names (e.g. "Etag") to unconditionally
	// include in API requests. By default, fields with empty or default values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "Etag") to include in API requests
	// with the JSON null value. By default, fields with empty values are omitted
	// from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s TaskList) MarshalJSON() ([]byte, error) {
	type NoMethod TaskList
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

type TaskLists struct {
	// Etag: ETag of the resource.
	Etag string `json:"etag,omitempty"`
	// Items: Collection of task lists.
	Items []*TaskList `json:"items,omitempty"`
	// Kind: Type of the resource. This is always "tasks#taskLists".
	Kind string `json:"kind,omitempty"`
	// NextPageToken: Token that can be used to request the next page of this
	// result.
	NextPageToken string `json:"nextPageToken,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the server.
	googleapi.ServerResponse `json:"-"`
	// ForceSendFields is a list of field names (e.g. "Etag") to unconditionally
	// include in API requests. By default, fields with empty or default values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "Etag") to include in API requests
	// with the JSON null value. By default, fields with empty values are omitted
	// from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s TaskLists) MarshalJSON() ([]byte, error) {
	type NoMethod TaskLists
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

type Tasks struct {
	// Etag: ETag of the resource.
	Etag string `json:"etag,omitempty"`
	// Items: Collection of tasks.
	Items []*Task `json:"items,omitempty"`
	// Kind: Type of the resource. This is always "tasks#tasks".
	Kind string `json:"kind,omitempty"`
	// NextPageToken: Token used to access the next page of this result.
	NextPageToken string `json:"nextPageToken,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the server.
	googleapi.ServerResponse `json:"-"`
	// ForceSendFields is a list of field names (e.g. "Etag") to unconditionally
	// include in API requests. By default, fields with empty or default values are
	// omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "Etag") to include in API requests
	// with the JSON null value. By default, fields with empty values are omitted
	// from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

func (s Tasks) MarshalJSON() ([]byte, error) {
	type NoMethod Tasks
	return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
}

type TasklistsDeleteCall struct {
	s          *Service
	tasklistid string
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Delete: Deletes the authenticated user's specified task list. If the list
// contains assigned tasks, both the assigned tasks and the original tasks in
// the assignment surface (Docs, Chat Spaces) are deleted.
//
// - tasklist: Task list identifier.
func (r *TasklistsService) Delete(tasklistid string) *TasklistsDeleteCall {
	c := &TasklistsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasklistsDeleteCall) Fields(s ...googleapi.Field) *TasklistsDeleteCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasklistsDeleteCall) Context(ctx context.Context) *TasklistsDeleteCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasklistsDeleteCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasklistsDeleteCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("DELETE", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasklists.delete", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasklists.delete" call.
func (c *TasklistsDeleteCall) 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 gensupport.WrapError(err)
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasklists.delete", "response", internallog.HTTPResponse(res, nil))
	return nil
}

type TasklistsGetCall struct {
	s            *Service
	tasklistid   string
	urlParams_   gensupport.URLParams
	ifNoneMatch_ string
	ctx_         context.Context
	header_      http.Header
}

// Get: Returns the authenticated user's specified task list.
//
// - tasklist: Task list identifier.
func (r *TasklistsService) Get(tasklistid string) *TasklistsGetCall {
	c := &TasklistsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasklistsGetCall) Fields(s ...googleapi.Field) *TasklistsGetCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// IfNoneMatch sets an 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.
func (c *TasklistsGetCall) IfNoneMatch(entityTag string) *TasklistsGetCall {
	c.ifNoneMatch_ = entityTag
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasklistsGetCall) Context(ctx context.Context) *TasklistsGetCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasklistsGetCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasklistsGetCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	if c.ifNoneMatch_ != "" {
		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("GET", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasklists.get", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasklists.get" call.
// Any non-2xx status code is an error. Response headers are in either
// *TaskList.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 *TasklistsGetCall) Do(opts ...googleapi.CallOption) (*TaskList, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &TaskList{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasklists.get", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasklistsInsertCall struct {
	s          *Service
	tasklist   *TaskList
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Insert: Creates a new task list and adds it to the authenticated user's task
// lists. A user can have up to 2000 lists at a time.
func (r *TasklistsService) Insert(tasklist *TaskList) *TasklistsInsertCall {
	c := &TasklistsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklist = tasklist
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasklistsInsertCall) Fields(s ...googleapi.Field) *TasklistsInsertCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasklistsInsertCall) Context(ctx context.Context) *TasklistsInsertCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasklistsInsertCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasklistsInsertCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
	body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.tasklist)
	if err != nil {
		return nil, err
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("POST", urls, body)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasklists.insert", "request", internallog.HTTPRequest(req, body.Bytes()))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasklists.insert" call.
// Any non-2xx status code is an error. Response headers are in either
// *TaskList.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 *TasklistsInsertCall) Do(opts ...googleapi.CallOption) (*TaskList, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &TaskList{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasklists.insert", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasklistsListCall struct {
	s            *Service
	urlParams_   gensupport.URLParams
	ifNoneMatch_ string
	ctx_         context.Context
	header_      http.Header
}

// List: Returns all the authenticated user's task lists. A user can have up to
// 2000 lists at a time.
func (r *TasklistsService) List() *TasklistsListCall {
	c := &TasklistsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	return c
}

// MaxResults sets the optional parameter "maxResults": Maximum number of task
// lists returned on one page.  The default is 1000 (max allowed: 1000).
func (c *TasklistsListCall) MaxResults(maxResults int64) *TasklistsListCall {
	c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
	return c
}

// PageToken sets the optional parameter "pageToken": Token specifying the
// result page to return.
func (c *TasklistsListCall) PageToken(pageToken string) *TasklistsListCall {
	c.urlParams_.Set("pageToken", pageToken)
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasklistsListCall) Fields(s ...googleapi.Field) *TasklistsListCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// IfNoneMatch sets an 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.
func (c *TasklistsListCall) IfNoneMatch(entityTag string) *TasklistsListCall {
	c.ifNoneMatch_ = entityTag
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasklistsListCall) Context(ctx context.Context) *TasklistsListCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasklistsListCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasklistsListCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	if c.ifNoneMatch_ != "" {
		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("GET", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasklists.list", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasklists.list" call.
// Any non-2xx status code is an error. Response headers are in either
// *TaskLists.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 *TasklistsListCall) Do(opts ...googleapi.CallOption) (*TaskLists, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &TaskLists{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasklists.list", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

// Pages invokes f for each page of results.
// A non-nil error returned from f will halt the iteration.
// The provided context supersedes any context provided to the Context method.
func (c *TasklistsListCall) Pages(ctx context.Context, f func(*TaskLists) error) error {
	c.ctx_ = ctx
	defer c.PageToken(c.urlParams_.Get("pageToken"))
	for {
		x, err := c.Do()
		if err != nil {
			return err
		}
		if err := f(x); err != nil {
			return err
		}
		if x.NextPageToken == "" {
			return nil
		}
		c.PageToken(x.NextPageToken)
	}
}

type TasklistsPatchCall struct {
	s          *Service
	tasklistid string
	tasklist   *TaskList
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Patch: Updates the authenticated user's specified task list. This method
// supports patch semantics.
//
// - tasklist: Task list identifier.
func (r *TasklistsService) Patch(tasklistid string, tasklist *TaskList) *TasklistsPatchCall {
	c := &TasklistsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.tasklist = tasklist
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasklistsPatchCall) Fields(s ...googleapi.Field) *TasklistsPatchCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasklistsPatchCall) Context(ctx context.Context) *TasklistsPatchCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasklistsPatchCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasklistsPatchCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
	body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.tasklist)
	if err != nil {
		return nil, err
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("PATCH", urls, body)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasklists.patch", "request", internallog.HTTPRequest(req, body.Bytes()))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasklists.patch" call.
// Any non-2xx status code is an error. Response headers are in either
// *TaskList.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 *TasklistsPatchCall) Do(opts ...googleapi.CallOption) (*TaskList, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &TaskList{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasklists.patch", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasklistsUpdateCall struct {
	s          *Service
	tasklistid string
	tasklist   *TaskList
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Update: Updates the authenticated user's specified task list.
//
// - tasklist: Task list identifier.
func (r *TasklistsService) Update(tasklistid string, tasklist *TaskList) *TasklistsUpdateCall {
	c := &TasklistsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.tasklist = tasklist
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasklistsUpdateCall) Fields(s ...googleapi.Field) *TasklistsUpdateCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasklistsUpdateCall) Context(ctx context.Context) *TasklistsUpdateCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasklistsUpdateCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasklistsUpdateCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
	body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.tasklist)
	if err != nil {
		return nil, err
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/users/@me/lists/{tasklist}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("PUT", urls, body)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasklists.update", "request", internallog.HTTPRequest(req, body.Bytes()))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasklists.update" call.
// Any non-2xx status code is an error. Response headers are in either
// *TaskList.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 *TasklistsUpdateCall) Do(opts ...googleapi.CallOption) (*TaskList, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &TaskList{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasklists.update", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasksClearCall struct {
	s          *Service
	tasklistid string
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Clear: Clears all completed tasks from the specified task list. The affected
// tasks will be marked as 'hidden' and no longer be returned by default when
// retrieving all tasks for a task list.
//
// - tasklist: Task list identifier.
func (r *TasksService) Clear(tasklistid string) *TasksClearCall {
	c := &TasksClearCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasksClearCall) Fields(s ...googleapi.Field) *TasksClearCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasksClearCall) Context(ctx context.Context) *TasksClearCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksClearCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksClearCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/clear")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("POST", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.clear", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.clear" call.
func (c *TasksClearCall) 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 gensupport.WrapError(err)
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.clear", "response", internallog.HTTPResponse(res, nil))
	return nil
}

type TasksDeleteCall struct {
	s          *Service
	tasklistid string
	taskid     string
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Delete: Deletes the specified task from the task list. If the task is
// assigned, both the assigned task and the original task (in Docs, Chat
// Spaces) are deleted. To delete the assigned task only, navigate to the
// assignment surface and unassign the task from there.
//
// - task: Task identifier.
// - tasklist: Task list identifier.
func (r *TasksService) Delete(tasklistid string, taskid string) *TasksDeleteCall {
	c := &TasksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.taskid = taskid
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
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.
func (c *TasksDeleteCall) Context(ctx context.Context) *TasksDeleteCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksDeleteCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksDeleteCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("DELETE", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
		"task":     c.taskid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.delete", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.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 gensupport.WrapError(err)
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.delete", "response", internallog.HTTPResponse(res, nil))
	return nil
}

type TasksGetCall struct {
	s            *Service
	tasklistid   string
	taskid       string
	urlParams_   gensupport.URLParams
	ifNoneMatch_ string
	ctx_         context.Context
	header_      http.Header
}

// Get: Returns the specified task.
//
// - task: Task identifier.
// - tasklist: Task list identifier.
func (r *TasksService) Get(tasklistid string, taskid string) *TasksGetCall {
	c := &TasksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.taskid = taskid
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasksGetCall) Fields(s ...googleapi.Field) *TasksGetCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// IfNoneMatch sets an 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.
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.
func (c *TasksGetCall) Context(ctx context.Context) *TasksGetCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksGetCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksGetCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	if c.ifNoneMatch_ != "" {
		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("GET", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
		"task":     c.taskid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.get", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.get" call.
// 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &Task{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.get", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasksInsertCall struct {
	s          *Service
	tasklistid string
	task       *Task
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Insert: Creates a new task on the specified task list. Tasks assigned from
// Docs or Chat Spaces cannot be inserted from Tasks Public API; they can only
// be created by assigning them from Docs or Chat Spaces. A user can have up to
// 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.
//
// - tasklist: Task list identifier.
func (r *TasksService) Insert(tasklistid string, task *Task) *TasksInsertCall {
	c := &TasksInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.task = task
	return c
}

// Parent sets the optional parameter "parent": Parent task identifier. If the
// task is created at the top level, this parameter is omitted. An assigned
// task cannot be a parent task, nor can it have a parent. Setting the parent
// to an assigned task results in failure of the request.
func (c *TasksInsertCall) Parent(parent string) *TasksInsertCall {
	c.urlParams_.Set("parent", parent)
	return c
}

// Previous sets the optional parameter "previous": Previous sibling task
// identifier. If the task is created at the first position among its siblings,
// this parameter is omitted.
func (c *TasksInsertCall) Previous(previous string) *TasksInsertCall {
	c.urlParams_.Set("previous", previous)
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasksInsertCall) Fields(s ...googleapi.Field) *TasksInsertCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasksInsertCall) Context(ctx context.Context) *TasksInsertCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksInsertCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksInsertCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
	body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.task)
	if err != nil {
		return nil, err
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("POST", urls, body)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.insert", "request", internallog.HTTPRequest(req, body.Bytes()))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.insert" call.
// 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 *TasksInsertCall) 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &Task{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.insert", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasksListCall struct {
	s            *Service
	tasklistid   string
	urlParams_   gensupport.URLParams
	ifNoneMatch_ string
	ctx_         context.Context
	header_      http.Header
}

// List: Returns all tasks in the specified task list. Doesn't return assigned
// tasks by default (from Docs, Chat Spaces). A user can have up to 20,000
// non-hidden tasks per list and up to 100,000 tasks in total at a time.
//
// - tasklist: Task list identifier.
func (r *TasksService) List(tasklistid string) *TasksListCall {
	c := &TasksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	return c
}

// CompletedMax sets the optional parameter "completedMax": Upper bound for a
// task's completion date (as a RFC 3339 timestamp) to filter by.  The default
// is not to filter by completion date.
func (c *TasksListCall) CompletedMax(completedMax string) *TasksListCall {
	c.urlParams_.Set("completedMax", completedMax)
	return c
}

// CompletedMin sets the optional parameter "completedMin": Lower bound for a
// task's completion date (as a RFC 3339 timestamp) to filter by.  The default
// is not to filter by completion date.
func (c *TasksListCall) CompletedMin(completedMin string) *TasksListCall {
	c.urlParams_.Set("completedMin", completedMin)
	return c
}

// DueMax sets the optional parameter "dueMax": Upper bound for a task's due
// date (as a RFC 3339 timestamp) to filter by.  The default is not to filter
// by due date.
func (c *TasksListCall) DueMax(dueMax string) *TasksListCall {
	c.urlParams_.Set("dueMax", dueMax)
	return c
}

// DueMin sets the optional parameter "dueMin": Lower bound for a task's due
// date (as a RFC 3339 timestamp) to filter by.  The default is not to filter
// by due date.
func (c *TasksListCall) DueMin(dueMin string) *TasksListCall {
	c.urlParams_.Set("dueMin", dueMin)
	return c
}

// MaxResults sets the optional parameter "maxResults": Maximum number of tasks
// returned on one page.  The default is 20 (max allowed: 100).
func (c *TasksListCall) MaxResults(maxResults int64) *TasksListCall {
	c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
	return c
}

// PageToken sets the optional parameter "pageToken": Token specifying the
// result page to return.
func (c *TasksListCall) PageToken(pageToken string) *TasksListCall {
	c.urlParams_.Set("pageToken", pageToken)
	return c
}

// ShowAssigned sets the optional parameter "showAssigned": Flag indicating
// whether tasks assigned to the current user are returned in the result.
// Optional. The default is False.
func (c *TasksListCall) ShowAssigned(showAssigned bool) *TasksListCall {
	c.urlParams_.Set("showAssigned", fmt.Sprint(showAssigned))
	return c
}

// ShowCompleted sets the optional parameter "showCompleted": Flag indicating
// whether completed tasks are returned in the result. Note that showHidden
// must also be True to show tasks completed in first party clients, such as
// the web UI and Google's mobile apps.  The default is True.
func (c *TasksListCall) ShowCompleted(showCompleted bool) *TasksListCall {
	c.urlParams_.Set("showCompleted", fmt.Sprint(showCompleted))
	return c
}

// ShowDeleted sets the optional parameter "showDeleted": Flag indicating
// whether deleted tasks are returned in the result.  The default is False.
func (c *TasksListCall) ShowDeleted(showDeleted bool) *TasksListCall {
	c.urlParams_.Set("showDeleted", fmt.Sprint(showDeleted))
	return c
}

// ShowHidden sets the optional parameter "showHidden": Flag indicating whether
// hidden tasks are returned in the result.  The default is False.
func (c *TasksListCall) ShowHidden(showHidden bool) *TasksListCall {
	c.urlParams_.Set("showHidden", fmt.Sprint(showHidden))
	return c
}

// UpdatedMin sets the optional parameter "updatedMin": Lower bound for a
// task's last modification time (as a RFC 3339 timestamp) to filter by.  The
// default is not to filter by last modification time.
func (c *TasksListCall) UpdatedMin(updatedMin string) *TasksListCall {
	c.urlParams_.Set("updatedMin", updatedMin)
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasksListCall) Fields(s ...googleapi.Field) *TasksListCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// IfNoneMatch sets an 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.
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.
func (c *TasksListCall) Context(ctx context.Context) *TasksListCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksListCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksListCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	if c.ifNoneMatch_ != "" {
		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("GET", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.list", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.list" call.
// 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 *TasksListCall) 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &Tasks{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.list", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

// Pages invokes f for each page of results.
// A non-nil error returned from f will halt the iteration.
// The provided context supersedes any context provided to the Context method.
func (c *TasksListCall) Pages(ctx context.Context, f func(*Tasks) error) error {
	c.ctx_ = ctx
	defer c.PageToken(c.urlParams_.Get("pageToken"))
	for {
		x, err := c.Do()
		if err != nil {
			return err
		}
		if err := f(x); err != nil {
			return err
		}
		if x.NextPageToken == "" {
			return nil
		}
		c.PageToken(x.NextPageToken)
	}
}

type TasksMoveCall struct {
	s          *Service
	tasklistid string
	taskid     string
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Move: Moves the specified task to another position in the destination task
// list. If the destination list is not specified, the task is moved within its
// current list. This can include putting it as a child task under a new parent
// and/or move it to a different position among its sibling tasks. A user can
// have up to 2,000 subtasks per task.
//
// - task: Task identifier.
// - tasklist: Task list identifier.
func (r *TasksService) Move(tasklistid string, taskid string) *TasksMoveCall {
	c := &TasksMoveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.taskid = taskid
	return c
}

// DestinationTasklist sets the optional parameter "destinationTasklist":
// Destination task list identifier. If set, the task is moved from tasklist to
// the destinationTasklist list. Otherwise the task is moved within its current
// list. Recurrent tasks cannot currently be moved between lists.
func (c *TasksMoveCall) DestinationTasklist(destinationTasklist string) *TasksMoveCall {
	c.urlParams_.Set("destinationTasklist", destinationTasklist)
	return c
}

// Parent sets the optional parameter "parent": New parent task identifier. If
// the task is moved to the top level, this parameter is omitted. The task set
// as parent must exist in the task list and can not be hidden. Exceptions: 1.
// Assigned and repeating tasks cannot be set as parent tasks (have subtasks),
// or be moved under a parent task (become subtasks). 2. Tasks that are both
// completed and hidden cannot be nested, so the parent field must be empty.
func (c *TasksMoveCall) Parent(parent string) *TasksMoveCall {
	c.urlParams_.Set("parent", parent)
	return c
}

// Previous sets the optional parameter "previous": New previous sibling task
// identifier. If the task is moved to the first position among its siblings,
// this parameter is omitted. The task set as previous must exist in the task
// list and can not be hidden. Exceptions: 1. Tasks that are both completed and
// hidden can only be moved to position 0, so the previous field must be empty.
func (c *TasksMoveCall) Previous(previous string) *TasksMoveCall {
	c.urlParams_.Set("previous", previous)
	return c
}

// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
// details.
func (c *TasksMoveCall) Fields(s ...googleapi.Field) *TasksMoveCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasksMoveCall) Context(ctx context.Context) *TasksMoveCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksMoveCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksMoveCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}/move")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("POST", urls, nil)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
		"task":     c.taskid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.move", "request", internallog.HTTPRequest(req, nil))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.move" call.
// 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 *TasksMoveCall) 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &Task{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.move", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasksPatchCall struct {
	s          *Service
	tasklistid string
	taskid     string
	task       *Task
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Patch: Updates the specified task. This method supports patch semantics.
//
// - task: Task identifier.
// - tasklist: Task list identifier.
func (r *TasksService) Patch(tasklistid string, taskid string, task *Task) *TasksPatchCall {
	c := &TasksPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.taskid = taskid
	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
// details.
func (c *TasksPatchCall) Fields(s ...googleapi.Field) *TasksPatchCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasksPatchCall) Context(ctx context.Context) *TasksPatchCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksPatchCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksPatchCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
	body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.task)
	if err != nil {
		return nil, err
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("PATCH", urls, body)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
		"task":     c.taskid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.patch", "request", internallog.HTTPRequest(req, body.Bytes()))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.patch" call.
// 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 *TasksPatchCall) 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &Task{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.patch", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}

type TasksUpdateCall struct {
	s          *Service
	tasklistid string
	taskid     string
	task       *Task
	urlParams_ gensupport.URLParams
	ctx_       context.Context
	header_    http.Header
}

// Update: Updates the specified task.
//
// - task: Task identifier.
// - tasklist: Task list identifier.
func (r *TasksService) Update(tasklistid string, taskid string, task *Task) *TasksUpdateCall {
	c := &TasksUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.tasklistid = tasklistid
	c.taskid = taskid
	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
// details.
func (c *TasksUpdateCall) Fields(s ...googleapi.Field) *TasksUpdateCall {
	c.urlParams_.Set("fields", googleapi.CombineFields(s))
	return c
}

// Context sets the context to be used in this call's Do method.
func (c *TasksUpdateCall) Context(ctx context.Context) *TasksUpdateCall {
	c.ctx_ = ctx
	return c
}

// Header returns a http.Header that can be modified by the caller to add
// headers to the request.
func (c *TasksUpdateCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}

func (c *TasksUpdateCall) doRequest(alt string) (*http.Response, error) {
	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
	body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.task)
	if err != nil {
		return nil, err
	}
	c.urlParams_.Set("alt", alt)
	c.urlParams_.Set("prettyPrint", "false")
	urls := googleapi.ResolveRelative(c.s.BasePath, "tasks/v1/lists/{tasklist}/tasks/{task}")
	urls += "?" + c.urlParams_.Encode()
	req, err := http.NewRequest("PUT", urls, body)
	if err != nil {
		return nil, err
	}
	req.Header = reqHeaders
	googleapi.Expand(req.URL, map[string]string{
		"tasklist": c.tasklistid,
		"task":     c.taskid,
	})
	c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "tasks.tasks.update", "request", internallog.HTTPRequest(req, body.Bytes()))
	return gensupport.SendRequest(c.ctx_, c.s.client, req)
}

// Do executes the "tasks.tasks.update" call.
// 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 *TasksUpdateCall) 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, gensupport.WrapError(&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, gensupport.WrapError(err)
	}
	ret := &Task{
		ServerResponse: googleapi.ServerResponse{
			Header:         res.Header,
			HTTPStatusCode: res.StatusCode,
		},
	}
	target := &ret
	b, err := gensupport.DecodeResponseBytes(target, res)
	if err != nil {
		return nil, err
	}
	c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "tasks.tasks.update", "response", internallog.HTTPResponse(res, b))
	return ret, nil
}
