1
// Package gmail provides access to the Gmail API.
3
// See https://developers.google.com/gmail/api/
7
// import "google.golang.org/api/gmail/v1"
9
// gmailService, err := gmail.New(oauthHttpClient)
17
"google.golang.org/api/googleapi"
25
// Always reference these packages, just in case the auto-generated code
27
var _ = bytes.NewBuffer
30
var _ = json.NewDecoder
33
var _ = googleapi.Version
35
var _ = strings.Replace
37
const apiId = "gmail:v1"
38
const apiName = "gmail"
39
const apiVersion = "v1"
40
const basePath = "https://www.googleapis.com/gmail/v1/users/"
42
// OAuth2 scopes used by this API.
44
// View and manage your mail
45
MailGoogleComScope = "https://mail.google.com/"
47
// Manage drafts and send emails
48
GmailComposeScope = "https://www.googleapis.com/auth/gmail.compose"
50
// View and modify but not delete your email
51
GmailModifyScope = "https://www.googleapis.com/auth/gmail.modify"
53
// View your emails messages and settings
54
GmailReadonlyScope = "https://www.googleapis.com/auth/gmail.readonly"
57
func New(client *http.Client) (*Service, error) {
59
return nil, errors.New("client is nil")
61
s := &Service{client: client, BasePath: basePath}
62
s.Users = NewUsersService(s)
68
BasePath string // API endpoint base URL
73
func NewUsersService(s *Service) *UsersService {
74
rs := &UsersService{s: s}
75
rs.Drafts = NewUsersDraftsService(s)
76
rs.History = NewUsersHistoryService(s)
77
rs.Labels = NewUsersLabelsService(s)
78
rs.Messages = NewUsersMessagesService(s)
79
rs.Threads = NewUsersThreadsService(s)
83
type UsersService struct {
86
Drafts *UsersDraftsService
88
History *UsersHistoryService
90
Labels *UsersLabelsService
92
Messages *UsersMessagesService
94
Threads *UsersThreadsService
97
func NewUsersDraftsService(s *Service) *UsersDraftsService {
98
rs := &UsersDraftsService{s: s}
102
type UsersDraftsService struct {
106
func NewUsersHistoryService(s *Service) *UsersHistoryService {
107
rs := &UsersHistoryService{s: s}
111
type UsersHistoryService struct {
115
func NewUsersLabelsService(s *Service) *UsersLabelsService {
116
rs := &UsersLabelsService{s: s}
120
type UsersLabelsService struct {
124
func NewUsersMessagesService(s *Service) *UsersMessagesService {
125
rs := &UsersMessagesService{s: s}
126
rs.Attachments = NewUsersMessagesAttachmentsService(s)
130
type UsersMessagesService struct {
133
Attachments *UsersMessagesAttachmentsService
136
func NewUsersMessagesAttachmentsService(s *Service) *UsersMessagesAttachmentsService {
137
rs := &UsersMessagesAttachmentsService{s: s}
141
type UsersMessagesAttachmentsService struct {
145
func NewUsersThreadsService(s *Service) *UsersThreadsService {
146
rs := &UsersThreadsService{s: s}
150
type UsersThreadsService struct {
155
// Id: The immutable ID of the draft.
156
Id string `json:"id,omitempty"`
158
// Message: The message content of the draft.
159
Message *Message `json:"message,omitempty"`
162
type History struct {
163
// Id: The mailbox sequence ID.
164
Id uint64 `json:"id,omitempty,string"`
166
// Messages: The messages that changed in this history record.
167
Messages []*Message `json:"messages,omitempty"`
171
// Id: The immutable ID of the label.
172
Id string `json:"id,omitempty"`
174
// LabelListVisibility: The visibility of the label in the label list in
175
// the Gmail web interface.
176
LabelListVisibility string `json:"labelListVisibility,omitempty"`
178
// MessageListVisibility: The visibility of the label in the message
179
// list in the Gmail web interface.
180
MessageListVisibility string `json:"messageListVisibility,omitempty"`
182
// MessagesTotal: The total number of messages with the label.
183
MessagesTotal int64 `json:"messagesTotal,omitempty"`
185
// MessagesUnread: The number of unread messages with the label.
186
MessagesUnread int64 `json:"messagesUnread,omitempty"`
188
// Name: The display name of the label.
189
Name string `json:"name,omitempty"`
191
// ThreadsTotal: The total number of threads with the label.
192
ThreadsTotal int64 `json:"threadsTotal,omitempty"`
194
// ThreadsUnread: The number of unread threads with the label.
195
ThreadsUnread int64 `json:"threadsUnread,omitempty"`
197
// Type: The owner type for the label. User labels are created by the
198
// user and can be modified and deleted by the user and can be applied
199
// to any message or thread. System labels are internally created and
200
// cannot be added, modified, or deleted. System labels may be able to
201
// be applied to or removed from messages and threads under some
202
// circumstances but this is not guaranteed. For example, users can
203
// apply and remove the INBOX and UNREAD labels from messages and
204
// threads, but cannot apply or remove the DRAFTS or SENT labels from
205
// messages or threads.
206
Type string `json:"type,omitempty"`
209
type ListDraftsResponse struct {
210
// Drafts: List of drafts.
211
Drafts []*Draft `json:"drafts,omitempty"`
213
// NextPageToken: Token to retrieve the next page of results in the
215
NextPageToken string `json:"nextPageToken,omitempty"`
217
// ResultSizeEstimate: Estimated total number of results.
218
ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
221
type ListHistoryResponse struct {
222
// History: List of history records.
223
History []*History `json:"history,omitempty"`
225
// HistoryId: The ID of the mailbox's current history record.
226
HistoryId uint64 `json:"historyId,omitempty,string"`
228
// NextPageToken: Page token to retrieve the next page of results in the
230
NextPageToken string `json:"nextPageToken,omitempty"`
233
type ListLabelsResponse struct {
234
// Labels: List of labels.
235
Labels []*Label `json:"labels,omitempty"`
238
type ListMessagesResponse struct {
239
// Messages: List of messages.
240
Messages []*Message `json:"messages,omitempty"`
242
// NextPageToken: Token to retrieve the next page of results in the
244
NextPageToken string `json:"nextPageToken,omitempty"`
246
// ResultSizeEstimate: Estimated total number of results.
247
ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
250
type ListThreadsResponse struct {
251
// NextPageToken: Page token to retrieve the next page of results in the
253
NextPageToken string `json:"nextPageToken,omitempty"`
255
// ResultSizeEstimate: Estimated total number of results.
256
ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
258
// Threads: List of threads.
259
Threads []*Thread `json:"threads,omitempty"`
262
type Message struct {
263
// HistoryId: The ID of the last history record that modified this
265
HistoryId uint64 `json:"historyId,omitempty,string"`
267
// Id: The immutable ID of the message.
268
Id string `json:"id,omitempty"`
270
// LabelIds: List of IDs of labels applied to this message.
271
LabelIds []string `json:"labelIds,omitempty"`
273
// Payload: The parsed email structure in the message parts.
274
Payload *MessagePart `json:"payload,omitempty"`
276
// Raw: The entire email message in an RFC 2822 formatted and URL-safe
277
// base64 encoded string. Returned in messages.get and drafts.get
278
// responses when the format=RAW parameter is supplied.
279
Raw string `json:"raw,omitempty"`
281
// SizeEstimate: Estimated size in bytes of the message.
282
SizeEstimate int64 `json:"sizeEstimate,omitempty"`
284
// Snippet: A short part of the message text.
285
Snippet string `json:"snippet,omitempty"`
287
// ThreadId: The ID of the thread the message belongs to. To add a
288
// message or draft to a thread, the following criteria must be met:
290
// The requested threadId must be specified on the Message or
291
// Draft.Message you supply with your request.
292
// - The References and
293
// In-Reply-To headers must be set in compliance with the RFC 2822
295
// - The Subject headers must match.
296
ThreadId string `json:"threadId,omitempty"`
299
type MessagePart struct {
300
// Body: The message part body for this part, which may be empty for
301
// container MIME message parts.
302
Body *MessagePartBody `json:"body,omitempty"`
304
// Filename: The filename of the attachment. Only present if this
305
// message part represents an attachment.
306
Filename string `json:"filename,omitempty"`
308
// Headers: List of headers on this message part. For the top-level
309
// message part, representing the entire message payload, it will
310
// contain the standard RFC 2822 email headers such as To, From, and
312
Headers []*MessagePartHeader `json:"headers,omitempty"`
314
// MimeType: The MIME type of the message part.
315
MimeType string `json:"mimeType,omitempty"`
317
// PartId: The immutable ID of the message part.
318
PartId string `json:"partId,omitempty"`
320
// Parts: The child MIME message parts of this part. This only applies
321
// to container MIME message parts, for example multipart/*. For non-
322
// container MIME message part types, such as text/plain, this field is
323
// empty. For more information, see RFC 1521.
324
Parts []*MessagePart `json:"parts,omitempty"`
327
type MessagePartBody struct {
328
// AttachmentId: When present, contains the ID of an external attachment
329
// that can be retrieved in a separate messages.attachments.get request.
330
// When not present, the entire content of the message part body is
331
// contained in the data field.
332
AttachmentId string `json:"attachmentId,omitempty"`
334
// Data: The body data of a MIME message part. May be empty for MIME
335
// container types that have no message body or when the body data is
336
// sent as a separate attachment. An attachment ID is present if the
337
// body data is contained in a separate attachment.
338
Data string `json:"data,omitempty"`
340
// Size: Total number of bytes in the body of the message part.
341
Size int64 `json:"size,omitempty"`
344
type MessagePartHeader struct {
345
// Name: The name of the header before the : separator. For example, To.
346
Name string `json:"name,omitempty"`
348
// Value: The value of the header after the : separator. For example,
349
// someuser@example.com.
350
Value string `json:"value,omitempty"`
353
type ModifyMessageRequest struct {
354
// AddLabelIds: A list of IDs of labels to add to this message.
355
AddLabelIds []string `json:"addLabelIds,omitempty"`
357
// RemoveLabelIds: A list IDs of labels to remove from this message.
358
RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
361
type ModifyThreadRequest struct {
362
// AddLabelIds: A list of IDs of labels to add to this thread.
363
AddLabelIds []string `json:"addLabelIds,omitempty"`
365
// RemoveLabelIds: A list of IDs of labels to remove from this thread.
366
RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
369
type Profile struct {
370
// EmailAddress: The user's email address.
371
EmailAddress string `json:"emailAddress,omitempty"`
373
// HistoryId: The ID of the mailbox's current history record.
374
HistoryId uint64 `json:"historyId,omitempty,string"`
376
// MessagesTotal: The total number of messages in the mailbox.
377
MessagesTotal int64 `json:"messagesTotal,omitempty"`
379
// ThreadsTotal: The total number of threads in the mailbox.
380
ThreadsTotal int64 `json:"threadsTotal,omitempty"`
384
// HistoryId: The ID of the last history record that modified this
386
HistoryId uint64 `json:"historyId,omitempty,string"`
388
// Id: The unique ID of the thread.
389
Id string `json:"id,omitempty"`
391
// Messages: The list of messages in the thread.
392
Messages []*Message `json:"messages,omitempty"`
394
// Snippet: A short part of the message text.
395
Snippet string `json:"snippet,omitempty"`
398
// method id "gmail.users.getProfile":
400
type UsersGetProfileCall struct {
403
opt_ map[string]interface{}
406
// GetProfile: Gets the current user's Gmail profile.
407
func (r *UsersService) GetProfile(userId string) *UsersGetProfileCall {
408
c := &UsersGetProfileCall{s: r.s, opt_: make(map[string]interface{})}
413
// Fields allows partial responses to be retrieved.
414
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
415
// for more information.
416
func (c *UsersGetProfileCall) Fields(s ...googleapi.Field) *UsersGetProfileCall {
417
c.opt_["fields"] = googleapi.CombineFields(s)
421
func (c *UsersGetProfileCall) Do() (*Profile, error) {
422
var body io.Reader = nil
423
params := make(url.Values)
424
params.Set("alt", "json")
425
if v, ok := c.opt_["fields"]; ok {
426
params.Set("fields", fmt.Sprintf("%v", v))
428
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/profile")
429
urls += "?" + params.Encode()
430
req, _ := http.NewRequest("GET", urls, body)
431
googleapi.Expand(req.URL, map[string]string{
434
req.Header.Set("User-Agent", "google-api-go-client/0.5")
435
res, err := c.s.client.Do(req)
439
defer googleapi.CloseBody(res)
440
if err := googleapi.CheckResponse(res); err != nil {
444
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
449
// "description": "Gets the current user's Gmail profile.",
450
// "httpMethod": "GET",
451
// "id": "gmail.users.getProfile",
452
// "parameterOrder": [
458
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
459
// "location": "path",
464
// "path": "{userId}/profile",
469
// "https://mail.google.com/",
470
// "https://www.googleapis.com/auth/gmail.compose",
471
// "https://www.googleapis.com/auth/gmail.modify",
472
// "https://www.googleapis.com/auth/gmail.readonly"
478
// method id "gmail.users.drafts.create":
480
type UsersDraftsCreateCall struct {
484
opt_ map[string]interface{}
488
// Create: Creates a new draft with the DRAFT label.
489
func (r *UsersDraftsService) Create(userId string, draft *Draft) *UsersDraftsCreateCall {
490
c := &UsersDraftsCreateCall{s: r.s, opt_: make(map[string]interface{})}
495
func (c *UsersDraftsCreateCall) Media(r io.Reader) *UsersDraftsCreateCall {
500
// Fields allows partial responses to be retrieved.
501
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
502
// for more information.
503
func (c *UsersDraftsCreateCall) Fields(s ...googleapi.Field) *UsersDraftsCreateCall {
504
c.opt_["fields"] = googleapi.CombineFields(s)
508
func (c *UsersDraftsCreateCall) Do() (*Draft, error) {
509
var body io.Reader = nil
510
body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
514
ctype := "application/json"
515
params := make(url.Values)
516
params.Set("alt", "json")
517
if v, ok := c.opt_["fields"]; ok {
518
params.Set("fields", fmt.Sprintf("%v", v))
520
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
522
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
523
params.Set("uploadType", "multipart")
525
urls += "?" + params.Encode()
526
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
527
req, _ := http.NewRequest("POST", urls, body)
528
googleapi.Expand(req.URL, map[string]string{
532
req.ContentLength = contentLength_
534
req.Header.Set("Content-Type", ctype)
535
req.Header.Set("User-Agent", "google-api-go-client/0.5")
536
res, err := c.s.client.Do(req)
540
defer googleapi.CloseBody(res)
541
if err := googleapi.CheckResponse(res); err != nil {
545
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
550
// "description": "Creates a new draft with the DRAFT label.",
551
// "httpMethod": "POST",
552
// "id": "gmail.users.drafts.create",
557
// "maxSize": "35MB",
560
// "multipart": true,
561
// "path": "/resumable/upload/gmail/v1/users/{userId}/drafts"
564
// "multipart": true,
565
// "path": "/upload/gmail/v1/users/{userId}/drafts"
569
// "parameterOrder": [
575
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
576
// "location": "path",
581
// "path": "{userId}/drafts",
589
// "https://mail.google.com/",
590
// "https://www.googleapis.com/auth/gmail.compose",
591
// "https://www.googleapis.com/auth/gmail.modify"
593
// "supportsMediaUpload": true
598
// method id "gmail.users.drafts.delete":
600
type UsersDraftsDeleteCall struct {
604
opt_ map[string]interface{}
607
// Delete: Immediately and permanently deletes the specified draft. Does
608
// not simply trash it.
609
func (r *UsersDraftsService) Delete(userId string, id string) *UsersDraftsDeleteCall {
610
c := &UsersDraftsDeleteCall{s: r.s, opt_: make(map[string]interface{})}
616
// Fields allows partial responses to be retrieved.
617
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
618
// for more information.
619
func (c *UsersDraftsDeleteCall) Fields(s ...googleapi.Field) *UsersDraftsDeleteCall {
620
c.opt_["fields"] = googleapi.CombineFields(s)
624
func (c *UsersDraftsDeleteCall) Do() error {
625
var body io.Reader = nil
626
params := make(url.Values)
627
params.Set("alt", "json")
628
if v, ok := c.opt_["fields"]; ok {
629
params.Set("fields", fmt.Sprintf("%v", v))
631
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
632
urls += "?" + params.Encode()
633
req, _ := http.NewRequest("DELETE", urls, body)
634
googleapi.Expand(req.URL, map[string]string{
638
req.Header.Set("User-Agent", "google-api-go-client/0.5")
639
res, err := c.s.client.Do(req)
643
defer googleapi.CloseBody(res)
644
if err := googleapi.CheckResponse(res); err != nil {
649
// "description": "Immediately and permanently deletes the specified draft. Does not simply trash it.",
650
// "httpMethod": "DELETE",
651
// "id": "gmail.users.drafts.delete",
652
// "parameterOrder": [
658
// "description": "The ID of the draft to delete.",
659
// "location": "path",
665
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
666
// "location": "path",
671
// "path": "{userId}/drafts/{id}",
673
// "https://mail.google.com/",
674
// "https://www.googleapis.com/auth/gmail.compose",
675
// "https://www.googleapis.com/auth/gmail.modify"
681
// method id "gmail.users.drafts.get":
683
type UsersDraftsGetCall struct {
687
opt_ map[string]interface{}
690
// Get: Gets the specified draft.
691
func (r *UsersDraftsService) Get(userId string, id string) *UsersDraftsGetCall {
692
c := &UsersDraftsGetCall{s: r.s, opt_: make(map[string]interface{})}
698
// Format sets the optional parameter "format": The format to return the
700
func (c *UsersDraftsGetCall) Format(format string) *UsersDraftsGetCall {
701
c.opt_["format"] = format
705
// Fields allows partial responses to be retrieved.
706
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
707
// for more information.
708
func (c *UsersDraftsGetCall) Fields(s ...googleapi.Field) *UsersDraftsGetCall {
709
c.opt_["fields"] = googleapi.CombineFields(s)
713
func (c *UsersDraftsGetCall) Do() (*Draft, error) {
714
var body io.Reader = nil
715
params := make(url.Values)
716
params.Set("alt", "json")
717
if v, ok := c.opt_["format"]; ok {
718
params.Set("format", fmt.Sprintf("%v", v))
720
if v, ok := c.opt_["fields"]; ok {
721
params.Set("fields", fmt.Sprintf("%v", v))
723
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
724
urls += "?" + params.Encode()
725
req, _ := http.NewRequest("GET", urls, body)
726
googleapi.Expand(req.URL, map[string]string{
730
req.Header.Set("User-Agent", "google-api-go-client/0.5")
731
res, err := c.s.client.Do(req)
735
defer googleapi.CloseBody(res)
736
if err := googleapi.CheckResponse(res); err != nil {
740
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
745
// "description": "Gets the specified draft.",
746
// "httpMethod": "GET",
747
// "id": "gmail.users.drafts.get",
748
// "parameterOrder": [
754
// "default": "full",
755
// "description": "The format to return the draft in.",
762
// "enumDescriptions": [
768
// "location": "query",
772
// "description": "The ID of the draft to retrieve.",
773
// "location": "path",
779
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
780
// "location": "path",
785
// "path": "{userId}/drafts/{id}",
790
// "https://mail.google.com/",
791
// "https://www.googleapis.com/auth/gmail.compose",
792
// "https://www.googleapis.com/auth/gmail.modify",
793
// "https://www.googleapis.com/auth/gmail.readonly"
799
// method id "gmail.users.drafts.list":
801
type UsersDraftsListCall struct {
804
opt_ map[string]interface{}
807
// List: Lists the drafts in the user's mailbox.
808
func (r *UsersDraftsService) List(userId string) *UsersDraftsListCall {
809
c := &UsersDraftsListCall{s: r.s, opt_: make(map[string]interface{})}
814
// MaxResults sets the optional parameter "maxResults": Maximum number
815
// of drafts to return.
816
func (c *UsersDraftsListCall) MaxResults(maxResults int64) *UsersDraftsListCall {
817
c.opt_["maxResults"] = maxResults
821
// PageToken sets the optional parameter "pageToken": Page token to
822
// retrieve a specific page of results in the list.
823
func (c *UsersDraftsListCall) PageToken(pageToken string) *UsersDraftsListCall {
824
c.opt_["pageToken"] = pageToken
828
// Fields allows partial responses to be retrieved.
829
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
830
// for more information.
831
func (c *UsersDraftsListCall) Fields(s ...googleapi.Field) *UsersDraftsListCall {
832
c.opt_["fields"] = googleapi.CombineFields(s)
836
func (c *UsersDraftsListCall) Do() (*ListDraftsResponse, error) {
837
var body io.Reader = nil
838
params := make(url.Values)
839
params.Set("alt", "json")
840
if v, ok := c.opt_["maxResults"]; ok {
841
params.Set("maxResults", fmt.Sprintf("%v", v))
843
if v, ok := c.opt_["pageToken"]; ok {
844
params.Set("pageToken", fmt.Sprintf("%v", v))
846
if v, ok := c.opt_["fields"]; ok {
847
params.Set("fields", fmt.Sprintf("%v", v))
849
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
850
urls += "?" + params.Encode()
851
req, _ := http.NewRequest("GET", urls, body)
852
googleapi.Expand(req.URL, map[string]string{
855
req.Header.Set("User-Agent", "google-api-go-client/0.5")
856
res, err := c.s.client.Do(req)
860
defer googleapi.CloseBody(res)
861
if err := googleapi.CheckResponse(res); err != nil {
864
var ret *ListDraftsResponse
865
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
870
// "description": "Lists the drafts in the user's mailbox.",
871
// "httpMethod": "GET",
872
// "id": "gmail.users.drafts.list",
873
// "parameterOrder": [
879
// "description": "Maximum number of drafts to return.",
880
// "format": "uint32",
881
// "location": "query",
885
// "description": "Page token to retrieve a specific page of results in the list.",
886
// "location": "query",
891
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
892
// "location": "path",
897
// "path": "{userId}/drafts",
899
// "$ref": "ListDraftsResponse"
902
// "https://mail.google.com/",
903
// "https://www.googleapis.com/auth/gmail.compose",
904
// "https://www.googleapis.com/auth/gmail.modify",
905
// "https://www.googleapis.com/auth/gmail.readonly"
911
// method id "gmail.users.drafts.send":
913
type UsersDraftsSendCall struct {
917
opt_ map[string]interface{}
921
// Send: Sends the specified, existing draft to the recipients in the
922
// To, Cc, and Bcc headers.
923
func (r *UsersDraftsService) Send(userId string, draft *Draft) *UsersDraftsSendCall {
924
c := &UsersDraftsSendCall{s: r.s, opt_: make(map[string]interface{})}
929
func (c *UsersDraftsSendCall) Media(r io.Reader) *UsersDraftsSendCall {
934
// Fields allows partial responses to be retrieved.
935
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
936
// for more information.
937
func (c *UsersDraftsSendCall) Fields(s ...googleapi.Field) *UsersDraftsSendCall {
938
c.opt_["fields"] = googleapi.CombineFields(s)
942
func (c *UsersDraftsSendCall) Do() (*Message, error) {
943
var body io.Reader = nil
944
body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
948
ctype := "application/json"
949
params := make(url.Values)
950
params.Set("alt", "json")
951
if v, ok := c.opt_["fields"]; ok {
952
params.Set("fields", fmt.Sprintf("%v", v))
954
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/send")
956
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
957
params.Set("uploadType", "multipart")
959
urls += "?" + params.Encode()
960
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
961
req, _ := http.NewRequest("POST", urls, body)
962
googleapi.Expand(req.URL, map[string]string{
966
req.ContentLength = contentLength_
968
req.Header.Set("Content-Type", ctype)
969
req.Header.Set("User-Agent", "google-api-go-client/0.5")
970
res, err := c.s.client.Do(req)
974
defer googleapi.CloseBody(res)
975
if err := googleapi.CheckResponse(res); err != nil {
979
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
984
// "description": "Sends the specified, existing draft to the recipients in the To, Cc, and Bcc headers.",
985
// "httpMethod": "POST",
986
// "id": "gmail.users.drafts.send",
991
// "maxSize": "35MB",
994
// "multipart": true,
995
// "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/send"
998
// "multipart": true,
999
// "path": "/upload/gmail/v1/users/{userId}/drafts/send"
1003
// "parameterOrder": [
1009
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1010
// "location": "path",
1011
// "required": true,
1015
// "path": "{userId}/drafts/send",
1020
// "$ref": "Message"
1023
// "https://mail.google.com/",
1024
// "https://www.googleapis.com/auth/gmail.compose",
1025
// "https://www.googleapis.com/auth/gmail.modify"
1027
// "supportsMediaUpload": true
1032
// method id "gmail.users.drafts.update":
1034
type UsersDraftsUpdateCall struct {
1039
opt_ map[string]interface{}
1043
// Update: Replaces a draft's content.
1044
func (r *UsersDraftsService) Update(userId string, id string, draft *Draft) *UsersDraftsUpdateCall {
1045
c := &UsersDraftsUpdateCall{s: r.s, opt_: make(map[string]interface{})}
1051
func (c *UsersDraftsUpdateCall) Media(r io.Reader) *UsersDraftsUpdateCall {
1056
// Fields allows partial responses to be retrieved.
1057
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1058
// for more information.
1059
func (c *UsersDraftsUpdateCall) Fields(s ...googleapi.Field) *UsersDraftsUpdateCall {
1060
c.opt_["fields"] = googleapi.CombineFields(s)
1064
func (c *UsersDraftsUpdateCall) Do() (*Draft, error) {
1065
var body io.Reader = nil
1066
body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
1070
ctype := "application/json"
1071
params := make(url.Values)
1072
params.Set("alt", "json")
1073
if v, ok := c.opt_["fields"]; ok {
1074
params.Set("fields", fmt.Sprintf("%v", v))
1076
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
1077
if c.media_ != nil {
1078
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
1079
params.Set("uploadType", "multipart")
1081
urls += "?" + params.Encode()
1082
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
1083
req, _ := http.NewRequest("PUT", urls, body)
1084
googleapi.Expand(req.URL, map[string]string{
1089
req.ContentLength = contentLength_
1091
req.Header.Set("Content-Type", ctype)
1092
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1093
res, err := c.s.client.Do(req)
1097
defer googleapi.CloseBody(res)
1098
if err := googleapi.CheckResponse(res); err != nil {
1102
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1107
// "description": "Replaces a draft's content.",
1108
// "httpMethod": "PUT",
1109
// "id": "gmail.users.drafts.update",
1114
// "maxSize": "35MB",
1117
// "multipart": true,
1118
// "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/{id}"
1121
// "multipart": true,
1122
// "path": "/upload/gmail/v1/users/{userId}/drafts/{id}"
1126
// "parameterOrder": [
1132
// "description": "The ID of the draft to update.",
1133
// "location": "path",
1134
// "required": true,
1139
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1140
// "location": "path",
1141
// "required": true,
1145
// "path": "{userId}/drafts/{id}",
1153
// "https://mail.google.com/",
1154
// "https://www.googleapis.com/auth/gmail.compose",
1155
// "https://www.googleapis.com/auth/gmail.modify"
1157
// "supportsMediaUpload": true
1162
// method id "gmail.users.history.list":
1164
type UsersHistoryListCall struct {
1167
opt_ map[string]interface{}
1170
// List: Lists the history of all changes to the given mailbox. History
1171
// results are returned in chronological order (increasing historyId).
1172
func (r *UsersHistoryService) List(userId string) *UsersHistoryListCall {
1173
c := &UsersHistoryListCall{s: r.s, opt_: make(map[string]interface{})}
1178
// LabelId sets the optional parameter "labelId": Only return messages
1179
// with a label matching the ID.
1180
func (c *UsersHistoryListCall) LabelId(labelId string) *UsersHistoryListCall {
1181
c.opt_["labelId"] = labelId
1185
// MaxResults sets the optional parameter "maxResults": The maximum
1186
// number of history records to return.
1187
func (c *UsersHistoryListCall) MaxResults(maxResults int64) *UsersHistoryListCall {
1188
c.opt_["maxResults"] = maxResults
1192
// PageToken sets the optional parameter "pageToken": Page token to
1193
// retrieve a specific page of results in the list.
1194
func (c *UsersHistoryListCall) PageToken(pageToken string) *UsersHistoryListCall {
1195
c.opt_["pageToken"] = pageToken
1199
// StartHistoryId sets the optional parameter "startHistoryId":
1200
// Required. Returns history records after the specified startHistoryId.
1201
// The supplied startHistoryId should be obtained from the historyId of
1202
// a message, thread, or previous list response. History IDs increase
1203
// chronologically but are not contiguous with random gaps in between
1204
// valid IDs. Supplying an invalid or out of date startHistoryId
1205
// typically returns an HTTP 404 error code. A historyId is typically
1206
// valid for at least a week, but in some circumstances may be valid for
1207
// only a few hours. If you receive an HTTP 404 error response, your
1208
// application should perform a full sync. If you receive no
1209
// nextPageToken in the response, there are no updates to retrieve and
1210
// you can store the returned historyId for a future request.
1211
func (c *UsersHistoryListCall) StartHistoryId(startHistoryId uint64) *UsersHistoryListCall {
1212
c.opt_["startHistoryId"] = startHistoryId
1216
// Fields allows partial responses to be retrieved.
1217
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1218
// for more information.
1219
func (c *UsersHistoryListCall) Fields(s ...googleapi.Field) *UsersHistoryListCall {
1220
c.opt_["fields"] = googleapi.CombineFields(s)
1224
func (c *UsersHistoryListCall) Do() (*ListHistoryResponse, error) {
1225
var body io.Reader = nil
1226
params := make(url.Values)
1227
params.Set("alt", "json")
1228
if v, ok := c.opt_["labelId"]; ok {
1229
params.Set("labelId", fmt.Sprintf("%v", v))
1231
if v, ok := c.opt_["maxResults"]; ok {
1232
params.Set("maxResults", fmt.Sprintf("%v", v))
1234
if v, ok := c.opt_["pageToken"]; ok {
1235
params.Set("pageToken", fmt.Sprintf("%v", v))
1237
if v, ok := c.opt_["startHistoryId"]; ok {
1238
params.Set("startHistoryId", fmt.Sprintf("%v", v))
1240
if v, ok := c.opt_["fields"]; ok {
1241
params.Set("fields", fmt.Sprintf("%v", v))
1243
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/history")
1244
urls += "?" + params.Encode()
1245
req, _ := http.NewRequest("GET", urls, body)
1246
googleapi.Expand(req.URL, map[string]string{
1249
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1250
res, err := c.s.client.Do(req)
1254
defer googleapi.CloseBody(res)
1255
if err := googleapi.CheckResponse(res); err != nil {
1258
var ret *ListHistoryResponse
1259
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1264
// "description": "Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId).",
1265
// "httpMethod": "GET",
1266
// "id": "gmail.users.history.list",
1267
// "parameterOrder": [
1272
// "description": "Only return messages with a label matching the ID.",
1273
// "location": "query",
1277
// "default": "100",
1278
// "description": "The maximum number of history records to return.",
1279
// "format": "uint32",
1280
// "location": "query",
1281
// "type": "integer"
1284
// "description": "Page token to retrieve a specific page of results in the list.",
1285
// "location": "query",
1288
// "startHistoryId": {
1289
// "description": "Required. Returns history records after the specified startHistoryId. The supplied startHistoryId should be obtained from the historyId of a message, thread, or previous list response. History IDs increase chronologically but are not contiguous with random gaps in between valid IDs. Supplying an invalid or out of date startHistoryId typically returns an HTTP 404 error code. A historyId is typically valid for at least a week, but in some circumstances may be valid for only a few hours. If you receive an HTTP 404 error response, your application should perform a full sync. If you receive no nextPageToken in the response, there are no updates to retrieve and you can store the returned historyId for a future request.",
1290
// "format": "uint64",
1291
// "location": "query",
1296
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1297
// "location": "path",
1298
// "required": true,
1302
// "path": "{userId}/history",
1304
// "$ref": "ListHistoryResponse"
1307
// "https://mail.google.com/",
1308
// "https://www.googleapis.com/auth/gmail.modify",
1309
// "https://www.googleapis.com/auth/gmail.readonly"
1315
// method id "gmail.users.labels.create":
1317
type UsersLabelsCreateCall struct {
1321
opt_ map[string]interface{}
1324
// Create: Creates a new label.
1325
func (r *UsersLabelsService) Create(userId string, label *Label) *UsersLabelsCreateCall {
1326
c := &UsersLabelsCreateCall{s: r.s, opt_: make(map[string]interface{})}
1332
// Fields allows partial responses to be retrieved.
1333
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1334
// for more information.
1335
func (c *UsersLabelsCreateCall) Fields(s ...googleapi.Field) *UsersLabelsCreateCall {
1336
c.opt_["fields"] = googleapi.CombineFields(s)
1340
func (c *UsersLabelsCreateCall) Do() (*Label, error) {
1341
var body io.Reader = nil
1342
body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
1346
ctype := "application/json"
1347
params := make(url.Values)
1348
params.Set("alt", "json")
1349
if v, ok := c.opt_["fields"]; ok {
1350
params.Set("fields", fmt.Sprintf("%v", v))
1352
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
1353
urls += "?" + params.Encode()
1354
req, _ := http.NewRequest("POST", urls, body)
1355
googleapi.Expand(req.URL, map[string]string{
1358
req.Header.Set("Content-Type", ctype)
1359
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1360
res, err := c.s.client.Do(req)
1364
defer googleapi.CloseBody(res)
1365
if err := googleapi.CheckResponse(res); err != nil {
1369
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1374
// "description": "Creates a new label.",
1375
// "httpMethod": "POST",
1376
// "id": "gmail.users.labels.create",
1377
// "parameterOrder": [
1383
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1384
// "location": "path",
1385
// "required": true,
1389
// "path": "{userId}/labels",
1397
// "https://mail.google.com/",
1398
// "https://www.googleapis.com/auth/gmail.modify"
1404
// method id "gmail.users.labels.delete":
1406
type UsersLabelsDeleteCall struct {
1410
opt_ map[string]interface{}
1413
// Delete: Immediately and permanently deletes the specified label and
1414
// removes it from any messages and threads that it is applied to.
1415
func (r *UsersLabelsService) Delete(userId string, id string) *UsersLabelsDeleteCall {
1416
c := &UsersLabelsDeleteCall{s: r.s, opt_: make(map[string]interface{})}
1422
// Fields allows partial responses to be retrieved.
1423
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1424
// for more information.
1425
func (c *UsersLabelsDeleteCall) Fields(s ...googleapi.Field) *UsersLabelsDeleteCall {
1426
c.opt_["fields"] = googleapi.CombineFields(s)
1430
func (c *UsersLabelsDeleteCall) Do() error {
1431
var body io.Reader = nil
1432
params := make(url.Values)
1433
params.Set("alt", "json")
1434
if v, ok := c.opt_["fields"]; ok {
1435
params.Set("fields", fmt.Sprintf("%v", v))
1437
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
1438
urls += "?" + params.Encode()
1439
req, _ := http.NewRequest("DELETE", urls, body)
1440
googleapi.Expand(req.URL, map[string]string{
1444
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1445
res, err := c.s.client.Do(req)
1449
defer googleapi.CloseBody(res)
1450
if err := googleapi.CheckResponse(res); err != nil {
1455
// "description": "Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.",
1456
// "httpMethod": "DELETE",
1457
// "id": "gmail.users.labels.delete",
1458
// "parameterOrder": [
1464
// "description": "The ID of the label to delete.",
1465
// "location": "path",
1466
// "required": true,
1471
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1472
// "location": "path",
1473
// "required": true,
1477
// "path": "{userId}/labels/{id}",
1479
// "https://mail.google.com/",
1480
// "https://www.googleapis.com/auth/gmail.modify"
1486
// method id "gmail.users.labels.get":
1488
type UsersLabelsGetCall struct {
1492
opt_ map[string]interface{}
1495
// Get: Gets the specified label.
1496
func (r *UsersLabelsService) Get(userId string, id string) *UsersLabelsGetCall {
1497
c := &UsersLabelsGetCall{s: r.s, opt_: make(map[string]interface{})}
1503
// Fields allows partial responses to be retrieved.
1504
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1505
// for more information.
1506
func (c *UsersLabelsGetCall) Fields(s ...googleapi.Field) *UsersLabelsGetCall {
1507
c.opt_["fields"] = googleapi.CombineFields(s)
1511
func (c *UsersLabelsGetCall) Do() (*Label, error) {
1512
var body io.Reader = nil
1513
params := make(url.Values)
1514
params.Set("alt", "json")
1515
if v, ok := c.opt_["fields"]; ok {
1516
params.Set("fields", fmt.Sprintf("%v", v))
1518
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
1519
urls += "?" + params.Encode()
1520
req, _ := http.NewRequest("GET", urls, body)
1521
googleapi.Expand(req.URL, map[string]string{
1525
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1526
res, err := c.s.client.Do(req)
1530
defer googleapi.CloseBody(res)
1531
if err := googleapi.CheckResponse(res); err != nil {
1535
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1540
// "description": "Gets the specified label.",
1541
// "httpMethod": "GET",
1542
// "id": "gmail.users.labels.get",
1543
// "parameterOrder": [
1549
// "description": "The ID of the label to retrieve.",
1550
// "location": "path",
1551
// "required": true,
1556
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1557
// "location": "path",
1558
// "required": true,
1562
// "path": "{userId}/labels/{id}",
1567
// "https://mail.google.com/",
1568
// "https://www.googleapis.com/auth/gmail.modify",
1569
// "https://www.googleapis.com/auth/gmail.readonly"
1575
// method id "gmail.users.labels.list":
1577
type UsersLabelsListCall struct {
1580
opt_ map[string]interface{}
1583
// List: Lists all labels in the user's mailbox.
1584
func (r *UsersLabelsService) List(userId string) *UsersLabelsListCall {
1585
c := &UsersLabelsListCall{s: r.s, opt_: make(map[string]interface{})}
1590
// Fields allows partial responses to be retrieved.
1591
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1592
// for more information.
1593
func (c *UsersLabelsListCall) Fields(s ...googleapi.Field) *UsersLabelsListCall {
1594
c.opt_["fields"] = googleapi.CombineFields(s)
1598
func (c *UsersLabelsListCall) Do() (*ListLabelsResponse, error) {
1599
var body io.Reader = nil
1600
params := make(url.Values)
1601
params.Set("alt", "json")
1602
if v, ok := c.opt_["fields"]; ok {
1603
params.Set("fields", fmt.Sprintf("%v", v))
1605
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
1606
urls += "?" + params.Encode()
1607
req, _ := http.NewRequest("GET", urls, body)
1608
googleapi.Expand(req.URL, map[string]string{
1611
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1612
res, err := c.s.client.Do(req)
1616
defer googleapi.CloseBody(res)
1617
if err := googleapi.CheckResponse(res); err != nil {
1620
var ret *ListLabelsResponse
1621
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1626
// "description": "Lists all labels in the user's mailbox.",
1627
// "httpMethod": "GET",
1628
// "id": "gmail.users.labels.list",
1629
// "parameterOrder": [
1635
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1636
// "location": "path",
1637
// "required": true,
1641
// "path": "{userId}/labels",
1643
// "$ref": "ListLabelsResponse"
1646
// "https://mail.google.com/",
1647
// "https://www.googleapis.com/auth/gmail.modify",
1648
// "https://www.googleapis.com/auth/gmail.readonly"
1654
// method id "gmail.users.labels.patch":
1656
type UsersLabelsPatchCall struct {
1661
opt_ map[string]interface{}
1664
// Patch: Updates the specified label. This method supports patch
1666
func (r *UsersLabelsService) Patch(userId string, id string, label *Label) *UsersLabelsPatchCall {
1667
c := &UsersLabelsPatchCall{s: r.s, opt_: make(map[string]interface{})}
1674
// Fields allows partial responses to be retrieved.
1675
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1676
// for more information.
1677
func (c *UsersLabelsPatchCall) Fields(s ...googleapi.Field) *UsersLabelsPatchCall {
1678
c.opt_["fields"] = googleapi.CombineFields(s)
1682
func (c *UsersLabelsPatchCall) Do() (*Label, error) {
1683
var body io.Reader = nil
1684
body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
1688
ctype := "application/json"
1689
params := make(url.Values)
1690
params.Set("alt", "json")
1691
if v, ok := c.opt_["fields"]; ok {
1692
params.Set("fields", fmt.Sprintf("%v", v))
1694
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
1695
urls += "?" + params.Encode()
1696
req, _ := http.NewRequest("PATCH", urls, body)
1697
googleapi.Expand(req.URL, map[string]string{
1701
req.Header.Set("Content-Type", ctype)
1702
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1703
res, err := c.s.client.Do(req)
1707
defer googleapi.CloseBody(res)
1708
if err := googleapi.CheckResponse(res); err != nil {
1712
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1717
// "description": "Updates the specified label. This method supports patch semantics.",
1718
// "httpMethod": "PATCH",
1719
// "id": "gmail.users.labels.patch",
1720
// "parameterOrder": [
1726
// "description": "The ID of the label to update.",
1727
// "location": "path",
1728
// "required": true,
1733
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1734
// "location": "path",
1735
// "required": true,
1739
// "path": "{userId}/labels/{id}",
1747
// "https://mail.google.com/",
1748
// "https://www.googleapis.com/auth/gmail.modify"
1754
// method id "gmail.users.labels.update":
1756
type UsersLabelsUpdateCall struct {
1761
opt_ map[string]interface{}
1764
// Update: Updates the specified label.
1765
func (r *UsersLabelsService) Update(userId string, id string, label *Label) *UsersLabelsUpdateCall {
1766
c := &UsersLabelsUpdateCall{s: r.s, opt_: make(map[string]interface{})}
1773
// Fields allows partial responses to be retrieved.
1774
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1775
// for more information.
1776
func (c *UsersLabelsUpdateCall) Fields(s ...googleapi.Field) *UsersLabelsUpdateCall {
1777
c.opt_["fields"] = googleapi.CombineFields(s)
1781
func (c *UsersLabelsUpdateCall) Do() (*Label, error) {
1782
var body io.Reader = nil
1783
body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
1787
ctype := "application/json"
1788
params := make(url.Values)
1789
params.Set("alt", "json")
1790
if v, ok := c.opt_["fields"]; ok {
1791
params.Set("fields", fmt.Sprintf("%v", v))
1793
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
1794
urls += "?" + params.Encode()
1795
req, _ := http.NewRequest("PUT", urls, body)
1796
googleapi.Expand(req.URL, map[string]string{
1800
req.Header.Set("Content-Type", ctype)
1801
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1802
res, err := c.s.client.Do(req)
1806
defer googleapi.CloseBody(res)
1807
if err := googleapi.CheckResponse(res); err != nil {
1811
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
1816
// "description": "Updates the specified label.",
1817
// "httpMethod": "PUT",
1818
// "id": "gmail.users.labels.update",
1819
// "parameterOrder": [
1825
// "description": "The ID of the label to update.",
1826
// "location": "path",
1827
// "required": true,
1832
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1833
// "location": "path",
1834
// "required": true,
1838
// "path": "{userId}/labels/{id}",
1846
// "https://mail.google.com/",
1847
// "https://www.googleapis.com/auth/gmail.modify"
1853
// method id "gmail.users.messages.delete":
1855
type UsersMessagesDeleteCall struct {
1859
opt_ map[string]interface{}
1862
// Delete: Immediately and permanently deletes the specified message.
1863
// This operation cannot be undone. Prefer messages.trash instead.
1864
func (r *UsersMessagesService) Delete(userId string, id string) *UsersMessagesDeleteCall {
1865
c := &UsersMessagesDeleteCall{s: r.s, opt_: make(map[string]interface{})}
1871
// Fields allows partial responses to be retrieved.
1872
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1873
// for more information.
1874
func (c *UsersMessagesDeleteCall) Fields(s ...googleapi.Field) *UsersMessagesDeleteCall {
1875
c.opt_["fields"] = googleapi.CombineFields(s)
1879
func (c *UsersMessagesDeleteCall) Do() error {
1880
var body io.Reader = nil
1881
params := make(url.Values)
1882
params.Set("alt", "json")
1883
if v, ok := c.opt_["fields"]; ok {
1884
params.Set("fields", fmt.Sprintf("%v", v))
1886
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
1887
urls += "?" + params.Encode()
1888
req, _ := http.NewRequest("DELETE", urls, body)
1889
googleapi.Expand(req.URL, map[string]string{
1893
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1894
res, err := c.s.client.Do(req)
1898
defer googleapi.CloseBody(res)
1899
if err := googleapi.CheckResponse(res); err != nil {
1904
// "description": "Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer messages.trash instead.",
1905
// "httpMethod": "DELETE",
1906
// "id": "gmail.users.messages.delete",
1907
// "parameterOrder": [
1913
// "description": "The ID of the message to delete.",
1914
// "location": "path",
1915
// "required": true,
1920
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
1921
// "location": "path",
1922
// "required": true,
1926
// "path": "{userId}/messages/{id}",
1928
// "https://mail.google.com/"
1934
// method id "gmail.users.messages.get":
1936
type UsersMessagesGetCall struct {
1940
opt_ map[string]interface{}
1943
// Get: Gets the specified message.
1944
func (r *UsersMessagesService) Get(userId string, id string) *UsersMessagesGetCall {
1945
c := &UsersMessagesGetCall{s: r.s, opt_: make(map[string]interface{})}
1951
// Format sets the optional parameter "format": The format to return the
1953
func (c *UsersMessagesGetCall) Format(format string) *UsersMessagesGetCall {
1954
c.opt_["format"] = format
1958
// MetadataHeaders sets the optional parameter "metadataHeaders": When
1959
// given and format is METADATA, only include headers specified.
1960
func (c *UsersMessagesGetCall) MetadataHeaders(metadataHeaders string) *UsersMessagesGetCall {
1961
c.opt_["metadataHeaders"] = metadataHeaders
1965
// Fields allows partial responses to be retrieved.
1966
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
1967
// for more information.
1968
func (c *UsersMessagesGetCall) Fields(s ...googleapi.Field) *UsersMessagesGetCall {
1969
c.opt_["fields"] = googleapi.CombineFields(s)
1973
func (c *UsersMessagesGetCall) Do() (*Message, error) {
1974
var body io.Reader = nil
1975
params := make(url.Values)
1976
params.Set("alt", "json")
1977
if v, ok := c.opt_["format"]; ok {
1978
params.Set("format", fmt.Sprintf("%v", v))
1980
if v, ok := c.opt_["metadataHeaders"]; ok {
1981
params.Set("metadataHeaders", fmt.Sprintf("%v", v))
1983
if v, ok := c.opt_["fields"]; ok {
1984
params.Set("fields", fmt.Sprintf("%v", v))
1986
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
1987
urls += "?" + params.Encode()
1988
req, _ := http.NewRequest("GET", urls, body)
1989
googleapi.Expand(req.URL, map[string]string{
1993
req.Header.Set("User-Agent", "google-api-go-client/0.5")
1994
res, err := c.s.client.Do(req)
1998
defer googleapi.CloseBody(res)
1999
if err := googleapi.CheckResponse(res); err != nil {
2003
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2008
// "description": "Gets the specified message.",
2009
// "httpMethod": "GET",
2010
// "id": "gmail.users.messages.get",
2011
// "parameterOrder": [
2017
// "default": "full",
2018
// "description": "The format to return the message in.",
2025
// "enumDescriptions": [
2031
// "location": "query",
2035
// "description": "The ID of the message to retrieve.",
2036
// "location": "path",
2037
// "required": true,
2040
// "metadataHeaders": {
2041
// "description": "When given and format is METADATA, only include headers specified.",
2042
// "location": "query",
2043
// "repeated": true,
2048
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2049
// "location": "path",
2050
// "required": true,
2054
// "path": "{userId}/messages/{id}",
2056
// "$ref": "Message"
2059
// "https://mail.google.com/",
2060
// "https://www.googleapis.com/auth/gmail.modify",
2061
// "https://www.googleapis.com/auth/gmail.readonly"
2067
// method id "gmail.users.messages.import":
2069
type UsersMessagesImportCall struct {
2073
opt_ map[string]interface{}
2077
// Import: Imports a message into only this user's mailbox, with
2078
// standard email delivery scanning and classification similar to
2079
// receiving via SMTP. Does not send a message.
2080
func (r *UsersMessagesService) Import(userId string, message *Message) *UsersMessagesImportCall {
2081
c := &UsersMessagesImportCall{s: r.s, opt_: make(map[string]interface{})}
2087
// InternalDateSource sets the optional parameter "internalDateSource":
2088
// Source for Gmail's internal date of the message.
2089
func (c *UsersMessagesImportCall) InternalDateSource(internalDateSource string) *UsersMessagesImportCall {
2090
c.opt_["internalDateSource"] = internalDateSource
2093
func (c *UsersMessagesImportCall) Media(r io.Reader) *UsersMessagesImportCall {
2098
// Fields allows partial responses to be retrieved.
2099
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2100
// for more information.
2101
func (c *UsersMessagesImportCall) Fields(s ...googleapi.Field) *UsersMessagesImportCall {
2102
c.opt_["fields"] = googleapi.CombineFields(s)
2106
func (c *UsersMessagesImportCall) Do() (*Message, error) {
2107
var body io.Reader = nil
2108
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
2112
ctype := "application/json"
2113
params := make(url.Values)
2114
params.Set("alt", "json")
2115
if v, ok := c.opt_["internalDateSource"]; ok {
2116
params.Set("internalDateSource", fmt.Sprintf("%v", v))
2118
if v, ok := c.opt_["fields"]; ok {
2119
params.Set("fields", fmt.Sprintf("%v", v))
2121
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/import")
2122
if c.media_ != nil {
2123
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
2124
params.Set("uploadType", "multipart")
2126
urls += "?" + params.Encode()
2127
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
2128
req, _ := http.NewRequest("POST", urls, body)
2129
googleapi.Expand(req.URL, map[string]string{
2133
req.ContentLength = contentLength_
2135
req.Header.Set("Content-Type", ctype)
2136
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2137
res, err := c.s.client.Do(req)
2141
defer googleapi.CloseBody(res)
2142
if err := googleapi.CheckResponse(res); err != nil {
2146
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2151
// "description": "Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. Does not send a message.",
2152
// "httpMethod": "POST",
2153
// "id": "gmail.users.messages.import",
2158
// "maxSize": "35MB",
2161
// "multipart": true,
2162
// "path": "/resumable/upload/gmail/v1/users/{userId}/messages/import"
2165
// "multipart": true,
2166
// "path": "/upload/gmail/v1/users/{userId}/messages/import"
2170
// "parameterOrder": [
2174
// "internalDateSource": {
2175
// "default": "dateHeader",
2176
// "description": "Source for Gmail's internal date of the message.",
2181
// "enumDescriptions": [
2185
// "location": "query",
2190
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2191
// "location": "path",
2192
// "required": true,
2196
// "path": "{userId}/messages/import",
2198
// "$ref": "Message"
2201
// "$ref": "Message"
2204
// "https://mail.google.com/",
2205
// "https://www.googleapis.com/auth/gmail.modify"
2207
// "supportsMediaUpload": true
2212
// method id "gmail.users.messages.insert":
2214
type UsersMessagesInsertCall struct {
2218
opt_ map[string]interface{}
2222
// Insert: Directly inserts a message into only this user's mailbox
2223
// similar to IMAP APPEND, bypassing most scanning and classification.
2224
// Does not send a message.
2225
func (r *UsersMessagesService) Insert(userId string, message *Message) *UsersMessagesInsertCall {
2226
c := &UsersMessagesInsertCall{s: r.s, opt_: make(map[string]interface{})}
2232
// InternalDateSource sets the optional parameter "internalDateSource":
2233
// Source for Gmail's internal date of the message.
2234
func (c *UsersMessagesInsertCall) InternalDateSource(internalDateSource string) *UsersMessagesInsertCall {
2235
c.opt_["internalDateSource"] = internalDateSource
2238
func (c *UsersMessagesInsertCall) Media(r io.Reader) *UsersMessagesInsertCall {
2243
// Fields allows partial responses to be retrieved.
2244
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2245
// for more information.
2246
func (c *UsersMessagesInsertCall) Fields(s ...googleapi.Field) *UsersMessagesInsertCall {
2247
c.opt_["fields"] = googleapi.CombineFields(s)
2251
func (c *UsersMessagesInsertCall) Do() (*Message, error) {
2252
var body io.Reader = nil
2253
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
2257
ctype := "application/json"
2258
params := make(url.Values)
2259
params.Set("alt", "json")
2260
if v, ok := c.opt_["internalDateSource"]; ok {
2261
params.Set("internalDateSource", fmt.Sprintf("%v", v))
2263
if v, ok := c.opt_["fields"]; ok {
2264
params.Set("fields", fmt.Sprintf("%v", v))
2266
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
2267
if c.media_ != nil {
2268
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
2269
params.Set("uploadType", "multipart")
2271
urls += "?" + params.Encode()
2272
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
2273
req, _ := http.NewRequest("POST", urls, body)
2274
googleapi.Expand(req.URL, map[string]string{
2278
req.ContentLength = contentLength_
2280
req.Header.Set("Content-Type", ctype)
2281
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2282
res, err := c.s.client.Do(req)
2286
defer googleapi.CloseBody(res)
2287
if err := googleapi.CheckResponse(res); err != nil {
2291
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2296
// "description": "Directly inserts a message into only this user's mailbox similar to IMAP APPEND, bypassing most scanning and classification. Does not send a message.",
2297
// "httpMethod": "POST",
2298
// "id": "gmail.users.messages.insert",
2303
// "maxSize": "35MB",
2306
// "multipart": true,
2307
// "path": "/resumable/upload/gmail/v1/users/{userId}/messages"
2310
// "multipart": true,
2311
// "path": "/upload/gmail/v1/users/{userId}/messages"
2315
// "parameterOrder": [
2319
// "internalDateSource": {
2320
// "default": "receivedTime",
2321
// "description": "Source for Gmail's internal date of the message.",
2326
// "enumDescriptions": [
2330
// "location": "query",
2335
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2336
// "location": "path",
2337
// "required": true,
2341
// "path": "{userId}/messages",
2343
// "$ref": "Message"
2346
// "$ref": "Message"
2349
// "https://mail.google.com/",
2350
// "https://www.googleapis.com/auth/gmail.modify"
2352
// "supportsMediaUpload": true
2357
// method id "gmail.users.messages.list":
2359
type UsersMessagesListCall struct {
2362
opt_ map[string]interface{}
2365
// List: Lists the messages in the user's mailbox.
2366
func (r *UsersMessagesService) List(userId string) *UsersMessagesListCall {
2367
c := &UsersMessagesListCall{s: r.s, opt_: make(map[string]interface{})}
2372
// IncludeSpamTrash sets the optional parameter "includeSpamTrash":
2373
// Include messages from SPAM and TRASH in the results.
2374
func (c *UsersMessagesListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersMessagesListCall {
2375
c.opt_["includeSpamTrash"] = includeSpamTrash
2379
// LabelIds sets the optional parameter "labelIds": Only return messages
2380
// with labels that match all of the specified label IDs.
2381
func (c *UsersMessagesListCall) LabelIds(labelIds string) *UsersMessagesListCall {
2382
c.opt_["labelIds"] = labelIds
2386
// MaxResults sets the optional parameter "maxResults": Maximum number
2387
// of messages to return.
2388
func (c *UsersMessagesListCall) MaxResults(maxResults int64) *UsersMessagesListCall {
2389
c.opt_["maxResults"] = maxResults
2393
// PageToken sets the optional parameter "pageToken": Page token to
2394
// retrieve a specific page of results in the list.
2395
func (c *UsersMessagesListCall) PageToken(pageToken string) *UsersMessagesListCall {
2396
c.opt_["pageToken"] = pageToken
2400
// Q sets the optional parameter "q": Only return messages matching the
2401
// specified query. Supports the same query format as the Gmail search
2402
// box. For example, "from:someuser@example.com rfc822msgid: is:unread".
2403
func (c *UsersMessagesListCall) Q(q string) *UsersMessagesListCall {
2408
// Fields allows partial responses to be retrieved.
2409
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2410
// for more information.
2411
func (c *UsersMessagesListCall) Fields(s ...googleapi.Field) *UsersMessagesListCall {
2412
c.opt_["fields"] = googleapi.CombineFields(s)
2416
func (c *UsersMessagesListCall) Do() (*ListMessagesResponse, error) {
2417
var body io.Reader = nil
2418
params := make(url.Values)
2419
params.Set("alt", "json")
2420
if v, ok := c.opt_["includeSpamTrash"]; ok {
2421
params.Set("includeSpamTrash", fmt.Sprintf("%v", v))
2423
if v, ok := c.opt_["labelIds"]; ok {
2424
params.Set("labelIds", fmt.Sprintf("%v", v))
2426
if v, ok := c.opt_["maxResults"]; ok {
2427
params.Set("maxResults", fmt.Sprintf("%v", v))
2429
if v, ok := c.opt_["pageToken"]; ok {
2430
params.Set("pageToken", fmt.Sprintf("%v", v))
2432
if v, ok := c.opt_["q"]; ok {
2433
params.Set("q", fmt.Sprintf("%v", v))
2435
if v, ok := c.opt_["fields"]; ok {
2436
params.Set("fields", fmt.Sprintf("%v", v))
2438
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
2439
urls += "?" + params.Encode()
2440
req, _ := http.NewRequest("GET", urls, body)
2441
googleapi.Expand(req.URL, map[string]string{
2444
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2445
res, err := c.s.client.Do(req)
2449
defer googleapi.CloseBody(res)
2450
if err := googleapi.CheckResponse(res); err != nil {
2453
var ret *ListMessagesResponse
2454
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2459
// "description": "Lists the messages in the user's mailbox.",
2460
// "httpMethod": "GET",
2461
// "id": "gmail.users.messages.list",
2462
// "parameterOrder": [
2466
// "includeSpamTrash": {
2467
// "default": "false",
2468
// "description": "Include messages from SPAM and TRASH in the results.",
2469
// "location": "query",
2470
// "type": "boolean"
2473
// "description": "Only return messages with labels that match all of the specified label IDs.",
2474
// "location": "query",
2475
// "repeated": true,
2479
// "default": "100",
2480
// "description": "Maximum number of messages to return.",
2481
// "format": "uint32",
2482
// "location": "query",
2483
// "type": "integer"
2486
// "description": "Page token to retrieve a specific page of results in the list.",
2487
// "location": "query",
2491
// "description": "Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, \"from:someuser@example.com rfc822msgid: is:unread\".",
2492
// "location": "query",
2497
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2498
// "location": "path",
2499
// "required": true,
2503
// "path": "{userId}/messages",
2505
// "$ref": "ListMessagesResponse"
2508
// "https://mail.google.com/",
2509
// "https://www.googleapis.com/auth/gmail.modify",
2510
// "https://www.googleapis.com/auth/gmail.readonly"
2516
// method id "gmail.users.messages.modify":
2518
type UsersMessagesModifyCall struct {
2522
modifymessagerequest *ModifyMessageRequest
2523
opt_ map[string]interface{}
2526
// Modify: Modifies the labels on the specified message.
2527
func (r *UsersMessagesService) Modify(userId string, id string, modifymessagerequest *ModifyMessageRequest) *UsersMessagesModifyCall {
2528
c := &UsersMessagesModifyCall{s: r.s, opt_: make(map[string]interface{})}
2531
c.modifymessagerequest = modifymessagerequest
2535
// Fields allows partial responses to be retrieved.
2536
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2537
// for more information.
2538
func (c *UsersMessagesModifyCall) Fields(s ...googleapi.Field) *UsersMessagesModifyCall {
2539
c.opt_["fields"] = googleapi.CombineFields(s)
2543
func (c *UsersMessagesModifyCall) Do() (*Message, error) {
2544
var body io.Reader = nil
2545
body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifymessagerequest)
2549
ctype := "application/json"
2550
params := make(url.Values)
2551
params.Set("alt", "json")
2552
if v, ok := c.opt_["fields"]; ok {
2553
params.Set("fields", fmt.Sprintf("%v", v))
2555
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/modify")
2556
urls += "?" + params.Encode()
2557
req, _ := http.NewRequest("POST", urls, body)
2558
googleapi.Expand(req.URL, map[string]string{
2562
req.Header.Set("Content-Type", ctype)
2563
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2564
res, err := c.s.client.Do(req)
2568
defer googleapi.CloseBody(res)
2569
if err := googleapi.CheckResponse(res); err != nil {
2573
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2578
// "description": "Modifies the labels on the specified message.",
2579
// "httpMethod": "POST",
2580
// "id": "gmail.users.messages.modify",
2581
// "parameterOrder": [
2587
// "description": "The ID of the message to modify.",
2588
// "location": "path",
2589
// "required": true,
2594
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2595
// "location": "path",
2596
// "required": true,
2600
// "path": "{userId}/messages/{id}/modify",
2602
// "$ref": "ModifyMessageRequest"
2605
// "$ref": "Message"
2608
// "https://mail.google.com/",
2609
// "https://www.googleapis.com/auth/gmail.modify"
2615
// method id "gmail.users.messages.send":
2617
type UsersMessagesSendCall struct {
2621
opt_ map[string]interface{}
2625
// Send: Sends the specified message to the recipients in the To, Cc,
2627
func (r *UsersMessagesService) Send(userId string, message *Message) *UsersMessagesSendCall {
2628
c := &UsersMessagesSendCall{s: r.s, opt_: make(map[string]interface{})}
2633
func (c *UsersMessagesSendCall) Media(r io.Reader) *UsersMessagesSendCall {
2638
// Fields allows partial responses to be retrieved.
2639
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2640
// for more information.
2641
func (c *UsersMessagesSendCall) Fields(s ...googleapi.Field) *UsersMessagesSendCall {
2642
c.opt_["fields"] = googleapi.CombineFields(s)
2646
func (c *UsersMessagesSendCall) Do() (*Message, error) {
2647
var body io.Reader = nil
2648
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
2652
ctype := "application/json"
2653
params := make(url.Values)
2654
params.Set("alt", "json")
2655
if v, ok := c.opt_["fields"]; ok {
2656
params.Set("fields", fmt.Sprintf("%v", v))
2658
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/send")
2659
if c.media_ != nil {
2660
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
2661
params.Set("uploadType", "multipart")
2663
urls += "?" + params.Encode()
2664
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
2665
req, _ := http.NewRequest("POST", urls, body)
2666
googleapi.Expand(req.URL, map[string]string{
2670
req.ContentLength = contentLength_
2672
req.Header.Set("Content-Type", ctype)
2673
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2674
res, err := c.s.client.Do(req)
2678
defer googleapi.CloseBody(res)
2679
if err := googleapi.CheckResponse(res); err != nil {
2683
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2688
// "description": "Sends the specified message to the recipients in the To, Cc, and Bcc headers.",
2689
// "httpMethod": "POST",
2690
// "id": "gmail.users.messages.send",
2695
// "maxSize": "35MB",
2698
// "multipart": true,
2699
// "path": "/resumable/upload/gmail/v1/users/{userId}/messages/send"
2702
// "multipart": true,
2703
// "path": "/upload/gmail/v1/users/{userId}/messages/send"
2707
// "parameterOrder": [
2713
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2714
// "location": "path",
2715
// "required": true,
2719
// "path": "{userId}/messages/send",
2721
// "$ref": "Message"
2724
// "$ref": "Message"
2727
// "https://mail.google.com/",
2728
// "https://www.googleapis.com/auth/gmail.compose",
2729
// "https://www.googleapis.com/auth/gmail.modify"
2731
// "supportsMediaUpload": true
2736
// method id "gmail.users.messages.trash":
2738
type UsersMessagesTrashCall struct {
2742
opt_ map[string]interface{}
2745
// Trash: Moves the specified message to the trash.
2746
func (r *UsersMessagesService) Trash(userId string, id string) *UsersMessagesTrashCall {
2747
c := &UsersMessagesTrashCall{s: r.s, opt_: make(map[string]interface{})}
2753
// Fields allows partial responses to be retrieved.
2754
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2755
// for more information.
2756
func (c *UsersMessagesTrashCall) Fields(s ...googleapi.Field) *UsersMessagesTrashCall {
2757
c.opt_["fields"] = googleapi.CombineFields(s)
2761
func (c *UsersMessagesTrashCall) Do() (*Message, error) {
2762
var body io.Reader = nil
2763
params := make(url.Values)
2764
params.Set("alt", "json")
2765
if v, ok := c.opt_["fields"]; ok {
2766
params.Set("fields", fmt.Sprintf("%v", v))
2768
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/trash")
2769
urls += "?" + params.Encode()
2770
req, _ := http.NewRequest("POST", urls, body)
2771
googleapi.Expand(req.URL, map[string]string{
2775
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2776
res, err := c.s.client.Do(req)
2780
defer googleapi.CloseBody(res)
2781
if err := googleapi.CheckResponse(res); err != nil {
2785
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2790
// "description": "Moves the specified message to the trash.",
2791
// "httpMethod": "POST",
2792
// "id": "gmail.users.messages.trash",
2793
// "parameterOrder": [
2799
// "description": "The ID of the message to Trash.",
2800
// "location": "path",
2801
// "required": true,
2806
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2807
// "location": "path",
2808
// "required": true,
2812
// "path": "{userId}/messages/{id}/trash",
2814
// "$ref": "Message"
2817
// "https://mail.google.com/",
2818
// "https://www.googleapis.com/auth/gmail.modify"
2824
// method id "gmail.users.messages.untrash":
2826
type UsersMessagesUntrashCall struct {
2830
opt_ map[string]interface{}
2833
// Untrash: Removes the specified message from the trash.
2834
func (r *UsersMessagesService) Untrash(userId string, id string) *UsersMessagesUntrashCall {
2835
c := &UsersMessagesUntrashCall{s: r.s, opt_: make(map[string]interface{})}
2841
// Fields allows partial responses to be retrieved.
2842
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2843
// for more information.
2844
func (c *UsersMessagesUntrashCall) Fields(s ...googleapi.Field) *UsersMessagesUntrashCall {
2845
c.opt_["fields"] = googleapi.CombineFields(s)
2849
func (c *UsersMessagesUntrashCall) Do() (*Message, error) {
2850
var body io.Reader = nil
2851
params := make(url.Values)
2852
params.Set("alt", "json")
2853
if v, ok := c.opt_["fields"]; ok {
2854
params.Set("fields", fmt.Sprintf("%v", v))
2856
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/untrash")
2857
urls += "?" + params.Encode()
2858
req, _ := http.NewRequest("POST", urls, body)
2859
googleapi.Expand(req.URL, map[string]string{
2863
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2864
res, err := c.s.client.Do(req)
2868
defer googleapi.CloseBody(res)
2869
if err := googleapi.CheckResponse(res); err != nil {
2873
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2878
// "description": "Removes the specified message from the trash.",
2879
// "httpMethod": "POST",
2880
// "id": "gmail.users.messages.untrash",
2881
// "parameterOrder": [
2887
// "description": "The ID of the message to remove from Trash.",
2888
// "location": "path",
2889
// "required": true,
2894
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2895
// "location": "path",
2896
// "required": true,
2900
// "path": "{userId}/messages/{id}/untrash",
2902
// "$ref": "Message"
2905
// "https://mail.google.com/",
2906
// "https://www.googleapis.com/auth/gmail.modify"
2912
// method id "gmail.users.messages.attachments.get":
2914
type UsersMessagesAttachmentsGetCall struct {
2919
opt_ map[string]interface{}
2922
// Get: Gets the specified message attachment.
2923
func (r *UsersMessagesAttachmentsService) Get(userId string, messageId string, id string) *UsersMessagesAttachmentsGetCall {
2924
c := &UsersMessagesAttachmentsGetCall{s: r.s, opt_: make(map[string]interface{})}
2926
c.messageId = messageId
2931
// Fields allows partial responses to be retrieved.
2932
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
2933
// for more information.
2934
func (c *UsersMessagesAttachmentsGetCall) Fields(s ...googleapi.Field) *UsersMessagesAttachmentsGetCall {
2935
c.opt_["fields"] = googleapi.CombineFields(s)
2939
func (c *UsersMessagesAttachmentsGetCall) Do() (*MessagePartBody, error) {
2940
var body io.Reader = nil
2941
params := make(url.Values)
2942
params.Set("alt", "json")
2943
if v, ok := c.opt_["fields"]; ok {
2944
params.Set("fields", fmt.Sprintf("%v", v))
2946
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{messageId}/attachments/{id}")
2947
urls += "?" + params.Encode()
2948
req, _ := http.NewRequest("GET", urls, body)
2949
googleapi.Expand(req.URL, map[string]string{
2951
"messageId": c.messageId,
2954
req.Header.Set("User-Agent", "google-api-go-client/0.5")
2955
res, err := c.s.client.Do(req)
2959
defer googleapi.CloseBody(res)
2960
if err := googleapi.CheckResponse(res); err != nil {
2963
var ret *MessagePartBody
2964
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
2969
// "description": "Gets the specified message attachment.",
2970
// "httpMethod": "GET",
2971
// "id": "gmail.users.messages.attachments.get",
2972
// "parameterOrder": [
2979
// "description": "The ID of the attachment.",
2980
// "location": "path",
2981
// "required": true,
2985
// "description": "The ID of the message containing the attachment.",
2986
// "location": "path",
2987
// "required": true,
2992
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
2993
// "location": "path",
2994
// "required": true,
2998
// "path": "{userId}/messages/{messageId}/attachments/{id}",
3000
// "$ref": "MessagePartBody"
3003
// "https://mail.google.com/",
3004
// "https://www.googleapis.com/auth/gmail.modify",
3005
// "https://www.googleapis.com/auth/gmail.readonly"
3011
// method id "gmail.users.threads.delete":
3013
type UsersThreadsDeleteCall struct {
3017
opt_ map[string]interface{}
3020
// Delete: Immediately and permanently deletes the specified thread.
3021
// This operation cannot be undone. Prefer threads.trash instead.
3022
func (r *UsersThreadsService) Delete(userId string, id string) *UsersThreadsDeleteCall {
3023
c := &UsersThreadsDeleteCall{s: r.s, opt_: make(map[string]interface{})}
3029
// Fields allows partial responses to be retrieved.
3030
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
3031
// for more information.
3032
func (c *UsersThreadsDeleteCall) Fields(s ...googleapi.Field) *UsersThreadsDeleteCall {
3033
c.opt_["fields"] = googleapi.CombineFields(s)
3037
func (c *UsersThreadsDeleteCall) Do() error {
3038
var body io.Reader = nil
3039
params := make(url.Values)
3040
params.Set("alt", "json")
3041
if v, ok := c.opt_["fields"]; ok {
3042
params.Set("fields", fmt.Sprintf("%v", v))
3044
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
3045
urls += "?" + params.Encode()
3046
req, _ := http.NewRequest("DELETE", urls, body)
3047
googleapi.Expand(req.URL, map[string]string{
3051
req.Header.Set("User-Agent", "google-api-go-client/0.5")
3052
res, err := c.s.client.Do(req)
3056
defer googleapi.CloseBody(res)
3057
if err := googleapi.CheckResponse(res); err != nil {
3062
// "description": "Immediately and permanently deletes the specified thread. This operation cannot be undone. Prefer threads.trash instead.",
3063
// "httpMethod": "DELETE",
3064
// "id": "gmail.users.threads.delete",
3065
// "parameterOrder": [
3071
// "description": "ID of the Thread to delete.",
3072
// "location": "path",
3073
// "required": true,
3078
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
3079
// "location": "path",
3080
// "required": true,
3084
// "path": "{userId}/threads/{id}",
3086
// "https://mail.google.com/"
3092
// method id "gmail.users.threads.get":
3094
type UsersThreadsGetCall struct {
3098
opt_ map[string]interface{}
3101
// Get: Gets the specified thread.
3102
func (r *UsersThreadsService) Get(userId string, id string) *UsersThreadsGetCall {
3103
c := &UsersThreadsGetCall{s: r.s, opt_: make(map[string]interface{})}
3109
// Format sets the optional parameter "format": The format to return the
3111
func (c *UsersThreadsGetCall) Format(format string) *UsersThreadsGetCall {
3112
c.opt_["format"] = format
3116
// MetadataHeaders sets the optional parameter "metadataHeaders": When
3117
// given and format is METADATA, only include headers specified.
3118
func (c *UsersThreadsGetCall) MetadataHeaders(metadataHeaders string) *UsersThreadsGetCall {
3119
c.opt_["metadataHeaders"] = metadataHeaders
3123
// Fields allows partial responses to be retrieved.
3124
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
3125
// for more information.
3126
func (c *UsersThreadsGetCall) Fields(s ...googleapi.Field) *UsersThreadsGetCall {
3127
c.opt_["fields"] = googleapi.CombineFields(s)
3131
func (c *UsersThreadsGetCall) Do() (*Thread, error) {
3132
var body io.Reader = nil
3133
params := make(url.Values)
3134
params.Set("alt", "json")
3135
if v, ok := c.opt_["format"]; ok {
3136
params.Set("format", fmt.Sprintf("%v", v))
3138
if v, ok := c.opt_["metadataHeaders"]; ok {
3139
params.Set("metadataHeaders", fmt.Sprintf("%v", v))
3141
if v, ok := c.opt_["fields"]; ok {
3142
params.Set("fields", fmt.Sprintf("%v", v))
3144
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
3145
urls += "?" + params.Encode()
3146
req, _ := http.NewRequest("GET", urls, body)
3147
googleapi.Expand(req.URL, map[string]string{
3151
req.Header.Set("User-Agent", "google-api-go-client/0.5")
3152
res, err := c.s.client.Do(req)
3156
defer googleapi.CloseBody(res)
3157
if err := googleapi.CheckResponse(res); err != nil {
3161
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
3166
// "description": "Gets the specified thread.",
3167
// "httpMethod": "GET",
3168
// "id": "gmail.users.threads.get",
3169
// "parameterOrder": [
3175
// "default": "full",
3176
// "description": "The format to return the messages in.",
3182
// "enumDescriptions": [
3187
// "location": "query",
3191
// "description": "The ID of the thread to retrieve.",
3192
// "location": "path",
3193
// "required": true,
3196
// "metadataHeaders": {
3197
// "description": "When given and format is METADATA, only include headers specified.",
3198
// "location": "query",
3199
// "repeated": true,
3204
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
3205
// "location": "path",
3206
// "required": true,
3210
// "path": "{userId}/threads/{id}",
3215
// "https://mail.google.com/",
3216
// "https://www.googleapis.com/auth/gmail.modify",
3217
// "https://www.googleapis.com/auth/gmail.readonly"
3223
// method id "gmail.users.threads.list":
3225
type UsersThreadsListCall struct {
3228
opt_ map[string]interface{}
3231
// List: Lists the threads in the user's mailbox.
3232
func (r *UsersThreadsService) List(userId string) *UsersThreadsListCall {
3233
c := &UsersThreadsListCall{s: r.s, opt_: make(map[string]interface{})}
3238
// IncludeSpamTrash sets the optional parameter "includeSpamTrash":
3239
// Include threads from SPAM and TRASH in the results.
3240
func (c *UsersThreadsListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersThreadsListCall {
3241
c.opt_["includeSpamTrash"] = includeSpamTrash
3245
// LabelIds sets the optional parameter "labelIds": Only return threads
3246
// with labels that match all of the specified label IDs.
3247
func (c *UsersThreadsListCall) LabelIds(labelIds string) *UsersThreadsListCall {
3248
c.opt_["labelIds"] = labelIds
3252
// MaxResults sets the optional parameter "maxResults": Maximum number
3253
// of threads to return.
3254
func (c *UsersThreadsListCall) MaxResults(maxResults int64) *UsersThreadsListCall {
3255
c.opt_["maxResults"] = maxResults
3259
// PageToken sets the optional parameter "pageToken": Page token to
3260
// retrieve a specific page of results in the list.
3261
func (c *UsersThreadsListCall) PageToken(pageToken string) *UsersThreadsListCall {
3262
c.opt_["pageToken"] = pageToken
3266
// Q sets the optional parameter "q": Only return threads matching the
3267
// specified query. Supports the same query format as the Gmail search
3268
// box. For example, "from:someuser@example.com rfc822msgid: is:unread".
3269
func (c *UsersThreadsListCall) Q(q string) *UsersThreadsListCall {
3274
// Fields allows partial responses to be retrieved.
3275
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
3276
// for more information.
3277
func (c *UsersThreadsListCall) Fields(s ...googleapi.Field) *UsersThreadsListCall {
3278
c.opt_["fields"] = googleapi.CombineFields(s)
3282
func (c *UsersThreadsListCall) Do() (*ListThreadsResponse, error) {
3283
var body io.Reader = nil
3284
params := make(url.Values)
3285
params.Set("alt", "json")
3286
if v, ok := c.opt_["includeSpamTrash"]; ok {
3287
params.Set("includeSpamTrash", fmt.Sprintf("%v", v))
3289
if v, ok := c.opt_["labelIds"]; ok {
3290
params.Set("labelIds", fmt.Sprintf("%v", v))
3292
if v, ok := c.opt_["maxResults"]; ok {
3293
params.Set("maxResults", fmt.Sprintf("%v", v))
3295
if v, ok := c.opt_["pageToken"]; ok {
3296
params.Set("pageToken", fmt.Sprintf("%v", v))
3298
if v, ok := c.opt_["q"]; ok {
3299
params.Set("q", fmt.Sprintf("%v", v))
3301
if v, ok := c.opt_["fields"]; ok {
3302
params.Set("fields", fmt.Sprintf("%v", v))
3304
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads")
3305
urls += "?" + params.Encode()
3306
req, _ := http.NewRequest("GET", urls, body)
3307
googleapi.Expand(req.URL, map[string]string{
3310
req.Header.Set("User-Agent", "google-api-go-client/0.5")
3311
res, err := c.s.client.Do(req)
3315
defer googleapi.CloseBody(res)
3316
if err := googleapi.CheckResponse(res); err != nil {
3319
var ret *ListThreadsResponse
3320
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
3325
// "description": "Lists the threads in the user's mailbox.",
3326
// "httpMethod": "GET",
3327
// "id": "gmail.users.threads.list",
3328
// "parameterOrder": [
3332
// "includeSpamTrash": {
3333
// "default": "false",
3334
// "description": "Include threads from SPAM and TRASH in the results.",
3335
// "location": "query",
3336
// "type": "boolean"
3339
// "description": "Only return threads with labels that match all of the specified label IDs.",
3340
// "location": "query",
3341
// "repeated": true,
3345
// "default": "100",
3346
// "description": "Maximum number of threads to return.",
3347
// "format": "uint32",
3348
// "location": "query",
3349
// "type": "integer"
3352
// "description": "Page token to retrieve a specific page of results in the list.",
3353
// "location": "query",
3357
// "description": "Only return threads matching the specified query. Supports the same query format as the Gmail search box. For example, \"from:someuser@example.com rfc822msgid: is:unread\".",
3358
// "location": "query",
3363
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
3364
// "location": "path",
3365
// "required": true,
3369
// "path": "{userId}/threads",
3371
// "$ref": "ListThreadsResponse"
3374
// "https://mail.google.com/",
3375
// "https://www.googleapis.com/auth/gmail.modify",
3376
// "https://www.googleapis.com/auth/gmail.readonly"
3382
// method id "gmail.users.threads.modify":
3384
type UsersThreadsModifyCall struct {
3388
modifythreadrequest *ModifyThreadRequest
3389
opt_ map[string]interface{}
3392
// Modify: Modifies the labels applied to the thread. This applies to
3393
// all messages in the thread.
3394
func (r *UsersThreadsService) Modify(userId string, id string, modifythreadrequest *ModifyThreadRequest) *UsersThreadsModifyCall {
3395
c := &UsersThreadsModifyCall{s: r.s, opt_: make(map[string]interface{})}
3398
c.modifythreadrequest = modifythreadrequest
3402
// Fields allows partial responses to be retrieved.
3403
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
3404
// for more information.
3405
func (c *UsersThreadsModifyCall) Fields(s ...googleapi.Field) *UsersThreadsModifyCall {
3406
c.opt_["fields"] = googleapi.CombineFields(s)
3410
func (c *UsersThreadsModifyCall) Do() (*Thread, error) {
3411
var body io.Reader = nil
3412
body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifythreadrequest)
3416
ctype := "application/json"
3417
params := make(url.Values)
3418
params.Set("alt", "json")
3419
if v, ok := c.opt_["fields"]; ok {
3420
params.Set("fields", fmt.Sprintf("%v", v))
3422
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/modify")
3423
urls += "?" + params.Encode()
3424
req, _ := http.NewRequest("POST", urls, body)
3425
googleapi.Expand(req.URL, map[string]string{
3429
req.Header.Set("Content-Type", ctype)
3430
req.Header.Set("User-Agent", "google-api-go-client/0.5")
3431
res, err := c.s.client.Do(req)
3435
defer googleapi.CloseBody(res)
3436
if err := googleapi.CheckResponse(res); err != nil {
3440
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
3445
// "description": "Modifies the labels applied to the thread. This applies to all messages in the thread.",
3446
// "httpMethod": "POST",
3447
// "id": "gmail.users.threads.modify",
3448
// "parameterOrder": [
3454
// "description": "The ID of the thread to modify.",
3455
// "location": "path",
3456
// "required": true,
3461
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
3462
// "location": "path",
3463
// "required": true,
3467
// "path": "{userId}/threads/{id}/modify",
3469
// "$ref": "ModifyThreadRequest"
3475
// "https://mail.google.com/",
3476
// "https://www.googleapis.com/auth/gmail.modify"
3482
// method id "gmail.users.threads.trash":
3484
type UsersThreadsTrashCall struct {
3488
opt_ map[string]interface{}
3491
// Trash: Moves the specified thread to the trash.
3492
func (r *UsersThreadsService) Trash(userId string, id string) *UsersThreadsTrashCall {
3493
c := &UsersThreadsTrashCall{s: r.s, opt_: make(map[string]interface{})}
3499
// Fields allows partial responses to be retrieved.
3500
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
3501
// for more information.
3502
func (c *UsersThreadsTrashCall) Fields(s ...googleapi.Field) *UsersThreadsTrashCall {
3503
c.opt_["fields"] = googleapi.CombineFields(s)
3507
func (c *UsersThreadsTrashCall) Do() (*Thread, error) {
3508
var body io.Reader = nil
3509
params := make(url.Values)
3510
params.Set("alt", "json")
3511
if v, ok := c.opt_["fields"]; ok {
3512
params.Set("fields", fmt.Sprintf("%v", v))
3514
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/trash")
3515
urls += "?" + params.Encode()
3516
req, _ := http.NewRequest("POST", urls, body)
3517
googleapi.Expand(req.URL, map[string]string{
3521
req.Header.Set("User-Agent", "google-api-go-client/0.5")
3522
res, err := c.s.client.Do(req)
3526
defer googleapi.CloseBody(res)
3527
if err := googleapi.CheckResponse(res); err != nil {
3531
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
3536
// "description": "Moves the specified thread to the trash.",
3537
// "httpMethod": "POST",
3538
// "id": "gmail.users.threads.trash",
3539
// "parameterOrder": [
3545
// "description": "The ID of the thread to Trash.",
3546
// "location": "path",
3547
// "required": true,
3552
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
3553
// "location": "path",
3554
// "required": true,
3558
// "path": "{userId}/threads/{id}/trash",
3563
// "https://mail.google.com/",
3564
// "https://www.googleapis.com/auth/gmail.modify"
3570
// method id "gmail.users.threads.untrash":
3572
type UsersThreadsUntrashCall struct {
3576
opt_ map[string]interface{}
3579
// Untrash: Removes the specified thread from the trash.
3580
func (r *UsersThreadsService) Untrash(userId string, id string) *UsersThreadsUntrashCall {
3581
c := &UsersThreadsUntrashCall{s: r.s, opt_: make(map[string]interface{})}
3587
// Fields allows partial responses to be retrieved.
3588
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
3589
// for more information.
3590
func (c *UsersThreadsUntrashCall) Fields(s ...googleapi.Field) *UsersThreadsUntrashCall {
3591
c.opt_["fields"] = googleapi.CombineFields(s)
3595
func (c *UsersThreadsUntrashCall) Do() (*Thread, error) {
3596
var body io.Reader = nil
3597
params := make(url.Values)
3598
params.Set("alt", "json")
3599
if v, ok := c.opt_["fields"]; ok {
3600
params.Set("fields", fmt.Sprintf("%v", v))
3602
urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/untrash")
3603
urls += "?" + params.Encode()
3604
req, _ := http.NewRequest("POST", urls, body)
3605
googleapi.Expand(req.URL, map[string]string{
3609
req.Header.Set("User-Agent", "google-api-go-client/0.5")
3610
res, err := c.s.client.Do(req)
3614
defer googleapi.CloseBody(res)
3615
if err := googleapi.CheckResponse(res); err != nil {
3619
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
3624
// "description": "Removes the specified thread from the trash.",
3625
// "httpMethod": "POST",
3626
// "id": "gmail.users.threads.untrash",
3627
// "parameterOrder": [
3633
// "description": "The ID of the thread to remove from Trash.",
3634
// "location": "path",
3635
// "required": true,
3640
// "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
3641
// "location": "path",
3642
// "required": true,
3646
// "path": "{userId}/threads/{id}/untrash",
3651
// "https://mail.google.com/",
3652
// "https://www.googleapis.com/auth/gmail.modify"