Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

11514 řádky
378 KiB

  1. // Package gmail provides access to the Gmail API.
  2. //
  3. // See https://developers.google.com/gmail/api/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/gmail/v1"
  8. // ...
  9. // gmailService, err := gmail.New(oauthHttpClient)
  10. package gmail // import "google.golang.org/api/gmail/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "gmail:v1"
  41. const apiName = "gmail"
  42. const apiVersion = "v1"
  43. const basePath = "https://www.googleapis.com/gmail/v1/users/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Read, send, delete, and manage your email
  47. MailGoogleComScope = "https://mail.google.com/"
  48. // Manage drafts and send emails
  49. GmailComposeScope = "https://www.googleapis.com/auth/gmail.compose"
  50. // Insert mail into your mailbox
  51. GmailInsertScope = "https://www.googleapis.com/auth/gmail.insert"
  52. // Manage mailbox labels
  53. GmailLabelsScope = "https://www.googleapis.com/auth/gmail.labels"
  54. // View your email message metadata such as labels and headers, but not
  55. // the email body
  56. GmailMetadataScope = "https://www.googleapis.com/auth/gmail.metadata"
  57. // View and modify but not delete your email
  58. GmailModifyScope = "https://www.googleapis.com/auth/gmail.modify"
  59. // View your email messages and settings
  60. GmailReadonlyScope = "https://www.googleapis.com/auth/gmail.readonly"
  61. // Send email on your behalf
  62. GmailSendScope = "https://www.googleapis.com/auth/gmail.send"
  63. // Manage your basic mail settings
  64. GmailSettingsBasicScope = "https://www.googleapis.com/auth/gmail.settings.basic"
  65. // Manage your sensitive mail settings, including who can manage your
  66. // mail
  67. GmailSettingsSharingScope = "https://www.googleapis.com/auth/gmail.settings.sharing"
  68. )
  69. func New(client *http.Client) (*Service, error) {
  70. if client == nil {
  71. return nil, errors.New("client is nil")
  72. }
  73. s := &Service{client: client, BasePath: basePath}
  74. s.Users = NewUsersService(s)
  75. return s, nil
  76. }
  77. type Service struct {
  78. client *http.Client
  79. BasePath string // API endpoint base URL
  80. UserAgent string // optional additional User-Agent fragment
  81. Users *UsersService
  82. }
  83. func (s *Service) userAgent() string {
  84. if s.UserAgent == "" {
  85. return googleapi.UserAgent
  86. }
  87. return googleapi.UserAgent + " " + s.UserAgent
  88. }
  89. func NewUsersService(s *Service) *UsersService {
  90. rs := &UsersService{s: s}
  91. rs.Drafts = NewUsersDraftsService(s)
  92. rs.History = NewUsersHistoryService(s)
  93. rs.Labels = NewUsersLabelsService(s)
  94. rs.Messages = NewUsersMessagesService(s)
  95. rs.Settings = NewUsersSettingsService(s)
  96. rs.Threads = NewUsersThreadsService(s)
  97. return rs
  98. }
  99. type UsersService struct {
  100. s *Service
  101. Drafts *UsersDraftsService
  102. History *UsersHistoryService
  103. Labels *UsersLabelsService
  104. Messages *UsersMessagesService
  105. Settings *UsersSettingsService
  106. Threads *UsersThreadsService
  107. }
  108. func NewUsersDraftsService(s *Service) *UsersDraftsService {
  109. rs := &UsersDraftsService{s: s}
  110. return rs
  111. }
  112. type UsersDraftsService struct {
  113. s *Service
  114. }
  115. func NewUsersHistoryService(s *Service) *UsersHistoryService {
  116. rs := &UsersHistoryService{s: s}
  117. return rs
  118. }
  119. type UsersHistoryService struct {
  120. s *Service
  121. }
  122. func NewUsersLabelsService(s *Service) *UsersLabelsService {
  123. rs := &UsersLabelsService{s: s}
  124. return rs
  125. }
  126. type UsersLabelsService struct {
  127. s *Service
  128. }
  129. func NewUsersMessagesService(s *Service) *UsersMessagesService {
  130. rs := &UsersMessagesService{s: s}
  131. rs.Attachments = NewUsersMessagesAttachmentsService(s)
  132. return rs
  133. }
  134. type UsersMessagesService struct {
  135. s *Service
  136. Attachments *UsersMessagesAttachmentsService
  137. }
  138. func NewUsersMessagesAttachmentsService(s *Service) *UsersMessagesAttachmentsService {
  139. rs := &UsersMessagesAttachmentsService{s: s}
  140. return rs
  141. }
  142. type UsersMessagesAttachmentsService struct {
  143. s *Service
  144. }
  145. func NewUsersSettingsService(s *Service) *UsersSettingsService {
  146. rs := &UsersSettingsService{s: s}
  147. rs.Filters = NewUsersSettingsFiltersService(s)
  148. rs.ForwardingAddresses = NewUsersSettingsForwardingAddressesService(s)
  149. rs.SendAs = NewUsersSettingsSendAsService(s)
  150. return rs
  151. }
  152. type UsersSettingsService struct {
  153. s *Service
  154. Filters *UsersSettingsFiltersService
  155. ForwardingAddresses *UsersSettingsForwardingAddressesService
  156. SendAs *UsersSettingsSendAsService
  157. }
  158. func NewUsersSettingsFiltersService(s *Service) *UsersSettingsFiltersService {
  159. rs := &UsersSettingsFiltersService{s: s}
  160. return rs
  161. }
  162. type UsersSettingsFiltersService struct {
  163. s *Service
  164. }
  165. func NewUsersSettingsForwardingAddressesService(s *Service) *UsersSettingsForwardingAddressesService {
  166. rs := &UsersSettingsForwardingAddressesService{s: s}
  167. return rs
  168. }
  169. type UsersSettingsForwardingAddressesService struct {
  170. s *Service
  171. }
  172. func NewUsersSettingsSendAsService(s *Service) *UsersSettingsSendAsService {
  173. rs := &UsersSettingsSendAsService{s: s}
  174. rs.SmimeInfo = NewUsersSettingsSendAsSmimeInfoService(s)
  175. return rs
  176. }
  177. type UsersSettingsSendAsService struct {
  178. s *Service
  179. SmimeInfo *UsersSettingsSendAsSmimeInfoService
  180. }
  181. func NewUsersSettingsSendAsSmimeInfoService(s *Service) *UsersSettingsSendAsSmimeInfoService {
  182. rs := &UsersSettingsSendAsSmimeInfoService{s: s}
  183. return rs
  184. }
  185. type UsersSettingsSendAsSmimeInfoService struct {
  186. s *Service
  187. }
  188. func NewUsersThreadsService(s *Service) *UsersThreadsService {
  189. rs := &UsersThreadsService{s: s}
  190. return rs
  191. }
  192. type UsersThreadsService struct {
  193. s *Service
  194. }
  195. // AutoForwarding: Auto-forwarding settings for an account.
  196. type AutoForwarding struct {
  197. // Disposition: The state that a message should be left in after it has
  198. // been forwarded.
  199. //
  200. // Possible values:
  201. // "archive"
  202. // "dispositionUnspecified"
  203. // "leaveInInbox"
  204. // "markRead"
  205. // "trash"
  206. Disposition string `json:"disposition,omitempty"`
  207. // EmailAddress: Email address to which all incoming messages are
  208. // forwarded. This email address must be a verified member of the
  209. // forwarding addresses.
  210. EmailAddress string `json:"emailAddress,omitempty"`
  211. // Enabled: Whether all incoming mail is automatically forwarded to
  212. // another address.
  213. Enabled bool `json:"enabled,omitempty"`
  214. // ServerResponse contains the HTTP response code and headers from the
  215. // server.
  216. googleapi.ServerResponse `json:"-"`
  217. // ForceSendFields is a list of field names (e.g. "Disposition") to
  218. // unconditionally include in API requests. By default, fields with
  219. // empty values are omitted from API requests. However, any non-pointer,
  220. // non-interface field appearing in ForceSendFields will be sent to the
  221. // server regardless of whether the field is empty or not. This may be
  222. // used to include empty fields in Patch requests.
  223. ForceSendFields []string `json:"-"`
  224. // NullFields is a list of field names (e.g. "Disposition") to include
  225. // in API requests with the JSON null value. By default, fields with
  226. // empty values are omitted from API requests. However, any field with
  227. // an empty value appearing in NullFields will be sent to the server as
  228. // null. It is an error if a field in this list has a non-empty value.
  229. // This may be used to include null fields in Patch requests.
  230. NullFields []string `json:"-"`
  231. }
  232. func (s *AutoForwarding) MarshalJSON() ([]byte, error) {
  233. type NoMethod AutoForwarding
  234. raw := NoMethod(*s)
  235. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  236. }
  237. type BatchDeleteMessagesRequest struct {
  238. // Ids: The IDs of the messages to delete.
  239. Ids []string `json:"ids,omitempty"`
  240. // ForceSendFields is a list of field names (e.g. "Ids") to
  241. // unconditionally include in API requests. By default, fields with
  242. // empty values are omitted from API requests. However, any non-pointer,
  243. // non-interface field appearing in ForceSendFields will be sent to the
  244. // server regardless of whether the field is empty or not. This may be
  245. // used to include empty fields in Patch requests.
  246. ForceSendFields []string `json:"-"`
  247. // NullFields is a list of field names (e.g. "Ids") to include in API
  248. // requests with the JSON null value. By default, fields with empty
  249. // values are omitted from API requests. However, any field with an
  250. // empty value appearing in NullFields will be sent to the server as
  251. // null. It is an error if a field in this list has a non-empty value.
  252. // This may be used to include null fields in Patch requests.
  253. NullFields []string `json:"-"`
  254. }
  255. func (s *BatchDeleteMessagesRequest) MarshalJSON() ([]byte, error) {
  256. type NoMethod BatchDeleteMessagesRequest
  257. raw := NoMethod(*s)
  258. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  259. }
  260. type BatchModifyMessagesRequest struct {
  261. // AddLabelIds: A list of label IDs to add to messages.
  262. AddLabelIds []string `json:"addLabelIds,omitempty"`
  263. // Ids: The IDs of the messages to modify. There is a limit of 1000 ids
  264. // per request.
  265. Ids []string `json:"ids,omitempty"`
  266. // RemoveLabelIds: A list of label IDs to remove from messages.
  267. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  268. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  269. // unconditionally include in API requests. By default, fields with
  270. // empty values are omitted from API requests. However, any non-pointer,
  271. // non-interface field appearing in ForceSendFields will be sent to the
  272. // server regardless of whether the field is empty or not. This may be
  273. // used to include empty fields in Patch requests.
  274. ForceSendFields []string `json:"-"`
  275. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  276. // in API requests with the JSON null value. By default, fields with
  277. // empty values are omitted from API requests. However, any field with
  278. // an empty value appearing in NullFields will be sent to the server as
  279. // null. It is an error if a field in this list has a non-empty value.
  280. // This may be used to include null fields in Patch requests.
  281. NullFields []string `json:"-"`
  282. }
  283. func (s *BatchModifyMessagesRequest) MarshalJSON() ([]byte, error) {
  284. type NoMethod BatchModifyMessagesRequest
  285. raw := NoMethod(*s)
  286. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  287. }
  288. // Draft: A draft email in the user's mailbox.
  289. type Draft struct {
  290. // Id: The immutable ID of the draft.
  291. Id string `json:"id,omitempty"`
  292. // Message: The message content of the draft.
  293. Message *Message `json:"message,omitempty"`
  294. // ServerResponse contains the HTTP response code and headers from the
  295. // server.
  296. googleapi.ServerResponse `json:"-"`
  297. // ForceSendFields is a list of field names (e.g. "Id") to
  298. // unconditionally include in API requests. By default, fields with
  299. // empty values are omitted from API requests. However, any non-pointer,
  300. // non-interface field appearing in ForceSendFields will be sent to the
  301. // server regardless of whether the field is empty or not. This may be
  302. // used to include empty fields in Patch requests.
  303. ForceSendFields []string `json:"-"`
  304. // NullFields is a list of field names (e.g. "Id") to include in API
  305. // requests with the JSON null value. By default, fields with empty
  306. // values are omitted from API requests. However, any field with an
  307. // empty value appearing in NullFields will be sent to the server as
  308. // null. It is an error if a field in this list has a non-empty value.
  309. // This may be used to include null fields in Patch requests.
  310. NullFields []string `json:"-"`
  311. }
  312. func (s *Draft) MarshalJSON() ([]byte, error) {
  313. type NoMethod Draft
  314. raw := NoMethod(*s)
  315. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  316. }
  317. // Filter: Resource definition for Gmail filters. Filters apply to
  318. // specific messages instead of an entire email thread.
  319. type Filter struct {
  320. // Action: Action that the filter performs.
  321. Action *FilterAction `json:"action,omitempty"`
  322. // Criteria: Matching criteria for the filter.
  323. Criteria *FilterCriteria `json:"criteria,omitempty"`
  324. // Id: The server assigned ID of the filter.
  325. Id string `json:"id,omitempty"`
  326. // ServerResponse contains the HTTP response code and headers from the
  327. // server.
  328. googleapi.ServerResponse `json:"-"`
  329. // ForceSendFields is a list of field names (e.g. "Action") to
  330. // unconditionally include in API requests. By default, fields with
  331. // empty values are omitted from API requests. However, any non-pointer,
  332. // non-interface field appearing in ForceSendFields will be sent to the
  333. // server regardless of whether the field is empty or not. This may be
  334. // used to include empty fields in Patch requests.
  335. ForceSendFields []string `json:"-"`
  336. // NullFields is a list of field names (e.g. "Action") to include in API
  337. // requests with the JSON null value. By default, fields with empty
  338. // values are omitted from API requests. However, any field with an
  339. // empty value appearing in NullFields will be sent to the server as
  340. // null. It is an error if a field in this list has a non-empty value.
  341. // This may be used to include null fields in Patch requests.
  342. NullFields []string `json:"-"`
  343. }
  344. func (s *Filter) MarshalJSON() ([]byte, error) {
  345. type NoMethod Filter
  346. raw := NoMethod(*s)
  347. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  348. }
  349. // FilterAction: A set of actions to perform on a message.
  350. type FilterAction struct {
  351. // AddLabelIds: List of labels to add to the message.
  352. AddLabelIds []string `json:"addLabelIds,omitempty"`
  353. // Forward: Email address that the message should be forwarded to.
  354. Forward string `json:"forward,omitempty"`
  355. // RemoveLabelIds: List of labels to remove from the message.
  356. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  357. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  358. // unconditionally include in API requests. By default, fields with
  359. // empty values are omitted from API requests. However, any non-pointer,
  360. // non-interface field appearing in ForceSendFields will be sent to the
  361. // server regardless of whether the field is empty or not. This may be
  362. // used to include empty fields in Patch requests.
  363. ForceSendFields []string `json:"-"`
  364. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  365. // in API requests with the JSON null value. By default, fields with
  366. // empty values are omitted from API requests. However, any field with
  367. // an empty value appearing in NullFields will be sent to the server as
  368. // null. It is an error if a field in this list has a non-empty value.
  369. // This may be used to include null fields in Patch requests.
  370. NullFields []string `json:"-"`
  371. }
  372. func (s *FilterAction) MarshalJSON() ([]byte, error) {
  373. type NoMethod FilterAction
  374. raw := NoMethod(*s)
  375. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  376. }
  377. // FilterCriteria: Message matching criteria.
  378. type FilterCriteria struct {
  379. // ExcludeChats: Whether the response should exclude chats.
  380. ExcludeChats bool `json:"excludeChats,omitempty"`
  381. // From: The sender's display name or email address.
  382. From string `json:"from,omitempty"`
  383. // HasAttachment: Whether the message has any attachment.
  384. HasAttachment bool `json:"hasAttachment,omitempty"`
  385. // NegatedQuery: Only return messages not matching the specified query.
  386. // Supports the same query format as the Gmail search box. For example,
  387. // "from:someuser@example.com rfc822msgid: is:unread".
  388. NegatedQuery string `json:"negatedQuery,omitempty"`
  389. // Query: Only return messages matching the specified query. Supports
  390. // the same query format as the Gmail search box. For example,
  391. // "from:someuser@example.com rfc822msgid: is:unread".
  392. Query string `json:"query,omitempty"`
  393. // Size: The size of the entire RFC822 message in bytes, including all
  394. // headers and attachments.
  395. Size int64 `json:"size,omitempty"`
  396. // SizeComparison: How the message size in bytes should be in relation
  397. // to the size field.
  398. //
  399. // Possible values:
  400. // "larger"
  401. // "smaller"
  402. // "unspecified"
  403. SizeComparison string `json:"sizeComparison,omitempty"`
  404. // Subject: Case-insensitive phrase found in the message's subject.
  405. // Trailing and leading whitespace are be trimmed and adjacent spaces
  406. // are collapsed.
  407. Subject string `json:"subject,omitempty"`
  408. // To: The recipient's display name or email address. Includes
  409. // recipients in the "to", "cc", and "bcc" header fields. You can use
  410. // simply the local part of the email address. For example, "example"
  411. // and "example@" both match "example@gmail.com". This field is
  412. // case-insensitive.
  413. To string `json:"to,omitempty"`
  414. // ForceSendFields is a list of field names (e.g. "ExcludeChats") to
  415. // unconditionally include in API requests. By default, fields with
  416. // empty values are omitted from API requests. However, any non-pointer,
  417. // non-interface field appearing in ForceSendFields will be sent to the
  418. // server regardless of whether the field is empty or not. This may be
  419. // used to include empty fields in Patch requests.
  420. ForceSendFields []string `json:"-"`
  421. // NullFields is a list of field names (e.g. "ExcludeChats") to include
  422. // in API requests with the JSON null value. By default, fields with
  423. // empty values are omitted from API requests. However, any field with
  424. // an empty value appearing in NullFields will be sent to the server as
  425. // null. It is an error if a field in this list has a non-empty value.
  426. // This may be used to include null fields in Patch requests.
  427. NullFields []string `json:"-"`
  428. }
  429. func (s *FilterCriteria) MarshalJSON() ([]byte, error) {
  430. type NoMethod FilterCriteria
  431. raw := NoMethod(*s)
  432. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  433. }
  434. // ForwardingAddress: Settings for a forwarding address.
  435. type ForwardingAddress struct {
  436. // ForwardingEmail: An email address to which messages can be forwarded.
  437. ForwardingEmail string `json:"forwardingEmail,omitempty"`
  438. // VerificationStatus: Indicates whether this address has been verified
  439. // and is usable for forwarding. Read-only.
  440. //
  441. // Possible values:
  442. // "accepted"
  443. // "pending"
  444. // "verificationStatusUnspecified"
  445. VerificationStatus string `json:"verificationStatus,omitempty"`
  446. // ServerResponse contains the HTTP response code and headers from the
  447. // server.
  448. googleapi.ServerResponse `json:"-"`
  449. // ForceSendFields is a list of field names (e.g. "ForwardingEmail") to
  450. // unconditionally include in API requests. By default, fields with
  451. // empty values are omitted from API requests. However, any non-pointer,
  452. // non-interface field appearing in ForceSendFields will be sent to the
  453. // server regardless of whether the field is empty or not. This may be
  454. // used to include empty fields in Patch requests.
  455. ForceSendFields []string `json:"-"`
  456. // NullFields is a list of field names (e.g. "ForwardingEmail") to
  457. // include in API requests with the JSON null value. By default, fields
  458. // with empty values are omitted from API requests. However, any field
  459. // with an empty value appearing in NullFields will be sent to the
  460. // server as null. It is an error if a field in this list has a
  461. // non-empty value. This may be used to include null fields in Patch
  462. // requests.
  463. NullFields []string `json:"-"`
  464. }
  465. func (s *ForwardingAddress) MarshalJSON() ([]byte, error) {
  466. type NoMethod ForwardingAddress
  467. raw := NoMethod(*s)
  468. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  469. }
  470. // History: A record of a change to the user's mailbox. Each history
  471. // change may affect multiple messages in multiple ways.
  472. type History struct {
  473. // Id: The mailbox sequence ID.
  474. Id uint64 `json:"id,omitempty,string"`
  475. // LabelsAdded: Labels added to messages in this history record.
  476. LabelsAdded []*HistoryLabelAdded `json:"labelsAdded,omitempty"`
  477. // LabelsRemoved: Labels removed from messages in this history record.
  478. LabelsRemoved []*HistoryLabelRemoved `json:"labelsRemoved,omitempty"`
  479. // Messages: List of messages changed in this history record. The fields
  480. // for specific change types, such as messagesAdded may duplicate
  481. // messages in this field. We recommend using the specific change-type
  482. // fields instead of this.
  483. Messages []*Message `json:"messages,omitempty"`
  484. // MessagesAdded: Messages added to the mailbox in this history record.
  485. MessagesAdded []*HistoryMessageAdded `json:"messagesAdded,omitempty"`
  486. // MessagesDeleted: Messages deleted (not Trashed) from the mailbox in
  487. // this history record.
  488. MessagesDeleted []*HistoryMessageDeleted `json:"messagesDeleted,omitempty"`
  489. // ForceSendFields is a list of field names (e.g. "Id") to
  490. // unconditionally include in API requests. By default, fields with
  491. // empty values are omitted from API requests. However, any non-pointer,
  492. // non-interface field appearing in ForceSendFields will be sent to the
  493. // server regardless of whether the field is empty or not. This may be
  494. // used to include empty fields in Patch requests.
  495. ForceSendFields []string `json:"-"`
  496. // NullFields is a list of field names (e.g. "Id") to include in API
  497. // requests with the JSON null value. By default, fields with empty
  498. // values are omitted from API requests. However, any field with an
  499. // empty value appearing in NullFields will be sent to the server as
  500. // null. It is an error if a field in this list has a non-empty value.
  501. // This may be used to include null fields in Patch requests.
  502. NullFields []string `json:"-"`
  503. }
  504. func (s *History) MarshalJSON() ([]byte, error) {
  505. type NoMethod History
  506. raw := NoMethod(*s)
  507. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  508. }
  509. type HistoryLabelAdded struct {
  510. // LabelIds: Label IDs added to the message.
  511. LabelIds []string `json:"labelIds,omitempty"`
  512. Message *Message `json:"message,omitempty"`
  513. // ForceSendFields is a list of field names (e.g. "LabelIds") to
  514. // unconditionally include in API requests. By default, fields with
  515. // empty values are omitted from API requests. However, any non-pointer,
  516. // non-interface field appearing in ForceSendFields will be sent to the
  517. // server regardless of whether the field is empty or not. This may be
  518. // used to include empty fields in Patch requests.
  519. ForceSendFields []string `json:"-"`
  520. // NullFields is a list of field names (e.g. "LabelIds") to include in
  521. // API requests with the JSON null value. By default, fields with empty
  522. // values are omitted from API requests. However, any field with an
  523. // empty value appearing in NullFields will be sent to the server as
  524. // null. It is an error if a field in this list has a non-empty value.
  525. // This may be used to include null fields in Patch requests.
  526. NullFields []string `json:"-"`
  527. }
  528. func (s *HistoryLabelAdded) MarshalJSON() ([]byte, error) {
  529. type NoMethod HistoryLabelAdded
  530. raw := NoMethod(*s)
  531. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  532. }
  533. type HistoryLabelRemoved struct {
  534. // LabelIds: Label IDs removed from the message.
  535. LabelIds []string `json:"labelIds,omitempty"`
  536. Message *Message `json:"message,omitempty"`
  537. // ForceSendFields is a list of field names (e.g. "LabelIds") to
  538. // unconditionally include in API requests. By default, fields with
  539. // empty values are omitted from API requests. However, any non-pointer,
  540. // non-interface field appearing in ForceSendFields will be sent to the
  541. // server regardless of whether the field is empty or not. This may be
  542. // used to include empty fields in Patch requests.
  543. ForceSendFields []string `json:"-"`
  544. // NullFields is a list of field names (e.g. "LabelIds") to include in
  545. // API requests with the JSON null value. By default, fields with empty
  546. // values are omitted from API requests. However, any field with an
  547. // empty value appearing in NullFields will be sent to the server as
  548. // null. It is an error if a field in this list has a non-empty value.
  549. // This may be used to include null fields in Patch requests.
  550. NullFields []string `json:"-"`
  551. }
  552. func (s *HistoryLabelRemoved) MarshalJSON() ([]byte, error) {
  553. type NoMethod HistoryLabelRemoved
  554. raw := NoMethod(*s)
  555. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  556. }
  557. type HistoryMessageAdded struct {
  558. Message *Message `json:"message,omitempty"`
  559. // ForceSendFields is a list of field names (e.g. "Message") to
  560. // unconditionally include in API requests. By default, fields with
  561. // empty values are omitted from API requests. However, any non-pointer,
  562. // non-interface field appearing in ForceSendFields will be sent to the
  563. // server regardless of whether the field is empty or not. This may be
  564. // used to include empty fields in Patch requests.
  565. ForceSendFields []string `json:"-"`
  566. // NullFields is a list of field names (e.g. "Message") to include in
  567. // API requests with the JSON null value. By default, fields with empty
  568. // values are omitted from API requests. However, any field with an
  569. // empty value appearing in NullFields will be sent to the server as
  570. // null. It is an error if a field in this list has a non-empty value.
  571. // This may be used to include null fields in Patch requests.
  572. NullFields []string `json:"-"`
  573. }
  574. func (s *HistoryMessageAdded) MarshalJSON() ([]byte, error) {
  575. type NoMethod HistoryMessageAdded
  576. raw := NoMethod(*s)
  577. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  578. }
  579. type HistoryMessageDeleted struct {
  580. Message *Message `json:"message,omitempty"`
  581. // ForceSendFields is a list of field names (e.g. "Message") to
  582. // unconditionally include in API requests. By default, fields with
  583. // empty values are omitted from API requests. However, any non-pointer,
  584. // non-interface field appearing in ForceSendFields will be sent to the
  585. // server regardless of whether the field is empty or not. This may be
  586. // used to include empty fields in Patch requests.
  587. ForceSendFields []string `json:"-"`
  588. // NullFields is a list of field names (e.g. "Message") to include in
  589. // API requests with the JSON null value. By default, fields with empty
  590. // values are omitted from API requests. However, any field with an
  591. // empty value appearing in NullFields will be sent to the server as
  592. // null. It is an error if a field in this list has a non-empty value.
  593. // This may be used to include null fields in Patch requests.
  594. NullFields []string `json:"-"`
  595. }
  596. func (s *HistoryMessageDeleted) MarshalJSON() ([]byte, error) {
  597. type NoMethod HistoryMessageDeleted
  598. raw := NoMethod(*s)
  599. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  600. }
  601. // ImapSettings: IMAP settings for an account.
  602. type ImapSettings struct {
  603. // AutoExpunge: If this value is true, Gmail will immediately expunge a
  604. // message when it is marked as deleted in IMAP. Otherwise, Gmail will
  605. // wait for an update from the client before expunging messages marked
  606. // as deleted.
  607. AutoExpunge bool `json:"autoExpunge,omitempty"`
  608. // Enabled: Whether IMAP is enabled for the account.
  609. Enabled bool `json:"enabled,omitempty"`
  610. // ExpungeBehavior: The action that will be executed on a message when
  611. // it is marked as deleted and expunged from the last visible IMAP
  612. // folder.
  613. //
  614. // Possible values:
  615. // "archive"
  616. // "deleteForever"
  617. // "expungeBehaviorUnspecified"
  618. // "trash"
  619. ExpungeBehavior string `json:"expungeBehavior,omitempty"`
  620. // MaxFolderSize: An optional limit on the number of messages that an
  621. // IMAP folder may contain. Legal values are 0, 1000, 2000, 5000 or
  622. // 10000. A value of zero is interpreted to mean that there is no limit.
  623. MaxFolderSize int64 `json:"maxFolderSize,omitempty"`
  624. // ServerResponse contains the HTTP response code and headers from the
  625. // server.
  626. googleapi.ServerResponse `json:"-"`
  627. // ForceSendFields is a list of field names (e.g. "AutoExpunge") to
  628. // unconditionally include in API requests. By default, fields with
  629. // empty values are omitted from API requests. However, any non-pointer,
  630. // non-interface field appearing in ForceSendFields will be sent to the
  631. // server regardless of whether the field is empty or not. This may be
  632. // used to include empty fields in Patch requests.
  633. ForceSendFields []string `json:"-"`
  634. // NullFields is a list of field names (e.g. "AutoExpunge") to include
  635. // in API requests with the JSON null value. By default, fields with
  636. // empty values are omitted from API requests. However, any field with
  637. // an empty value appearing in NullFields will be sent to the server as
  638. // null. It is an error if a field in this list has a non-empty value.
  639. // This may be used to include null fields in Patch requests.
  640. NullFields []string `json:"-"`
  641. }
  642. func (s *ImapSettings) MarshalJSON() ([]byte, error) {
  643. type NoMethod ImapSettings
  644. raw := NoMethod(*s)
  645. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  646. }
  647. // Label: Labels are used to categorize messages and threads within the
  648. // user's mailbox.
  649. type Label struct {
  650. // Color: The color to assign to the label. Color is only available for
  651. // labels that have their type set to user.
  652. Color *LabelColor `json:"color,omitempty"`
  653. // Id: The immutable ID of the label.
  654. Id string `json:"id,omitempty"`
  655. // LabelListVisibility: The visibility of the label in the label list in
  656. // the Gmail web interface.
  657. //
  658. // Possible values:
  659. // "labelHide"
  660. // "labelShow"
  661. // "labelShowIfUnread"
  662. LabelListVisibility string `json:"labelListVisibility,omitempty"`
  663. // MessageListVisibility: The visibility of the label in the message
  664. // list in the Gmail web interface.
  665. //
  666. // Possible values:
  667. // "hide"
  668. // "show"
  669. MessageListVisibility string `json:"messageListVisibility,omitempty"`
  670. // MessagesTotal: The total number of messages with the label.
  671. MessagesTotal int64 `json:"messagesTotal,omitempty"`
  672. // MessagesUnread: The number of unread messages with the label.
  673. MessagesUnread int64 `json:"messagesUnread,omitempty"`
  674. // Name: The display name of the label.
  675. Name string `json:"name,omitempty"`
  676. // ThreadsTotal: The total number of threads with the label.
  677. ThreadsTotal int64 `json:"threadsTotal,omitempty"`
  678. // ThreadsUnread: The number of unread threads with the label.
  679. ThreadsUnread int64 `json:"threadsUnread,omitempty"`
  680. // Type: The owner type for the label. User labels are created by the
  681. // user and can be modified and deleted by the user and can be applied
  682. // to any message or thread. System labels are internally created and
  683. // cannot be added, modified, or deleted. System labels may be able to
  684. // be applied to or removed from messages and threads under some
  685. // circumstances but this is not guaranteed. For example, users can
  686. // apply and remove the INBOX and UNREAD labels from messages and
  687. // threads, but cannot apply or remove the DRAFTS or SENT labels from
  688. // messages or threads.
  689. //
  690. // Possible values:
  691. // "system"
  692. // "user"
  693. Type string `json:"type,omitempty"`
  694. // ServerResponse contains the HTTP response code and headers from the
  695. // server.
  696. googleapi.ServerResponse `json:"-"`
  697. // ForceSendFields is a list of field names (e.g. "Color") to
  698. // unconditionally include in API requests. By default, fields with
  699. // empty values are omitted from API requests. However, any non-pointer,
  700. // non-interface field appearing in ForceSendFields will be sent to the
  701. // server regardless of whether the field is empty or not. This may be
  702. // used to include empty fields in Patch requests.
  703. ForceSendFields []string `json:"-"`
  704. // NullFields is a list of field names (e.g. "Color") to include in API
  705. // requests with the JSON null value. By default, fields with empty
  706. // values are omitted from API requests. However, any field with an
  707. // empty value appearing in NullFields will be sent to the server as
  708. // null. It is an error if a field in this list has a non-empty value.
  709. // This may be used to include null fields in Patch requests.
  710. NullFields []string `json:"-"`
  711. }
  712. func (s *Label) MarshalJSON() ([]byte, error) {
  713. type NoMethod Label
  714. raw := NoMethod(*s)
  715. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  716. }
  717. type LabelColor struct {
  718. // BackgroundColor: The background color represented as hex string
  719. // #RRGGBB (ex #000000). This field is required in order to set the
  720. // color of a label. Only the following predefined set of color values
  721. // are allowed:
  722. // #000000, #434343, #666666, #999999, #cccccc, #efefef, #f3f3f3,
  723. // #ffffff, #fb4c2f, #ffad47, #fad165, #16a766, #43d692, #4a86e8,
  724. // #a479e2, #f691b3, #f6c5be, #ffe6c7, #fef1d1, #b9e4d0, #c6f3de,
  725. // #c9daf8, #e4d7f5, #fcdee8, #efa093, #ffd6a2, #fce8b3, #89d3b2,
  726. // #a0eac9, #a4c2f4, #d0bcf1, #fbc8d9, #e66550, #ffbc6b, #fcda83,
  727. // #44b984, #68dfa9, #6d9eeb, #b694e8, #f7a7c0, #cc3a21, #eaa041,
  728. // #f2c960, #149e60, #3dc789, #3c78d8, #8e63ce, #e07798, #ac2b16,
  729. // #cf8933, #d5ae49, #0b804b, #2a9c68, #285bac, #653e9b, #b65775,
  730. // #822111, #a46a21, #aa8831, #076239, #1a764d, #1c4587, #41236d,
  731. // #83334c
  732. BackgroundColor string `json:"backgroundColor,omitempty"`
  733. // TextColor: The text color of the label, represented as hex string.
  734. // This field is required in order to set the color of a label. Only the
  735. // following predefined set of color values are allowed:
  736. // #000000, #434343, #666666, #999999, #cccccc, #efefef, #f3f3f3,
  737. // #ffffff, #fb4c2f, #ffad47, #fad165, #16a766, #43d692, #4a86e8,
  738. // #a479e2, #f691b3, #f6c5be, #ffe6c7, #fef1d1, #b9e4d0, #c6f3de,
  739. // #c9daf8, #e4d7f5, #fcdee8, #efa093, #ffd6a2, #fce8b3, #89d3b2,
  740. // #a0eac9, #a4c2f4, #d0bcf1, #fbc8d9, #e66550, #ffbc6b, #fcda83,
  741. // #44b984, #68dfa9, #6d9eeb, #b694e8, #f7a7c0, #cc3a21, #eaa041,
  742. // #f2c960, #149e60, #3dc789, #3c78d8, #8e63ce, #e07798, #ac2b16,
  743. // #cf8933, #d5ae49, #0b804b, #2a9c68, #285bac, #653e9b, #b65775,
  744. // #822111, #a46a21, #aa8831, #076239, #1a764d, #1c4587, #41236d,
  745. // #83334c
  746. TextColor string `json:"textColor,omitempty"`
  747. // ForceSendFields is a list of field names (e.g. "BackgroundColor") to
  748. // unconditionally include in API requests. By default, fields with
  749. // empty values are omitted from API requests. However, any non-pointer,
  750. // non-interface field appearing in ForceSendFields will be sent to the
  751. // server regardless of whether the field is empty or not. This may be
  752. // used to include empty fields in Patch requests.
  753. ForceSendFields []string `json:"-"`
  754. // NullFields is a list of field names (e.g. "BackgroundColor") to
  755. // include in API requests with the JSON null value. By default, fields
  756. // with empty values are omitted from API requests. However, any field
  757. // with an empty value appearing in NullFields will be sent to the
  758. // server as null. It is an error if a field in this list has a
  759. // non-empty value. This may be used to include null fields in Patch
  760. // requests.
  761. NullFields []string `json:"-"`
  762. }
  763. func (s *LabelColor) MarshalJSON() ([]byte, error) {
  764. type NoMethod LabelColor
  765. raw := NoMethod(*s)
  766. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  767. }
  768. type ListDraftsResponse struct {
  769. // Drafts: List of drafts.
  770. Drafts []*Draft `json:"drafts,omitempty"`
  771. // NextPageToken: Token to retrieve the next page of results in the
  772. // list.
  773. NextPageToken string `json:"nextPageToken,omitempty"`
  774. // ResultSizeEstimate: Estimated total number of results.
  775. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  776. // ServerResponse contains the HTTP response code and headers from the
  777. // server.
  778. googleapi.ServerResponse `json:"-"`
  779. // ForceSendFields is a list of field names (e.g. "Drafts") to
  780. // unconditionally include in API requests. By default, fields with
  781. // empty values are omitted from API requests. However, any non-pointer,
  782. // non-interface field appearing in ForceSendFields will be sent to the
  783. // server regardless of whether the field is empty or not. This may be
  784. // used to include empty fields in Patch requests.
  785. ForceSendFields []string `json:"-"`
  786. // NullFields is a list of field names (e.g. "Drafts") to include in API
  787. // requests with the JSON null value. By default, fields with empty
  788. // values are omitted from API requests. However, any field with an
  789. // empty value appearing in NullFields will be sent to the server as
  790. // null. It is an error if a field in this list has a non-empty value.
  791. // This may be used to include null fields in Patch requests.
  792. NullFields []string `json:"-"`
  793. }
  794. func (s *ListDraftsResponse) MarshalJSON() ([]byte, error) {
  795. type NoMethod ListDraftsResponse
  796. raw := NoMethod(*s)
  797. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  798. }
  799. // ListFiltersResponse: Response for the ListFilters method.
  800. type ListFiltersResponse struct {
  801. // Filter: List of a user's filters.
  802. Filter []*Filter `json:"filter,omitempty"`
  803. // ServerResponse contains the HTTP response code and headers from the
  804. // server.
  805. googleapi.ServerResponse `json:"-"`
  806. // ForceSendFields is a list of field names (e.g. "Filter") to
  807. // unconditionally include in API requests. By default, fields with
  808. // empty values are omitted from API requests. However, any non-pointer,
  809. // non-interface field appearing in ForceSendFields will be sent to the
  810. // server regardless of whether the field is empty or not. This may be
  811. // used to include empty fields in Patch requests.
  812. ForceSendFields []string `json:"-"`
  813. // NullFields is a list of field names (e.g. "Filter") to include in API
  814. // requests with the JSON null value. By default, fields with empty
  815. // values are omitted from API requests. However, any field with an
  816. // empty value appearing in NullFields will be sent to the server as
  817. // null. It is an error if a field in this list has a non-empty value.
  818. // This may be used to include null fields in Patch requests.
  819. NullFields []string `json:"-"`
  820. }
  821. func (s *ListFiltersResponse) MarshalJSON() ([]byte, error) {
  822. type NoMethod ListFiltersResponse
  823. raw := NoMethod(*s)
  824. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  825. }
  826. // ListForwardingAddressesResponse: Response for the
  827. // ListForwardingAddresses method.
  828. type ListForwardingAddressesResponse struct {
  829. // ForwardingAddresses: List of addresses that may be used for
  830. // forwarding.
  831. ForwardingAddresses []*ForwardingAddress `json:"forwardingAddresses,omitempty"`
  832. // ServerResponse contains the HTTP response code and headers from the
  833. // server.
  834. googleapi.ServerResponse `json:"-"`
  835. // ForceSendFields is a list of field names (e.g. "ForwardingAddresses")
  836. // to unconditionally include in API requests. By default, fields with
  837. // empty values are omitted from API requests. However, any non-pointer,
  838. // non-interface field appearing in ForceSendFields will be sent to the
  839. // server regardless of whether the field is empty or not. This may be
  840. // used to include empty fields in Patch requests.
  841. ForceSendFields []string `json:"-"`
  842. // NullFields is a list of field names (e.g. "ForwardingAddresses") to
  843. // include in API requests with the JSON null value. By default, fields
  844. // with empty values are omitted from API requests. However, any field
  845. // with an empty value appearing in NullFields will be sent to the
  846. // server as null. It is an error if a field in this list has a
  847. // non-empty value. This may be used to include null fields in Patch
  848. // requests.
  849. NullFields []string `json:"-"`
  850. }
  851. func (s *ListForwardingAddressesResponse) MarshalJSON() ([]byte, error) {
  852. type NoMethod ListForwardingAddressesResponse
  853. raw := NoMethod(*s)
  854. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  855. }
  856. type ListHistoryResponse struct {
  857. // History: List of history records. Any messages contained in the
  858. // response will typically only have id and threadId fields populated.
  859. History []*History `json:"history,omitempty"`
  860. // HistoryId: The ID of the mailbox's current history record.
  861. HistoryId uint64 `json:"historyId,omitempty,string"`
  862. // NextPageToken: Page token to retrieve the next page of results in the
  863. // list.
  864. NextPageToken string `json:"nextPageToken,omitempty"`
  865. // ServerResponse contains the HTTP response code and headers from the
  866. // server.
  867. googleapi.ServerResponse `json:"-"`
  868. // ForceSendFields is a list of field names (e.g. "History") to
  869. // unconditionally include in API requests. By default, fields with
  870. // empty values are omitted from API requests. However, any non-pointer,
  871. // non-interface field appearing in ForceSendFields will be sent to the
  872. // server regardless of whether the field is empty or not. This may be
  873. // used to include empty fields in Patch requests.
  874. ForceSendFields []string `json:"-"`
  875. // NullFields is a list of field names (e.g. "History") to include in
  876. // API requests with the JSON null value. By default, fields with empty
  877. // values are omitted from API requests. However, any field with an
  878. // empty value appearing in NullFields will be sent to the server as
  879. // null. It is an error if a field in this list has a non-empty value.
  880. // This may be used to include null fields in Patch requests.
  881. NullFields []string `json:"-"`
  882. }
  883. func (s *ListHistoryResponse) MarshalJSON() ([]byte, error) {
  884. type NoMethod ListHistoryResponse
  885. raw := NoMethod(*s)
  886. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  887. }
  888. type ListLabelsResponse struct {
  889. // Labels: List of labels.
  890. Labels []*Label `json:"labels,omitempty"`
  891. // ServerResponse contains the HTTP response code and headers from the
  892. // server.
  893. googleapi.ServerResponse `json:"-"`
  894. // ForceSendFields is a list of field names (e.g. "Labels") to
  895. // unconditionally include in API requests. By default, fields with
  896. // empty values are omitted from API requests. However, any non-pointer,
  897. // non-interface field appearing in ForceSendFields will be sent to the
  898. // server regardless of whether the field is empty or not. This may be
  899. // used to include empty fields in Patch requests.
  900. ForceSendFields []string `json:"-"`
  901. // NullFields is a list of field names (e.g. "Labels") to include in API
  902. // requests with the JSON null value. By default, fields with empty
  903. // values are omitted from API requests. However, any field with an
  904. // empty value appearing in NullFields will be sent to the server as
  905. // null. It is an error if a field in this list has a non-empty value.
  906. // This may be used to include null fields in Patch requests.
  907. NullFields []string `json:"-"`
  908. }
  909. func (s *ListLabelsResponse) MarshalJSON() ([]byte, error) {
  910. type NoMethod ListLabelsResponse
  911. raw := NoMethod(*s)
  912. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  913. }
  914. type ListMessagesResponse struct {
  915. // Messages: List of messages.
  916. Messages []*Message `json:"messages,omitempty"`
  917. // NextPageToken: Token to retrieve the next page of results in the
  918. // list.
  919. NextPageToken string `json:"nextPageToken,omitempty"`
  920. // ResultSizeEstimate: Estimated total number of results.
  921. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  922. // ServerResponse contains the HTTP response code and headers from the
  923. // server.
  924. googleapi.ServerResponse `json:"-"`
  925. // ForceSendFields is a list of field names (e.g. "Messages") to
  926. // unconditionally include in API requests. By default, fields with
  927. // empty values are omitted from API requests. However, any non-pointer,
  928. // non-interface field appearing in ForceSendFields will be sent to the
  929. // server regardless of whether the field is empty or not. This may be
  930. // used to include empty fields in Patch requests.
  931. ForceSendFields []string `json:"-"`
  932. // NullFields is a list of field names (e.g. "Messages") to include in
  933. // API requests with the JSON null value. By default, fields with empty
  934. // values are omitted from API requests. However, any field with an
  935. // empty value appearing in NullFields will be sent to the server as
  936. // null. It is an error if a field in this list has a non-empty value.
  937. // This may be used to include null fields in Patch requests.
  938. NullFields []string `json:"-"`
  939. }
  940. func (s *ListMessagesResponse) MarshalJSON() ([]byte, error) {
  941. type NoMethod ListMessagesResponse
  942. raw := NoMethod(*s)
  943. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  944. }
  945. // ListSendAsResponse: Response for the ListSendAs method.
  946. type ListSendAsResponse struct {
  947. // SendAs: List of send-as aliases.
  948. SendAs []*SendAs `json:"sendAs,omitempty"`
  949. // ServerResponse contains the HTTP response code and headers from the
  950. // server.
  951. googleapi.ServerResponse `json:"-"`
  952. // ForceSendFields is a list of field names (e.g. "SendAs") to
  953. // unconditionally include in API requests. By default, fields with
  954. // empty values are omitted from API requests. However, any non-pointer,
  955. // non-interface field appearing in ForceSendFields will be sent to the
  956. // server regardless of whether the field is empty or not. This may be
  957. // used to include empty fields in Patch requests.
  958. ForceSendFields []string `json:"-"`
  959. // NullFields is a list of field names (e.g. "SendAs") to include in API
  960. // requests with the JSON null value. By default, fields with empty
  961. // values are omitted from API requests. However, any field with an
  962. // empty value appearing in NullFields will be sent to the server as
  963. // null. It is an error if a field in this list has a non-empty value.
  964. // This may be used to include null fields in Patch requests.
  965. NullFields []string `json:"-"`
  966. }
  967. func (s *ListSendAsResponse) MarshalJSON() ([]byte, error) {
  968. type NoMethod ListSendAsResponse
  969. raw := NoMethod(*s)
  970. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  971. }
  972. type ListSmimeInfoResponse struct {
  973. // SmimeInfo: List of SmimeInfo.
  974. SmimeInfo []*SmimeInfo `json:"smimeInfo,omitempty"`
  975. // ServerResponse contains the HTTP response code and headers from the
  976. // server.
  977. googleapi.ServerResponse `json:"-"`
  978. // ForceSendFields is a list of field names (e.g. "SmimeInfo") to
  979. // unconditionally include in API requests. By default, fields with
  980. // empty values are omitted from API requests. However, any non-pointer,
  981. // non-interface field appearing in ForceSendFields will be sent to the
  982. // server regardless of whether the field is empty or not. This may be
  983. // used to include empty fields in Patch requests.
  984. ForceSendFields []string `json:"-"`
  985. // NullFields is a list of field names (e.g. "SmimeInfo") to include in
  986. // API requests with the JSON null value. By default, fields with empty
  987. // values are omitted from API requests. However, any field with an
  988. // empty value appearing in NullFields will be sent to the server as
  989. // null. It is an error if a field in this list has a non-empty value.
  990. // This may be used to include null fields in Patch requests.
  991. NullFields []string `json:"-"`
  992. }
  993. func (s *ListSmimeInfoResponse) MarshalJSON() ([]byte, error) {
  994. type NoMethod ListSmimeInfoResponse
  995. raw := NoMethod(*s)
  996. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  997. }
  998. type ListThreadsResponse struct {
  999. // NextPageToken: Page token to retrieve the next page of results in the
  1000. // list.
  1001. NextPageToken string `json:"nextPageToken,omitempty"`
  1002. // ResultSizeEstimate: Estimated total number of results.
  1003. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  1004. // Threads: List of threads.
  1005. Threads []*Thread `json:"threads,omitempty"`
  1006. // ServerResponse contains the HTTP response code and headers from the
  1007. // server.
  1008. googleapi.ServerResponse `json:"-"`
  1009. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  1010. // unconditionally include in API requests. By default, fields with
  1011. // empty values are omitted from API requests. However, any non-pointer,
  1012. // non-interface field appearing in ForceSendFields will be sent to the
  1013. // server regardless of whether the field is empty or not. This may be
  1014. // used to include empty fields in Patch requests.
  1015. ForceSendFields []string `json:"-"`
  1016. // NullFields is a list of field names (e.g. "NextPageToken") to include
  1017. // in API requests with the JSON null value. By default, fields with
  1018. // empty values are omitted from API requests. However, any field with
  1019. // an empty value appearing in NullFields will be sent to the server as
  1020. // null. It is an error if a field in this list has a non-empty value.
  1021. // This may be used to include null fields in Patch requests.
  1022. NullFields []string `json:"-"`
  1023. }
  1024. func (s *ListThreadsResponse) MarshalJSON() ([]byte, error) {
  1025. type NoMethod ListThreadsResponse
  1026. raw := NoMethod(*s)
  1027. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1028. }
  1029. // Message: An email message.
  1030. type Message struct {
  1031. // HistoryId: The ID of the last history record that modified this
  1032. // message.
  1033. HistoryId uint64 `json:"historyId,omitempty,string"`
  1034. // Id: The immutable ID of the message.
  1035. Id string `json:"id,omitempty"`
  1036. // InternalDate: The internal message creation timestamp (epoch ms),
  1037. // which determines ordering in the inbox. For normal SMTP-received
  1038. // email, this represents the time the message was originally accepted
  1039. // by Google, which is more reliable than the Date header. However, for
  1040. // API-migrated mail, it can be configured by client to be based on the
  1041. // Date header.
  1042. InternalDate int64 `json:"internalDate,omitempty,string"`
  1043. // LabelIds: List of IDs of labels applied to this message.
  1044. LabelIds []string `json:"labelIds,omitempty"`
  1045. // Payload: The parsed email structure in the message parts.
  1046. Payload *MessagePart `json:"payload,omitempty"`
  1047. // Raw: The entire email message in an RFC 2822 formatted and base64url
  1048. // encoded string. Returned in messages.get and drafts.get responses
  1049. // when the format=RAW parameter is supplied.
  1050. Raw string `json:"raw,omitempty"`
  1051. // SizeEstimate: Estimated size in bytes of the message.
  1052. SizeEstimate int64 `json:"sizeEstimate,omitempty"`
  1053. // Snippet: A short part of the message text.
  1054. Snippet string `json:"snippet,omitempty"`
  1055. // ThreadId: The ID of the thread the message belongs to. To add a
  1056. // message or draft to a thread, the following criteria must be met:
  1057. // - The requested threadId must be specified on the Message or
  1058. // Draft.Message you supply with your request.
  1059. // - The References and In-Reply-To headers must be set in compliance
  1060. // with the RFC 2822 standard.
  1061. // - The Subject headers must match.
  1062. ThreadId string `json:"threadId,omitempty"`
  1063. // ServerResponse contains the HTTP response code and headers from the
  1064. // server.
  1065. googleapi.ServerResponse `json:"-"`
  1066. // ForceSendFields is a list of field names (e.g. "HistoryId") to
  1067. // unconditionally include in API requests. By default, fields with
  1068. // empty values are omitted from API requests. However, any non-pointer,
  1069. // non-interface field appearing in ForceSendFields will be sent to the
  1070. // server regardless of whether the field is empty or not. This may be
  1071. // used to include empty fields in Patch requests.
  1072. ForceSendFields []string `json:"-"`
  1073. // NullFields is a list of field names (e.g. "HistoryId") to include in
  1074. // API requests with the JSON null value. By default, fields with empty
  1075. // values are omitted from API requests. However, any field with an
  1076. // empty value appearing in NullFields will be sent to the server as
  1077. // null. It is an error if a field in this list has a non-empty value.
  1078. // This may be used to include null fields in Patch requests.
  1079. NullFields []string `json:"-"`
  1080. }
  1081. func (s *Message) MarshalJSON() ([]byte, error) {
  1082. type NoMethod Message
  1083. raw := NoMethod(*s)
  1084. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1085. }
  1086. // MessagePart: A single MIME message part.
  1087. type MessagePart struct {
  1088. // Body: The message part body for this part, which may be empty for
  1089. // container MIME message parts.
  1090. Body *MessagePartBody `json:"body,omitempty"`
  1091. // Filename: The filename of the attachment. Only present if this
  1092. // message part represents an attachment.
  1093. Filename string `json:"filename,omitempty"`
  1094. // Headers: List of headers on this message part. For the top-level
  1095. // message part, representing the entire message payload, it will
  1096. // contain the standard RFC 2822 email headers such as To, From, and
  1097. // Subject.
  1098. Headers []*MessagePartHeader `json:"headers,omitempty"`
  1099. // MimeType: The MIME type of the message part.
  1100. MimeType string `json:"mimeType,omitempty"`
  1101. // PartId: The immutable ID of the message part.
  1102. PartId string `json:"partId,omitempty"`
  1103. // Parts: The child MIME message parts of this part. This only applies
  1104. // to container MIME message parts, for example multipart/*. For non-
  1105. // container MIME message part types, such as text/plain, this field is
  1106. // empty. For more information, see RFC 1521.
  1107. Parts []*MessagePart `json:"parts,omitempty"`
  1108. // ForceSendFields is a list of field names (e.g. "Body") to
  1109. // unconditionally include in API requests. By default, fields with
  1110. // empty values are omitted from API requests. However, any non-pointer,
  1111. // non-interface field appearing in ForceSendFields will be sent to the
  1112. // server regardless of whether the field is empty or not. This may be
  1113. // used to include empty fields in Patch requests.
  1114. ForceSendFields []string `json:"-"`
  1115. // NullFields is a list of field names (e.g. "Body") to include in API
  1116. // requests with the JSON null value. By default, fields with empty
  1117. // values are omitted from API requests. However, any field with an
  1118. // empty value appearing in NullFields will be sent to the server as
  1119. // null. It is an error if a field in this list has a non-empty value.
  1120. // This may be used to include null fields in Patch requests.
  1121. NullFields []string `json:"-"`
  1122. }
  1123. func (s *MessagePart) MarshalJSON() ([]byte, error) {
  1124. type NoMethod MessagePart
  1125. raw := NoMethod(*s)
  1126. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1127. }
  1128. // MessagePartBody: The body of a single MIME message part.
  1129. type MessagePartBody struct {
  1130. // AttachmentId: When present, contains the ID of an external attachment
  1131. // that can be retrieved in a separate messages.attachments.get request.
  1132. // When not present, the entire content of the message part body is
  1133. // contained in the data field.
  1134. AttachmentId string `json:"attachmentId,omitempty"`
  1135. // Data: The body data of a MIME message part as a base64url encoded
  1136. // string. May be empty for MIME container types that have no message
  1137. // body or when the body data is sent as a separate attachment. An
  1138. // attachment ID is present if the body data is contained in a separate
  1139. // attachment.
  1140. Data string `json:"data,omitempty"`
  1141. // Size: Number of bytes for the message part data (encoding
  1142. // notwithstanding).
  1143. Size int64 `json:"size,omitempty"`
  1144. // ServerResponse contains the HTTP response code and headers from the
  1145. // server.
  1146. googleapi.ServerResponse `json:"-"`
  1147. // ForceSendFields is a list of field names (e.g. "AttachmentId") to
  1148. // unconditionally include in API requests. By default, fields with
  1149. // empty values are omitted from API requests. However, any non-pointer,
  1150. // non-interface field appearing in ForceSendFields will be sent to the
  1151. // server regardless of whether the field is empty or not. This may be
  1152. // used to include empty fields in Patch requests.
  1153. ForceSendFields []string `json:"-"`
  1154. // NullFields is a list of field names (e.g. "AttachmentId") to include
  1155. // in API requests with the JSON null value. By default, fields with
  1156. // empty values are omitted from API requests. However, any field with
  1157. // an empty value appearing in NullFields will be sent to the server as
  1158. // null. It is an error if a field in this list has a non-empty value.
  1159. // This may be used to include null fields in Patch requests.
  1160. NullFields []string `json:"-"`
  1161. }
  1162. func (s *MessagePartBody) MarshalJSON() ([]byte, error) {
  1163. type NoMethod MessagePartBody
  1164. raw := NoMethod(*s)
  1165. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1166. }
  1167. type MessagePartHeader struct {
  1168. // Name: The name of the header before the : separator. For example, To.
  1169. Name string `json:"name,omitempty"`
  1170. // Value: The value of the header after the : separator. For example,
  1171. // someuser@example.com.
  1172. Value string `json:"value,omitempty"`
  1173. // ForceSendFields is a list of field names (e.g. "Name") to
  1174. // unconditionally include in API requests. By default, fields with
  1175. // empty values are omitted from API requests. However, any non-pointer,
  1176. // non-interface field appearing in ForceSendFields will be sent to the
  1177. // server regardless of whether the field is empty or not. This may be
  1178. // used to include empty fields in Patch requests.
  1179. ForceSendFields []string `json:"-"`
  1180. // NullFields is a list of field names (e.g. "Name") to include in API
  1181. // requests with the JSON null value. By default, fields with empty
  1182. // values are omitted from API requests. However, any field with an
  1183. // empty value appearing in NullFields will be sent to the server as
  1184. // null. It is an error if a field in this list has a non-empty value.
  1185. // This may be used to include null fields in Patch requests.
  1186. NullFields []string `json:"-"`
  1187. }
  1188. func (s *MessagePartHeader) MarshalJSON() ([]byte, error) {
  1189. type NoMethod MessagePartHeader
  1190. raw := NoMethod(*s)
  1191. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1192. }
  1193. type ModifyMessageRequest struct {
  1194. // AddLabelIds: A list of IDs of labels to add to this message.
  1195. AddLabelIds []string `json:"addLabelIds,omitempty"`
  1196. // RemoveLabelIds: A list IDs of labels to remove from this message.
  1197. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  1198. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  1199. // unconditionally include in API requests. By default, fields with
  1200. // empty values are omitted from API requests. However, any non-pointer,
  1201. // non-interface field appearing in ForceSendFields will be sent to the
  1202. // server regardless of whether the field is empty or not. This may be
  1203. // used to include empty fields in Patch requests.
  1204. ForceSendFields []string `json:"-"`
  1205. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  1206. // in API requests with the JSON null value. By default, fields with
  1207. // empty values are omitted from API requests. However, any field with
  1208. // an empty value appearing in NullFields will be sent to the server as
  1209. // null. It is an error if a field in this list has a non-empty value.
  1210. // This may be used to include null fields in Patch requests.
  1211. NullFields []string `json:"-"`
  1212. }
  1213. func (s *ModifyMessageRequest) MarshalJSON() ([]byte, error) {
  1214. type NoMethod ModifyMessageRequest
  1215. raw := NoMethod(*s)
  1216. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1217. }
  1218. type ModifyThreadRequest struct {
  1219. // AddLabelIds: A list of IDs of labels to add to this thread.
  1220. AddLabelIds []string `json:"addLabelIds,omitempty"`
  1221. // RemoveLabelIds: A list of IDs of labels to remove from this thread.
  1222. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  1223. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  1224. // unconditionally include in API requests. By default, fields with
  1225. // empty values are omitted from API requests. However, any non-pointer,
  1226. // non-interface field appearing in ForceSendFields will be sent to the
  1227. // server regardless of whether the field is empty or not. This may be
  1228. // used to include empty fields in Patch requests.
  1229. ForceSendFields []string `json:"-"`
  1230. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  1231. // in API requests with the JSON null value. By default, fields with
  1232. // empty values are omitted from API requests. However, any field with
  1233. // an empty value appearing in NullFields will be sent to the server as
  1234. // null. It is an error if a field in this list has a non-empty value.
  1235. // This may be used to include null fields in Patch requests.
  1236. NullFields []string `json:"-"`
  1237. }
  1238. func (s *ModifyThreadRequest) MarshalJSON() ([]byte, error) {
  1239. type NoMethod ModifyThreadRequest
  1240. raw := NoMethod(*s)
  1241. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1242. }
  1243. // PopSettings: POP settings for an account.
  1244. type PopSettings struct {
  1245. // AccessWindow: The range of messages which are accessible via POP.
  1246. //
  1247. // Possible values:
  1248. // "accessWindowUnspecified"
  1249. // "allMail"
  1250. // "disabled"
  1251. // "fromNowOn"
  1252. AccessWindow string `json:"accessWindow,omitempty"`
  1253. // Disposition: The action that will be executed on a message after it
  1254. // has been fetched via POP.
  1255. //
  1256. // Possible values:
  1257. // "archive"
  1258. // "dispositionUnspecified"
  1259. // "leaveInInbox"
  1260. // "markRead"
  1261. // "trash"
  1262. Disposition string `json:"disposition,omitempty"`
  1263. // ServerResponse contains the HTTP response code and headers from the
  1264. // server.
  1265. googleapi.ServerResponse `json:"-"`
  1266. // ForceSendFields is a list of field names (e.g. "AccessWindow") to
  1267. // unconditionally include in API requests. By default, fields with
  1268. // empty values are omitted from API requests. However, any non-pointer,
  1269. // non-interface field appearing in ForceSendFields will be sent to the
  1270. // server regardless of whether the field is empty or not. This may be
  1271. // used to include empty fields in Patch requests.
  1272. ForceSendFields []string `json:"-"`
  1273. // NullFields is a list of field names (e.g. "AccessWindow") to include
  1274. // in API requests with the JSON null value. By default, fields with
  1275. // empty values are omitted from API requests. However, any field with
  1276. // an empty value appearing in NullFields will be sent to the server as
  1277. // null. It is an error if a field in this list has a non-empty value.
  1278. // This may be used to include null fields in Patch requests.
  1279. NullFields []string `json:"-"`
  1280. }
  1281. func (s *PopSettings) MarshalJSON() ([]byte, error) {
  1282. type NoMethod PopSettings
  1283. raw := NoMethod(*s)
  1284. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1285. }
  1286. // Profile: Profile for a Gmail user.
  1287. type Profile struct {
  1288. // EmailAddress: The user's email address.
  1289. EmailAddress string `json:"emailAddress,omitempty"`
  1290. // HistoryId: The ID of the mailbox's current history record.
  1291. HistoryId uint64 `json:"historyId,omitempty,string"`
  1292. // MessagesTotal: The total number of messages in the mailbox.
  1293. MessagesTotal int64 `json:"messagesTotal,omitempty"`
  1294. // ThreadsTotal: The total number of threads in the mailbox.
  1295. ThreadsTotal int64 `json:"threadsTotal,omitempty"`
  1296. // ServerResponse contains the HTTP response code and headers from the
  1297. // server.
  1298. googleapi.ServerResponse `json:"-"`
  1299. // ForceSendFields is a list of field names (e.g. "EmailAddress") to
  1300. // unconditionally include in API requests. By default, fields with
  1301. // empty values are omitted from API requests. However, any non-pointer,
  1302. // non-interface field appearing in ForceSendFields will be sent to the
  1303. // server regardless of whether the field is empty or not. This may be
  1304. // used to include empty fields in Patch requests.
  1305. ForceSendFields []string `json:"-"`
  1306. // NullFields is a list of field names (e.g. "EmailAddress") to include
  1307. // in API requests with the JSON null value. By default, fields with
  1308. // empty values are omitted from API requests. However, any field with
  1309. // an empty value appearing in NullFields will be sent to the server as
  1310. // null. It is an error if a field in this list has a non-empty value.
  1311. // This may be used to include null fields in Patch requests.
  1312. NullFields []string `json:"-"`
  1313. }
  1314. func (s *Profile) MarshalJSON() ([]byte, error) {
  1315. type NoMethod Profile
  1316. raw := NoMethod(*s)
  1317. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1318. }
  1319. // SendAs: Settings associated with a send-as alias, which can be either
  1320. // the primary login address associated with the account or a custom
  1321. // "from" address. Send-as aliases correspond to the "Send Mail As"
  1322. // feature in the web interface.
  1323. type SendAs struct {
  1324. // DisplayName: A name that appears in the "From:" header for mail sent
  1325. // using this alias. For custom "from" addresses, when this is empty,
  1326. // Gmail will populate the "From:" header with the name that is used for
  1327. // the primary address associated with the account. If the admin has
  1328. // disabled the ability for users to update their name format, requests
  1329. // to update this field for the primary login will silently fail.
  1330. DisplayName string `json:"displayName,omitempty"`
  1331. // IsDefault: Whether this address is selected as the default "From:"
  1332. // address in situations such as composing a new message or sending a
  1333. // vacation auto-reply. Every Gmail account has exactly one default
  1334. // send-as address, so the only legal value that clients may write to
  1335. // this field is true. Changing this from false to true for an address
  1336. // will result in this field becoming false for the other previous
  1337. // default address.
  1338. IsDefault bool `json:"isDefault,omitempty"`
  1339. // IsPrimary: Whether this address is the primary address used to login
  1340. // to the account. Every Gmail account has exactly one primary address,
  1341. // and it cannot be deleted from the collection of send-as aliases. This
  1342. // field is read-only.
  1343. IsPrimary bool `json:"isPrimary,omitempty"`
  1344. // ReplyToAddress: An optional email address that is included in a
  1345. // "Reply-To:" header for mail sent using this alias. If this is empty,
  1346. // Gmail will not generate a "Reply-To:" header.
  1347. ReplyToAddress string `json:"replyToAddress,omitempty"`
  1348. // SendAsEmail: The email address that appears in the "From:" header for
  1349. // mail sent using this alias. This is read-only for all operations
  1350. // except create.
  1351. SendAsEmail string `json:"sendAsEmail,omitempty"`
  1352. // Signature: An optional HTML signature that is included in messages
  1353. // composed with this alias in the Gmail web UI.
  1354. Signature string `json:"signature,omitempty"`
  1355. // SmtpMsa: An optional SMTP service that will be used as an outbound
  1356. // relay for mail sent using this alias. If this is empty, outbound mail
  1357. // will be sent directly from Gmail's servers to the destination SMTP
  1358. // service. This setting only applies to custom "from" aliases.
  1359. SmtpMsa *SmtpMsa `json:"smtpMsa,omitempty"`
  1360. // TreatAsAlias: Whether Gmail should treat this address as an alias
  1361. // for the user's primary email address. This setting only applies to
  1362. // custom "from" aliases.
  1363. TreatAsAlias bool `json:"treatAsAlias,omitempty"`
  1364. // VerificationStatus: Indicates whether this address has been verified
  1365. // for use as a send-as alias. Read-only. This setting only applies to
  1366. // custom "from" aliases.
  1367. //
  1368. // Possible values:
  1369. // "accepted"
  1370. // "pending"
  1371. // "verificationStatusUnspecified"
  1372. VerificationStatus string `json:"verificationStatus,omitempty"`
  1373. // ServerResponse contains the HTTP response code and headers from the
  1374. // server.
  1375. googleapi.ServerResponse `json:"-"`
  1376. // ForceSendFields is a list of field names (e.g. "DisplayName") to
  1377. // unconditionally include in API requests. By default, fields with
  1378. // empty values are omitted from API requests. However, any non-pointer,
  1379. // non-interface field appearing in ForceSendFields will be sent to the
  1380. // server regardless of whether the field is empty or not. This may be
  1381. // used to include empty fields in Patch requests.
  1382. ForceSendFields []string `json:"-"`
  1383. // NullFields is a list of field names (e.g. "DisplayName") to include
  1384. // in API requests with the JSON null value. By default, fields with
  1385. // empty values are omitted from API requests. However, any field with
  1386. // an empty value appearing in NullFields will be sent to the server as
  1387. // null. It is an error if a field in this list has a non-empty value.
  1388. // This may be used to include null fields in Patch requests.
  1389. NullFields []string `json:"-"`
  1390. }
  1391. func (s *SendAs) MarshalJSON() ([]byte, error) {
  1392. type NoMethod SendAs
  1393. raw := NoMethod(*s)
  1394. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1395. }
  1396. // SmimeInfo: An S/MIME email config.
  1397. type SmimeInfo struct {
  1398. // EncryptedKeyPassword: Encrypted key password, when key is encrypted.
  1399. EncryptedKeyPassword string `json:"encryptedKeyPassword,omitempty"`
  1400. // Expiration: When the certificate expires (in milliseconds since
  1401. // epoch).
  1402. Expiration int64 `json:"expiration,omitempty,string"`
  1403. // Id: The immutable ID for the SmimeInfo.
  1404. Id string `json:"id,omitempty"`
  1405. // IsDefault: Whether this SmimeInfo is the default one for this user's
  1406. // send-as address.
  1407. IsDefault bool `json:"isDefault,omitempty"`
  1408. // IssuerCn: The S/MIME certificate issuer's common name.
  1409. IssuerCn string `json:"issuerCn,omitempty"`
  1410. // Pem: PEM formatted X509 concatenated certificate string (standard
  1411. // base64 encoding). Format used for returning key, which includes
  1412. // public key as well as certificate chain (not private key).
  1413. Pem string `json:"pem,omitempty"`
  1414. // Pkcs12: PKCS#12 format containing a single private/public key pair
  1415. // and certificate chain. This format is only accepted from client for
  1416. // creating a new SmimeInfo and is never returned, because the private
  1417. // key is not intended to be exported. PKCS#12 may be encrypted, in
  1418. // which case encryptedKeyPassword should be set appropriately.
  1419. Pkcs12 string `json:"pkcs12,omitempty"`
  1420. // ServerResponse contains the HTTP response code and headers from the
  1421. // server.
  1422. googleapi.ServerResponse `json:"-"`
  1423. // ForceSendFields is a list of field names (e.g.
  1424. // "EncryptedKeyPassword") to unconditionally include in API requests.
  1425. // By default, fields with empty values are omitted from API requests.
  1426. // However, any non-pointer, non-interface field appearing in
  1427. // ForceSendFields will be sent to the server regardless of whether the
  1428. // field is empty or not. This may be used to include empty fields in
  1429. // Patch requests.
  1430. ForceSendFields []string `json:"-"`
  1431. // NullFields is a list of field names (e.g. "EncryptedKeyPassword") to
  1432. // include in API requests with the JSON null value. By default, fields
  1433. // with empty values are omitted from API requests. However, any field
  1434. // with an empty value appearing in NullFields will be sent to the
  1435. // server as null. It is an error if a field in this list has a
  1436. // non-empty value. This may be used to include null fields in Patch
  1437. // requests.
  1438. NullFields []string `json:"-"`
  1439. }
  1440. func (s *SmimeInfo) MarshalJSON() ([]byte, error) {
  1441. type NoMethod SmimeInfo
  1442. raw := NoMethod(*s)
  1443. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1444. }
  1445. // SmtpMsa: Configuration for communication with an SMTP service.
  1446. type SmtpMsa struct {
  1447. // Host: The hostname of the SMTP service. Required.
  1448. Host string `json:"host,omitempty"`
  1449. // Password: The password that will be used for authentication with the
  1450. // SMTP service. This is a write-only field that can be specified in
  1451. // requests to create or update SendAs settings; it is never populated
  1452. // in responses.
  1453. Password string `json:"password,omitempty"`
  1454. // Port: The port of the SMTP service. Required.
  1455. Port int64 `json:"port,omitempty"`
  1456. // SecurityMode: The protocol that will be used to secure communication
  1457. // with the SMTP service. Required.
  1458. //
  1459. // Possible values:
  1460. // "none"
  1461. // "securityModeUnspecified"
  1462. // "ssl"
  1463. // "starttls"
  1464. SecurityMode string `json:"securityMode,omitempty"`
  1465. // Username: The username that will be used for authentication with the
  1466. // SMTP service. This is a write-only field that can be specified in
  1467. // requests to create or update SendAs settings; it is never populated
  1468. // in responses.
  1469. Username string `json:"username,omitempty"`
  1470. // ForceSendFields is a list of field names (e.g. "Host") to
  1471. // unconditionally include in API requests. By default, fields with
  1472. // empty values are omitted from API requests. However, any non-pointer,
  1473. // non-interface field appearing in ForceSendFields will be sent to the
  1474. // server regardless of whether the field is empty or not. This may be
  1475. // used to include empty fields in Patch requests.
  1476. ForceSendFields []string `json:"-"`
  1477. // NullFields is a list of field names (e.g. "Host") to include in API
  1478. // requests with the JSON null value. By default, fields with empty
  1479. // values are omitted from API requests. However, any field with an
  1480. // empty value appearing in NullFields will be sent to the server as
  1481. // null. It is an error if a field in this list has a non-empty value.
  1482. // This may be used to include null fields in Patch requests.
  1483. NullFields []string `json:"-"`
  1484. }
  1485. func (s *SmtpMsa) MarshalJSON() ([]byte, error) {
  1486. type NoMethod SmtpMsa
  1487. raw := NoMethod(*s)
  1488. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1489. }
  1490. // Thread: A collection of messages representing a conversation.
  1491. type Thread struct {
  1492. // HistoryId: The ID of the last history record that modified this
  1493. // thread.
  1494. HistoryId uint64 `json:"historyId,omitempty,string"`
  1495. // Id: The unique ID of the thread.
  1496. Id string `json:"id,omitempty"`
  1497. // Messages: The list of messages in the thread.
  1498. Messages []*Message `json:"messages,omitempty"`
  1499. // Snippet: A short part of the message text.
  1500. Snippet string `json:"snippet,omitempty"`
  1501. // ServerResponse contains the HTTP response code and headers from the
  1502. // server.
  1503. googleapi.ServerResponse `json:"-"`
  1504. // ForceSendFields is a list of field names (e.g. "HistoryId") to
  1505. // unconditionally include in API requests. By default, fields with
  1506. // empty values are omitted from API requests. However, any non-pointer,
  1507. // non-interface field appearing in ForceSendFields will be sent to the
  1508. // server regardless of whether the field is empty or not. This may be
  1509. // used to include empty fields in Patch requests.
  1510. ForceSendFields []string `json:"-"`
  1511. // NullFields is a list of field names (e.g. "HistoryId") to include in
  1512. // API requests with the JSON null value. By default, fields with empty
  1513. // values are omitted from API requests. However, any field with an
  1514. // empty value appearing in NullFields will be sent to the server as
  1515. // null. It is an error if a field in this list has a non-empty value.
  1516. // This may be used to include null fields in Patch requests.
  1517. NullFields []string `json:"-"`
  1518. }
  1519. func (s *Thread) MarshalJSON() ([]byte, error) {
  1520. type NoMethod Thread
  1521. raw := NoMethod(*s)
  1522. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1523. }
  1524. // VacationSettings: Vacation auto-reply settings for an account. These
  1525. // settings correspond to the "Vacation responder" feature in the web
  1526. // interface.
  1527. type VacationSettings struct {
  1528. // EnableAutoReply: Flag that controls whether Gmail automatically
  1529. // replies to messages.
  1530. EnableAutoReply bool `json:"enableAutoReply,omitempty"`
  1531. // EndTime: An optional end time for sending auto-replies (epoch ms).
  1532. // When this is specified, Gmail will automatically reply only to
  1533. // messages that it receives before the end time. If both startTime and
  1534. // endTime are specified, startTime must precede endTime.
  1535. EndTime int64 `json:"endTime,omitempty,string"`
  1536. // ResponseBodyHtml: Response body in HTML format. Gmail will sanitize
  1537. // the HTML before storing it.
  1538. ResponseBodyHtml string `json:"responseBodyHtml,omitempty"`
  1539. // ResponseBodyPlainText: Response body in plain text format.
  1540. ResponseBodyPlainText string `json:"responseBodyPlainText,omitempty"`
  1541. // ResponseSubject: Optional text to prepend to the subject line in
  1542. // vacation responses. In order to enable auto-replies, either the
  1543. // response subject or the response body must be nonempty.
  1544. ResponseSubject string `json:"responseSubject,omitempty"`
  1545. // RestrictToContacts: Flag that determines whether responses are sent
  1546. // to recipients who are not in the user's list of contacts.
  1547. RestrictToContacts bool `json:"restrictToContacts,omitempty"`
  1548. // RestrictToDomain: Flag that determines whether responses are sent to
  1549. // recipients who are outside of the user's domain. This feature is only
  1550. // available for G Suite users.
  1551. RestrictToDomain bool `json:"restrictToDomain,omitempty"`
  1552. // StartTime: An optional start time for sending auto-replies (epoch
  1553. // ms). When this is specified, Gmail will automatically reply only to
  1554. // messages that it receives after the start time. If both startTime and
  1555. // endTime are specified, startTime must precede endTime.
  1556. StartTime int64 `json:"startTime,omitempty,string"`
  1557. // ServerResponse contains the HTTP response code and headers from the
  1558. // server.
  1559. googleapi.ServerResponse `json:"-"`
  1560. // ForceSendFields is a list of field names (e.g. "EnableAutoReply") to
  1561. // unconditionally include in API requests. By default, fields with
  1562. // empty values are omitted from API requests. However, any non-pointer,
  1563. // non-interface field appearing in ForceSendFields will be sent to the
  1564. // server regardless of whether the field is empty or not. This may be
  1565. // used to include empty fields in Patch requests.
  1566. ForceSendFields []string `json:"-"`
  1567. // NullFields is a list of field names (e.g. "EnableAutoReply") to
  1568. // include in API requests with the JSON null value. By default, fields
  1569. // with empty values are omitted from API requests. However, any field
  1570. // with an empty value appearing in NullFields will be sent to the
  1571. // server as null. It is an error if a field in this list has a
  1572. // non-empty value. This may be used to include null fields in Patch
  1573. // requests.
  1574. NullFields []string `json:"-"`
  1575. }
  1576. func (s *VacationSettings) MarshalJSON() ([]byte, error) {
  1577. type NoMethod VacationSettings
  1578. raw := NoMethod(*s)
  1579. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1580. }
  1581. // WatchRequest: Set up or update a new push notification watch on this
  1582. // user's mailbox.
  1583. type WatchRequest struct {
  1584. // LabelFilterAction: Filtering behavior of labelIds list specified.
  1585. //
  1586. // Possible values:
  1587. // "exclude"
  1588. // "include"
  1589. LabelFilterAction string `json:"labelFilterAction,omitempty"`
  1590. // LabelIds: List of label_ids to restrict notifications about. By
  1591. // default, if unspecified, all changes are pushed out. If specified
  1592. // then dictates which labels are required for a push notification to be
  1593. // generated.
  1594. LabelIds []string `json:"labelIds,omitempty"`
  1595. // TopicName: A fully qualified Google Cloud Pub/Sub API topic name to
  1596. // publish the events to. This topic name **must** already exist in
  1597. // Cloud Pub/Sub and you **must** have already granted gmail "publish"
  1598. // permission on it. For example,
  1599. // "projects/my-project-identifier/topics/my-topic-name" (using the
  1600. // Cloud Pub/Sub "v1" topic naming format).
  1601. //
  1602. // Note that the "my-project-identifier" portion must exactly match your
  1603. // Google developer project id (the one executing this watch request).
  1604. TopicName string `json:"topicName,omitempty"`
  1605. // ForceSendFields is a list of field names (e.g. "LabelFilterAction")
  1606. // to unconditionally include in API requests. By default, fields with
  1607. // empty values are omitted from API requests. However, any non-pointer,
  1608. // non-interface field appearing in ForceSendFields will be sent to the
  1609. // server regardless of whether the field is empty or not. This may be
  1610. // used to include empty fields in Patch requests.
  1611. ForceSendFields []string `json:"-"`
  1612. // NullFields is a list of field names (e.g. "LabelFilterAction") to
  1613. // include in API requests with the JSON null value. By default, fields
  1614. // with empty values are omitted from API requests. However, any field
  1615. // with an empty value appearing in NullFields will be sent to the
  1616. // server as null. It is an error if a field in this list has a
  1617. // non-empty value. This may be used to include null fields in Patch
  1618. // requests.
  1619. NullFields []string `json:"-"`
  1620. }
  1621. func (s *WatchRequest) MarshalJSON() ([]byte, error) {
  1622. type NoMethod WatchRequest
  1623. raw := NoMethod(*s)
  1624. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1625. }
  1626. // WatchResponse: Push notification watch response.
  1627. type WatchResponse struct {
  1628. // Expiration: When Gmail will stop sending notifications for mailbox
  1629. // updates (epoch millis). Call watch again before this time to renew
  1630. // the watch.
  1631. Expiration int64 `json:"expiration,omitempty,string"`
  1632. // HistoryId: The ID of the mailbox's current history record.
  1633. HistoryId uint64 `json:"historyId,omitempty,string"`
  1634. // ServerResponse contains the HTTP response code and headers from the
  1635. // server.
  1636. googleapi.ServerResponse `json:"-"`
  1637. // ForceSendFields is a list of field names (e.g. "Expiration") to
  1638. // unconditionally include in API requests. By default, fields with
  1639. // empty values are omitted from API requests. However, any non-pointer,
  1640. // non-interface field appearing in ForceSendFields will be sent to the
  1641. // server regardless of whether the field is empty or not. This may be
  1642. // used to include empty fields in Patch requests.
  1643. ForceSendFields []string `json:"-"`
  1644. // NullFields is a list of field names (e.g. "Expiration") to include in
  1645. // API requests with the JSON null value. By default, fields with empty
  1646. // values are omitted from API requests. However, any field with an
  1647. // empty value appearing in NullFields will be sent to the server as
  1648. // null. It is an error if a field in this list has a non-empty value.
  1649. // This may be used to include null fields in Patch requests.
  1650. NullFields []string `json:"-"`
  1651. }
  1652. func (s *WatchResponse) MarshalJSON() ([]byte, error) {
  1653. type NoMethod WatchResponse
  1654. raw := NoMethod(*s)
  1655. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1656. }
  1657. // method id "gmail.users.getProfile":
  1658. type UsersGetProfileCall struct {
  1659. s *Service
  1660. userId string
  1661. urlParams_ gensupport.URLParams
  1662. ifNoneMatch_ string
  1663. ctx_ context.Context
  1664. header_ http.Header
  1665. }
  1666. // GetProfile: Gets the current user's Gmail profile.
  1667. func (r *UsersService) GetProfile(userId string) *UsersGetProfileCall {
  1668. c := &UsersGetProfileCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1669. c.userId = userId
  1670. return c
  1671. }
  1672. // Fields allows partial responses to be retrieved. See
  1673. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1674. // for more information.
  1675. func (c *UsersGetProfileCall) Fields(s ...googleapi.Field) *UsersGetProfileCall {
  1676. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1677. return c
  1678. }
  1679. // IfNoneMatch sets the optional parameter which makes the operation
  1680. // fail if the object's ETag matches the given value. This is useful for
  1681. // getting updates only after the object has changed since the last
  1682. // request. Use googleapi.IsNotModified to check whether the response
  1683. // error from Do is the result of In-None-Match.
  1684. func (c *UsersGetProfileCall) IfNoneMatch(entityTag string) *UsersGetProfileCall {
  1685. c.ifNoneMatch_ = entityTag
  1686. return c
  1687. }
  1688. // Context sets the context to be used in this call's Do method. Any
  1689. // pending HTTP request will be aborted if the provided context is
  1690. // canceled.
  1691. func (c *UsersGetProfileCall) Context(ctx context.Context) *UsersGetProfileCall {
  1692. c.ctx_ = ctx
  1693. return c
  1694. }
  1695. // Header returns an http.Header that can be modified by the caller to
  1696. // add HTTP headers to the request.
  1697. func (c *UsersGetProfileCall) Header() http.Header {
  1698. if c.header_ == nil {
  1699. c.header_ = make(http.Header)
  1700. }
  1701. return c.header_
  1702. }
  1703. func (c *UsersGetProfileCall) doRequest(alt string) (*http.Response, error) {
  1704. reqHeaders := make(http.Header)
  1705. for k, v := range c.header_ {
  1706. reqHeaders[k] = v
  1707. }
  1708. reqHeaders.Set("User-Agent", c.s.userAgent())
  1709. if c.ifNoneMatch_ != "" {
  1710. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1711. }
  1712. var body io.Reader = nil
  1713. c.urlParams_.Set("alt", alt)
  1714. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/profile")
  1715. urls += "?" + c.urlParams_.Encode()
  1716. req, _ := http.NewRequest("GET", urls, body)
  1717. req.Header = reqHeaders
  1718. googleapi.Expand(req.URL, map[string]string{
  1719. "userId": c.userId,
  1720. })
  1721. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1722. }
  1723. // Do executes the "gmail.users.getProfile" call.
  1724. // Exactly one of *Profile or error will be non-nil. Any non-2xx status
  1725. // code is an error. Response headers are in either
  1726. // *Profile.ServerResponse.Header or (if a response was returned at all)
  1727. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1728. // check whether the returned error was because http.StatusNotModified
  1729. // was returned.
  1730. func (c *UsersGetProfileCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
  1731. gensupport.SetOptions(c.urlParams_, opts...)
  1732. res, err := c.doRequest("json")
  1733. if res != nil && res.StatusCode == http.StatusNotModified {
  1734. if res.Body != nil {
  1735. res.Body.Close()
  1736. }
  1737. return nil, &googleapi.Error{
  1738. Code: res.StatusCode,
  1739. Header: res.Header,
  1740. }
  1741. }
  1742. if err != nil {
  1743. return nil, err
  1744. }
  1745. defer googleapi.CloseBody(res)
  1746. if err := googleapi.CheckResponse(res); err != nil {
  1747. return nil, err
  1748. }
  1749. ret := &Profile{
  1750. ServerResponse: googleapi.ServerResponse{
  1751. Header: res.Header,
  1752. HTTPStatusCode: res.StatusCode,
  1753. },
  1754. }
  1755. target := &ret
  1756. if err := gensupport.DecodeResponse(target, res); err != nil {
  1757. return nil, err
  1758. }
  1759. return ret, nil
  1760. // {
  1761. // "description": "Gets the current user's Gmail profile.",
  1762. // "httpMethod": "GET",
  1763. // "id": "gmail.users.getProfile",
  1764. // "parameterOrder": [
  1765. // "userId"
  1766. // ],
  1767. // "parameters": {
  1768. // "userId": {
  1769. // "default": "me",
  1770. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1771. // "location": "path",
  1772. // "required": true,
  1773. // "type": "string"
  1774. // }
  1775. // },
  1776. // "path": "{userId}/profile",
  1777. // "response": {
  1778. // "$ref": "Profile"
  1779. // },
  1780. // "scopes": [
  1781. // "https://mail.google.com/",
  1782. // "https://www.googleapis.com/auth/gmail.compose",
  1783. // "https://www.googleapis.com/auth/gmail.metadata",
  1784. // "https://www.googleapis.com/auth/gmail.modify",
  1785. // "https://www.googleapis.com/auth/gmail.readonly"
  1786. // ]
  1787. // }
  1788. }
  1789. // method id "gmail.users.stop":
  1790. type UsersStopCall struct {
  1791. s *Service
  1792. userId string
  1793. urlParams_ gensupport.URLParams
  1794. ctx_ context.Context
  1795. header_ http.Header
  1796. }
  1797. // Stop: Stop receiving push notifications for the given user mailbox.
  1798. func (r *UsersService) Stop(userId string) *UsersStopCall {
  1799. c := &UsersStopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1800. c.userId = userId
  1801. return c
  1802. }
  1803. // Fields allows partial responses to be retrieved. See
  1804. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1805. // for more information.
  1806. func (c *UsersStopCall) Fields(s ...googleapi.Field) *UsersStopCall {
  1807. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1808. return c
  1809. }
  1810. // Context sets the context to be used in this call's Do method. Any
  1811. // pending HTTP request will be aborted if the provided context is
  1812. // canceled.
  1813. func (c *UsersStopCall) Context(ctx context.Context) *UsersStopCall {
  1814. c.ctx_ = ctx
  1815. return c
  1816. }
  1817. // Header returns an http.Header that can be modified by the caller to
  1818. // add HTTP headers to the request.
  1819. func (c *UsersStopCall) Header() http.Header {
  1820. if c.header_ == nil {
  1821. c.header_ = make(http.Header)
  1822. }
  1823. return c.header_
  1824. }
  1825. func (c *UsersStopCall) doRequest(alt string) (*http.Response, error) {
  1826. reqHeaders := make(http.Header)
  1827. for k, v := range c.header_ {
  1828. reqHeaders[k] = v
  1829. }
  1830. reqHeaders.Set("User-Agent", c.s.userAgent())
  1831. var body io.Reader = nil
  1832. c.urlParams_.Set("alt", alt)
  1833. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/stop")
  1834. urls += "?" + c.urlParams_.Encode()
  1835. req, _ := http.NewRequest("POST", urls, body)
  1836. req.Header = reqHeaders
  1837. googleapi.Expand(req.URL, map[string]string{
  1838. "userId": c.userId,
  1839. })
  1840. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1841. }
  1842. // Do executes the "gmail.users.stop" call.
  1843. func (c *UsersStopCall) Do(opts ...googleapi.CallOption) error {
  1844. gensupport.SetOptions(c.urlParams_, opts...)
  1845. res, err := c.doRequest("json")
  1846. if err != nil {
  1847. return err
  1848. }
  1849. defer googleapi.CloseBody(res)
  1850. if err := googleapi.CheckResponse(res); err != nil {
  1851. return err
  1852. }
  1853. return nil
  1854. // {
  1855. // "description": "Stop receiving push notifications for the given user mailbox.",
  1856. // "httpMethod": "POST",
  1857. // "id": "gmail.users.stop",
  1858. // "parameterOrder": [
  1859. // "userId"
  1860. // ],
  1861. // "parameters": {
  1862. // "userId": {
  1863. // "default": "me",
  1864. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1865. // "location": "path",
  1866. // "required": true,
  1867. // "type": "string"
  1868. // }
  1869. // },
  1870. // "path": "{userId}/stop",
  1871. // "scopes": [
  1872. // "https://mail.google.com/",
  1873. // "https://www.googleapis.com/auth/gmail.metadata",
  1874. // "https://www.googleapis.com/auth/gmail.modify",
  1875. // "https://www.googleapis.com/auth/gmail.readonly"
  1876. // ]
  1877. // }
  1878. }
  1879. // method id "gmail.users.watch":
  1880. type UsersWatchCall struct {
  1881. s *Service
  1882. userId string
  1883. watchrequest *WatchRequest
  1884. urlParams_ gensupport.URLParams
  1885. ctx_ context.Context
  1886. header_ http.Header
  1887. }
  1888. // Watch: Set up or update a push notification watch on the given user
  1889. // mailbox.
  1890. func (r *UsersService) Watch(userId string, watchrequest *WatchRequest) *UsersWatchCall {
  1891. c := &UsersWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1892. c.userId = userId
  1893. c.watchrequest = watchrequest
  1894. return c
  1895. }
  1896. // Fields allows partial responses to be retrieved. See
  1897. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1898. // for more information.
  1899. func (c *UsersWatchCall) Fields(s ...googleapi.Field) *UsersWatchCall {
  1900. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1901. return c
  1902. }
  1903. // Context sets the context to be used in this call's Do method. Any
  1904. // pending HTTP request will be aborted if the provided context is
  1905. // canceled.
  1906. func (c *UsersWatchCall) Context(ctx context.Context) *UsersWatchCall {
  1907. c.ctx_ = ctx
  1908. return c
  1909. }
  1910. // Header returns an http.Header that can be modified by the caller to
  1911. // add HTTP headers to the request.
  1912. func (c *UsersWatchCall) Header() http.Header {
  1913. if c.header_ == nil {
  1914. c.header_ = make(http.Header)
  1915. }
  1916. return c.header_
  1917. }
  1918. func (c *UsersWatchCall) doRequest(alt string) (*http.Response, error) {
  1919. reqHeaders := make(http.Header)
  1920. for k, v := range c.header_ {
  1921. reqHeaders[k] = v
  1922. }
  1923. reqHeaders.Set("User-Agent", c.s.userAgent())
  1924. var body io.Reader = nil
  1925. body, err := googleapi.WithoutDataWrapper.JSONReader(c.watchrequest)
  1926. if err != nil {
  1927. return nil, err
  1928. }
  1929. reqHeaders.Set("Content-Type", "application/json")
  1930. c.urlParams_.Set("alt", alt)
  1931. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/watch")
  1932. urls += "?" + c.urlParams_.Encode()
  1933. req, _ := http.NewRequest("POST", urls, body)
  1934. req.Header = reqHeaders
  1935. googleapi.Expand(req.URL, map[string]string{
  1936. "userId": c.userId,
  1937. })
  1938. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1939. }
  1940. // Do executes the "gmail.users.watch" call.
  1941. // Exactly one of *WatchResponse or error will be non-nil. Any non-2xx
  1942. // status code is an error. Response headers are in either
  1943. // *WatchResponse.ServerResponse.Header or (if a response was returned
  1944. // at all) in error.(*googleapi.Error).Header. Use
  1945. // googleapi.IsNotModified to check whether the returned error was
  1946. // because http.StatusNotModified was returned.
  1947. func (c *UsersWatchCall) Do(opts ...googleapi.CallOption) (*WatchResponse, error) {
  1948. gensupport.SetOptions(c.urlParams_, opts...)
  1949. res, err := c.doRequest("json")
  1950. if res != nil && res.StatusCode == http.StatusNotModified {
  1951. if res.Body != nil {
  1952. res.Body.Close()
  1953. }
  1954. return nil, &googleapi.Error{
  1955. Code: res.StatusCode,
  1956. Header: res.Header,
  1957. }
  1958. }
  1959. if err != nil {
  1960. return nil, err
  1961. }
  1962. defer googleapi.CloseBody(res)
  1963. if err := googleapi.CheckResponse(res); err != nil {
  1964. return nil, err
  1965. }
  1966. ret := &WatchResponse{
  1967. ServerResponse: googleapi.ServerResponse{
  1968. Header: res.Header,
  1969. HTTPStatusCode: res.StatusCode,
  1970. },
  1971. }
  1972. target := &ret
  1973. if err := gensupport.DecodeResponse(target, res); err != nil {
  1974. return nil, err
  1975. }
  1976. return ret, nil
  1977. // {
  1978. // "description": "Set up or update a push notification watch on the given user mailbox.",
  1979. // "httpMethod": "POST",
  1980. // "id": "gmail.users.watch",
  1981. // "parameterOrder": [
  1982. // "userId"
  1983. // ],
  1984. // "parameters": {
  1985. // "userId": {
  1986. // "default": "me",
  1987. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1988. // "location": "path",
  1989. // "required": true,
  1990. // "type": "string"
  1991. // }
  1992. // },
  1993. // "path": "{userId}/watch",
  1994. // "request": {
  1995. // "$ref": "WatchRequest"
  1996. // },
  1997. // "response": {
  1998. // "$ref": "WatchResponse"
  1999. // },
  2000. // "scopes": [
  2001. // "https://mail.google.com/",
  2002. // "https://www.googleapis.com/auth/gmail.metadata",
  2003. // "https://www.googleapis.com/auth/gmail.modify",
  2004. // "https://www.googleapis.com/auth/gmail.readonly"
  2005. // ]
  2006. // }
  2007. }
  2008. // method id "gmail.users.drafts.create":
  2009. type UsersDraftsCreateCall struct {
  2010. s *Service
  2011. userId string
  2012. draft *Draft
  2013. urlParams_ gensupport.URLParams
  2014. mediaInfo_ *gensupport.MediaInfo
  2015. ctx_ context.Context
  2016. header_ http.Header
  2017. }
  2018. // Create: Creates a new draft with the DRAFT label.
  2019. func (r *UsersDraftsService) Create(userId string, draft *Draft) *UsersDraftsCreateCall {
  2020. c := &UsersDraftsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2021. c.userId = userId
  2022. c.draft = draft
  2023. return c
  2024. }
  2025. // Media specifies the media to upload in one or more chunks. The chunk
  2026. // size may be controlled by supplying a MediaOption generated by
  2027. // googleapi.ChunkSize. The chunk size defaults to
  2028. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  2029. // upload request will be determined by sniffing the contents of r,
  2030. // unless a MediaOption generated by googleapi.ContentType is
  2031. // supplied.
  2032. // At most one of Media and ResumableMedia may be set.
  2033. func (c *UsersDraftsCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsCreateCall {
  2034. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  2035. return c
  2036. }
  2037. // ResumableMedia specifies the media to upload in chunks and can be
  2038. // canceled with ctx.
  2039. //
  2040. // Deprecated: use Media instead.
  2041. //
  2042. // At most one of Media and ResumableMedia may be set. mediaType
  2043. // identifies the MIME media type of the upload, such as "image/png". If
  2044. // mediaType is "", it will be auto-detected. The provided ctx will
  2045. // supersede any context previously provided to the Context method.
  2046. func (c *UsersDraftsCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsCreateCall {
  2047. c.ctx_ = ctx
  2048. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  2049. return c
  2050. }
  2051. // ProgressUpdater provides a callback function that will be called
  2052. // after every chunk. It should be a low-latency function in order to
  2053. // not slow down the upload operation. This should only be called when
  2054. // using ResumableMedia (as opposed to Media).
  2055. func (c *UsersDraftsCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsCreateCall {
  2056. c.mediaInfo_.SetProgressUpdater(pu)
  2057. return c
  2058. }
  2059. // Fields allows partial responses to be retrieved. See
  2060. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2061. // for more information.
  2062. func (c *UsersDraftsCreateCall) Fields(s ...googleapi.Field) *UsersDraftsCreateCall {
  2063. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2064. return c
  2065. }
  2066. // Context sets the context to be used in this call's Do method. Any
  2067. // pending HTTP request will be aborted if the provided context is
  2068. // canceled.
  2069. // This context will supersede any context previously provided to the
  2070. // ResumableMedia method.
  2071. func (c *UsersDraftsCreateCall) Context(ctx context.Context) *UsersDraftsCreateCall {
  2072. c.ctx_ = ctx
  2073. return c
  2074. }
  2075. // Header returns an http.Header that can be modified by the caller to
  2076. // add HTTP headers to the request.
  2077. func (c *UsersDraftsCreateCall) Header() http.Header {
  2078. if c.header_ == nil {
  2079. c.header_ = make(http.Header)
  2080. }
  2081. return c.header_
  2082. }
  2083. func (c *UsersDraftsCreateCall) doRequest(alt string) (*http.Response, error) {
  2084. reqHeaders := make(http.Header)
  2085. for k, v := range c.header_ {
  2086. reqHeaders[k] = v
  2087. }
  2088. reqHeaders.Set("User-Agent", c.s.userAgent())
  2089. var body io.Reader = nil
  2090. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  2091. if err != nil {
  2092. return nil, err
  2093. }
  2094. reqHeaders.Set("Content-Type", "application/json")
  2095. c.urlParams_.Set("alt", alt)
  2096. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
  2097. if c.mediaInfo_ != nil {
  2098. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  2099. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  2100. }
  2101. if body == nil {
  2102. body = new(bytes.Buffer)
  2103. reqHeaders.Set("Content-Type", "application/json")
  2104. }
  2105. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  2106. defer cleanup()
  2107. urls += "?" + c.urlParams_.Encode()
  2108. req, _ := http.NewRequest("POST", urls, body)
  2109. req.Header = reqHeaders
  2110. gensupport.SetGetBody(req, getBody)
  2111. googleapi.Expand(req.URL, map[string]string{
  2112. "userId": c.userId,
  2113. })
  2114. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2115. }
  2116. // Do executes the "gmail.users.drafts.create" call.
  2117. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  2118. // code is an error. Response headers are in either
  2119. // *Draft.ServerResponse.Header or (if a response was returned at all)
  2120. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2121. // check whether the returned error was because http.StatusNotModified
  2122. // was returned.
  2123. func (c *UsersDraftsCreateCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  2124. gensupport.SetOptions(c.urlParams_, opts...)
  2125. res, err := c.doRequest("json")
  2126. if res != nil && res.StatusCode == http.StatusNotModified {
  2127. if res.Body != nil {
  2128. res.Body.Close()
  2129. }
  2130. return nil, &googleapi.Error{
  2131. Code: res.StatusCode,
  2132. Header: res.Header,
  2133. }
  2134. }
  2135. if err != nil {
  2136. return nil, err
  2137. }
  2138. defer googleapi.CloseBody(res)
  2139. if err := googleapi.CheckResponse(res); err != nil {
  2140. return nil, err
  2141. }
  2142. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  2143. if rx != nil {
  2144. rx.Client = c.s.client
  2145. rx.UserAgent = c.s.userAgent()
  2146. ctx := c.ctx_
  2147. if ctx == nil {
  2148. ctx = context.TODO()
  2149. }
  2150. res, err = rx.Upload(ctx)
  2151. if err != nil {
  2152. return nil, err
  2153. }
  2154. defer res.Body.Close()
  2155. if err := googleapi.CheckResponse(res); err != nil {
  2156. return nil, err
  2157. }
  2158. }
  2159. ret := &Draft{
  2160. ServerResponse: googleapi.ServerResponse{
  2161. Header: res.Header,
  2162. HTTPStatusCode: res.StatusCode,
  2163. },
  2164. }
  2165. target := &ret
  2166. if err := gensupport.DecodeResponse(target, res); err != nil {
  2167. return nil, err
  2168. }
  2169. return ret, nil
  2170. // {
  2171. // "description": "Creates a new draft with the DRAFT label.",
  2172. // "httpMethod": "POST",
  2173. // "id": "gmail.users.drafts.create",
  2174. // "mediaUpload": {
  2175. // "accept": [
  2176. // "message/rfc822"
  2177. // ],
  2178. // "maxSize": "35MB",
  2179. // "protocols": {
  2180. // "resumable": {
  2181. // "multipart": true,
  2182. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts"
  2183. // },
  2184. // "simple": {
  2185. // "multipart": true,
  2186. // "path": "/upload/gmail/v1/users/{userId}/drafts"
  2187. // }
  2188. // }
  2189. // },
  2190. // "parameterOrder": [
  2191. // "userId"
  2192. // ],
  2193. // "parameters": {
  2194. // "userId": {
  2195. // "default": "me",
  2196. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2197. // "location": "path",
  2198. // "required": true,
  2199. // "type": "string"
  2200. // }
  2201. // },
  2202. // "path": "{userId}/drafts",
  2203. // "request": {
  2204. // "$ref": "Draft"
  2205. // },
  2206. // "response": {
  2207. // "$ref": "Draft"
  2208. // },
  2209. // "scopes": [
  2210. // "https://mail.google.com/",
  2211. // "https://www.googleapis.com/auth/gmail.compose",
  2212. // "https://www.googleapis.com/auth/gmail.modify"
  2213. // ],
  2214. // "supportsMediaUpload": true
  2215. // }
  2216. }
  2217. // method id "gmail.users.drafts.delete":
  2218. type UsersDraftsDeleteCall struct {
  2219. s *Service
  2220. userId string
  2221. id string
  2222. urlParams_ gensupport.URLParams
  2223. ctx_ context.Context
  2224. header_ http.Header
  2225. }
  2226. // Delete: Immediately and permanently deletes the specified draft. Does
  2227. // not simply trash it.
  2228. func (r *UsersDraftsService) Delete(userId string, id string) *UsersDraftsDeleteCall {
  2229. c := &UsersDraftsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2230. c.userId = userId
  2231. c.id = id
  2232. return c
  2233. }
  2234. // Fields allows partial responses to be retrieved. See
  2235. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2236. // for more information.
  2237. func (c *UsersDraftsDeleteCall) Fields(s ...googleapi.Field) *UsersDraftsDeleteCall {
  2238. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2239. return c
  2240. }
  2241. // Context sets the context to be used in this call's Do method. Any
  2242. // pending HTTP request will be aborted if the provided context is
  2243. // canceled.
  2244. func (c *UsersDraftsDeleteCall) Context(ctx context.Context) *UsersDraftsDeleteCall {
  2245. c.ctx_ = ctx
  2246. return c
  2247. }
  2248. // Header returns an http.Header that can be modified by the caller to
  2249. // add HTTP headers to the request.
  2250. func (c *UsersDraftsDeleteCall) Header() http.Header {
  2251. if c.header_ == nil {
  2252. c.header_ = make(http.Header)
  2253. }
  2254. return c.header_
  2255. }
  2256. func (c *UsersDraftsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2257. reqHeaders := make(http.Header)
  2258. for k, v := range c.header_ {
  2259. reqHeaders[k] = v
  2260. }
  2261. reqHeaders.Set("User-Agent", c.s.userAgent())
  2262. var body io.Reader = nil
  2263. c.urlParams_.Set("alt", alt)
  2264. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  2265. urls += "?" + c.urlParams_.Encode()
  2266. req, _ := http.NewRequest("DELETE", urls, body)
  2267. req.Header = reqHeaders
  2268. googleapi.Expand(req.URL, map[string]string{
  2269. "userId": c.userId,
  2270. "id": c.id,
  2271. })
  2272. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2273. }
  2274. // Do executes the "gmail.users.drafts.delete" call.
  2275. func (c *UsersDraftsDeleteCall) Do(opts ...googleapi.CallOption) error {
  2276. gensupport.SetOptions(c.urlParams_, opts...)
  2277. res, err := c.doRequest("json")
  2278. if err != nil {
  2279. return err
  2280. }
  2281. defer googleapi.CloseBody(res)
  2282. if err := googleapi.CheckResponse(res); err != nil {
  2283. return err
  2284. }
  2285. return nil
  2286. // {
  2287. // "description": "Immediately and permanently deletes the specified draft. Does not simply trash it.",
  2288. // "httpMethod": "DELETE",
  2289. // "id": "gmail.users.drafts.delete",
  2290. // "parameterOrder": [
  2291. // "userId",
  2292. // "id"
  2293. // ],
  2294. // "parameters": {
  2295. // "id": {
  2296. // "description": "The ID of the draft to delete.",
  2297. // "location": "path",
  2298. // "required": true,
  2299. // "type": "string"
  2300. // },
  2301. // "userId": {
  2302. // "default": "me",
  2303. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2304. // "location": "path",
  2305. // "required": true,
  2306. // "type": "string"
  2307. // }
  2308. // },
  2309. // "path": "{userId}/drafts/{id}",
  2310. // "scopes": [
  2311. // "https://mail.google.com/",
  2312. // "https://www.googleapis.com/auth/gmail.compose",
  2313. // "https://www.googleapis.com/auth/gmail.modify"
  2314. // ]
  2315. // }
  2316. }
  2317. // method id "gmail.users.drafts.get":
  2318. type UsersDraftsGetCall struct {
  2319. s *Service
  2320. userId string
  2321. id string
  2322. urlParams_ gensupport.URLParams
  2323. ifNoneMatch_ string
  2324. ctx_ context.Context
  2325. header_ http.Header
  2326. }
  2327. // Get: Gets the specified draft.
  2328. func (r *UsersDraftsService) Get(userId string, id string) *UsersDraftsGetCall {
  2329. c := &UsersDraftsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2330. c.userId = userId
  2331. c.id = id
  2332. return c
  2333. }
  2334. // Format sets the optional parameter "format": The format to return the
  2335. // draft in.
  2336. //
  2337. // Possible values:
  2338. // "full" (default)
  2339. // "metadata"
  2340. // "minimal"
  2341. // "raw"
  2342. func (c *UsersDraftsGetCall) Format(format string) *UsersDraftsGetCall {
  2343. c.urlParams_.Set("format", format)
  2344. return c
  2345. }
  2346. // Fields allows partial responses to be retrieved. See
  2347. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2348. // for more information.
  2349. func (c *UsersDraftsGetCall) Fields(s ...googleapi.Field) *UsersDraftsGetCall {
  2350. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2351. return c
  2352. }
  2353. // IfNoneMatch sets the optional parameter which makes the operation
  2354. // fail if the object's ETag matches the given value. This is useful for
  2355. // getting updates only after the object has changed since the last
  2356. // request. Use googleapi.IsNotModified to check whether the response
  2357. // error from Do is the result of In-None-Match.
  2358. func (c *UsersDraftsGetCall) IfNoneMatch(entityTag string) *UsersDraftsGetCall {
  2359. c.ifNoneMatch_ = entityTag
  2360. return c
  2361. }
  2362. // Context sets the context to be used in this call's Do method. Any
  2363. // pending HTTP request will be aborted if the provided context is
  2364. // canceled.
  2365. func (c *UsersDraftsGetCall) Context(ctx context.Context) *UsersDraftsGetCall {
  2366. c.ctx_ = ctx
  2367. return c
  2368. }
  2369. // Header returns an http.Header that can be modified by the caller to
  2370. // add HTTP headers to the request.
  2371. func (c *UsersDraftsGetCall) Header() http.Header {
  2372. if c.header_ == nil {
  2373. c.header_ = make(http.Header)
  2374. }
  2375. return c.header_
  2376. }
  2377. func (c *UsersDraftsGetCall) doRequest(alt string) (*http.Response, error) {
  2378. reqHeaders := make(http.Header)
  2379. for k, v := range c.header_ {
  2380. reqHeaders[k] = v
  2381. }
  2382. reqHeaders.Set("User-Agent", c.s.userAgent())
  2383. if c.ifNoneMatch_ != "" {
  2384. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2385. }
  2386. var body io.Reader = nil
  2387. c.urlParams_.Set("alt", alt)
  2388. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  2389. urls += "?" + c.urlParams_.Encode()
  2390. req, _ := http.NewRequest("GET", urls, body)
  2391. req.Header = reqHeaders
  2392. googleapi.Expand(req.URL, map[string]string{
  2393. "userId": c.userId,
  2394. "id": c.id,
  2395. })
  2396. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2397. }
  2398. // Do executes the "gmail.users.drafts.get" call.
  2399. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  2400. // code is an error. Response headers are in either
  2401. // *Draft.ServerResponse.Header or (if a response was returned at all)
  2402. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2403. // check whether the returned error was because http.StatusNotModified
  2404. // was returned.
  2405. func (c *UsersDraftsGetCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  2406. gensupport.SetOptions(c.urlParams_, opts...)
  2407. res, err := c.doRequest("json")
  2408. if res != nil && res.StatusCode == http.StatusNotModified {
  2409. if res.Body != nil {
  2410. res.Body.Close()
  2411. }
  2412. return nil, &googleapi.Error{
  2413. Code: res.StatusCode,
  2414. Header: res.Header,
  2415. }
  2416. }
  2417. if err != nil {
  2418. return nil, err
  2419. }
  2420. defer googleapi.CloseBody(res)
  2421. if err := googleapi.CheckResponse(res); err != nil {
  2422. return nil, err
  2423. }
  2424. ret := &Draft{
  2425. ServerResponse: googleapi.ServerResponse{
  2426. Header: res.Header,
  2427. HTTPStatusCode: res.StatusCode,
  2428. },
  2429. }
  2430. target := &ret
  2431. if err := gensupport.DecodeResponse(target, res); err != nil {
  2432. return nil, err
  2433. }
  2434. return ret, nil
  2435. // {
  2436. // "description": "Gets the specified draft.",
  2437. // "httpMethod": "GET",
  2438. // "id": "gmail.users.drafts.get",
  2439. // "parameterOrder": [
  2440. // "userId",
  2441. // "id"
  2442. // ],
  2443. // "parameters": {
  2444. // "format": {
  2445. // "default": "full",
  2446. // "description": "The format to return the draft in.",
  2447. // "enum": [
  2448. // "full",
  2449. // "metadata",
  2450. // "minimal",
  2451. // "raw"
  2452. // ],
  2453. // "enumDescriptions": [
  2454. // "",
  2455. // "",
  2456. // "",
  2457. // ""
  2458. // ],
  2459. // "location": "query",
  2460. // "type": "string"
  2461. // },
  2462. // "id": {
  2463. // "description": "The ID of the draft to retrieve.",
  2464. // "location": "path",
  2465. // "required": true,
  2466. // "type": "string"
  2467. // },
  2468. // "userId": {
  2469. // "default": "me",
  2470. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2471. // "location": "path",
  2472. // "required": true,
  2473. // "type": "string"
  2474. // }
  2475. // },
  2476. // "path": "{userId}/drafts/{id}",
  2477. // "response": {
  2478. // "$ref": "Draft"
  2479. // },
  2480. // "scopes": [
  2481. // "https://mail.google.com/",
  2482. // "https://www.googleapis.com/auth/gmail.compose",
  2483. // "https://www.googleapis.com/auth/gmail.modify",
  2484. // "https://www.googleapis.com/auth/gmail.readonly"
  2485. // ]
  2486. // }
  2487. }
  2488. // method id "gmail.users.drafts.list":
  2489. type UsersDraftsListCall struct {
  2490. s *Service
  2491. userId string
  2492. urlParams_ gensupport.URLParams
  2493. ifNoneMatch_ string
  2494. ctx_ context.Context
  2495. header_ http.Header
  2496. }
  2497. // List: Lists the drafts in the user's mailbox.
  2498. func (r *UsersDraftsService) List(userId string) *UsersDraftsListCall {
  2499. c := &UsersDraftsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2500. c.userId = userId
  2501. return c
  2502. }
  2503. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  2504. // Include drafts from SPAM and TRASH in the results.
  2505. func (c *UsersDraftsListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersDraftsListCall {
  2506. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  2507. return c
  2508. }
  2509. // MaxResults sets the optional parameter "maxResults": Maximum number
  2510. // of drafts to return.
  2511. func (c *UsersDraftsListCall) MaxResults(maxResults int64) *UsersDraftsListCall {
  2512. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  2513. return c
  2514. }
  2515. // PageToken sets the optional parameter "pageToken": Page token to
  2516. // retrieve a specific page of results in the list.
  2517. func (c *UsersDraftsListCall) PageToken(pageToken string) *UsersDraftsListCall {
  2518. c.urlParams_.Set("pageToken", pageToken)
  2519. return c
  2520. }
  2521. // Q sets the optional parameter "q": Only return draft messages
  2522. // matching the specified query. Supports the same query format as the
  2523. // Gmail search box. For example, "from:someuser@example.com
  2524. // rfc822msgid: is:unread".
  2525. func (c *UsersDraftsListCall) Q(q string) *UsersDraftsListCall {
  2526. c.urlParams_.Set("q", q)
  2527. return c
  2528. }
  2529. // Fields allows partial responses to be retrieved. See
  2530. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2531. // for more information.
  2532. func (c *UsersDraftsListCall) Fields(s ...googleapi.Field) *UsersDraftsListCall {
  2533. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2534. return c
  2535. }
  2536. // IfNoneMatch sets the optional parameter which makes the operation
  2537. // fail if the object's ETag matches the given value. This is useful for
  2538. // getting updates only after the object has changed since the last
  2539. // request. Use googleapi.IsNotModified to check whether the response
  2540. // error from Do is the result of In-None-Match.
  2541. func (c *UsersDraftsListCall) IfNoneMatch(entityTag string) *UsersDraftsListCall {
  2542. c.ifNoneMatch_ = entityTag
  2543. return c
  2544. }
  2545. // Context sets the context to be used in this call's Do method. Any
  2546. // pending HTTP request will be aborted if the provided context is
  2547. // canceled.
  2548. func (c *UsersDraftsListCall) Context(ctx context.Context) *UsersDraftsListCall {
  2549. c.ctx_ = ctx
  2550. return c
  2551. }
  2552. // Header returns an http.Header that can be modified by the caller to
  2553. // add HTTP headers to the request.
  2554. func (c *UsersDraftsListCall) Header() http.Header {
  2555. if c.header_ == nil {
  2556. c.header_ = make(http.Header)
  2557. }
  2558. return c.header_
  2559. }
  2560. func (c *UsersDraftsListCall) doRequest(alt string) (*http.Response, error) {
  2561. reqHeaders := make(http.Header)
  2562. for k, v := range c.header_ {
  2563. reqHeaders[k] = v
  2564. }
  2565. reqHeaders.Set("User-Agent", c.s.userAgent())
  2566. if c.ifNoneMatch_ != "" {
  2567. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2568. }
  2569. var body io.Reader = nil
  2570. c.urlParams_.Set("alt", alt)
  2571. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
  2572. urls += "?" + c.urlParams_.Encode()
  2573. req, _ := http.NewRequest("GET", urls, body)
  2574. req.Header = reqHeaders
  2575. googleapi.Expand(req.URL, map[string]string{
  2576. "userId": c.userId,
  2577. })
  2578. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2579. }
  2580. // Do executes the "gmail.users.drafts.list" call.
  2581. // Exactly one of *ListDraftsResponse or error will be non-nil. Any
  2582. // non-2xx status code is an error. Response headers are in either
  2583. // *ListDraftsResponse.ServerResponse.Header or (if a response was
  2584. // returned at all) in error.(*googleapi.Error).Header. Use
  2585. // googleapi.IsNotModified to check whether the returned error was
  2586. // because http.StatusNotModified was returned.
  2587. func (c *UsersDraftsListCall) Do(opts ...googleapi.CallOption) (*ListDraftsResponse, error) {
  2588. gensupport.SetOptions(c.urlParams_, opts...)
  2589. res, err := c.doRequest("json")
  2590. if res != nil && res.StatusCode == http.StatusNotModified {
  2591. if res.Body != nil {
  2592. res.Body.Close()
  2593. }
  2594. return nil, &googleapi.Error{
  2595. Code: res.StatusCode,
  2596. Header: res.Header,
  2597. }
  2598. }
  2599. if err != nil {
  2600. return nil, err
  2601. }
  2602. defer googleapi.CloseBody(res)
  2603. if err := googleapi.CheckResponse(res); err != nil {
  2604. return nil, err
  2605. }
  2606. ret := &ListDraftsResponse{
  2607. ServerResponse: googleapi.ServerResponse{
  2608. Header: res.Header,
  2609. HTTPStatusCode: res.StatusCode,
  2610. },
  2611. }
  2612. target := &ret
  2613. if err := gensupport.DecodeResponse(target, res); err != nil {
  2614. return nil, err
  2615. }
  2616. return ret, nil
  2617. // {
  2618. // "description": "Lists the drafts in the user's mailbox.",
  2619. // "httpMethod": "GET",
  2620. // "id": "gmail.users.drafts.list",
  2621. // "parameterOrder": [
  2622. // "userId"
  2623. // ],
  2624. // "parameters": {
  2625. // "includeSpamTrash": {
  2626. // "default": "false",
  2627. // "description": "Include drafts from SPAM and TRASH in the results.",
  2628. // "location": "query",
  2629. // "type": "boolean"
  2630. // },
  2631. // "maxResults": {
  2632. // "default": "100",
  2633. // "description": "Maximum number of drafts to return.",
  2634. // "format": "uint32",
  2635. // "location": "query",
  2636. // "type": "integer"
  2637. // },
  2638. // "pageToken": {
  2639. // "description": "Page token to retrieve a specific page of results in the list.",
  2640. // "location": "query",
  2641. // "type": "string"
  2642. // },
  2643. // "q": {
  2644. // "description": "Only return draft messages matching the specified query. Supports the same query format as the Gmail search box. For example, \"from:someuser@example.com rfc822msgid: is:unread\".",
  2645. // "location": "query",
  2646. // "type": "string"
  2647. // },
  2648. // "userId": {
  2649. // "default": "me",
  2650. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2651. // "location": "path",
  2652. // "required": true,
  2653. // "type": "string"
  2654. // }
  2655. // },
  2656. // "path": "{userId}/drafts",
  2657. // "response": {
  2658. // "$ref": "ListDraftsResponse"
  2659. // },
  2660. // "scopes": [
  2661. // "https://mail.google.com/",
  2662. // "https://www.googleapis.com/auth/gmail.compose",
  2663. // "https://www.googleapis.com/auth/gmail.modify",
  2664. // "https://www.googleapis.com/auth/gmail.readonly"
  2665. // ]
  2666. // }
  2667. }
  2668. // Pages invokes f for each page of results.
  2669. // A non-nil error returned from f will halt the iteration.
  2670. // The provided context supersedes any context provided to the Context method.
  2671. func (c *UsersDraftsListCall) Pages(ctx context.Context, f func(*ListDraftsResponse) error) error {
  2672. c.ctx_ = ctx
  2673. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2674. for {
  2675. x, err := c.Do()
  2676. if err != nil {
  2677. return err
  2678. }
  2679. if err := f(x); err != nil {
  2680. return err
  2681. }
  2682. if x.NextPageToken == "" {
  2683. return nil
  2684. }
  2685. c.PageToken(x.NextPageToken)
  2686. }
  2687. }
  2688. // method id "gmail.users.drafts.send":
  2689. type UsersDraftsSendCall struct {
  2690. s *Service
  2691. userId string
  2692. draft *Draft
  2693. urlParams_ gensupport.URLParams
  2694. mediaInfo_ *gensupport.MediaInfo
  2695. ctx_ context.Context
  2696. header_ http.Header
  2697. }
  2698. // Send: Sends the specified, existing draft to the recipients in the
  2699. // To, Cc, and Bcc headers.
  2700. func (r *UsersDraftsService) Send(userId string, draft *Draft) *UsersDraftsSendCall {
  2701. c := &UsersDraftsSendCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2702. c.userId = userId
  2703. c.draft = draft
  2704. return c
  2705. }
  2706. // Media specifies the media to upload in one or more chunks. The chunk
  2707. // size may be controlled by supplying a MediaOption generated by
  2708. // googleapi.ChunkSize. The chunk size defaults to
  2709. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  2710. // upload request will be determined by sniffing the contents of r,
  2711. // unless a MediaOption generated by googleapi.ContentType is
  2712. // supplied.
  2713. // At most one of Media and ResumableMedia may be set.
  2714. func (c *UsersDraftsSendCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsSendCall {
  2715. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  2716. return c
  2717. }
  2718. // ResumableMedia specifies the media to upload in chunks and can be
  2719. // canceled with ctx.
  2720. //
  2721. // Deprecated: use Media instead.
  2722. //
  2723. // At most one of Media and ResumableMedia may be set. mediaType
  2724. // identifies the MIME media type of the upload, such as "image/png". If
  2725. // mediaType is "", it will be auto-detected. The provided ctx will
  2726. // supersede any context previously provided to the Context method.
  2727. func (c *UsersDraftsSendCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsSendCall {
  2728. c.ctx_ = ctx
  2729. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  2730. return c
  2731. }
  2732. // ProgressUpdater provides a callback function that will be called
  2733. // after every chunk. It should be a low-latency function in order to
  2734. // not slow down the upload operation. This should only be called when
  2735. // using ResumableMedia (as opposed to Media).
  2736. func (c *UsersDraftsSendCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsSendCall {
  2737. c.mediaInfo_.SetProgressUpdater(pu)
  2738. return c
  2739. }
  2740. // Fields allows partial responses to be retrieved. See
  2741. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2742. // for more information.
  2743. func (c *UsersDraftsSendCall) Fields(s ...googleapi.Field) *UsersDraftsSendCall {
  2744. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2745. return c
  2746. }
  2747. // Context sets the context to be used in this call's Do method. Any
  2748. // pending HTTP request will be aborted if the provided context is
  2749. // canceled.
  2750. // This context will supersede any context previously provided to the
  2751. // ResumableMedia method.
  2752. func (c *UsersDraftsSendCall) Context(ctx context.Context) *UsersDraftsSendCall {
  2753. c.ctx_ = ctx
  2754. return c
  2755. }
  2756. // Header returns an http.Header that can be modified by the caller to
  2757. // add HTTP headers to the request.
  2758. func (c *UsersDraftsSendCall) Header() http.Header {
  2759. if c.header_ == nil {
  2760. c.header_ = make(http.Header)
  2761. }
  2762. return c.header_
  2763. }
  2764. func (c *UsersDraftsSendCall) doRequest(alt string) (*http.Response, error) {
  2765. reqHeaders := make(http.Header)
  2766. for k, v := range c.header_ {
  2767. reqHeaders[k] = v
  2768. }
  2769. reqHeaders.Set("User-Agent", c.s.userAgent())
  2770. var body io.Reader = nil
  2771. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  2772. if err != nil {
  2773. return nil, err
  2774. }
  2775. reqHeaders.Set("Content-Type", "application/json")
  2776. c.urlParams_.Set("alt", alt)
  2777. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/send")
  2778. if c.mediaInfo_ != nil {
  2779. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  2780. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  2781. }
  2782. if body == nil {
  2783. body = new(bytes.Buffer)
  2784. reqHeaders.Set("Content-Type", "application/json")
  2785. }
  2786. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  2787. defer cleanup()
  2788. urls += "?" + c.urlParams_.Encode()
  2789. req, _ := http.NewRequest("POST", urls, body)
  2790. req.Header = reqHeaders
  2791. gensupport.SetGetBody(req, getBody)
  2792. googleapi.Expand(req.URL, map[string]string{
  2793. "userId": c.userId,
  2794. })
  2795. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2796. }
  2797. // Do executes the "gmail.users.drafts.send" call.
  2798. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  2799. // code is an error. Response headers are in either
  2800. // *Message.ServerResponse.Header or (if a response was returned at all)
  2801. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2802. // check whether the returned error was because http.StatusNotModified
  2803. // was returned.
  2804. func (c *UsersDraftsSendCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  2805. gensupport.SetOptions(c.urlParams_, opts...)
  2806. res, err := c.doRequest("json")
  2807. if res != nil && res.StatusCode == http.StatusNotModified {
  2808. if res.Body != nil {
  2809. res.Body.Close()
  2810. }
  2811. return nil, &googleapi.Error{
  2812. Code: res.StatusCode,
  2813. Header: res.Header,
  2814. }
  2815. }
  2816. if err != nil {
  2817. return nil, err
  2818. }
  2819. defer googleapi.CloseBody(res)
  2820. if err := googleapi.CheckResponse(res); err != nil {
  2821. return nil, err
  2822. }
  2823. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  2824. if rx != nil {
  2825. rx.Client = c.s.client
  2826. rx.UserAgent = c.s.userAgent()
  2827. ctx := c.ctx_
  2828. if ctx == nil {
  2829. ctx = context.TODO()
  2830. }
  2831. res, err = rx.Upload(ctx)
  2832. if err != nil {
  2833. return nil, err
  2834. }
  2835. defer res.Body.Close()
  2836. if err := googleapi.CheckResponse(res); err != nil {
  2837. return nil, err
  2838. }
  2839. }
  2840. ret := &Message{
  2841. ServerResponse: googleapi.ServerResponse{
  2842. Header: res.Header,
  2843. HTTPStatusCode: res.StatusCode,
  2844. },
  2845. }
  2846. target := &ret
  2847. if err := gensupport.DecodeResponse(target, res); err != nil {
  2848. return nil, err
  2849. }
  2850. return ret, nil
  2851. // {
  2852. // "description": "Sends the specified, existing draft to the recipients in the To, Cc, and Bcc headers.",
  2853. // "httpMethod": "POST",
  2854. // "id": "gmail.users.drafts.send",
  2855. // "mediaUpload": {
  2856. // "accept": [
  2857. // "message/rfc822"
  2858. // ],
  2859. // "maxSize": "35MB",
  2860. // "protocols": {
  2861. // "resumable": {
  2862. // "multipart": true,
  2863. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/send"
  2864. // },
  2865. // "simple": {
  2866. // "multipart": true,
  2867. // "path": "/upload/gmail/v1/users/{userId}/drafts/send"
  2868. // }
  2869. // }
  2870. // },
  2871. // "parameterOrder": [
  2872. // "userId"
  2873. // ],
  2874. // "parameters": {
  2875. // "userId": {
  2876. // "default": "me",
  2877. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2878. // "location": "path",
  2879. // "required": true,
  2880. // "type": "string"
  2881. // }
  2882. // },
  2883. // "path": "{userId}/drafts/send",
  2884. // "request": {
  2885. // "$ref": "Draft"
  2886. // },
  2887. // "response": {
  2888. // "$ref": "Message"
  2889. // },
  2890. // "scopes": [
  2891. // "https://mail.google.com/",
  2892. // "https://www.googleapis.com/auth/gmail.compose",
  2893. // "https://www.googleapis.com/auth/gmail.modify"
  2894. // ],
  2895. // "supportsMediaUpload": true
  2896. // }
  2897. }
  2898. // method id "gmail.users.drafts.update":
  2899. type UsersDraftsUpdateCall struct {
  2900. s *Service
  2901. userId string
  2902. id string
  2903. draft *Draft
  2904. urlParams_ gensupport.URLParams
  2905. mediaInfo_ *gensupport.MediaInfo
  2906. ctx_ context.Context
  2907. header_ http.Header
  2908. }
  2909. // Update: Replaces a draft's content.
  2910. func (r *UsersDraftsService) Update(userId string, id string, draft *Draft) *UsersDraftsUpdateCall {
  2911. c := &UsersDraftsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2912. c.userId = userId
  2913. c.id = id
  2914. c.draft = draft
  2915. return c
  2916. }
  2917. // Media specifies the media to upload in one or more chunks. The chunk
  2918. // size may be controlled by supplying a MediaOption generated by
  2919. // googleapi.ChunkSize. The chunk size defaults to
  2920. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  2921. // upload request will be determined by sniffing the contents of r,
  2922. // unless a MediaOption generated by googleapi.ContentType is
  2923. // supplied.
  2924. // At most one of Media and ResumableMedia may be set.
  2925. func (c *UsersDraftsUpdateCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsUpdateCall {
  2926. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  2927. return c
  2928. }
  2929. // ResumableMedia specifies the media to upload in chunks and can be
  2930. // canceled with ctx.
  2931. //
  2932. // Deprecated: use Media instead.
  2933. //
  2934. // At most one of Media and ResumableMedia may be set. mediaType
  2935. // identifies the MIME media type of the upload, such as "image/png". If
  2936. // mediaType is "", it will be auto-detected. The provided ctx will
  2937. // supersede any context previously provided to the Context method.
  2938. func (c *UsersDraftsUpdateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsUpdateCall {
  2939. c.ctx_ = ctx
  2940. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  2941. return c
  2942. }
  2943. // ProgressUpdater provides a callback function that will be called
  2944. // after every chunk. It should be a low-latency function in order to
  2945. // not slow down the upload operation. This should only be called when
  2946. // using ResumableMedia (as opposed to Media).
  2947. func (c *UsersDraftsUpdateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsUpdateCall {
  2948. c.mediaInfo_.SetProgressUpdater(pu)
  2949. return c
  2950. }
  2951. // Fields allows partial responses to be retrieved. See
  2952. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2953. // for more information.
  2954. func (c *UsersDraftsUpdateCall) Fields(s ...googleapi.Field) *UsersDraftsUpdateCall {
  2955. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2956. return c
  2957. }
  2958. // Context sets the context to be used in this call's Do method. Any
  2959. // pending HTTP request will be aborted if the provided context is
  2960. // canceled.
  2961. // This context will supersede any context previously provided to the
  2962. // ResumableMedia method.
  2963. func (c *UsersDraftsUpdateCall) Context(ctx context.Context) *UsersDraftsUpdateCall {
  2964. c.ctx_ = ctx
  2965. return c
  2966. }
  2967. // Header returns an http.Header that can be modified by the caller to
  2968. // add HTTP headers to the request.
  2969. func (c *UsersDraftsUpdateCall) Header() http.Header {
  2970. if c.header_ == nil {
  2971. c.header_ = make(http.Header)
  2972. }
  2973. return c.header_
  2974. }
  2975. func (c *UsersDraftsUpdateCall) doRequest(alt string) (*http.Response, error) {
  2976. reqHeaders := make(http.Header)
  2977. for k, v := range c.header_ {
  2978. reqHeaders[k] = v
  2979. }
  2980. reqHeaders.Set("User-Agent", c.s.userAgent())
  2981. var body io.Reader = nil
  2982. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  2983. if err != nil {
  2984. return nil, err
  2985. }
  2986. reqHeaders.Set("Content-Type", "application/json")
  2987. c.urlParams_.Set("alt", alt)
  2988. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  2989. if c.mediaInfo_ != nil {
  2990. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  2991. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  2992. }
  2993. if body == nil {
  2994. body = new(bytes.Buffer)
  2995. reqHeaders.Set("Content-Type", "application/json")
  2996. }
  2997. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  2998. defer cleanup()
  2999. urls += "?" + c.urlParams_.Encode()
  3000. req, _ := http.NewRequest("PUT", urls, body)
  3001. req.Header = reqHeaders
  3002. gensupport.SetGetBody(req, getBody)
  3003. googleapi.Expand(req.URL, map[string]string{
  3004. "userId": c.userId,
  3005. "id": c.id,
  3006. })
  3007. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3008. }
  3009. // Do executes the "gmail.users.drafts.update" call.
  3010. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  3011. // code is an error. Response headers are in either
  3012. // *Draft.ServerResponse.Header or (if a response was returned at all)
  3013. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3014. // check whether the returned error was because http.StatusNotModified
  3015. // was returned.
  3016. func (c *UsersDraftsUpdateCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  3017. gensupport.SetOptions(c.urlParams_, opts...)
  3018. res, err := c.doRequest("json")
  3019. if res != nil && res.StatusCode == http.StatusNotModified {
  3020. if res.Body != nil {
  3021. res.Body.Close()
  3022. }
  3023. return nil, &googleapi.Error{
  3024. Code: res.StatusCode,
  3025. Header: res.Header,
  3026. }
  3027. }
  3028. if err != nil {
  3029. return nil, err
  3030. }
  3031. defer googleapi.CloseBody(res)
  3032. if err := googleapi.CheckResponse(res); err != nil {
  3033. return nil, err
  3034. }
  3035. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  3036. if rx != nil {
  3037. rx.Client = c.s.client
  3038. rx.UserAgent = c.s.userAgent()
  3039. ctx := c.ctx_
  3040. if ctx == nil {
  3041. ctx = context.TODO()
  3042. }
  3043. res, err = rx.Upload(ctx)
  3044. if err != nil {
  3045. return nil, err
  3046. }
  3047. defer res.Body.Close()
  3048. if err := googleapi.CheckResponse(res); err != nil {
  3049. return nil, err
  3050. }
  3051. }
  3052. ret := &Draft{
  3053. ServerResponse: googleapi.ServerResponse{
  3054. Header: res.Header,
  3055. HTTPStatusCode: res.StatusCode,
  3056. },
  3057. }
  3058. target := &ret
  3059. if err := gensupport.DecodeResponse(target, res); err != nil {
  3060. return nil, err
  3061. }
  3062. return ret, nil
  3063. // {
  3064. // "description": "Replaces a draft's content.",
  3065. // "httpMethod": "PUT",
  3066. // "id": "gmail.users.drafts.update",
  3067. // "mediaUpload": {
  3068. // "accept": [
  3069. // "message/rfc822"
  3070. // ],
  3071. // "maxSize": "35MB",
  3072. // "protocols": {
  3073. // "resumable": {
  3074. // "multipart": true,
  3075. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/{id}"
  3076. // },
  3077. // "simple": {
  3078. // "multipart": true,
  3079. // "path": "/upload/gmail/v1/users/{userId}/drafts/{id}"
  3080. // }
  3081. // }
  3082. // },
  3083. // "parameterOrder": [
  3084. // "userId",
  3085. // "id"
  3086. // ],
  3087. // "parameters": {
  3088. // "id": {
  3089. // "description": "The ID of the draft to update.",
  3090. // "location": "path",
  3091. // "required": true,
  3092. // "type": "string"
  3093. // },
  3094. // "userId": {
  3095. // "default": "me",
  3096. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3097. // "location": "path",
  3098. // "required": true,
  3099. // "type": "string"
  3100. // }
  3101. // },
  3102. // "path": "{userId}/drafts/{id}",
  3103. // "request": {
  3104. // "$ref": "Draft"
  3105. // },
  3106. // "response": {
  3107. // "$ref": "Draft"
  3108. // },
  3109. // "scopes": [
  3110. // "https://mail.google.com/",
  3111. // "https://www.googleapis.com/auth/gmail.compose",
  3112. // "https://www.googleapis.com/auth/gmail.modify"
  3113. // ],
  3114. // "supportsMediaUpload": true
  3115. // }
  3116. }
  3117. // method id "gmail.users.history.list":
  3118. type UsersHistoryListCall struct {
  3119. s *Service
  3120. userId string
  3121. urlParams_ gensupport.URLParams
  3122. ifNoneMatch_ string
  3123. ctx_ context.Context
  3124. header_ http.Header
  3125. }
  3126. // List: Lists the history of all changes to the given mailbox. History
  3127. // results are returned in chronological order (increasing historyId).
  3128. func (r *UsersHistoryService) List(userId string) *UsersHistoryListCall {
  3129. c := &UsersHistoryListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3130. c.userId = userId
  3131. return c
  3132. }
  3133. // HistoryTypes sets the optional parameter "historyTypes": History
  3134. // types to be returned by the function
  3135. //
  3136. // Possible values:
  3137. // "labelAdded"
  3138. // "labelRemoved"
  3139. // "messageAdded"
  3140. // "messageDeleted"
  3141. func (c *UsersHistoryListCall) HistoryTypes(historyTypes ...string) *UsersHistoryListCall {
  3142. c.urlParams_.SetMulti("historyTypes", append([]string{}, historyTypes...))
  3143. return c
  3144. }
  3145. // LabelId sets the optional parameter "labelId": Only return messages
  3146. // with a label matching the ID.
  3147. func (c *UsersHistoryListCall) LabelId(labelId string) *UsersHistoryListCall {
  3148. c.urlParams_.Set("labelId", labelId)
  3149. return c
  3150. }
  3151. // MaxResults sets the optional parameter "maxResults": The maximum
  3152. // number of history records to return.
  3153. func (c *UsersHistoryListCall) MaxResults(maxResults int64) *UsersHistoryListCall {
  3154. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  3155. return c
  3156. }
  3157. // PageToken sets the optional parameter "pageToken": Page token to
  3158. // retrieve a specific page of results in the list.
  3159. func (c *UsersHistoryListCall) PageToken(pageToken string) *UsersHistoryListCall {
  3160. c.urlParams_.Set("pageToken", pageToken)
  3161. return c
  3162. }
  3163. // StartHistoryId sets the optional parameter "startHistoryId":
  3164. // Required. Returns history records after the specified startHistoryId.
  3165. // The supplied startHistoryId should be obtained from the historyId of
  3166. // a message, thread, or previous list response. History IDs increase
  3167. // chronologically but are not contiguous with random gaps in between
  3168. // valid IDs. Supplying an invalid or out of date startHistoryId
  3169. // typically returns an HTTP 404 error code. A historyId is typically
  3170. // valid for at least a week, but in some rare circumstances may be
  3171. // valid for only a few hours. If you receive an HTTP 404 error
  3172. // response, your application should perform a full sync. If you receive
  3173. // no nextPageToken in the response, there are no updates to retrieve
  3174. // and you can store the returned historyId for a future request.
  3175. func (c *UsersHistoryListCall) StartHistoryId(startHistoryId uint64) *UsersHistoryListCall {
  3176. c.urlParams_.Set("startHistoryId", fmt.Sprint(startHistoryId))
  3177. return c
  3178. }
  3179. // Fields allows partial responses to be retrieved. See
  3180. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3181. // for more information.
  3182. func (c *UsersHistoryListCall) Fields(s ...googleapi.Field) *UsersHistoryListCall {
  3183. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3184. return c
  3185. }
  3186. // IfNoneMatch sets the optional parameter which makes the operation
  3187. // fail if the object's ETag matches the given value. This is useful for
  3188. // getting updates only after the object has changed since the last
  3189. // request. Use googleapi.IsNotModified to check whether the response
  3190. // error from Do is the result of In-None-Match.
  3191. func (c *UsersHistoryListCall) IfNoneMatch(entityTag string) *UsersHistoryListCall {
  3192. c.ifNoneMatch_ = entityTag
  3193. return c
  3194. }
  3195. // Context sets the context to be used in this call's Do method. Any
  3196. // pending HTTP request will be aborted if the provided context is
  3197. // canceled.
  3198. func (c *UsersHistoryListCall) Context(ctx context.Context) *UsersHistoryListCall {
  3199. c.ctx_ = ctx
  3200. return c
  3201. }
  3202. // Header returns an http.Header that can be modified by the caller to
  3203. // add HTTP headers to the request.
  3204. func (c *UsersHistoryListCall) Header() http.Header {
  3205. if c.header_ == nil {
  3206. c.header_ = make(http.Header)
  3207. }
  3208. return c.header_
  3209. }
  3210. func (c *UsersHistoryListCall) doRequest(alt string) (*http.Response, error) {
  3211. reqHeaders := make(http.Header)
  3212. for k, v := range c.header_ {
  3213. reqHeaders[k] = v
  3214. }
  3215. reqHeaders.Set("User-Agent", c.s.userAgent())
  3216. if c.ifNoneMatch_ != "" {
  3217. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3218. }
  3219. var body io.Reader = nil
  3220. c.urlParams_.Set("alt", alt)
  3221. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/history")
  3222. urls += "?" + c.urlParams_.Encode()
  3223. req, _ := http.NewRequest("GET", urls, body)
  3224. req.Header = reqHeaders
  3225. googleapi.Expand(req.URL, map[string]string{
  3226. "userId": c.userId,
  3227. })
  3228. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3229. }
  3230. // Do executes the "gmail.users.history.list" call.
  3231. // Exactly one of *ListHistoryResponse or error will be non-nil. Any
  3232. // non-2xx status code is an error. Response headers are in either
  3233. // *ListHistoryResponse.ServerResponse.Header or (if a response was
  3234. // returned at all) in error.(*googleapi.Error).Header. Use
  3235. // googleapi.IsNotModified to check whether the returned error was
  3236. // because http.StatusNotModified was returned.
  3237. func (c *UsersHistoryListCall) Do(opts ...googleapi.CallOption) (*ListHistoryResponse, error) {
  3238. gensupport.SetOptions(c.urlParams_, opts...)
  3239. res, err := c.doRequest("json")
  3240. if res != nil && res.StatusCode == http.StatusNotModified {
  3241. if res.Body != nil {
  3242. res.Body.Close()
  3243. }
  3244. return nil, &googleapi.Error{
  3245. Code: res.StatusCode,
  3246. Header: res.Header,
  3247. }
  3248. }
  3249. if err != nil {
  3250. return nil, err
  3251. }
  3252. defer googleapi.CloseBody(res)
  3253. if err := googleapi.CheckResponse(res); err != nil {
  3254. return nil, err
  3255. }
  3256. ret := &ListHistoryResponse{
  3257. ServerResponse: googleapi.ServerResponse{
  3258. Header: res.Header,
  3259. HTTPStatusCode: res.StatusCode,
  3260. },
  3261. }
  3262. target := &ret
  3263. if err := gensupport.DecodeResponse(target, res); err != nil {
  3264. return nil, err
  3265. }
  3266. return ret, nil
  3267. // {
  3268. // "description": "Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId).",
  3269. // "httpMethod": "GET",
  3270. // "id": "gmail.users.history.list",
  3271. // "parameterOrder": [
  3272. // "userId"
  3273. // ],
  3274. // "parameters": {
  3275. // "historyTypes": {
  3276. // "description": "History types to be returned by the function",
  3277. // "enum": [
  3278. // "labelAdded",
  3279. // "labelRemoved",
  3280. // "messageAdded",
  3281. // "messageDeleted"
  3282. // ],
  3283. // "enumDescriptions": [
  3284. // "",
  3285. // "",
  3286. // "",
  3287. // ""
  3288. // ],
  3289. // "location": "query",
  3290. // "repeated": true,
  3291. // "type": "string"
  3292. // },
  3293. // "labelId": {
  3294. // "description": "Only return messages with a label matching the ID.",
  3295. // "location": "query",
  3296. // "type": "string"
  3297. // },
  3298. // "maxResults": {
  3299. // "default": "100",
  3300. // "description": "The maximum number of history records to return.",
  3301. // "format": "uint32",
  3302. // "location": "query",
  3303. // "type": "integer"
  3304. // },
  3305. // "pageToken": {
  3306. // "description": "Page token to retrieve a specific page of results in the list.",
  3307. // "location": "query",
  3308. // "type": "string"
  3309. // },
  3310. // "startHistoryId": {
  3311. // "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 rare 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.",
  3312. // "format": "uint64",
  3313. // "location": "query",
  3314. // "type": "string"
  3315. // },
  3316. // "userId": {
  3317. // "default": "me",
  3318. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3319. // "location": "path",
  3320. // "required": true,
  3321. // "type": "string"
  3322. // }
  3323. // },
  3324. // "path": "{userId}/history",
  3325. // "response": {
  3326. // "$ref": "ListHistoryResponse"
  3327. // },
  3328. // "scopes": [
  3329. // "https://mail.google.com/",
  3330. // "https://www.googleapis.com/auth/gmail.metadata",
  3331. // "https://www.googleapis.com/auth/gmail.modify",
  3332. // "https://www.googleapis.com/auth/gmail.readonly"
  3333. // ]
  3334. // }
  3335. }
  3336. // Pages invokes f for each page of results.
  3337. // A non-nil error returned from f will halt the iteration.
  3338. // The provided context supersedes any context provided to the Context method.
  3339. func (c *UsersHistoryListCall) Pages(ctx context.Context, f func(*ListHistoryResponse) error) error {
  3340. c.ctx_ = ctx
  3341. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3342. for {
  3343. x, err := c.Do()
  3344. if err != nil {
  3345. return err
  3346. }
  3347. if err := f(x); err != nil {
  3348. return err
  3349. }
  3350. if x.NextPageToken == "" {
  3351. return nil
  3352. }
  3353. c.PageToken(x.NextPageToken)
  3354. }
  3355. }
  3356. // method id "gmail.users.labels.create":
  3357. type UsersLabelsCreateCall struct {
  3358. s *Service
  3359. userId string
  3360. label *Label
  3361. urlParams_ gensupport.URLParams
  3362. ctx_ context.Context
  3363. header_ http.Header
  3364. }
  3365. // Create: Creates a new label.
  3366. func (r *UsersLabelsService) Create(userId string, label *Label) *UsersLabelsCreateCall {
  3367. c := &UsersLabelsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3368. c.userId = userId
  3369. c.label = label
  3370. return c
  3371. }
  3372. // Fields allows partial responses to be retrieved. See
  3373. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3374. // for more information.
  3375. func (c *UsersLabelsCreateCall) Fields(s ...googleapi.Field) *UsersLabelsCreateCall {
  3376. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3377. return c
  3378. }
  3379. // Context sets the context to be used in this call's Do method. Any
  3380. // pending HTTP request will be aborted if the provided context is
  3381. // canceled.
  3382. func (c *UsersLabelsCreateCall) Context(ctx context.Context) *UsersLabelsCreateCall {
  3383. c.ctx_ = ctx
  3384. return c
  3385. }
  3386. // Header returns an http.Header that can be modified by the caller to
  3387. // add HTTP headers to the request.
  3388. func (c *UsersLabelsCreateCall) Header() http.Header {
  3389. if c.header_ == nil {
  3390. c.header_ = make(http.Header)
  3391. }
  3392. return c.header_
  3393. }
  3394. func (c *UsersLabelsCreateCall) doRequest(alt string) (*http.Response, error) {
  3395. reqHeaders := make(http.Header)
  3396. for k, v := range c.header_ {
  3397. reqHeaders[k] = v
  3398. }
  3399. reqHeaders.Set("User-Agent", c.s.userAgent())
  3400. var body io.Reader = nil
  3401. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  3402. if err != nil {
  3403. return nil, err
  3404. }
  3405. reqHeaders.Set("Content-Type", "application/json")
  3406. c.urlParams_.Set("alt", alt)
  3407. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
  3408. urls += "?" + c.urlParams_.Encode()
  3409. req, _ := http.NewRequest("POST", urls, body)
  3410. req.Header = reqHeaders
  3411. googleapi.Expand(req.URL, map[string]string{
  3412. "userId": c.userId,
  3413. })
  3414. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3415. }
  3416. // Do executes the "gmail.users.labels.create" call.
  3417. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  3418. // code is an error. Response headers are in either
  3419. // *Label.ServerResponse.Header or (if a response was returned at all)
  3420. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3421. // check whether the returned error was because http.StatusNotModified
  3422. // was returned.
  3423. func (c *UsersLabelsCreateCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  3424. gensupport.SetOptions(c.urlParams_, opts...)
  3425. res, err := c.doRequest("json")
  3426. if res != nil && res.StatusCode == http.StatusNotModified {
  3427. if res.Body != nil {
  3428. res.Body.Close()
  3429. }
  3430. return nil, &googleapi.Error{
  3431. Code: res.StatusCode,
  3432. Header: res.Header,
  3433. }
  3434. }
  3435. if err != nil {
  3436. return nil, err
  3437. }
  3438. defer googleapi.CloseBody(res)
  3439. if err := googleapi.CheckResponse(res); err != nil {
  3440. return nil, err
  3441. }
  3442. ret := &Label{
  3443. ServerResponse: googleapi.ServerResponse{
  3444. Header: res.Header,
  3445. HTTPStatusCode: res.StatusCode,
  3446. },
  3447. }
  3448. target := &ret
  3449. if err := gensupport.DecodeResponse(target, res); err != nil {
  3450. return nil, err
  3451. }
  3452. return ret, nil
  3453. // {
  3454. // "description": "Creates a new label.",
  3455. // "httpMethod": "POST",
  3456. // "id": "gmail.users.labels.create",
  3457. // "parameterOrder": [
  3458. // "userId"
  3459. // ],
  3460. // "parameters": {
  3461. // "userId": {
  3462. // "default": "me",
  3463. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3464. // "location": "path",
  3465. // "required": true,
  3466. // "type": "string"
  3467. // }
  3468. // },
  3469. // "path": "{userId}/labels",
  3470. // "request": {
  3471. // "$ref": "Label"
  3472. // },
  3473. // "response": {
  3474. // "$ref": "Label"
  3475. // },
  3476. // "scopes": [
  3477. // "https://mail.google.com/",
  3478. // "https://www.googleapis.com/auth/gmail.labels",
  3479. // "https://www.googleapis.com/auth/gmail.modify"
  3480. // ]
  3481. // }
  3482. }
  3483. // method id "gmail.users.labels.delete":
  3484. type UsersLabelsDeleteCall struct {
  3485. s *Service
  3486. userId string
  3487. id string
  3488. urlParams_ gensupport.URLParams
  3489. ctx_ context.Context
  3490. header_ http.Header
  3491. }
  3492. // Delete: Immediately and permanently deletes the specified label and
  3493. // removes it from any messages and threads that it is applied to.
  3494. func (r *UsersLabelsService) Delete(userId string, id string) *UsersLabelsDeleteCall {
  3495. c := &UsersLabelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3496. c.userId = userId
  3497. c.id = id
  3498. return c
  3499. }
  3500. // Fields allows partial responses to be retrieved. See
  3501. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3502. // for more information.
  3503. func (c *UsersLabelsDeleteCall) Fields(s ...googleapi.Field) *UsersLabelsDeleteCall {
  3504. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3505. return c
  3506. }
  3507. // Context sets the context to be used in this call's Do method. Any
  3508. // pending HTTP request will be aborted if the provided context is
  3509. // canceled.
  3510. func (c *UsersLabelsDeleteCall) Context(ctx context.Context) *UsersLabelsDeleteCall {
  3511. c.ctx_ = ctx
  3512. return c
  3513. }
  3514. // Header returns an http.Header that can be modified by the caller to
  3515. // add HTTP headers to the request.
  3516. func (c *UsersLabelsDeleteCall) Header() http.Header {
  3517. if c.header_ == nil {
  3518. c.header_ = make(http.Header)
  3519. }
  3520. return c.header_
  3521. }
  3522. func (c *UsersLabelsDeleteCall) doRequest(alt string) (*http.Response, error) {
  3523. reqHeaders := make(http.Header)
  3524. for k, v := range c.header_ {
  3525. reqHeaders[k] = v
  3526. }
  3527. reqHeaders.Set("User-Agent", c.s.userAgent())
  3528. var body io.Reader = nil
  3529. c.urlParams_.Set("alt", alt)
  3530. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  3531. urls += "?" + c.urlParams_.Encode()
  3532. req, _ := http.NewRequest("DELETE", urls, body)
  3533. req.Header = reqHeaders
  3534. googleapi.Expand(req.URL, map[string]string{
  3535. "userId": c.userId,
  3536. "id": c.id,
  3537. })
  3538. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3539. }
  3540. // Do executes the "gmail.users.labels.delete" call.
  3541. func (c *UsersLabelsDeleteCall) Do(opts ...googleapi.CallOption) error {
  3542. gensupport.SetOptions(c.urlParams_, opts...)
  3543. res, err := c.doRequest("json")
  3544. if err != nil {
  3545. return err
  3546. }
  3547. defer googleapi.CloseBody(res)
  3548. if err := googleapi.CheckResponse(res); err != nil {
  3549. return err
  3550. }
  3551. return nil
  3552. // {
  3553. // "description": "Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.",
  3554. // "httpMethod": "DELETE",
  3555. // "id": "gmail.users.labels.delete",
  3556. // "parameterOrder": [
  3557. // "userId",
  3558. // "id"
  3559. // ],
  3560. // "parameters": {
  3561. // "id": {
  3562. // "description": "The ID of the label to delete.",
  3563. // "location": "path",
  3564. // "required": true,
  3565. // "type": "string"
  3566. // },
  3567. // "userId": {
  3568. // "default": "me",
  3569. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3570. // "location": "path",
  3571. // "required": true,
  3572. // "type": "string"
  3573. // }
  3574. // },
  3575. // "path": "{userId}/labels/{id}",
  3576. // "scopes": [
  3577. // "https://mail.google.com/",
  3578. // "https://www.googleapis.com/auth/gmail.labels",
  3579. // "https://www.googleapis.com/auth/gmail.modify"
  3580. // ]
  3581. // }
  3582. }
  3583. // method id "gmail.users.labels.get":
  3584. type UsersLabelsGetCall struct {
  3585. s *Service
  3586. userId string
  3587. id string
  3588. urlParams_ gensupport.URLParams
  3589. ifNoneMatch_ string
  3590. ctx_ context.Context
  3591. header_ http.Header
  3592. }
  3593. // Get: Gets the specified label.
  3594. func (r *UsersLabelsService) Get(userId string, id string) *UsersLabelsGetCall {
  3595. c := &UsersLabelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3596. c.userId = userId
  3597. c.id = id
  3598. return c
  3599. }
  3600. // Fields allows partial responses to be retrieved. See
  3601. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3602. // for more information.
  3603. func (c *UsersLabelsGetCall) Fields(s ...googleapi.Field) *UsersLabelsGetCall {
  3604. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3605. return c
  3606. }
  3607. // IfNoneMatch sets the optional parameter which makes the operation
  3608. // fail if the object's ETag matches the given value. This is useful for
  3609. // getting updates only after the object has changed since the last
  3610. // request. Use googleapi.IsNotModified to check whether the response
  3611. // error from Do is the result of In-None-Match.
  3612. func (c *UsersLabelsGetCall) IfNoneMatch(entityTag string) *UsersLabelsGetCall {
  3613. c.ifNoneMatch_ = entityTag
  3614. return c
  3615. }
  3616. // Context sets the context to be used in this call's Do method. Any
  3617. // pending HTTP request will be aborted if the provided context is
  3618. // canceled.
  3619. func (c *UsersLabelsGetCall) Context(ctx context.Context) *UsersLabelsGetCall {
  3620. c.ctx_ = ctx
  3621. return c
  3622. }
  3623. // Header returns an http.Header that can be modified by the caller to
  3624. // add HTTP headers to the request.
  3625. func (c *UsersLabelsGetCall) Header() http.Header {
  3626. if c.header_ == nil {
  3627. c.header_ = make(http.Header)
  3628. }
  3629. return c.header_
  3630. }
  3631. func (c *UsersLabelsGetCall) doRequest(alt string) (*http.Response, error) {
  3632. reqHeaders := make(http.Header)
  3633. for k, v := range c.header_ {
  3634. reqHeaders[k] = v
  3635. }
  3636. reqHeaders.Set("User-Agent", c.s.userAgent())
  3637. if c.ifNoneMatch_ != "" {
  3638. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3639. }
  3640. var body io.Reader = nil
  3641. c.urlParams_.Set("alt", alt)
  3642. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  3643. urls += "?" + c.urlParams_.Encode()
  3644. req, _ := http.NewRequest("GET", urls, body)
  3645. req.Header = reqHeaders
  3646. googleapi.Expand(req.URL, map[string]string{
  3647. "userId": c.userId,
  3648. "id": c.id,
  3649. })
  3650. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3651. }
  3652. // Do executes the "gmail.users.labels.get" call.
  3653. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  3654. // code is an error. Response headers are in either
  3655. // *Label.ServerResponse.Header or (if a response was returned at all)
  3656. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3657. // check whether the returned error was because http.StatusNotModified
  3658. // was returned.
  3659. func (c *UsersLabelsGetCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  3660. gensupport.SetOptions(c.urlParams_, opts...)
  3661. res, err := c.doRequest("json")
  3662. if res != nil && res.StatusCode == http.StatusNotModified {
  3663. if res.Body != nil {
  3664. res.Body.Close()
  3665. }
  3666. return nil, &googleapi.Error{
  3667. Code: res.StatusCode,
  3668. Header: res.Header,
  3669. }
  3670. }
  3671. if err != nil {
  3672. return nil, err
  3673. }
  3674. defer googleapi.CloseBody(res)
  3675. if err := googleapi.CheckResponse(res); err != nil {
  3676. return nil, err
  3677. }
  3678. ret := &Label{
  3679. ServerResponse: googleapi.ServerResponse{
  3680. Header: res.Header,
  3681. HTTPStatusCode: res.StatusCode,
  3682. },
  3683. }
  3684. target := &ret
  3685. if err := gensupport.DecodeResponse(target, res); err != nil {
  3686. return nil, err
  3687. }
  3688. return ret, nil
  3689. // {
  3690. // "description": "Gets the specified label.",
  3691. // "httpMethod": "GET",
  3692. // "id": "gmail.users.labels.get",
  3693. // "parameterOrder": [
  3694. // "userId",
  3695. // "id"
  3696. // ],
  3697. // "parameters": {
  3698. // "id": {
  3699. // "description": "The ID of the label to retrieve.",
  3700. // "location": "path",
  3701. // "required": true,
  3702. // "type": "string"
  3703. // },
  3704. // "userId": {
  3705. // "default": "me",
  3706. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3707. // "location": "path",
  3708. // "required": true,
  3709. // "type": "string"
  3710. // }
  3711. // },
  3712. // "path": "{userId}/labels/{id}",
  3713. // "response": {
  3714. // "$ref": "Label"
  3715. // },
  3716. // "scopes": [
  3717. // "https://mail.google.com/",
  3718. // "https://www.googleapis.com/auth/gmail.labels",
  3719. // "https://www.googleapis.com/auth/gmail.metadata",
  3720. // "https://www.googleapis.com/auth/gmail.modify",
  3721. // "https://www.googleapis.com/auth/gmail.readonly"
  3722. // ]
  3723. // }
  3724. }
  3725. // method id "gmail.users.labels.list":
  3726. type UsersLabelsListCall struct {
  3727. s *Service
  3728. userId string
  3729. urlParams_ gensupport.URLParams
  3730. ifNoneMatch_ string
  3731. ctx_ context.Context
  3732. header_ http.Header
  3733. }
  3734. // List: Lists all labels in the user's mailbox.
  3735. func (r *UsersLabelsService) List(userId string) *UsersLabelsListCall {
  3736. c := &UsersLabelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3737. c.userId = userId
  3738. return c
  3739. }
  3740. // Fields allows partial responses to be retrieved. See
  3741. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3742. // for more information.
  3743. func (c *UsersLabelsListCall) Fields(s ...googleapi.Field) *UsersLabelsListCall {
  3744. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3745. return c
  3746. }
  3747. // IfNoneMatch sets the optional parameter which makes the operation
  3748. // fail if the object's ETag matches the given value. This is useful for
  3749. // getting updates only after the object has changed since the last
  3750. // request. Use googleapi.IsNotModified to check whether the response
  3751. // error from Do is the result of In-None-Match.
  3752. func (c *UsersLabelsListCall) IfNoneMatch(entityTag string) *UsersLabelsListCall {
  3753. c.ifNoneMatch_ = entityTag
  3754. return c
  3755. }
  3756. // Context sets the context to be used in this call's Do method. Any
  3757. // pending HTTP request will be aborted if the provided context is
  3758. // canceled.
  3759. func (c *UsersLabelsListCall) Context(ctx context.Context) *UsersLabelsListCall {
  3760. c.ctx_ = ctx
  3761. return c
  3762. }
  3763. // Header returns an http.Header that can be modified by the caller to
  3764. // add HTTP headers to the request.
  3765. func (c *UsersLabelsListCall) Header() http.Header {
  3766. if c.header_ == nil {
  3767. c.header_ = make(http.Header)
  3768. }
  3769. return c.header_
  3770. }
  3771. func (c *UsersLabelsListCall) doRequest(alt string) (*http.Response, error) {
  3772. reqHeaders := make(http.Header)
  3773. for k, v := range c.header_ {
  3774. reqHeaders[k] = v
  3775. }
  3776. reqHeaders.Set("User-Agent", c.s.userAgent())
  3777. if c.ifNoneMatch_ != "" {
  3778. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3779. }
  3780. var body io.Reader = nil
  3781. c.urlParams_.Set("alt", alt)
  3782. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
  3783. urls += "?" + c.urlParams_.Encode()
  3784. req, _ := http.NewRequest("GET", urls, body)
  3785. req.Header = reqHeaders
  3786. googleapi.Expand(req.URL, map[string]string{
  3787. "userId": c.userId,
  3788. })
  3789. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3790. }
  3791. // Do executes the "gmail.users.labels.list" call.
  3792. // Exactly one of *ListLabelsResponse or error will be non-nil. Any
  3793. // non-2xx status code is an error. Response headers are in either
  3794. // *ListLabelsResponse.ServerResponse.Header or (if a response was
  3795. // returned at all) in error.(*googleapi.Error).Header. Use
  3796. // googleapi.IsNotModified to check whether the returned error was
  3797. // because http.StatusNotModified was returned.
  3798. func (c *UsersLabelsListCall) Do(opts ...googleapi.CallOption) (*ListLabelsResponse, error) {
  3799. gensupport.SetOptions(c.urlParams_, opts...)
  3800. res, err := c.doRequest("json")
  3801. if res != nil && res.StatusCode == http.StatusNotModified {
  3802. if res.Body != nil {
  3803. res.Body.Close()
  3804. }
  3805. return nil, &googleapi.Error{
  3806. Code: res.StatusCode,
  3807. Header: res.Header,
  3808. }
  3809. }
  3810. if err != nil {
  3811. return nil, err
  3812. }
  3813. defer googleapi.CloseBody(res)
  3814. if err := googleapi.CheckResponse(res); err != nil {
  3815. return nil, err
  3816. }
  3817. ret := &ListLabelsResponse{
  3818. ServerResponse: googleapi.ServerResponse{
  3819. Header: res.Header,
  3820. HTTPStatusCode: res.StatusCode,
  3821. },
  3822. }
  3823. target := &ret
  3824. if err := gensupport.DecodeResponse(target, res); err != nil {
  3825. return nil, err
  3826. }
  3827. return ret, nil
  3828. // {
  3829. // "description": "Lists all labels in the user's mailbox.",
  3830. // "httpMethod": "GET",
  3831. // "id": "gmail.users.labels.list",
  3832. // "parameterOrder": [
  3833. // "userId"
  3834. // ],
  3835. // "parameters": {
  3836. // "userId": {
  3837. // "default": "me",
  3838. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3839. // "location": "path",
  3840. // "required": true,
  3841. // "type": "string"
  3842. // }
  3843. // },
  3844. // "path": "{userId}/labels",
  3845. // "response": {
  3846. // "$ref": "ListLabelsResponse"
  3847. // },
  3848. // "scopes": [
  3849. // "https://mail.google.com/",
  3850. // "https://www.googleapis.com/auth/gmail.labels",
  3851. // "https://www.googleapis.com/auth/gmail.metadata",
  3852. // "https://www.googleapis.com/auth/gmail.modify",
  3853. // "https://www.googleapis.com/auth/gmail.readonly"
  3854. // ]
  3855. // }
  3856. }
  3857. // method id "gmail.users.labels.patch":
  3858. type UsersLabelsPatchCall struct {
  3859. s *Service
  3860. userId string
  3861. id string
  3862. label *Label
  3863. urlParams_ gensupport.URLParams
  3864. ctx_ context.Context
  3865. header_ http.Header
  3866. }
  3867. // Patch: Updates the specified label. This method supports patch
  3868. // semantics.
  3869. func (r *UsersLabelsService) Patch(userId string, id string, label *Label) *UsersLabelsPatchCall {
  3870. c := &UsersLabelsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3871. c.userId = userId
  3872. c.id = id
  3873. c.label = label
  3874. return c
  3875. }
  3876. // Fields allows partial responses to be retrieved. See
  3877. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3878. // for more information.
  3879. func (c *UsersLabelsPatchCall) Fields(s ...googleapi.Field) *UsersLabelsPatchCall {
  3880. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3881. return c
  3882. }
  3883. // Context sets the context to be used in this call's Do method. Any
  3884. // pending HTTP request will be aborted if the provided context is
  3885. // canceled.
  3886. func (c *UsersLabelsPatchCall) Context(ctx context.Context) *UsersLabelsPatchCall {
  3887. c.ctx_ = ctx
  3888. return c
  3889. }
  3890. // Header returns an http.Header that can be modified by the caller to
  3891. // add HTTP headers to the request.
  3892. func (c *UsersLabelsPatchCall) Header() http.Header {
  3893. if c.header_ == nil {
  3894. c.header_ = make(http.Header)
  3895. }
  3896. return c.header_
  3897. }
  3898. func (c *UsersLabelsPatchCall) doRequest(alt string) (*http.Response, error) {
  3899. reqHeaders := make(http.Header)
  3900. for k, v := range c.header_ {
  3901. reqHeaders[k] = v
  3902. }
  3903. reqHeaders.Set("User-Agent", c.s.userAgent())
  3904. var body io.Reader = nil
  3905. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  3906. if err != nil {
  3907. return nil, err
  3908. }
  3909. reqHeaders.Set("Content-Type", "application/json")
  3910. c.urlParams_.Set("alt", alt)
  3911. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  3912. urls += "?" + c.urlParams_.Encode()
  3913. req, _ := http.NewRequest("PATCH", urls, body)
  3914. req.Header = reqHeaders
  3915. googleapi.Expand(req.URL, map[string]string{
  3916. "userId": c.userId,
  3917. "id": c.id,
  3918. })
  3919. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3920. }
  3921. // Do executes the "gmail.users.labels.patch" call.
  3922. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  3923. // code is an error. Response headers are in either
  3924. // *Label.ServerResponse.Header or (if a response was returned at all)
  3925. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3926. // check whether the returned error was because http.StatusNotModified
  3927. // was returned.
  3928. func (c *UsersLabelsPatchCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  3929. gensupport.SetOptions(c.urlParams_, opts...)
  3930. res, err := c.doRequest("json")
  3931. if res != nil && res.StatusCode == http.StatusNotModified {
  3932. if res.Body != nil {
  3933. res.Body.Close()
  3934. }
  3935. return nil, &googleapi.Error{
  3936. Code: res.StatusCode,
  3937. Header: res.Header,
  3938. }
  3939. }
  3940. if err != nil {
  3941. return nil, err
  3942. }
  3943. defer googleapi.CloseBody(res)
  3944. if err := googleapi.CheckResponse(res); err != nil {
  3945. return nil, err
  3946. }
  3947. ret := &Label{
  3948. ServerResponse: googleapi.ServerResponse{
  3949. Header: res.Header,
  3950. HTTPStatusCode: res.StatusCode,
  3951. },
  3952. }
  3953. target := &ret
  3954. if err := gensupport.DecodeResponse(target, res); err != nil {
  3955. return nil, err
  3956. }
  3957. return ret, nil
  3958. // {
  3959. // "description": "Updates the specified label. This method supports patch semantics.",
  3960. // "httpMethod": "PATCH",
  3961. // "id": "gmail.users.labels.patch",
  3962. // "parameterOrder": [
  3963. // "userId",
  3964. // "id"
  3965. // ],
  3966. // "parameters": {
  3967. // "id": {
  3968. // "description": "The ID of the label to update.",
  3969. // "location": "path",
  3970. // "required": true,
  3971. // "type": "string"
  3972. // },
  3973. // "userId": {
  3974. // "default": "me",
  3975. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3976. // "location": "path",
  3977. // "required": true,
  3978. // "type": "string"
  3979. // }
  3980. // },
  3981. // "path": "{userId}/labels/{id}",
  3982. // "request": {
  3983. // "$ref": "Label"
  3984. // },
  3985. // "response": {
  3986. // "$ref": "Label"
  3987. // },
  3988. // "scopes": [
  3989. // "https://mail.google.com/",
  3990. // "https://www.googleapis.com/auth/gmail.labels",
  3991. // "https://www.googleapis.com/auth/gmail.modify"
  3992. // ]
  3993. // }
  3994. }
  3995. // method id "gmail.users.labels.update":
  3996. type UsersLabelsUpdateCall struct {
  3997. s *Service
  3998. userId string
  3999. id string
  4000. label *Label
  4001. urlParams_ gensupport.URLParams
  4002. ctx_ context.Context
  4003. header_ http.Header
  4004. }
  4005. // Update: Updates the specified label.
  4006. func (r *UsersLabelsService) Update(userId string, id string, label *Label) *UsersLabelsUpdateCall {
  4007. c := &UsersLabelsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4008. c.userId = userId
  4009. c.id = id
  4010. c.label = label
  4011. return c
  4012. }
  4013. // Fields allows partial responses to be retrieved. See
  4014. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4015. // for more information.
  4016. func (c *UsersLabelsUpdateCall) Fields(s ...googleapi.Field) *UsersLabelsUpdateCall {
  4017. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4018. return c
  4019. }
  4020. // Context sets the context to be used in this call's Do method. Any
  4021. // pending HTTP request will be aborted if the provided context is
  4022. // canceled.
  4023. func (c *UsersLabelsUpdateCall) Context(ctx context.Context) *UsersLabelsUpdateCall {
  4024. c.ctx_ = ctx
  4025. return c
  4026. }
  4027. // Header returns an http.Header that can be modified by the caller to
  4028. // add HTTP headers to the request.
  4029. func (c *UsersLabelsUpdateCall) Header() http.Header {
  4030. if c.header_ == nil {
  4031. c.header_ = make(http.Header)
  4032. }
  4033. return c.header_
  4034. }
  4035. func (c *UsersLabelsUpdateCall) doRequest(alt string) (*http.Response, error) {
  4036. reqHeaders := make(http.Header)
  4037. for k, v := range c.header_ {
  4038. reqHeaders[k] = v
  4039. }
  4040. reqHeaders.Set("User-Agent", c.s.userAgent())
  4041. var body io.Reader = nil
  4042. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  4043. if err != nil {
  4044. return nil, err
  4045. }
  4046. reqHeaders.Set("Content-Type", "application/json")
  4047. c.urlParams_.Set("alt", alt)
  4048. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  4049. urls += "?" + c.urlParams_.Encode()
  4050. req, _ := http.NewRequest("PUT", urls, body)
  4051. req.Header = reqHeaders
  4052. googleapi.Expand(req.URL, map[string]string{
  4053. "userId": c.userId,
  4054. "id": c.id,
  4055. })
  4056. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4057. }
  4058. // Do executes the "gmail.users.labels.update" call.
  4059. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  4060. // code is an error. Response headers are in either
  4061. // *Label.ServerResponse.Header or (if a response was returned at all)
  4062. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4063. // check whether the returned error was because http.StatusNotModified
  4064. // was returned.
  4065. func (c *UsersLabelsUpdateCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  4066. gensupport.SetOptions(c.urlParams_, opts...)
  4067. res, err := c.doRequest("json")
  4068. if res != nil && res.StatusCode == http.StatusNotModified {
  4069. if res.Body != nil {
  4070. res.Body.Close()
  4071. }
  4072. return nil, &googleapi.Error{
  4073. Code: res.StatusCode,
  4074. Header: res.Header,
  4075. }
  4076. }
  4077. if err != nil {
  4078. return nil, err
  4079. }
  4080. defer googleapi.CloseBody(res)
  4081. if err := googleapi.CheckResponse(res); err != nil {
  4082. return nil, err
  4083. }
  4084. ret := &Label{
  4085. ServerResponse: googleapi.ServerResponse{
  4086. Header: res.Header,
  4087. HTTPStatusCode: res.StatusCode,
  4088. },
  4089. }
  4090. target := &ret
  4091. if err := gensupport.DecodeResponse(target, res); err != nil {
  4092. return nil, err
  4093. }
  4094. return ret, nil
  4095. // {
  4096. // "description": "Updates the specified label.",
  4097. // "httpMethod": "PUT",
  4098. // "id": "gmail.users.labels.update",
  4099. // "parameterOrder": [
  4100. // "userId",
  4101. // "id"
  4102. // ],
  4103. // "parameters": {
  4104. // "id": {
  4105. // "description": "The ID of the label to update.",
  4106. // "location": "path",
  4107. // "required": true,
  4108. // "type": "string"
  4109. // },
  4110. // "userId": {
  4111. // "default": "me",
  4112. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4113. // "location": "path",
  4114. // "required": true,
  4115. // "type": "string"
  4116. // }
  4117. // },
  4118. // "path": "{userId}/labels/{id}",
  4119. // "request": {
  4120. // "$ref": "Label"
  4121. // },
  4122. // "response": {
  4123. // "$ref": "Label"
  4124. // },
  4125. // "scopes": [
  4126. // "https://mail.google.com/",
  4127. // "https://www.googleapis.com/auth/gmail.labels",
  4128. // "https://www.googleapis.com/auth/gmail.modify"
  4129. // ]
  4130. // }
  4131. }
  4132. // method id "gmail.users.messages.batchDelete":
  4133. type UsersMessagesBatchDeleteCall struct {
  4134. s *Service
  4135. userId string
  4136. batchdeletemessagesrequest *BatchDeleteMessagesRequest
  4137. urlParams_ gensupport.URLParams
  4138. ctx_ context.Context
  4139. header_ http.Header
  4140. }
  4141. // BatchDelete: Deletes many messages by message ID. Provides no
  4142. // guarantees that messages were not already deleted or even existed at
  4143. // all.
  4144. func (r *UsersMessagesService) BatchDelete(userId string, batchdeletemessagesrequest *BatchDeleteMessagesRequest) *UsersMessagesBatchDeleteCall {
  4145. c := &UsersMessagesBatchDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4146. c.userId = userId
  4147. c.batchdeletemessagesrequest = batchdeletemessagesrequest
  4148. return c
  4149. }
  4150. // Fields allows partial responses to be retrieved. See
  4151. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4152. // for more information.
  4153. func (c *UsersMessagesBatchDeleteCall) Fields(s ...googleapi.Field) *UsersMessagesBatchDeleteCall {
  4154. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4155. return c
  4156. }
  4157. // Context sets the context to be used in this call's Do method. Any
  4158. // pending HTTP request will be aborted if the provided context is
  4159. // canceled.
  4160. func (c *UsersMessagesBatchDeleteCall) Context(ctx context.Context) *UsersMessagesBatchDeleteCall {
  4161. c.ctx_ = ctx
  4162. return c
  4163. }
  4164. // Header returns an http.Header that can be modified by the caller to
  4165. // add HTTP headers to the request.
  4166. func (c *UsersMessagesBatchDeleteCall) Header() http.Header {
  4167. if c.header_ == nil {
  4168. c.header_ = make(http.Header)
  4169. }
  4170. return c.header_
  4171. }
  4172. func (c *UsersMessagesBatchDeleteCall) doRequest(alt string) (*http.Response, error) {
  4173. reqHeaders := make(http.Header)
  4174. for k, v := range c.header_ {
  4175. reqHeaders[k] = v
  4176. }
  4177. reqHeaders.Set("User-Agent", c.s.userAgent())
  4178. var body io.Reader = nil
  4179. body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchdeletemessagesrequest)
  4180. if err != nil {
  4181. return nil, err
  4182. }
  4183. reqHeaders.Set("Content-Type", "application/json")
  4184. c.urlParams_.Set("alt", alt)
  4185. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/batchDelete")
  4186. urls += "?" + c.urlParams_.Encode()
  4187. req, _ := http.NewRequest("POST", urls, body)
  4188. req.Header = reqHeaders
  4189. googleapi.Expand(req.URL, map[string]string{
  4190. "userId": c.userId,
  4191. })
  4192. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4193. }
  4194. // Do executes the "gmail.users.messages.batchDelete" call.
  4195. func (c *UsersMessagesBatchDeleteCall) Do(opts ...googleapi.CallOption) error {
  4196. gensupport.SetOptions(c.urlParams_, opts...)
  4197. res, err := c.doRequest("json")
  4198. if err != nil {
  4199. return err
  4200. }
  4201. defer googleapi.CloseBody(res)
  4202. if err := googleapi.CheckResponse(res); err != nil {
  4203. return err
  4204. }
  4205. return nil
  4206. // {
  4207. // "description": "Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.",
  4208. // "httpMethod": "POST",
  4209. // "id": "gmail.users.messages.batchDelete",
  4210. // "parameterOrder": [
  4211. // "userId"
  4212. // ],
  4213. // "parameters": {
  4214. // "userId": {
  4215. // "default": "me",
  4216. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4217. // "location": "path",
  4218. // "required": true,
  4219. // "type": "string"
  4220. // }
  4221. // },
  4222. // "path": "{userId}/messages/batchDelete",
  4223. // "request": {
  4224. // "$ref": "BatchDeleteMessagesRequest"
  4225. // },
  4226. // "scopes": [
  4227. // "https://mail.google.com/"
  4228. // ]
  4229. // }
  4230. }
  4231. // method id "gmail.users.messages.batchModify":
  4232. type UsersMessagesBatchModifyCall struct {
  4233. s *Service
  4234. userId string
  4235. batchmodifymessagesrequest *BatchModifyMessagesRequest
  4236. urlParams_ gensupport.URLParams
  4237. ctx_ context.Context
  4238. header_ http.Header
  4239. }
  4240. // BatchModify: Modifies the labels on the specified messages.
  4241. func (r *UsersMessagesService) BatchModify(userId string, batchmodifymessagesrequest *BatchModifyMessagesRequest) *UsersMessagesBatchModifyCall {
  4242. c := &UsersMessagesBatchModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4243. c.userId = userId
  4244. c.batchmodifymessagesrequest = batchmodifymessagesrequest
  4245. return c
  4246. }
  4247. // Fields allows partial responses to be retrieved. See
  4248. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4249. // for more information.
  4250. func (c *UsersMessagesBatchModifyCall) Fields(s ...googleapi.Field) *UsersMessagesBatchModifyCall {
  4251. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4252. return c
  4253. }
  4254. // Context sets the context to be used in this call's Do method. Any
  4255. // pending HTTP request will be aborted if the provided context is
  4256. // canceled.
  4257. func (c *UsersMessagesBatchModifyCall) Context(ctx context.Context) *UsersMessagesBatchModifyCall {
  4258. c.ctx_ = ctx
  4259. return c
  4260. }
  4261. // Header returns an http.Header that can be modified by the caller to
  4262. // add HTTP headers to the request.
  4263. func (c *UsersMessagesBatchModifyCall) Header() http.Header {
  4264. if c.header_ == nil {
  4265. c.header_ = make(http.Header)
  4266. }
  4267. return c.header_
  4268. }
  4269. func (c *UsersMessagesBatchModifyCall) doRequest(alt string) (*http.Response, error) {
  4270. reqHeaders := make(http.Header)
  4271. for k, v := range c.header_ {
  4272. reqHeaders[k] = v
  4273. }
  4274. reqHeaders.Set("User-Agent", c.s.userAgent())
  4275. var body io.Reader = nil
  4276. body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchmodifymessagesrequest)
  4277. if err != nil {
  4278. return nil, err
  4279. }
  4280. reqHeaders.Set("Content-Type", "application/json")
  4281. c.urlParams_.Set("alt", alt)
  4282. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/batchModify")
  4283. urls += "?" + c.urlParams_.Encode()
  4284. req, _ := http.NewRequest("POST", urls, body)
  4285. req.Header = reqHeaders
  4286. googleapi.Expand(req.URL, map[string]string{
  4287. "userId": c.userId,
  4288. })
  4289. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4290. }
  4291. // Do executes the "gmail.users.messages.batchModify" call.
  4292. func (c *UsersMessagesBatchModifyCall) Do(opts ...googleapi.CallOption) error {
  4293. gensupport.SetOptions(c.urlParams_, opts...)
  4294. res, err := c.doRequest("json")
  4295. if err != nil {
  4296. return err
  4297. }
  4298. defer googleapi.CloseBody(res)
  4299. if err := googleapi.CheckResponse(res); err != nil {
  4300. return err
  4301. }
  4302. return nil
  4303. // {
  4304. // "description": "Modifies the labels on the specified messages.",
  4305. // "httpMethod": "POST",
  4306. // "id": "gmail.users.messages.batchModify",
  4307. // "parameterOrder": [
  4308. // "userId"
  4309. // ],
  4310. // "parameters": {
  4311. // "userId": {
  4312. // "default": "me",
  4313. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4314. // "location": "path",
  4315. // "required": true,
  4316. // "type": "string"
  4317. // }
  4318. // },
  4319. // "path": "{userId}/messages/batchModify",
  4320. // "request": {
  4321. // "$ref": "BatchModifyMessagesRequest"
  4322. // },
  4323. // "scopes": [
  4324. // "https://mail.google.com/",
  4325. // "https://www.googleapis.com/auth/gmail.modify"
  4326. // ]
  4327. // }
  4328. }
  4329. // method id "gmail.users.messages.delete":
  4330. type UsersMessagesDeleteCall struct {
  4331. s *Service
  4332. userId string
  4333. id string
  4334. urlParams_ gensupport.URLParams
  4335. ctx_ context.Context
  4336. header_ http.Header
  4337. }
  4338. // Delete: Immediately and permanently deletes the specified message.
  4339. // This operation cannot be undone. Prefer messages.trash instead.
  4340. func (r *UsersMessagesService) Delete(userId string, id string) *UsersMessagesDeleteCall {
  4341. c := &UsersMessagesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4342. c.userId = userId
  4343. c.id = id
  4344. return c
  4345. }
  4346. // Fields allows partial responses to be retrieved. See
  4347. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4348. // for more information.
  4349. func (c *UsersMessagesDeleteCall) Fields(s ...googleapi.Field) *UsersMessagesDeleteCall {
  4350. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4351. return c
  4352. }
  4353. // Context sets the context to be used in this call's Do method. Any
  4354. // pending HTTP request will be aborted if the provided context is
  4355. // canceled.
  4356. func (c *UsersMessagesDeleteCall) Context(ctx context.Context) *UsersMessagesDeleteCall {
  4357. c.ctx_ = ctx
  4358. return c
  4359. }
  4360. // Header returns an http.Header that can be modified by the caller to
  4361. // add HTTP headers to the request.
  4362. func (c *UsersMessagesDeleteCall) Header() http.Header {
  4363. if c.header_ == nil {
  4364. c.header_ = make(http.Header)
  4365. }
  4366. return c.header_
  4367. }
  4368. func (c *UsersMessagesDeleteCall) doRequest(alt string) (*http.Response, error) {
  4369. reqHeaders := make(http.Header)
  4370. for k, v := range c.header_ {
  4371. reqHeaders[k] = v
  4372. }
  4373. reqHeaders.Set("User-Agent", c.s.userAgent())
  4374. var body io.Reader = nil
  4375. c.urlParams_.Set("alt", alt)
  4376. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
  4377. urls += "?" + c.urlParams_.Encode()
  4378. req, _ := http.NewRequest("DELETE", urls, body)
  4379. req.Header = reqHeaders
  4380. googleapi.Expand(req.URL, map[string]string{
  4381. "userId": c.userId,
  4382. "id": c.id,
  4383. })
  4384. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4385. }
  4386. // Do executes the "gmail.users.messages.delete" call.
  4387. func (c *UsersMessagesDeleteCall) Do(opts ...googleapi.CallOption) error {
  4388. gensupport.SetOptions(c.urlParams_, opts...)
  4389. res, err := c.doRequest("json")
  4390. if err != nil {
  4391. return err
  4392. }
  4393. defer googleapi.CloseBody(res)
  4394. if err := googleapi.CheckResponse(res); err != nil {
  4395. return err
  4396. }
  4397. return nil
  4398. // {
  4399. // "description": "Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer messages.trash instead.",
  4400. // "httpMethod": "DELETE",
  4401. // "id": "gmail.users.messages.delete",
  4402. // "parameterOrder": [
  4403. // "userId",
  4404. // "id"
  4405. // ],
  4406. // "parameters": {
  4407. // "id": {
  4408. // "description": "The ID of the message to delete.",
  4409. // "location": "path",
  4410. // "required": true,
  4411. // "type": "string"
  4412. // },
  4413. // "userId": {
  4414. // "default": "me",
  4415. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4416. // "location": "path",
  4417. // "required": true,
  4418. // "type": "string"
  4419. // }
  4420. // },
  4421. // "path": "{userId}/messages/{id}",
  4422. // "scopes": [
  4423. // "https://mail.google.com/"
  4424. // ]
  4425. // }
  4426. }
  4427. // method id "gmail.users.messages.get":
  4428. type UsersMessagesGetCall struct {
  4429. s *Service
  4430. userId string
  4431. id string
  4432. urlParams_ gensupport.URLParams
  4433. ifNoneMatch_ string
  4434. ctx_ context.Context
  4435. header_ http.Header
  4436. }
  4437. // Get: Gets the specified message.
  4438. func (r *UsersMessagesService) Get(userId string, id string) *UsersMessagesGetCall {
  4439. c := &UsersMessagesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4440. c.userId = userId
  4441. c.id = id
  4442. return c
  4443. }
  4444. // Format sets the optional parameter "format": The format to return the
  4445. // message in.
  4446. //
  4447. // Possible values:
  4448. // "full" (default)
  4449. // "metadata"
  4450. // "minimal"
  4451. // "raw"
  4452. func (c *UsersMessagesGetCall) Format(format string) *UsersMessagesGetCall {
  4453. c.urlParams_.Set("format", format)
  4454. return c
  4455. }
  4456. // MetadataHeaders sets the optional parameter "metadataHeaders": When
  4457. // given and format is METADATA, only include headers specified.
  4458. func (c *UsersMessagesGetCall) MetadataHeaders(metadataHeaders ...string) *UsersMessagesGetCall {
  4459. c.urlParams_.SetMulti("metadataHeaders", append([]string{}, metadataHeaders...))
  4460. return c
  4461. }
  4462. // Fields allows partial responses to be retrieved. See
  4463. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4464. // for more information.
  4465. func (c *UsersMessagesGetCall) Fields(s ...googleapi.Field) *UsersMessagesGetCall {
  4466. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4467. return c
  4468. }
  4469. // IfNoneMatch sets the optional parameter which makes the operation
  4470. // fail if the object's ETag matches the given value. This is useful for
  4471. // getting updates only after the object has changed since the last
  4472. // request. Use googleapi.IsNotModified to check whether the response
  4473. // error from Do is the result of In-None-Match.
  4474. func (c *UsersMessagesGetCall) IfNoneMatch(entityTag string) *UsersMessagesGetCall {
  4475. c.ifNoneMatch_ = entityTag
  4476. return c
  4477. }
  4478. // Context sets the context to be used in this call's Do method. Any
  4479. // pending HTTP request will be aborted if the provided context is
  4480. // canceled.
  4481. func (c *UsersMessagesGetCall) Context(ctx context.Context) *UsersMessagesGetCall {
  4482. c.ctx_ = ctx
  4483. return c
  4484. }
  4485. // Header returns an http.Header that can be modified by the caller to
  4486. // add HTTP headers to the request.
  4487. func (c *UsersMessagesGetCall) Header() http.Header {
  4488. if c.header_ == nil {
  4489. c.header_ = make(http.Header)
  4490. }
  4491. return c.header_
  4492. }
  4493. func (c *UsersMessagesGetCall) doRequest(alt string) (*http.Response, error) {
  4494. reqHeaders := make(http.Header)
  4495. for k, v := range c.header_ {
  4496. reqHeaders[k] = v
  4497. }
  4498. reqHeaders.Set("User-Agent", c.s.userAgent())
  4499. if c.ifNoneMatch_ != "" {
  4500. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  4501. }
  4502. var body io.Reader = nil
  4503. c.urlParams_.Set("alt", alt)
  4504. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
  4505. urls += "?" + c.urlParams_.Encode()
  4506. req, _ := http.NewRequest("GET", urls, body)
  4507. req.Header = reqHeaders
  4508. googleapi.Expand(req.URL, map[string]string{
  4509. "userId": c.userId,
  4510. "id": c.id,
  4511. })
  4512. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4513. }
  4514. // Do executes the "gmail.users.messages.get" call.
  4515. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4516. // code is an error. Response headers are in either
  4517. // *Message.ServerResponse.Header or (if a response was returned at all)
  4518. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4519. // check whether the returned error was because http.StatusNotModified
  4520. // was returned.
  4521. func (c *UsersMessagesGetCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4522. gensupport.SetOptions(c.urlParams_, opts...)
  4523. res, err := c.doRequest("json")
  4524. if res != nil && res.StatusCode == http.StatusNotModified {
  4525. if res.Body != nil {
  4526. res.Body.Close()
  4527. }
  4528. return nil, &googleapi.Error{
  4529. Code: res.StatusCode,
  4530. Header: res.Header,
  4531. }
  4532. }
  4533. if err != nil {
  4534. return nil, err
  4535. }
  4536. defer googleapi.CloseBody(res)
  4537. if err := googleapi.CheckResponse(res); err != nil {
  4538. return nil, err
  4539. }
  4540. ret := &Message{
  4541. ServerResponse: googleapi.ServerResponse{
  4542. Header: res.Header,
  4543. HTTPStatusCode: res.StatusCode,
  4544. },
  4545. }
  4546. target := &ret
  4547. if err := gensupport.DecodeResponse(target, res); err != nil {
  4548. return nil, err
  4549. }
  4550. return ret, nil
  4551. // {
  4552. // "description": "Gets the specified message.",
  4553. // "httpMethod": "GET",
  4554. // "id": "gmail.users.messages.get",
  4555. // "parameterOrder": [
  4556. // "userId",
  4557. // "id"
  4558. // ],
  4559. // "parameters": {
  4560. // "format": {
  4561. // "default": "full",
  4562. // "description": "The format to return the message in.",
  4563. // "enum": [
  4564. // "full",
  4565. // "metadata",
  4566. // "minimal",
  4567. // "raw"
  4568. // ],
  4569. // "enumDescriptions": [
  4570. // "",
  4571. // "",
  4572. // "",
  4573. // ""
  4574. // ],
  4575. // "location": "query",
  4576. // "type": "string"
  4577. // },
  4578. // "id": {
  4579. // "description": "The ID of the message to retrieve.",
  4580. // "location": "path",
  4581. // "required": true,
  4582. // "type": "string"
  4583. // },
  4584. // "metadataHeaders": {
  4585. // "description": "When given and format is METADATA, only include headers specified.",
  4586. // "location": "query",
  4587. // "repeated": true,
  4588. // "type": "string"
  4589. // },
  4590. // "userId": {
  4591. // "default": "me",
  4592. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4593. // "location": "path",
  4594. // "required": true,
  4595. // "type": "string"
  4596. // }
  4597. // },
  4598. // "path": "{userId}/messages/{id}",
  4599. // "response": {
  4600. // "$ref": "Message"
  4601. // },
  4602. // "scopes": [
  4603. // "https://mail.google.com/",
  4604. // "https://www.googleapis.com/auth/gmail.metadata",
  4605. // "https://www.googleapis.com/auth/gmail.modify",
  4606. // "https://www.googleapis.com/auth/gmail.readonly"
  4607. // ]
  4608. // }
  4609. }
  4610. // method id "gmail.users.messages.import":
  4611. type UsersMessagesImportCall struct {
  4612. s *Service
  4613. userId string
  4614. message *Message
  4615. urlParams_ gensupport.URLParams
  4616. mediaInfo_ *gensupport.MediaInfo
  4617. ctx_ context.Context
  4618. header_ http.Header
  4619. }
  4620. // Import: Imports a message into only this user's mailbox, with
  4621. // standard email delivery scanning and classification similar to
  4622. // receiving via SMTP. Does not send a message.
  4623. func (r *UsersMessagesService) Import(userId string, message *Message) *UsersMessagesImportCall {
  4624. c := &UsersMessagesImportCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4625. c.userId = userId
  4626. c.message = message
  4627. return c
  4628. }
  4629. // Deleted sets the optional parameter "deleted": Mark the email as
  4630. // permanently deleted (not TRASH) and only visible in Google Vault to a
  4631. // Vault administrator. Only used for G Suite accounts.
  4632. func (c *UsersMessagesImportCall) Deleted(deleted bool) *UsersMessagesImportCall {
  4633. c.urlParams_.Set("deleted", fmt.Sprint(deleted))
  4634. return c
  4635. }
  4636. // InternalDateSource sets the optional parameter "internalDateSource":
  4637. // Source for Gmail's internal date of the message.
  4638. //
  4639. // Possible values:
  4640. // "dateHeader" (default)
  4641. // "receivedTime"
  4642. func (c *UsersMessagesImportCall) InternalDateSource(internalDateSource string) *UsersMessagesImportCall {
  4643. c.urlParams_.Set("internalDateSource", internalDateSource)
  4644. return c
  4645. }
  4646. // NeverMarkSpam sets the optional parameter "neverMarkSpam": Ignore the
  4647. // Gmail spam classifier decision and never mark this email as SPAM in
  4648. // the mailbox.
  4649. func (c *UsersMessagesImportCall) NeverMarkSpam(neverMarkSpam bool) *UsersMessagesImportCall {
  4650. c.urlParams_.Set("neverMarkSpam", fmt.Sprint(neverMarkSpam))
  4651. return c
  4652. }
  4653. // ProcessForCalendar sets the optional parameter "processForCalendar":
  4654. // Process calendar invites in the email and add any extracted meetings
  4655. // to the Google Calendar for this user.
  4656. func (c *UsersMessagesImportCall) ProcessForCalendar(processForCalendar bool) *UsersMessagesImportCall {
  4657. c.urlParams_.Set("processForCalendar", fmt.Sprint(processForCalendar))
  4658. return c
  4659. }
  4660. // Media specifies the media to upload in one or more chunks. The chunk
  4661. // size may be controlled by supplying a MediaOption generated by
  4662. // googleapi.ChunkSize. The chunk size defaults to
  4663. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  4664. // upload request will be determined by sniffing the contents of r,
  4665. // unless a MediaOption generated by googleapi.ContentType is
  4666. // supplied.
  4667. // At most one of Media and ResumableMedia may be set.
  4668. func (c *UsersMessagesImportCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesImportCall {
  4669. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  4670. return c
  4671. }
  4672. // ResumableMedia specifies the media to upload in chunks and can be
  4673. // canceled with ctx.
  4674. //
  4675. // Deprecated: use Media instead.
  4676. //
  4677. // At most one of Media and ResumableMedia may be set. mediaType
  4678. // identifies the MIME media type of the upload, such as "image/png". If
  4679. // mediaType is "", it will be auto-detected. The provided ctx will
  4680. // supersede any context previously provided to the Context method.
  4681. func (c *UsersMessagesImportCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesImportCall {
  4682. c.ctx_ = ctx
  4683. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  4684. return c
  4685. }
  4686. // ProgressUpdater provides a callback function that will be called
  4687. // after every chunk. It should be a low-latency function in order to
  4688. // not slow down the upload operation. This should only be called when
  4689. // using ResumableMedia (as opposed to Media).
  4690. func (c *UsersMessagesImportCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesImportCall {
  4691. c.mediaInfo_.SetProgressUpdater(pu)
  4692. return c
  4693. }
  4694. // Fields allows partial responses to be retrieved. See
  4695. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4696. // for more information.
  4697. func (c *UsersMessagesImportCall) Fields(s ...googleapi.Field) *UsersMessagesImportCall {
  4698. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4699. return c
  4700. }
  4701. // Context sets the context to be used in this call's Do method. Any
  4702. // pending HTTP request will be aborted if the provided context is
  4703. // canceled.
  4704. // This context will supersede any context previously provided to the
  4705. // ResumableMedia method.
  4706. func (c *UsersMessagesImportCall) Context(ctx context.Context) *UsersMessagesImportCall {
  4707. c.ctx_ = ctx
  4708. return c
  4709. }
  4710. // Header returns an http.Header that can be modified by the caller to
  4711. // add HTTP headers to the request.
  4712. func (c *UsersMessagesImportCall) Header() http.Header {
  4713. if c.header_ == nil {
  4714. c.header_ = make(http.Header)
  4715. }
  4716. return c.header_
  4717. }
  4718. func (c *UsersMessagesImportCall) doRequest(alt string) (*http.Response, error) {
  4719. reqHeaders := make(http.Header)
  4720. for k, v := range c.header_ {
  4721. reqHeaders[k] = v
  4722. }
  4723. reqHeaders.Set("User-Agent", c.s.userAgent())
  4724. var body io.Reader = nil
  4725. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  4726. if err != nil {
  4727. return nil, err
  4728. }
  4729. reqHeaders.Set("Content-Type", "application/json")
  4730. c.urlParams_.Set("alt", alt)
  4731. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/import")
  4732. if c.mediaInfo_ != nil {
  4733. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  4734. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  4735. }
  4736. if body == nil {
  4737. body = new(bytes.Buffer)
  4738. reqHeaders.Set("Content-Type", "application/json")
  4739. }
  4740. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  4741. defer cleanup()
  4742. urls += "?" + c.urlParams_.Encode()
  4743. req, _ := http.NewRequest("POST", urls, body)
  4744. req.Header = reqHeaders
  4745. gensupport.SetGetBody(req, getBody)
  4746. googleapi.Expand(req.URL, map[string]string{
  4747. "userId": c.userId,
  4748. })
  4749. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4750. }
  4751. // Do executes the "gmail.users.messages.import" call.
  4752. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4753. // code is an error. Response headers are in either
  4754. // *Message.ServerResponse.Header or (if a response was returned at all)
  4755. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4756. // check whether the returned error was because http.StatusNotModified
  4757. // was returned.
  4758. func (c *UsersMessagesImportCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4759. gensupport.SetOptions(c.urlParams_, opts...)
  4760. res, err := c.doRequest("json")
  4761. if res != nil && res.StatusCode == http.StatusNotModified {
  4762. if res.Body != nil {
  4763. res.Body.Close()
  4764. }
  4765. return nil, &googleapi.Error{
  4766. Code: res.StatusCode,
  4767. Header: res.Header,
  4768. }
  4769. }
  4770. if err != nil {
  4771. return nil, err
  4772. }
  4773. defer googleapi.CloseBody(res)
  4774. if err := googleapi.CheckResponse(res); err != nil {
  4775. return nil, err
  4776. }
  4777. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  4778. if rx != nil {
  4779. rx.Client = c.s.client
  4780. rx.UserAgent = c.s.userAgent()
  4781. ctx := c.ctx_
  4782. if ctx == nil {
  4783. ctx = context.TODO()
  4784. }
  4785. res, err = rx.Upload(ctx)
  4786. if err != nil {
  4787. return nil, err
  4788. }
  4789. defer res.Body.Close()
  4790. if err := googleapi.CheckResponse(res); err != nil {
  4791. return nil, err
  4792. }
  4793. }
  4794. ret := &Message{
  4795. ServerResponse: googleapi.ServerResponse{
  4796. Header: res.Header,
  4797. HTTPStatusCode: res.StatusCode,
  4798. },
  4799. }
  4800. target := &ret
  4801. if err := gensupport.DecodeResponse(target, res); err != nil {
  4802. return nil, err
  4803. }
  4804. return ret, nil
  4805. // {
  4806. // "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.",
  4807. // "httpMethod": "POST",
  4808. // "id": "gmail.users.messages.import",
  4809. // "mediaUpload": {
  4810. // "accept": [
  4811. // "message/rfc822"
  4812. // ],
  4813. // "maxSize": "50MB",
  4814. // "protocols": {
  4815. // "resumable": {
  4816. // "multipart": true,
  4817. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages/import"
  4818. // },
  4819. // "simple": {
  4820. // "multipart": true,
  4821. // "path": "/upload/gmail/v1/users/{userId}/messages/import"
  4822. // }
  4823. // }
  4824. // },
  4825. // "parameterOrder": [
  4826. // "userId"
  4827. // ],
  4828. // "parameters": {
  4829. // "deleted": {
  4830. // "default": "false",
  4831. // "description": "Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for G Suite accounts.",
  4832. // "location": "query",
  4833. // "type": "boolean"
  4834. // },
  4835. // "internalDateSource": {
  4836. // "default": "dateHeader",
  4837. // "description": "Source for Gmail's internal date of the message.",
  4838. // "enum": [
  4839. // "dateHeader",
  4840. // "receivedTime"
  4841. // ],
  4842. // "enumDescriptions": [
  4843. // "",
  4844. // ""
  4845. // ],
  4846. // "location": "query",
  4847. // "type": "string"
  4848. // },
  4849. // "neverMarkSpam": {
  4850. // "default": "false",
  4851. // "description": "Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.",
  4852. // "location": "query",
  4853. // "type": "boolean"
  4854. // },
  4855. // "processForCalendar": {
  4856. // "default": "false",
  4857. // "description": "Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.",
  4858. // "location": "query",
  4859. // "type": "boolean"
  4860. // },
  4861. // "userId": {
  4862. // "default": "me",
  4863. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4864. // "location": "path",
  4865. // "required": true,
  4866. // "type": "string"
  4867. // }
  4868. // },
  4869. // "path": "{userId}/messages/import",
  4870. // "request": {
  4871. // "$ref": "Message"
  4872. // },
  4873. // "response": {
  4874. // "$ref": "Message"
  4875. // },
  4876. // "scopes": [
  4877. // "https://mail.google.com/",
  4878. // "https://www.googleapis.com/auth/gmail.insert",
  4879. // "https://www.googleapis.com/auth/gmail.modify"
  4880. // ],
  4881. // "supportsMediaUpload": true
  4882. // }
  4883. }
  4884. // method id "gmail.users.messages.insert":
  4885. type UsersMessagesInsertCall struct {
  4886. s *Service
  4887. userId string
  4888. message *Message
  4889. urlParams_ gensupport.URLParams
  4890. mediaInfo_ *gensupport.MediaInfo
  4891. ctx_ context.Context
  4892. header_ http.Header
  4893. }
  4894. // Insert: Directly inserts a message into only this user's mailbox
  4895. // similar to IMAP APPEND, bypassing most scanning and classification.
  4896. // Does not send a message.
  4897. func (r *UsersMessagesService) Insert(userId string, message *Message) *UsersMessagesInsertCall {
  4898. c := &UsersMessagesInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4899. c.userId = userId
  4900. c.message = message
  4901. return c
  4902. }
  4903. // Deleted sets the optional parameter "deleted": Mark the email as
  4904. // permanently deleted (not TRASH) and only visible in Google Vault to a
  4905. // Vault administrator. Only used for G Suite accounts.
  4906. func (c *UsersMessagesInsertCall) Deleted(deleted bool) *UsersMessagesInsertCall {
  4907. c.urlParams_.Set("deleted", fmt.Sprint(deleted))
  4908. return c
  4909. }
  4910. // InternalDateSource sets the optional parameter "internalDateSource":
  4911. // Source for Gmail's internal date of the message.
  4912. //
  4913. // Possible values:
  4914. // "dateHeader"
  4915. // "receivedTime" (default)
  4916. func (c *UsersMessagesInsertCall) InternalDateSource(internalDateSource string) *UsersMessagesInsertCall {
  4917. c.urlParams_.Set("internalDateSource", internalDateSource)
  4918. return c
  4919. }
  4920. // Media specifies the media to upload in one or more chunks. The chunk
  4921. // size may be controlled by supplying a MediaOption generated by
  4922. // googleapi.ChunkSize. The chunk size defaults to
  4923. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  4924. // upload request will be determined by sniffing the contents of r,
  4925. // unless a MediaOption generated by googleapi.ContentType is
  4926. // supplied.
  4927. // At most one of Media and ResumableMedia may be set.
  4928. func (c *UsersMessagesInsertCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesInsertCall {
  4929. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  4930. return c
  4931. }
  4932. // ResumableMedia specifies the media to upload in chunks and can be
  4933. // canceled with ctx.
  4934. //
  4935. // Deprecated: use Media instead.
  4936. //
  4937. // At most one of Media and ResumableMedia may be set. mediaType
  4938. // identifies the MIME media type of the upload, such as "image/png". If
  4939. // mediaType is "", it will be auto-detected. The provided ctx will
  4940. // supersede any context previously provided to the Context method.
  4941. func (c *UsersMessagesInsertCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesInsertCall {
  4942. c.ctx_ = ctx
  4943. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  4944. return c
  4945. }
  4946. // ProgressUpdater provides a callback function that will be called
  4947. // after every chunk. It should be a low-latency function in order to
  4948. // not slow down the upload operation. This should only be called when
  4949. // using ResumableMedia (as opposed to Media).
  4950. func (c *UsersMessagesInsertCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesInsertCall {
  4951. c.mediaInfo_.SetProgressUpdater(pu)
  4952. return c
  4953. }
  4954. // Fields allows partial responses to be retrieved. See
  4955. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4956. // for more information.
  4957. func (c *UsersMessagesInsertCall) Fields(s ...googleapi.Field) *UsersMessagesInsertCall {
  4958. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4959. return c
  4960. }
  4961. // Context sets the context to be used in this call's Do method. Any
  4962. // pending HTTP request will be aborted if the provided context is
  4963. // canceled.
  4964. // This context will supersede any context previously provided to the
  4965. // ResumableMedia method.
  4966. func (c *UsersMessagesInsertCall) Context(ctx context.Context) *UsersMessagesInsertCall {
  4967. c.ctx_ = ctx
  4968. return c
  4969. }
  4970. // Header returns an http.Header that can be modified by the caller to
  4971. // add HTTP headers to the request.
  4972. func (c *UsersMessagesInsertCall) Header() http.Header {
  4973. if c.header_ == nil {
  4974. c.header_ = make(http.Header)
  4975. }
  4976. return c.header_
  4977. }
  4978. func (c *UsersMessagesInsertCall) doRequest(alt string) (*http.Response, error) {
  4979. reqHeaders := make(http.Header)
  4980. for k, v := range c.header_ {
  4981. reqHeaders[k] = v
  4982. }
  4983. reqHeaders.Set("User-Agent", c.s.userAgent())
  4984. var body io.Reader = nil
  4985. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  4986. if err != nil {
  4987. return nil, err
  4988. }
  4989. reqHeaders.Set("Content-Type", "application/json")
  4990. c.urlParams_.Set("alt", alt)
  4991. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
  4992. if c.mediaInfo_ != nil {
  4993. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  4994. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  4995. }
  4996. if body == nil {
  4997. body = new(bytes.Buffer)
  4998. reqHeaders.Set("Content-Type", "application/json")
  4999. }
  5000. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  5001. defer cleanup()
  5002. urls += "?" + c.urlParams_.Encode()
  5003. req, _ := http.NewRequest("POST", urls, body)
  5004. req.Header = reqHeaders
  5005. gensupport.SetGetBody(req, getBody)
  5006. googleapi.Expand(req.URL, map[string]string{
  5007. "userId": c.userId,
  5008. })
  5009. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5010. }
  5011. // Do executes the "gmail.users.messages.insert" call.
  5012. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5013. // code is an error. Response headers are in either
  5014. // *Message.ServerResponse.Header or (if a response was returned at all)
  5015. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5016. // check whether the returned error was because http.StatusNotModified
  5017. // was returned.
  5018. func (c *UsersMessagesInsertCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5019. gensupport.SetOptions(c.urlParams_, opts...)
  5020. res, err := c.doRequest("json")
  5021. if res != nil && res.StatusCode == http.StatusNotModified {
  5022. if res.Body != nil {
  5023. res.Body.Close()
  5024. }
  5025. return nil, &googleapi.Error{
  5026. Code: res.StatusCode,
  5027. Header: res.Header,
  5028. }
  5029. }
  5030. if err != nil {
  5031. return nil, err
  5032. }
  5033. defer googleapi.CloseBody(res)
  5034. if err := googleapi.CheckResponse(res); err != nil {
  5035. return nil, err
  5036. }
  5037. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  5038. if rx != nil {
  5039. rx.Client = c.s.client
  5040. rx.UserAgent = c.s.userAgent()
  5041. ctx := c.ctx_
  5042. if ctx == nil {
  5043. ctx = context.TODO()
  5044. }
  5045. res, err = rx.Upload(ctx)
  5046. if err != nil {
  5047. return nil, err
  5048. }
  5049. defer res.Body.Close()
  5050. if err := googleapi.CheckResponse(res); err != nil {
  5051. return nil, err
  5052. }
  5053. }
  5054. ret := &Message{
  5055. ServerResponse: googleapi.ServerResponse{
  5056. Header: res.Header,
  5057. HTTPStatusCode: res.StatusCode,
  5058. },
  5059. }
  5060. target := &ret
  5061. if err := gensupport.DecodeResponse(target, res); err != nil {
  5062. return nil, err
  5063. }
  5064. return ret, nil
  5065. // {
  5066. // "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.",
  5067. // "httpMethod": "POST",
  5068. // "id": "gmail.users.messages.insert",
  5069. // "mediaUpload": {
  5070. // "accept": [
  5071. // "message/rfc822"
  5072. // ],
  5073. // "maxSize": "50MB",
  5074. // "protocols": {
  5075. // "resumable": {
  5076. // "multipart": true,
  5077. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages"
  5078. // },
  5079. // "simple": {
  5080. // "multipart": true,
  5081. // "path": "/upload/gmail/v1/users/{userId}/messages"
  5082. // }
  5083. // }
  5084. // },
  5085. // "parameterOrder": [
  5086. // "userId"
  5087. // ],
  5088. // "parameters": {
  5089. // "deleted": {
  5090. // "default": "false",
  5091. // "description": "Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for G Suite accounts.",
  5092. // "location": "query",
  5093. // "type": "boolean"
  5094. // },
  5095. // "internalDateSource": {
  5096. // "default": "receivedTime",
  5097. // "description": "Source for Gmail's internal date of the message.",
  5098. // "enum": [
  5099. // "dateHeader",
  5100. // "receivedTime"
  5101. // ],
  5102. // "enumDescriptions": [
  5103. // "",
  5104. // ""
  5105. // ],
  5106. // "location": "query",
  5107. // "type": "string"
  5108. // },
  5109. // "userId": {
  5110. // "default": "me",
  5111. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5112. // "location": "path",
  5113. // "required": true,
  5114. // "type": "string"
  5115. // }
  5116. // },
  5117. // "path": "{userId}/messages",
  5118. // "request": {
  5119. // "$ref": "Message"
  5120. // },
  5121. // "response": {
  5122. // "$ref": "Message"
  5123. // },
  5124. // "scopes": [
  5125. // "https://mail.google.com/",
  5126. // "https://www.googleapis.com/auth/gmail.insert",
  5127. // "https://www.googleapis.com/auth/gmail.modify"
  5128. // ],
  5129. // "supportsMediaUpload": true
  5130. // }
  5131. }
  5132. // method id "gmail.users.messages.list":
  5133. type UsersMessagesListCall struct {
  5134. s *Service
  5135. userId string
  5136. urlParams_ gensupport.URLParams
  5137. ifNoneMatch_ string
  5138. ctx_ context.Context
  5139. header_ http.Header
  5140. }
  5141. // List: Lists the messages in the user's mailbox.
  5142. func (r *UsersMessagesService) List(userId string) *UsersMessagesListCall {
  5143. c := &UsersMessagesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5144. c.userId = userId
  5145. return c
  5146. }
  5147. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  5148. // Include messages from SPAM and TRASH in the results.
  5149. func (c *UsersMessagesListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersMessagesListCall {
  5150. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  5151. return c
  5152. }
  5153. // LabelIds sets the optional parameter "labelIds": Only return messages
  5154. // with labels that match all of the specified label IDs.
  5155. func (c *UsersMessagesListCall) LabelIds(labelIds ...string) *UsersMessagesListCall {
  5156. c.urlParams_.SetMulti("labelIds", append([]string{}, labelIds...))
  5157. return c
  5158. }
  5159. // MaxResults sets the optional parameter "maxResults": Maximum number
  5160. // of messages to return.
  5161. func (c *UsersMessagesListCall) MaxResults(maxResults int64) *UsersMessagesListCall {
  5162. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  5163. return c
  5164. }
  5165. // PageToken sets the optional parameter "pageToken": Page token to
  5166. // retrieve a specific page of results in the list.
  5167. func (c *UsersMessagesListCall) PageToken(pageToken string) *UsersMessagesListCall {
  5168. c.urlParams_.Set("pageToken", pageToken)
  5169. return c
  5170. }
  5171. // Q sets the optional parameter "q": Only return messages matching the
  5172. // specified query. Supports the same query format as the Gmail search
  5173. // box. For example, "from:someuser@example.com
  5174. // rfc822msgid:<somemsgid@example.com> is:unread". Parameter cannot be
  5175. // used when accessing the api using the gmail.metadata scope.
  5176. func (c *UsersMessagesListCall) Q(q string) *UsersMessagesListCall {
  5177. c.urlParams_.Set("q", q)
  5178. return c
  5179. }
  5180. // Fields allows partial responses to be retrieved. See
  5181. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5182. // for more information.
  5183. func (c *UsersMessagesListCall) Fields(s ...googleapi.Field) *UsersMessagesListCall {
  5184. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5185. return c
  5186. }
  5187. // IfNoneMatch sets the optional parameter which makes the operation
  5188. // fail if the object's ETag matches the given value. This is useful for
  5189. // getting updates only after the object has changed since the last
  5190. // request. Use googleapi.IsNotModified to check whether the response
  5191. // error from Do is the result of In-None-Match.
  5192. func (c *UsersMessagesListCall) IfNoneMatch(entityTag string) *UsersMessagesListCall {
  5193. c.ifNoneMatch_ = entityTag
  5194. return c
  5195. }
  5196. // Context sets the context to be used in this call's Do method. Any
  5197. // pending HTTP request will be aborted if the provided context is
  5198. // canceled.
  5199. func (c *UsersMessagesListCall) Context(ctx context.Context) *UsersMessagesListCall {
  5200. c.ctx_ = ctx
  5201. return c
  5202. }
  5203. // Header returns an http.Header that can be modified by the caller to
  5204. // add HTTP headers to the request.
  5205. func (c *UsersMessagesListCall) Header() http.Header {
  5206. if c.header_ == nil {
  5207. c.header_ = make(http.Header)
  5208. }
  5209. return c.header_
  5210. }
  5211. func (c *UsersMessagesListCall) doRequest(alt string) (*http.Response, error) {
  5212. reqHeaders := make(http.Header)
  5213. for k, v := range c.header_ {
  5214. reqHeaders[k] = v
  5215. }
  5216. reqHeaders.Set("User-Agent", c.s.userAgent())
  5217. if c.ifNoneMatch_ != "" {
  5218. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  5219. }
  5220. var body io.Reader = nil
  5221. c.urlParams_.Set("alt", alt)
  5222. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
  5223. urls += "?" + c.urlParams_.Encode()
  5224. req, _ := http.NewRequest("GET", urls, body)
  5225. req.Header = reqHeaders
  5226. googleapi.Expand(req.URL, map[string]string{
  5227. "userId": c.userId,
  5228. })
  5229. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5230. }
  5231. // Do executes the "gmail.users.messages.list" call.
  5232. // Exactly one of *ListMessagesResponse or error will be non-nil. Any
  5233. // non-2xx status code is an error. Response headers are in either
  5234. // *ListMessagesResponse.ServerResponse.Header or (if a response was
  5235. // returned at all) in error.(*googleapi.Error).Header. Use
  5236. // googleapi.IsNotModified to check whether the returned error was
  5237. // because http.StatusNotModified was returned.
  5238. func (c *UsersMessagesListCall) Do(opts ...googleapi.CallOption) (*ListMessagesResponse, error) {
  5239. gensupport.SetOptions(c.urlParams_, opts...)
  5240. res, err := c.doRequest("json")
  5241. if res != nil && res.StatusCode == http.StatusNotModified {
  5242. if res.Body != nil {
  5243. res.Body.Close()
  5244. }
  5245. return nil, &googleapi.Error{
  5246. Code: res.StatusCode,
  5247. Header: res.Header,
  5248. }
  5249. }
  5250. if err != nil {
  5251. return nil, err
  5252. }
  5253. defer googleapi.CloseBody(res)
  5254. if err := googleapi.CheckResponse(res); err != nil {
  5255. return nil, err
  5256. }
  5257. ret := &ListMessagesResponse{
  5258. ServerResponse: googleapi.ServerResponse{
  5259. Header: res.Header,
  5260. HTTPStatusCode: res.StatusCode,
  5261. },
  5262. }
  5263. target := &ret
  5264. if err := gensupport.DecodeResponse(target, res); err != nil {
  5265. return nil, err
  5266. }
  5267. return ret, nil
  5268. // {
  5269. // "description": "Lists the messages in the user's mailbox.",
  5270. // "httpMethod": "GET",
  5271. // "id": "gmail.users.messages.list",
  5272. // "parameterOrder": [
  5273. // "userId"
  5274. // ],
  5275. // "parameters": {
  5276. // "includeSpamTrash": {
  5277. // "default": "false",
  5278. // "description": "Include messages from SPAM and TRASH in the results.",
  5279. // "location": "query",
  5280. // "type": "boolean"
  5281. // },
  5282. // "labelIds": {
  5283. // "description": "Only return messages with labels that match all of the specified label IDs.",
  5284. // "location": "query",
  5285. // "repeated": true,
  5286. // "type": "string"
  5287. // },
  5288. // "maxResults": {
  5289. // "default": "100",
  5290. // "description": "Maximum number of messages to return.",
  5291. // "format": "uint32",
  5292. // "location": "query",
  5293. // "type": "integer"
  5294. // },
  5295. // "pageToken": {
  5296. // "description": "Page token to retrieve a specific page of results in the list.",
  5297. // "location": "query",
  5298. // "type": "string"
  5299. // },
  5300. // "q": {
  5301. // "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:\u003csomemsgid@example.com\u003e is:unread\". Parameter cannot be used when accessing the api using the gmail.metadata scope.",
  5302. // "location": "query",
  5303. // "type": "string"
  5304. // },
  5305. // "userId": {
  5306. // "default": "me",
  5307. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5308. // "location": "path",
  5309. // "required": true,
  5310. // "type": "string"
  5311. // }
  5312. // },
  5313. // "path": "{userId}/messages",
  5314. // "response": {
  5315. // "$ref": "ListMessagesResponse"
  5316. // },
  5317. // "scopes": [
  5318. // "https://mail.google.com/",
  5319. // "https://www.googleapis.com/auth/gmail.metadata",
  5320. // "https://www.googleapis.com/auth/gmail.modify",
  5321. // "https://www.googleapis.com/auth/gmail.readonly"
  5322. // ]
  5323. // }
  5324. }
  5325. // Pages invokes f for each page of results.
  5326. // A non-nil error returned from f will halt the iteration.
  5327. // The provided context supersedes any context provided to the Context method.
  5328. func (c *UsersMessagesListCall) Pages(ctx context.Context, f func(*ListMessagesResponse) error) error {
  5329. c.ctx_ = ctx
  5330. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  5331. for {
  5332. x, err := c.Do()
  5333. if err != nil {
  5334. return err
  5335. }
  5336. if err := f(x); err != nil {
  5337. return err
  5338. }
  5339. if x.NextPageToken == "" {
  5340. return nil
  5341. }
  5342. c.PageToken(x.NextPageToken)
  5343. }
  5344. }
  5345. // method id "gmail.users.messages.modify":
  5346. type UsersMessagesModifyCall struct {
  5347. s *Service
  5348. userId string
  5349. id string
  5350. modifymessagerequest *ModifyMessageRequest
  5351. urlParams_ gensupport.URLParams
  5352. ctx_ context.Context
  5353. header_ http.Header
  5354. }
  5355. // Modify: Modifies the labels on the specified message.
  5356. func (r *UsersMessagesService) Modify(userId string, id string, modifymessagerequest *ModifyMessageRequest) *UsersMessagesModifyCall {
  5357. c := &UsersMessagesModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5358. c.userId = userId
  5359. c.id = id
  5360. c.modifymessagerequest = modifymessagerequest
  5361. return c
  5362. }
  5363. // Fields allows partial responses to be retrieved. See
  5364. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5365. // for more information.
  5366. func (c *UsersMessagesModifyCall) Fields(s ...googleapi.Field) *UsersMessagesModifyCall {
  5367. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5368. return c
  5369. }
  5370. // Context sets the context to be used in this call's Do method. Any
  5371. // pending HTTP request will be aborted if the provided context is
  5372. // canceled.
  5373. func (c *UsersMessagesModifyCall) Context(ctx context.Context) *UsersMessagesModifyCall {
  5374. c.ctx_ = ctx
  5375. return c
  5376. }
  5377. // Header returns an http.Header that can be modified by the caller to
  5378. // add HTTP headers to the request.
  5379. func (c *UsersMessagesModifyCall) Header() http.Header {
  5380. if c.header_ == nil {
  5381. c.header_ = make(http.Header)
  5382. }
  5383. return c.header_
  5384. }
  5385. func (c *UsersMessagesModifyCall) doRequest(alt string) (*http.Response, error) {
  5386. reqHeaders := make(http.Header)
  5387. for k, v := range c.header_ {
  5388. reqHeaders[k] = v
  5389. }
  5390. reqHeaders.Set("User-Agent", c.s.userAgent())
  5391. var body io.Reader = nil
  5392. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifymessagerequest)
  5393. if err != nil {
  5394. return nil, err
  5395. }
  5396. reqHeaders.Set("Content-Type", "application/json")
  5397. c.urlParams_.Set("alt", alt)
  5398. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/modify")
  5399. urls += "?" + c.urlParams_.Encode()
  5400. req, _ := http.NewRequest("POST", urls, body)
  5401. req.Header = reqHeaders
  5402. googleapi.Expand(req.URL, map[string]string{
  5403. "userId": c.userId,
  5404. "id": c.id,
  5405. })
  5406. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5407. }
  5408. // Do executes the "gmail.users.messages.modify" call.
  5409. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5410. // code is an error. Response headers are in either
  5411. // *Message.ServerResponse.Header or (if a response was returned at all)
  5412. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5413. // check whether the returned error was because http.StatusNotModified
  5414. // was returned.
  5415. func (c *UsersMessagesModifyCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5416. gensupport.SetOptions(c.urlParams_, opts...)
  5417. res, err := c.doRequest("json")
  5418. if res != nil && res.StatusCode == http.StatusNotModified {
  5419. if res.Body != nil {
  5420. res.Body.Close()
  5421. }
  5422. return nil, &googleapi.Error{
  5423. Code: res.StatusCode,
  5424. Header: res.Header,
  5425. }
  5426. }
  5427. if err != nil {
  5428. return nil, err
  5429. }
  5430. defer googleapi.CloseBody(res)
  5431. if err := googleapi.CheckResponse(res); err != nil {
  5432. return nil, err
  5433. }
  5434. ret := &Message{
  5435. ServerResponse: googleapi.ServerResponse{
  5436. Header: res.Header,
  5437. HTTPStatusCode: res.StatusCode,
  5438. },
  5439. }
  5440. target := &ret
  5441. if err := gensupport.DecodeResponse(target, res); err != nil {
  5442. return nil, err
  5443. }
  5444. return ret, nil
  5445. // {
  5446. // "description": "Modifies the labels on the specified message.",
  5447. // "httpMethod": "POST",
  5448. // "id": "gmail.users.messages.modify",
  5449. // "parameterOrder": [
  5450. // "userId",
  5451. // "id"
  5452. // ],
  5453. // "parameters": {
  5454. // "id": {
  5455. // "description": "The ID of the message to modify.",
  5456. // "location": "path",
  5457. // "required": true,
  5458. // "type": "string"
  5459. // },
  5460. // "userId": {
  5461. // "default": "me",
  5462. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5463. // "location": "path",
  5464. // "required": true,
  5465. // "type": "string"
  5466. // }
  5467. // },
  5468. // "path": "{userId}/messages/{id}/modify",
  5469. // "request": {
  5470. // "$ref": "ModifyMessageRequest"
  5471. // },
  5472. // "response": {
  5473. // "$ref": "Message"
  5474. // },
  5475. // "scopes": [
  5476. // "https://mail.google.com/",
  5477. // "https://www.googleapis.com/auth/gmail.modify"
  5478. // ]
  5479. // }
  5480. }
  5481. // method id "gmail.users.messages.send":
  5482. type UsersMessagesSendCall struct {
  5483. s *Service
  5484. userId string
  5485. message *Message
  5486. urlParams_ gensupport.URLParams
  5487. mediaInfo_ *gensupport.MediaInfo
  5488. ctx_ context.Context
  5489. header_ http.Header
  5490. }
  5491. // Send: Sends the specified message to the recipients in the To, Cc,
  5492. // and Bcc headers.
  5493. func (r *UsersMessagesService) Send(userId string, message *Message) *UsersMessagesSendCall {
  5494. c := &UsersMessagesSendCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5495. c.userId = userId
  5496. c.message = message
  5497. return c
  5498. }
  5499. // Media specifies the media to upload in one or more chunks. The chunk
  5500. // size may be controlled by supplying a MediaOption generated by
  5501. // googleapi.ChunkSize. The chunk size defaults to
  5502. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  5503. // upload request will be determined by sniffing the contents of r,
  5504. // unless a MediaOption generated by googleapi.ContentType is
  5505. // supplied.
  5506. // At most one of Media and ResumableMedia may be set.
  5507. func (c *UsersMessagesSendCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesSendCall {
  5508. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  5509. return c
  5510. }
  5511. // ResumableMedia specifies the media to upload in chunks and can be
  5512. // canceled with ctx.
  5513. //
  5514. // Deprecated: use Media instead.
  5515. //
  5516. // At most one of Media and ResumableMedia may be set. mediaType
  5517. // identifies the MIME media type of the upload, such as "image/png". If
  5518. // mediaType is "", it will be auto-detected. The provided ctx will
  5519. // supersede any context previously provided to the Context method.
  5520. func (c *UsersMessagesSendCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesSendCall {
  5521. c.ctx_ = ctx
  5522. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  5523. return c
  5524. }
  5525. // ProgressUpdater provides a callback function that will be called
  5526. // after every chunk. It should be a low-latency function in order to
  5527. // not slow down the upload operation. This should only be called when
  5528. // using ResumableMedia (as opposed to Media).
  5529. func (c *UsersMessagesSendCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesSendCall {
  5530. c.mediaInfo_.SetProgressUpdater(pu)
  5531. return c
  5532. }
  5533. // Fields allows partial responses to be retrieved. See
  5534. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5535. // for more information.
  5536. func (c *UsersMessagesSendCall) Fields(s ...googleapi.Field) *UsersMessagesSendCall {
  5537. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5538. return c
  5539. }
  5540. // Context sets the context to be used in this call's Do method. Any
  5541. // pending HTTP request will be aborted if the provided context is
  5542. // canceled.
  5543. // This context will supersede any context previously provided to the
  5544. // ResumableMedia method.
  5545. func (c *UsersMessagesSendCall) Context(ctx context.Context) *UsersMessagesSendCall {
  5546. c.ctx_ = ctx
  5547. return c
  5548. }
  5549. // Header returns an http.Header that can be modified by the caller to
  5550. // add HTTP headers to the request.
  5551. func (c *UsersMessagesSendCall) Header() http.Header {
  5552. if c.header_ == nil {
  5553. c.header_ = make(http.Header)
  5554. }
  5555. return c.header_
  5556. }
  5557. func (c *UsersMessagesSendCall) doRequest(alt string) (*http.Response, error) {
  5558. reqHeaders := make(http.Header)
  5559. for k, v := range c.header_ {
  5560. reqHeaders[k] = v
  5561. }
  5562. reqHeaders.Set("User-Agent", c.s.userAgent())
  5563. var body io.Reader = nil
  5564. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  5565. if err != nil {
  5566. return nil, err
  5567. }
  5568. reqHeaders.Set("Content-Type", "application/json")
  5569. c.urlParams_.Set("alt", alt)
  5570. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/send")
  5571. if c.mediaInfo_ != nil {
  5572. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  5573. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  5574. }
  5575. if body == nil {
  5576. body = new(bytes.Buffer)
  5577. reqHeaders.Set("Content-Type", "application/json")
  5578. }
  5579. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  5580. defer cleanup()
  5581. urls += "?" + c.urlParams_.Encode()
  5582. req, _ := http.NewRequest("POST", urls, body)
  5583. req.Header = reqHeaders
  5584. gensupport.SetGetBody(req, getBody)
  5585. googleapi.Expand(req.URL, map[string]string{
  5586. "userId": c.userId,
  5587. })
  5588. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5589. }
  5590. // Do executes the "gmail.users.messages.send" call.
  5591. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5592. // code is an error. Response headers are in either
  5593. // *Message.ServerResponse.Header or (if a response was returned at all)
  5594. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5595. // check whether the returned error was because http.StatusNotModified
  5596. // was returned.
  5597. func (c *UsersMessagesSendCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5598. gensupport.SetOptions(c.urlParams_, opts...)
  5599. res, err := c.doRequest("json")
  5600. if res != nil && res.StatusCode == http.StatusNotModified {
  5601. if res.Body != nil {
  5602. res.Body.Close()
  5603. }
  5604. return nil, &googleapi.Error{
  5605. Code: res.StatusCode,
  5606. Header: res.Header,
  5607. }
  5608. }
  5609. if err != nil {
  5610. return nil, err
  5611. }
  5612. defer googleapi.CloseBody(res)
  5613. if err := googleapi.CheckResponse(res); err != nil {
  5614. return nil, err
  5615. }
  5616. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  5617. if rx != nil {
  5618. rx.Client = c.s.client
  5619. rx.UserAgent = c.s.userAgent()
  5620. ctx := c.ctx_
  5621. if ctx == nil {
  5622. ctx = context.TODO()
  5623. }
  5624. res, err = rx.Upload(ctx)
  5625. if err != nil {
  5626. return nil, err
  5627. }
  5628. defer res.Body.Close()
  5629. if err := googleapi.CheckResponse(res); err != nil {
  5630. return nil, err
  5631. }
  5632. }
  5633. ret := &Message{
  5634. ServerResponse: googleapi.ServerResponse{
  5635. Header: res.Header,
  5636. HTTPStatusCode: res.StatusCode,
  5637. },
  5638. }
  5639. target := &ret
  5640. if err := gensupport.DecodeResponse(target, res); err != nil {
  5641. return nil, err
  5642. }
  5643. return ret, nil
  5644. // {
  5645. // "description": "Sends the specified message to the recipients in the To, Cc, and Bcc headers.",
  5646. // "httpMethod": "POST",
  5647. // "id": "gmail.users.messages.send",
  5648. // "mediaUpload": {
  5649. // "accept": [
  5650. // "message/rfc822"
  5651. // ],
  5652. // "maxSize": "35MB",
  5653. // "protocols": {
  5654. // "resumable": {
  5655. // "multipart": true,
  5656. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages/send"
  5657. // },
  5658. // "simple": {
  5659. // "multipart": true,
  5660. // "path": "/upload/gmail/v1/users/{userId}/messages/send"
  5661. // }
  5662. // }
  5663. // },
  5664. // "parameterOrder": [
  5665. // "userId"
  5666. // ],
  5667. // "parameters": {
  5668. // "userId": {
  5669. // "default": "me",
  5670. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5671. // "location": "path",
  5672. // "required": true,
  5673. // "type": "string"
  5674. // }
  5675. // },
  5676. // "path": "{userId}/messages/send",
  5677. // "request": {
  5678. // "$ref": "Message"
  5679. // },
  5680. // "response": {
  5681. // "$ref": "Message"
  5682. // },
  5683. // "scopes": [
  5684. // "https://mail.google.com/",
  5685. // "https://www.googleapis.com/auth/gmail.compose",
  5686. // "https://www.googleapis.com/auth/gmail.modify",
  5687. // "https://www.googleapis.com/auth/gmail.send"
  5688. // ],
  5689. // "supportsMediaUpload": true
  5690. // }
  5691. }
  5692. // method id "gmail.users.messages.trash":
  5693. type UsersMessagesTrashCall struct {
  5694. s *Service
  5695. userId string
  5696. id string
  5697. urlParams_ gensupport.URLParams
  5698. ctx_ context.Context
  5699. header_ http.Header
  5700. }
  5701. // Trash: Moves the specified message to the trash.
  5702. func (r *UsersMessagesService) Trash(userId string, id string) *UsersMessagesTrashCall {
  5703. c := &UsersMessagesTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5704. c.userId = userId
  5705. c.id = id
  5706. return c
  5707. }
  5708. // Fields allows partial responses to be retrieved. See
  5709. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5710. // for more information.
  5711. func (c *UsersMessagesTrashCall) Fields(s ...googleapi.Field) *UsersMessagesTrashCall {
  5712. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5713. return c
  5714. }
  5715. // Context sets the context to be used in this call's Do method. Any
  5716. // pending HTTP request will be aborted if the provided context is
  5717. // canceled.
  5718. func (c *UsersMessagesTrashCall) Context(ctx context.Context) *UsersMessagesTrashCall {
  5719. c.ctx_ = ctx
  5720. return c
  5721. }
  5722. // Header returns an http.Header that can be modified by the caller to
  5723. // add HTTP headers to the request.
  5724. func (c *UsersMessagesTrashCall) Header() http.Header {
  5725. if c.header_ == nil {
  5726. c.header_ = make(http.Header)
  5727. }
  5728. return c.header_
  5729. }
  5730. func (c *UsersMessagesTrashCall) doRequest(alt string) (*http.Response, error) {
  5731. reqHeaders := make(http.Header)
  5732. for k, v := range c.header_ {
  5733. reqHeaders[k] = v
  5734. }
  5735. reqHeaders.Set("User-Agent", c.s.userAgent())
  5736. var body io.Reader = nil
  5737. c.urlParams_.Set("alt", alt)
  5738. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/trash")
  5739. urls += "?" + c.urlParams_.Encode()
  5740. req, _ := http.NewRequest("POST", urls, body)
  5741. req.Header = reqHeaders
  5742. googleapi.Expand(req.URL, map[string]string{
  5743. "userId": c.userId,
  5744. "id": c.id,
  5745. })
  5746. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5747. }
  5748. // Do executes the "gmail.users.messages.trash" call.
  5749. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5750. // code is an error. Response headers are in either
  5751. // *Message.ServerResponse.Header or (if a response was returned at all)
  5752. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5753. // check whether the returned error was because http.StatusNotModified
  5754. // was returned.
  5755. func (c *UsersMessagesTrashCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5756. gensupport.SetOptions(c.urlParams_, opts...)
  5757. res, err := c.doRequest("json")
  5758. if res != nil && res.StatusCode == http.StatusNotModified {
  5759. if res.Body != nil {
  5760. res.Body.Close()
  5761. }
  5762. return nil, &googleapi.Error{
  5763. Code: res.StatusCode,
  5764. Header: res.Header,
  5765. }
  5766. }
  5767. if err != nil {
  5768. return nil, err
  5769. }
  5770. defer googleapi.CloseBody(res)
  5771. if err := googleapi.CheckResponse(res); err != nil {
  5772. return nil, err
  5773. }
  5774. ret := &Message{
  5775. ServerResponse: googleapi.ServerResponse{
  5776. Header: res.Header,
  5777. HTTPStatusCode: res.StatusCode,
  5778. },
  5779. }
  5780. target := &ret
  5781. if err := gensupport.DecodeResponse(target, res); err != nil {
  5782. return nil, err
  5783. }
  5784. return ret, nil
  5785. // {
  5786. // "description": "Moves the specified message to the trash.",
  5787. // "httpMethod": "POST",
  5788. // "id": "gmail.users.messages.trash",
  5789. // "parameterOrder": [
  5790. // "userId",
  5791. // "id"
  5792. // ],
  5793. // "parameters": {
  5794. // "id": {
  5795. // "description": "The ID of the message to Trash.",
  5796. // "location": "path",
  5797. // "required": true,
  5798. // "type": "string"
  5799. // },
  5800. // "userId": {
  5801. // "default": "me",
  5802. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5803. // "location": "path",
  5804. // "required": true,
  5805. // "type": "string"
  5806. // }
  5807. // },
  5808. // "path": "{userId}/messages/{id}/trash",
  5809. // "response": {
  5810. // "$ref": "Message"
  5811. // },
  5812. // "scopes": [
  5813. // "https://mail.google.com/",
  5814. // "https://www.googleapis.com/auth/gmail.modify"
  5815. // ]
  5816. // }
  5817. }
  5818. // method id "gmail.users.messages.untrash":
  5819. type UsersMessagesUntrashCall struct {
  5820. s *Service
  5821. userId string
  5822. id string
  5823. urlParams_ gensupport.URLParams
  5824. ctx_ context.Context
  5825. header_ http.Header
  5826. }
  5827. // Untrash: Removes the specified message from the trash.
  5828. func (r *UsersMessagesService) Untrash(userId string, id string) *UsersMessagesUntrashCall {
  5829. c := &UsersMessagesUntrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5830. c.userId = userId
  5831. c.id = id
  5832. return c
  5833. }
  5834. // Fields allows partial responses to be retrieved. See
  5835. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5836. // for more information.
  5837. func (c *UsersMessagesUntrashCall) Fields(s ...googleapi.Field) *UsersMessagesUntrashCall {
  5838. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5839. return c
  5840. }
  5841. // Context sets the context to be used in this call's Do method. Any
  5842. // pending HTTP request will be aborted if the provided context is
  5843. // canceled.
  5844. func (c *UsersMessagesUntrashCall) Context(ctx context.Context) *UsersMessagesUntrashCall {
  5845. c.ctx_ = ctx
  5846. return c
  5847. }
  5848. // Header returns an http.Header that can be modified by the caller to
  5849. // add HTTP headers to the request.
  5850. func (c *UsersMessagesUntrashCall) Header() http.Header {
  5851. if c.header_ == nil {
  5852. c.header_ = make(http.Header)
  5853. }
  5854. return c.header_
  5855. }
  5856. func (c *UsersMessagesUntrashCall) doRequest(alt string) (*http.Response, error) {
  5857. reqHeaders := make(http.Header)
  5858. for k, v := range c.header_ {
  5859. reqHeaders[k] = v
  5860. }
  5861. reqHeaders.Set("User-Agent", c.s.userAgent())
  5862. var body io.Reader = nil
  5863. c.urlParams_.Set("alt", alt)
  5864. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/untrash")
  5865. urls += "?" + c.urlParams_.Encode()
  5866. req, _ := http.NewRequest("POST", urls, body)
  5867. req.Header = reqHeaders
  5868. googleapi.Expand(req.URL, map[string]string{
  5869. "userId": c.userId,
  5870. "id": c.id,
  5871. })
  5872. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5873. }
  5874. // Do executes the "gmail.users.messages.untrash" call.
  5875. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5876. // code is an error. Response headers are in either
  5877. // *Message.ServerResponse.Header or (if a response was returned at all)
  5878. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5879. // check whether the returned error was because http.StatusNotModified
  5880. // was returned.
  5881. func (c *UsersMessagesUntrashCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5882. gensupport.SetOptions(c.urlParams_, opts...)
  5883. res, err := c.doRequest("json")
  5884. if res != nil && res.StatusCode == http.StatusNotModified {
  5885. if res.Body != nil {
  5886. res.Body.Close()
  5887. }
  5888. return nil, &googleapi.Error{
  5889. Code: res.StatusCode,
  5890. Header: res.Header,
  5891. }
  5892. }
  5893. if err != nil {
  5894. return nil, err
  5895. }
  5896. defer googleapi.CloseBody(res)
  5897. if err := googleapi.CheckResponse(res); err != nil {
  5898. return nil, err
  5899. }
  5900. ret := &Message{
  5901. ServerResponse: googleapi.ServerResponse{
  5902. Header: res.Header,
  5903. HTTPStatusCode: res.StatusCode,
  5904. },
  5905. }
  5906. target := &ret
  5907. if err := gensupport.DecodeResponse(target, res); err != nil {
  5908. return nil, err
  5909. }
  5910. return ret, nil
  5911. // {
  5912. // "description": "Removes the specified message from the trash.",
  5913. // "httpMethod": "POST",
  5914. // "id": "gmail.users.messages.untrash",
  5915. // "parameterOrder": [
  5916. // "userId",
  5917. // "id"
  5918. // ],
  5919. // "parameters": {
  5920. // "id": {
  5921. // "description": "The ID of the message to remove from Trash.",
  5922. // "location": "path",
  5923. // "required": true,
  5924. // "type": "string"
  5925. // },
  5926. // "userId": {
  5927. // "default": "me",
  5928. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5929. // "location": "path",
  5930. // "required": true,
  5931. // "type": "string"
  5932. // }
  5933. // },
  5934. // "path": "{userId}/messages/{id}/untrash",
  5935. // "response": {
  5936. // "$ref": "Message"
  5937. // },
  5938. // "scopes": [
  5939. // "https://mail.google.com/",
  5940. // "https://www.googleapis.com/auth/gmail.modify"
  5941. // ]
  5942. // }
  5943. }
  5944. // method id "gmail.users.messages.attachments.get":
  5945. type UsersMessagesAttachmentsGetCall struct {
  5946. s *Service
  5947. userId string
  5948. messageId string
  5949. id string
  5950. urlParams_ gensupport.URLParams
  5951. ifNoneMatch_ string
  5952. ctx_ context.Context
  5953. header_ http.Header
  5954. }
  5955. // Get: Gets the specified message attachment.
  5956. func (r *UsersMessagesAttachmentsService) Get(userId string, messageId string, id string) *UsersMessagesAttachmentsGetCall {
  5957. c := &UsersMessagesAttachmentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5958. c.userId = userId
  5959. c.messageId = messageId
  5960. c.id = id
  5961. return c
  5962. }
  5963. // Fields allows partial responses to be retrieved. See
  5964. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5965. // for more information.
  5966. func (c *UsersMessagesAttachmentsGetCall) Fields(s ...googleapi.Field) *UsersMessagesAttachmentsGetCall {
  5967. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5968. return c
  5969. }
  5970. // IfNoneMatch sets the optional parameter which makes the operation
  5971. // fail if the object's ETag matches the given value. This is useful for
  5972. // getting updates only after the object has changed since the last
  5973. // request. Use googleapi.IsNotModified to check whether the response
  5974. // error from Do is the result of In-None-Match.
  5975. func (c *UsersMessagesAttachmentsGetCall) IfNoneMatch(entityTag string) *UsersMessagesAttachmentsGetCall {
  5976. c.ifNoneMatch_ = entityTag
  5977. return c
  5978. }
  5979. // Context sets the context to be used in this call's Do method. Any
  5980. // pending HTTP request will be aborted if the provided context is
  5981. // canceled.
  5982. func (c *UsersMessagesAttachmentsGetCall) Context(ctx context.Context) *UsersMessagesAttachmentsGetCall {
  5983. c.ctx_ = ctx
  5984. return c
  5985. }
  5986. // Header returns an http.Header that can be modified by the caller to
  5987. // add HTTP headers to the request.
  5988. func (c *UsersMessagesAttachmentsGetCall) Header() http.Header {
  5989. if c.header_ == nil {
  5990. c.header_ = make(http.Header)
  5991. }
  5992. return c.header_
  5993. }
  5994. func (c *UsersMessagesAttachmentsGetCall) doRequest(alt string) (*http.Response, error) {
  5995. reqHeaders := make(http.Header)
  5996. for k, v := range c.header_ {
  5997. reqHeaders[k] = v
  5998. }
  5999. reqHeaders.Set("User-Agent", c.s.userAgent())
  6000. if c.ifNoneMatch_ != "" {
  6001. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6002. }
  6003. var body io.Reader = nil
  6004. c.urlParams_.Set("alt", alt)
  6005. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{messageId}/attachments/{id}")
  6006. urls += "?" + c.urlParams_.Encode()
  6007. req, _ := http.NewRequest("GET", urls, body)
  6008. req.Header = reqHeaders
  6009. googleapi.Expand(req.URL, map[string]string{
  6010. "userId": c.userId,
  6011. "messageId": c.messageId,
  6012. "id": c.id,
  6013. })
  6014. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6015. }
  6016. // Do executes the "gmail.users.messages.attachments.get" call.
  6017. // Exactly one of *MessagePartBody or error will be non-nil. Any non-2xx
  6018. // status code is an error. Response headers are in either
  6019. // *MessagePartBody.ServerResponse.Header or (if a response was returned
  6020. // at all) in error.(*googleapi.Error).Header. Use
  6021. // googleapi.IsNotModified to check whether the returned error was
  6022. // because http.StatusNotModified was returned.
  6023. func (c *UsersMessagesAttachmentsGetCall) Do(opts ...googleapi.CallOption) (*MessagePartBody, error) {
  6024. gensupport.SetOptions(c.urlParams_, opts...)
  6025. res, err := c.doRequest("json")
  6026. if res != nil && res.StatusCode == http.StatusNotModified {
  6027. if res.Body != nil {
  6028. res.Body.Close()
  6029. }
  6030. return nil, &googleapi.Error{
  6031. Code: res.StatusCode,
  6032. Header: res.Header,
  6033. }
  6034. }
  6035. if err != nil {
  6036. return nil, err
  6037. }
  6038. defer googleapi.CloseBody(res)
  6039. if err := googleapi.CheckResponse(res); err != nil {
  6040. return nil, err
  6041. }
  6042. ret := &MessagePartBody{
  6043. ServerResponse: googleapi.ServerResponse{
  6044. Header: res.Header,
  6045. HTTPStatusCode: res.StatusCode,
  6046. },
  6047. }
  6048. target := &ret
  6049. if err := gensupport.DecodeResponse(target, res); err != nil {
  6050. return nil, err
  6051. }
  6052. return ret, nil
  6053. // {
  6054. // "description": "Gets the specified message attachment.",
  6055. // "httpMethod": "GET",
  6056. // "id": "gmail.users.messages.attachments.get",
  6057. // "parameterOrder": [
  6058. // "userId",
  6059. // "messageId",
  6060. // "id"
  6061. // ],
  6062. // "parameters": {
  6063. // "id": {
  6064. // "description": "The ID of the attachment.",
  6065. // "location": "path",
  6066. // "required": true,
  6067. // "type": "string"
  6068. // },
  6069. // "messageId": {
  6070. // "description": "The ID of the message containing the attachment.",
  6071. // "location": "path",
  6072. // "required": true,
  6073. // "type": "string"
  6074. // },
  6075. // "userId": {
  6076. // "default": "me",
  6077. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  6078. // "location": "path",
  6079. // "required": true,
  6080. // "type": "string"
  6081. // }
  6082. // },
  6083. // "path": "{userId}/messages/{messageId}/attachments/{id}",
  6084. // "response": {
  6085. // "$ref": "MessagePartBody"
  6086. // },
  6087. // "scopes": [
  6088. // "https://mail.google.com/",
  6089. // "https://www.googleapis.com/auth/gmail.modify",
  6090. // "https://www.googleapis.com/auth/gmail.readonly"
  6091. // ]
  6092. // }
  6093. }
  6094. // method id "gmail.users.settings.getAutoForwarding":
  6095. type UsersSettingsGetAutoForwardingCall struct {
  6096. s *Service
  6097. userId string
  6098. urlParams_ gensupport.URLParams
  6099. ifNoneMatch_ string
  6100. ctx_ context.Context
  6101. header_ http.Header
  6102. }
  6103. // GetAutoForwarding: Gets the auto-forwarding setting for the specified
  6104. // account.
  6105. func (r *UsersSettingsService) GetAutoForwarding(userId string) *UsersSettingsGetAutoForwardingCall {
  6106. c := &UsersSettingsGetAutoForwardingCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6107. c.userId = userId
  6108. return c
  6109. }
  6110. // Fields allows partial responses to be retrieved. See
  6111. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6112. // for more information.
  6113. func (c *UsersSettingsGetAutoForwardingCall) Fields(s ...googleapi.Field) *UsersSettingsGetAutoForwardingCall {
  6114. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6115. return c
  6116. }
  6117. // IfNoneMatch sets the optional parameter which makes the operation
  6118. // fail if the object's ETag matches the given value. This is useful for
  6119. // getting updates only after the object has changed since the last
  6120. // request. Use googleapi.IsNotModified to check whether the response
  6121. // error from Do is the result of In-None-Match.
  6122. func (c *UsersSettingsGetAutoForwardingCall) IfNoneMatch(entityTag string) *UsersSettingsGetAutoForwardingCall {
  6123. c.ifNoneMatch_ = entityTag
  6124. return c
  6125. }
  6126. // Context sets the context to be used in this call's Do method. Any
  6127. // pending HTTP request will be aborted if the provided context is
  6128. // canceled.
  6129. func (c *UsersSettingsGetAutoForwardingCall) Context(ctx context.Context) *UsersSettingsGetAutoForwardingCall {
  6130. c.ctx_ = ctx
  6131. return c
  6132. }
  6133. // Header returns an http.Header that can be modified by the caller to
  6134. // add HTTP headers to the request.
  6135. func (c *UsersSettingsGetAutoForwardingCall) Header() http.Header {
  6136. if c.header_ == nil {
  6137. c.header_ = make(http.Header)
  6138. }
  6139. return c.header_
  6140. }
  6141. func (c *UsersSettingsGetAutoForwardingCall) doRequest(alt string) (*http.Response, error) {
  6142. reqHeaders := make(http.Header)
  6143. for k, v := range c.header_ {
  6144. reqHeaders[k] = v
  6145. }
  6146. reqHeaders.Set("User-Agent", c.s.userAgent())
  6147. if c.ifNoneMatch_ != "" {
  6148. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6149. }
  6150. var body io.Reader = nil
  6151. c.urlParams_.Set("alt", alt)
  6152. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/autoForwarding")
  6153. urls += "?" + c.urlParams_.Encode()
  6154. req, _ := http.NewRequest("GET", urls, body)
  6155. req.Header = reqHeaders
  6156. googleapi.Expand(req.URL, map[string]string{
  6157. "userId": c.userId,
  6158. })
  6159. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6160. }
  6161. // Do executes the "gmail.users.settings.getAutoForwarding" call.
  6162. // Exactly one of *AutoForwarding or error will be non-nil. Any non-2xx
  6163. // status code is an error. Response headers are in either
  6164. // *AutoForwarding.ServerResponse.Header or (if a response was returned
  6165. // at all) in error.(*googleapi.Error).Header. Use
  6166. // googleapi.IsNotModified to check whether the returned error was
  6167. // because http.StatusNotModified was returned.
  6168. func (c *UsersSettingsGetAutoForwardingCall) Do(opts ...googleapi.CallOption) (*AutoForwarding, error) {
  6169. gensupport.SetOptions(c.urlParams_, opts...)
  6170. res, err := c.doRequest("json")
  6171. if res != nil && res.StatusCode == http.StatusNotModified {
  6172. if res.Body != nil {
  6173. res.Body.Close()
  6174. }
  6175. return nil, &googleapi.Error{
  6176. Code: res.StatusCode,
  6177. Header: res.Header,
  6178. }
  6179. }
  6180. if err != nil {
  6181. return nil, err
  6182. }
  6183. defer googleapi.CloseBody(res)
  6184. if err := googleapi.CheckResponse(res); err != nil {
  6185. return nil, err
  6186. }
  6187. ret := &AutoForwarding{
  6188. ServerResponse: googleapi.ServerResponse{
  6189. Header: res.Header,
  6190. HTTPStatusCode: res.StatusCode,
  6191. },
  6192. }
  6193. target := &ret
  6194. if err := gensupport.DecodeResponse(target, res); err != nil {
  6195. return nil, err
  6196. }
  6197. return ret, nil
  6198. // {
  6199. // "description": "Gets the auto-forwarding setting for the specified account.",
  6200. // "httpMethod": "GET",
  6201. // "id": "gmail.users.settings.getAutoForwarding",
  6202. // "parameterOrder": [
  6203. // "userId"
  6204. // ],
  6205. // "parameters": {
  6206. // "userId": {
  6207. // "default": "me",
  6208. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6209. // "location": "path",
  6210. // "required": true,
  6211. // "type": "string"
  6212. // }
  6213. // },
  6214. // "path": "{userId}/settings/autoForwarding",
  6215. // "response": {
  6216. // "$ref": "AutoForwarding"
  6217. // },
  6218. // "scopes": [
  6219. // "https://mail.google.com/",
  6220. // "https://www.googleapis.com/auth/gmail.modify",
  6221. // "https://www.googleapis.com/auth/gmail.readonly",
  6222. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6223. // ]
  6224. // }
  6225. }
  6226. // method id "gmail.users.settings.getImap":
  6227. type UsersSettingsGetImapCall struct {
  6228. s *Service
  6229. userId string
  6230. urlParams_ gensupport.URLParams
  6231. ifNoneMatch_ string
  6232. ctx_ context.Context
  6233. header_ http.Header
  6234. }
  6235. // GetImap: Gets IMAP settings.
  6236. func (r *UsersSettingsService) GetImap(userId string) *UsersSettingsGetImapCall {
  6237. c := &UsersSettingsGetImapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6238. c.userId = userId
  6239. return c
  6240. }
  6241. // Fields allows partial responses to be retrieved. See
  6242. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6243. // for more information.
  6244. func (c *UsersSettingsGetImapCall) Fields(s ...googleapi.Field) *UsersSettingsGetImapCall {
  6245. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6246. return c
  6247. }
  6248. // IfNoneMatch sets the optional parameter which makes the operation
  6249. // fail if the object's ETag matches the given value. This is useful for
  6250. // getting updates only after the object has changed since the last
  6251. // request. Use googleapi.IsNotModified to check whether the response
  6252. // error from Do is the result of In-None-Match.
  6253. func (c *UsersSettingsGetImapCall) IfNoneMatch(entityTag string) *UsersSettingsGetImapCall {
  6254. c.ifNoneMatch_ = entityTag
  6255. return c
  6256. }
  6257. // Context sets the context to be used in this call's Do method. Any
  6258. // pending HTTP request will be aborted if the provided context is
  6259. // canceled.
  6260. func (c *UsersSettingsGetImapCall) Context(ctx context.Context) *UsersSettingsGetImapCall {
  6261. c.ctx_ = ctx
  6262. return c
  6263. }
  6264. // Header returns an http.Header that can be modified by the caller to
  6265. // add HTTP headers to the request.
  6266. func (c *UsersSettingsGetImapCall) Header() http.Header {
  6267. if c.header_ == nil {
  6268. c.header_ = make(http.Header)
  6269. }
  6270. return c.header_
  6271. }
  6272. func (c *UsersSettingsGetImapCall) doRequest(alt string) (*http.Response, error) {
  6273. reqHeaders := make(http.Header)
  6274. for k, v := range c.header_ {
  6275. reqHeaders[k] = v
  6276. }
  6277. reqHeaders.Set("User-Agent", c.s.userAgent())
  6278. if c.ifNoneMatch_ != "" {
  6279. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6280. }
  6281. var body io.Reader = nil
  6282. c.urlParams_.Set("alt", alt)
  6283. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/imap")
  6284. urls += "?" + c.urlParams_.Encode()
  6285. req, _ := http.NewRequest("GET", urls, body)
  6286. req.Header = reqHeaders
  6287. googleapi.Expand(req.URL, map[string]string{
  6288. "userId": c.userId,
  6289. })
  6290. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6291. }
  6292. // Do executes the "gmail.users.settings.getImap" call.
  6293. // Exactly one of *ImapSettings or error will be non-nil. Any non-2xx
  6294. // status code is an error. Response headers are in either
  6295. // *ImapSettings.ServerResponse.Header or (if a response was returned at
  6296. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  6297. // to check whether the returned error was because
  6298. // http.StatusNotModified was returned.
  6299. func (c *UsersSettingsGetImapCall) Do(opts ...googleapi.CallOption) (*ImapSettings, error) {
  6300. gensupport.SetOptions(c.urlParams_, opts...)
  6301. res, err := c.doRequest("json")
  6302. if res != nil && res.StatusCode == http.StatusNotModified {
  6303. if res.Body != nil {
  6304. res.Body.Close()
  6305. }
  6306. return nil, &googleapi.Error{
  6307. Code: res.StatusCode,
  6308. Header: res.Header,
  6309. }
  6310. }
  6311. if err != nil {
  6312. return nil, err
  6313. }
  6314. defer googleapi.CloseBody(res)
  6315. if err := googleapi.CheckResponse(res); err != nil {
  6316. return nil, err
  6317. }
  6318. ret := &ImapSettings{
  6319. ServerResponse: googleapi.ServerResponse{
  6320. Header: res.Header,
  6321. HTTPStatusCode: res.StatusCode,
  6322. },
  6323. }
  6324. target := &ret
  6325. if err := gensupport.DecodeResponse(target, res); err != nil {
  6326. return nil, err
  6327. }
  6328. return ret, nil
  6329. // {
  6330. // "description": "Gets IMAP settings.",
  6331. // "httpMethod": "GET",
  6332. // "id": "gmail.users.settings.getImap",
  6333. // "parameterOrder": [
  6334. // "userId"
  6335. // ],
  6336. // "parameters": {
  6337. // "userId": {
  6338. // "default": "me",
  6339. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6340. // "location": "path",
  6341. // "required": true,
  6342. // "type": "string"
  6343. // }
  6344. // },
  6345. // "path": "{userId}/settings/imap",
  6346. // "response": {
  6347. // "$ref": "ImapSettings"
  6348. // },
  6349. // "scopes": [
  6350. // "https://mail.google.com/",
  6351. // "https://www.googleapis.com/auth/gmail.modify",
  6352. // "https://www.googleapis.com/auth/gmail.readonly",
  6353. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6354. // ]
  6355. // }
  6356. }
  6357. // method id "gmail.users.settings.getPop":
  6358. type UsersSettingsGetPopCall struct {
  6359. s *Service
  6360. userId string
  6361. urlParams_ gensupport.URLParams
  6362. ifNoneMatch_ string
  6363. ctx_ context.Context
  6364. header_ http.Header
  6365. }
  6366. // GetPop: Gets POP settings.
  6367. func (r *UsersSettingsService) GetPop(userId string) *UsersSettingsGetPopCall {
  6368. c := &UsersSettingsGetPopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6369. c.userId = userId
  6370. return c
  6371. }
  6372. // Fields allows partial responses to be retrieved. See
  6373. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6374. // for more information.
  6375. func (c *UsersSettingsGetPopCall) Fields(s ...googleapi.Field) *UsersSettingsGetPopCall {
  6376. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6377. return c
  6378. }
  6379. // IfNoneMatch sets the optional parameter which makes the operation
  6380. // fail if the object's ETag matches the given value. This is useful for
  6381. // getting updates only after the object has changed since the last
  6382. // request. Use googleapi.IsNotModified to check whether the response
  6383. // error from Do is the result of In-None-Match.
  6384. func (c *UsersSettingsGetPopCall) IfNoneMatch(entityTag string) *UsersSettingsGetPopCall {
  6385. c.ifNoneMatch_ = entityTag
  6386. return c
  6387. }
  6388. // Context sets the context to be used in this call's Do method. Any
  6389. // pending HTTP request will be aborted if the provided context is
  6390. // canceled.
  6391. func (c *UsersSettingsGetPopCall) Context(ctx context.Context) *UsersSettingsGetPopCall {
  6392. c.ctx_ = ctx
  6393. return c
  6394. }
  6395. // Header returns an http.Header that can be modified by the caller to
  6396. // add HTTP headers to the request.
  6397. func (c *UsersSettingsGetPopCall) Header() http.Header {
  6398. if c.header_ == nil {
  6399. c.header_ = make(http.Header)
  6400. }
  6401. return c.header_
  6402. }
  6403. func (c *UsersSettingsGetPopCall) doRequest(alt string) (*http.Response, error) {
  6404. reqHeaders := make(http.Header)
  6405. for k, v := range c.header_ {
  6406. reqHeaders[k] = v
  6407. }
  6408. reqHeaders.Set("User-Agent", c.s.userAgent())
  6409. if c.ifNoneMatch_ != "" {
  6410. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6411. }
  6412. var body io.Reader = nil
  6413. c.urlParams_.Set("alt", alt)
  6414. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/pop")
  6415. urls += "?" + c.urlParams_.Encode()
  6416. req, _ := http.NewRequest("GET", urls, body)
  6417. req.Header = reqHeaders
  6418. googleapi.Expand(req.URL, map[string]string{
  6419. "userId": c.userId,
  6420. })
  6421. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6422. }
  6423. // Do executes the "gmail.users.settings.getPop" call.
  6424. // Exactly one of *PopSettings or error will be non-nil. Any non-2xx
  6425. // status code is an error. Response headers are in either
  6426. // *PopSettings.ServerResponse.Header or (if a response was returned at
  6427. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  6428. // to check whether the returned error was because
  6429. // http.StatusNotModified was returned.
  6430. func (c *UsersSettingsGetPopCall) Do(opts ...googleapi.CallOption) (*PopSettings, error) {
  6431. gensupport.SetOptions(c.urlParams_, opts...)
  6432. res, err := c.doRequest("json")
  6433. if res != nil && res.StatusCode == http.StatusNotModified {
  6434. if res.Body != nil {
  6435. res.Body.Close()
  6436. }
  6437. return nil, &googleapi.Error{
  6438. Code: res.StatusCode,
  6439. Header: res.Header,
  6440. }
  6441. }
  6442. if err != nil {
  6443. return nil, err
  6444. }
  6445. defer googleapi.CloseBody(res)
  6446. if err := googleapi.CheckResponse(res); err != nil {
  6447. return nil, err
  6448. }
  6449. ret := &PopSettings{
  6450. ServerResponse: googleapi.ServerResponse{
  6451. Header: res.Header,
  6452. HTTPStatusCode: res.StatusCode,
  6453. },
  6454. }
  6455. target := &ret
  6456. if err := gensupport.DecodeResponse(target, res); err != nil {
  6457. return nil, err
  6458. }
  6459. return ret, nil
  6460. // {
  6461. // "description": "Gets POP settings.",
  6462. // "httpMethod": "GET",
  6463. // "id": "gmail.users.settings.getPop",
  6464. // "parameterOrder": [
  6465. // "userId"
  6466. // ],
  6467. // "parameters": {
  6468. // "userId": {
  6469. // "default": "me",
  6470. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6471. // "location": "path",
  6472. // "required": true,
  6473. // "type": "string"
  6474. // }
  6475. // },
  6476. // "path": "{userId}/settings/pop",
  6477. // "response": {
  6478. // "$ref": "PopSettings"
  6479. // },
  6480. // "scopes": [
  6481. // "https://mail.google.com/",
  6482. // "https://www.googleapis.com/auth/gmail.modify",
  6483. // "https://www.googleapis.com/auth/gmail.readonly",
  6484. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6485. // ]
  6486. // }
  6487. }
  6488. // method id "gmail.users.settings.getVacation":
  6489. type UsersSettingsGetVacationCall struct {
  6490. s *Service
  6491. userId string
  6492. urlParams_ gensupport.URLParams
  6493. ifNoneMatch_ string
  6494. ctx_ context.Context
  6495. header_ http.Header
  6496. }
  6497. // GetVacation: Gets vacation responder settings.
  6498. func (r *UsersSettingsService) GetVacation(userId string) *UsersSettingsGetVacationCall {
  6499. c := &UsersSettingsGetVacationCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6500. c.userId = userId
  6501. return c
  6502. }
  6503. // Fields allows partial responses to be retrieved. See
  6504. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6505. // for more information.
  6506. func (c *UsersSettingsGetVacationCall) Fields(s ...googleapi.Field) *UsersSettingsGetVacationCall {
  6507. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6508. return c
  6509. }
  6510. // IfNoneMatch sets the optional parameter which makes the operation
  6511. // fail if the object's ETag matches the given value. This is useful for
  6512. // getting updates only after the object has changed since the last
  6513. // request. Use googleapi.IsNotModified to check whether the response
  6514. // error from Do is the result of In-None-Match.
  6515. func (c *UsersSettingsGetVacationCall) IfNoneMatch(entityTag string) *UsersSettingsGetVacationCall {
  6516. c.ifNoneMatch_ = entityTag
  6517. return c
  6518. }
  6519. // Context sets the context to be used in this call's Do method. Any
  6520. // pending HTTP request will be aborted if the provided context is
  6521. // canceled.
  6522. func (c *UsersSettingsGetVacationCall) Context(ctx context.Context) *UsersSettingsGetVacationCall {
  6523. c.ctx_ = ctx
  6524. return c
  6525. }
  6526. // Header returns an http.Header that can be modified by the caller to
  6527. // add HTTP headers to the request.
  6528. func (c *UsersSettingsGetVacationCall) Header() http.Header {
  6529. if c.header_ == nil {
  6530. c.header_ = make(http.Header)
  6531. }
  6532. return c.header_
  6533. }
  6534. func (c *UsersSettingsGetVacationCall) doRequest(alt string) (*http.Response, error) {
  6535. reqHeaders := make(http.Header)
  6536. for k, v := range c.header_ {
  6537. reqHeaders[k] = v
  6538. }
  6539. reqHeaders.Set("User-Agent", c.s.userAgent())
  6540. if c.ifNoneMatch_ != "" {
  6541. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6542. }
  6543. var body io.Reader = nil
  6544. c.urlParams_.Set("alt", alt)
  6545. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/vacation")
  6546. urls += "?" + c.urlParams_.Encode()
  6547. req, _ := http.NewRequest("GET", urls, body)
  6548. req.Header = reqHeaders
  6549. googleapi.Expand(req.URL, map[string]string{
  6550. "userId": c.userId,
  6551. })
  6552. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6553. }
  6554. // Do executes the "gmail.users.settings.getVacation" call.
  6555. // Exactly one of *VacationSettings or error will be non-nil. Any
  6556. // non-2xx status code is an error. Response headers are in either
  6557. // *VacationSettings.ServerResponse.Header or (if a response was
  6558. // returned at all) in error.(*googleapi.Error).Header. Use
  6559. // googleapi.IsNotModified to check whether the returned error was
  6560. // because http.StatusNotModified was returned.
  6561. func (c *UsersSettingsGetVacationCall) Do(opts ...googleapi.CallOption) (*VacationSettings, error) {
  6562. gensupport.SetOptions(c.urlParams_, opts...)
  6563. res, err := c.doRequest("json")
  6564. if res != nil && res.StatusCode == http.StatusNotModified {
  6565. if res.Body != nil {
  6566. res.Body.Close()
  6567. }
  6568. return nil, &googleapi.Error{
  6569. Code: res.StatusCode,
  6570. Header: res.Header,
  6571. }
  6572. }
  6573. if err != nil {
  6574. return nil, err
  6575. }
  6576. defer googleapi.CloseBody(res)
  6577. if err := googleapi.CheckResponse(res); err != nil {
  6578. return nil, err
  6579. }
  6580. ret := &VacationSettings{
  6581. ServerResponse: googleapi.ServerResponse{
  6582. Header: res.Header,
  6583. HTTPStatusCode: res.StatusCode,
  6584. },
  6585. }
  6586. target := &ret
  6587. if err := gensupport.DecodeResponse(target, res); err != nil {
  6588. return nil, err
  6589. }
  6590. return ret, nil
  6591. // {
  6592. // "description": "Gets vacation responder settings.",
  6593. // "httpMethod": "GET",
  6594. // "id": "gmail.users.settings.getVacation",
  6595. // "parameterOrder": [
  6596. // "userId"
  6597. // ],
  6598. // "parameters": {
  6599. // "userId": {
  6600. // "default": "me",
  6601. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6602. // "location": "path",
  6603. // "required": true,
  6604. // "type": "string"
  6605. // }
  6606. // },
  6607. // "path": "{userId}/settings/vacation",
  6608. // "response": {
  6609. // "$ref": "VacationSettings"
  6610. // },
  6611. // "scopes": [
  6612. // "https://mail.google.com/",
  6613. // "https://www.googleapis.com/auth/gmail.modify",
  6614. // "https://www.googleapis.com/auth/gmail.readonly",
  6615. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6616. // ]
  6617. // }
  6618. }
  6619. // method id "gmail.users.settings.updateAutoForwarding":
  6620. type UsersSettingsUpdateAutoForwardingCall struct {
  6621. s *Service
  6622. userId string
  6623. autoforwarding *AutoForwarding
  6624. urlParams_ gensupport.URLParams
  6625. ctx_ context.Context
  6626. header_ http.Header
  6627. }
  6628. // UpdateAutoForwarding: Updates the auto-forwarding setting for the
  6629. // specified account. A verified forwarding address must be specified
  6630. // when auto-forwarding is enabled.
  6631. //
  6632. // This method is only available to service account clients that have
  6633. // been delegated domain-wide authority.
  6634. func (r *UsersSettingsService) UpdateAutoForwarding(userId string, autoforwarding *AutoForwarding) *UsersSettingsUpdateAutoForwardingCall {
  6635. c := &UsersSettingsUpdateAutoForwardingCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6636. c.userId = userId
  6637. c.autoforwarding = autoforwarding
  6638. return c
  6639. }
  6640. // Fields allows partial responses to be retrieved. See
  6641. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6642. // for more information.
  6643. func (c *UsersSettingsUpdateAutoForwardingCall) Fields(s ...googleapi.Field) *UsersSettingsUpdateAutoForwardingCall {
  6644. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6645. return c
  6646. }
  6647. // Context sets the context to be used in this call's Do method. Any
  6648. // pending HTTP request will be aborted if the provided context is
  6649. // canceled.
  6650. func (c *UsersSettingsUpdateAutoForwardingCall) Context(ctx context.Context) *UsersSettingsUpdateAutoForwardingCall {
  6651. c.ctx_ = ctx
  6652. return c
  6653. }
  6654. // Header returns an http.Header that can be modified by the caller to
  6655. // add HTTP headers to the request.
  6656. func (c *UsersSettingsUpdateAutoForwardingCall) Header() http.Header {
  6657. if c.header_ == nil {
  6658. c.header_ = make(http.Header)
  6659. }
  6660. return c.header_
  6661. }
  6662. func (c *UsersSettingsUpdateAutoForwardingCall) doRequest(alt string) (*http.Response, error) {
  6663. reqHeaders := make(http.Header)
  6664. for k, v := range c.header_ {
  6665. reqHeaders[k] = v
  6666. }
  6667. reqHeaders.Set("User-Agent", c.s.userAgent())
  6668. var body io.Reader = nil
  6669. body, err := googleapi.WithoutDataWrapper.JSONReader(c.autoforwarding)
  6670. if err != nil {
  6671. return nil, err
  6672. }
  6673. reqHeaders.Set("Content-Type", "application/json")
  6674. c.urlParams_.Set("alt", alt)
  6675. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/autoForwarding")
  6676. urls += "?" + c.urlParams_.Encode()
  6677. req, _ := http.NewRequest("PUT", urls, body)
  6678. req.Header = reqHeaders
  6679. googleapi.Expand(req.URL, map[string]string{
  6680. "userId": c.userId,
  6681. })
  6682. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6683. }
  6684. // Do executes the "gmail.users.settings.updateAutoForwarding" call.
  6685. // Exactly one of *AutoForwarding or error will be non-nil. Any non-2xx
  6686. // status code is an error. Response headers are in either
  6687. // *AutoForwarding.ServerResponse.Header or (if a response was returned
  6688. // at all) in error.(*googleapi.Error).Header. Use
  6689. // googleapi.IsNotModified to check whether the returned error was
  6690. // because http.StatusNotModified was returned.
  6691. func (c *UsersSettingsUpdateAutoForwardingCall) Do(opts ...googleapi.CallOption) (*AutoForwarding, error) {
  6692. gensupport.SetOptions(c.urlParams_, opts...)
  6693. res, err := c.doRequest("json")
  6694. if res != nil && res.StatusCode == http.StatusNotModified {
  6695. if res.Body != nil {
  6696. res.Body.Close()
  6697. }
  6698. return nil, &googleapi.Error{
  6699. Code: res.StatusCode,
  6700. Header: res.Header,
  6701. }
  6702. }
  6703. if err != nil {
  6704. return nil, err
  6705. }
  6706. defer googleapi.CloseBody(res)
  6707. if err := googleapi.CheckResponse(res); err != nil {
  6708. return nil, err
  6709. }
  6710. ret := &AutoForwarding{
  6711. ServerResponse: googleapi.ServerResponse{
  6712. Header: res.Header,
  6713. HTTPStatusCode: res.StatusCode,
  6714. },
  6715. }
  6716. target := &ret
  6717. if err := gensupport.DecodeResponse(target, res); err != nil {
  6718. return nil, err
  6719. }
  6720. return ret, nil
  6721. // {
  6722. // "description": "Updates the auto-forwarding setting for the specified account. A verified forwarding address must be specified when auto-forwarding is enabled.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  6723. // "httpMethod": "PUT",
  6724. // "id": "gmail.users.settings.updateAutoForwarding",
  6725. // "parameterOrder": [
  6726. // "userId"
  6727. // ],
  6728. // "parameters": {
  6729. // "userId": {
  6730. // "default": "me",
  6731. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6732. // "location": "path",
  6733. // "required": true,
  6734. // "type": "string"
  6735. // }
  6736. // },
  6737. // "path": "{userId}/settings/autoForwarding",
  6738. // "request": {
  6739. // "$ref": "AutoForwarding"
  6740. // },
  6741. // "response": {
  6742. // "$ref": "AutoForwarding"
  6743. // },
  6744. // "scopes": [
  6745. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  6746. // ]
  6747. // }
  6748. }
  6749. // method id "gmail.users.settings.updateImap":
  6750. type UsersSettingsUpdateImapCall struct {
  6751. s *Service
  6752. userId string
  6753. imapsettings *ImapSettings
  6754. urlParams_ gensupport.URLParams
  6755. ctx_ context.Context
  6756. header_ http.Header
  6757. }
  6758. // UpdateImap: Updates IMAP settings.
  6759. func (r *UsersSettingsService) UpdateImap(userId string, imapsettings *ImapSettings) *UsersSettingsUpdateImapCall {
  6760. c := &UsersSettingsUpdateImapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6761. c.userId = userId
  6762. c.imapsettings = imapsettings
  6763. return c
  6764. }
  6765. // Fields allows partial responses to be retrieved. See
  6766. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6767. // for more information.
  6768. func (c *UsersSettingsUpdateImapCall) Fields(s ...googleapi.Field) *UsersSettingsUpdateImapCall {
  6769. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6770. return c
  6771. }
  6772. // Context sets the context to be used in this call's Do method. Any
  6773. // pending HTTP request will be aborted if the provided context is
  6774. // canceled.
  6775. func (c *UsersSettingsUpdateImapCall) Context(ctx context.Context) *UsersSettingsUpdateImapCall {
  6776. c.ctx_ = ctx
  6777. return c
  6778. }
  6779. // Header returns an http.Header that can be modified by the caller to
  6780. // add HTTP headers to the request.
  6781. func (c *UsersSettingsUpdateImapCall) Header() http.Header {
  6782. if c.header_ == nil {
  6783. c.header_ = make(http.Header)
  6784. }
  6785. return c.header_
  6786. }
  6787. func (c *UsersSettingsUpdateImapCall) doRequest(alt string) (*http.Response, error) {
  6788. reqHeaders := make(http.Header)
  6789. for k, v := range c.header_ {
  6790. reqHeaders[k] = v
  6791. }
  6792. reqHeaders.Set("User-Agent", c.s.userAgent())
  6793. var body io.Reader = nil
  6794. body, err := googleapi.WithoutDataWrapper.JSONReader(c.imapsettings)
  6795. if err != nil {
  6796. return nil, err
  6797. }
  6798. reqHeaders.Set("Content-Type", "application/json")
  6799. c.urlParams_.Set("alt", alt)
  6800. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/imap")
  6801. urls += "?" + c.urlParams_.Encode()
  6802. req, _ := http.NewRequest("PUT", urls, body)
  6803. req.Header = reqHeaders
  6804. googleapi.Expand(req.URL, map[string]string{
  6805. "userId": c.userId,
  6806. })
  6807. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6808. }
  6809. // Do executes the "gmail.users.settings.updateImap" call.
  6810. // Exactly one of *ImapSettings or error will be non-nil. Any non-2xx
  6811. // status code is an error. Response headers are in either
  6812. // *ImapSettings.ServerResponse.Header or (if a response was returned at
  6813. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  6814. // to check whether the returned error was because
  6815. // http.StatusNotModified was returned.
  6816. func (c *UsersSettingsUpdateImapCall) Do(opts ...googleapi.CallOption) (*ImapSettings, error) {
  6817. gensupport.SetOptions(c.urlParams_, opts...)
  6818. res, err := c.doRequest("json")
  6819. if res != nil && res.StatusCode == http.StatusNotModified {
  6820. if res.Body != nil {
  6821. res.Body.Close()
  6822. }
  6823. return nil, &googleapi.Error{
  6824. Code: res.StatusCode,
  6825. Header: res.Header,
  6826. }
  6827. }
  6828. if err != nil {
  6829. return nil, err
  6830. }
  6831. defer googleapi.CloseBody(res)
  6832. if err := googleapi.CheckResponse(res); err != nil {
  6833. return nil, err
  6834. }
  6835. ret := &ImapSettings{
  6836. ServerResponse: googleapi.ServerResponse{
  6837. Header: res.Header,
  6838. HTTPStatusCode: res.StatusCode,
  6839. },
  6840. }
  6841. target := &ret
  6842. if err := gensupport.DecodeResponse(target, res); err != nil {
  6843. return nil, err
  6844. }
  6845. return ret, nil
  6846. // {
  6847. // "description": "Updates IMAP settings.",
  6848. // "httpMethod": "PUT",
  6849. // "id": "gmail.users.settings.updateImap",
  6850. // "parameterOrder": [
  6851. // "userId"
  6852. // ],
  6853. // "parameters": {
  6854. // "userId": {
  6855. // "default": "me",
  6856. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6857. // "location": "path",
  6858. // "required": true,
  6859. // "type": "string"
  6860. // }
  6861. // },
  6862. // "path": "{userId}/settings/imap",
  6863. // "request": {
  6864. // "$ref": "ImapSettings"
  6865. // },
  6866. // "response": {
  6867. // "$ref": "ImapSettings"
  6868. // },
  6869. // "scopes": [
  6870. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6871. // ]
  6872. // }
  6873. }
  6874. // method id "gmail.users.settings.updatePop":
  6875. type UsersSettingsUpdatePopCall struct {
  6876. s *Service
  6877. userId string
  6878. popsettings *PopSettings
  6879. urlParams_ gensupport.URLParams
  6880. ctx_ context.Context
  6881. header_ http.Header
  6882. }
  6883. // UpdatePop: Updates POP settings.
  6884. func (r *UsersSettingsService) UpdatePop(userId string, popsettings *PopSettings) *UsersSettingsUpdatePopCall {
  6885. c := &UsersSettingsUpdatePopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6886. c.userId = userId
  6887. c.popsettings = popsettings
  6888. return c
  6889. }
  6890. // Fields allows partial responses to be retrieved. See
  6891. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6892. // for more information.
  6893. func (c *UsersSettingsUpdatePopCall) Fields(s ...googleapi.Field) *UsersSettingsUpdatePopCall {
  6894. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6895. return c
  6896. }
  6897. // Context sets the context to be used in this call's Do method. Any
  6898. // pending HTTP request will be aborted if the provided context is
  6899. // canceled.
  6900. func (c *UsersSettingsUpdatePopCall) Context(ctx context.Context) *UsersSettingsUpdatePopCall {
  6901. c.ctx_ = ctx
  6902. return c
  6903. }
  6904. // Header returns an http.Header that can be modified by the caller to
  6905. // add HTTP headers to the request.
  6906. func (c *UsersSettingsUpdatePopCall) Header() http.Header {
  6907. if c.header_ == nil {
  6908. c.header_ = make(http.Header)
  6909. }
  6910. return c.header_
  6911. }
  6912. func (c *UsersSettingsUpdatePopCall) doRequest(alt string) (*http.Response, error) {
  6913. reqHeaders := make(http.Header)
  6914. for k, v := range c.header_ {
  6915. reqHeaders[k] = v
  6916. }
  6917. reqHeaders.Set("User-Agent", c.s.userAgent())
  6918. var body io.Reader = nil
  6919. body, err := googleapi.WithoutDataWrapper.JSONReader(c.popsettings)
  6920. if err != nil {
  6921. return nil, err
  6922. }
  6923. reqHeaders.Set("Content-Type", "application/json")
  6924. c.urlParams_.Set("alt", alt)
  6925. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/pop")
  6926. urls += "?" + c.urlParams_.Encode()
  6927. req, _ := http.NewRequest("PUT", urls, body)
  6928. req.Header = reqHeaders
  6929. googleapi.Expand(req.URL, map[string]string{
  6930. "userId": c.userId,
  6931. })
  6932. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6933. }
  6934. // Do executes the "gmail.users.settings.updatePop" call.
  6935. // Exactly one of *PopSettings or error will be non-nil. Any non-2xx
  6936. // status code is an error. Response headers are in either
  6937. // *PopSettings.ServerResponse.Header or (if a response was returned at
  6938. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  6939. // to check whether the returned error was because
  6940. // http.StatusNotModified was returned.
  6941. func (c *UsersSettingsUpdatePopCall) Do(opts ...googleapi.CallOption) (*PopSettings, error) {
  6942. gensupport.SetOptions(c.urlParams_, opts...)
  6943. res, err := c.doRequest("json")
  6944. if res != nil && res.StatusCode == http.StatusNotModified {
  6945. if res.Body != nil {
  6946. res.Body.Close()
  6947. }
  6948. return nil, &googleapi.Error{
  6949. Code: res.StatusCode,
  6950. Header: res.Header,
  6951. }
  6952. }
  6953. if err != nil {
  6954. return nil, err
  6955. }
  6956. defer googleapi.CloseBody(res)
  6957. if err := googleapi.CheckResponse(res); err != nil {
  6958. return nil, err
  6959. }
  6960. ret := &PopSettings{
  6961. ServerResponse: googleapi.ServerResponse{
  6962. Header: res.Header,
  6963. HTTPStatusCode: res.StatusCode,
  6964. },
  6965. }
  6966. target := &ret
  6967. if err := gensupport.DecodeResponse(target, res); err != nil {
  6968. return nil, err
  6969. }
  6970. return ret, nil
  6971. // {
  6972. // "description": "Updates POP settings.",
  6973. // "httpMethod": "PUT",
  6974. // "id": "gmail.users.settings.updatePop",
  6975. // "parameterOrder": [
  6976. // "userId"
  6977. // ],
  6978. // "parameters": {
  6979. // "userId": {
  6980. // "default": "me",
  6981. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6982. // "location": "path",
  6983. // "required": true,
  6984. // "type": "string"
  6985. // }
  6986. // },
  6987. // "path": "{userId}/settings/pop",
  6988. // "request": {
  6989. // "$ref": "PopSettings"
  6990. // },
  6991. // "response": {
  6992. // "$ref": "PopSettings"
  6993. // },
  6994. // "scopes": [
  6995. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6996. // ]
  6997. // }
  6998. }
  6999. // method id "gmail.users.settings.updateVacation":
  7000. type UsersSettingsUpdateVacationCall struct {
  7001. s *Service
  7002. userId string
  7003. vacationsettings *VacationSettings
  7004. urlParams_ gensupport.URLParams
  7005. ctx_ context.Context
  7006. header_ http.Header
  7007. }
  7008. // UpdateVacation: Updates vacation responder settings.
  7009. func (r *UsersSettingsService) UpdateVacation(userId string, vacationsettings *VacationSettings) *UsersSettingsUpdateVacationCall {
  7010. c := &UsersSettingsUpdateVacationCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7011. c.userId = userId
  7012. c.vacationsettings = vacationsettings
  7013. return c
  7014. }
  7015. // Fields allows partial responses to be retrieved. See
  7016. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7017. // for more information.
  7018. func (c *UsersSettingsUpdateVacationCall) Fields(s ...googleapi.Field) *UsersSettingsUpdateVacationCall {
  7019. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7020. return c
  7021. }
  7022. // Context sets the context to be used in this call's Do method. Any
  7023. // pending HTTP request will be aborted if the provided context is
  7024. // canceled.
  7025. func (c *UsersSettingsUpdateVacationCall) Context(ctx context.Context) *UsersSettingsUpdateVacationCall {
  7026. c.ctx_ = ctx
  7027. return c
  7028. }
  7029. // Header returns an http.Header that can be modified by the caller to
  7030. // add HTTP headers to the request.
  7031. func (c *UsersSettingsUpdateVacationCall) Header() http.Header {
  7032. if c.header_ == nil {
  7033. c.header_ = make(http.Header)
  7034. }
  7035. return c.header_
  7036. }
  7037. func (c *UsersSettingsUpdateVacationCall) doRequest(alt string) (*http.Response, error) {
  7038. reqHeaders := make(http.Header)
  7039. for k, v := range c.header_ {
  7040. reqHeaders[k] = v
  7041. }
  7042. reqHeaders.Set("User-Agent", c.s.userAgent())
  7043. var body io.Reader = nil
  7044. body, err := googleapi.WithoutDataWrapper.JSONReader(c.vacationsettings)
  7045. if err != nil {
  7046. return nil, err
  7047. }
  7048. reqHeaders.Set("Content-Type", "application/json")
  7049. c.urlParams_.Set("alt", alt)
  7050. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/vacation")
  7051. urls += "?" + c.urlParams_.Encode()
  7052. req, _ := http.NewRequest("PUT", urls, body)
  7053. req.Header = reqHeaders
  7054. googleapi.Expand(req.URL, map[string]string{
  7055. "userId": c.userId,
  7056. })
  7057. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7058. }
  7059. // Do executes the "gmail.users.settings.updateVacation" call.
  7060. // Exactly one of *VacationSettings or error will be non-nil. Any
  7061. // non-2xx status code is an error. Response headers are in either
  7062. // *VacationSettings.ServerResponse.Header or (if a response was
  7063. // returned at all) in error.(*googleapi.Error).Header. Use
  7064. // googleapi.IsNotModified to check whether the returned error was
  7065. // because http.StatusNotModified was returned.
  7066. func (c *UsersSettingsUpdateVacationCall) Do(opts ...googleapi.CallOption) (*VacationSettings, error) {
  7067. gensupport.SetOptions(c.urlParams_, opts...)
  7068. res, err := c.doRequest("json")
  7069. if res != nil && res.StatusCode == http.StatusNotModified {
  7070. if res.Body != nil {
  7071. res.Body.Close()
  7072. }
  7073. return nil, &googleapi.Error{
  7074. Code: res.StatusCode,
  7075. Header: res.Header,
  7076. }
  7077. }
  7078. if err != nil {
  7079. return nil, err
  7080. }
  7081. defer googleapi.CloseBody(res)
  7082. if err := googleapi.CheckResponse(res); err != nil {
  7083. return nil, err
  7084. }
  7085. ret := &VacationSettings{
  7086. ServerResponse: googleapi.ServerResponse{
  7087. Header: res.Header,
  7088. HTTPStatusCode: res.StatusCode,
  7089. },
  7090. }
  7091. target := &ret
  7092. if err := gensupport.DecodeResponse(target, res); err != nil {
  7093. return nil, err
  7094. }
  7095. return ret, nil
  7096. // {
  7097. // "description": "Updates vacation responder settings.",
  7098. // "httpMethod": "PUT",
  7099. // "id": "gmail.users.settings.updateVacation",
  7100. // "parameterOrder": [
  7101. // "userId"
  7102. // ],
  7103. // "parameters": {
  7104. // "userId": {
  7105. // "default": "me",
  7106. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7107. // "location": "path",
  7108. // "required": true,
  7109. // "type": "string"
  7110. // }
  7111. // },
  7112. // "path": "{userId}/settings/vacation",
  7113. // "request": {
  7114. // "$ref": "VacationSettings"
  7115. // },
  7116. // "response": {
  7117. // "$ref": "VacationSettings"
  7118. // },
  7119. // "scopes": [
  7120. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7121. // ]
  7122. // }
  7123. }
  7124. // method id "gmail.users.settings.filters.create":
  7125. type UsersSettingsFiltersCreateCall struct {
  7126. s *Service
  7127. userId string
  7128. filter *Filter
  7129. urlParams_ gensupport.URLParams
  7130. ctx_ context.Context
  7131. header_ http.Header
  7132. }
  7133. // Create: Creates a filter.
  7134. func (r *UsersSettingsFiltersService) Create(userId string, filter *Filter) *UsersSettingsFiltersCreateCall {
  7135. c := &UsersSettingsFiltersCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7136. c.userId = userId
  7137. c.filter = filter
  7138. return c
  7139. }
  7140. // Fields allows partial responses to be retrieved. See
  7141. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7142. // for more information.
  7143. func (c *UsersSettingsFiltersCreateCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersCreateCall {
  7144. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7145. return c
  7146. }
  7147. // Context sets the context to be used in this call's Do method. Any
  7148. // pending HTTP request will be aborted if the provided context is
  7149. // canceled.
  7150. func (c *UsersSettingsFiltersCreateCall) Context(ctx context.Context) *UsersSettingsFiltersCreateCall {
  7151. c.ctx_ = ctx
  7152. return c
  7153. }
  7154. // Header returns an http.Header that can be modified by the caller to
  7155. // add HTTP headers to the request.
  7156. func (c *UsersSettingsFiltersCreateCall) Header() http.Header {
  7157. if c.header_ == nil {
  7158. c.header_ = make(http.Header)
  7159. }
  7160. return c.header_
  7161. }
  7162. func (c *UsersSettingsFiltersCreateCall) doRequest(alt string) (*http.Response, error) {
  7163. reqHeaders := make(http.Header)
  7164. for k, v := range c.header_ {
  7165. reqHeaders[k] = v
  7166. }
  7167. reqHeaders.Set("User-Agent", c.s.userAgent())
  7168. var body io.Reader = nil
  7169. body, err := googleapi.WithoutDataWrapper.JSONReader(c.filter)
  7170. if err != nil {
  7171. return nil, err
  7172. }
  7173. reqHeaders.Set("Content-Type", "application/json")
  7174. c.urlParams_.Set("alt", alt)
  7175. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters")
  7176. urls += "?" + c.urlParams_.Encode()
  7177. req, _ := http.NewRequest("POST", urls, body)
  7178. req.Header = reqHeaders
  7179. googleapi.Expand(req.URL, map[string]string{
  7180. "userId": c.userId,
  7181. })
  7182. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7183. }
  7184. // Do executes the "gmail.users.settings.filters.create" call.
  7185. // Exactly one of *Filter or error will be non-nil. Any non-2xx status
  7186. // code is an error. Response headers are in either
  7187. // *Filter.ServerResponse.Header or (if a response was returned at all)
  7188. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  7189. // check whether the returned error was because http.StatusNotModified
  7190. // was returned.
  7191. func (c *UsersSettingsFiltersCreateCall) Do(opts ...googleapi.CallOption) (*Filter, error) {
  7192. gensupport.SetOptions(c.urlParams_, opts...)
  7193. res, err := c.doRequest("json")
  7194. if res != nil && res.StatusCode == http.StatusNotModified {
  7195. if res.Body != nil {
  7196. res.Body.Close()
  7197. }
  7198. return nil, &googleapi.Error{
  7199. Code: res.StatusCode,
  7200. Header: res.Header,
  7201. }
  7202. }
  7203. if err != nil {
  7204. return nil, err
  7205. }
  7206. defer googleapi.CloseBody(res)
  7207. if err := googleapi.CheckResponse(res); err != nil {
  7208. return nil, err
  7209. }
  7210. ret := &Filter{
  7211. ServerResponse: googleapi.ServerResponse{
  7212. Header: res.Header,
  7213. HTTPStatusCode: res.StatusCode,
  7214. },
  7215. }
  7216. target := &ret
  7217. if err := gensupport.DecodeResponse(target, res); err != nil {
  7218. return nil, err
  7219. }
  7220. return ret, nil
  7221. // {
  7222. // "description": "Creates a filter.",
  7223. // "httpMethod": "POST",
  7224. // "id": "gmail.users.settings.filters.create",
  7225. // "parameterOrder": [
  7226. // "userId"
  7227. // ],
  7228. // "parameters": {
  7229. // "userId": {
  7230. // "default": "me",
  7231. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7232. // "location": "path",
  7233. // "required": true,
  7234. // "type": "string"
  7235. // }
  7236. // },
  7237. // "path": "{userId}/settings/filters",
  7238. // "request": {
  7239. // "$ref": "Filter"
  7240. // },
  7241. // "response": {
  7242. // "$ref": "Filter"
  7243. // },
  7244. // "scopes": [
  7245. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7246. // ]
  7247. // }
  7248. }
  7249. // method id "gmail.users.settings.filters.delete":
  7250. type UsersSettingsFiltersDeleteCall struct {
  7251. s *Service
  7252. userId string
  7253. id string
  7254. urlParams_ gensupport.URLParams
  7255. ctx_ context.Context
  7256. header_ http.Header
  7257. }
  7258. // Delete: Deletes a filter.
  7259. func (r *UsersSettingsFiltersService) Delete(userId string, id string) *UsersSettingsFiltersDeleteCall {
  7260. c := &UsersSettingsFiltersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7261. c.userId = userId
  7262. c.id = id
  7263. return c
  7264. }
  7265. // Fields allows partial responses to be retrieved. See
  7266. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7267. // for more information.
  7268. func (c *UsersSettingsFiltersDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersDeleteCall {
  7269. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7270. return c
  7271. }
  7272. // Context sets the context to be used in this call's Do method. Any
  7273. // pending HTTP request will be aborted if the provided context is
  7274. // canceled.
  7275. func (c *UsersSettingsFiltersDeleteCall) Context(ctx context.Context) *UsersSettingsFiltersDeleteCall {
  7276. c.ctx_ = ctx
  7277. return c
  7278. }
  7279. // Header returns an http.Header that can be modified by the caller to
  7280. // add HTTP headers to the request.
  7281. func (c *UsersSettingsFiltersDeleteCall) Header() http.Header {
  7282. if c.header_ == nil {
  7283. c.header_ = make(http.Header)
  7284. }
  7285. return c.header_
  7286. }
  7287. func (c *UsersSettingsFiltersDeleteCall) doRequest(alt string) (*http.Response, error) {
  7288. reqHeaders := make(http.Header)
  7289. for k, v := range c.header_ {
  7290. reqHeaders[k] = v
  7291. }
  7292. reqHeaders.Set("User-Agent", c.s.userAgent())
  7293. var body io.Reader = nil
  7294. c.urlParams_.Set("alt", alt)
  7295. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters/{id}")
  7296. urls += "?" + c.urlParams_.Encode()
  7297. req, _ := http.NewRequest("DELETE", urls, body)
  7298. req.Header = reqHeaders
  7299. googleapi.Expand(req.URL, map[string]string{
  7300. "userId": c.userId,
  7301. "id": c.id,
  7302. })
  7303. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7304. }
  7305. // Do executes the "gmail.users.settings.filters.delete" call.
  7306. func (c *UsersSettingsFiltersDeleteCall) Do(opts ...googleapi.CallOption) error {
  7307. gensupport.SetOptions(c.urlParams_, opts...)
  7308. res, err := c.doRequest("json")
  7309. if err != nil {
  7310. return err
  7311. }
  7312. defer googleapi.CloseBody(res)
  7313. if err := googleapi.CheckResponse(res); err != nil {
  7314. return err
  7315. }
  7316. return nil
  7317. // {
  7318. // "description": "Deletes a filter.",
  7319. // "httpMethod": "DELETE",
  7320. // "id": "gmail.users.settings.filters.delete",
  7321. // "parameterOrder": [
  7322. // "userId",
  7323. // "id"
  7324. // ],
  7325. // "parameters": {
  7326. // "id": {
  7327. // "description": "The ID of the filter to be deleted.",
  7328. // "location": "path",
  7329. // "required": true,
  7330. // "type": "string"
  7331. // },
  7332. // "userId": {
  7333. // "default": "me",
  7334. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7335. // "location": "path",
  7336. // "required": true,
  7337. // "type": "string"
  7338. // }
  7339. // },
  7340. // "path": "{userId}/settings/filters/{id}",
  7341. // "scopes": [
  7342. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7343. // ]
  7344. // }
  7345. }
  7346. // method id "gmail.users.settings.filters.get":
  7347. type UsersSettingsFiltersGetCall struct {
  7348. s *Service
  7349. userId string
  7350. id string
  7351. urlParams_ gensupport.URLParams
  7352. ifNoneMatch_ string
  7353. ctx_ context.Context
  7354. header_ http.Header
  7355. }
  7356. // Get: Gets a filter.
  7357. func (r *UsersSettingsFiltersService) Get(userId string, id string) *UsersSettingsFiltersGetCall {
  7358. c := &UsersSettingsFiltersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7359. c.userId = userId
  7360. c.id = id
  7361. return c
  7362. }
  7363. // Fields allows partial responses to be retrieved. See
  7364. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7365. // for more information.
  7366. func (c *UsersSettingsFiltersGetCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersGetCall {
  7367. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7368. return c
  7369. }
  7370. // IfNoneMatch sets the optional parameter which makes the operation
  7371. // fail if the object's ETag matches the given value. This is useful for
  7372. // getting updates only after the object has changed since the last
  7373. // request. Use googleapi.IsNotModified to check whether the response
  7374. // error from Do is the result of In-None-Match.
  7375. func (c *UsersSettingsFiltersGetCall) IfNoneMatch(entityTag string) *UsersSettingsFiltersGetCall {
  7376. c.ifNoneMatch_ = entityTag
  7377. return c
  7378. }
  7379. // Context sets the context to be used in this call's Do method. Any
  7380. // pending HTTP request will be aborted if the provided context is
  7381. // canceled.
  7382. func (c *UsersSettingsFiltersGetCall) Context(ctx context.Context) *UsersSettingsFiltersGetCall {
  7383. c.ctx_ = ctx
  7384. return c
  7385. }
  7386. // Header returns an http.Header that can be modified by the caller to
  7387. // add HTTP headers to the request.
  7388. func (c *UsersSettingsFiltersGetCall) Header() http.Header {
  7389. if c.header_ == nil {
  7390. c.header_ = make(http.Header)
  7391. }
  7392. return c.header_
  7393. }
  7394. func (c *UsersSettingsFiltersGetCall) doRequest(alt string) (*http.Response, error) {
  7395. reqHeaders := make(http.Header)
  7396. for k, v := range c.header_ {
  7397. reqHeaders[k] = v
  7398. }
  7399. reqHeaders.Set("User-Agent", c.s.userAgent())
  7400. if c.ifNoneMatch_ != "" {
  7401. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  7402. }
  7403. var body io.Reader = nil
  7404. c.urlParams_.Set("alt", alt)
  7405. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters/{id}")
  7406. urls += "?" + c.urlParams_.Encode()
  7407. req, _ := http.NewRequest("GET", urls, body)
  7408. req.Header = reqHeaders
  7409. googleapi.Expand(req.URL, map[string]string{
  7410. "userId": c.userId,
  7411. "id": c.id,
  7412. })
  7413. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7414. }
  7415. // Do executes the "gmail.users.settings.filters.get" call.
  7416. // Exactly one of *Filter or error will be non-nil. Any non-2xx status
  7417. // code is an error. Response headers are in either
  7418. // *Filter.ServerResponse.Header or (if a response was returned at all)
  7419. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  7420. // check whether the returned error was because http.StatusNotModified
  7421. // was returned.
  7422. func (c *UsersSettingsFiltersGetCall) Do(opts ...googleapi.CallOption) (*Filter, error) {
  7423. gensupport.SetOptions(c.urlParams_, opts...)
  7424. res, err := c.doRequest("json")
  7425. if res != nil && res.StatusCode == http.StatusNotModified {
  7426. if res.Body != nil {
  7427. res.Body.Close()
  7428. }
  7429. return nil, &googleapi.Error{
  7430. Code: res.StatusCode,
  7431. Header: res.Header,
  7432. }
  7433. }
  7434. if err != nil {
  7435. return nil, err
  7436. }
  7437. defer googleapi.CloseBody(res)
  7438. if err := googleapi.CheckResponse(res); err != nil {
  7439. return nil, err
  7440. }
  7441. ret := &Filter{
  7442. ServerResponse: googleapi.ServerResponse{
  7443. Header: res.Header,
  7444. HTTPStatusCode: res.StatusCode,
  7445. },
  7446. }
  7447. target := &ret
  7448. if err := gensupport.DecodeResponse(target, res); err != nil {
  7449. return nil, err
  7450. }
  7451. return ret, nil
  7452. // {
  7453. // "description": "Gets a filter.",
  7454. // "httpMethod": "GET",
  7455. // "id": "gmail.users.settings.filters.get",
  7456. // "parameterOrder": [
  7457. // "userId",
  7458. // "id"
  7459. // ],
  7460. // "parameters": {
  7461. // "id": {
  7462. // "description": "The ID of the filter to be fetched.",
  7463. // "location": "path",
  7464. // "required": true,
  7465. // "type": "string"
  7466. // },
  7467. // "userId": {
  7468. // "default": "me",
  7469. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7470. // "location": "path",
  7471. // "required": true,
  7472. // "type": "string"
  7473. // }
  7474. // },
  7475. // "path": "{userId}/settings/filters/{id}",
  7476. // "response": {
  7477. // "$ref": "Filter"
  7478. // },
  7479. // "scopes": [
  7480. // "https://mail.google.com/",
  7481. // "https://www.googleapis.com/auth/gmail.modify",
  7482. // "https://www.googleapis.com/auth/gmail.readonly",
  7483. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7484. // ]
  7485. // }
  7486. }
  7487. // method id "gmail.users.settings.filters.list":
  7488. type UsersSettingsFiltersListCall struct {
  7489. s *Service
  7490. userId string
  7491. urlParams_ gensupport.URLParams
  7492. ifNoneMatch_ string
  7493. ctx_ context.Context
  7494. header_ http.Header
  7495. }
  7496. // List: Lists the message filters of a Gmail user.
  7497. func (r *UsersSettingsFiltersService) List(userId string) *UsersSettingsFiltersListCall {
  7498. c := &UsersSettingsFiltersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7499. c.userId = userId
  7500. return c
  7501. }
  7502. // Fields allows partial responses to be retrieved. See
  7503. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7504. // for more information.
  7505. func (c *UsersSettingsFiltersListCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersListCall {
  7506. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7507. return c
  7508. }
  7509. // IfNoneMatch sets the optional parameter which makes the operation
  7510. // fail if the object's ETag matches the given value. This is useful for
  7511. // getting updates only after the object has changed since the last
  7512. // request. Use googleapi.IsNotModified to check whether the response
  7513. // error from Do is the result of In-None-Match.
  7514. func (c *UsersSettingsFiltersListCall) IfNoneMatch(entityTag string) *UsersSettingsFiltersListCall {
  7515. c.ifNoneMatch_ = entityTag
  7516. return c
  7517. }
  7518. // Context sets the context to be used in this call's Do method. Any
  7519. // pending HTTP request will be aborted if the provided context is
  7520. // canceled.
  7521. func (c *UsersSettingsFiltersListCall) Context(ctx context.Context) *UsersSettingsFiltersListCall {
  7522. c.ctx_ = ctx
  7523. return c
  7524. }
  7525. // Header returns an http.Header that can be modified by the caller to
  7526. // add HTTP headers to the request.
  7527. func (c *UsersSettingsFiltersListCall) Header() http.Header {
  7528. if c.header_ == nil {
  7529. c.header_ = make(http.Header)
  7530. }
  7531. return c.header_
  7532. }
  7533. func (c *UsersSettingsFiltersListCall) doRequest(alt string) (*http.Response, error) {
  7534. reqHeaders := make(http.Header)
  7535. for k, v := range c.header_ {
  7536. reqHeaders[k] = v
  7537. }
  7538. reqHeaders.Set("User-Agent", c.s.userAgent())
  7539. if c.ifNoneMatch_ != "" {
  7540. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  7541. }
  7542. var body io.Reader = nil
  7543. c.urlParams_.Set("alt", alt)
  7544. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters")
  7545. urls += "?" + c.urlParams_.Encode()
  7546. req, _ := http.NewRequest("GET", urls, body)
  7547. req.Header = reqHeaders
  7548. googleapi.Expand(req.URL, map[string]string{
  7549. "userId": c.userId,
  7550. })
  7551. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7552. }
  7553. // Do executes the "gmail.users.settings.filters.list" call.
  7554. // Exactly one of *ListFiltersResponse or error will be non-nil. Any
  7555. // non-2xx status code is an error. Response headers are in either
  7556. // *ListFiltersResponse.ServerResponse.Header or (if a response was
  7557. // returned at all) in error.(*googleapi.Error).Header. Use
  7558. // googleapi.IsNotModified to check whether the returned error was
  7559. // because http.StatusNotModified was returned.
  7560. func (c *UsersSettingsFiltersListCall) Do(opts ...googleapi.CallOption) (*ListFiltersResponse, error) {
  7561. gensupport.SetOptions(c.urlParams_, opts...)
  7562. res, err := c.doRequest("json")
  7563. if res != nil && res.StatusCode == http.StatusNotModified {
  7564. if res.Body != nil {
  7565. res.Body.Close()
  7566. }
  7567. return nil, &googleapi.Error{
  7568. Code: res.StatusCode,
  7569. Header: res.Header,
  7570. }
  7571. }
  7572. if err != nil {
  7573. return nil, err
  7574. }
  7575. defer googleapi.CloseBody(res)
  7576. if err := googleapi.CheckResponse(res); err != nil {
  7577. return nil, err
  7578. }
  7579. ret := &ListFiltersResponse{
  7580. ServerResponse: googleapi.ServerResponse{
  7581. Header: res.Header,
  7582. HTTPStatusCode: res.StatusCode,
  7583. },
  7584. }
  7585. target := &ret
  7586. if err := gensupport.DecodeResponse(target, res); err != nil {
  7587. return nil, err
  7588. }
  7589. return ret, nil
  7590. // {
  7591. // "description": "Lists the message filters of a Gmail user.",
  7592. // "httpMethod": "GET",
  7593. // "id": "gmail.users.settings.filters.list",
  7594. // "parameterOrder": [
  7595. // "userId"
  7596. // ],
  7597. // "parameters": {
  7598. // "userId": {
  7599. // "default": "me",
  7600. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7601. // "location": "path",
  7602. // "required": true,
  7603. // "type": "string"
  7604. // }
  7605. // },
  7606. // "path": "{userId}/settings/filters",
  7607. // "response": {
  7608. // "$ref": "ListFiltersResponse"
  7609. // },
  7610. // "scopes": [
  7611. // "https://mail.google.com/",
  7612. // "https://www.googleapis.com/auth/gmail.modify",
  7613. // "https://www.googleapis.com/auth/gmail.readonly",
  7614. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7615. // ]
  7616. // }
  7617. }
  7618. // method id "gmail.users.settings.forwardingAddresses.create":
  7619. type UsersSettingsForwardingAddressesCreateCall struct {
  7620. s *Service
  7621. userId string
  7622. forwardingaddress *ForwardingAddress
  7623. urlParams_ gensupport.URLParams
  7624. ctx_ context.Context
  7625. header_ http.Header
  7626. }
  7627. // Create: Creates a forwarding address. If ownership verification is
  7628. // required, a message will be sent to the recipient and the resource's
  7629. // verification status will be set to pending; otherwise, the resource
  7630. // will be created with verification status set to accepted.
  7631. //
  7632. // This method is only available to service account clients that have
  7633. // been delegated domain-wide authority.
  7634. func (r *UsersSettingsForwardingAddressesService) Create(userId string, forwardingaddress *ForwardingAddress) *UsersSettingsForwardingAddressesCreateCall {
  7635. c := &UsersSettingsForwardingAddressesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7636. c.userId = userId
  7637. c.forwardingaddress = forwardingaddress
  7638. return c
  7639. }
  7640. // Fields allows partial responses to be retrieved. See
  7641. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7642. // for more information.
  7643. func (c *UsersSettingsForwardingAddressesCreateCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesCreateCall {
  7644. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7645. return c
  7646. }
  7647. // Context sets the context to be used in this call's Do method. Any
  7648. // pending HTTP request will be aborted if the provided context is
  7649. // canceled.
  7650. func (c *UsersSettingsForwardingAddressesCreateCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesCreateCall {
  7651. c.ctx_ = ctx
  7652. return c
  7653. }
  7654. // Header returns an http.Header that can be modified by the caller to
  7655. // add HTTP headers to the request.
  7656. func (c *UsersSettingsForwardingAddressesCreateCall) Header() http.Header {
  7657. if c.header_ == nil {
  7658. c.header_ = make(http.Header)
  7659. }
  7660. return c.header_
  7661. }
  7662. func (c *UsersSettingsForwardingAddressesCreateCall) doRequest(alt string) (*http.Response, error) {
  7663. reqHeaders := make(http.Header)
  7664. for k, v := range c.header_ {
  7665. reqHeaders[k] = v
  7666. }
  7667. reqHeaders.Set("User-Agent", c.s.userAgent())
  7668. var body io.Reader = nil
  7669. body, err := googleapi.WithoutDataWrapper.JSONReader(c.forwardingaddress)
  7670. if err != nil {
  7671. return nil, err
  7672. }
  7673. reqHeaders.Set("Content-Type", "application/json")
  7674. c.urlParams_.Set("alt", alt)
  7675. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses")
  7676. urls += "?" + c.urlParams_.Encode()
  7677. req, _ := http.NewRequest("POST", urls, body)
  7678. req.Header = reqHeaders
  7679. googleapi.Expand(req.URL, map[string]string{
  7680. "userId": c.userId,
  7681. })
  7682. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7683. }
  7684. // Do executes the "gmail.users.settings.forwardingAddresses.create" call.
  7685. // Exactly one of *ForwardingAddress or error will be non-nil. Any
  7686. // non-2xx status code is an error. Response headers are in either
  7687. // *ForwardingAddress.ServerResponse.Header or (if a response was
  7688. // returned at all) in error.(*googleapi.Error).Header. Use
  7689. // googleapi.IsNotModified to check whether the returned error was
  7690. // because http.StatusNotModified was returned.
  7691. func (c *UsersSettingsForwardingAddressesCreateCall) Do(opts ...googleapi.CallOption) (*ForwardingAddress, error) {
  7692. gensupport.SetOptions(c.urlParams_, opts...)
  7693. res, err := c.doRequest("json")
  7694. if res != nil && res.StatusCode == http.StatusNotModified {
  7695. if res.Body != nil {
  7696. res.Body.Close()
  7697. }
  7698. return nil, &googleapi.Error{
  7699. Code: res.StatusCode,
  7700. Header: res.Header,
  7701. }
  7702. }
  7703. if err != nil {
  7704. return nil, err
  7705. }
  7706. defer googleapi.CloseBody(res)
  7707. if err := googleapi.CheckResponse(res); err != nil {
  7708. return nil, err
  7709. }
  7710. ret := &ForwardingAddress{
  7711. ServerResponse: googleapi.ServerResponse{
  7712. Header: res.Header,
  7713. HTTPStatusCode: res.StatusCode,
  7714. },
  7715. }
  7716. target := &ret
  7717. if err := gensupport.DecodeResponse(target, res); err != nil {
  7718. return nil, err
  7719. }
  7720. return ret, nil
  7721. // {
  7722. // "description": "Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  7723. // "httpMethod": "POST",
  7724. // "id": "gmail.users.settings.forwardingAddresses.create",
  7725. // "parameterOrder": [
  7726. // "userId"
  7727. // ],
  7728. // "parameters": {
  7729. // "userId": {
  7730. // "default": "me",
  7731. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7732. // "location": "path",
  7733. // "required": true,
  7734. // "type": "string"
  7735. // }
  7736. // },
  7737. // "path": "{userId}/settings/forwardingAddresses",
  7738. // "request": {
  7739. // "$ref": "ForwardingAddress"
  7740. // },
  7741. // "response": {
  7742. // "$ref": "ForwardingAddress"
  7743. // },
  7744. // "scopes": [
  7745. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  7746. // ]
  7747. // }
  7748. }
  7749. // method id "gmail.users.settings.forwardingAddresses.delete":
  7750. type UsersSettingsForwardingAddressesDeleteCall struct {
  7751. s *Service
  7752. userId string
  7753. forwardingEmail string
  7754. urlParams_ gensupport.URLParams
  7755. ctx_ context.Context
  7756. header_ http.Header
  7757. }
  7758. // Delete: Deletes the specified forwarding address and revokes any
  7759. // verification that may have been required.
  7760. //
  7761. // This method is only available to service account clients that have
  7762. // been delegated domain-wide authority.
  7763. func (r *UsersSettingsForwardingAddressesService) Delete(userId string, forwardingEmail string) *UsersSettingsForwardingAddressesDeleteCall {
  7764. c := &UsersSettingsForwardingAddressesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7765. c.userId = userId
  7766. c.forwardingEmail = forwardingEmail
  7767. return c
  7768. }
  7769. // Fields allows partial responses to be retrieved. See
  7770. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7771. // for more information.
  7772. func (c *UsersSettingsForwardingAddressesDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesDeleteCall {
  7773. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7774. return c
  7775. }
  7776. // Context sets the context to be used in this call's Do method. Any
  7777. // pending HTTP request will be aborted if the provided context is
  7778. // canceled.
  7779. func (c *UsersSettingsForwardingAddressesDeleteCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesDeleteCall {
  7780. c.ctx_ = ctx
  7781. return c
  7782. }
  7783. // Header returns an http.Header that can be modified by the caller to
  7784. // add HTTP headers to the request.
  7785. func (c *UsersSettingsForwardingAddressesDeleteCall) Header() http.Header {
  7786. if c.header_ == nil {
  7787. c.header_ = make(http.Header)
  7788. }
  7789. return c.header_
  7790. }
  7791. func (c *UsersSettingsForwardingAddressesDeleteCall) doRequest(alt string) (*http.Response, error) {
  7792. reqHeaders := make(http.Header)
  7793. for k, v := range c.header_ {
  7794. reqHeaders[k] = v
  7795. }
  7796. reqHeaders.Set("User-Agent", c.s.userAgent())
  7797. var body io.Reader = nil
  7798. c.urlParams_.Set("alt", alt)
  7799. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses/{forwardingEmail}")
  7800. urls += "?" + c.urlParams_.Encode()
  7801. req, _ := http.NewRequest("DELETE", urls, body)
  7802. req.Header = reqHeaders
  7803. googleapi.Expand(req.URL, map[string]string{
  7804. "userId": c.userId,
  7805. "forwardingEmail": c.forwardingEmail,
  7806. })
  7807. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7808. }
  7809. // Do executes the "gmail.users.settings.forwardingAddresses.delete" call.
  7810. func (c *UsersSettingsForwardingAddressesDeleteCall) Do(opts ...googleapi.CallOption) error {
  7811. gensupport.SetOptions(c.urlParams_, opts...)
  7812. res, err := c.doRequest("json")
  7813. if err != nil {
  7814. return err
  7815. }
  7816. defer googleapi.CloseBody(res)
  7817. if err := googleapi.CheckResponse(res); err != nil {
  7818. return err
  7819. }
  7820. return nil
  7821. // {
  7822. // "description": "Deletes the specified forwarding address and revokes any verification that may have been required.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  7823. // "httpMethod": "DELETE",
  7824. // "id": "gmail.users.settings.forwardingAddresses.delete",
  7825. // "parameterOrder": [
  7826. // "userId",
  7827. // "forwardingEmail"
  7828. // ],
  7829. // "parameters": {
  7830. // "forwardingEmail": {
  7831. // "description": "The forwarding address to be deleted.",
  7832. // "location": "path",
  7833. // "required": true,
  7834. // "type": "string"
  7835. // },
  7836. // "userId": {
  7837. // "default": "me",
  7838. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7839. // "location": "path",
  7840. // "required": true,
  7841. // "type": "string"
  7842. // }
  7843. // },
  7844. // "path": "{userId}/settings/forwardingAddresses/{forwardingEmail}",
  7845. // "scopes": [
  7846. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  7847. // ]
  7848. // }
  7849. }
  7850. // method id "gmail.users.settings.forwardingAddresses.get":
  7851. type UsersSettingsForwardingAddressesGetCall struct {
  7852. s *Service
  7853. userId string
  7854. forwardingEmail string
  7855. urlParams_ gensupport.URLParams
  7856. ifNoneMatch_ string
  7857. ctx_ context.Context
  7858. header_ http.Header
  7859. }
  7860. // Get: Gets the specified forwarding address.
  7861. func (r *UsersSettingsForwardingAddressesService) Get(userId string, forwardingEmail string) *UsersSettingsForwardingAddressesGetCall {
  7862. c := &UsersSettingsForwardingAddressesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7863. c.userId = userId
  7864. c.forwardingEmail = forwardingEmail
  7865. return c
  7866. }
  7867. // Fields allows partial responses to be retrieved. See
  7868. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7869. // for more information.
  7870. func (c *UsersSettingsForwardingAddressesGetCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesGetCall {
  7871. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7872. return c
  7873. }
  7874. // IfNoneMatch sets the optional parameter which makes the operation
  7875. // fail if the object's ETag matches the given value. This is useful for
  7876. // getting updates only after the object has changed since the last
  7877. // request. Use googleapi.IsNotModified to check whether the response
  7878. // error from Do is the result of In-None-Match.
  7879. func (c *UsersSettingsForwardingAddressesGetCall) IfNoneMatch(entityTag string) *UsersSettingsForwardingAddressesGetCall {
  7880. c.ifNoneMatch_ = entityTag
  7881. return c
  7882. }
  7883. // Context sets the context to be used in this call's Do method. Any
  7884. // pending HTTP request will be aborted if the provided context is
  7885. // canceled.
  7886. func (c *UsersSettingsForwardingAddressesGetCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesGetCall {
  7887. c.ctx_ = ctx
  7888. return c
  7889. }
  7890. // Header returns an http.Header that can be modified by the caller to
  7891. // add HTTP headers to the request.
  7892. func (c *UsersSettingsForwardingAddressesGetCall) Header() http.Header {
  7893. if c.header_ == nil {
  7894. c.header_ = make(http.Header)
  7895. }
  7896. return c.header_
  7897. }
  7898. func (c *UsersSettingsForwardingAddressesGetCall) doRequest(alt string) (*http.Response, error) {
  7899. reqHeaders := make(http.Header)
  7900. for k, v := range c.header_ {
  7901. reqHeaders[k] = v
  7902. }
  7903. reqHeaders.Set("User-Agent", c.s.userAgent())
  7904. if c.ifNoneMatch_ != "" {
  7905. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  7906. }
  7907. var body io.Reader = nil
  7908. c.urlParams_.Set("alt", alt)
  7909. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses/{forwardingEmail}")
  7910. urls += "?" + c.urlParams_.Encode()
  7911. req, _ := http.NewRequest("GET", urls, body)
  7912. req.Header = reqHeaders
  7913. googleapi.Expand(req.URL, map[string]string{
  7914. "userId": c.userId,
  7915. "forwardingEmail": c.forwardingEmail,
  7916. })
  7917. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7918. }
  7919. // Do executes the "gmail.users.settings.forwardingAddresses.get" call.
  7920. // Exactly one of *ForwardingAddress or error will be non-nil. Any
  7921. // non-2xx status code is an error. Response headers are in either
  7922. // *ForwardingAddress.ServerResponse.Header or (if a response was
  7923. // returned at all) in error.(*googleapi.Error).Header. Use
  7924. // googleapi.IsNotModified to check whether the returned error was
  7925. // because http.StatusNotModified was returned.
  7926. func (c *UsersSettingsForwardingAddressesGetCall) Do(opts ...googleapi.CallOption) (*ForwardingAddress, error) {
  7927. gensupport.SetOptions(c.urlParams_, opts...)
  7928. res, err := c.doRequest("json")
  7929. if res != nil && res.StatusCode == http.StatusNotModified {
  7930. if res.Body != nil {
  7931. res.Body.Close()
  7932. }
  7933. return nil, &googleapi.Error{
  7934. Code: res.StatusCode,
  7935. Header: res.Header,
  7936. }
  7937. }
  7938. if err != nil {
  7939. return nil, err
  7940. }
  7941. defer googleapi.CloseBody(res)
  7942. if err := googleapi.CheckResponse(res); err != nil {
  7943. return nil, err
  7944. }
  7945. ret := &ForwardingAddress{
  7946. ServerResponse: googleapi.ServerResponse{
  7947. Header: res.Header,
  7948. HTTPStatusCode: res.StatusCode,
  7949. },
  7950. }
  7951. target := &ret
  7952. if err := gensupport.DecodeResponse(target, res); err != nil {
  7953. return nil, err
  7954. }
  7955. return ret, nil
  7956. // {
  7957. // "description": "Gets the specified forwarding address.",
  7958. // "httpMethod": "GET",
  7959. // "id": "gmail.users.settings.forwardingAddresses.get",
  7960. // "parameterOrder": [
  7961. // "userId",
  7962. // "forwardingEmail"
  7963. // ],
  7964. // "parameters": {
  7965. // "forwardingEmail": {
  7966. // "description": "The forwarding address to be retrieved.",
  7967. // "location": "path",
  7968. // "required": true,
  7969. // "type": "string"
  7970. // },
  7971. // "userId": {
  7972. // "default": "me",
  7973. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7974. // "location": "path",
  7975. // "required": true,
  7976. // "type": "string"
  7977. // }
  7978. // },
  7979. // "path": "{userId}/settings/forwardingAddresses/{forwardingEmail}",
  7980. // "response": {
  7981. // "$ref": "ForwardingAddress"
  7982. // },
  7983. // "scopes": [
  7984. // "https://mail.google.com/",
  7985. // "https://www.googleapis.com/auth/gmail.modify",
  7986. // "https://www.googleapis.com/auth/gmail.readonly",
  7987. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7988. // ]
  7989. // }
  7990. }
  7991. // method id "gmail.users.settings.forwardingAddresses.list":
  7992. type UsersSettingsForwardingAddressesListCall struct {
  7993. s *Service
  7994. userId string
  7995. urlParams_ gensupport.URLParams
  7996. ifNoneMatch_ string
  7997. ctx_ context.Context
  7998. header_ http.Header
  7999. }
  8000. // List: Lists the forwarding addresses for the specified account.
  8001. func (r *UsersSettingsForwardingAddressesService) List(userId string) *UsersSettingsForwardingAddressesListCall {
  8002. c := &UsersSettingsForwardingAddressesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8003. c.userId = userId
  8004. return c
  8005. }
  8006. // Fields allows partial responses to be retrieved. See
  8007. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8008. // for more information.
  8009. func (c *UsersSettingsForwardingAddressesListCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesListCall {
  8010. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8011. return c
  8012. }
  8013. // IfNoneMatch sets the optional parameter which makes the operation
  8014. // fail if the object's ETag matches the given value. This is useful for
  8015. // getting updates only after the object has changed since the last
  8016. // request. Use googleapi.IsNotModified to check whether the response
  8017. // error from Do is the result of In-None-Match.
  8018. func (c *UsersSettingsForwardingAddressesListCall) IfNoneMatch(entityTag string) *UsersSettingsForwardingAddressesListCall {
  8019. c.ifNoneMatch_ = entityTag
  8020. return c
  8021. }
  8022. // Context sets the context to be used in this call's Do method. Any
  8023. // pending HTTP request will be aborted if the provided context is
  8024. // canceled.
  8025. func (c *UsersSettingsForwardingAddressesListCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesListCall {
  8026. c.ctx_ = ctx
  8027. return c
  8028. }
  8029. // Header returns an http.Header that can be modified by the caller to
  8030. // add HTTP headers to the request.
  8031. func (c *UsersSettingsForwardingAddressesListCall) Header() http.Header {
  8032. if c.header_ == nil {
  8033. c.header_ = make(http.Header)
  8034. }
  8035. return c.header_
  8036. }
  8037. func (c *UsersSettingsForwardingAddressesListCall) doRequest(alt string) (*http.Response, error) {
  8038. reqHeaders := make(http.Header)
  8039. for k, v := range c.header_ {
  8040. reqHeaders[k] = v
  8041. }
  8042. reqHeaders.Set("User-Agent", c.s.userAgent())
  8043. if c.ifNoneMatch_ != "" {
  8044. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8045. }
  8046. var body io.Reader = nil
  8047. c.urlParams_.Set("alt", alt)
  8048. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses")
  8049. urls += "?" + c.urlParams_.Encode()
  8050. req, _ := http.NewRequest("GET", urls, body)
  8051. req.Header = reqHeaders
  8052. googleapi.Expand(req.URL, map[string]string{
  8053. "userId": c.userId,
  8054. })
  8055. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8056. }
  8057. // Do executes the "gmail.users.settings.forwardingAddresses.list" call.
  8058. // Exactly one of *ListForwardingAddressesResponse or error will be
  8059. // non-nil. Any non-2xx status code is an error. Response headers are in
  8060. // either *ListForwardingAddressesResponse.ServerResponse.Header or (if
  8061. // a response was returned at all) in error.(*googleapi.Error).Header.
  8062. // Use googleapi.IsNotModified to check whether the returned error was
  8063. // because http.StatusNotModified was returned.
  8064. func (c *UsersSettingsForwardingAddressesListCall) Do(opts ...googleapi.CallOption) (*ListForwardingAddressesResponse, error) {
  8065. gensupport.SetOptions(c.urlParams_, opts...)
  8066. res, err := c.doRequest("json")
  8067. if res != nil && res.StatusCode == http.StatusNotModified {
  8068. if res.Body != nil {
  8069. res.Body.Close()
  8070. }
  8071. return nil, &googleapi.Error{
  8072. Code: res.StatusCode,
  8073. Header: res.Header,
  8074. }
  8075. }
  8076. if err != nil {
  8077. return nil, err
  8078. }
  8079. defer googleapi.CloseBody(res)
  8080. if err := googleapi.CheckResponse(res); err != nil {
  8081. return nil, err
  8082. }
  8083. ret := &ListForwardingAddressesResponse{
  8084. ServerResponse: googleapi.ServerResponse{
  8085. Header: res.Header,
  8086. HTTPStatusCode: res.StatusCode,
  8087. },
  8088. }
  8089. target := &ret
  8090. if err := gensupport.DecodeResponse(target, res); err != nil {
  8091. return nil, err
  8092. }
  8093. return ret, nil
  8094. // {
  8095. // "description": "Lists the forwarding addresses for the specified account.",
  8096. // "httpMethod": "GET",
  8097. // "id": "gmail.users.settings.forwardingAddresses.list",
  8098. // "parameterOrder": [
  8099. // "userId"
  8100. // ],
  8101. // "parameters": {
  8102. // "userId": {
  8103. // "default": "me",
  8104. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8105. // "location": "path",
  8106. // "required": true,
  8107. // "type": "string"
  8108. // }
  8109. // },
  8110. // "path": "{userId}/settings/forwardingAddresses",
  8111. // "response": {
  8112. // "$ref": "ListForwardingAddressesResponse"
  8113. // },
  8114. // "scopes": [
  8115. // "https://mail.google.com/",
  8116. // "https://www.googleapis.com/auth/gmail.modify",
  8117. // "https://www.googleapis.com/auth/gmail.readonly",
  8118. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8119. // ]
  8120. // }
  8121. }
  8122. // method id "gmail.users.settings.sendAs.create":
  8123. type UsersSettingsSendAsCreateCall struct {
  8124. s *Service
  8125. userId string
  8126. sendas *SendAs
  8127. urlParams_ gensupport.URLParams
  8128. ctx_ context.Context
  8129. header_ http.Header
  8130. }
  8131. // Create: Creates a custom "from" send-as alias. If an SMTP MSA is
  8132. // specified, Gmail will attempt to connect to the SMTP service to
  8133. // validate the configuration before creating the alias. If ownership
  8134. // verification is required for the alias, a message will be sent to the
  8135. // email address and the resource's verification status will be set to
  8136. // pending; otherwise, the resource will be created with verification
  8137. // status set to accepted. If a signature is provided, Gmail will
  8138. // sanitize the HTML before saving it with the alias.
  8139. //
  8140. // This method is only available to service account clients that have
  8141. // been delegated domain-wide authority.
  8142. func (r *UsersSettingsSendAsService) Create(userId string, sendas *SendAs) *UsersSettingsSendAsCreateCall {
  8143. c := &UsersSettingsSendAsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8144. c.userId = userId
  8145. c.sendas = sendas
  8146. return c
  8147. }
  8148. // Fields allows partial responses to be retrieved. See
  8149. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8150. // for more information.
  8151. func (c *UsersSettingsSendAsCreateCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsCreateCall {
  8152. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8153. return c
  8154. }
  8155. // Context sets the context to be used in this call's Do method. Any
  8156. // pending HTTP request will be aborted if the provided context is
  8157. // canceled.
  8158. func (c *UsersSettingsSendAsCreateCall) Context(ctx context.Context) *UsersSettingsSendAsCreateCall {
  8159. c.ctx_ = ctx
  8160. return c
  8161. }
  8162. // Header returns an http.Header that can be modified by the caller to
  8163. // add HTTP headers to the request.
  8164. func (c *UsersSettingsSendAsCreateCall) Header() http.Header {
  8165. if c.header_ == nil {
  8166. c.header_ = make(http.Header)
  8167. }
  8168. return c.header_
  8169. }
  8170. func (c *UsersSettingsSendAsCreateCall) doRequest(alt string) (*http.Response, error) {
  8171. reqHeaders := make(http.Header)
  8172. for k, v := range c.header_ {
  8173. reqHeaders[k] = v
  8174. }
  8175. reqHeaders.Set("User-Agent", c.s.userAgent())
  8176. var body io.Reader = nil
  8177. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sendas)
  8178. if err != nil {
  8179. return nil, err
  8180. }
  8181. reqHeaders.Set("Content-Type", "application/json")
  8182. c.urlParams_.Set("alt", alt)
  8183. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs")
  8184. urls += "?" + c.urlParams_.Encode()
  8185. req, _ := http.NewRequest("POST", urls, body)
  8186. req.Header = reqHeaders
  8187. googleapi.Expand(req.URL, map[string]string{
  8188. "userId": c.userId,
  8189. })
  8190. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8191. }
  8192. // Do executes the "gmail.users.settings.sendAs.create" call.
  8193. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  8194. // code is an error. Response headers are in either
  8195. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  8196. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  8197. // check whether the returned error was because http.StatusNotModified
  8198. // was returned.
  8199. func (c *UsersSettingsSendAsCreateCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  8200. gensupport.SetOptions(c.urlParams_, opts...)
  8201. res, err := c.doRequest("json")
  8202. if res != nil && res.StatusCode == http.StatusNotModified {
  8203. if res.Body != nil {
  8204. res.Body.Close()
  8205. }
  8206. return nil, &googleapi.Error{
  8207. Code: res.StatusCode,
  8208. Header: res.Header,
  8209. }
  8210. }
  8211. if err != nil {
  8212. return nil, err
  8213. }
  8214. defer googleapi.CloseBody(res)
  8215. if err := googleapi.CheckResponse(res); err != nil {
  8216. return nil, err
  8217. }
  8218. ret := &SendAs{
  8219. ServerResponse: googleapi.ServerResponse{
  8220. Header: res.Header,
  8221. HTTPStatusCode: res.StatusCode,
  8222. },
  8223. }
  8224. target := &ret
  8225. if err := gensupport.DecodeResponse(target, res); err != nil {
  8226. return nil, err
  8227. }
  8228. return ret, nil
  8229. // {
  8230. // "description": "Creates a custom \"from\" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  8231. // "httpMethod": "POST",
  8232. // "id": "gmail.users.settings.sendAs.create",
  8233. // "parameterOrder": [
  8234. // "userId"
  8235. // ],
  8236. // "parameters": {
  8237. // "userId": {
  8238. // "default": "me",
  8239. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8240. // "location": "path",
  8241. // "required": true,
  8242. // "type": "string"
  8243. // }
  8244. // },
  8245. // "path": "{userId}/settings/sendAs",
  8246. // "request": {
  8247. // "$ref": "SendAs"
  8248. // },
  8249. // "response": {
  8250. // "$ref": "SendAs"
  8251. // },
  8252. // "scopes": [
  8253. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  8254. // ]
  8255. // }
  8256. }
  8257. // method id "gmail.users.settings.sendAs.delete":
  8258. type UsersSettingsSendAsDeleteCall struct {
  8259. s *Service
  8260. userId string
  8261. sendAsEmail string
  8262. urlParams_ gensupport.URLParams
  8263. ctx_ context.Context
  8264. header_ http.Header
  8265. }
  8266. // Delete: Deletes the specified send-as alias. Revokes any verification
  8267. // that may have been required for using it.
  8268. //
  8269. // This method is only available to service account clients that have
  8270. // been delegated domain-wide authority.
  8271. func (r *UsersSettingsSendAsService) Delete(userId string, sendAsEmail string) *UsersSettingsSendAsDeleteCall {
  8272. c := &UsersSettingsSendAsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8273. c.userId = userId
  8274. c.sendAsEmail = sendAsEmail
  8275. return c
  8276. }
  8277. // Fields allows partial responses to be retrieved. See
  8278. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8279. // for more information.
  8280. func (c *UsersSettingsSendAsDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsDeleteCall {
  8281. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8282. return c
  8283. }
  8284. // Context sets the context to be used in this call's Do method. Any
  8285. // pending HTTP request will be aborted if the provided context is
  8286. // canceled.
  8287. func (c *UsersSettingsSendAsDeleteCall) Context(ctx context.Context) *UsersSettingsSendAsDeleteCall {
  8288. c.ctx_ = ctx
  8289. return c
  8290. }
  8291. // Header returns an http.Header that can be modified by the caller to
  8292. // add HTTP headers to the request.
  8293. func (c *UsersSettingsSendAsDeleteCall) Header() http.Header {
  8294. if c.header_ == nil {
  8295. c.header_ = make(http.Header)
  8296. }
  8297. return c.header_
  8298. }
  8299. func (c *UsersSettingsSendAsDeleteCall) doRequest(alt string) (*http.Response, error) {
  8300. reqHeaders := make(http.Header)
  8301. for k, v := range c.header_ {
  8302. reqHeaders[k] = v
  8303. }
  8304. reqHeaders.Set("User-Agent", c.s.userAgent())
  8305. var body io.Reader = nil
  8306. c.urlParams_.Set("alt", alt)
  8307. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  8308. urls += "?" + c.urlParams_.Encode()
  8309. req, _ := http.NewRequest("DELETE", urls, body)
  8310. req.Header = reqHeaders
  8311. googleapi.Expand(req.URL, map[string]string{
  8312. "userId": c.userId,
  8313. "sendAsEmail": c.sendAsEmail,
  8314. })
  8315. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8316. }
  8317. // Do executes the "gmail.users.settings.sendAs.delete" call.
  8318. func (c *UsersSettingsSendAsDeleteCall) Do(opts ...googleapi.CallOption) error {
  8319. gensupport.SetOptions(c.urlParams_, opts...)
  8320. res, err := c.doRequest("json")
  8321. if err != nil {
  8322. return err
  8323. }
  8324. defer googleapi.CloseBody(res)
  8325. if err := googleapi.CheckResponse(res); err != nil {
  8326. return err
  8327. }
  8328. return nil
  8329. // {
  8330. // "description": "Deletes the specified send-as alias. Revokes any verification that may have been required for using it.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  8331. // "httpMethod": "DELETE",
  8332. // "id": "gmail.users.settings.sendAs.delete",
  8333. // "parameterOrder": [
  8334. // "userId",
  8335. // "sendAsEmail"
  8336. // ],
  8337. // "parameters": {
  8338. // "sendAsEmail": {
  8339. // "description": "The send-as alias to be deleted.",
  8340. // "location": "path",
  8341. // "required": true,
  8342. // "type": "string"
  8343. // },
  8344. // "userId": {
  8345. // "default": "me",
  8346. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8347. // "location": "path",
  8348. // "required": true,
  8349. // "type": "string"
  8350. // }
  8351. // },
  8352. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  8353. // "scopes": [
  8354. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  8355. // ]
  8356. // }
  8357. }
  8358. // method id "gmail.users.settings.sendAs.get":
  8359. type UsersSettingsSendAsGetCall struct {
  8360. s *Service
  8361. userId string
  8362. sendAsEmail string
  8363. urlParams_ gensupport.URLParams
  8364. ifNoneMatch_ string
  8365. ctx_ context.Context
  8366. header_ http.Header
  8367. }
  8368. // Get: Gets the specified send-as alias. Fails with an HTTP 404 error
  8369. // if the specified address is not a member of the collection.
  8370. func (r *UsersSettingsSendAsService) Get(userId string, sendAsEmail string) *UsersSettingsSendAsGetCall {
  8371. c := &UsersSettingsSendAsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8372. c.userId = userId
  8373. c.sendAsEmail = sendAsEmail
  8374. return c
  8375. }
  8376. // Fields allows partial responses to be retrieved. See
  8377. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8378. // for more information.
  8379. func (c *UsersSettingsSendAsGetCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsGetCall {
  8380. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8381. return c
  8382. }
  8383. // IfNoneMatch sets the optional parameter which makes the operation
  8384. // fail if the object's ETag matches the given value. This is useful for
  8385. // getting updates only after the object has changed since the last
  8386. // request. Use googleapi.IsNotModified to check whether the response
  8387. // error from Do is the result of In-None-Match.
  8388. func (c *UsersSettingsSendAsGetCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsGetCall {
  8389. c.ifNoneMatch_ = entityTag
  8390. return c
  8391. }
  8392. // Context sets the context to be used in this call's Do method. Any
  8393. // pending HTTP request will be aborted if the provided context is
  8394. // canceled.
  8395. func (c *UsersSettingsSendAsGetCall) Context(ctx context.Context) *UsersSettingsSendAsGetCall {
  8396. c.ctx_ = ctx
  8397. return c
  8398. }
  8399. // Header returns an http.Header that can be modified by the caller to
  8400. // add HTTP headers to the request.
  8401. func (c *UsersSettingsSendAsGetCall) Header() http.Header {
  8402. if c.header_ == nil {
  8403. c.header_ = make(http.Header)
  8404. }
  8405. return c.header_
  8406. }
  8407. func (c *UsersSettingsSendAsGetCall) doRequest(alt string) (*http.Response, error) {
  8408. reqHeaders := make(http.Header)
  8409. for k, v := range c.header_ {
  8410. reqHeaders[k] = v
  8411. }
  8412. reqHeaders.Set("User-Agent", c.s.userAgent())
  8413. if c.ifNoneMatch_ != "" {
  8414. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8415. }
  8416. var body io.Reader = nil
  8417. c.urlParams_.Set("alt", alt)
  8418. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  8419. urls += "?" + c.urlParams_.Encode()
  8420. req, _ := http.NewRequest("GET", urls, body)
  8421. req.Header = reqHeaders
  8422. googleapi.Expand(req.URL, map[string]string{
  8423. "userId": c.userId,
  8424. "sendAsEmail": c.sendAsEmail,
  8425. })
  8426. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8427. }
  8428. // Do executes the "gmail.users.settings.sendAs.get" call.
  8429. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  8430. // code is an error. Response headers are in either
  8431. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  8432. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  8433. // check whether the returned error was because http.StatusNotModified
  8434. // was returned.
  8435. func (c *UsersSettingsSendAsGetCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  8436. gensupport.SetOptions(c.urlParams_, opts...)
  8437. res, err := c.doRequest("json")
  8438. if res != nil && res.StatusCode == http.StatusNotModified {
  8439. if res.Body != nil {
  8440. res.Body.Close()
  8441. }
  8442. return nil, &googleapi.Error{
  8443. Code: res.StatusCode,
  8444. Header: res.Header,
  8445. }
  8446. }
  8447. if err != nil {
  8448. return nil, err
  8449. }
  8450. defer googleapi.CloseBody(res)
  8451. if err := googleapi.CheckResponse(res); err != nil {
  8452. return nil, err
  8453. }
  8454. ret := &SendAs{
  8455. ServerResponse: googleapi.ServerResponse{
  8456. Header: res.Header,
  8457. HTTPStatusCode: res.StatusCode,
  8458. },
  8459. }
  8460. target := &ret
  8461. if err := gensupport.DecodeResponse(target, res); err != nil {
  8462. return nil, err
  8463. }
  8464. return ret, nil
  8465. // {
  8466. // "description": "Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection.",
  8467. // "httpMethod": "GET",
  8468. // "id": "gmail.users.settings.sendAs.get",
  8469. // "parameterOrder": [
  8470. // "userId",
  8471. // "sendAsEmail"
  8472. // ],
  8473. // "parameters": {
  8474. // "sendAsEmail": {
  8475. // "description": "The send-as alias to be retrieved.",
  8476. // "location": "path",
  8477. // "required": true,
  8478. // "type": "string"
  8479. // },
  8480. // "userId": {
  8481. // "default": "me",
  8482. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8483. // "location": "path",
  8484. // "required": true,
  8485. // "type": "string"
  8486. // }
  8487. // },
  8488. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  8489. // "response": {
  8490. // "$ref": "SendAs"
  8491. // },
  8492. // "scopes": [
  8493. // "https://mail.google.com/",
  8494. // "https://www.googleapis.com/auth/gmail.modify",
  8495. // "https://www.googleapis.com/auth/gmail.readonly",
  8496. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8497. // ]
  8498. // }
  8499. }
  8500. // method id "gmail.users.settings.sendAs.list":
  8501. type UsersSettingsSendAsListCall struct {
  8502. s *Service
  8503. userId string
  8504. urlParams_ gensupport.URLParams
  8505. ifNoneMatch_ string
  8506. ctx_ context.Context
  8507. header_ http.Header
  8508. }
  8509. // List: Lists the send-as aliases for the specified account. The result
  8510. // includes the primary send-as address associated with the account as
  8511. // well as any custom "from" aliases.
  8512. func (r *UsersSettingsSendAsService) List(userId string) *UsersSettingsSendAsListCall {
  8513. c := &UsersSettingsSendAsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8514. c.userId = userId
  8515. return c
  8516. }
  8517. // Fields allows partial responses to be retrieved. See
  8518. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8519. // for more information.
  8520. func (c *UsersSettingsSendAsListCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsListCall {
  8521. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8522. return c
  8523. }
  8524. // IfNoneMatch sets the optional parameter which makes the operation
  8525. // fail if the object's ETag matches the given value. This is useful for
  8526. // getting updates only after the object has changed since the last
  8527. // request. Use googleapi.IsNotModified to check whether the response
  8528. // error from Do is the result of In-None-Match.
  8529. func (c *UsersSettingsSendAsListCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsListCall {
  8530. c.ifNoneMatch_ = entityTag
  8531. return c
  8532. }
  8533. // Context sets the context to be used in this call's Do method. Any
  8534. // pending HTTP request will be aborted if the provided context is
  8535. // canceled.
  8536. func (c *UsersSettingsSendAsListCall) Context(ctx context.Context) *UsersSettingsSendAsListCall {
  8537. c.ctx_ = ctx
  8538. return c
  8539. }
  8540. // Header returns an http.Header that can be modified by the caller to
  8541. // add HTTP headers to the request.
  8542. func (c *UsersSettingsSendAsListCall) Header() http.Header {
  8543. if c.header_ == nil {
  8544. c.header_ = make(http.Header)
  8545. }
  8546. return c.header_
  8547. }
  8548. func (c *UsersSettingsSendAsListCall) doRequest(alt string) (*http.Response, error) {
  8549. reqHeaders := make(http.Header)
  8550. for k, v := range c.header_ {
  8551. reqHeaders[k] = v
  8552. }
  8553. reqHeaders.Set("User-Agent", c.s.userAgent())
  8554. if c.ifNoneMatch_ != "" {
  8555. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8556. }
  8557. var body io.Reader = nil
  8558. c.urlParams_.Set("alt", alt)
  8559. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs")
  8560. urls += "?" + c.urlParams_.Encode()
  8561. req, _ := http.NewRequest("GET", urls, body)
  8562. req.Header = reqHeaders
  8563. googleapi.Expand(req.URL, map[string]string{
  8564. "userId": c.userId,
  8565. })
  8566. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8567. }
  8568. // Do executes the "gmail.users.settings.sendAs.list" call.
  8569. // Exactly one of *ListSendAsResponse or error will be non-nil. Any
  8570. // non-2xx status code is an error. Response headers are in either
  8571. // *ListSendAsResponse.ServerResponse.Header or (if a response was
  8572. // returned at all) in error.(*googleapi.Error).Header. Use
  8573. // googleapi.IsNotModified to check whether the returned error was
  8574. // because http.StatusNotModified was returned.
  8575. func (c *UsersSettingsSendAsListCall) Do(opts ...googleapi.CallOption) (*ListSendAsResponse, error) {
  8576. gensupport.SetOptions(c.urlParams_, opts...)
  8577. res, err := c.doRequest("json")
  8578. if res != nil && res.StatusCode == http.StatusNotModified {
  8579. if res.Body != nil {
  8580. res.Body.Close()
  8581. }
  8582. return nil, &googleapi.Error{
  8583. Code: res.StatusCode,
  8584. Header: res.Header,
  8585. }
  8586. }
  8587. if err != nil {
  8588. return nil, err
  8589. }
  8590. defer googleapi.CloseBody(res)
  8591. if err := googleapi.CheckResponse(res); err != nil {
  8592. return nil, err
  8593. }
  8594. ret := &ListSendAsResponse{
  8595. ServerResponse: googleapi.ServerResponse{
  8596. Header: res.Header,
  8597. HTTPStatusCode: res.StatusCode,
  8598. },
  8599. }
  8600. target := &ret
  8601. if err := gensupport.DecodeResponse(target, res); err != nil {
  8602. return nil, err
  8603. }
  8604. return ret, nil
  8605. // {
  8606. // "description": "Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom \"from\" aliases.",
  8607. // "httpMethod": "GET",
  8608. // "id": "gmail.users.settings.sendAs.list",
  8609. // "parameterOrder": [
  8610. // "userId"
  8611. // ],
  8612. // "parameters": {
  8613. // "userId": {
  8614. // "default": "me",
  8615. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8616. // "location": "path",
  8617. // "required": true,
  8618. // "type": "string"
  8619. // }
  8620. // },
  8621. // "path": "{userId}/settings/sendAs",
  8622. // "response": {
  8623. // "$ref": "ListSendAsResponse"
  8624. // },
  8625. // "scopes": [
  8626. // "https://mail.google.com/",
  8627. // "https://www.googleapis.com/auth/gmail.modify",
  8628. // "https://www.googleapis.com/auth/gmail.readonly",
  8629. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8630. // ]
  8631. // }
  8632. }
  8633. // method id "gmail.users.settings.sendAs.patch":
  8634. type UsersSettingsSendAsPatchCall struct {
  8635. s *Service
  8636. userId string
  8637. sendAsEmail string
  8638. sendas *SendAs
  8639. urlParams_ gensupport.URLParams
  8640. ctx_ context.Context
  8641. header_ http.Header
  8642. }
  8643. // Patch: Updates a send-as alias. If a signature is provided, Gmail
  8644. // will sanitize the HTML before saving it with the alias.
  8645. //
  8646. // Addresses other than the primary address for the account can only be
  8647. // updated by service account clients that have been delegated
  8648. // domain-wide authority. This method supports patch semantics.
  8649. func (r *UsersSettingsSendAsService) Patch(userId string, sendAsEmail string, sendas *SendAs) *UsersSettingsSendAsPatchCall {
  8650. c := &UsersSettingsSendAsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8651. c.userId = userId
  8652. c.sendAsEmail = sendAsEmail
  8653. c.sendas = sendas
  8654. return c
  8655. }
  8656. // Fields allows partial responses to be retrieved. See
  8657. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8658. // for more information.
  8659. func (c *UsersSettingsSendAsPatchCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsPatchCall {
  8660. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8661. return c
  8662. }
  8663. // Context sets the context to be used in this call's Do method. Any
  8664. // pending HTTP request will be aborted if the provided context is
  8665. // canceled.
  8666. func (c *UsersSettingsSendAsPatchCall) Context(ctx context.Context) *UsersSettingsSendAsPatchCall {
  8667. c.ctx_ = ctx
  8668. return c
  8669. }
  8670. // Header returns an http.Header that can be modified by the caller to
  8671. // add HTTP headers to the request.
  8672. func (c *UsersSettingsSendAsPatchCall) Header() http.Header {
  8673. if c.header_ == nil {
  8674. c.header_ = make(http.Header)
  8675. }
  8676. return c.header_
  8677. }
  8678. func (c *UsersSettingsSendAsPatchCall) doRequest(alt string) (*http.Response, error) {
  8679. reqHeaders := make(http.Header)
  8680. for k, v := range c.header_ {
  8681. reqHeaders[k] = v
  8682. }
  8683. reqHeaders.Set("User-Agent", c.s.userAgent())
  8684. var body io.Reader = nil
  8685. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sendas)
  8686. if err != nil {
  8687. return nil, err
  8688. }
  8689. reqHeaders.Set("Content-Type", "application/json")
  8690. c.urlParams_.Set("alt", alt)
  8691. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  8692. urls += "?" + c.urlParams_.Encode()
  8693. req, _ := http.NewRequest("PATCH", urls, body)
  8694. req.Header = reqHeaders
  8695. googleapi.Expand(req.URL, map[string]string{
  8696. "userId": c.userId,
  8697. "sendAsEmail": c.sendAsEmail,
  8698. })
  8699. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8700. }
  8701. // Do executes the "gmail.users.settings.sendAs.patch" call.
  8702. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  8703. // code is an error. Response headers are in either
  8704. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  8705. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  8706. // check whether the returned error was because http.StatusNotModified
  8707. // was returned.
  8708. func (c *UsersSettingsSendAsPatchCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  8709. gensupport.SetOptions(c.urlParams_, opts...)
  8710. res, err := c.doRequest("json")
  8711. if res != nil && res.StatusCode == http.StatusNotModified {
  8712. if res.Body != nil {
  8713. res.Body.Close()
  8714. }
  8715. return nil, &googleapi.Error{
  8716. Code: res.StatusCode,
  8717. Header: res.Header,
  8718. }
  8719. }
  8720. if err != nil {
  8721. return nil, err
  8722. }
  8723. defer googleapi.CloseBody(res)
  8724. if err := googleapi.CheckResponse(res); err != nil {
  8725. return nil, err
  8726. }
  8727. ret := &SendAs{
  8728. ServerResponse: googleapi.ServerResponse{
  8729. Header: res.Header,
  8730. HTTPStatusCode: res.StatusCode,
  8731. },
  8732. }
  8733. target := &ret
  8734. if err := gensupport.DecodeResponse(target, res); err != nil {
  8735. return nil, err
  8736. }
  8737. return ret, nil
  8738. // {
  8739. // "description": "Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias.\n\nAddresses other than the primary address for the account can only be updated by service account clients that have been delegated domain-wide authority. This method supports patch semantics.",
  8740. // "httpMethod": "PATCH",
  8741. // "id": "gmail.users.settings.sendAs.patch",
  8742. // "parameterOrder": [
  8743. // "userId",
  8744. // "sendAsEmail"
  8745. // ],
  8746. // "parameters": {
  8747. // "sendAsEmail": {
  8748. // "description": "The send-as alias to be updated.",
  8749. // "location": "path",
  8750. // "required": true,
  8751. // "type": "string"
  8752. // },
  8753. // "userId": {
  8754. // "default": "me",
  8755. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8756. // "location": "path",
  8757. // "required": true,
  8758. // "type": "string"
  8759. // }
  8760. // },
  8761. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  8762. // "request": {
  8763. // "$ref": "SendAs"
  8764. // },
  8765. // "response": {
  8766. // "$ref": "SendAs"
  8767. // },
  8768. // "scopes": [
  8769. // "https://www.googleapis.com/auth/gmail.settings.basic",
  8770. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  8771. // ]
  8772. // }
  8773. }
  8774. // method id "gmail.users.settings.sendAs.update":
  8775. type UsersSettingsSendAsUpdateCall struct {
  8776. s *Service
  8777. userId string
  8778. sendAsEmail string
  8779. sendas *SendAs
  8780. urlParams_ gensupport.URLParams
  8781. ctx_ context.Context
  8782. header_ http.Header
  8783. }
  8784. // Update: Updates a send-as alias. If a signature is provided, Gmail
  8785. // will sanitize the HTML before saving it with the alias.
  8786. //
  8787. // Addresses other than the primary address for the account can only be
  8788. // updated by service account clients that have been delegated
  8789. // domain-wide authority.
  8790. func (r *UsersSettingsSendAsService) Update(userId string, sendAsEmail string, sendas *SendAs) *UsersSettingsSendAsUpdateCall {
  8791. c := &UsersSettingsSendAsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8792. c.userId = userId
  8793. c.sendAsEmail = sendAsEmail
  8794. c.sendas = sendas
  8795. return c
  8796. }
  8797. // Fields allows partial responses to be retrieved. See
  8798. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8799. // for more information.
  8800. func (c *UsersSettingsSendAsUpdateCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsUpdateCall {
  8801. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8802. return c
  8803. }
  8804. // Context sets the context to be used in this call's Do method. Any
  8805. // pending HTTP request will be aborted if the provided context is
  8806. // canceled.
  8807. func (c *UsersSettingsSendAsUpdateCall) Context(ctx context.Context) *UsersSettingsSendAsUpdateCall {
  8808. c.ctx_ = ctx
  8809. return c
  8810. }
  8811. // Header returns an http.Header that can be modified by the caller to
  8812. // add HTTP headers to the request.
  8813. func (c *UsersSettingsSendAsUpdateCall) Header() http.Header {
  8814. if c.header_ == nil {
  8815. c.header_ = make(http.Header)
  8816. }
  8817. return c.header_
  8818. }
  8819. func (c *UsersSettingsSendAsUpdateCall) doRequest(alt string) (*http.Response, error) {
  8820. reqHeaders := make(http.Header)
  8821. for k, v := range c.header_ {
  8822. reqHeaders[k] = v
  8823. }
  8824. reqHeaders.Set("User-Agent", c.s.userAgent())
  8825. var body io.Reader = nil
  8826. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sendas)
  8827. if err != nil {
  8828. return nil, err
  8829. }
  8830. reqHeaders.Set("Content-Type", "application/json")
  8831. c.urlParams_.Set("alt", alt)
  8832. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  8833. urls += "?" + c.urlParams_.Encode()
  8834. req, _ := http.NewRequest("PUT", urls, body)
  8835. req.Header = reqHeaders
  8836. googleapi.Expand(req.URL, map[string]string{
  8837. "userId": c.userId,
  8838. "sendAsEmail": c.sendAsEmail,
  8839. })
  8840. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8841. }
  8842. // Do executes the "gmail.users.settings.sendAs.update" call.
  8843. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  8844. // code is an error. Response headers are in either
  8845. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  8846. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  8847. // check whether the returned error was because http.StatusNotModified
  8848. // was returned.
  8849. func (c *UsersSettingsSendAsUpdateCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  8850. gensupport.SetOptions(c.urlParams_, opts...)
  8851. res, err := c.doRequest("json")
  8852. if res != nil && res.StatusCode == http.StatusNotModified {
  8853. if res.Body != nil {
  8854. res.Body.Close()
  8855. }
  8856. return nil, &googleapi.Error{
  8857. Code: res.StatusCode,
  8858. Header: res.Header,
  8859. }
  8860. }
  8861. if err != nil {
  8862. return nil, err
  8863. }
  8864. defer googleapi.CloseBody(res)
  8865. if err := googleapi.CheckResponse(res); err != nil {
  8866. return nil, err
  8867. }
  8868. ret := &SendAs{
  8869. ServerResponse: googleapi.ServerResponse{
  8870. Header: res.Header,
  8871. HTTPStatusCode: res.StatusCode,
  8872. },
  8873. }
  8874. target := &ret
  8875. if err := gensupport.DecodeResponse(target, res); err != nil {
  8876. return nil, err
  8877. }
  8878. return ret, nil
  8879. // {
  8880. // "description": "Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias.\n\nAddresses other than the primary address for the account can only be updated by service account clients that have been delegated domain-wide authority.",
  8881. // "httpMethod": "PUT",
  8882. // "id": "gmail.users.settings.sendAs.update",
  8883. // "parameterOrder": [
  8884. // "userId",
  8885. // "sendAsEmail"
  8886. // ],
  8887. // "parameters": {
  8888. // "sendAsEmail": {
  8889. // "description": "The send-as alias to be updated.",
  8890. // "location": "path",
  8891. // "required": true,
  8892. // "type": "string"
  8893. // },
  8894. // "userId": {
  8895. // "default": "me",
  8896. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8897. // "location": "path",
  8898. // "required": true,
  8899. // "type": "string"
  8900. // }
  8901. // },
  8902. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  8903. // "request": {
  8904. // "$ref": "SendAs"
  8905. // },
  8906. // "response": {
  8907. // "$ref": "SendAs"
  8908. // },
  8909. // "scopes": [
  8910. // "https://www.googleapis.com/auth/gmail.settings.basic",
  8911. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  8912. // ]
  8913. // }
  8914. }
  8915. // method id "gmail.users.settings.sendAs.verify":
  8916. type UsersSettingsSendAsVerifyCall struct {
  8917. s *Service
  8918. userId string
  8919. sendAsEmail string
  8920. urlParams_ gensupport.URLParams
  8921. ctx_ context.Context
  8922. header_ http.Header
  8923. }
  8924. // Verify: Sends a verification email to the specified send-as alias
  8925. // address. The verification status must be pending.
  8926. //
  8927. // This method is only available to service account clients that have
  8928. // been delegated domain-wide authority.
  8929. func (r *UsersSettingsSendAsService) Verify(userId string, sendAsEmail string) *UsersSettingsSendAsVerifyCall {
  8930. c := &UsersSettingsSendAsVerifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8931. c.userId = userId
  8932. c.sendAsEmail = sendAsEmail
  8933. return c
  8934. }
  8935. // Fields allows partial responses to be retrieved. See
  8936. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8937. // for more information.
  8938. func (c *UsersSettingsSendAsVerifyCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsVerifyCall {
  8939. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8940. return c
  8941. }
  8942. // Context sets the context to be used in this call's Do method. Any
  8943. // pending HTTP request will be aborted if the provided context is
  8944. // canceled.
  8945. func (c *UsersSettingsSendAsVerifyCall) Context(ctx context.Context) *UsersSettingsSendAsVerifyCall {
  8946. c.ctx_ = ctx
  8947. return c
  8948. }
  8949. // Header returns an http.Header that can be modified by the caller to
  8950. // add HTTP headers to the request.
  8951. func (c *UsersSettingsSendAsVerifyCall) Header() http.Header {
  8952. if c.header_ == nil {
  8953. c.header_ = make(http.Header)
  8954. }
  8955. return c.header_
  8956. }
  8957. func (c *UsersSettingsSendAsVerifyCall) doRequest(alt string) (*http.Response, error) {
  8958. reqHeaders := make(http.Header)
  8959. for k, v := range c.header_ {
  8960. reqHeaders[k] = v
  8961. }
  8962. reqHeaders.Set("User-Agent", c.s.userAgent())
  8963. var body io.Reader = nil
  8964. c.urlParams_.Set("alt", alt)
  8965. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/verify")
  8966. urls += "?" + c.urlParams_.Encode()
  8967. req, _ := http.NewRequest("POST", urls, body)
  8968. req.Header = reqHeaders
  8969. googleapi.Expand(req.URL, map[string]string{
  8970. "userId": c.userId,
  8971. "sendAsEmail": c.sendAsEmail,
  8972. })
  8973. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8974. }
  8975. // Do executes the "gmail.users.settings.sendAs.verify" call.
  8976. func (c *UsersSettingsSendAsVerifyCall) Do(opts ...googleapi.CallOption) error {
  8977. gensupport.SetOptions(c.urlParams_, opts...)
  8978. res, err := c.doRequest("json")
  8979. if err != nil {
  8980. return err
  8981. }
  8982. defer googleapi.CloseBody(res)
  8983. if err := googleapi.CheckResponse(res); err != nil {
  8984. return err
  8985. }
  8986. return nil
  8987. // {
  8988. // "description": "Sends a verification email to the specified send-as alias address. The verification status must be pending.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  8989. // "httpMethod": "POST",
  8990. // "id": "gmail.users.settings.sendAs.verify",
  8991. // "parameterOrder": [
  8992. // "userId",
  8993. // "sendAsEmail"
  8994. // ],
  8995. // "parameters": {
  8996. // "sendAsEmail": {
  8997. // "description": "The send-as alias to be verified.",
  8998. // "location": "path",
  8999. // "required": true,
  9000. // "type": "string"
  9001. // },
  9002. // "userId": {
  9003. // "default": "me",
  9004. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9005. // "location": "path",
  9006. // "required": true,
  9007. // "type": "string"
  9008. // }
  9009. // },
  9010. // "path": "{userId}/settings/sendAs/{sendAsEmail}/verify",
  9011. // "scopes": [
  9012. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9013. // ]
  9014. // }
  9015. }
  9016. // method id "gmail.users.settings.sendAs.smimeInfo.delete":
  9017. type UsersSettingsSendAsSmimeInfoDeleteCall struct {
  9018. s *Service
  9019. userId string
  9020. sendAsEmail string
  9021. id string
  9022. urlParams_ gensupport.URLParams
  9023. ctx_ context.Context
  9024. header_ http.Header
  9025. }
  9026. // Delete: Deletes the specified S/MIME config for the specified send-as
  9027. // alias.
  9028. func (r *UsersSettingsSendAsSmimeInfoService) Delete(userId string, sendAsEmail string, id string) *UsersSettingsSendAsSmimeInfoDeleteCall {
  9029. c := &UsersSettingsSendAsSmimeInfoDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9030. c.userId = userId
  9031. c.sendAsEmail = sendAsEmail
  9032. c.id = id
  9033. return c
  9034. }
  9035. // Fields allows partial responses to be retrieved. See
  9036. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9037. // for more information.
  9038. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoDeleteCall {
  9039. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9040. return c
  9041. }
  9042. // Context sets the context to be used in this call's Do method. Any
  9043. // pending HTTP request will be aborted if the provided context is
  9044. // canceled.
  9045. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoDeleteCall {
  9046. c.ctx_ = ctx
  9047. return c
  9048. }
  9049. // Header returns an http.Header that can be modified by the caller to
  9050. // add HTTP headers to the request.
  9051. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Header() http.Header {
  9052. if c.header_ == nil {
  9053. c.header_ = make(http.Header)
  9054. }
  9055. return c.header_
  9056. }
  9057. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) doRequest(alt string) (*http.Response, error) {
  9058. reqHeaders := make(http.Header)
  9059. for k, v := range c.header_ {
  9060. reqHeaders[k] = v
  9061. }
  9062. reqHeaders.Set("User-Agent", c.s.userAgent())
  9063. var body io.Reader = nil
  9064. c.urlParams_.Set("alt", alt)
  9065. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}")
  9066. urls += "?" + c.urlParams_.Encode()
  9067. req, _ := http.NewRequest("DELETE", urls, body)
  9068. req.Header = reqHeaders
  9069. googleapi.Expand(req.URL, map[string]string{
  9070. "userId": c.userId,
  9071. "sendAsEmail": c.sendAsEmail,
  9072. "id": c.id,
  9073. })
  9074. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9075. }
  9076. // Do executes the "gmail.users.settings.sendAs.smimeInfo.delete" call.
  9077. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Do(opts ...googleapi.CallOption) error {
  9078. gensupport.SetOptions(c.urlParams_, opts...)
  9079. res, err := c.doRequest("json")
  9080. if err != nil {
  9081. return err
  9082. }
  9083. defer googleapi.CloseBody(res)
  9084. if err := googleapi.CheckResponse(res); err != nil {
  9085. return err
  9086. }
  9087. return nil
  9088. // {
  9089. // "description": "Deletes the specified S/MIME config for the specified send-as alias.",
  9090. // "httpMethod": "DELETE",
  9091. // "id": "gmail.users.settings.sendAs.smimeInfo.delete",
  9092. // "parameterOrder": [
  9093. // "userId",
  9094. // "sendAsEmail",
  9095. // "id"
  9096. // ],
  9097. // "parameters": {
  9098. // "id": {
  9099. // "description": "The immutable ID for the SmimeInfo.",
  9100. // "location": "path",
  9101. // "required": true,
  9102. // "type": "string"
  9103. // },
  9104. // "sendAsEmail": {
  9105. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  9106. // "location": "path",
  9107. // "required": true,
  9108. // "type": "string"
  9109. // },
  9110. // "userId": {
  9111. // "default": "me",
  9112. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9113. // "location": "path",
  9114. // "required": true,
  9115. // "type": "string"
  9116. // }
  9117. // },
  9118. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}",
  9119. // "scopes": [
  9120. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9121. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9122. // ]
  9123. // }
  9124. }
  9125. // method id "gmail.users.settings.sendAs.smimeInfo.get":
  9126. type UsersSettingsSendAsSmimeInfoGetCall struct {
  9127. s *Service
  9128. userId string
  9129. sendAsEmail string
  9130. id string
  9131. urlParams_ gensupport.URLParams
  9132. ifNoneMatch_ string
  9133. ctx_ context.Context
  9134. header_ http.Header
  9135. }
  9136. // Get: Gets the specified S/MIME config for the specified send-as
  9137. // alias.
  9138. func (r *UsersSettingsSendAsSmimeInfoService) Get(userId string, sendAsEmail string, id string) *UsersSettingsSendAsSmimeInfoGetCall {
  9139. c := &UsersSettingsSendAsSmimeInfoGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9140. c.userId = userId
  9141. c.sendAsEmail = sendAsEmail
  9142. c.id = id
  9143. return c
  9144. }
  9145. // Fields allows partial responses to be retrieved. See
  9146. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9147. // for more information.
  9148. func (c *UsersSettingsSendAsSmimeInfoGetCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoGetCall {
  9149. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9150. return c
  9151. }
  9152. // IfNoneMatch sets the optional parameter which makes the operation
  9153. // fail if the object's ETag matches the given value. This is useful for
  9154. // getting updates only after the object has changed since the last
  9155. // request. Use googleapi.IsNotModified to check whether the response
  9156. // error from Do is the result of In-None-Match.
  9157. func (c *UsersSettingsSendAsSmimeInfoGetCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsSmimeInfoGetCall {
  9158. c.ifNoneMatch_ = entityTag
  9159. return c
  9160. }
  9161. // Context sets the context to be used in this call's Do method. Any
  9162. // pending HTTP request will be aborted if the provided context is
  9163. // canceled.
  9164. func (c *UsersSettingsSendAsSmimeInfoGetCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoGetCall {
  9165. c.ctx_ = ctx
  9166. return c
  9167. }
  9168. // Header returns an http.Header that can be modified by the caller to
  9169. // add HTTP headers to the request.
  9170. func (c *UsersSettingsSendAsSmimeInfoGetCall) Header() http.Header {
  9171. if c.header_ == nil {
  9172. c.header_ = make(http.Header)
  9173. }
  9174. return c.header_
  9175. }
  9176. func (c *UsersSettingsSendAsSmimeInfoGetCall) doRequest(alt string) (*http.Response, error) {
  9177. reqHeaders := make(http.Header)
  9178. for k, v := range c.header_ {
  9179. reqHeaders[k] = v
  9180. }
  9181. reqHeaders.Set("User-Agent", c.s.userAgent())
  9182. if c.ifNoneMatch_ != "" {
  9183. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  9184. }
  9185. var body io.Reader = nil
  9186. c.urlParams_.Set("alt", alt)
  9187. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}")
  9188. urls += "?" + c.urlParams_.Encode()
  9189. req, _ := http.NewRequest("GET", urls, body)
  9190. req.Header = reqHeaders
  9191. googleapi.Expand(req.URL, map[string]string{
  9192. "userId": c.userId,
  9193. "sendAsEmail": c.sendAsEmail,
  9194. "id": c.id,
  9195. })
  9196. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9197. }
  9198. // Do executes the "gmail.users.settings.sendAs.smimeInfo.get" call.
  9199. // Exactly one of *SmimeInfo or error will be non-nil. Any non-2xx
  9200. // status code is an error. Response headers are in either
  9201. // *SmimeInfo.ServerResponse.Header or (if a response was returned at
  9202. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  9203. // to check whether the returned error was because
  9204. // http.StatusNotModified was returned.
  9205. func (c *UsersSettingsSendAsSmimeInfoGetCall) Do(opts ...googleapi.CallOption) (*SmimeInfo, error) {
  9206. gensupport.SetOptions(c.urlParams_, opts...)
  9207. res, err := c.doRequest("json")
  9208. if res != nil && res.StatusCode == http.StatusNotModified {
  9209. if res.Body != nil {
  9210. res.Body.Close()
  9211. }
  9212. return nil, &googleapi.Error{
  9213. Code: res.StatusCode,
  9214. Header: res.Header,
  9215. }
  9216. }
  9217. if err != nil {
  9218. return nil, err
  9219. }
  9220. defer googleapi.CloseBody(res)
  9221. if err := googleapi.CheckResponse(res); err != nil {
  9222. return nil, err
  9223. }
  9224. ret := &SmimeInfo{
  9225. ServerResponse: googleapi.ServerResponse{
  9226. Header: res.Header,
  9227. HTTPStatusCode: res.StatusCode,
  9228. },
  9229. }
  9230. target := &ret
  9231. if err := gensupport.DecodeResponse(target, res); err != nil {
  9232. return nil, err
  9233. }
  9234. return ret, nil
  9235. // {
  9236. // "description": "Gets the specified S/MIME config for the specified send-as alias.",
  9237. // "httpMethod": "GET",
  9238. // "id": "gmail.users.settings.sendAs.smimeInfo.get",
  9239. // "parameterOrder": [
  9240. // "userId",
  9241. // "sendAsEmail",
  9242. // "id"
  9243. // ],
  9244. // "parameters": {
  9245. // "id": {
  9246. // "description": "The immutable ID for the SmimeInfo.",
  9247. // "location": "path",
  9248. // "required": true,
  9249. // "type": "string"
  9250. // },
  9251. // "sendAsEmail": {
  9252. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  9253. // "location": "path",
  9254. // "required": true,
  9255. // "type": "string"
  9256. // },
  9257. // "userId": {
  9258. // "default": "me",
  9259. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9260. // "location": "path",
  9261. // "required": true,
  9262. // "type": "string"
  9263. // }
  9264. // },
  9265. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}",
  9266. // "response": {
  9267. // "$ref": "SmimeInfo"
  9268. // },
  9269. // "scopes": [
  9270. // "https://mail.google.com/",
  9271. // "https://www.googleapis.com/auth/gmail.modify",
  9272. // "https://www.googleapis.com/auth/gmail.readonly",
  9273. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9274. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9275. // ]
  9276. // }
  9277. }
  9278. // method id "gmail.users.settings.sendAs.smimeInfo.insert":
  9279. type UsersSettingsSendAsSmimeInfoInsertCall struct {
  9280. s *Service
  9281. userId string
  9282. sendAsEmail string
  9283. smimeinfo *SmimeInfo
  9284. urlParams_ gensupport.URLParams
  9285. ctx_ context.Context
  9286. header_ http.Header
  9287. }
  9288. // Insert: Insert (upload) the given S/MIME config for the specified
  9289. // send-as alias. Note that pkcs12 format is required for the key.
  9290. func (r *UsersSettingsSendAsSmimeInfoService) Insert(userId string, sendAsEmail string, smimeinfo *SmimeInfo) *UsersSettingsSendAsSmimeInfoInsertCall {
  9291. c := &UsersSettingsSendAsSmimeInfoInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9292. c.userId = userId
  9293. c.sendAsEmail = sendAsEmail
  9294. c.smimeinfo = smimeinfo
  9295. return c
  9296. }
  9297. // Fields allows partial responses to be retrieved. See
  9298. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9299. // for more information.
  9300. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoInsertCall {
  9301. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9302. return c
  9303. }
  9304. // Context sets the context to be used in this call's Do method. Any
  9305. // pending HTTP request will be aborted if the provided context is
  9306. // canceled.
  9307. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoInsertCall {
  9308. c.ctx_ = ctx
  9309. return c
  9310. }
  9311. // Header returns an http.Header that can be modified by the caller to
  9312. // add HTTP headers to the request.
  9313. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Header() http.Header {
  9314. if c.header_ == nil {
  9315. c.header_ = make(http.Header)
  9316. }
  9317. return c.header_
  9318. }
  9319. func (c *UsersSettingsSendAsSmimeInfoInsertCall) doRequest(alt string) (*http.Response, error) {
  9320. reqHeaders := make(http.Header)
  9321. for k, v := range c.header_ {
  9322. reqHeaders[k] = v
  9323. }
  9324. reqHeaders.Set("User-Agent", c.s.userAgent())
  9325. var body io.Reader = nil
  9326. body, err := googleapi.WithoutDataWrapper.JSONReader(c.smimeinfo)
  9327. if err != nil {
  9328. return nil, err
  9329. }
  9330. reqHeaders.Set("Content-Type", "application/json")
  9331. c.urlParams_.Set("alt", alt)
  9332. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo")
  9333. urls += "?" + c.urlParams_.Encode()
  9334. req, _ := http.NewRequest("POST", urls, body)
  9335. req.Header = reqHeaders
  9336. googleapi.Expand(req.URL, map[string]string{
  9337. "userId": c.userId,
  9338. "sendAsEmail": c.sendAsEmail,
  9339. })
  9340. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9341. }
  9342. // Do executes the "gmail.users.settings.sendAs.smimeInfo.insert" call.
  9343. // Exactly one of *SmimeInfo or error will be non-nil. Any non-2xx
  9344. // status code is an error. Response headers are in either
  9345. // *SmimeInfo.ServerResponse.Header or (if a response was returned at
  9346. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  9347. // to check whether the returned error was because
  9348. // http.StatusNotModified was returned.
  9349. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Do(opts ...googleapi.CallOption) (*SmimeInfo, error) {
  9350. gensupport.SetOptions(c.urlParams_, opts...)
  9351. res, err := c.doRequest("json")
  9352. if res != nil && res.StatusCode == http.StatusNotModified {
  9353. if res.Body != nil {
  9354. res.Body.Close()
  9355. }
  9356. return nil, &googleapi.Error{
  9357. Code: res.StatusCode,
  9358. Header: res.Header,
  9359. }
  9360. }
  9361. if err != nil {
  9362. return nil, err
  9363. }
  9364. defer googleapi.CloseBody(res)
  9365. if err := googleapi.CheckResponse(res); err != nil {
  9366. return nil, err
  9367. }
  9368. ret := &SmimeInfo{
  9369. ServerResponse: googleapi.ServerResponse{
  9370. Header: res.Header,
  9371. HTTPStatusCode: res.StatusCode,
  9372. },
  9373. }
  9374. target := &ret
  9375. if err := gensupport.DecodeResponse(target, res); err != nil {
  9376. return nil, err
  9377. }
  9378. return ret, nil
  9379. // {
  9380. // "description": "Insert (upload) the given S/MIME config for the specified send-as alias. Note that pkcs12 format is required for the key.",
  9381. // "httpMethod": "POST",
  9382. // "id": "gmail.users.settings.sendAs.smimeInfo.insert",
  9383. // "parameterOrder": [
  9384. // "userId",
  9385. // "sendAsEmail"
  9386. // ],
  9387. // "parameters": {
  9388. // "sendAsEmail": {
  9389. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  9390. // "location": "path",
  9391. // "required": true,
  9392. // "type": "string"
  9393. // },
  9394. // "userId": {
  9395. // "default": "me",
  9396. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9397. // "location": "path",
  9398. // "required": true,
  9399. // "type": "string"
  9400. // }
  9401. // },
  9402. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo",
  9403. // "request": {
  9404. // "$ref": "SmimeInfo"
  9405. // },
  9406. // "response": {
  9407. // "$ref": "SmimeInfo"
  9408. // },
  9409. // "scopes": [
  9410. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9411. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9412. // ]
  9413. // }
  9414. }
  9415. // method id "gmail.users.settings.sendAs.smimeInfo.list":
  9416. type UsersSettingsSendAsSmimeInfoListCall struct {
  9417. s *Service
  9418. userId string
  9419. sendAsEmail string
  9420. urlParams_ gensupport.URLParams
  9421. ifNoneMatch_ string
  9422. ctx_ context.Context
  9423. header_ http.Header
  9424. }
  9425. // List: Lists S/MIME configs for the specified send-as alias.
  9426. func (r *UsersSettingsSendAsSmimeInfoService) List(userId string, sendAsEmail string) *UsersSettingsSendAsSmimeInfoListCall {
  9427. c := &UsersSettingsSendAsSmimeInfoListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9428. c.userId = userId
  9429. c.sendAsEmail = sendAsEmail
  9430. return c
  9431. }
  9432. // Fields allows partial responses to be retrieved. See
  9433. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9434. // for more information.
  9435. func (c *UsersSettingsSendAsSmimeInfoListCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoListCall {
  9436. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9437. return c
  9438. }
  9439. // IfNoneMatch sets the optional parameter which makes the operation
  9440. // fail if the object's ETag matches the given value. This is useful for
  9441. // getting updates only after the object has changed since the last
  9442. // request. Use googleapi.IsNotModified to check whether the response
  9443. // error from Do is the result of In-None-Match.
  9444. func (c *UsersSettingsSendAsSmimeInfoListCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsSmimeInfoListCall {
  9445. c.ifNoneMatch_ = entityTag
  9446. return c
  9447. }
  9448. // Context sets the context to be used in this call's Do method. Any
  9449. // pending HTTP request will be aborted if the provided context is
  9450. // canceled.
  9451. func (c *UsersSettingsSendAsSmimeInfoListCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoListCall {
  9452. c.ctx_ = ctx
  9453. return c
  9454. }
  9455. // Header returns an http.Header that can be modified by the caller to
  9456. // add HTTP headers to the request.
  9457. func (c *UsersSettingsSendAsSmimeInfoListCall) Header() http.Header {
  9458. if c.header_ == nil {
  9459. c.header_ = make(http.Header)
  9460. }
  9461. return c.header_
  9462. }
  9463. func (c *UsersSettingsSendAsSmimeInfoListCall) doRequest(alt string) (*http.Response, error) {
  9464. reqHeaders := make(http.Header)
  9465. for k, v := range c.header_ {
  9466. reqHeaders[k] = v
  9467. }
  9468. reqHeaders.Set("User-Agent", c.s.userAgent())
  9469. if c.ifNoneMatch_ != "" {
  9470. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  9471. }
  9472. var body io.Reader = nil
  9473. c.urlParams_.Set("alt", alt)
  9474. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo")
  9475. urls += "?" + c.urlParams_.Encode()
  9476. req, _ := http.NewRequest("GET", urls, body)
  9477. req.Header = reqHeaders
  9478. googleapi.Expand(req.URL, map[string]string{
  9479. "userId": c.userId,
  9480. "sendAsEmail": c.sendAsEmail,
  9481. })
  9482. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9483. }
  9484. // Do executes the "gmail.users.settings.sendAs.smimeInfo.list" call.
  9485. // Exactly one of *ListSmimeInfoResponse or error will be non-nil. Any
  9486. // non-2xx status code is an error. Response headers are in either
  9487. // *ListSmimeInfoResponse.ServerResponse.Header or (if a response was
  9488. // returned at all) in error.(*googleapi.Error).Header. Use
  9489. // googleapi.IsNotModified to check whether the returned error was
  9490. // because http.StatusNotModified was returned.
  9491. func (c *UsersSettingsSendAsSmimeInfoListCall) Do(opts ...googleapi.CallOption) (*ListSmimeInfoResponse, error) {
  9492. gensupport.SetOptions(c.urlParams_, opts...)
  9493. res, err := c.doRequest("json")
  9494. if res != nil && res.StatusCode == http.StatusNotModified {
  9495. if res.Body != nil {
  9496. res.Body.Close()
  9497. }
  9498. return nil, &googleapi.Error{
  9499. Code: res.StatusCode,
  9500. Header: res.Header,
  9501. }
  9502. }
  9503. if err != nil {
  9504. return nil, err
  9505. }
  9506. defer googleapi.CloseBody(res)
  9507. if err := googleapi.CheckResponse(res); err != nil {
  9508. return nil, err
  9509. }
  9510. ret := &ListSmimeInfoResponse{
  9511. ServerResponse: googleapi.ServerResponse{
  9512. Header: res.Header,
  9513. HTTPStatusCode: res.StatusCode,
  9514. },
  9515. }
  9516. target := &ret
  9517. if err := gensupport.DecodeResponse(target, res); err != nil {
  9518. return nil, err
  9519. }
  9520. return ret, nil
  9521. // {
  9522. // "description": "Lists S/MIME configs for the specified send-as alias.",
  9523. // "httpMethod": "GET",
  9524. // "id": "gmail.users.settings.sendAs.smimeInfo.list",
  9525. // "parameterOrder": [
  9526. // "userId",
  9527. // "sendAsEmail"
  9528. // ],
  9529. // "parameters": {
  9530. // "sendAsEmail": {
  9531. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  9532. // "location": "path",
  9533. // "required": true,
  9534. // "type": "string"
  9535. // },
  9536. // "userId": {
  9537. // "default": "me",
  9538. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9539. // "location": "path",
  9540. // "required": true,
  9541. // "type": "string"
  9542. // }
  9543. // },
  9544. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo",
  9545. // "response": {
  9546. // "$ref": "ListSmimeInfoResponse"
  9547. // },
  9548. // "scopes": [
  9549. // "https://mail.google.com/",
  9550. // "https://www.googleapis.com/auth/gmail.modify",
  9551. // "https://www.googleapis.com/auth/gmail.readonly",
  9552. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9553. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9554. // ]
  9555. // }
  9556. }
  9557. // method id "gmail.users.settings.sendAs.smimeInfo.setDefault":
  9558. type UsersSettingsSendAsSmimeInfoSetDefaultCall struct {
  9559. s *Service
  9560. userId string
  9561. sendAsEmail string
  9562. id string
  9563. urlParams_ gensupport.URLParams
  9564. ctx_ context.Context
  9565. header_ http.Header
  9566. }
  9567. // SetDefault: Sets the default S/MIME config for the specified send-as
  9568. // alias.
  9569. func (r *UsersSettingsSendAsSmimeInfoService) SetDefault(userId string, sendAsEmail string, id string) *UsersSettingsSendAsSmimeInfoSetDefaultCall {
  9570. c := &UsersSettingsSendAsSmimeInfoSetDefaultCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9571. c.userId = userId
  9572. c.sendAsEmail = sendAsEmail
  9573. c.id = id
  9574. return c
  9575. }
  9576. // Fields allows partial responses to be retrieved. See
  9577. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9578. // for more information.
  9579. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoSetDefaultCall {
  9580. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9581. return c
  9582. }
  9583. // Context sets the context to be used in this call's Do method. Any
  9584. // pending HTTP request will be aborted if the provided context is
  9585. // canceled.
  9586. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoSetDefaultCall {
  9587. c.ctx_ = ctx
  9588. return c
  9589. }
  9590. // Header returns an http.Header that can be modified by the caller to
  9591. // add HTTP headers to the request.
  9592. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Header() http.Header {
  9593. if c.header_ == nil {
  9594. c.header_ = make(http.Header)
  9595. }
  9596. return c.header_
  9597. }
  9598. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) doRequest(alt string) (*http.Response, error) {
  9599. reqHeaders := make(http.Header)
  9600. for k, v := range c.header_ {
  9601. reqHeaders[k] = v
  9602. }
  9603. reqHeaders.Set("User-Agent", c.s.userAgent())
  9604. var body io.Reader = nil
  9605. c.urlParams_.Set("alt", alt)
  9606. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault")
  9607. urls += "?" + c.urlParams_.Encode()
  9608. req, _ := http.NewRequest("POST", urls, body)
  9609. req.Header = reqHeaders
  9610. googleapi.Expand(req.URL, map[string]string{
  9611. "userId": c.userId,
  9612. "sendAsEmail": c.sendAsEmail,
  9613. "id": c.id,
  9614. })
  9615. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9616. }
  9617. // Do executes the "gmail.users.settings.sendAs.smimeInfo.setDefault" call.
  9618. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Do(opts ...googleapi.CallOption) error {
  9619. gensupport.SetOptions(c.urlParams_, opts...)
  9620. res, err := c.doRequest("json")
  9621. if err != nil {
  9622. return err
  9623. }
  9624. defer googleapi.CloseBody(res)
  9625. if err := googleapi.CheckResponse(res); err != nil {
  9626. return err
  9627. }
  9628. return nil
  9629. // {
  9630. // "description": "Sets the default S/MIME config for the specified send-as alias.",
  9631. // "httpMethod": "POST",
  9632. // "id": "gmail.users.settings.sendAs.smimeInfo.setDefault",
  9633. // "parameterOrder": [
  9634. // "userId",
  9635. // "sendAsEmail",
  9636. // "id"
  9637. // ],
  9638. // "parameters": {
  9639. // "id": {
  9640. // "description": "The immutable ID for the SmimeInfo.",
  9641. // "location": "path",
  9642. // "required": true,
  9643. // "type": "string"
  9644. // },
  9645. // "sendAsEmail": {
  9646. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  9647. // "location": "path",
  9648. // "required": true,
  9649. // "type": "string"
  9650. // },
  9651. // "userId": {
  9652. // "default": "me",
  9653. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9654. // "location": "path",
  9655. // "required": true,
  9656. // "type": "string"
  9657. // }
  9658. // },
  9659. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault",
  9660. // "scopes": [
  9661. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9662. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9663. // ]
  9664. // }
  9665. }
  9666. // method id "gmail.users.threads.delete":
  9667. type UsersThreadsDeleteCall struct {
  9668. s *Service
  9669. userId string
  9670. id string
  9671. urlParams_ gensupport.URLParams
  9672. ctx_ context.Context
  9673. header_ http.Header
  9674. }
  9675. // Delete: Immediately and permanently deletes the specified thread.
  9676. // This operation cannot be undone. Prefer threads.trash instead.
  9677. func (r *UsersThreadsService) Delete(userId string, id string) *UsersThreadsDeleteCall {
  9678. c := &UsersThreadsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9679. c.userId = userId
  9680. c.id = id
  9681. return c
  9682. }
  9683. // Fields allows partial responses to be retrieved. See
  9684. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9685. // for more information.
  9686. func (c *UsersThreadsDeleteCall) Fields(s ...googleapi.Field) *UsersThreadsDeleteCall {
  9687. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9688. return c
  9689. }
  9690. // Context sets the context to be used in this call's Do method. Any
  9691. // pending HTTP request will be aborted if the provided context is
  9692. // canceled.
  9693. func (c *UsersThreadsDeleteCall) Context(ctx context.Context) *UsersThreadsDeleteCall {
  9694. c.ctx_ = ctx
  9695. return c
  9696. }
  9697. // Header returns an http.Header that can be modified by the caller to
  9698. // add HTTP headers to the request.
  9699. func (c *UsersThreadsDeleteCall) Header() http.Header {
  9700. if c.header_ == nil {
  9701. c.header_ = make(http.Header)
  9702. }
  9703. return c.header_
  9704. }
  9705. func (c *UsersThreadsDeleteCall) doRequest(alt string) (*http.Response, error) {
  9706. reqHeaders := make(http.Header)
  9707. for k, v := range c.header_ {
  9708. reqHeaders[k] = v
  9709. }
  9710. reqHeaders.Set("User-Agent", c.s.userAgent())
  9711. var body io.Reader = nil
  9712. c.urlParams_.Set("alt", alt)
  9713. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
  9714. urls += "?" + c.urlParams_.Encode()
  9715. req, _ := http.NewRequest("DELETE", urls, body)
  9716. req.Header = reqHeaders
  9717. googleapi.Expand(req.URL, map[string]string{
  9718. "userId": c.userId,
  9719. "id": c.id,
  9720. })
  9721. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9722. }
  9723. // Do executes the "gmail.users.threads.delete" call.
  9724. func (c *UsersThreadsDeleteCall) Do(opts ...googleapi.CallOption) error {
  9725. gensupport.SetOptions(c.urlParams_, opts...)
  9726. res, err := c.doRequest("json")
  9727. if err != nil {
  9728. return err
  9729. }
  9730. defer googleapi.CloseBody(res)
  9731. if err := googleapi.CheckResponse(res); err != nil {
  9732. return err
  9733. }
  9734. return nil
  9735. // {
  9736. // "description": "Immediately and permanently deletes the specified thread. This operation cannot be undone. Prefer threads.trash instead.",
  9737. // "httpMethod": "DELETE",
  9738. // "id": "gmail.users.threads.delete",
  9739. // "parameterOrder": [
  9740. // "userId",
  9741. // "id"
  9742. // ],
  9743. // "parameters": {
  9744. // "id": {
  9745. // "description": "ID of the Thread to delete.",
  9746. // "location": "path",
  9747. // "required": true,
  9748. // "type": "string"
  9749. // },
  9750. // "userId": {
  9751. // "default": "me",
  9752. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9753. // "location": "path",
  9754. // "required": true,
  9755. // "type": "string"
  9756. // }
  9757. // },
  9758. // "path": "{userId}/threads/{id}",
  9759. // "scopes": [
  9760. // "https://mail.google.com/"
  9761. // ]
  9762. // }
  9763. }
  9764. // method id "gmail.users.threads.get":
  9765. type UsersThreadsGetCall struct {
  9766. s *Service
  9767. userId string
  9768. id string
  9769. urlParams_ gensupport.URLParams
  9770. ifNoneMatch_ string
  9771. ctx_ context.Context
  9772. header_ http.Header
  9773. }
  9774. // Get: Gets the specified thread.
  9775. func (r *UsersThreadsService) Get(userId string, id string) *UsersThreadsGetCall {
  9776. c := &UsersThreadsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9777. c.userId = userId
  9778. c.id = id
  9779. return c
  9780. }
  9781. // Format sets the optional parameter "format": The format to return the
  9782. // messages in.
  9783. //
  9784. // Possible values:
  9785. // "full" (default)
  9786. // "metadata"
  9787. // "minimal"
  9788. func (c *UsersThreadsGetCall) Format(format string) *UsersThreadsGetCall {
  9789. c.urlParams_.Set("format", format)
  9790. return c
  9791. }
  9792. // MetadataHeaders sets the optional parameter "metadataHeaders": When
  9793. // given and format is METADATA, only include headers specified.
  9794. func (c *UsersThreadsGetCall) MetadataHeaders(metadataHeaders ...string) *UsersThreadsGetCall {
  9795. c.urlParams_.SetMulti("metadataHeaders", append([]string{}, metadataHeaders...))
  9796. return c
  9797. }
  9798. // Fields allows partial responses to be retrieved. See
  9799. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9800. // for more information.
  9801. func (c *UsersThreadsGetCall) Fields(s ...googleapi.Field) *UsersThreadsGetCall {
  9802. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9803. return c
  9804. }
  9805. // IfNoneMatch sets the optional parameter which makes the operation
  9806. // fail if the object's ETag matches the given value. This is useful for
  9807. // getting updates only after the object has changed since the last
  9808. // request. Use googleapi.IsNotModified to check whether the response
  9809. // error from Do is the result of In-None-Match.
  9810. func (c *UsersThreadsGetCall) IfNoneMatch(entityTag string) *UsersThreadsGetCall {
  9811. c.ifNoneMatch_ = entityTag
  9812. return c
  9813. }
  9814. // Context sets the context to be used in this call's Do method. Any
  9815. // pending HTTP request will be aborted if the provided context is
  9816. // canceled.
  9817. func (c *UsersThreadsGetCall) Context(ctx context.Context) *UsersThreadsGetCall {
  9818. c.ctx_ = ctx
  9819. return c
  9820. }
  9821. // Header returns an http.Header that can be modified by the caller to
  9822. // add HTTP headers to the request.
  9823. func (c *UsersThreadsGetCall) Header() http.Header {
  9824. if c.header_ == nil {
  9825. c.header_ = make(http.Header)
  9826. }
  9827. return c.header_
  9828. }
  9829. func (c *UsersThreadsGetCall) doRequest(alt string) (*http.Response, error) {
  9830. reqHeaders := make(http.Header)
  9831. for k, v := range c.header_ {
  9832. reqHeaders[k] = v
  9833. }
  9834. reqHeaders.Set("User-Agent", c.s.userAgent())
  9835. if c.ifNoneMatch_ != "" {
  9836. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  9837. }
  9838. var body io.Reader = nil
  9839. c.urlParams_.Set("alt", alt)
  9840. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
  9841. urls += "?" + c.urlParams_.Encode()
  9842. req, _ := http.NewRequest("GET", urls, body)
  9843. req.Header = reqHeaders
  9844. googleapi.Expand(req.URL, map[string]string{
  9845. "userId": c.userId,
  9846. "id": c.id,
  9847. })
  9848. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9849. }
  9850. // Do executes the "gmail.users.threads.get" call.
  9851. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  9852. // code is an error. Response headers are in either
  9853. // *Thread.ServerResponse.Header or (if a response was returned at all)
  9854. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  9855. // check whether the returned error was because http.StatusNotModified
  9856. // was returned.
  9857. func (c *UsersThreadsGetCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  9858. gensupport.SetOptions(c.urlParams_, opts...)
  9859. res, err := c.doRequest("json")
  9860. if res != nil && res.StatusCode == http.StatusNotModified {
  9861. if res.Body != nil {
  9862. res.Body.Close()
  9863. }
  9864. return nil, &googleapi.Error{
  9865. Code: res.StatusCode,
  9866. Header: res.Header,
  9867. }
  9868. }
  9869. if err != nil {
  9870. return nil, err
  9871. }
  9872. defer googleapi.CloseBody(res)
  9873. if err := googleapi.CheckResponse(res); err != nil {
  9874. return nil, err
  9875. }
  9876. ret := &Thread{
  9877. ServerResponse: googleapi.ServerResponse{
  9878. Header: res.Header,
  9879. HTTPStatusCode: res.StatusCode,
  9880. },
  9881. }
  9882. target := &ret
  9883. if err := gensupport.DecodeResponse(target, res); err != nil {
  9884. return nil, err
  9885. }
  9886. return ret, nil
  9887. // {
  9888. // "description": "Gets the specified thread.",
  9889. // "httpMethod": "GET",
  9890. // "id": "gmail.users.threads.get",
  9891. // "parameterOrder": [
  9892. // "userId",
  9893. // "id"
  9894. // ],
  9895. // "parameters": {
  9896. // "format": {
  9897. // "default": "full",
  9898. // "description": "The format to return the messages in.",
  9899. // "enum": [
  9900. // "full",
  9901. // "metadata",
  9902. // "minimal"
  9903. // ],
  9904. // "enumDescriptions": [
  9905. // "",
  9906. // "",
  9907. // ""
  9908. // ],
  9909. // "location": "query",
  9910. // "type": "string"
  9911. // },
  9912. // "id": {
  9913. // "description": "The ID of the thread to retrieve.",
  9914. // "location": "path",
  9915. // "required": true,
  9916. // "type": "string"
  9917. // },
  9918. // "metadataHeaders": {
  9919. // "description": "When given and format is METADATA, only include headers specified.",
  9920. // "location": "query",
  9921. // "repeated": true,
  9922. // "type": "string"
  9923. // },
  9924. // "userId": {
  9925. // "default": "me",
  9926. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  9927. // "location": "path",
  9928. // "required": true,
  9929. // "type": "string"
  9930. // }
  9931. // },
  9932. // "path": "{userId}/threads/{id}",
  9933. // "response": {
  9934. // "$ref": "Thread"
  9935. // },
  9936. // "scopes": [
  9937. // "https://mail.google.com/",
  9938. // "https://www.googleapis.com/auth/gmail.metadata",
  9939. // "https://www.googleapis.com/auth/gmail.modify",
  9940. // "https://www.googleapis.com/auth/gmail.readonly"
  9941. // ]
  9942. // }
  9943. }
  9944. // method id "gmail.users.threads.list":
  9945. type UsersThreadsListCall struct {
  9946. s *Service
  9947. userId string
  9948. urlParams_ gensupport.URLParams
  9949. ifNoneMatch_ string
  9950. ctx_ context.Context
  9951. header_ http.Header
  9952. }
  9953. // List: Lists the threads in the user's mailbox.
  9954. func (r *UsersThreadsService) List(userId string) *UsersThreadsListCall {
  9955. c := &UsersThreadsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9956. c.userId = userId
  9957. return c
  9958. }
  9959. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  9960. // Include threads from SPAM and TRASH in the results.
  9961. func (c *UsersThreadsListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersThreadsListCall {
  9962. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  9963. return c
  9964. }
  9965. // LabelIds sets the optional parameter "labelIds": Only return threads
  9966. // with labels that match all of the specified label IDs.
  9967. func (c *UsersThreadsListCall) LabelIds(labelIds ...string) *UsersThreadsListCall {
  9968. c.urlParams_.SetMulti("labelIds", append([]string{}, labelIds...))
  9969. return c
  9970. }
  9971. // MaxResults sets the optional parameter "maxResults": Maximum number
  9972. // of threads to return.
  9973. func (c *UsersThreadsListCall) MaxResults(maxResults int64) *UsersThreadsListCall {
  9974. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  9975. return c
  9976. }
  9977. // PageToken sets the optional parameter "pageToken": Page token to
  9978. // retrieve a specific page of results in the list.
  9979. func (c *UsersThreadsListCall) PageToken(pageToken string) *UsersThreadsListCall {
  9980. c.urlParams_.Set("pageToken", pageToken)
  9981. return c
  9982. }
  9983. // Q sets the optional parameter "q": Only return threads matching the
  9984. // specified query. Supports the same query format as the Gmail search
  9985. // box. For example, "from:someuser@example.com rfc822msgid: is:unread".
  9986. // Parameter cannot be used when accessing the api using the
  9987. // gmail.metadata scope.
  9988. func (c *UsersThreadsListCall) Q(q string) *UsersThreadsListCall {
  9989. c.urlParams_.Set("q", q)
  9990. return c
  9991. }
  9992. // Fields allows partial responses to be retrieved. See
  9993. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9994. // for more information.
  9995. func (c *UsersThreadsListCall) Fields(s ...googleapi.Field) *UsersThreadsListCall {
  9996. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9997. return c
  9998. }
  9999. // IfNoneMatch sets the optional parameter which makes the operation
  10000. // fail if the object's ETag matches the given value. This is useful for
  10001. // getting updates only after the object has changed since the last
  10002. // request. Use googleapi.IsNotModified to check whether the response
  10003. // error from Do is the result of In-None-Match.
  10004. func (c *UsersThreadsListCall) IfNoneMatch(entityTag string) *UsersThreadsListCall {
  10005. c.ifNoneMatch_ = entityTag
  10006. return c
  10007. }
  10008. // Context sets the context to be used in this call's Do method. Any
  10009. // pending HTTP request will be aborted if the provided context is
  10010. // canceled.
  10011. func (c *UsersThreadsListCall) Context(ctx context.Context) *UsersThreadsListCall {
  10012. c.ctx_ = ctx
  10013. return c
  10014. }
  10015. // Header returns an http.Header that can be modified by the caller to
  10016. // add HTTP headers to the request.
  10017. func (c *UsersThreadsListCall) Header() http.Header {
  10018. if c.header_ == nil {
  10019. c.header_ = make(http.Header)
  10020. }
  10021. return c.header_
  10022. }
  10023. func (c *UsersThreadsListCall) doRequest(alt string) (*http.Response, error) {
  10024. reqHeaders := make(http.Header)
  10025. for k, v := range c.header_ {
  10026. reqHeaders[k] = v
  10027. }
  10028. reqHeaders.Set("User-Agent", c.s.userAgent())
  10029. if c.ifNoneMatch_ != "" {
  10030. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  10031. }
  10032. var body io.Reader = nil
  10033. c.urlParams_.Set("alt", alt)
  10034. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads")
  10035. urls += "?" + c.urlParams_.Encode()
  10036. req, _ := http.NewRequest("GET", urls, body)
  10037. req.Header = reqHeaders
  10038. googleapi.Expand(req.URL, map[string]string{
  10039. "userId": c.userId,
  10040. })
  10041. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10042. }
  10043. // Do executes the "gmail.users.threads.list" call.
  10044. // Exactly one of *ListThreadsResponse or error will be non-nil. Any
  10045. // non-2xx status code is an error. Response headers are in either
  10046. // *ListThreadsResponse.ServerResponse.Header or (if a response was
  10047. // returned at all) in error.(*googleapi.Error).Header. Use
  10048. // googleapi.IsNotModified to check whether the returned error was
  10049. // because http.StatusNotModified was returned.
  10050. func (c *UsersThreadsListCall) Do(opts ...googleapi.CallOption) (*ListThreadsResponse, error) {
  10051. gensupport.SetOptions(c.urlParams_, opts...)
  10052. res, err := c.doRequest("json")
  10053. if res != nil && res.StatusCode == http.StatusNotModified {
  10054. if res.Body != nil {
  10055. res.Body.Close()
  10056. }
  10057. return nil, &googleapi.Error{
  10058. Code: res.StatusCode,
  10059. Header: res.Header,
  10060. }
  10061. }
  10062. if err != nil {
  10063. return nil, err
  10064. }
  10065. defer googleapi.CloseBody(res)
  10066. if err := googleapi.CheckResponse(res); err != nil {
  10067. return nil, err
  10068. }
  10069. ret := &ListThreadsResponse{
  10070. ServerResponse: googleapi.ServerResponse{
  10071. Header: res.Header,
  10072. HTTPStatusCode: res.StatusCode,
  10073. },
  10074. }
  10075. target := &ret
  10076. if err := gensupport.DecodeResponse(target, res); err != nil {
  10077. return nil, err
  10078. }
  10079. return ret, nil
  10080. // {
  10081. // "description": "Lists the threads in the user's mailbox.",
  10082. // "httpMethod": "GET",
  10083. // "id": "gmail.users.threads.list",
  10084. // "parameterOrder": [
  10085. // "userId"
  10086. // ],
  10087. // "parameters": {
  10088. // "includeSpamTrash": {
  10089. // "default": "false",
  10090. // "description": "Include threads from SPAM and TRASH in the results.",
  10091. // "location": "query",
  10092. // "type": "boolean"
  10093. // },
  10094. // "labelIds": {
  10095. // "description": "Only return threads with labels that match all of the specified label IDs.",
  10096. // "location": "query",
  10097. // "repeated": true,
  10098. // "type": "string"
  10099. // },
  10100. // "maxResults": {
  10101. // "default": "100",
  10102. // "description": "Maximum number of threads to return.",
  10103. // "format": "uint32",
  10104. // "location": "query",
  10105. // "type": "integer"
  10106. // },
  10107. // "pageToken": {
  10108. // "description": "Page token to retrieve a specific page of results in the list.",
  10109. // "location": "query",
  10110. // "type": "string"
  10111. // },
  10112. // "q": {
  10113. // "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\". Parameter cannot be used when accessing the api using the gmail.metadata scope.",
  10114. // "location": "query",
  10115. // "type": "string"
  10116. // },
  10117. // "userId": {
  10118. // "default": "me",
  10119. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10120. // "location": "path",
  10121. // "required": true,
  10122. // "type": "string"
  10123. // }
  10124. // },
  10125. // "path": "{userId}/threads",
  10126. // "response": {
  10127. // "$ref": "ListThreadsResponse"
  10128. // },
  10129. // "scopes": [
  10130. // "https://mail.google.com/",
  10131. // "https://www.googleapis.com/auth/gmail.metadata",
  10132. // "https://www.googleapis.com/auth/gmail.modify",
  10133. // "https://www.googleapis.com/auth/gmail.readonly"
  10134. // ]
  10135. // }
  10136. }
  10137. // Pages invokes f for each page of results.
  10138. // A non-nil error returned from f will halt the iteration.
  10139. // The provided context supersedes any context provided to the Context method.
  10140. func (c *UsersThreadsListCall) Pages(ctx context.Context, f func(*ListThreadsResponse) error) error {
  10141. c.ctx_ = ctx
  10142. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  10143. for {
  10144. x, err := c.Do()
  10145. if err != nil {
  10146. return err
  10147. }
  10148. if err := f(x); err != nil {
  10149. return err
  10150. }
  10151. if x.NextPageToken == "" {
  10152. return nil
  10153. }
  10154. c.PageToken(x.NextPageToken)
  10155. }
  10156. }
  10157. // method id "gmail.users.threads.modify":
  10158. type UsersThreadsModifyCall struct {
  10159. s *Service
  10160. userId string
  10161. id string
  10162. modifythreadrequest *ModifyThreadRequest
  10163. urlParams_ gensupport.URLParams
  10164. ctx_ context.Context
  10165. header_ http.Header
  10166. }
  10167. // Modify: Modifies the labels applied to the thread. This applies to
  10168. // all messages in the thread.
  10169. func (r *UsersThreadsService) Modify(userId string, id string, modifythreadrequest *ModifyThreadRequest) *UsersThreadsModifyCall {
  10170. c := &UsersThreadsModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10171. c.userId = userId
  10172. c.id = id
  10173. c.modifythreadrequest = modifythreadrequest
  10174. return c
  10175. }
  10176. // Fields allows partial responses to be retrieved. See
  10177. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10178. // for more information.
  10179. func (c *UsersThreadsModifyCall) Fields(s ...googleapi.Field) *UsersThreadsModifyCall {
  10180. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10181. return c
  10182. }
  10183. // Context sets the context to be used in this call's Do method. Any
  10184. // pending HTTP request will be aborted if the provided context is
  10185. // canceled.
  10186. func (c *UsersThreadsModifyCall) Context(ctx context.Context) *UsersThreadsModifyCall {
  10187. c.ctx_ = ctx
  10188. return c
  10189. }
  10190. // Header returns an http.Header that can be modified by the caller to
  10191. // add HTTP headers to the request.
  10192. func (c *UsersThreadsModifyCall) Header() http.Header {
  10193. if c.header_ == nil {
  10194. c.header_ = make(http.Header)
  10195. }
  10196. return c.header_
  10197. }
  10198. func (c *UsersThreadsModifyCall) doRequest(alt string) (*http.Response, error) {
  10199. reqHeaders := make(http.Header)
  10200. for k, v := range c.header_ {
  10201. reqHeaders[k] = v
  10202. }
  10203. reqHeaders.Set("User-Agent", c.s.userAgent())
  10204. var body io.Reader = nil
  10205. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifythreadrequest)
  10206. if err != nil {
  10207. return nil, err
  10208. }
  10209. reqHeaders.Set("Content-Type", "application/json")
  10210. c.urlParams_.Set("alt", alt)
  10211. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/modify")
  10212. urls += "?" + c.urlParams_.Encode()
  10213. req, _ := http.NewRequest("POST", urls, body)
  10214. req.Header = reqHeaders
  10215. googleapi.Expand(req.URL, map[string]string{
  10216. "userId": c.userId,
  10217. "id": c.id,
  10218. })
  10219. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10220. }
  10221. // Do executes the "gmail.users.threads.modify" call.
  10222. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  10223. // code is an error. Response headers are in either
  10224. // *Thread.ServerResponse.Header or (if a response was returned at all)
  10225. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  10226. // check whether the returned error was because http.StatusNotModified
  10227. // was returned.
  10228. func (c *UsersThreadsModifyCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  10229. gensupport.SetOptions(c.urlParams_, opts...)
  10230. res, err := c.doRequest("json")
  10231. if res != nil && res.StatusCode == http.StatusNotModified {
  10232. if res.Body != nil {
  10233. res.Body.Close()
  10234. }
  10235. return nil, &googleapi.Error{
  10236. Code: res.StatusCode,
  10237. Header: res.Header,
  10238. }
  10239. }
  10240. if err != nil {
  10241. return nil, err
  10242. }
  10243. defer googleapi.CloseBody(res)
  10244. if err := googleapi.CheckResponse(res); err != nil {
  10245. return nil, err
  10246. }
  10247. ret := &Thread{
  10248. ServerResponse: googleapi.ServerResponse{
  10249. Header: res.Header,
  10250. HTTPStatusCode: res.StatusCode,
  10251. },
  10252. }
  10253. target := &ret
  10254. if err := gensupport.DecodeResponse(target, res); err != nil {
  10255. return nil, err
  10256. }
  10257. return ret, nil
  10258. // {
  10259. // "description": "Modifies the labels applied to the thread. This applies to all messages in the thread.",
  10260. // "httpMethod": "POST",
  10261. // "id": "gmail.users.threads.modify",
  10262. // "parameterOrder": [
  10263. // "userId",
  10264. // "id"
  10265. // ],
  10266. // "parameters": {
  10267. // "id": {
  10268. // "description": "The ID of the thread to modify.",
  10269. // "location": "path",
  10270. // "required": true,
  10271. // "type": "string"
  10272. // },
  10273. // "userId": {
  10274. // "default": "me",
  10275. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10276. // "location": "path",
  10277. // "required": true,
  10278. // "type": "string"
  10279. // }
  10280. // },
  10281. // "path": "{userId}/threads/{id}/modify",
  10282. // "request": {
  10283. // "$ref": "ModifyThreadRequest"
  10284. // },
  10285. // "response": {
  10286. // "$ref": "Thread"
  10287. // },
  10288. // "scopes": [
  10289. // "https://mail.google.com/",
  10290. // "https://www.googleapis.com/auth/gmail.modify"
  10291. // ]
  10292. // }
  10293. }
  10294. // method id "gmail.users.threads.trash":
  10295. type UsersThreadsTrashCall struct {
  10296. s *Service
  10297. userId string
  10298. id string
  10299. urlParams_ gensupport.URLParams
  10300. ctx_ context.Context
  10301. header_ http.Header
  10302. }
  10303. // Trash: Moves the specified thread to the trash.
  10304. func (r *UsersThreadsService) Trash(userId string, id string) *UsersThreadsTrashCall {
  10305. c := &UsersThreadsTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10306. c.userId = userId
  10307. c.id = id
  10308. return c
  10309. }
  10310. // Fields allows partial responses to be retrieved. See
  10311. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10312. // for more information.
  10313. func (c *UsersThreadsTrashCall) Fields(s ...googleapi.Field) *UsersThreadsTrashCall {
  10314. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10315. return c
  10316. }
  10317. // Context sets the context to be used in this call's Do method. Any
  10318. // pending HTTP request will be aborted if the provided context is
  10319. // canceled.
  10320. func (c *UsersThreadsTrashCall) Context(ctx context.Context) *UsersThreadsTrashCall {
  10321. c.ctx_ = ctx
  10322. return c
  10323. }
  10324. // Header returns an http.Header that can be modified by the caller to
  10325. // add HTTP headers to the request.
  10326. func (c *UsersThreadsTrashCall) Header() http.Header {
  10327. if c.header_ == nil {
  10328. c.header_ = make(http.Header)
  10329. }
  10330. return c.header_
  10331. }
  10332. func (c *UsersThreadsTrashCall) doRequest(alt string) (*http.Response, error) {
  10333. reqHeaders := make(http.Header)
  10334. for k, v := range c.header_ {
  10335. reqHeaders[k] = v
  10336. }
  10337. reqHeaders.Set("User-Agent", c.s.userAgent())
  10338. var body io.Reader = nil
  10339. c.urlParams_.Set("alt", alt)
  10340. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/trash")
  10341. urls += "?" + c.urlParams_.Encode()
  10342. req, _ := http.NewRequest("POST", urls, body)
  10343. req.Header = reqHeaders
  10344. googleapi.Expand(req.URL, map[string]string{
  10345. "userId": c.userId,
  10346. "id": c.id,
  10347. })
  10348. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10349. }
  10350. // Do executes the "gmail.users.threads.trash" call.
  10351. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  10352. // code is an error. Response headers are in either
  10353. // *Thread.ServerResponse.Header or (if a response was returned at all)
  10354. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  10355. // check whether the returned error was because http.StatusNotModified
  10356. // was returned.
  10357. func (c *UsersThreadsTrashCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  10358. gensupport.SetOptions(c.urlParams_, opts...)
  10359. res, err := c.doRequest("json")
  10360. if res != nil && res.StatusCode == http.StatusNotModified {
  10361. if res.Body != nil {
  10362. res.Body.Close()
  10363. }
  10364. return nil, &googleapi.Error{
  10365. Code: res.StatusCode,
  10366. Header: res.Header,
  10367. }
  10368. }
  10369. if err != nil {
  10370. return nil, err
  10371. }
  10372. defer googleapi.CloseBody(res)
  10373. if err := googleapi.CheckResponse(res); err != nil {
  10374. return nil, err
  10375. }
  10376. ret := &Thread{
  10377. ServerResponse: googleapi.ServerResponse{
  10378. Header: res.Header,
  10379. HTTPStatusCode: res.StatusCode,
  10380. },
  10381. }
  10382. target := &ret
  10383. if err := gensupport.DecodeResponse(target, res); err != nil {
  10384. return nil, err
  10385. }
  10386. return ret, nil
  10387. // {
  10388. // "description": "Moves the specified thread to the trash.",
  10389. // "httpMethod": "POST",
  10390. // "id": "gmail.users.threads.trash",
  10391. // "parameterOrder": [
  10392. // "userId",
  10393. // "id"
  10394. // ],
  10395. // "parameters": {
  10396. // "id": {
  10397. // "description": "The ID of the thread to Trash.",
  10398. // "location": "path",
  10399. // "required": true,
  10400. // "type": "string"
  10401. // },
  10402. // "userId": {
  10403. // "default": "me",
  10404. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10405. // "location": "path",
  10406. // "required": true,
  10407. // "type": "string"
  10408. // }
  10409. // },
  10410. // "path": "{userId}/threads/{id}/trash",
  10411. // "response": {
  10412. // "$ref": "Thread"
  10413. // },
  10414. // "scopes": [
  10415. // "https://mail.google.com/",
  10416. // "https://www.googleapis.com/auth/gmail.modify"
  10417. // ]
  10418. // }
  10419. }
  10420. // method id "gmail.users.threads.untrash":
  10421. type UsersThreadsUntrashCall struct {
  10422. s *Service
  10423. userId string
  10424. id string
  10425. urlParams_ gensupport.URLParams
  10426. ctx_ context.Context
  10427. header_ http.Header
  10428. }
  10429. // Untrash: Removes the specified thread from the trash.
  10430. func (r *UsersThreadsService) Untrash(userId string, id string) *UsersThreadsUntrashCall {
  10431. c := &UsersThreadsUntrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10432. c.userId = userId
  10433. c.id = id
  10434. return c
  10435. }
  10436. // Fields allows partial responses to be retrieved. See
  10437. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10438. // for more information.
  10439. func (c *UsersThreadsUntrashCall) Fields(s ...googleapi.Field) *UsersThreadsUntrashCall {
  10440. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10441. return c
  10442. }
  10443. // Context sets the context to be used in this call's Do method. Any
  10444. // pending HTTP request will be aborted if the provided context is
  10445. // canceled.
  10446. func (c *UsersThreadsUntrashCall) Context(ctx context.Context) *UsersThreadsUntrashCall {
  10447. c.ctx_ = ctx
  10448. return c
  10449. }
  10450. // Header returns an http.Header that can be modified by the caller to
  10451. // add HTTP headers to the request.
  10452. func (c *UsersThreadsUntrashCall) Header() http.Header {
  10453. if c.header_ == nil {
  10454. c.header_ = make(http.Header)
  10455. }
  10456. return c.header_
  10457. }
  10458. func (c *UsersThreadsUntrashCall) doRequest(alt string) (*http.Response, error) {
  10459. reqHeaders := make(http.Header)
  10460. for k, v := range c.header_ {
  10461. reqHeaders[k] = v
  10462. }
  10463. reqHeaders.Set("User-Agent", c.s.userAgent())
  10464. var body io.Reader = nil
  10465. c.urlParams_.Set("alt", alt)
  10466. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/untrash")
  10467. urls += "?" + c.urlParams_.Encode()
  10468. req, _ := http.NewRequest("POST", urls, body)
  10469. req.Header = reqHeaders
  10470. googleapi.Expand(req.URL, map[string]string{
  10471. "userId": c.userId,
  10472. "id": c.id,
  10473. })
  10474. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10475. }
  10476. // Do executes the "gmail.users.threads.untrash" call.
  10477. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  10478. // code is an error. Response headers are in either
  10479. // *Thread.ServerResponse.Header or (if a response was returned at all)
  10480. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  10481. // check whether the returned error was because http.StatusNotModified
  10482. // was returned.
  10483. func (c *UsersThreadsUntrashCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  10484. gensupport.SetOptions(c.urlParams_, opts...)
  10485. res, err := c.doRequest("json")
  10486. if res != nil && res.StatusCode == http.StatusNotModified {
  10487. if res.Body != nil {
  10488. res.Body.Close()
  10489. }
  10490. return nil, &googleapi.Error{
  10491. Code: res.StatusCode,
  10492. Header: res.Header,
  10493. }
  10494. }
  10495. if err != nil {
  10496. return nil, err
  10497. }
  10498. defer googleapi.CloseBody(res)
  10499. if err := googleapi.CheckResponse(res); err != nil {
  10500. return nil, err
  10501. }
  10502. ret := &Thread{
  10503. ServerResponse: googleapi.ServerResponse{
  10504. Header: res.Header,
  10505. HTTPStatusCode: res.StatusCode,
  10506. },
  10507. }
  10508. target := &ret
  10509. if err := gensupport.DecodeResponse(target, res); err != nil {
  10510. return nil, err
  10511. }
  10512. return ret, nil
  10513. // {
  10514. // "description": "Removes the specified thread from the trash.",
  10515. // "httpMethod": "POST",
  10516. // "id": "gmail.users.threads.untrash",
  10517. // "parameterOrder": [
  10518. // "userId",
  10519. // "id"
  10520. // ],
  10521. // "parameters": {
  10522. // "id": {
  10523. // "description": "The ID of the thread to remove from Trash.",
  10524. // "location": "path",
  10525. // "required": true,
  10526. // "type": "string"
  10527. // },
  10528. // "userId": {
  10529. // "default": "me",
  10530. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10531. // "location": "path",
  10532. // "required": true,
  10533. // "type": "string"
  10534. // }
  10535. // },
  10536. // "path": "{userId}/threads/{id}/untrash",
  10537. // "response": {
  10538. // "$ref": "Thread"
  10539. // },
  10540. // "scopes": [
  10541. // "https://mail.google.com/",
  10542. // "https://www.googleapis.com/auth/gmail.modify"
  10543. // ]
  10544. // }
  10545. }