You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

12507 lines
409 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package gmail provides access to the Gmail API.
  6. //
  7. // For product documentation, see: https://developers.google.com/gmail/api/
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/gmail/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // gmailService, err := gmail.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
  25. //
  26. // gmailService, err := gmail.NewService(ctx, option.WithScopes(gmail.GmailSettingsSharingScope))
  27. //
  28. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  29. //
  30. // gmailService, err := gmail.NewService(ctx, option.WithAPIKey("AIza..."))
  31. //
  32. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  33. //
  34. // config := &oauth2.Config{...}
  35. // // ...
  36. // token, err := config.Exchange(ctx, ...)
  37. // gmailService, err := gmail.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  38. //
  39. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  40. package gmail // import "google.golang.org/api/gmail/v1"
  41. import (
  42. "bytes"
  43. "context"
  44. "encoding/json"
  45. "errors"
  46. "fmt"
  47. "io"
  48. "net/http"
  49. "net/url"
  50. "strconv"
  51. "strings"
  52. gensupport "google.golang.org/api/gensupport"
  53. googleapi "google.golang.org/api/googleapi"
  54. option "google.golang.org/api/option"
  55. htransport "google.golang.org/api/transport/http"
  56. )
  57. // Always reference these packages, just in case the auto-generated code
  58. // below doesn't.
  59. var _ = bytes.NewBuffer
  60. var _ = strconv.Itoa
  61. var _ = fmt.Sprintf
  62. var _ = json.NewDecoder
  63. var _ = io.Copy
  64. var _ = url.Parse
  65. var _ = gensupport.MarshalJSON
  66. var _ = googleapi.Version
  67. var _ = errors.New
  68. var _ = strings.Replace
  69. var _ = context.Canceled
  70. const apiId = "gmail:v1"
  71. const apiName = "gmail"
  72. const apiVersion = "v1"
  73. const basePath = "https://www.googleapis.com/gmail/v1/users/"
  74. // OAuth2 scopes used by this API.
  75. const (
  76. // Read, compose, send, and permanently delete all your email from Gmail
  77. MailGoogleComScope = "https://mail.google.com/"
  78. // Manage drafts and send emails
  79. GmailComposeScope = "https://www.googleapis.com/auth/gmail.compose"
  80. // Insert mail into your mailbox
  81. GmailInsertScope = "https://www.googleapis.com/auth/gmail.insert"
  82. // Manage mailbox labels
  83. GmailLabelsScope = "https://www.googleapis.com/auth/gmail.labels"
  84. // View your email message metadata such as labels and headers, but not
  85. // the email body
  86. GmailMetadataScope = "https://www.googleapis.com/auth/gmail.metadata"
  87. // View and modify but not delete your email
  88. GmailModifyScope = "https://www.googleapis.com/auth/gmail.modify"
  89. // View your email messages and settings
  90. GmailReadonlyScope = "https://www.googleapis.com/auth/gmail.readonly"
  91. // Send email on your behalf
  92. GmailSendScope = "https://www.googleapis.com/auth/gmail.send"
  93. // Manage your basic mail settings
  94. GmailSettingsBasicScope = "https://www.googleapis.com/auth/gmail.settings.basic"
  95. // Manage your sensitive mail settings, including who can manage your
  96. // mail
  97. GmailSettingsSharingScope = "https://www.googleapis.com/auth/gmail.settings.sharing"
  98. )
  99. // NewService creates a new Service.
  100. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  101. scopesOption := option.WithScopes(
  102. "https://mail.google.com/",
  103. "https://www.googleapis.com/auth/gmail.compose",
  104. "https://www.googleapis.com/auth/gmail.insert",
  105. "https://www.googleapis.com/auth/gmail.labels",
  106. "https://www.googleapis.com/auth/gmail.metadata",
  107. "https://www.googleapis.com/auth/gmail.modify",
  108. "https://www.googleapis.com/auth/gmail.readonly",
  109. "https://www.googleapis.com/auth/gmail.send",
  110. "https://www.googleapis.com/auth/gmail.settings.basic",
  111. "https://www.googleapis.com/auth/gmail.settings.sharing",
  112. )
  113. // NOTE: prepend, so we don't override user-specified scopes.
  114. opts = append([]option.ClientOption{scopesOption}, opts...)
  115. client, endpoint, err := htransport.NewClient(ctx, opts...)
  116. if err != nil {
  117. return nil, err
  118. }
  119. s, err := New(client)
  120. if err != nil {
  121. return nil, err
  122. }
  123. if endpoint != "" {
  124. s.BasePath = endpoint
  125. }
  126. return s, nil
  127. }
  128. // New creates a new Service. It uses the provided http.Client for requests.
  129. //
  130. // Deprecated: please use NewService instead.
  131. // To provide a custom HTTP client, use option.WithHTTPClient.
  132. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  133. func New(client *http.Client) (*Service, error) {
  134. if client == nil {
  135. return nil, errors.New("client is nil")
  136. }
  137. s := &Service{client: client, BasePath: basePath}
  138. s.Users = NewUsersService(s)
  139. return s, nil
  140. }
  141. type Service struct {
  142. client *http.Client
  143. BasePath string // API endpoint base URL
  144. UserAgent string // optional additional User-Agent fragment
  145. Users *UsersService
  146. }
  147. func (s *Service) userAgent() string {
  148. if s.UserAgent == "" {
  149. return googleapi.UserAgent
  150. }
  151. return googleapi.UserAgent + " " + s.UserAgent
  152. }
  153. func NewUsersService(s *Service) *UsersService {
  154. rs := &UsersService{s: s}
  155. rs.Drafts = NewUsersDraftsService(s)
  156. rs.History = NewUsersHistoryService(s)
  157. rs.Labels = NewUsersLabelsService(s)
  158. rs.Messages = NewUsersMessagesService(s)
  159. rs.Settings = NewUsersSettingsService(s)
  160. rs.Threads = NewUsersThreadsService(s)
  161. return rs
  162. }
  163. type UsersService struct {
  164. s *Service
  165. Drafts *UsersDraftsService
  166. History *UsersHistoryService
  167. Labels *UsersLabelsService
  168. Messages *UsersMessagesService
  169. Settings *UsersSettingsService
  170. Threads *UsersThreadsService
  171. }
  172. func NewUsersDraftsService(s *Service) *UsersDraftsService {
  173. rs := &UsersDraftsService{s: s}
  174. return rs
  175. }
  176. type UsersDraftsService struct {
  177. s *Service
  178. }
  179. func NewUsersHistoryService(s *Service) *UsersHistoryService {
  180. rs := &UsersHistoryService{s: s}
  181. return rs
  182. }
  183. type UsersHistoryService struct {
  184. s *Service
  185. }
  186. func NewUsersLabelsService(s *Service) *UsersLabelsService {
  187. rs := &UsersLabelsService{s: s}
  188. return rs
  189. }
  190. type UsersLabelsService struct {
  191. s *Service
  192. }
  193. func NewUsersMessagesService(s *Service) *UsersMessagesService {
  194. rs := &UsersMessagesService{s: s}
  195. rs.Attachments = NewUsersMessagesAttachmentsService(s)
  196. return rs
  197. }
  198. type UsersMessagesService struct {
  199. s *Service
  200. Attachments *UsersMessagesAttachmentsService
  201. }
  202. func NewUsersMessagesAttachmentsService(s *Service) *UsersMessagesAttachmentsService {
  203. rs := &UsersMessagesAttachmentsService{s: s}
  204. return rs
  205. }
  206. type UsersMessagesAttachmentsService struct {
  207. s *Service
  208. }
  209. func NewUsersSettingsService(s *Service) *UsersSettingsService {
  210. rs := &UsersSettingsService{s: s}
  211. rs.Delegates = NewUsersSettingsDelegatesService(s)
  212. rs.Filters = NewUsersSettingsFiltersService(s)
  213. rs.ForwardingAddresses = NewUsersSettingsForwardingAddressesService(s)
  214. rs.SendAs = NewUsersSettingsSendAsService(s)
  215. return rs
  216. }
  217. type UsersSettingsService struct {
  218. s *Service
  219. Delegates *UsersSettingsDelegatesService
  220. Filters *UsersSettingsFiltersService
  221. ForwardingAddresses *UsersSettingsForwardingAddressesService
  222. SendAs *UsersSettingsSendAsService
  223. }
  224. func NewUsersSettingsDelegatesService(s *Service) *UsersSettingsDelegatesService {
  225. rs := &UsersSettingsDelegatesService{s: s}
  226. return rs
  227. }
  228. type UsersSettingsDelegatesService struct {
  229. s *Service
  230. }
  231. func NewUsersSettingsFiltersService(s *Service) *UsersSettingsFiltersService {
  232. rs := &UsersSettingsFiltersService{s: s}
  233. return rs
  234. }
  235. type UsersSettingsFiltersService struct {
  236. s *Service
  237. }
  238. func NewUsersSettingsForwardingAddressesService(s *Service) *UsersSettingsForwardingAddressesService {
  239. rs := &UsersSettingsForwardingAddressesService{s: s}
  240. return rs
  241. }
  242. type UsersSettingsForwardingAddressesService struct {
  243. s *Service
  244. }
  245. func NewUsersSettingsSendAsService(s *Service) *UsersSettingsSendAsService {
  246. rs := &UsersSettingsSendAsService{s: s}
  247. rs.SmimeInfo = NewUsersSettingsSendAsSmimeInfoService(s)
  248. return rs
  249. }
  250. type UsersSettingsSendAsService struct {
  251. s *Service
  252. SmimeInfo *UsersSettingsSendAsSmimeInfoService
  253. }
  254. func NewUsersSettingsSendAsSmimeInfoService(s *Service) *UsersSettingsSendAsSmimeInfoService {
  255. rs := &UsersSettingsSendAsSmimeInfoService{s: s}
  256. return rs
  257. }
  258. type UsersSettingsSendAsSmimeInfoService struct {
  259. s *Service
  260. }
  261. func NewUsersThreadsService(s *Service) *UsersThreadsService {
  262. rs := &UsersThreadsService{s: s}
  263. return rs
  264. }
  265. type UsersThreadsService struct {
  266. s *Service
  267. }
  268. // AutoForwarding: Auto-forwarding settings for an account.
  269. type AutoForwarding struct {
  270. // Disposition: The state that a message should be left in after it has
  271. // been forwarded.
  272. //
  273. // Possible values:
  274. // "archive"
  275. // "dispositionUnspecified"
  276. // "leaveInInbox"
  277. // "markRead"
  278. // "trash"
  279. Disposition string `json:"disposition,omitempty"`
  280. // EmailAddress: Email address to which all incoming messages are
  281. // forwarded. This email address must be a verified member of the
  282. // forwarding addresses.
  283. EmailAddress string `json:"emailAddress,omitempty"`
  284. // Enabled: Whether all incoming mail is automatically forwarded to
  285. // another address.
  286. Enabled bool `json:"enabled,omitempty"`
  287. // ServerResponse contains the HTTP response code and headers from the
  288. // server.
  289. googleapi.ServerResponse `json:"-"`
  290. // ForceSendFields is a list of field names (e.g. "Disposition") to
  291. // unconditionally include in API requests. By default, fields with
  292. // empty values are omitted from API requests. However, any non-pointer,
  293. // non-interface field appearing in ForceSendFields will be sent to the
  294. // server regardless of whether the field is empty or not. This may be
  295. // used to include empty fields in Patch requests.
  296. ForceSendFields []string `json:"-"`
  297. // NullFields is a list of field names (e.g. "Disposition") to include
  298. // in API requests with the JSON null value. By default, fields with
  299. // empty values are omitted from API requests. However, any field with
  300. // an empty value appearing in NullFields will be sent to the server as
  301. // null. It is an error if a field in this list has a non-empty value.
  302. // This may be used to include null fields in Patch requests.
  303. NullFields []string `json:"-"`
  304. }
  305. func (s *AutoForwarding) MarshalJSON() ([]byte, error) {
  306. type NoMethod AutoForwarding
  307. raw := NoMethod(*s)
  308. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  309. }
  310. type BatchDeleteMessagesRequest struct {
  311. // Ids: The IDs of the messages to delete.
  312. Ids []string `json:"ids,omitempty"`
  313. // ForceSendFields is a list of field names (e.g. "Ids") to
  314. // unconditionally include in API requests. By default, fields with
  315. // empty values are omitted from API requests. However, any non-pointer,
  316. // non-interface field appearing in ForceSendFields will be sent to the
  317. // server regardless of whether the field is empty or not. This may be
  318. // used to include empty fields in Patch requests.
  319. ForceSendFields []string `json:"-"`
  320. // NullFields is a list of field names (e.g. "Ids") to include in API
  321. // requests with the JSON null value. By default, fields with empty
  322. // values are omitted from API requests. However, any field with an
  323. // empty value appearing in NullFields will be sent to the server as
  324. // null. It is an error if a field in this list has a non-empty value.
  325. // This may be used to include null fields in Patch requests.
  326. NullFields []string `json:"-"`
  327. }
  328. func (s *BatchDeleteMessagesRequest) MarshalJSON() ([]byte, error) {
  329. type NoMethod BatchDeleteMessagesRequest
  330. raw := NoMethod(*s)
  331. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  332. }
  333. type BatchModifyMessagesRequest struct {
  334. // AddLabelIds: A list of label IDs to add to messages.
  335. AddLabelIds []string `json:"addLabelIds,omitempty"`
  336. // Ids: The IDs of the messages to modify. There is a limit of 1000 ids
  337. // per request.
  338. Ids []string `json:"ids,omitempty"`
  339. // RemoveLabelIds: A list of label IDs to remove from messages.
  340. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  341. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  342. // unconditionally include in API requests. By default, fields with
  343. // empty values are omitted from API requests. However, any non-pointer,
  344. // non-interface field appearing in ForceSendFields will be sent to the
  345. // server regardless of whether the field is empty or not. This may be
  346. // used to include empty fields in Patch requests.
  347. ForceSendFields []string `json:"-"`
  348. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  349. // in API requests with the JSON null value. By default, fields with
  350. // empty values are omitted from API requests. However, any field with
  351. // an empty value appearing in NullFields will be sent to the server as
  352. // null. It is an error if a field in this list has a non-empty value.
  353. // This may be used to include null fields in Patch requests.
  354. NullFields []string `json:"-"`
  355. }
  356. func (s *BatchModifyMessagesRequest) MarshalJSON() ([]byte, error) {
  357. type NoMethod BatchModifyMessagesRequest
  358. raw := NoMethod(*s)
  359. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  360. }
  361. // Delegate: Settings for a delegate. Delegates can read, send, and
  362. // delete messages, as well as view and add contacts, for the
  363. // delegator's account. See "Set up mail delegation" for more
  364. // information about delegates.
  365. type Delegate struct {
  366. // DelegateEmail: The email address of the delegate.
  367. DelegateEmail string `json:"delegateEmail,omitempty"`
  368. // VerificationStatus: Indicates whether this address has been verified
  369. // and can act as a delegate for the account. Read-only.
  370. //
  371. // Possible values:
  372. // "accepted"
  373. // "expired"
  374. // "pending"
  375. // "rejected"
  376. // "verificationStatusUnspecified"
  377. VerificationStatus string `json:"verificationStatus,omitempty"`
  378. // ServerResponse contains the HTTP response code and headers from the
  379. // server.
  380. googleapi.ServerResponse `json:"-"`
  381. // ForceSendFields is a list of field names (e.g. "DelegateEmail") to
  382. // unconditionally include in API requests. By default, fields with
  383. // empty values are omitted from API requests. However, any non-pointer,
  384. // non-interface field appearing in ForceSendFields will be sent to the
  385. // server regardless of whether the field is empty or not. This may be
  386. // used to include empty fields in Patch requests.
  387. ForceSendFields []string `json:"-"`
  388. // NullFields is a list of field names (e.g. "DelegateEmail") to include
  389. // in API requests with the JSON null value. By default, fields with
  390. // empty values are omitted from API requests. However, any field with
  391. // an empty value appearing in NullFields will be sent to the server as
  392. // null. It is an error if a field in this list has a non-empty value.
  393. // This may be used to include null fields in Patch requests.
  394. NullFields []string `json:"-"`
  395. }
  396. func (s *Delegate) MarshalJSON() ([]byte, error) {
  397. type NoMethod Delegate
  398. raw := NoMethod(*s)
  399. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  400. }
  401. // Draft: A draft email in the user's mailbox.
  402. type Draft struct {
  403. // Id: The immutable ID of the draft.
  404. Id string `json:"id,omitempty"`
  405. // Message: The message content of the draft.
  406. Message *Message `json:"message,omitempty"`
  407. // ServerResponse contains the HTTP response code and headers from the
  408. // server.
  409. googleapi.ServerResponse `json:"-"`
  410. // ForceSendFields is a list of field names (e.g. "Id") to
  411. // unconditionally include in API requests. By default, fields with
  412. // empty values are omitted from API requests. However, any non-pointer,
  413. // non-interface field appearing in ForceSendFields will be sent to the
  414. // server regardless of whether the field is empty or not. This may be
  415. // used to include empty fields in Patch requests.
  416. ForceSendFields []string `json:"-"`
  417. // NullFields is a list of field names (e.g. "Id") to include in API
  418. // requests with the JSON null value. By default, fields with empty
  419. // values are omitted from API requests. However, any field with an
  420. // empty value appearing in NullFields will be sent to the server as
  421. // null. It is an error if a field in this list has a non-empty value.
  422. // This may be used to include null fields in Patch requests.
  423. NullFields []string `json:"-"`
  424. }
  425. func (s *Draft) MarshalJSON() ([]byte, error) {
  426. type NoMethod Draft
  427. raw := NoMethod(*s)
  428. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  429. }
  430. // Filter: Resource definition for Gmail filters. Filters apply to
  431. // specific messages instead of an entire email thread.
  432. type Filter struct {
  433. // Action: Action that the filter performs.
  434. Action *FilterAction `json:"action,omitempty"`
  435. // Criteria: Matching criteria for the filter.
  436. Criteria *FilterCriteria `json:"criteria,omitempty"`
  437. // Id: The server assigned ID of the filter.
  438. Id string `json:"id,omitempty"`
  439. // ServerResponse contains the HTTP response code and headers from the
  440. // server.
  441. googleapi.ServerResponse `json:"-"`
  442. // ForceSendFields is a list of field names (e.g. "Action") to
  443. // unconditionally include in API requests. By default, fields with
  444. // empty values are omitted from API requests. However, any non-pointer,
  445. // non-interface field appearing in ForceSendFields will be sent to the
  446. // server regardless of whether the field is empty or not. This may be
  447. // used to include empty fields in Patch requests.
  448. ForceSendFields []string `json:"-"`
  449. // NullFields is a list of field names (e.g. "Action") to include in API
  450. // requests with the JSON null value. By default, fields with empty
  451. // values are omitted from API requests. However, any field with an
  452. // empty value appearing in NullFields will be sent to the server as
  453. // null. It is an error if a field in this list has a non-empty value.
  454. // This may be used to include null fields in Patch requests.
  455. NullFields []string `json:"-"`
  456. }
  457. func (s *Filter) MarshalJSON() ([]byte, error) {
  458. type NoMethod Filter
  459. raw := NoMethod(*s)
  460. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  461. }
  462. // FilterAction: A set of actions to perform on a message.
  463. type FilterAction struct {
  464. // AddLabelIds: List of labels to add to the message.
  465. AddLabelIds []string `json:"addLabelIds,omitempty"`
  466. // Forward: Email address that the message should be forwarded to.
  467. Forward string `json:"forward,omitempty"`
  468. // RemoveLabelIds: List of labels to remove from the message.
  469. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  470. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  471. // unconditionally include in API requests. By default, fields with
  472. // empty values are omitted from API requests. However, any non-pointer,
  473. // non-interface field appearing in ForceSendFields will be sent to the
  474. // server regardless of whether the field is empty or not. This may be
  475. // used to include empty fields in Patch requests.
  476. ForceSendFields []string `json:"-"`
  477. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  478. // in API requests with the JSON null value. By default, fields with
  479. // empty values are omitted from API requests. However, any field with
  480. // an empty value appearing in NullFields will be sent to the server as
  481. // null. It is an error if a field in this list has a non-empty value.
  482. // This may be used to include null fields in Patch requests.
  483. NullFields []string `json:"-"`
  484. }
  485. func (s *FilterAction) MarshalJSON() ([]byte, error) {
  486. type NoMethod FilterAction
  487. raw := NoMethod(*s)
  488. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  489. }
  490. // FilterCriteria: Message matching criteria.
  491. type FilterCriteria struct {
  492. // ExcludeChats: Whether the response should exclude chats.
  493. ExcludeChats bool `json:"excludeChats,omitempty"`
  494. // From: The sender's display name or email address.
  495. From string `json:"from,omitempty"`
  496. // HasAttachment: Whether the message has any attachment.
  497. HasAttachment bool `json:"hasAttachment,omitempty"`
  498. // NegatedQuery: Only return messages not matching the specified query.
  499. // Supports the same query format as the Gmail search box. For example,
  500. // "from:someuser@example.com rfc822msgid: is:unread".
  501. NegatedQuery string `json:"negatedQuery,omitempty"`
  502. // Query: Only return messages matching the specified query. Supports
  503. // the same query format as the Gmail search box. For example,
  504. // "from:someuser@example.com rfc822msgid: is:unread".
  505. Query string `json:"query,omitempty"`
  506. // Size: The size of the entire RFC822 message in bytes, including all
  507. // headers and attachments.
  508. Size int64 `json:"size,omitempty"`
  509. // SizeComparison: How the message size in bytes should be in relation
  510. // to the size field.
  511. //
  512. // Possible values:
  513. // "larger"
  514. // "smaller"
  515. // "unspecified"
  516. SizeComparison string `json:"sizeComparison,omitempty"`
  517. // Subject: Case-insensitive phrase found in the message's subject.
  518. // Trailing and leading whitespace are be trimmed and adjacent spaces
  519. // are collapsed.
  520. Subject string `json:"subject,omitempty"`
  521. // To: The recipient's display name or email address. Includes
  522. // recipients in the "to", "cc", and "bcc" header fields. You can use
  523. // simply the local part of the email address. For example, "example"
  524. // and "example@" both match "example@gmail.com". This field is
  525. // case-insensitive.
  526. To string `json:"to,omitempty"`
  527. // ForceSendFields is a list of field names (e.g. "ExcludeChats") to
  528. // unconditionally include in API requests. By default, fields with
  529. // empty values are omitted from API requests. However, any non-pointer,
  530. // non-interface field appearing in ForceSendFields will be sent to the
  531. // server regardless of whether the field is empty or not. This may be
  532. // used to include empty fields in Patch requests.
  533. ForceSendFields []string `json:"-"`
  534. // NullFields is a list of field names (e.g. "ExcludeChats") to include
  535. // in API requests with the JSON null value. By default, fields with
  536. // empty values are omitted from API requests. However, any field with
  537. // an empty value appearing in NullFields will be sent to the server as
  538. // null. It is an error if a field in this list has a non-empty value.
  539. // This may be used to include null fields in Patch requests.
  540. NullFields []string `json:"-"`
  541. }
  542. func (s *FilterCriteria) MarshalJSON() ([]byte, error) {
  543. type NoMethod FilterCriteria
  544. raw := NoMethod(*s)
  545. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  546. }
  547. // ForwardingAddress: Settings for a forwarding address.
  548. type ForwardingAddress struct {
  549. // ForwardingEmail: An email address to which messages can be forwarded.
  550. ForwardingEmail string `json:"forwardingEmail,omitempty"`
  551. // VerificationStatus: Indicates whether this address has been verified
  552. // and is usable for forwarding. Read-only.
  553. //
  554. // Possible values:
  555. // "accepted"
  556. // "pending"
  557. // "verificationStatusUnspecified"
  558. VerificationStatus string `json:"verificationStatus,omitempty"`
  559. // ServerResponse contains the HTTP response code and headers from the
  560. // server.
  561. googleapi.ServerResponse `json:"-"`
  562. // ForceSendFields is a list of field names (e.g. "ForwardingEmail") to
  563. // unconditionally include in API requests. By default, fields with
  564. // empty values are omitted from API requests. However, any non-pointer,
  565. // non-interface field appearing in ForceSendFields will be sent to the
  566. // server regardless of whether the field is empty or not. This may be
  567. // used to include empty fields in Patch requests.
  568. ForceSendFields []string `json:"-"`
  569. // NullFields is a list of field names (e.g. "ForwardingEmail") to
  570. // include in API requests with the JSON null value. By default, fields
  571. // with empty values are omitted from API requests. However, any field
  572. // with an empty value appearing in NullFields will be sent to the
  573. // server as null. It is an error if a field in this list has a
  574. // non-empty value. This may be used to include null fields in Patch
  575. // requests.
  576. NullFields []string `json:"-"`
  577. }
  578. func (s *ForwardingAddress) MarshalJSON() ([]byte, error) {
  579. type NoMethod ForwardingAddress
  580. raw := NoMethod(*s)
  581. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  582. }
  583. // History: A record of a change to the user's mailbox. Each history
  584. // change may affect multiple messages in multiple ways.
  585. type History struct {
  586. // Id: The mailbox sequence ID.
  587. Id uint64 `json:"id,omitempty,string"`
  588. // LabelsAdded: Labels added to messages in this history record.
  589. LabelsAdded []*HistoryLabelAdded `json:"labelsAdded,omitempty"`
  590. // LabelsRemoved: Labels removed from messages in this history record.
  591. LabelsRemoved []*HistoryLabelRemoved `json:"labelsRemoved,omitempty"`
  592. // Messages: List of messages changed in this history record. The fields
  593. // for specific change types, such as messagesAdded may duplicate
  594. // messages in this field. We recommend using the specific change-type
  595. // fields instead of this.
  596. Messages []*Message `json:"messages,omitempty"`
  597. // MessagesAdded: Messages added to the mailbox in this history record.
  598. MessagesAdded []*HistoryMessageAdded `json:"messagesAdded,omitempty"`
  599. // MessagesDeleted: Messages deleted (not Trashed) from the mailbox in
  600. // this history record.
  601. MessagesDeleted []*HistoryMessageDeleted `json:"messagesDeleted,omitempty"`
  602. // ForceSendFields is a list of field names (e.g. "Id") to
  603. // unconditionally include in API requests. By default, fields with
  604. // empty values are omitted from API requests. However, any non-pointer,
  605. // non-interface field appearing in ForceSendFields will be sent to the
  606. // server regardless of whether the field is empty or not. This may be
  607. // used to include empty fields in Patch requests.
  608. ForceSendFields []string `json:"-"`
  609. // NullFields is a list of field names (e.g. "Id") to include in API
  610. // requests with the JSON null value. By default, fields with empty
  611. // values are omitted from API requests. However, any field with an
  612. // empty value appearing in NullFields will be sent to the server as
  613. // null. It is an error if a field in this list has a non-empty value.
  614. // This may be used to include null fields in Patch requests.
  615. NullFields []string `json:"-"`
  616. }
  617. func (s *History) MarshalJSON() ([]byte, error) {
  618. type NoMethod History
  619. raw := NoMethod(*s)
  620. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  621. }
  622. type HistoryLabelAdded struct {
  623. // LabelIds: Label IDs added to the message.
  624. LabelIds []string `json:"labelIds,omitempty"`
  625. Message *Message `json:"message,omitempty"`
  626. // ForceSendFields is a list of field names (e.g. "LabelIds") to
  627. // unconditionally include in API requests. By default, fields with
  628. // empty values are omitted from API requests. However, any non-pointer,
  629. // non-interface field appearing in ForceSendFields will be sent to the
  630. // server regardless of whether the field is empty or not. This may be
  631. // used to include empty fields in Patch requests.
  632. ForceSendFields []string `json:"-"`
  633. // NullFields is a list of field names (e.g. "LabelIds") to include in
  634. // API requests with the JSON null value. By default, fields with empty
  635. // values are omitted from API requests. However, any field with an
  636. // empty value appearing in NullFields will be sent to the server as
  637. // null. It is an error if a field in this list has a non-empty value.
  638. // This may be used to include null fields in Patch requests.
  639. NullFields []string `json:"-"`
  640. }
  641. func (s *HistoryLabelAdded) MarshalJSON() ([]byte, error) {
  642. type NoMethod HistoryLabelAdded
  643. raw := NoMethod(*s)
  644. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  645. }
  646. type HistoryLabelRemoved struct {
  647. // LabelIds: Label IDs removed from the message.
  648. LabelIds []string `json:"labelIds,omitempty"`
  649. Message *Message `json:"message,omitempty"`
  650. // ForceSendFields is a list of field names (e.g. "LabelIds") to
  651. // unconditionally include in API requests. By default, fields with
  652. // empty values are omitted from API requests. However, any non-pointer,
  653. // non-interface field appearing in ForceSendFields will be sent to the
  654. // server regardless of whether the field is empty or not. This may be
  655. // used to include empty fields in Patch requests.
  656. ForceSendFields []string `json:"-"`
  657. // NullFields is a list of field names (e.g. "LabelIds") to include in
  658. // API requests with the JSON null value. By default, fields with empty
  659. // values are omitted from API requests. However, any field with an
  660. // empty value appearing in NullFields will be sent to the server as
  661. // null. It is an error if a field in this list has a non-empty value.
  662. // This may be used to include null fields in Patch requests.
  663. NullFields []string `json:"-"`
  664. }
  665. func (s *HistoryLabelRemoved) MarshalJSON() ([]byte, error) {
  666. type NoMethod HistoryLabelRemoved
  667. raw := NoMethod(*s)
  668. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  669. }
  670. type HistoryMessageAdded struct {
  671. Message *Message `json:"message,omitempty"`
  672. // ForceSendFields is a list of field names (e.g. "Message") to
  673. // unconditionally include in API requests. By default, fields with
  674. // empty values are omitted from API requests. However, any non-pointer,
  675. // non-interface field appearing in ForceSendFields will be sent to the
  676. // server regardless of whether the field is empty or not. This may be
  677. // used to include empty fields in Patch requests.
  678. ForceSendFields []string `json:"-"`
  679. // NullFields is a list of field names (e.g. "Message") to include in
  680. // API requests with the JSON null value. By default, fields with empty
  681. // values are omitted from API requests. However, any field with an
  682. // empty value appearing in NullFields will be sent to the server as
  683. // null. It is an error if a field in this list has a non-empty value.
  684. // This may be used to include null fields in Patch requests.
  685. NullFields []string `json:"-"`
  686. }
  687. func (s *HistoryMessageAdded) MarshalJSON() ([]byte, error) {
  688. type NoMethod HistoryMessageAdded
  689. raw := NoMethod(*s)
  690. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  691. }
  692. type HistoryMessageDeleted struct {
  693. Message *Message `json:"message,omitempty"`
  694. // ForceSendFields is a list of field names (e.g. "Message") to
  695. // unconditionally include in API requests. By default, fields with
  696. // empty values are omitted from API requests. However, any non-pointer,
  697. // non-interface field appearing in ForceSendFields will be sent to the
  698. // server regardless of whether the field is empty or not. This may be
  699. // used to include empty fields in Patch requests.
  700. ForceSendFields []string `json:"-"`
  701. // NullFields is a list of field names (e.g. "Message") to include in
  702. // API requests with the JSON null value. By default, fields with empty
  703. // values are omitted from API requests. However, any field with an
  704. // empty value appearing in NullFields will be sent to the server as
  705. // null. It is an error if a field in this list has a non-empty value.
  706. // This may be used to include null fields in Patch requests.
  707. NullFields []string `json:"-"`
  708. }
  709. func (s *HistoryMessageDeleted) MarshalJSON() ([]byte, error) {
  710. type NoMethod HistoryMessageDeleted
  711. raw := NoMethod(*s)
  712. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  713. }
  714. // ImapSettings: IMAP settings for an account.
  715. type ImapSettings struct {
  716. // AutoExpunge: If this value is true, Gmail will immediately expunge a
  717. // message when it is marked as deleted in IMAP. Otherwise, Gmail will
  718. // wait for an update from the client before expunging messages marked
  719. // as deleted.
  720. AutoExpunge bool `json:"autoExpunge,omitempty"`
  721. // Enabled: Whether IMAP is enabled for the account.
  722. Enabled bool `json:"enabled,omitempty"`
  723. // ExpungeBehavior: The action that will be executed on a message when
  724. // it is marked as deleted and expunged from the last visible IMAP
  725. // folder.
  726. //
  727. // Possible values:
  728. // "archive"
  729. // "deleteForever"
  730. // "expungeBehaviorUnspecified"
  731. // "trash"
  732. ExpungeBehavior string `json:"expungeBehavior,omitempty"`
  733. // MaxFolderSize: An optional limit on the number of messages that an
  734. // IMAP folder may contain. Legal values are 0, 1000, 2000, 5000 or
  735. // 10000. A value of zero is interpreted to mean that there is no limit.
  736. MaxFolderSize int64 `json:"maxFolderSize,omitempty"`
  737. // ServerResponse contains the HTTP response code and headers from the
  738. // server.
  739. googleapi.ServerResponse `json:"-"`
  740. // ForceSendFields is a list of field names (e.g. "AutoExpunge") to
  741. // unconditionally include in API requests. By default, fields with
  742. // empty values are omitted from API requests. However, any non-pointer,
  743. // non-interface field appearing in ForceSendFields will be sent to the
  744. // server regardless of whether the field is empty or not. This may be
  745. // used to include empty fields in Patch requests.
  746. ForceSendFields []string `json:"-"`
  747. // NullFields is a list of field names (e.g. "AutoExpunge") to include
  748. // in API requests with the JSON null value. By default, fields with
  749. // empty values are omitted from API requests. However, any field with
  750. // an empty value appearing in NullFields will be sent to the server as
  751. // null. It is an error if a field in this list has a non-empty value.
  752. // This may be used to include null fields in Patch requests.
  753. NullFields []string `json:"-"`
  754. }
  755. func (s *ImapSettings) MarshalJSON() ([]byte, error) {
  756. type NoMethod ImapSettings
  757. raw := NoMethod(*s)
  758. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  759. }
  760. // Label: Labels are used to categorize messages and threads within the
  761. // user's mailbox.
  762. type Label struct {
  763. // Color: The color to assign to the label. Color is only available for
  764. // labels that have their type set to user.
  765. Color *LabelColor `json:"color,omitempty"`
  766. // Id: The immutable ID of the label.
  767. Id string `json:"id,omitempty"`
  768. // LabelListVisibility: The visibility of the label in the label list in
  769. // the Gmail web interface.
  770. //
  771. // Possible values:
  772. // "labelHide"
  773. // "labelShow"
  774. // "labelShowIfUnread"
  775. LabelListVisibility string `json:"labelListVisibility,omitempty"`
  776. // MessageListVisibility: The visibility of the label in the message
  777. // list in the Gmail web interface.
  778. //
  779. // Possible values:
  780. // "hide"
  781. // "show"
  782. MessageListVisibility string `json:"messageListVisibility,omitempty"`
  783. // MessagesTotal: The total number of messages with the label.
  784. MessagesTotal int64 `json:"messagesTotal,omitempty"`
  785. // MessagesUnread: The number of unread messages with the label.
  786. MessagesUnread int64 `json:"messagesUnread,omitempty"`
  787. // Name: The display name of the label.
  788. Name string `json:"name,omitempty"`
  789. // ThreadsTotal: The total number of threads with the label.
  790. ThreadsTotal int64 `json:"threadsTotal,omitempty"`
  791. // ThreadsUnread: The number of unread threads with the label.
  792. ThreadsUnread int64 `json:"threadsUnread,omitempty"`
  793. // Type: The owner type for the label. User labels are created by the
  794. // user and can be modified and deleted by the user and can be applied
  795. // to any message or thread. System labels are internally created and
  796. // cannot be added, modified, or deleted. System labels may be able to
  797. // be applied to or removed from messages and threads under some
  798. // circumstances but this is not guaranteed. For example, users can
  799. // apply and remove the INBOX and UNREAD labels from messages and
  800. // threads, but cannot apply or remove the DRAFTS or SENT labels from
  801. // messages or threads.
  802. //
  803. // Possible values:
  804. // "system"
  805. // "user"
  806. Type string `json:"type,omitempty"`
  807. // ServerResponse contains the HTTP response code and headers from the
  808. // server.
  809. googleapi.ServerResponse `json:"-"`
  810. // ForceSendFields is a list of field names (e.g. "Color") to
  811. // unconditionally include in API requests. By default, fields with
  812. // empty values are omitted from API requests. However, any non-pointer,
  813. // non-interface field appearing in ForceSendFields will be sent to the
  814. // server regardless of whether the field is empty or not. This may be
  815. // used to include empty fields in Patch requests.
  816. ForceSendFields []string `json:"-"`
  817. // NullFields is a list of field names (e.g. "Color") to include in API
  818. // requests with the JSON null value. By default, fields with empty
  819. // values are omitted from API requests. However, any field with an
  820. // empty value appearing in NullFields will be sent to the server as
  821. // null. It is an error if a field in this list has a non-empty value.
  822. // This may be used to include null fields in Patch requests.
  823. NullFields []string `json:"-"`
  824. }
  825. func (s *Label) MarshalJSON() ([]byte, error) {
  826. type NoMethod Label
  827. raw := NoMethod(*s)
  828. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  829. }
  830. type LabelColor struct {
  831. // BackgroundColor: The background color represented as hex string
  832. // #RRGGBB (ex #000000). This field is required in order to set the
  833. // color of a label. Only the following predefined set of color values
  834. // are allowed:
  835. // #000000, #434343, #666666, #999999, #cccccc, #efefef, #f3f3f3,
  836. // #ffffff, #fb4c2f, #ffad47, #fad165, #16a766, #43d692, #4a86e8,
  837. // #a479e2, #f691b3, #f6c5be, #ffe6c7, #fef1d1, #b9e4d0, #c6f3de,
  838. // #c9daf8, #e4d7f5, #fcdee8, #efa093, #ffd6a2, #fce8b3, #89d3b2,
  839. // #a0eac9, #a4c2f4, #d0bcf1, #fbc8d9, #e66550, #ffbc6b, #fcda83,
  840. // #44b984, #68dfa9, #6d9eeb, #b694e8, #f7a7c0, #cc3a21, #eaa041,
  841. // #f2c960, #149e60, #3dc789, #3c78d8, #8e63ce, #e07798, #ac2b16,
  842. // #cf8933, #d5ae49, #0b804b, #2a9c68, #285bac, #653e9b, #b65775,
  843. // #822111, #a46a21, #aa8831, #076239, #1a764d, #1c4587, #41236d,
  844. // #83334c
  845. BackgroundColor string `json:"backgroundColor,omitempty"`
  846. // TextColor: The text color of the label, represented as hex string.
  847. // This field is required in order to set the color of a label. Only the
  848. // following predefined set of color values are allowed:
  849. // #000000, #434343, #666666, #999999, #cccccc, #efefef, #f3f3f3,
  850. // #ffffff, #fb4c2f, #ffad47, #fad165, #16a766, #43d692, #4a86e8,
  851. // #a479e2, #f691b3, #f6c5be, #ffe6c7, #fef1d1, #b9e4d0, #c6f3de,
  852. // #c9daf8, #e4d7f5, #fcdee8, #efa093, #ffd6a2, #fce8b3, #89d3b2,
  853. // #a0eac9, #a4c2f4, #d0bcf1, #fbc8d9, #e66550, #ffbc6b, #fcda83,
  854. // #44b984, #68dfa9, #6d9eeb, #b694e8, #f7a7c0, #cc3a21, #eaa041,
  855. // #f2c960, #149e60, #3dc789, #3c78d8, #8e63ce, #e07798, #ac2b16,
  856. // #cf8933, #d5ae49, #0b804b, #2a9c68, #285bac, #653e9b, #b65775,
  857. // #822111, #a46a21, #aa8831, #076239, #1a764d, #1c4587, #41236d,
  858. // #83334c
  859. TextColor string `json:"textColor,omitempty"`
  860. // ForceSendFields is a list of field names (e.g. "BackgroundColor") to
  861. // unconditionally include in API requests. By default, fields with
  862. // empty values are omitted from API requests. However, any non-pointer,
  863. // non-interface field appearing in ForceSendFields will be sent to the
  864. // server regardless of whether the field is empty or not. This may be
  865. // used to include empty fields in Patch requests.
  866. ForceSendFields []string `json:"-"`
  867. // NullFields is a list of field names (e.g. "BackgroundColor") to
  868. // include in API requests with the JSON null value. By default, fields
  869. // with empty values are omitted from API requests. However, any field
  870. // with an empty value appearing in NullFields will be sent to the
  871. // server as null. It is an error if a field in this list has a
  872. // non-empty value. This may be used to include null fields in Patch
  873. // requests.
  874. NullFields []string `json:"-"`
  875. }
  876. func (s *LabelColor) MarshalJSON() ([]byte, error) {
  877. type NoMethod LabelColor
  878. raw := NoMethod(*s)
  879. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  880. }
  881. // ListDelegatesResponse: Response for the ListDelegates method.
  882. type ListDelegatesResponse struct {
  883. // Delegates: List of the user's delegates (with any verification
  884. // status).
  885. Delegates []*Delegate `json:"delegates,omitempty"`
  886. // ServerResponse contains the HTTP response code and headers from the
  887. // server.
  888. googleapi.ServerResponse `json:"-"`
  889. // ForceSendFields is a list of field names (e.g. "Delegates") to
  890. // unconditionally include in API requests. By default, fields with
  891. // empty values are omitted from API requests. However, any non-pointer,
  892. // non-interface field appearing in ForceSendFields will be sent to the
  893. // server regardless of whether the field is empty or not. This may be
  894. // used to include empty fields in Patch requests.
  895. ForceSendFields []string `json:"-"`
  896. // NullFields is a list of field names (e.g. "Delegates") to include in
  897. // API requests with the JSON null value. By default, fields with empty
  898. // values are omitted from API requests. However, any field with an
  899. // empty value appearing in NullFields will be sent to the server as
  900. // null. It is an error if a field in this list has a non-empty value.
  901. // This may be used to include null fields in Patch requests.
  902. NullFields []string `json:"-"`
  903. }
  904. func (s *ListDelegatesResponse) MarshalJSON() ([]byte, error) {
  905. type NoMethod ListDelegatesResponse
  906. raw := NoMethod(*s)
  907. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  908. }
  909. type ListDraftsResponse struct {
  910. // Drafts: List of drafts.
  911. Drafts []*Draft `json:"drafts,omitempty"`
  912. // NextPageToken: Token to retrieve the next page of results in the
  913. // list.
  914. NextPageToken string `json:"nextPageToken,omitempty"`
  915. // ResultSizeEstimate: Estimated total number of results.
  916. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  917. // ServerResponse contains the HTTP response code and headers from the
  918. // server.
  919. googleapi.ServerResponse `json:"-"`
  920. // ForceSendFields is a list of field names (e.g. "Drafts") to
  921. // unconditionally include in API requests. By default, fields with
  922. // empty values are omitted from API requests. However, any non-pointer,
  923. // non-interface field appearing in ForceSendFields will be sent to the
  924. // server regardless of whether the field is empty or not. This may be
  925. // used to include empty fields in Patch requests.
  926. ForceSendFields []string `json:"-"`
  927. // NullFields is a list of field names (e.g. "Drafts") to include in API
  928. // requests with the JSON null value. By default, fields with empty
  929. // values are omitted from API requests. However, any field with an
  930. // empty value appearing in NullFields will be sent to the server as
  931. // null. It is an error if a field in this list has a non-empty value.
  932. // This may be used to include null fields in Patch requests.
  933. NullFields []string `json:"-"`
  934. }
  935. func (s *ListDraftsResponse) MarshalJSON() ([]byte, error) {
  936. type NoMethod ListDraftsResponse
  937. raw := NoMethod(*s)
  938. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  939. }
  940. // ListFiltersResponse: Response for the ListFilters method.
  941. type ListFiltersResponse struct {
  942. // Filter: List of a user's filters.
  943. Filter []*Filter `json:"filter,omitempty"`
  944. // ServerResponse contains the HTTP response code and headers from the
  945. // server.
  946. googleapi.ServerResponse `json:"-"`
  947. // ForceSendFields is a list of field names (e.g. "Filter") to
  948. // unconditionally include in API requests. By default, fields with
  949. // empty values are omitted from API requests. However, any non-pointer,
  950. // non-interface field appearing in ForceSendFields will be sent to the
  951. // server regardless of whether the field is empty or not. This may be
  952. // used to include empty fields in Patch requests.
  953. ForceSendFields []string `json:"-"`
  954. // NullFields is a list of field names (e.g. "Filter") to include in API
  955. // requests with the JSON null value. By default, fields with empty
  956. // values are omitted from API requests. However, any field with an
  957. // empty value appearing in NullFields will be sent to the server as
  958. // null. It is an error if a field in this list has a non-empty value.
  959. // This may be used to include null fields in Patch requests.
  960. NullFields []string `json:"-"`
  961. }
  962. func (s *ListFiltersResponse) MarshalJSON() ([]byte, error) {
  963. type NoMethod ListFiltersResponse
  964. raw := NoMethod(*s)
  965. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  966. }
  967. // ListForwardingAddressesResponse: Response for the
  968. // ListForwardingAddresses method.
  969. type ListForwardingAddressesResponse struct {
  970. // ForwardingAddresses: List of addresses that may be used for
  971. // forwarding.
  972. ForwardingAddresses []*ForwardingAddress `json:"forwardingAddresses,omitempty"`
  973. // ServerResponse contains the HTTP response code and headers from the
  974. // server.
  975. googleapi.ServerResponse `json:"-"`
  976. // ForceSendFields is a list of field names (e.g. "ForwardingAddresses")
  977. // to unconditionally include in API requests. By default, fields with
  978. // empty values are omitted from API requests. However, any non-pointer,
  979. // non-interface field appearing in ForceSendFields will be sent to the
  980. // server regardless of whether the field is empty or not. This may be
  981. // used to include empty fields in Patch requests.
  982. ForceSendFields []string `json:"-"`
  983. // NullFields is a list of field names (e.g. "ForwardingAddresses") to
  984. // include in API requests with the JSON null value. By default, fields
  985. // with empty values are omitted from API requests. However, any field
  986. // with an empty value appearing in NullFields will be sent to the
  987. // server as null. It is an error if a field in this list has a
  988. // non-empty value. This may be used to include null fields in Patch
  989. // requests.
  990. NullFields []string `json:"-"`
  991. }
  992. func (s *ListForwardingAddressesResponse) MarshalJSON() ([]byte, error) {
  993. type NoMethod ListForwardingAddressesResponse
  994. raw := NoMethod(*s)
  995. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  996. }
  997. type ListHistoryResponse struct {
  998. // History: List of history records. Any messages contained in the
  999. // response will typically only have id and threadId fields populated.
  1000. History []*History `json:"history,omitempty"`
  1001. // HistoryId: The ID of the mailbox's current history record.
  1002. HistoryId uint64 `json:"historyId,omitempty,string"`
  1003. // NextPageToken: Page token to retrieve the next page of results in the
  1004. // list.
  1005. NextPageToken string `json:"nextPageToken,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. "History") 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. "History") to include in
  1017. // API requests with the JSON null value. By default, fields with empty
  1018. // values are omitted from API requests. However, any field with an
  1019. // 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 *ListHistoryResponse) MarshalJSON() ([]byte, error) {
  1025. type NoMethod ListHistoryResponse
  1026. raw := NoMethod(*s)
  1027. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1028. }
  1029. type ListLabelsResponse struct {
  1030. // Labels: List of labels.
  1031. Labels []*Label `json:"labels,omitempty"`
  1032. // ServerResponse contains the HTTP response code and headers from the
  1033. // server.
  1034. googleapi.ServerResponse `json:"-"`
  1035. // ForceSendFields is a list of field names (e.g. "Labels") to
  1036. // unconditionally include in API requests. By default, fields with
  1037. // empty values are omitted from API requests. However, any non-pointer,
  1038. // non-interface field appearing in ForceSendFields will be sent to the
  1039. // server regardless of whether the field is empty or not. This may be
  1040. // used to include empty fields in Patch requests.
  1041. ForceSendFields []string `json:"-"`
  1042. // NullFields is a list of field names (e.g. "Labels") to include in API
  1043. // requests with the JSON null value. By default, fields with empty
  1044. // values are omitted from API requests. However, any field with an
  1045. // empty value appearing in NullFields will be sent to the server as
  1046. // null. It is an error if a field in this list has a non-empty value.
  1047. // This may be used to include null fields in Patch requests.
  1048. NullFields []string `json:"-"`
  1049. }
  1050. func (s *ListLabelsResponse) MarshalJSON() ([]byte, error) {
  1051. type NoMethod ListLabelsResponse
  1052. raw := NoMethod(*s)
  1053. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1054. }
  1055. type ListMessagesResponse struct {
  1056. // Messages: List of messages. Note that each message resource contains
  1057. // only an id and a threadId. Additional message details can be fetched
  1058. // using the messages.get method.
  1059. Messages []*Message `json:"messages,omitempty"`
  1060. // NextPageToken: Token to retrieve the next page of results in the
  1061. // list.
  1062. NextPageToken string `json:"nextPageToken,omitempty"`
  1063. // ResultSizeEstimate: Estimated total number of results.
  1064. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  1065. // ServerResponse contains the HTTP response code and headers from the
  1066. // server.
  1067. googleapi.ServerResponse `json:"-"`
  1068. // ForceSendFields is a list of field names (e.g. "Messages") to
  1069. // unconditionally include in API requests. By default, fields with
  1070. // empty values are omitted from API requests. However, any non-pointer,
  1071. // non-interface field appearing in ForceSendFields will be sent to the
  1072. // server regardless of whether the field is empty or not. This may be
  1073. // used to include empty fields in Patch requests.
  1074. ForceSendFields []string `json:"-"`
  1075. // NullFields is a list of field names (e.g. "Messages") to include in
  1076. // API requests with the JSON null value. By default, fields with empty
  1077. // values are omitted from API requests. However, any field with an
  1078. // empty value appearing in NullFields will be sent to the server as
  1079. // null. It is an error if a field in this list has a non-empty value.
  1080. // This may be used to include null fields in Patch requests.
  1081. NullFields []string `json:"-"`
  1082. }
  1083. func (s *ListMessagesResponse) MarshalJSON() ([]byte, error) {
  1084. type NoMethod ListMessagesResponse
  1085. raw := NoMethod(*s)
  1086. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1087. }
  1088. // ListSendAsResponse: Response for the ListSendAs method.
  1089. type ListSendAsResponse struct {
  1090. // SendAs: List of send-as aliases.
  1091. SendAs []*SendAs `json:"sendAs,omitempty"`
  1092. // ServerResponse contains the HTTP response code and headers from the
  1093. // server.
  1094. googleapi.ServerResponse `json:"-"`
  1095. // ForceSendFields is a list of field names (e.g. "SendAs") to
  1096. // unconditionally include in API requests. By default, fields with
  1097. // empty values are omitted from API requests. However, any non-pointer,
  1098. // non-interface field appearing in ForceSendFields will be sent to the
  1099. // server regardless of whether the field is empty or not. This may be
  1100. // used to include empty fields in Patch requests.
  1101. ForceSendFields []string `json:"-"`
  1102. // NullFields is a list of field names (e.g. "SendAs") to include in API
  1103. // requests with the JSON null value. By default, fields with empty
  1104. // values are omitted from API requests. However, any field with an
  1105. // empty value appearing in NullFields will be sent to the server as
  1106. // null. It is an error if a field in this list has a non-empty value.
  1107. // This may be used to include null fields in Patch requests.
  1108. NullFields []string `json:"-"`
  1109. }
  1110. func (s *ListSendAsResponse) MarshalJSON() ([]byte, error) {
  1111. type NoMethod ListSendAsResponse
  1112. raw := NoMethod(*s)
  1113. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1114. }
  1115. type ListSmimeInfoResponse struct {
  1116. // SmimeInfo: List of SmimeInfo.
  1117. SmimeInfo []*SmimeInfo `json:"smimeInfo,omitempty"`
  1118. // ServerResponse contains the HTTP response code and headers from the
  1119. // server.
  1120. googleapi.ServerResponse `json:"-"`
  1121. // ForceSendFields is a list of field names (e.g. "SmimeInfo") to
  1122. // unconditionally include in API requests. By default, fields with
  1123. // empty values are omitted from API requests. However, any non-pointer,
  1124. // non-interface field appearing in ForceSendFields will be sent to the
  1125. // server regardless of whether the field is empty or not. This may be
  1126. // used to include empty fields in Patch requests.
  1127. ForceSendFields []string `json:"-"`
  1128. // NullFields is a list of field names (e.g. "SmimeInfo") to include in
  1129. // API requests with the JSON null value. By default, fields with empty
  1130. // values are omitted from API requests. However, any field with an
  1131. // empty value appearing in NullFields will be sent to the server as
  1132. // null. It is an error if a field in this list has a non-empty value.
  1133. // This may be used to include null fields in Patch requests.
  1134. NullFields []string `json:"-"`
  1135. }
  1136. func (s *ListSmimeInfoResponse) MarshalJSON() ([]byte, error) {
  1137. type NoMethod ListSmimeInfoResponse
  1138. raw := NoMethod(*s)
  1139. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1140. }
  1141. type ListThreadsResponse struct {
  1142. // NextPageToken: Page token to retrieve the next page of results in the
  1143. // list.
  1144. NextPageToken string `json:"nextPageToken,omitempty"`
  1145. // ResultSizeEstimate: Estimated total number of results.
  1146. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  1147. // Threads: List of threads. Note that each thread resource does not
  1148. // contain a list of messages. The list of messages for a given thread
  1149. // can be fetched using the threads.get method.
  1150. Threads []*Thread `json:"threads,omitempty"`
  1151. // ServerResponse contains the HTTP response code and headers from the
  1152. // server.
  1153. googleapi.ServerResponse `json:"-"`
  1154. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  1155. // unconditionally include in API requests. By default, fields with
  1156. // empty values are omitted from API requests. However, any non-pointer,
  1157. // non-interface field appearing in ForceSendFields will be sent to the
  1158. // server regardless of whether the field is empty or not. This may be
  1159. // used to include empty fields in Patch requests.
  1160. ForceSendFields []string `json:"-"`
  1161. // NullFields is a list of field names (e.g. "NextPageToken") to include
  1162. // in API requests with the JSON null value. By default, fields with
  1163. // empty values are omitted from API requests. However, any field with
  1164. // an empty value appearing in NullFields will be sent to the server as
  1165. // null. It is an error if a field in this list has a non-empty value.
  1166. // This may be used to include null fields in Patch requests.
  1167. NullFields []string `json:"-"`
  1168. }
  1169. func (s *ListThreadsResponse) MarshalJSON() ([]byte, error) {
  1170. type NoMethod ListThreadsResponse
  1171. raw := NoMethod(*s)
  1172. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1173. }
  1174. // Message: An email message.
  1175. type Message struct {
  1176. // HistoryId: The ID of the last history record that modified this
  1177. // message.
  1178. HistoryId uint64 `json:"historyId,omitempty,string"`
  1179. // Id: The immutable ID of the message.
  1180. Id string `json:"id,omitempty"`
  1181. // InternalDate: The internal message creation timestamp (epoch ms),
  1182. // which determines ordering in the inbox. For normal SMTP-received
  1183. // email, this represents the time the message was originally accepted
  1184. // by Google, which is more reliable than the Date header. However, for
  1185. // API-migrated mail, it can be configured by client to be based on the
  1186. // Date header.
  1187. InternalDate int64 `json:"internalDate,omitempty,string"`
  1188. // LabelIds: List of IDs of labels applied to this message.
  1189. LabelIds []string `json:"labelIds,omitempty"`
  1190. // Payload: The parsed email structure in the message parts.
  1191. Payload *MessagePart `json:"payload,omitempty"`
  1192. // Raw: The entire email message in an RFC 2822 formatted and base64url
  1193. // encoded string. Returned in messages.get and drafts.get responses
  1194. // when the format=RAW parameter is supplied.
  1195. Raw string `json:"raw,omitempty"`
  1196. // SizeEstimate: Estimated size in bytes of the message.
  1197. SizeEstimate int64 `json:"sizeEstimate,omitempty"`
  1198. // Snippet: A short part of the message text.
  1199. Snippet string `json:"snippet,omitempty"`
  1200. // ThreadId: The ID of the thread the message belongs to. To add a
  1201. // message or draft to a thread, the following criteria must be met:
  1202. // - The requested threadId must be specified on the Message or
  1203. // Draft.Message you supply with your request.
  1204. // - The References and In-Reply-To headers must be set in compliance
  1205. // with the RFC 2822 standard.
  1206. // - The Subject headers must match.
  1207. ThreadId string `json:"threadId,omitempty"`
  1208. // ServerResponse contains the HTTP response code and headers from the
  1209. // server.
  1210. googleapi.ServerResponse `json:"-"`
  1211. // ForceSendFields is a list of field names (e.g. "HistoryId") to
  1212. // unconditionally include in API requests. By default, fields with
  1213. // empty values are omitted from API requests. However, any non-pointer,
  1214. // non-interface field appearing in ForceSendFields will be sent to the
  1215. // server regardless of whether the field is empty or not. This may be
  1216. // used to include empty fields in Patch requests.
  1217. ForceSendFields []string `json:"-"`
  1218. // NullFields is a list of field names (e.g. "HistoryId") to include in
  1219. // API requests with the JSON null value. By default, fields with empty
  1220. // values are omitted from API requests. However, any field with an
  1221. // empty value appearing in NullFields will be sent to the server as
  1222. // null. It is an error if a field in this list has a non-empty value.
  1223. // This may be used to include null fields in Patch requests.
  1224. NullFields []string `json:"-"`
  1225. }
  1226. func (s *Message) MarshalJSON() ([]byte, error) {
  1227. type NoMethod Message
  1228. raw := NoMethod(*s)
  1229. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1230. }
  1231. // MessagePart: A single MIME message part.
  1232. type MessagePart struct {
  1233. // Body: The message part body for this part, which may be empty for
  1234. // container MIME message parts.
  1235. Body *MessagePartBody `json:"body,omitempty"`
  1236. // Filename: The filename of the attachment. Only present if this
  1237. // message part represents an attachment.
  1238. Filename string `json:"filename,omitempty"`
  1239. // Headers: List of headers on this message part. For the top-level
  1240. // message part, representing the entire message payload, it will
  1241. // contain the standard RFC 2822 email headers such as To, From, and
  1242. // Subject.
  1243. Headers []*MessagePartHeader `json:"headers,omitempty"`
  1244. // MimeType: The MIME type of the message part.
  1245. MimeType string `json:"mimeType,omitempty"`
  1246. // PartId: The immutable ID of the message part.
  1247. PartId string `json:"partId,omitempty"`
  1248. // Parts: The child MIME message parts of this part. This only applies
  1249. // to container MIME message parts, for example multipart/*. For non-
  1250. // container MIME message part types, such as text/plain, this field is
  1251. // empty. For more information, see RFC 1521.
  1252. Parts []*MessagePart `json:"parts,omitempty"`
  1253. // ForceSendFields is a list of field names (e.g. "Body") to
  1254. // unconditionally include in API requests. By default, fields with
  1255. // empty values are omitted from API requests. However, any non-pointer,
  1256. // non-interface field appearing in ForceSendFields will be sent to the
  1257. // server regardless of whether the field is empty or not. This may be
  1258. // used to include empty fields in Patch requests.
  1259. ForceSendFields []string `json:"-"`
  1260. // NullFields is a list of field names (e.g. "Body") to include in API
  1261. // requests with the JSON null value. By default, fields with empty
  1262. // values are omitted from API requests. However, any field with an
  1263. // empty value appearing in NullFields will be sent to the server as
  1264. // null. It is an error if a field in this list has a non-empty value.
  1265. // This may be used to include null fields in Patch requests.
  1266. NullFields []string `json:"-"`
  1267. }
  1268. func (s *MessagePart) MarshalJSON() ([]byte, error) {
  1269. type NoMethod MessagePart
  1270. raw := NoMethod(*s)
  1271. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1272. }
  1273. // MessagePartBody: The body of a single MIME message part.
  1274. type MessagePartBody struct {
  1275. // AttachmentId: When present, contains the ID of an external attachment
  1276. // that can be retrieved in a separate messages.attachments.get request.
  1277. // When not present, the entire content of the message part body is
  1278. // contained in the data field.
  1279. AttachmentId string `json:"attachmentId,omitempty"`
  1280. // Data: The body data of a MIME message part as a base64url encoded
  1281. // string. May be empty for MIME container types that have no message
  1282. // body or when the body data is sent as a separate attachment. An
  1283. // attachment ID is present if the body data is contained in a separate
  1284. // attachment.
  1285. Data string `json:"data,omitempty"`
  1286. // Size: Number of bytes for the message part data (encoding
  1287. // notwithstanding).
  1288. Size int64 `json:"size,omitempty"`
  1289. // ServerResponse contains the HTTP response code and headers from the
  1290. // server.
  1291. googleapi.ServerResponse `json:"-"`
  1292. // ForceSendFields is a list of field names (e.g. "AttachmentId") to
  1293. // unconditionally include in API requests. By default, fields with
  1294. // empty values are omitted from API requests. However, any non-pointer,
  1295. // non-interface field appearing in ForceSendFields will be sent to the
  1296. // server regardless of whether the field is empty or not. This may be
  1297. // used to include empty fields in Patch requests.
  1298. ForceSendFields []string `json:"-"`
  1299. // NullFields is a list of field names (e.g. "AttachmentId") to include
  1300. // in API requests with the JSON null value. By default, fields with
  1301. // empty values are omitted from API requests. However, any field with
  1302. // an empty value appearing in NullFields will be sent to the server as
  1303. // null. It is an error if a field in this list has a non-empty value.
  1304. // This may be used to include null fields in Patch requests.
  1305. NullFields []string `json:"-"`
  1306. }
  1307. func (s *MessagePartBody) MarshalJSON() ([]byte, error) {
  1308. type NoMethod MessagePartBody
  1309. raw := NoMethod(*s)
  1310. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1311. }
  1312. type MessagePartHeader struct {
  1313. // Name: The name of the header before the : separator. For example, To.
  1314. Name string `json:"name,omitempty"`
  1315. // Value: The value of the header after the : separator. For example,
  1316. // someuser@example.com.
  1317. Value string `json:"value,omitempty"`
  1318. // ForceSendFields is a list of field names (e.g. "Name") to
  1319. // unconditionally include in API requests. By default, fields with
  1320. // empty values are omitted from API requests. However, any non-pointer,
  1321. // non-interface field appearing in ForceSendFields will be sent to the
  1322. // server regardless of whether the field is empty or not. This may be
  1323. // used to include empty fields in Patch requests.
  1324. ForceSendFields []string `json:"-"`
  1325. // NullFields is a list of field names (e.g. "Name") to include in API
  1326. // requests with the JSON null value. By default, fields with empty
  1327. // values are omitted from API requests. However, any field with an
  1328. // empty value appearing in NullFields will be sent to the server as
  1329. // null. It is an error if a field in this list has a non-empty value.
  1330. // This may be used to include null fields in Patch requests.
  1331. NullFields []string `json:"-"`
  1332. }
  1333. func (s *MessagePartHeader) MarshalJSON() ([]byte, error) {
  1334. type NoMethod MessagePartHeader
  1335. raw := NoMethod(*s)
  1336. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1337. }
  1338. type ModifyMessageRequest struct {
  1339. // AddLabelIds: A list of IDs of labels to add to this message.
  1340. AddLabelIds []string `json:"addLabelIds,omitempty"`
  1341. // RemoveLabelIds: A list IDs of labels to remove from this message.
  1342. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  1343. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  1344. // unconditionally include in API requests. By default, fields with
  1345. // empty values are omitted from API requests. However, any non-pointer,
  1346. // non-interface field appearing in ForceSendFields will be sent to the
  1347. // server regardless of whether the field is empty or not. This may be
  1348. // used to include empty fields in Patch requests.
  1349. ForceSendFields []string `json:"-"`
  1350. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  1351. // in API requests with the JSON null value. By default, fields with
  1352. // empty values are omitted from API requests. However, any field with
  1353. // an empty value appearing in NullFields will be sent to the server as
  1354. // null. It is an error if a field in this list has a non-empty value.
  1355. // This may be used to include null fields in Patch requests.
  1356. NullFields []string `json:"-"`
  1357. }
  1358. func (s *ModifyMessageRequest) MarshalJSON() ([]byte, error) {
  1359. type NoMethod ModifyMessageRequest
  1360. raw := NoMethod(*s)
  1361. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1362. }
  1363. type ModifyThreadRequest struct {
  1364. // AddLabelIds: A list of IDs of labels to add to this thread.
  1365. AddLabelIds []string `json:"addLabelIds,omitempty"`
  1366. // RemoveLabelIds: A list of IDs of labels to remove from this thread.
  1367. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  1368. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  1369. // unconditionally include in API requests. By default, fields with
  1370. // empty values are omitted from API requests. However, any non-pointer,
  1371. // non-interface field appearing in ForceSendFields will be sent to the
  1372. // server regardless of whether the field is empty or not. This may be
  1373. // used to include empty fields in Patch requests.
  1374. ForceSendFields []string `json:"-"`
  1375. // NullFields is a list of field names (e.g. "AddLabelIds") to include
  1376. // in API requests with the JSON null value. By default, fields with
  1377. // empty values are omitted from API requests. However, any field with
  1378. // an empty value appearing in NullFields will be sent to the server as
  1379. // null. It is an error if a field in this list has a non-empty value.
  1380. // This may be used to include null fields in Patch requests.
  1381. NullFields []string `json:"-"`
  1382. }
  1383. func (s *ModifyThreadRequest) MarshalJSON() ([]byte, error) {
  1384. type NoMethod ModifyThreadRequest
  1385. raw := NoMethod(*s)
  1386. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1387. }
  1388. // PopSettings: POP settings for an account.
  1389. type PopSettings struct {
  1390. // AccessWindow: The range of messages which are accessible via POP.
  1391. //
  1392. // Possible values:
  1393. // "accessWindowUnspecified"
  1394. // "allMail"
  1395. // "disabled"
  1396. // "fromNowOn"
  1397. AccessWindow string `json:"accessWindow,omitempty"`
  1398. // Disposition: The action that will be executed on a message after it
  1399. // has been fetched via POP.
  1400. //
  1401. // Possible values:
  1402. // "archive"
  1403. // "dispositionUnspecified"
  1404. // "leaveInInbox"
  1405. // "markRead"
  1406. // "trash"
  1407. Disposition string `json:"disposition,omitempty"`
  1408. // ServerResponse contains the HTTP response code and headers from the
  1409. // server.
  1410. googleapi.ServerResponse `json:"-"`
  1411. // ForceSendFields is a list of field names (e.g. "AccessWindow") to
  1412. // unconditionally include in API requests. By default, fields with
  1413. // empty values are omitted from API requests. However, any non-pointer,
  1414. // non-interface field appearing in ForceSendFields will be sent to the
  1415. // server regardless of whether the field is empty or not. This may be
  1416. // used to include empty fields in Patch requests.
  1417. ForceSendFields []string `json:"-"`
  1418. // NullFields is a list of field names (e.g. "AccessWindow") to include
  1419. // in API requests with the JSON null value. By default, fields with
  1420. // empty values are omitted from API requests. However, any field with
  1421. // an empty value appearing in NullFields will be sent to the server as
  1422. // null. It is an error if a field in this list has a non-empty value.
  1423. // This may be used to include null fields in Patch requests.
  1424. NullFields []string `json:"-"`
  1425. }
  1426. func (s *PopSettings) MarshalJSON() ([]byte, error) {
  1427. type NoMethod PopSettings
  1428. raw := NoMethod(*s)
  1429. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1430. }
  1431. // Profile: Profile for a Gmail user.
  1432. type Profile struct {
  1433. // EmailAddress: The user's email address.
  1434. EmailAddress string `json:"emailAddress,omitempty"`
  1435. // HistoryId: The ID of the mailbox's current history record.
  1436. HistoryId uint64 `json:"historyId,omitempty,string"`
  1437. // MessagesTotal: The total number of messages in the mailbox.
  1438. MessagesTotal int64 `json:"messagesTotal,omitempty"`
  1439. // ThreadsTotal: The total number of threads in the mailbox.
  1440. ThreadsTotal int64 `json:"threadsTotal,omitempty"`
  1441. // ServerResponse contains the HTTP response code and headers from the
  1442. // server.
  1443. googleapi.ServerResponse `json:"-"`
  1444. // ForceSendFields is a list of field names (e.g. "EmailAddress") to
  1445. // unconditionally include in API requests. By default, fields with
  1446. // empty values are omitted from API requests. However, any non-pointer,
  1447. // non-interface field appearing in ForceSendFields will be sent to the
  1448. // server regardless of whether the field is empty or not. This may be
  1449. // used to include empty fields in Patch requests.
  1450. ForceSendFields []string `json:"-"`
  1451. // NullFields is a list of field names (e.g. "EmailAddress") to include
  1452. // in API requests with the JSON null value. By default, fields with
  1453. // empty values are omitted from API requests. However, any field with
  1454. // an empty value appearing in NullFields will be sent to the server as
  1455. // null. It is an error if a field in this list has a non-empty value.
  1456. // This may be used to include null fields in Patch requests.
  1457. NullFields []string `json:"-"`
  1458. }
  1459. func (s *Profile) MarshalJSON() ([]byte, error) {
  1460. type NoMethod Profile
  1461. raw := NoMethod(*s)
  1462. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1463. }
  1464. // SendAs: Settings associated with a send-as alias, which can be either
  1465. // the primary login address associated with the account or a custom
  1466. // "from" address. Send-as aliases correspond to the "Send Mail As"
  1467. // feature in the web interface.
  1468. type SendAs struct {
  1469. // DisplayName: A name that appears in the "From:" header for mail sent
  1470. // using this alias. For custom "from" addresses, when this is empty,
  1471. // Gmail will populate the "From:" header with the name that is used for
  1472. // the primary address associated with the account. If the admin has
  1473. // disabled the ability for users to update their name format, requests
  1474. // to update this field for the primary login will silently fail.
  1475. DisplayName string `json:"displayName,omitempty"`
  1476. // IsDefault: Whether this address is selected as the default "From:"
  1477. // address in situations such as composing a new message or sending a
  1478. // vacation auto-reply. Every Gmail account has exactly one default
  1479. // send-as address, so the only legal value that clients may write to
  1480. // this field is true. Changing this from false to true for an address
  1481. // will result in this field becoming false for the other previous
  1482. // default address.
  1483. IsDefault bool `json:"isDefault,omitempty"`
  1484. // IsPrimary: Whether this address is the primary address used to login
  1485. // to the account. Every Gmail account has exactly one primary address,
  1486. // and it cannot be deleted from the collection of send-as aliases. This
  1487. // field is read-only.
  1488. IsPrimary bool `json:"isPrimary,omitempty"`
  1489. // ReplyToAddress: An optional email address that is included in a
  1490. // "Reply-To:" header for mail sent using this alias. If this is empty,
  1491. // Gmail will not generate a "Reply-To:" header.
  1492. ReplyToAddress string `json:"replyToAddress,omitempty"`
  1493. // SendAsEmail: The email address that appears in the "From:" header for
  1494. // mail sent using this alias. This is read-only for all operations
  1495. // except create.
  1496. SendAsEmail string `json:"sendAsEmail,omitempty"`
  1497. // Signature: An optional HTML signature that is included in messages
  1498. // composed with this alias in the Gmail web UI.
  1499. Signature string `json:"signature,omitempty"`
  1500. // SmtpMsa: An optional SMTP service that will be used as an outbound
  1501. // relay for mail sent using this alias. If this is empty, outbound mail
  1502. // will be sent directly from Gmail's servers to the destination SMTP
  1503. // service. This setting only applies to custom "from" aliases.
  1504. SmtpMsa *SmtpMsa `json:"smtpMsa,omitempty"`
  1505. // TreatAsAlias: Whether Gmail should treat this address as an alias
  1506. // for the user's primary email address. This setting only applies to
  1507. // custom "from" aliases.
  1508. TreatAsAlias bool `json:"treatAsAlias,omitempty"`
  1509. // VerificationStatus: Indicates whether this address has been verified
  1510. // for use as a send-as alias. Read-only. This setting only applies to
  1511. // custom "from" aliases.
  1512. //
  1513. // Possible values:
  1514. // "accepted"
  1515. // "pending"
  1516. // "verificationStatusUnspecified"
  1517. VerificationStatus string `json:"verificationStatus,omitempty"`
  1518. // ServerResponse contains the HTTP response code and headers from the
  1519. // server.
  1520. googleapi.ServerResponse `json:"-"`
  1521. // ForceSendFields is a list of field names (e.g. "DisplayName") to
  1522. // unconditionally include in API requests. By default, fields with
  1523. // empty values are omitted from API requests. However, any non-pointer,
  1524. // non-interface field appearing in ForceSendFields will be sent to the
  1525. // server regardless of whether the field is empty or not. This may be
  1526. // used to include empty fields in Patch requests.
  1527. ForceSendFields []string `json:"-"`
  1528. // NullFields is a list of field names (e.g. "DisplayName") to include
  1529. // in API requests with the JSON null value. By default, fields with
  1530. // empty values are omitted from API requests. However, any field with
  1531. // an empty value appearing in NullFields will be sent to the server as
  1532. // null. It is an error if a field in this list has a non-empty value.
  1533. // This may be used to include null fields in Patch requests.
  1534. NullFields []string `json:"-"`
  1535. }
  1536. func (s *SendAs) MarshalJSON() ([]byte, error) {
  1537. type NoMethod SendAs
  1538. raw := NoMethod(*s)
  1539. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1540. }
  1541. // SmimeInfo: An S/MIME email config.
  1542. type SmimeInfo struct {
  1543. // EncryptedKeyPassword: Encrypted key password, when key is encrypted.
  1544. EncryptedKeyPassword string `json:"encryptedKeyPassword,omitempty"`
  1545. // Expiration: When the certificate expires (in milliseconds since
  1546. // epoch).
  1547. Expiration int64 `json:"expiration,omitempty,string"`
  1548. // Id: The immutable ID for the SmimeInfo.
  1549. Id string `json:"id,omitempty"`
  1550. // IsDefault: Whether this SmimeInfo is the default one for this user's
  1551. // send-as address.
  1552. IsDefault bool `json:"isDefault,omitempty"`
  1553. // IssuerCn: The S/MIME certificate issuer's common name.
  1554. IssuerCn string `json:"issuerCn,omitempty"`
  1555. // Pem: PEM formatted X509 concatenated certificate string (standard
  1556. // base64 encoding). Format used for returning key, which includes
  1557. // public key as well as certificate chain (not private key).
  1558. Pem string `json:"pem,omitempty"`
  1559. // Pkcs12: PKCS#12 format containing a single private/public key pair
  1560. // and certificate chain. This format is only accepted from client for
  1561. // creating a new SmimeInfo and is never returned, because the private
  1562. // key is not intended to be exported. PKCS#12 may be encrypted, in
  1563. // which case encryptedKeyPassword should be set appropriately.
  1564. Pkcs12 string `json:"pkcs12,omitempty"`
  1565. // ServerResponse contains the HTTP response code and headers from the
  1566. // server.
  1567. googleapi.ServerResponse `json:"-"`
  1568. // ForceSendFields is a list of field names (e.g.
  1569. // "EncryptedKeyPassword") to unconditionally include in API requests.
  1570. // By default, fields with empty values are omitted from API requests.
  1571. // However, any non-pointer, non-interface field appearing in
  1572. // ForceSendFields will be sent to the server regardless of whether the
  1573. // field is empty or not. This may be used to include empty fields in
  1574. // Patch requests.
  1575. ForceSendFields []string `json:"-"`
  1576. // NullFields is a list of field names (e.g. "EncryptedKeyPassword") to
  1577. // include in API requests with the JSON null value. By default, fields
  1578. // with empty values are omitted from API requests. However, any field
  1579. // with an empty value appearing in NullFields will be sent to the
  1580. // server as null. It is an error if a field in this list has a
  1581. // non-empty value. This may be used to include null fields in Patch
  1582. // requests.
  1583. NullFields []string `json:"-"`
  1584. }
  1585. func (s *SmimeInfo) MarshalJSON() ([]byte, error) {
  1586. type NoMethod SmimeInfo
  1587. raw := NoMethod(*s)
  1588. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1589. }
  1590. // SmtpMsa: Configuration for communication with an SMTP service.
  1591. type SmtpMsa struct {
  1592. // Host: The hostname of the SMTP service. Required.
  1593. Host string `json:"host,omitempty"`
  1594. // Password: The password that will be used for authentication with the
  1595. // SMTP service. This is a write-only field that can be specified in
  1596. // requests to create or update SendAs settings; it is never populated
  1597. // in responses.
  1598. Password string `json:"password,omitempty"`
  1599. // Port: The port of the SMTP service. Required.
  1600. Port int64 `json:"port,omitempty"`
  1601. // SecurityMode: The protocol that will be used to secure communication
  1602. // with the SMTP service. Required.
  1603. //
  1604. // Possible values:
  1605. // "none"
  1606. // "securityModeUnspecified"
  1607. // "ssl"
  1608. // "starttls"
  1609. SecurityMode string `json:"securityMode,omitempty"`
  1610. // Username: The username that will be used for authentication with the
  1611. // SMTP service. This is a write-only field that can be specified in
  1612. // requests to create or update SendAs settings; it is never populated
  1613. // in responses.
  1614. Username string `json:"username,omitempty"`
  1615. // ForceSendFields is a list of field names (e.g. "Host") to
  1616. // unconditionally include in API requests. By default, fields with
  1617. // empty values are omitted from API requests. However, any non-pointer,
  1618. // non-interface field appearing in ForceSendFields will be sent to the
  1619. // server regardless of whether the field is empty or not. This may be
  1620. // used to include empty fields in Patch requests.
  1621. ForceSendFields []string `json:"-"`
  1622. // NullFields is a list of field names (e.g. "Host") to include in API
  1623. // requests with the JSON null value. By default, fields with empty
  1624. // values are omitted from API requests. However, any field with an
  1625. // empty value appearing in NullFields will be sent to the server as
  1626. // null. It is an error if a field in this list has a non-empty value.
  1627. // This may be used to include null fields in Patch requests.
  1628. NullFields []string `json:"-"`
  1629. }
  1630. func (s *SmtpMsa) MarshalJSON() ([]byte, error) {
  1631. type NoMethod SmtpMsa
  1632. raw := NoMethod(*s)
  1633. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1634. }
  1635. // Thread: A collection of messages representing a conversation.
  1636. type Thread struct {
  1637. // HistoryId: The ID of the last history record that modified this
  1638. // thread.
  1639. HistoryId uint64 `json:"historyId,omitempty,string"`
  1640. // Id: The unique ID of the thread.
  1641. Id string `json:"id,omitempty"`
  1642. // Messages: The list of messages in the thread.
  1643. Messages []*Message `json:"messages,omitempty"`
  1644. // Snippet: A short part of the message text.
  1645. Snippet string `json:"snippet,omitempty"`
  1646. // ServerResponse contains the HTTP response code and headers from the
  1647. // server.
  1648. googleapi.ServerResponse `json:"-"`
  1649. // ForceSendFields is a list of field names (e.g. "HistoryId") to
  1650. // unconditionally include in API requests. By default, fields with
  1651. // empty values are omitted from API requests. However, any non-pointer,
  1652. // non-interface field appearing in ForceSendFields will be sent to the
  1653. // server regardless of whether the field is empty or not. This may be
  1654. // used to include empty fields in Patch requests.
  1655. ForceSendFields []string `json:"-"`
  1656. // NullFields is a list of field names (e.g. "HistoryId") to include in
  1657. // API requests with the JSON null value. By default, fields with empty
  1658. // values are omitted from API requests. However, any field with an
  1659. // empty value appearing in NullFields will be sent to the server as
  1660. // null. It is an error if a field in this list has a non-empty value.
  1661. // This may be used to include null fields in Patch requests.
  1662. NullFields []string `json:"-"`
  1663. }
  1664. func (s *Thread) MarshalJSON() ([]byte, error) {
  1665. type NoMethod Thread
  1666. raw := NoMethod(*s)
  1667. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1668. }
  1669. // VacationSettings: Vacation auto-reply settings for an account. These
  1670. // settings correspond to the "Vacation responder" feature in the web
  1671. // interface.
  1672. type VacationSettings struct {
  1673. // EnableAutoReply: Flag that controls whether Gmail automatically
  1674. // replies to messages.
  1675. EnableAutoReply bool `json:"enableAutoReply,omitempty"`
  1676. // EndTime: An optional end time for sending auto-replies (epoch ms).
  1677. // When this is specified, Gmail will automatically reply only to
  1678. // messages that it receives before the end time. If both startTime and
  1679. // endTime are specified, startTime must precede endTime.
  1680. EndTime int64 `json:"endTime,omitempty,string"`
  1681. // ResponseBodyHtml: Response body in HTML format. Gmail will sanitize
  1682. // the HTML before storing it.
  1683. ResponseBodyHtml string `json:"responseBodyHtml,omitempty"`
  1684. // ResponseBodyPlainText: Response body in plain text format.
  1685. ResponseBodyPlainText string `json:"responseBodyPlainText,omitempty"`
  1686. // ResponseSubject: Optional text to prepend to the subject line in
  1687. // vacation responses. In order to enable auto-replies, either the
  1688. // response subject or the response body must be nonempty.
  1689. ResponseSubject string `json:"responseSubject,omitempty"`
  1690. // RestrictToContacts: Flag that determines whether responses are sent
  1691. // to recipients who are not in the user's list of contacts.
  1692. RestrictToContacts bool `json:"restrictToContacts,omitempty"`
  1693. // RestrictToDomain: Flag that determines whether responses are sent to
  1694. // recipients who are outside of the user's domain. This feature is only
  1695. // available for G Suite users.
  1696. RestrictToDomain bool `json:"restrictToDomain,omitempty"`
  1697. // StartTime: An optional start time for sending auto-replies (epoch
  1698. // ms). When this is specified, Gmail will automatically reply only to
  1699. // messages that it receives after the start time. If both startTime and
  1700. // endTime are specified, startTime must precede endTime.
  1701. StartTime int64 `json:"startTime,omitempty,string"`
  1702. // ServerResponse contains the HTTP response code and headers from the
  1703. // server.
  1704. googleapi.ServerResponse `json:"-"`
  1705. // ForceSendFields is a list of field names (e.g. "EnableAutoReply") to
  1706. // unconditionally include in API requests. By default, fields with
  1707. // empty values are omitted from API requests. However, any non-pointer,
  1708. // non-interface field appearing in ForceSendFields will be sent to the
  1709. // server regardless of whether the field is empty or not. This may be
  1710. // used to include empty fields in Patch requests.
  1711. ForceSendFields []string `json:"-"`
  1712. // NullFields is a list of field names (e.g. "EnableAutoReply") to
  1713. // include in API requests with the JSON null value. By default, fields
  1714. // with empty values are omitted from API requests. However, any field
  1715. // with an empty value appearing in NullFields will be sent to the
  1716. // server as null. It is an error if a field in this list has a
  1717. // non-empty value. This may be used to include null fields in Patch
  1718. // requests.
  1719. NullFields []string `json:"-"`
  1720. }
  1721. func (s *VacationSettings) MarshalJSON() ([]byte, error) {
  1722. type NoMethod VacationSettings
  1723. raw := NoMethod(*s)
  1724. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1725. }
  1726. // WatchRequest: Set up or update a new push notification watch on this
  1727. // user's mailbox.
  1728. type WatchRequest struct {
  1729. // LabelFilterAction: Filtering behavior of labelIds list specified.
  1730. //
  1731. // Possible values:
  1732. // "exclude"
  1733. // "include"
  1734. LabelFilterAction string `json:"labelFilterAction,omitempty"`
  1735. // LabelIds: List of label_ids to restrict notifications about. By
  1736. // default, if unspecified, all changes are pushed out. If specified
  1737. // then dictates which labels are required for a push notification to be
  1738. // generated.
  1739. LabelIds []string `json:"labelIds,omitempty"`
  1740. // TopicName: A fully qualified Google Cloud Pub/Sub API topic name to
  1741. // publish the events to. This topic name **must** already exist in
  1742. // Cloud Pub/Sub and you **must** have already granted gmail "publish"
  1743. // permission on it. For example,
  1744. // "projects/my-project-identifier/topics/my-topic-name" (using the
  1745. // Cloud Pub/Sub "v1" topic naming format).
  1746. //
  1747. // Note that the "my-project-identifier" portion must exactly match your
  1748. // Google developer project id (the one executing this watch request).
  1749. TopicName string `json:"topicName,omitempty"`
  1750. // ForceSendFields is a list of field names (e.g. "LabelFilterAction")
  1751. // to unconditionally include in API requests. By default, fields with
  1752. // empty values are omitted from API requests. However, any non-pointer,
  1753. // non-interface field appearing in ForceSendFields will be sent to the
  1754. // server regardless of whether the field is empty or not. This may be
  1755. // used to include empty fields in Patch requests.
  1756. ForceSendFields []string `json:"-"`
  1757. // NullFields is a list of field names (e.g. "LabelFilterAction") to
  1758. // include in API requests with the JSON null value. By default, fields
  1759. // with empty values are omitted from API requests. However, any field
  1760. // with an empty value appearing in NullFields will be sent to the
  1761. // server as null. It is an error if a field in this list has a
  1762. // non-empty value. This may be used to include null fields in Patch
  1763. // requests.
  1764. NullFields []string `json:"-"`
  1765. }
  1766. func (s *WatchRequest) MarshalJSON() ([]byte, error) {
  1767. type NoMethod WatchRequest
  1768. raw := NoMethod(*s)
  1769. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1770. }
  1771. // WatchResponse: Push notification watch response.
  1772. type WatchResponse struct {
  1773. // Expiration: When Gmail will stop sending notifications for mailbox
  1774. // updates (epoch millis). Call watch again before this time to renew
  1775. // the watch.
  1776. Expiration int64 `json:"expiration,omitempty,string"`
  1777. // HistoryId: The ID of the mailbox's current history record.
  1778. HistoryId uint64 `json:"historyId,omitempty,string"`
  1779. // ServerResponse contains the HTTP response code and headers from the
  1780. // server.
  1781. googleapi.ServerResponse `json:"-"`
  1782. // ForceSendFields is a list of field names (e.g. "Expiration") to
  1783. // unconditionally include in API requests. By default, fields with
  1784. // empty values are omitted from API requests. However, any non-pointer,
  1785. // non-interface field appearing in ForceSendFields will be sent to the
  1786. // server regardless of whether the field is empty or not. This may be
  1787. // used to include empty fields in Patch requests.
  1788. ForceSendFields []string `json:"-"`
  1789. // NullFields is a list of field names (e.g. "Expiration") to include in
  1790. // API requests with the JSON null value. By default, fields with empty
  1791. // values are omitted from API requests. However, any field with an
  1792. // empty value appearing in NullFields will be sent to the server as
  1793. // null. It is an error if a field in this list has a non-empty value.
  1794. // This may be used to include null fields in Patch requests.
  1795. NullFields []string `json:"-"`
  1796. }
  1797. func (s *WatchResponse) MarshalJSON() ([]byte, error) {
  1798. type NoMethod WatchResponse
  1799. raw := NoMethod(*s)
  1800. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1801. }
  1802. // method id "gmail.users.getProfile":
  1803. type UsersGetProfileCall struct {
  1804. s *Service
  1805. userId string
  1806. urlParams_ gensupport.URLParams
  1807. ifNoneMatch_ string
  1808. ctx_ context.Context
  1809. header_ http.Header
  1810. }
  1811. // GetProfile: Gets the current user's Gmail profile.
  1812. func (r *UsersService) GetProfile(userId string) *UsersGetProfileCall {
  1813. c := &UsersGetProfileCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1814. c.userId = userId
  1815. return c
  1816. }
  1817. // Fields allows partial responses to be retrieved. See
  1818. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1819. // for more information.
  1820. func (c *UsersGetProfileCall) Fields(s ...googleapi.Field) *UsersGetProfileCall {
  1821. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1822. return c
  1823. }
  1824. // IfNoneMatch sets the optional parameter which makes the operation
  1825. // fail if the object's ETag matches the given value. This is useful for
  1826. // getting updates only after the object has changed since the last
  1827. // request. Use googleapi.IsNotModified to check whether the response
  1828. // error from Do is the result of In-None-Match.
  1829. func (c *UsersGetProfileCall) IfNoneMatch(entityTag string) *UsersGetProfileCall {
  1830. c.ifNoneMatch_ = entityTag
  1831. return c
  1832. }
  1833. // Context sets the context to be used in this call's Do method. Any
  1834. // pending HTTP request will be aborted if the provided context is
  1835. // canceled.
  1836. func (c *UsersGetProfileCall) Context(ctx context.Context) *UsersGetProfileCall {
  1837. c.ctx_ = ctx
  1838. return c
  1839. }
  1840. // Header returns an http.Header that can be modified by the caller to
  1841. // add HTTP headers to the request.
  1842. func (c *UsersGetProfileCall) Header() http.Header {
  1843. if c.header_ == nil {
  1844. c.header_ = make(http.Header)
  1845. }
  1846. return c.header_
  1847. }
  1848. func (c *UsersGetProfileCall) doRequest(alt string) (*http.Response, error) {
  1849. reqHeaders := make(http.Header)
  1850. for k, v := range c.header_ {
  1851. reqHeaders[k] = v
  1852. }
  1853. reqHeaders.Set("User-Agent", c.s.userAgent())
  1854. if c.ifNoneMatch_ != "" {
  1855. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1856. }
  1857. var body io.Reader = nil
  1858. c.urlParams_.Set("alt", alt)
  1859. c.urlParams_.Set("prettyPrint", "false")
  1860. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/profile")
  1861. urls += "?" + c.urlParams_.Encode()
  1862. req, err := http.NewRequest("GET", urls, body)
  1863. if err != nil {
  1864. return nil, err
  1865. }
  1866. req.Header = reqHeaders
  1867. googleapi.Expand(req.URL, map[string]string{
  1868. "userId": c.userId,
  1869. })
  1870. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1871. }
  1872. // Do executes the "gmail.users.getProfile" call.
  1873. // Exactly one of *Profile or error will be non-nil. Any non-2xx status
  1874. // code is an error. Response headers are in either
  1875. // *Profile.ServerResponse.Header or (if a response was returned at all)
  1876. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1877. // check whether the returned error was because http.StatusNotModified
  1878. // was returned.
  1879. func (c *UsersGetProfileCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
  1880. gensupport.SetOptions(c.urlParams_, opts...)
  1881. res, err := c.doRequest("json")
  1882. if res != nil && res.StatusCode == http.StatusNotModified {
  1883. if res.Body != nil {
  1884. res.Body.Close()
  1885. }
  1886. return nil, &googleapi.Error{
  1887. Code: res.StatusCode,
  1888. Header: res.Header,
  1889. }
  1890. }
  1891. if err != nil {
  1892. return nil, err
  1893. }
  1894. defer googleapi.CloseBody(res)
  1895. if err := googleapi.CheckResponse(res); err != nil {
  1896. return nil, err
  1897. }
  1898. ret := &Profile{
  1899. ServerResponse: googleapi.ServerResponse{
  1900. Header: res.Header,
  1901. HTTPStatusCode: res.StatusCode,
  1902. },
  1903. }
  1904. target := &ret
  1905. if err := gensupport.DecodeResponse(target, res); err != nil {
  1906. return nil, err
  1907. }
  1908. return ret, nil
  1909. // {
  1910. // "description": "Gets the current user's Gmail profile.",
  1911. // "httpMethod": "GET",
  1912. // "id": "gmail.users.getProfile",
  1913. // "parameterOrder": [
  1914. // "userId"
  1915. // ],
  1916. // "parameters": {
  1917. // "userId": {
  1918. // "default": "me",
  1919. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1920. // "location": "path",
  1921. // "required": true,
  1922. // "type": "string"
  1923. // }
  1924. // },
  1925. // "path": "{userId}/profile",
  1926. // "response": {
  1927. // "$ref": "Profile"
  1928. // },
  1929. // "scopes": [
  1930. // "https://mail.google.com/",
  1931. // "https://www.googleapis.com/auth/gmail.compose",
  1932. // "https://www.googleapis.com/auth/gmail.metadata",
  1933. // "https://www.googleapis.com/auth/gmail.modify",
  1934. // "https://www.googleapis.com/auth/gmail.readonly"
  1935. // ]
  1936. // }
  1937. }
  1938. // method id "gmail.users.stop":
  1939. type UsersStopCall struct {
  1940. s *Service
  1941. userId string
  1942. urlParams_ gensupport.URLParams
  1943. ctx_ context.Context
  1944. header_ http.Header
  1945. }
  1946. // Stop: Stop receiving push notifications for the given user mailbox.
  1947. func (r *UsersService) Stop(userId string) *UsersStopCall {
  1948. c := &UsersStopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1949. c.userId = userId
  1950. return c
  1951. }
  1952. // Fields allows partial responses to be retrieved. See
  1953. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1954. // for more information.
  1955. func (c *UsersStopCall) Fields(s ...googleapi.Field) *UsersStopCall {
  1956. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1957. return c
  1958. }
  1959. // Context sets the context to be used in this call's Do method. Any
  1960. // pending HTTP request will be aborted if the provided context is
  1961. // canceled.
  1962. func (c *UsersStopCall) Context(ctx context.Context) *UsersStopCall {
  1963. c.ctx_ = ctx
  1964. return c
  1965. }
  1966. // Header returns an http.Header that can be modified by the caller to
  1967. // add HTTP headers to the request.
  1968. func (c *UsersStopCall) Header() http.Header {
  1969. if c.header_ == nil {
  1970. c.header_ = make(http.Header)
  1971. }
  1972. return c.header_
  1973. }
  1974. func (c *UsersStopCall) doRequest(alt string) (*http.Response, error) {
  1975. reqHeaders := make(http.Header)
  1976. for k, v := range c.header_ {
  1977. reqHeaders[k] = v
  1978. }
  1979. reqHeaders.Set("User-Agent", c.s.userAgent())
  1980. var body io.Reader = nil
  1981. c.urlParams_.Set("alt", alt)
  1982. c.urlParams_.Set("prettyPrint", "false")
  1983. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/stop")
  1984. urls += "?" + c.urlParams_.Encode()
  1985. req, err := http.NewRequest("POST", urls, body)
  1986. if err != nil {
  1987. return nil, err
  1988. }
  1989. req.Header = reqHeaders
  1990. googleapi.Expand(req.URL, map[string]string{
  1991. "userId": c.userId,
  1992. })
  1993. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1994. }
  1995. // Do executes the "gmail.users.stop" call.
  1996. func (c *UsersStopCall) Do(opts ...googleapi.CallOption) error {
  1997. gensupport.SetOptions(c.urlParams_, opts...)
  1998. res, err := c.doRequest("json")
  1999. if err != nil {
  2000. return err
  2001. }
  2002. defer googleapi.CloseBody(res)
  2003. if err := googleapi.CheckResponse(res); err != nil {
  2004. return err
  2005. }
  2006. return nil
  2007. // {
  2008. // "description": "Stop receiving push notifications for the given user mailbox.",
  2009. // "httpMethod": "POST",
  2010. // "id": "gmail.users.stop",
  2011. // "parameterOrder": [
  2012. // "userId"
  2013. // ],
  2014. // "parameters": {
  2015. // "userId": {
  2016. // "default": "me",
  2017. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2018. // "location": "path",
  2019. // "required": true,
  2020. // "type": "string"
  2021. // }
  2022. // },
  2023. // "path": "{userId}/stop",
  2024. // "scopes": [
  2025. // "https://mail.google.com/",
  2026. // "https://www.googleapis.com/auth/gmail.metadata",
  2027. // "https://www.googleapis.com/auth/gmail.modify",
  2028. // "https://www.googleapis.com/auth/gmail.readonly"
  2029. // ]
  2030. // }
  2031. }
  2032. // method id "gmail.users.watch":
  2033. type UsersWatchCall struct {
  2034. s *Service
  2035. userId string
  2036. watchrequest *WatchRequest
  2037. urlParams_ gensupport.URLParams
  2038. ctx_ context.Context
  2039. header_ http.Header
  2040. }
  2041. // Watch: Set up or update a push notification watch on the given user
  2042. // mailbox.
  2043. func (r *UsersService) Watch(userId string, watchrequest *WatchRequest) *UsersWatchCall {
  2044. c := &UsersWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2045. c.userId = userId
  2046. c.watchrequest = watchrequest
  2047. return c
  2048. }
  2049. // Fields allows partial responses to be retrieved. See
  2050. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2051. // for more information.
  2052. func (c *UsersWatchCall) Fields(s ...googleapi.Field) *UsersWatchCall {
  2053. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2054. return c
  2055. }
  2056. // Context sets the context to be used in this call's Do method. Any
  2057. // pending HTTP request will be aborted if the provided context is
  2058. // canceled.
  2059. func (c *UsersWatchCall) Context(ctx context.Context) *UsersWatchCall {
  2060. c.ctx_ = ctx
  2061. return c
  2062. }
  2063. // Header returns an http.Header that can be modified by the caller to
  2064. // add HTTP headers to the request.
  2065. func (c *UsersWatchCall) Header() http.Header {
  2066. if c.header_ == nil {
  2067. c.header_ = make(http.Header)
  2068. }
  2069. return c.header_
  2070. }
  2071. func (c *UsersWatchCall) doRequest(alt string) (*http.Response, error) {
  2072. reqHeaders := make(http.Header)
  2073. for k, v := range c.header_ {
  2074. reqHeaders[k] = v
  2075. }
  2076. reqHeaders.Set("User-Agent", c.s.userAgent())
  2077. var body io.Reader = nil
  2078. body, err := googleapi.WithoutDataWrapper.JSONReader(c.watchrequest)
  2079. if err != nil {
  2080. return nil, err
  2081. }
  2082. reqHeaders.Set("Content-Type", "application/json")
  2083. c.urlParams_.Set("alt", alt)
  2084. c.urlParams_.Set("prettyPrint", "false")
  2085. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/watch")
  2086. urls += "?" + c.urlParams_.Encode()
  2087. req, err := http.NewRequest("POST", urls, body)
  2088. if err != nil {
  2089. return nil, err
  2090. }
  2091. req.Header = reqHeaders
  2092. googleapi.Expand(req.URL, map[string]string{
  2093. "userId": c.userId,
  2094. })
  2095. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2096. }
  2097. // Do executes the "gmail.users.watch" call.
  2098. // Exactly one of *WatchResponse or error will be non-nil. Any non-2xx
  2099. // status code is an error. Response headers are in either
  2100. // *WatchResponse.ServerResponse.Header or (if a response was returned
  2101. // at all) in error.(*googleapi.Error).Header. Use
  2102. // googleapi.IsNotModified to check whether the returned error was
  2103. // because http.StatusNotModified was returned.
  2104. func (c *UsersWatchCall) Do(opts ...googleapi.CallOption) (*WatchResponse, error) {
  2105. gensupport.SetOptions(c.urlParams_, opts...)
  2106. res, err := c.doRequest("json")
  2107. if res != nil && res.StatusCode == http.StatusNotModified {
  2108. if res.Body != nil {
  2109. res.Body.Close()
  2110. }
  2111. return nil, &googleapi.Error{
  2112. Code: res.StatusCode,
  2113. Header: res.Header,
  2114. }
  2115. }
  2116. if err != nil {
  2117. return nil, err
  2118. }
  2119. defer googleapi.CloseBody(res)
  2120. if err := googleapi.CheckResponse(res); err != nil {
  2121. return nil, err
  2122. }
  2123. ret := &WatchResponse{
  2124. ServerResponse: googleapi.ServerResponse{
  2125. Header: res.Header,
  2126. HTTPStatusCode: res.StatusCode,
  2127. },
  2128. }
  2129. target := &ret
  2130. if err := gensupport.DecodeResponse(target, res); err != nil {
  2131. return nil, err
  2132. }
  2133. return ret, nil
  2134. // {
  2135. // "description": "Set up or update a push notification watch on the given user mailbox.",
  2136. // "httpMethod": "POST",
  2137. // "id": "gmail.users.watch",
  2138. // "parameterOrder": [
  2139. // "userId"
  2140. // ],
  2141. // "parameters": {
  2142. // "userId": {
  2143. // "default": "me",
  2144. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2145. // "location": "path",
  2146. // "required": true,
  2147. // "type": "string"
  2148. // }
  2149. // },
  2150. // "path": "{userId}/watch",
  2151. // "request": {
  2152. // "$ref": "WatchRequest"
  2153. // },
  2154. // "response": {
  2155. // "$ref": "WatchResponse"
  2156. // },
  2157. // "scopes": [
  2158. // "https://mail.google.com/",
  2159. // "https://www.googleapis.com/auth/gmail.metadata",
  2160. // "https://www.googleapis.com/auth/gmail.modify",
  2161. // "https://www.googleapis.com/auth/gmail.readonly"
  2162. // ]
  2163. // }
  2164. }
  2165. // method id "gmail.users.drafts.create":
  2166. type UsersDraftsCreateCall struct {
  2167. s *Service
  2168. userId string
  2169. draft *Draft
  2170. urlParams_ gensupport.URLParams
  2171. mediaInfo_ *gensupport.MediaInfo
  2172. ctx_ context.Context
  2173. header_ http.Header
  2174. }
  2175. // Create: Creates a new draft with the DRAFT label.
  2176. func (r *UsersDraftsService) Create(userId string, draft *Draft) *UsersDraftsCreateCall {
  2177. c := &UsersDraftsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2178. c.userId = userId
  2179. c.draft = draft
  2180. return c
  2181. }
  2182. // Media specifies the media to upload in one or more chunks. The chunk
  2183. // size may be controlled by supplying a MediaOption generated by
  2184. // googleapi.ChunkSize. The chunk size defaults to
  2185. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  2186. // upload request will be determined by sniffing the contents of r,
  2187. // unless a MediaOption generated by googleapi.ContentType is
  2188. // supplied.
  2189. // At most one of Media and ResumableMedia may be set.
  2190. func (c *UsersDraftsCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsCreateCall {
  2191. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  2192. return c
  2193. }
  2194. // ResumableMedia specifies the media to upload in chunks and can be
  2195. // canceled with ctx.
  2196. //
  2197. // Deprecated: use Media instead.
  2198. //
  2199. // At most one of Media and ResumableMedia may be set. mediaType
  2200. // identifies the MIME media type of the upload, such as "image/png". If
  2201. // mediaType is "", it will be auto-detected. The provided ctx will
  2202. // supersede any context previously provided to the Context method.
  2203. func (c *UsersDraftsCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsCreateCall {
  2204. c.ctx_ = ctx
  2205. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  2206. return c
  2207. }
  2208. // ProgressUpdater provides a callback function that will be called
  2209. // after every chunk. It should be a low-latency function in order to
  2210. // not slow down the upload operation. This should only be called when
  2211. // using ResumableMedia (as opposed to Media).
  2212. func (c *UsersDraftsCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsCreateCall {
  2213. c.mediaInfo_.SetProgressUpdater(pu)
  2214. return c
  2215. }
  2216. // Fields allows partial responses to be retrieved. See
  2217. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2218. // for more information.
  2219. func (c *UsersDraftsCreateCall) Fields(s ...googleapi.Field) *UsersDraftsCreateCall {
  2220. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2221. return c
  2222. }
  2223. // Context sets the context to be used in this call's Do method. Any
  2224. // pending HTTP request will be aborted if the provided context is
  2225. // canceled.
  2226. // This context will supersede any context previously provided to the
  2227. // ResumableMedia method.
  2228. func (c *UsersDraftsCreateCall) Context(ctx context.Context) *UsersDraftsCreateCall {
  2229. c.ctx_ = ctx
  2230. return c
  2231. }
  2232. // Header returns an http.Header that can be modified by the caller to
  2233. // add HTTP headers to the request.
  2234. func (c *UsersDraftsCreateCall) Header() http.Header {
  2235. if c.header_ == nil {
  2236. c.header_ = make(http.Header)
  2237. }
  2238. return c.header_
  2239. }
  2240. func (c *UsersDraftsCreateCall) doRequest(alt string) (*http.Response, error) {
  2241. reqHeaders := make(http.Header)
  2242. for k, v := range c.header_ {
  2243. reqHeaders[k] = v
  2244. }
  2245. reqHeaders.Set("User-Agent", c.s.userAgent())
  2246. var body io.Reader = nil
  2247. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  2248. if err != nil {
  2249. return nil, err
  2250. }
  2251. reqHeaders.Set("Content-Type", "application/json")
  2252. c.urlParams_.Set("alt", alt)
  2253. c.urlParams_.Set("prettyPrint", "false")
  2254. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
  2255. if c.mediaInfo_ != nil {
  2256. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  2257. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  2258. }
  2259. if body == nil {
  2260. body = new(bytes.Buffer)
  2261. reqHeaders.Set("Content-Type", "application/json")
  2262. }
  2263. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  2264. defer cleanup()
  2265. urls += "?" + c.urlParams_.Encode()
  2266. req, err := http.NewRequest("POST", urls, body)
  2267. if err != nil {
  2268. return nil, err
  2269. }
  2270. req.Header = reqHeaders
  2271. req.GetBody = getBody
  2272. googleapi.Expand(req.URL, map[string]string{
  2273. "userId": c.userId,
  2274. })
  2275. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2276. }
  2277. // Do executes the "gmail.users.drafts.create" call.
  2278. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  2279. // code is an error. Response headers are in either
  2280. // *Draft.ServerResponse.Header or (if a response was returned at all)
  2281. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2282. // check whether the returned error was because http.StatusNotModified
  2283. // was returned.
  2284. func (c *UsersDraftsCreateCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  2285. gensupport.SetOptions(c.urlParams_, opts...)
  2286. res, err := c.doRequest("json")
  2287. if res != nil && res.StatusCode == http.StatusNotModified {
  2288. if res.Body != nil {
  2289. res.Body.Close()
  2290. }
  2291. return nil, &googleapi.Error{
  2292. Code: res.StatusCode,
  2293. Header: res.Header,
  2294. }
  2295. }
  2296. if err != nil {
  2297. return nil, err
  2298. }
  2299. defer googleapi.CloseBody(res)
  2300. if err := googleapi.CheckResponse(res); err != nil {
  2301. return nil, err
  2302. }
  2303. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  2304. if rx != nil {
  2305. rx.Client = c.s.client
  2306. rx.UserAgent = c.s.userAgent()
  2307. ctx := c.ctx_
  2308. if ctx == nil {
  2309. ctx = context.TODO()
  2310. }
  2311. res, err = rx.Upload(ctx)
  2312. if err != nil {
  2313. return nil, err
  2314. }
  2315. defer res.Body.Close()
  2316. if err := googleapi.CheckResponse(res); err != nil {
  2317. return nil, err
  2318. }
  2319. }
  2320. ret := &Draft{
  2321. ServerResponse: googleapi.ServerResponse{
  2322. Header: res.Header,
  2323. HTTPStatusCode: res.StatusCode,
  2324. },
  2325. }
  2326. target := &ret
  2327. if err := gensupport.DecodeResponse(target, res); err != nil {
  2328. return nil, err
  2329. }
  2330. return ret, nil
  2331. // {
  2332. // "description": "Creates a new draft with the DRAFT label.",
  2333. // "httpMethod": "POST",
  2334. // "id": "gmail.users.drafts.create",
  2335. // "mediaUpload": {
  2336. // "accept": [
  2337. // "message/rfc822"
  2338. // ],
  2339. // "maxSize": "35MB",
  2340. // "protocols": {
  2341. // "resumable": {
  2342. // "multipart": true,
  2343. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts"
  2344. // },
  2345. // "simple": {
  2346. // "multipart": true,
  2347. // "path": "/upload/gmail/v1/users/{userId}/drafts"
  2348. // }
  2349. // }
  2350. // },
  2351. // "parameterOrder": [
  2352. // "userId"
  2353. // ],
  2354. // "parameters": {
  2355. // "userId": {
  2356. // "default": "me",
  2357. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2358. // "location": "path",
  2359. // "required": true,
  2360. // "type": "string"
  2361. // }
  2362. // },
  2363. // "path": "{userId}/drafts",
  2364. // "request": {
  2365. // "$ref": "Draft"
  2366. // },
  2367. // "response": {
  2368. // "$ref": "Draft"
  2369. // },
  2370. // "scopes": [
  2371. // "https://mail.google.com/",
  2372. // "https://www.googleapis.com/auth/gmail.compose",
  2373. // "https://www.googleapis.com/auth/gmail.modify"
  2374. // ],
  2375. // "supportsMediaUpload": true
  2376. // }
  2377. }
  2378. // method id "gmail.users.drafts.delete":
  2379. type UsersDraftsDeleteCall struct {
  2380. s *Service
  2381. userId string
  2382. id string
  2383. urlParams_ gensupport.URLParams
  2384. ctx_ context.Context
  2385. header_ http.Header
  2386. }
  2387. // Delete: Immediately and permanently deletes the specified draft. Does
  2388. // not simply trash it.
  2389. func (r *UsersDraftsService) Delete(userId string, id string) *UsersDraftsDeleteCall {
  2390. c := &UsersDraftsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2391. c.userId = userId
  2392. c.id = id
  2393. return c
  2394. }
  2395. // Fields allows partial responses to be retrieved. See
  2396. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2397. // for more information.
  2398. func (c *UsersDraftsDeleteCall) Fields(s ...googleapi.Field) *UsersDraftsDeleteCall {
  2399. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2400. return c
  2401. }
  2402. // Context sets the context to be used in this call's Do method. Any
  2403. // pending HTTP request will be aborted if the provided context is
  2404. // canceled.
  2405. func (c *UsersDraftsDeleteCall) Context(ctx context.Context) *UsersDraftsDeleteCall {
  2406. c.ctx_ = ctx
  2407. return c
  2408. }
  2409. // Header returns an http.Header that can be modified by the caller to
  2410. // add HTTP headers to the request.
  2411. func (c *UsersDraftsDeleteCall) Header() http.Header {
  2412. if c.header_ == nil {
  2413. c.header_ = make(http.Header)
  2414. }
  2415. return c.header_
  2416. }
  2417. func (c *UsersDraftsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2418. reqHeaders := make(http.Header)
  2419. for k, v := range c.header_ {
  2420. reqHeaders[k] = v
  2421. }
  2422. reqHeaders.Set("User-Agent", c.s.userAgent())
  2423. var body io.Reader = nil
  2424. c.urlParams_.Set("alt", alt)
  2425. c.urlParams_.Set("prettyPrint", "false")
  2426. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  2427. urls += "?" + c.urlParams_.Encode()
  2428. req, err := http.NewRequest("DELETE", urls, body)
  2429. if err != nil {
  2430. return nil, err
  2431. }
  2432. req.Header = reqHeaders
  2433. googleapi.Expand(req.URL, map[string]string{
  2434. "userId": c.userId,
  2435. "id": c.id,
  2436. })
  2437. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2438. }
  2439. // Do executes the "gmail.users.drafts.delete" call.
  2440. func (c *UsersDraftsDeleteCall) Do(opts ...googleapi.CallOption) error {
  2441. gensupport.SetOptions(c.urlParams_, opts...)
  2442. res, err := c.doRequest("json")
  2443. if err != nil {
  2444. return err
  2445. }
  2446. defer googleapi.CloseBody(res)
  2447. if err := googleapi.CheckResponse(res); err != nil {
  2448. return err
  2449. }
  2450. return nil
  2451. // {
  2452. // "description": "Immediately and permanently deletes the specified draft. Does not simply trash it.",
  2453. // "httpMethod": "DELETE",
  2454. // "id": "gmail.users.drafts.delete",
  2455. // "parameterOrder": [
  2456. // "userId",
  2457. // "id"
  2458. // ],
  2459. // "parameters": {
  2460. // "id": {
  2461. // "description": "The ID of the draft to delete.",
  2462. // "location": "path",
  2463. // "required": true,
  2464. // "type": "string"
  2465. // },
  2466. // "userId": {
  2467. // "default": "me",
  2468. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2469. // "location": "path",
  2470. // "required": true,
  2471. // "type": "string"
  2472. // }
  2473. // },
  2474. // "path": "{userId}/drafts/{id}",
  2475. // "scopes": [
  2476. // "https://mail.google.com/",
  2477. // "https://www.googleapis.com/auth/gmail.compose",
  2478. // "https://www.googleapis.com/auth/gmail.modify"
  2479. // ]
  2480. // }
  2481. }
  2482. // method id "gmail.users.drafts.get":
  2483. type UsersDraftsGetCall struct {
  2484. s *Service
  2485. userId string
  2486. id string
  2487. urlParams_ gensupport.URLParams
  2488. ifNoneMatch_ string
  2489. ctx_ context.Context
  2490. header_ http.Header
  2491. }
  2492. // Get: Gets the specified draft.
  2493. func (r *UsersDraftsService) Get(userId string, id string) *UsersDraftsGetCall {
  2494. c := &UsersDraftsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2495. c.userId = userId
  2496. c.id = id
  2497. return c
  2498. }
  2499. // Format sets the optional parameter "format": The format to return the
  2500. // draft in.
  2501. //
  2502. // Possible values:
  2503. // "full" (default)
  2504. // "metadata"
  2505. // "minimal"
  2506. // "raw"
  2507. func (c *UsersDraftsGetCall) Format(format string) *UsersDraftsGetCall {
  2508. c.urlParams_.Set("format", format)
  2509. return c
  2510. }
  2511. // Fields allows partial responses to be retrieved. See
  2512. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2513. // for more information.
  2514. func (c *UsersDraftsGetCall) Fields(s ...googleapi.Field) *UsersDraftsGetCall {
  2515. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2516. return c
  2517. }
  2518. // IfNoneMatch sets the optional parameter which makes the operation
  2519. // fail if the object's ETag matches the given value. This is useful for
  2520. // getting updates only after the object has changed since the last
  2521. // request. Use googleapi.IsNotModified to check whether the response
  2522. // error from Do is the result of In-None-Match.
  2523. func (c *UsersDraftsGetCall) IfNoneMatch(entityTag string) *UsersDraftsGetCall {
  2524. c.ifNoneMatch_ = entityTag
  2525. return c
  2526. }
  2527. // Context sets the context to be used in this call's Do method. Any
  2528. // pending HTTP request will be aborted if the provided context is
  2529. // canceled.
  2530. func (c *UsersDraftsGetCall) Context(ctx context.Context) *UsersDraftsGetCall {
  2531. c.ctx_ = ctx
  2532. return c
  2533. }
  2534. // Header returns an http.Header that can be modified by the caller to
  2535. // add HTTP headers to the request.
  2536. func (c *UsersDraftsGetCall) Header() http.Header {
  2537. if c.header_ == nil {
  2538. c.header_ = make(http.Header)
  2539. }
  2540. return c.header_
  2541. }
  2542. func (c *UsersDraftsGetCall) doRequest(alt string) (*http.Response, error) {
  2543. reqHeaders := make(http.Header)
  2544. for k, v := range c.header_ {
  2545. reqHeaders[k] = v
  2546. }
  2547. reqHeaders.Set("User-Agent", c.s.userAgent())
  2548. if c.ifNoneMatch_ != "" {
  2549. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2550. }
  2551. var body io.Reader = nil
  2552. c.urlParams_.Set("alt", alt)
  2553. c.urlParams_.Set("prettyPrint", "false")
  2554. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  2555. urls += "?" + c.urlParams_.Encode()
  2556. req, err := http.NewRequest("GET", urls, body)
  2557. if err != nil {
  2558. return nil, err
  2559. }
  2560. req.Header = reqHeaders
  2561. googleapi.Expand(req.URL, map[string]string{
  2562. "userId": c.userId,
  2563. "id": c.id,
  2564. })
  2565. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2566. }
  2567. // Do executes the "gmail.users.drafts.get" call.
  2568. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  2569. // code is an error. Response headers are in either
  2570. // *Draft.ServerResponse.Header or (if a response was returned at all)
  2571. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2572. // check whether the returned error was because http.StatusNotModified
  2573. // was returned.
  2574. func (c *UsersDraftsGetCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  2575. gensupport.SetOptions(c.urlParams_, opts...)
  2576. res, err := c.doRequest("json")
  2577. if res != nil && res.StatusCode == http.StatusNotModified {
  2578. if res.Body != nil {
  2579. res.Body.Close()
  2580. }
  2581. return nil, &googleapi.Error{
  2582. Code: res.StatusCode,
  2583. Header: res.Header,
  2584. }
  2585. }
  2586. if err != nil {
  2587. return nil, err
  2588. }
  2589. defer googleapi.CloseBody(res)
  2590. if err := googleapi.CheckResponse(res); err != nil {
  2591. return nil, err
  2592. }
  2593. ret := &Draft{
  2594. ServerResponse: googleapi.ServerResponse{
  2595. Header: res.Header,
  2596. HTTPStatusCode: res.StatusCode,
  2597. },
  2598. }
  2599. target := &ret
  2600. if err := gensupport.DecodeResponse(target, res); err != nil {
  2601. return nil, err
  2602. }
  2603. return ret, nil
  2604. // {
  2605. // "description": "Gets the specified draft.",
  2606. // "httpMethod": "GET",
  2607. // "id": "gmail.users.drafts.get",
  2608. // "parameterOrder": [
  2609. // "userId",
  2610. // "id"
  2611. // ],
  2612. // "parameters": {
  2613. // "format": {
  2614. // "default": "full",
  2615. // "description": "The format to return the draft in.",
  2616. // "enum": [
  2617. // "full",
  2618. // "metadata",
  2619. // "minimal",
  2620. // "raw"
  2621. // ],
  2622. // "enumDescriptions": [
  2623. // "",
  2624. // "",
  2625. // "",
  2626. // ""
  2627. // ],
  2628. // "location": "query",
  2629. // "type": "string"
  2630. // },
  2631. // "id": {
  2632. // "description": "The ID of the draft to retrieve.",
  2633. // "location": "path",
  2634. // "required": true,
  2635. // "type": "string"
  2636. // },
  2637. // "userId": {
  2638. // "default": "me",
  2639. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2640. // "location": "path",
  2641. // "required": true,
  2642. // "type": "string"
  2643. // }
  2644. // },
  2645. // "path": "{userId}/drafts/{id}",
  2646. // "response": {
  2647. // "$ref": "Draft"
  2648. // },
  2649. // "scopes": [
  2650. // "https://mail.google.com/",
  2651. // "https://www.googleapis.com/auth/gmail.compose",
  2652. // "https://www.googleapis.com/auth/gmail.modify",
  2653. // "https://www.googleapis.com/auth/gmail.readonly"
  2654. // ]
  2655. // }
  2656. }
  2657. // method id "gmail.users.drafts.list":
  2658. type UsersDraftsListCall struct {
  2659. s *Service
  2660. userId string
  2661. urlParams_ gensupport.URLParams
  2662. ifNoneMatch_ string
  2663. ctx_ context.Context
  2664. header_ http.Header
  2665. }
  2666. // List: Lists the drafts in the user's mailbox.
  2667. func (r *UsersDraftsService) List(userId string) *UsersDraftsListCall {
  2668. c := &UsersDraftsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2669. c.userId = userId
  2670. return c
  2671. }
  2672. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  2673. // Include drafts from SPAM and TRASH in the results.
  2674. func (c *UsersDraftsListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersDraftsListCall {
  2675. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  2676. return c
  2677. }
  2678. // MaxResults sets the optional parameter "maxResults": Maximum number
  2679. // of drafts to return.
  2680. func (c *UsersDraftsListCall) MaxResults(maxResults int64) *UsersDraftsListCall {
  2681. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  2682. return c
  2683. }
  2684. // PageToken sets the optional parameter "pageToken": Page token to
  2685. // retrieve a specific page of results in the list.
  2686. func (c *UsersDraftsListCall) PageToken(pageToken string) *UsersDraftsListCall {
  2687. c.urlParams_.Set("pageToken", pageToken)
  2688. return c
  2689. }
  2690. // Q sets the optional parameter "q": Only return draft messages
  2691. // matching the specified query. Supports the same query format as the
  2692. // Gmail search box. For example, "from:someuser@example.com
  2693. // rfc822msgid: is:unread".
  2694. func (c *UsersDraftsListCall) Q(q string) *UsersDraftsListCall {
  2695. c.urlParams_.Set("q", q)
  2696. return c
  2697. }
  2698. // Fields allows partial responses to be retrieved. See
  2699. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2700. // for more information.
  2701. func (c *UsersDraftsListCall) Fields(s ...googleapi.Field) *UsersDraftsListCall {
  2702. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2703. return c
  2704. }
  2705. // IfNoneMatch sets the optional parameter which makes the operation
  2706. // fail if the object's ETag matches the given value. This is useful for
  2707. // getting updates only after the object has changed since the last
  2708. // request. Use googleapi.IsNotModified to check whether the response
  2709. // error from Do is the result of In-None-Match.
  2710. func (c *UsersDraftsListCall) IfNoneMatch(entityTag string) *UsersDraftsListCall {
  2711. c.ifNoneMatch_ = entityTag
  2712. return c
  2713. }
  2714. // Context sets the context to be used in this call's Do method. Any
  2715. // pending HTTP request will be aborted if the provided context is
  2716. // canceled.
  2717. func (c *UsersDraftsListCall) Context(ctx context.Context) *UsersDraftsListCall {
  2718. c.ctx_ = ctx
  2719. return c
  2720. }
  2721. // Header returns an http.Header that can be modified by the caller to
  2722. // add HTTP headers to the request.
  2723. func (c *UsersDraftsListCall) Header() http.Header {
  2724. if c.header_ == nil {
  2725. c.header_ = make(http.Header)
  2726. }
  2727. return c.header_
  2728. }
  2729. func (c *UsersDraftsListCall) doRequest(alt string) (*http.Response, error) {
  2730. reqHeaders := make(http.Header)
  2731. for k, v := range c.header_ {
  2732. reqHeaders[k] = v
  2733. }
  2734. reqHeaders.Set("User-Agent", c.s.userAgent())
  2735. if c.ifNoneMatch_ != "" {
  2736. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2737. }
  2738. var body io.Reader = nil
  2739. c.urlParams_.Set("alt", alt)
  2740. c.urlParams_.Set("prettyPrint", "false")
  2741. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
  2742. urls += "?" + c.urlParams_.Encode()
  2743. req, err := http.NewRequest("GET", urls, body)
  2744. if err != nil {
  2745. return nil, err
  2746. }
  2747. req.Header = reqHeaders
  2748. googleapi.Expand(req.URL, map[string]string{
  2749. "userId": c.userId,
  2750. })
  2751. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2752. }
  2753. // Do executes the "gmail.users.drafts.list" call.
  2754. // Exactly one of *ListDraftsResponse or error will be non-nil. Any
  2755. // non-2xx status code is an error. Response headers are in either
  2756. // *ListDraftsResponse.ServerResponse.Header or (if a response was
  2757. // returned at all) in error.(*googleapi.Error).Header. Use
  2758. // googleapi.IsNotModified to check whether the returned error was
  2759. // because http.StatusNotModified was returned.
  2760. func (c *UsersDraftsListCall) Do(opts ...googleapi.CallOption) (*ListDraftsResponse, error) {
  2761. gensupport.SetOptions(c.urlParams_, opts...)
  2762. res, err := c.doRequest("json")
  2763. if res != nil && res.StatusCode == http.StatusNotModified {
  2764. if res.Body != nil {
  2765. res.Body.Close()
  2766. }
  2767. return nil, &googleapi.Error{
  2768. Code: res.StatusCode,
  2769. Header: res.Header,
  2770. }
  2771. }
  2772. if err != nil {
  2773. return nil, err
  2774. }
  2775. defer googleapi.CloseBody(res)
  2776. if err := googleapi.CheckResponse(res); err != nil {
  2777. return nil, err
  2778. }
  2779. ret := &ListDraftsResponse{
  2780. ServerResponse: googleapi.ServerResponse{
  2781. Header: res.Header,
  2782. HTTPStatusCode: res.StatusCode,
  2783. },
  2784. }
  2785. target := &ret
  2786. if err := gensupport.DecodeResponse(target, res); err != nil {
  2787. return nil, err
  2788. }
  2789. return ret, nil
  2790. // {
  2791. // "description": "Lists the drafts in the user's mailbox.",
  2792. // "httpMethod": "GET",
  2793. // "id": "gmail.users.drafts.list",
  2794. // "parameterOrder": [
  2795. // "userId"
  2796. // ],
  2797. // "parameters": {
  2798. // "includeSpamTrash": {
  2799. // "default": "false",
  2800. // "description": "Include drafts from SPAM and TRASH in the results.",
  2801. // "location": "query",
  2802. // "type": "boolean"
  2803. // },
  2804. // "maxResults": {
  2805. // "default": "100",
  2806. // "description": "Maximum number of drafts to return.",
  2807. // "format": "uint32",
  2808. // "location": "query",
  2809. // "type": "integer"
  2810. // },
  2811. // "pageToken": {
  2812. // "description": "Page token to retrieve a specific page of results in the list.",
  2813. // "location": "query",
  2814. // "type": "string"
  2815. // },
  2816. // "q": {
  2817. // "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\".",
  2818. // "location": "query",
  2819. // "type": "string"
  2820. // },
  2821. // "userId": {
  2822. // "default": "me",
  2823. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2824. // "location": "path",
  2825. // "required": true,
  2826. // "type": "string"
  2827. // }
  2828. // },
  2829. // "path": "{userId}/drafts",
  2830. // "response": {
  2831. // "$ref": "ListDraftsResponse"
  2832. // },
  2833. // "scopes": [
  2834. // "https://mail.google.com/",
  2835. // "https://www.googleapis.com/auth/gmail.compose",
  2836. // "https://www.googleapis.com/auth/gmail.modify",
  2837. // "https://www.googleapis.com/auth/gmail.readonly"
  2838. // ]
  2839. // }
  2840. }
  2841. // Pages invokes f for each page of results.
  2842. // A non-nil error returned from f will halt the iteration.
  2843. // The provided context supersedes any context provided to the Context method.
  2844. func (c *UsersDraftsListCall) Pages(ctx context.Context, f func(*ListDraftsResponse) error) error {
  2845. c.ctx_ = ctx
  2846. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2847. for {
  2848. x, err := c.Do()
  2849. if err != nil {
  2850. return err
  2851. }
  2852. if err := f(x); err != nil {
  2853. return err
  2854. }
  2855. if x.NextPageToken == "" {
  2856. return nil
  2857. }
  2858. c.PageToken(x.NextPageToken)
  2859. }
  2860. }
  2861. // method id "gmail.users.drafts.send":
  2862. type UsersDraftsSendCall struct {
  2863. s *Service
  2864. userId string
  2865. draft *Draft
  2866. urlParams_ gensupport.URLParams
  2867. mediaInfo_ *gensupport.MediaInfo
  2868. ctx_ context.Context
  2869. header_ http.Header
  2870. }
  2871. // Send: Sends the specified, existing draft to the recipients in the
  2872. // To, Cc, and Bcc headers.
  2873. func (r *UsersDraftsService) Send(userId string, draft *Draft) *UsersDraftsSendCall {
  2874. c := &UsersDraftsSendCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2875. c.userId = userId
  2876. c.draft = draft
  2877. return c
  2878. }
  2879. // Media specifies the media to upload in one or more chunks. The chunk
  2880. // size may be controlled by supplying a MediaOption generated by
  2881. // googleapi.ChunkSize. The chunk size defaults to
  2882. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  2883. // upload request will be determined by sniffing the contents of r,
  2884. // unless a MediaOption generated by googleapi.ContentType is
  2885. // supplied.
  2886. // At most one of Media and ResumableMedia may be set.
  2887. func (c *UsersDraftsSendCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsSendCall {
  2888. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  2889. return c
  2890. }
  2891. // ResumableMedia specifies the media to upload in chunks and can be
  2892. // canceled with ctx.
  2893. //
  2894. // Deprecated: use Media instead.
  2895. //
  2896. // At most one of Media and ResumableMedia may be set. mediaType
  2897. // identifies the MIME media type of the upload, such as "image/png". If
  2898. // mediaType is "", it will be auto-detected. The provided ctx will
  2899. // supersede any context previously provided to the Context method.
  2900. func (c *UsersDraftsSendCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsSendCall {
  2901. c.ctx_ = ctx
  2902. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  2903. return c
  2904. }
  2905. // ProgressUpdater provides a callback function that will be called
  2906. // after every chunk. It should be a low-latency function in order to
  2907. // not slow down the upload operation. This should only be called when
  2908. // using ResumableMedia (as opposed to Media).
  2909. func (c *UsersDraftsSendCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsSendCall {
  2910. c.mediaInfo_.SetProgressUpdater(pu)
  2911. return c
  2912. }
  2913. // Fields allows partial responses to be retrieved. See
  2914. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2915. // for more information.
  2916. func (c *UsersDraftsSendCall) Fields(s ...googleapi.Field) *UsersDraftsSendCall {
  2917. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2918. return c
  2919. }
  2920. // Context sets the context to be used in this call's Do method. Any
  2921. // pending HTTP request will be aborted if the provided context is
  2922. // canceled.
  2923. // This context will supersede any context previously provided to the
  2924. // ResumableMedia method.
  2925. func (c *UsersDraftsSendCall) Context(ctx context.Context) *UsersDraftsSendCall {
  2926. c.ctx_ = ctx
  2927. return c
  2928. }
  2929. // Header returns an http.Header that can be modified by the caller to
  2930. // add HTTP headers to the request.
  2931. func (c *UsersDraftsSendCall) Header() http.Header {
  2932. if c.header_ == nil {
  2933. c.header_ = make(http.Header)
  2934. }
  2935. return c.header_
  2936. }
  2937. func (c *UsersDraftsSendCall) doRequest(alt string) (*http.Response, error) {
  2938. reqHeaders := make(http.Header)
  2939. for k, v := range c.header_ {
  2940. reqHeaders[k] = v
  2941. }
  2942. reqHeaders.Set("User-Agent", c.s.userAgent())
  2943. var body io.Reader = nil
  2944. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  2945. if err != nil {
  2946. return nil, err
  2947. }
  2948. reqHeaders.Set("Content-Type", "application/json")
  2949. c.urlParams_.Set("alt", alt)
  2950. c.urlParams_.Set("prettyPrint", "false")
  2951. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/send")
  2952. if c.mediaInfo_ != nil {
  2953. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  2954. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  2955. }
  2956. if body == nil {
  2957. body = new(bytes.Buffer)
  2958. reqHeaders.Set("Content-Type", "application/json")
  2959. }
  2960. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  2961. defer cleanup()
  2962. urls += "?" + c.urlParams_.Encode()
  2963. req, err := http.NewRequest("POST", urls, body)
  2964. if err != nil {
  2965. return nil, err
  2966. }
  2967. req.Header = reqHeaders
  2968. req.GetBody = getBody
  2969. googleapi.Expand(req.URL, map[string]string{
  2970. "userId": c.userId,
  2971. })
  2972. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2973. }
  2974. // Do executes the "gmail.users.drafts.send" call.
  2975. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  2976. // code is an error. Response headers are in either
  2977. // *Message.ServerResponse.Header or (if a response was returned at all)
  2978. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2979. // check whether the returned error was because http.StatusNotModified
  2980. // was returned.
  2981. func (c *UsersDraftsSendCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  2982. gensupport.SetOptions(c.urlParams_, opts...)
  2983. res, err := c.doRequest("json")
  2984. if res != nil && res.StatusCode == http.StatusNotModified {
  2985. if res.Body != nil {
  2986. res.Body.Close()
  2987. }
  2988. return nil, &googleapi.Error{
  2989. Code: res.StatusCode,
  2990. Header: res.Header,
  2991. }
  2992. }
  2993. if err != nil {
  2994. return nil, err
  2995. }
  2996. defer googleapi.CloseBody(res)
  2997. if err := googleapi.CheckResponse(res); err != nil {
  2998. return nil, err
  2999. }
  3000. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  3001. if rx != nil {
  3002. rx.Client = c.s.client
  3003. rx.UserAgent = c.s.userAgent()
  3004. ctx := c.ctx_
  3005. if ctx == nil {
  3006. ctx = context.TODO()
  3007. }
  3008. res, err = rx.Upload(ctx)
  3009. if err != nil {
  3010. return nil, err
  3011. }
  3012. defer res.Body.Close()
  3013. if err := googleapi.CheckResponse(res); err != nil {
  3014. return nil, err
  3015. }
  3016. }
  3017. ret := &Message{
  3018. ServerResponse: googleapi.ServerResponse{
  3019. Header: res.Header,
  3020. HTTPStatusCode: res.StatusCode,
  3021. },
  3022. }
  3023. target := &ret
  3024. if err := gensupport.DecodeResponse(target, res); err != nil {
  3025. return nil, err
  3026. }
  3027. return ret, nil
  3028. // {
  3029. // "description": "Sends the specified, existing draft to the recipients in the To, Cc, and Bcc headers.",
  3030. // "httpMethod": "POST",
  3031. // "id": "gmail.users.drafts.send",
  3032. // "mediaUpload": {
  3033. // "accept": [
  3034. // "message/rfc822"
  3035. // ],
  3036. // "maxSize": "35MB",
  3037. // "protocols": {
  3038. // "resumable": {
  3039. // "multipart": true,
  3040. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/send"
  3041. // },
  3042. // "simple": {
  3043. // "multipart": true,
  3044. // "path": "/upload/gmail/v1/users/{userId}/drafts/send"
  3045. // }
  3046. // }
  3047. // },
  3048. // "parameterOrder": [
  3049. // "userId"
  3050. // ],
  3051. // "parameters": {
  3052. // "userId": {
  3053. // "default": "me",
  3054. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3055. // "location": "path",
  3056. // "required": true,
  3057. // "type": "string"
  3058. // }
  3059. // },
  3060. // "path": "{userId}/drafts/send",
  3061. // "request": {
  3062. // "$ref": "Draft"
  3063. // },
  3064. // "response": {
  3065. // "$ref": "Message"
  3066. // },
  3067. // "scopes": [
  3068. // "https://mail.google.com/",
  3069. // "https://www.googleapis.com/auth/gmail.compose",
  3070. // "https://www.googleapis.com/auth/gmail.modify"
  3071. // ],
  3072. // "supportsMediaUpload": true
  3073. // }
  3074. }
  3075. // method id "gmail.users.drafts.update":
  3076. type UsersDraftsUpdateCall struct {
  3077. s *Service
  3078. userId string
  3079. id string
  3080. draft *Draft
  3081. urlParams_ gensupport.URLParams
  3082. mediaInfo_ *gensupport.MediaInfo
  3083. ctx_ context.Context
  3084. header_ http.Header
  3085. }
  3086. // Update: Replaces a draft's content.
  3087. func (r *UsersDraftsService) Update(userId string, id string, draft *Draft) *UsersDraftsUpdateCall {
  3088. c := &UsersDraftsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3089. c.userId = userId
  3090. c.id = id
  3091. c.draft = draft
  3092. return c
  3093. }
  3094. // Media specifies the media to upload in one or more chunks. The chunk
  3095. // size may be controlled by supplying a MediaOption generated by
  3096. // googleapi.ChunkSize. The chunk size defaults to
  3097. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  3098. // upload request will be determined by sniffing the contents of r,
  3099. // unless a MediaOption generated by googleapi.ContentType is
  3100. // supplied.
  3101. // At most one of Media and ResumableMedia may be set.
  3102. func (c *UsersDraftsUpdateCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsUpdateCall {
  3103. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  3104. return c
  3105. }
  3106. // ResumableMedia specifies the media to upload in chunks and can be
  3107. // canceled with ctx.
  3108. //
  3109. // Deprecated: use Media instead.
  3110. //
  3111. // At most one of Media and ResumableMedia may be set. mediaType
  3112. // identifies the MIME media type of the upload, such as "image/png". If
  3113. // mediaType is "", it will be auto-detected. The provided ctx will
  3114. // supersede any context previously provided to the Context method.
  3115. func (c *UsersDraftsUpdateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsUpdateCall {
  3116. c.ctx_ = ctx
  3117. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  3118. return c
  3119. }
  3120. // ProgressUpdater provides a callback function that will be called
  3121. // after every chunk. It should be a low-latency function in order to
  3122. // not slow down the upload operation. This should only be called when
  3123. // using ResumableMedia (as opposed to Media).
  3124. func (c *UsersDraftsUpdateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsUpdateCall {
  3125. c.mediaInfo_.SetProgressUpdater(pu)
  3126. return c
  3127. }
  3128. // Fields allows partial responses to be retrieved. See
  3129. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3130. // for more information.
  3131. func (c *UsersDraftsUpdateCall) Fields(s ...googleapi.Field) *UsersDraftsUpdateCall {
  3132. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3133. return c
  3134. }
  3135. // Context sets the context to be used in this call's Do method. Any
  3136. // pending HTTP request will be aborted if the provided context is
  3137. // canceled.
  3138. // This context will supersede any context previously provided to the
  3139. // ResumableMedia method.
  3140. func (c *UsersDraftsUpdateCall) Context(ctx context.Context) *UsersDraftsUpdateCall {
  3141. c.ctx_ = ctx
  3142. return c
  3143. }
  3144. // Header returns an http.Header that can be modified by the caller to
  3145. // add HTTP headers to the request.
  3146. func (c *UsersDraftsUpdateCall) Header() http.Header {
  3147. if c.header_ == nil {
  3148. c.header_ = make(http.Header)
  3149. }
  3150. return c.header_
  3151. }
  3152. func (c *UsersDraftsUpdateCall) doRequest(alt string) (*http.Response, error) {
  3153. reqHeaders := make(http.Header)
  3154. for k, v := range c.header_ {
  3155. reqHeaders[k] = v
  3156. }
  3157. reqHeaders.Set("User-Agent", c.s.userAgent())
  3158. var body io.Reader = nil
  3159. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  3160. if err != nil {
  3161. return nil, err
  3162. }
  3163. reqHeaders.Set("Content-Type", "application/json")
  3164. c.urlParams_.Set("alt", alt)
  3165. c.urlParams_.Set("prettyPrint", "false")
  3166. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  3167. if c.mediaInfo_ != nil {
  3168. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  3169. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  3170. }
  3171. if body == nil {
  3172. body = new(bytes.Buffer)
  3173. reqHeaders.Set("Content-Type", "application/json")
  3174. }
  3175. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  3176. defer cleanup()
  3177. urls += "?" + c.urlParams_.Encode()
  3178. req, err := http.NewRequest("PUT", urls, body)
  3179. if err != nil {
  3180. return nil, err
  3181. }
  3182. req.Header = reqHeaders
  3183. req.GetBody = getBody
  3184. googleapi.Expand(req.URL, map[string]string{
  3185. "userId": c.userId,
  3186. "id": c.id,
  3187. })
  3188. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3189. }
  3190. // Do executes the "gmail.users.drafts.update" call.
  3191. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  3192. // code is an error. Response headers are in either
  3193. // *Draft.ServerResponse.Header or (if a response was returned at all)
  3194. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3195. // check whether the returned error was because http.StatusNotModified
  3196. // was returned.
  3197. func (c *UsersDraftsUpdateCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  3198. gensupport.SetOptions(c.urlParams_, opts...)
  3199. res, err := c.doRequest("json")
  3200. if res != nil && res.StatusCode == http.StatusNotModified {
  3201. if res.Body != nil {
  3202. res.Body.Close()
  3203. }
  3204. return nil, &googleapi.Error{
  3205. Code: res.StatusCode,
  3206. Header: res.Header,
  3207. }
  3208. }
  3209. if err != nil {
  3210. return nil, err
  3211. }
  3212. defer googleapi.CloseBody(res)
  3213. if err := googleapi.CheckResponse(res); err != nil {
  3214. return nil, err
  3215. }
  3216. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  3217. if rx != nil {
  3218. rx.Client = c.s.client
  3219. rx.UserAgent = c.s.userAgent()
  3220. ctx := c.ctx_
  3221. if ctx == nil {
  3222. ctx = context.TODO()
  3223. }
  3224. res, err = rx.Upload(ctx)
  3225. if err != nil {
  3226. return nil, err
  3227. }
  3228. defer res.Body.Close()
  3229. if err := googleapi.CheckResponse(res); err != nil {
  3230. return nil, err
  3231. }
  3232. }
  3233. ret := &Draft{
  3234. ServerResponse: googleapi.ServerResponse{
  3235. Header: res.Header,
  3236. HTTPStatusCode: res.StatusCode,
  3237. },
  3238. }
  3239. target := &ret
  3240. if err := gensupport.DecodeResponse(target, res); err != nil {
  3241. return nil, err
  3242. }
  3243. return ret, nil
  3244. // {
  3245. // "description": "Replaces a draft's content.",
  3246. // "httpMethod": "PUT",
  3247. // "id": "gmail.users.drafts.update",
  3248. // "mediaUpload": {
  3249. // "accept": [
  3250. // "message/rfc822"
  3251. // ],
  3252. // "maxSize": "35MB",
  3253. // "protocols": {
  3254. // "resumable": {
  3255. // "multipart": true,
  3256. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/{id}"
  3257. // },
  3258. // "simple": {
  3259. // "multipart": true,
  3260. // "path": "/upload/gmail/v1/users/{userId}/drafts/{id}"
  3261. // }
  3262. // }
  3263. // },
  3264. // "parameterOrder": [
  3265. // "userId",
  3266. // "id"
  3267. // ],
  3268. // "parameters": {
  3269. // "id": {
  3270. // "description": "The ID of the draft to update.",
  3271. // "location": "path",
  3272. // "required": true,
  3273. // "type": "string"
  3274. // },
  3275. // "userId": {
  3276. // "default": "me",
  3277. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3278. // "location": "path",
  3279. // "required": true,
  3280. // "type": "string"
  3281. // }
  3282. // },
  3283. // "path": "{userId}/drafts/{id}",
  3284. // "request": {
  3285. // "$ref": "Draft"
  3286. // },
  3287. // "response": {
  3288. // "$ref": "Draft"
  3289. // },
  3290. // "scopes": [
  3291. // "https://mail.google.com/",
  3292. // "https://www.googleapis.com/auth/gmail.compose",
  3293. // "https://www.googleapis.com/auth/gmail.modify"
  3294. // ],
  3295. // "supportsMediaUpload": true
  3296. // }
  3297. }
  3298. // method id "gmail.users.history.list":
  3299. type UsersHistoryListCall struct {
  3300. s *Service
  3301. userId string
  3302. urlParams_ gensupport.URLParams
  3303. ifNoneMatch_ string
  3304. ctx_ context.Context
  3305. header_ http.Header
  3306. }
  3307. // List: Lists the history of all changes to the given mailbox. History
  3308. // results are returned in chronological order (increasing historyId).
  3309. func (r *UsersHistoryService) List(userId string) *UsersHistoryListCall {
  3310. c := &UsersHistoryListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3311. c.userId = userId
  3312. return c
  3313. }
  3314. // HistoryTypes sets the optional parameter "historyTypes": History
  3315. // types to be returned by the function
  3316. //
  3317. // Possible values:
  3318. // "labelAdded"
  3319. // "labelRemoved"
  3320. // "messageAdded"
  3321. // "messageDeleted"
  3322. func (c *UsersHistoryListCall) HistoryTypes(historyTypes ...string) *UsersHistoryListCall {
  3323. c.urlParams_.SetMulti("historyTypes", append([]string{}, historyTypes...))
  3324. return c
  3325. }
  3326. // LabelId sets the optional parameter "labelId": Only return messages
  3327. // with a label matching the ID.
  3328. func (c *UsersHistoryListCall) LabelId(labelId string) *UsersHistoryListCall {
  3329. c.urlParams_.Set("labelId", labelId)
  3330. return c
  3331. }
  3332. // MaxResults sets the optional parameter "maxResults": The maximum
  3333. // number of history records to return.
  3334. func (c *UsersHistoryListCall) MaxResults(maxResults int64) *UsersHistoryListCall {
  3335. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  3336. return c
  3337. }
  3338. // PageToken sets the optional parameter "pageToken": Page token to
  3339. // retrieve a specific page of results in the list.
  3340. func (c *UsersHistoryListCall) PageToken(pageToken string) *UsersHistoryListCall {
  3341. c.urlParams_.Set("pageToken", pageToken)
  3342. return c
  3343. }
  3344. // StartHistoryId sets the optional parameter "startHistoryId":
  3345. // Required. Returns history records after the specified startHistoryId.
  3346. // The supplied startHistoryId should be obtained from the historyId of
  3347. // a message, thread, or previous list response. History IDs increase
  3348. // chronologically but are not contiguous with random gaps in between
  3349. // valid IDs. Supplying an invalid or out of date startHistoryId
  3350. // typically returns an HTTP 404 error code. A historyId is typically
  3351. // valid for at least a week, but in some rare circumstances may be
  3352. // valid for only a few hours. If you receive an HTTP 404 error
  3353. // response, your application should perform a full sync. If you receive
  3354. // no nextPageToken in the response, there are no updates to retrieve
  3355. // and you can store the returned historyId for a future request.
  3356. func (c *UsersHistoryListCall) StartHistoryId(startHistoryId uint64) *UsersHistoryListCall {
  3357. c.urlParams_.Set("startHistoryId", fmt.Sprint(startHistoryId))
  3358. return c
  3359. }
  3360. // Fields allows partial responses to be retrieved. See
  3361. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3362. // for more information.
  3363. func (c *UsersHistoryListCall) Fields(s ...googleapi.Field) *UsersHistoryListCall {
  3364. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3365. return c
  3366. }
  3367. // IfNoneMatch sets the optional parameter which makes the operation
  3368. // fail if the object's ETag matches the given value. This is useful for
  3369. // getting updates only after the object has changed since the last
  3370. // request. Use googleapi.IsNotModified to check whether the response
  3371. // error from Do is the result of In-None-Match.
  3372. func (c *UsersHistoryListCall) IfNoneMatch(entityTag string) *UsersHistoryListCall {
  3373. c.ifNoneMatch_ = entityTag
  3374. return c
  3375. }
  3376. // Context sets the context to be used in this call's Do method. Any
  3377. // pending HTTP request will be aborted if the provided context is
  3378. // canceled.
  3379. func (c *UsersHistoryListCall) Context(ctx context.Context) *UsersHistoryListCall {
  3380. c.ctx_ = ctx
  3381. return c
  3382. }
  3383. // Header returns an http.Header that can be modified by the caller to
  3384. // add HTTP headers to the request.
  3385. func (c *UsersHistoryListCall) Header() http.Header {
  3386. if c.header_ == nil {
  3387. c.header_ = make(http.Header)
  3388. }
  3389. return c.header_
  3390. }
  3391. func (c *UsersHistoryListCall) doRequest(alt string) (*http.Response, error) {
  3392. reqHeaders := make(http.Header)
  3393. for k, v := range c.header_ {
  3394. reqHeaders[k] = v
  3395. }
  3396. reqHeaders.Set("User-Agent", c.s.userAgent())
  3397. if c.ifNoneMatch_ != "" {
  3398. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3399. }
  3400. var body io.Reader = nil
  3401. c.urlParams_.Set("alt", alt)
  3402. c.urlParams_.Set("prettyPrint", "false")
  3403. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/history")
  3404. urls += "?" + c.urlParams_.Encode()
  3405. req, err := http.NewRequest("GET", urls, body)
  3406. if err != nil {
  3407. return nil, err
  3408. }
  3409. req.Header = reqHeaders
  3410. googleapi.Expand(req.URL, map[string]string{
  3411. "userId": c.userId,
  3412. })
  3413. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3414. }
  3415. // Do executes the "gmail.users.history.list" call.
  3416. // Exactly one of *ListHistoryResponse or error will be non-nil. Any
  3417. // non-2xx status code is an error. Response headers are in either
  3418. // *ListHistoryResponse.ServerResponse.Header or (if a response was
  3419. // returned at all) in error.(*googleapi.Error).Header. Use
  3420. // googleapi.IsNotModified to check whether the returned error was
  3421. // because http.StatusNotModified was returned.
  3422. func (c *UsersHistoryListCall) Do(opts ...googleapi.CallOption) (*ListHistoryResponse, error) {
  3423. gensupport.SetOptions(c.urlParams_, opts...)
  3424. res, err := c.doRequest("json")
  3425. if res != nil && res.StatusCode == http.StatusNotModified {
  3426. if res.Body != nil {
  3427. res.Body.Close()
  3428. }
  3429. return nil, &googleapi.Error{
  3430. Code: res.StatusCode,
  3431. Header: res.Header,
  3432. }
  3433. }
  3434. if err != nil {
  3435. return nil, err
  3436. }
  3437. defer googleapi.CloseBody(res)
  3438. if err := googleapi.CheckResponse(res); err != nil {
  3439. return nil, err
  3440. }
  3441. ret := &ListHistoryResponse{
  3442. ServerResponse: googleapi.ServerResponse{
  3443. Header: res.Header,
  3444. HTTPStatusCode: res.StatusCode,
  3445. },
  3446. }
  3447. target := &ret
  3448. if err := gensupport.DecodeResponse(target, res); err != nil {
  3449. return nil, err
  3450. }
  3451. return ret, nil
  3452. // {
  3453. // "description": "Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId).",
  3454. // "httpMethod": "GET",
  3455. // "id": "gmail.users.history.list",
  3456. // "parameterOrder": [
  3457. // "userId"
  3458. // ],
  3459. // "parameters": {
  3460. // "historyTypes": {
  3461. // "description": "History types to be returned by the function",
  3462. // "enum": [
  3463. // "labelAdded",
  3464. // "labelRemoved",
  3465. // "messageAdded",
  3466. // "messageDeleted"
  3467. // ],
  3468. // "enumDescriptions": [
  3469. // "",
  3470. // "",
  3471. // "",
  3472. // ""
  3473. // ],
  3474. // "location": "query",
  3475. // "repeated": true,
  3476. // "type": "string"
  3477. // },
  3478. // "labelId": {
  3479. // "description": "Only return messages with a label matching the ID.",
  3480. // "location": "query",
  3481. // "type": "string"
  3482. // },
  3483. // "maxResults": {
  3484. // "default": "100",
  3485. // "description": "The maximum number of history records to return.",
  3486. // "format": "uint32",
  3487. // "location": "query",
  3488. // "type": "integer"
  3489. // },
  3490. // "pageToken": {
  3491. // "description": "Page token to retrieve a specific page of results in the list.",
  3492. // "location": "query",
  3493. // "type": "string"
  3494. // },
  3495. // "startHistoryId": {
  3496. // "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.",
  3497. // "format": "uint64",
  3498. // "location": "query",
  3499. // "type": "string"
  3500. // },
  3501. // "userId": {
  3502. // "default": "me",
  3503. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3504. // "location": "path",
  3505. // "required": true,
  3506. // "type": "string"
  3507. // }
  3508. // },
  3509. // "path": "{userId}/history",
  3510. // "response": {
  3511. // "$ref": "ListHistoryResponse"
  3512. // },
  3513. // "scopes": [
  3514. // "https://mail.google.com/",
  3515. // "https://www.googleapis.com/auth/gmail.metadata",
  3516. // "https://www.googleapis.com/auth/gmail.modify",
  3517. // "https://www.googleapis.com/auth/gmail.readonly"
  3518. // ]
  3519. // }
  3520. }
  3521. // Pages invokes f for each page of results.
  3522. // A non-nil error returned from f will halt the iteration.
  3523. // The provided context supersedes any context provided to the Context method.
  3524. func (c *UsersHistoryListCall) Pages(ctx context.Context, f func(*ListHistoryResponse) error) error {
  3525. c.ctx_ = ctx
  3526. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3527. for {
  3528. x, err := c.Do()
  3529. if err != nil {
  3530. return err
  3531. }
  3532. if err := f(x); err != nil {
  3533. return err
  3534. }
  3535. if x.NextPageToken == "" {
  3536. return nil
  3537. }
  3538. c.PageToken(x.NextPageToken)
  3539. }
  3540. }
  3541. // method id "gmail.users.labels.create":
  3542. type UsersLabelsCreateCall struct {
  3543. s *Service
  3544. userId string
  3545. label *Label
  3546. urlParams_ gensupport.URLParams
  3547. ctx_ context.Context
  3548. header_ http.Header
  3549. }
  3550. // Create: Creates a new label.
  3551. func (r *UsersLabelsService) Create(userId string, label *Label) *UsersLabelsCreateCall {
  3552. c := &UsersLabelsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3553. c.userId = userId
  3554. c.label = label
  3555. return c
  3556. }
  3557. // Fields allows partial responses to be retrieved. See
  3558. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3559. // for more information.
  3560. func (c *UsersLabelsCreateCall) Fields(s ...googleapi.Field) *UsersLabelsCreateCall {
  3561. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3562. return c
  3563. }
  3564. // Context sets the context to be used in this call's Do method. Any
  3565. // pending HTTP request will be aborted if the provided context is
  3566. // canceled.
  3567. func (c *UsersLabelsCreateCall) Context(ctx context.Context) *UsersLabelsCreateCall {
  3568. c.ctx_ = ctx
  3569. return c
  3570. }
  3571. // Header returns an http.Header that can be modified by the caller to
  3572. // add HTTP headers to the request.
  3573. func (c *UsersLabelsCreateCall) Header() http.Header {
  3574. if c.header_ == nil {
  3575. c.header_ = make(http.Header)
  3576. }
  3577. return c.header_
  3578. }
  3579. func (c *UsersLabelsCreateCall) doRequest(alt string) (*http.Response, error) {
  3580. reqHeaders := make(http.Header)
  3581. for k, v := range c.header_ {
  3582. reqHeaders[k] = v
  3583. }
  3584. reqHeaders.Set("User-Agent", c.s.userAgent())
  3585. var body io.Reader = nil
  3586. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  3587. if err != nil {
  3588. return nil, err
  3589. }
  3590. reqHeaders.Set("Content-Type", "application/json")
  3591. c.urlParams_.Set("alt", alt)
  3592. c.urlParams_.Set("prettyPrint", "false")
  3593. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
  3594. urls += "?" + c.urlParams_.Encode()
  3595. req, err := http.NewRequest("POST", urls, body)
  3596. if err != nil {
  3597. return nil, err
  3598. }
  3599. req.Header = reqHeaders
  3600. googleapi.Expand(req.URL, map[string]string{
  3601. "userId": c.userId,
  3602. })
  3603. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3604. }
  3605. // Do executes the "gmail.users.labels.create" call.
  3606. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  3607. // code is an error. Response headers are in either
  3608. // *Label.ServerResponse.Header or (if a response was returned at all)
  3609. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3610. // check whether the returned error was because http.StatusNotModified
  3611. // was returned.
  3612. func (c *UsersLabelsCreateCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  3613. gensupport.SetOptions(c.urlParams_, opts...)
  3614. res, err := c.doRequest("json")
  3615. if res != nil && res.StatusCode == http.StatusNotModified {
  3616. if res.Body != nil {
  3617. res.Body.Close()
  3618. }
  3619. return nil, &googleapi.Error{
  3620. Code: res.StatusCode,
  3621. Header: res.Header,
  3622. }
  3623. }
  3624. if err != nil {
  3625. return nil, err
  3626. }
  3627. defer googleapi.CloseBody(res)
  3628. if err := googleapi.CheckResponse(res); err != nil {
  3629. return nil, err
  3630. }
  3631. ret := &Label{
  3632. ServerResponse: googleapi.ServerResponse{
  3633. Header: res.Header,
  3634. HTTPStatusCode: res.StatusCode,
  3635. },
  3636. }
  3637. target := &ret
  3638. if err := gensupport.DecodeResponse(target, res); err != nil {
  3639. return nil, err
  3640. }
  3641. return ret, nil
  3642. // {
  3643. // "description": "Creates a new label.",
  3644. // "httpMethod": "POST",
  3645. // "id": "gmail.users.labels.create",
  3646. // "parameterOrder": [
  3647. // "userId"
  3648. // ],
  3649. // "parameters": {
  3650. // "userId": {
  3651. // "default": "me",
  3652. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3653. // "location": "path",
  3654. // "required": true,
  3655. // "type": "string"
  3656. // }
  3657. // },
  3658. // "path": "{userId}/labels",
  3659. // "request": {
  3660. // "$ref": "Label"
  3661. // },
  3662. // "response": {
  3663. // "$ref": "Label"
  3664. // },
  3665. // "scopes": [
  3666. // "https://mail.google.com/",
  3667. // "https://www.googleapis.com/auth/gmail.labels",
  3668. // "https://www.googleapis.com/auth/gmail.modify"
  3669. // ]
  3670. // }
  3671. }
  3672. // method id "gmail.users.labels.delete":
  3673. type UsersLabelsDeleteCall struct {
  3674. s *Service
  3675. userId string
  3676. id string
  3677. urlParams_ gensupport.URLParams
  3678. ctx_ context.Context
  3679. header_ http.Header
  3680. }
  3681. // Delete: Immediately and permanently deletes the specified label and
  3682. // removes it from any messages and threads that it is applied to.
  3683. func (r *UsersLabelsService) Delete(userId string, id string) *UsersLabelsDeleteCall {
  3684. c := &UsersLabelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3685. c.userId = userId
  3686. c.id = id
  3687. return c
  3688. }
  3689. // Fields allows partial responses to be retrieved. See
  3690. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3691. // for more information.
  3692. func (c *UsersLabelsDeleteCall) Fields(s ...googleapi.Field) *UsersLabelsDeleteCall {
  3693. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3694. return c
  3695. }
  3696. // Context sets the context to be used in this call's Do method. Any
  3697. // pending HTTP request will be aborted if the provided context is
  3698. // canceled.
  3699. func (c *UsersLabelsDeleteCall) Context(ctx context.Context) *UsersLabelsDeleteCall {
  3700. c.ctx_ = ctx
  3701. return c
  3702. }
  3703. // Header returns an http.Header that can be modified by the caller to
  3704. // add HTTP headers to the request.
  3705. func (c *UsersLabelsDeleteCall) Header() http.Header {
  3706. if c.header_ == nil {
  3707. c.header_ = make(http.Header)
  3708. }
  3709. return c.header_
  3710. }
  3711. func (c *UsersLabelsDeleteCall) doRequest(alt string) (*http.Response, error) {
  3712. reqHeaders := make(http.Header)
  3713. for k, v := range c.header_ {
  3714. reqHeaders[k] = v
  3715. }
  3716. reqHeaders.Set("User-Agent", c.s.userAgent())
  3717. var body io.Reader = nil
  3718. c.urlParams_.Set("alt", alt)
  3719. c.urlParams_.Set("prettyPrint", "false")
  3720. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  3721. urls += "?" + c.urlParams_.Encode()
  3722. req, err := http.NewRequest("DELETE", urls, body)
  3723. if err != nil {
  3724. return nil, err
  3725. }
  3726. req.Header = reqHeaders
  3727. googleapi.Expand(req.URL, map[string]string{
  3728. "userId": c.userId,
  3729. "id": c.id,
  3730. })
  3731. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3732. }
  3733. // Do executes the "gmail.users.labels.delete" call.
  3734. func (c *UsersLabelsDeleteCall) Do(opts ...googleapi.CallOption) error {
  3735. gensupport.SetOptions(c.urlParams_, opts...)
  3736. res, err := c.doRequest("json")
  3737. if err != nil {
  3738. return err
  3739. }
  3740. defer googleapi.CloseBody(res)
  3741. if err := googleapi.CheckResponse(res); err != nil {
  3742. return err
  3743. }
  3744. return nil
  3745. // {
  3746. // "description": "Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.",
  3747. // "httpMethod": "DELETE",
  3748. // "id": "gmail.users.labels.delete",
  3749. // "parameterOrder": [
  3750. // "userId",
  3751. // "id"
  3752. // ],
  3753. // "parameters": {
  3754. // "id": {
  3755. // "description": "The ID of the label to delete.",
  3756. // "location": "path",
  3757. // "required": true,
  3758. // "type": "string"
  3759. // },
  3760. // "userId": {
  3761. // "default": "me",
  3762. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3763. // "location": "path",
  3764. // "required": true,
  3765. // "type": "string"
  3766. // }
  3767. // },
  3768. // "path": "{userId}/labels/{id}",
  3769. // "scopes": [
  3770. // "https://mail.google.com/",
  3771. // "https://www.googleapis.com/auth/gmail.labels",
  3772. // "https://www.googleapis.com/auth/gmail.modify"
  3773. // ]
  3774. // }
  3775. }
  3776. // method id "gmail.users.labels.get":
  3777. type UsersLabelsGetCall struct {
  3778. s *Service
  3779. userId string
  3780. id string
  3781. urlParams_ gensupport.URLParams
  3782. ifNoneMatch_ string
  3783. ctx_ context.Context
  3784. header_ http.Header
  3785. }
  3786. // Get: Gets the specified label.
  3787. func (r *UsersLabelsService) Get(userId string, id string) *UsersLabelsGetCall {
  3788. c := &UsersLabelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3789. c.userId = userId
  3790. c.id = id
  3791. return c
  3792. }
  3793. // Fields allows partial responses to be retrieved. See
  3794. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3795. // for more information.
  3796. func (c *UsersLabelsGetCall) Fields(s ...googleapi.Field) *UsersLabelsGetCall {
  3797. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3798. return c
  3799. }
  3800. // IfNoneMatch sets the optional parameter which makes the operation
  3801. // fail if the object's ETag matches the given value. This is useful for
  3802. // getting updates only after the object has changed since the last
  3803. // request. Use googleapi.IsNotModified to check whether the response
  3804. // error from Do is the result of In-None-Match.
  3805. func (c *UsersLabelsGetCall) IfNoneMatch(entityTag string) *UsersLabelsGetCall {
  3806. c.ifNoneMatch_ = entityTag
  3807. return c
  3808. }
  3809. // Context sets the context to be used in this call's Do method. Any
  3810. // pending HTTP request will be aborted if the provided context is
  3811. // canceled.
  3812. func (c *UsersLabelsGetCall) Context(ctx context.Context) *UsersLabelsGetCall {
  3813. c.ctx_ = ctx
  3814. return c
  3815. }
  3816. // Header returns an http.Header that can be modified by the caller to
  3817. // add HTTP headers to the request.
  3818. func (c *UsersLabelsGetCall) Header() http.Header {
  3819. if c.header_ == nil {
  3820. c.header_ = make(http.Header)
  3821. }
  3822. return c.header_
  3823. }
  3824. func (c *UsersLabelsGetCall) doRequest(alt string) (*http.Response, error) {
  3825. reqHeaders := make(http.Header)
  3826. for k, v := range c.header_ {
  3827. reqHeaders[k] = v
  3828. }
  3829. reqHeaders.Set("User-Agent", c.s.userAgent())
  3830. if c.ifNoneMatch_ != "" {
  3831. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3832. }
  3833. var body io.Reader = nil
  3834. c.urlParams_.Set("alt", alt)
  3835. c.urlParams_.Set("prettyPrint", "false")
  3836. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  3837. urls += "?" + c.urlParams_.Encode()
  3838. req, err := http.NewRequest("GET", urls, body)
  3839. if err != nil {
  3840. return nil, err
  3841. }
  3842. req.Header = reqHeaders
  3843. googleapi.Expand(req.URL, map[string]string{
  3844. "userId": c.userId,
  3845. "id": c.id,
  3846. })
  3847. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3848. }
  3849. // Do executes the "gmail.users.labels.get" call.
  3850. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  3851. // code is an error. Response headers are in either
  3852. // *Label.ServerResponse.Header or (if a response was returned at all)
  3853. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3854. // check whether the returned error was because http.StatusNotModified
  3855. // was returned.
  3856. func (c *UsersLabelsGetCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  3857. gensupport.SetOptions(c.urlParams_, opts...)
  3858. res, err := c.doRequest("json")
  3859. if res != nil && res.StatusCode == http.StatusNotModified {
  3860. if res.Body != nil {
  3861. res.Body.Close()
  3862. }
  3863. return nil, &googleapi.Error{
  3864. Code: res.StatusCode,
  3865. Header: res.Header,
  3866. }
  3867. }
  3868. if err != nil {
  3869. return nil, err
  3870. }
  3871. defer googleapi.CloseBody(res)
  3872. if err := googleapi.CheckResponse(res); err != nil {
  3873. return nil, err
  3874. }
  3875. ret := &Label{
  3876. ServerResponse: googleapi.ServerResponse{
  3877. Header: res.Header,
  3878. HTTPStatusCode: res.StatusCode,
  3879. },
  3880. }
  3881. target := &ret
  3882. if err := gensupport.DecodeResponse(target, res); err != nil {
  3883. return nil, err
  3884. }
  3885. return ret, nil
  3886. // {
  3887. // "description": "Gets the specified label.",
  3888. // "httpMethod": "GET",
  3889. // "id": "gmail.users.labels.get",
  3890. // "parameterOrder": [
  3891. // "userId",
  3892. // "id"
  3893. // ],
  3894. // "parameters": {
  3895. // "id": {
  3896. // "description": "The ID of the label to retrieve.",
  3897. // "location": "path",
  3898. // "required": true,
  3899. // "type": "string"
  3900. // },
  3901. // "userId": {
  3902. // "default": "me",
  3903. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3904. // "location": "path",
  3905. // "required": true,
  3906. // "type": "string"
  3907. // }
  3908. // },
  3909. // "path": "{userId}/labels/{id}",
  3910. // "response": {
  3911. // "$ref": "Label"
  3912. // },
  3913. // "scopes": [
  3914. // "https://mail.google.com/",
  3915. // "https://www.googleapis.com/auth/gmail.labels",
  3916. // "https://www.googleapis.com/auth/gmail.metadata",
  3917. // "https://www.googleapis.com/auth/gmail.modify",
  3918. // "https://www.googleapis.com/auth/gmail.readonly"
  3919. // ]
  3920. // }
  3921. }
  3922. // method id "gmail.users.labels.list":
  3923. type UsersLabelsListCall struct {
  3924. s *Service
  3925. userId string
  3926. urlParams_ gensupport.URLParams
  3927. ifNoneMatch_ string
  3928. ctx_ context.Context
  3929. header_ http.Header
  3930. }
  3931. // List: Lists all labels in the user's mailbox.
  3932. func (r *UsersLabelsService) List(userId string) *UsersLabelsListCall {
  3933. c := &UsersLabelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3934. c.userId = userId
  3935. return c
  3936. }
  3937. // Fields allows partial responses to be retrieved. See
  3938. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3939. // for more information.
  3940. func (c *UsersLabelsListCall) Fields(s ...googleapi.Field) *UsersLabelsListCall {
  3941. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3942. return c
  3943. }
  3944. // IfNoneMatch sets the optional parameter which makes the operation
  3945. // fail if the object's ETag matches the given value. This is useful for
  3946. // getting updates only after the object has changed since the last
  3947. // request. Use googleapi.IsNotModified to check whether the response
  3948. // error from Do is the result of In-None-Match.
  3949. func (c *UsersLabelsListCall) IfNoneMatch(entityTag string) *UsersLabelsListCall {
  3950. c.ifNoneMatch_ = entityTag
  3951. return c
  3952. }
  3953. // Context sets the context to be used in this call's Do method. Any
  3954. // pending HTTP request will be aborted if the provided context is
  3955. // canceled.
  3956. func (c *UsersLabelsListCall) Context(ctx context.Context) *UsersLabelsListCall {
  3957. c.ctx_ = ctx
  3958. return c
  3959. }
  3960. // Header returns an http.Header that can be modified by the caller to
  3961. // add HTTP headers to the request.
  3962. func (c *UsersLabelsListCall) Header() http.Header {
  3963. if c.header_ == nil {
  3964. c.header_ = make(http.Header)
  3965. }
  3966. return c.header_
  3967. }
  3968. func (c *UsersLabelsListCall) doRequest(alt string) (*http.Response, error) {
  3969. reqHeaders := make(http.Header)
  3970. for k, v := range c.header_ {
  3971. reqHeaders[k] = v
  3972. }
  3973. reqHeaders.Set("User-Agent", c.s.userAgent())
  3974. if c.ifNoneMatch_ != "" {
  3975. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3976. }
  3977. var body io.Reader = nil
  3978. c.urlParams_.Set("alt", alt)
  3979. c.urlParams_.Set("prettyPrint", "false")
  3980. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
  3981. urls += "?" + c.urlParams_.Encode()
  3982. req, err := http.NewRequest("GET", urls, body)
  3983. if err != nil {
  3984. return nil, err
  3985. }
  3986. req.Header = reqHeaders
  3987. googleapi.Expand(req.URL, map[string]string{
  3988. "userId": c.userId,
  3989. })
  3990. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3991. }
  3992. // Do executes the "gmail.users.labels.list" call.
  3993. // Exactly one of *ListLabelsResponse or error will be non-nil. Any
  3994. // non-2xx status code is an error. Response headers are in either
  3995. // *ListLabelsResponse.ServerResponse.Header or (if a response was
  3996. // returned at all) in error.(*googleapi.Error).Header. Use
  3997. // googleapi.IsNotModified to check whether the returned error was
  3998. // because http.StatusNotModified was returned.
  3999. func (c *UsersLabelsListCall) Do(opts ...googleapi.CallOption) (*ListLabelsResponse, error) {
  4000. gensupport.SetOptions(c.urlParams_, opts...)
  4001. res, err := c.doRequest("json")
  4002. if res != nil && res.StatusCode == http.StatusNotModified {
  4003. if res.Body != nil {
  4004. res.Body.Close()
  4005. }
  4006. return nil, &googleapi.Error{
  4007. Code: res.StatusCode,
  4008. Header: res.Header,
  4009. }
  4010. }
  4011. if err != nil {
  4012. return nil, err
  4013. }
  4014. defer googleapi.CloseBody(res)
  4015. if err := googleapi.CheckResponse(res); err != nil {
  4016. return nil, err
  4017. }
  4018. ret := &ListLabelsResponse{
  4019. ServerResponse: googleapi.ServerResponse{
  4020. Header: res.Header,
  4021. HTTPStatusCode: res.StatusCode,
  4022. },
  4023. }
  4024. target := &ret
  4025. if err := gensupport.DecodeResponse(target, res); err != nil {
  4026. return nil, err
  4027. }
  4028. return ret, nil
  4029. // {
  4030. // "description": "Lists all labels in the user's mailbox.",
  4031. // "httpMethod": "GET",
  4032. // "id": "gmail.users.labels.list",
  4033. // "parameterOrder": [
  4034. // "userId"
  4035. // ],
  4036. // "parameters": {
  4037. // "userId": {
  4038. // "default": "me",
  4039. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4040. // "location": "path",
  4041. // "required": true,
  4042. // "type": "string"
  4043. // }
  4044. // },
  4045. // "path": "{userId}/labels",
  4046. // "response": {
  4047. // "$ref": "ListLabelsResponse"
  4048. // },
  4049. // "scopes": [
  4050. // "https://mail.google.com/",
  4051. // "https://www.googleapis.com/auth/gmail.labels",
  4052. // "https://www.googleapis.com/auth/gmail.metadata",
  4053. // "https://www.googleapis.com/auth/gmail.modify",
  4054. // "https://www.googleapis.com/auth/gmail.readonly"
  4055. // ]
  4056. // }
  4057. }
  4058. // method id "gmail.users.labels.patch":
  4059. type UsersLabelsPatchCall struct {
  4060. s *Service
  4061. userId string
  4062. id string
  4063. label *Label
  4064. urlParams_ gensupport.URLParams
  4065. ctx_ context.Context
  4066. header_ http.Header
  4067. }
  4068. // Patch: Updates the specified label. This method supports patch
  4069. // semantics.
  4070. func (r *UsersLabelsService) Patch(userId string, id string, label *Label) *UsersLabelsPatchCall {
  4071. c := &UsersLabelsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4072. c.userId = userId
  4073. c.id = id
  4074. c.label = label
  4075. return c
  4076. }
  4077. // Fields allows partial responses to be retrieved. See
  4078. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4079. // for more information.
  4080. func (c *UsersLabelsPatchCall) Fields(s ...googleapi.Field) *UsersLabelsPatchCall {
  4081. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4082. return c
  4083. }
  4084. // Context sets the context to be used in this call's Do method. Any
  4085. // pending HTTP request will be aborted if the provided context is
  4086. // canceled.
  4087. func (c *UsersLabelsPatchCall) Context(ctx context.Context) *UsersLabelsPatchCall {
  4088. c.ctx_ = ctx
  4089. return c
  4090. }
  4091. // Header returns an http.Header that can be modified by the caller to
  4092. // add HTTP headers to the request.
  4093. func (c *UsersLabelsPatchCall) Header() http.Header {
  4094. if c.header_ == nil {
  4095. c.header_ = make(http.Header)
  4096. }
  4097. return c.header_
  4098. }
  4099. func (c *UsersLabelsPatchCall) doRequest(alt string) (*http.Response, error) {
  4100. reqHeaders := make(http.Header)
  4101. for k, v := range c.header_ {
  4102. reqHeaders[k] = v
  4103. }
  4104. reqHeaders.Set("User-Agent", c.s.userAgent())
  4105. var body io.Reader = nil
  4106. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  4107. if err != nil {
  4108. return nil, err
  4109. }
  4110. reqHeaders.Set("Content-Type", "application/json")
  4111. c.urlParams_.Set("alt", alt)
  4112. c.urlParams_.Set("prettyPrint", "false")
  4113. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  4114. urls += "?" + c.urlParams_.Encode()
  4115. req, err := http.NewRequest("PATCH", urls, body)
  4116. if err != nil {
  4117. return nil, err
  4118. }
  4119. req.Header = reqHeaders
  4120. googleapi.Expand(req.URL, map[string]string{
  4121. "userId": c.userId,
  4122. "id": c.id,
  4123. })
  4124. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4125. }
  4126. // Do executes the "gmail.users.labels.patch" call.
  4127. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  4128. // code is an error. Response headers are in either
  4129. // *Label.ServerResponse.Header or (if a response was returned at all)
  4130. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4131. // check whether the returned error was because http.StatusNotModified
  4132. // was returned.
  4133. func (c *UsersLabelsPatchCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  4134. gensupport.SetOptions(c.urlParams_, opts...)
  4135. res, err := c.doRequest("json")
  4136. if res != nil && res.StatusCode == http.StatusNotModified {
  4137. if res.Body != nil {
  4138. res.Body.Close()
  4139. }
  4140. return nil, &googleapi.Error{
  4141. Code: res.StatusCode,
  4142. Header: res.Header,
  4143. }
  4144. }
  4145. if err != nil {
  4146. return nil, err
  4147. }
  4148. defer googleapi.CloseBody(res)
  4149. if err := googleapi.CheckResponse(res); err != nil {
  4150. return nil, err
  4151. }
  4152. ret := &Label{
  4153. ServerResponse: googleapi.ServerResponse{
  4154. Header: res.Header,
  4155. HTTPStatusCode: res.StatusCode,
  4156. },
  4157. }
  4158. target := &ret
  4159. if err := gensupport.DecodeResponse(target, res); err != nil {
  4160. return nil, err
  4161. }
  4162. return ret, nil
  4163. // {
  4164. // "description": "Updates the specified label. This method supports patch semantics.",
  4165. // "httpMethod": "PATCH",
  4166. // "id": "gmail.users.labels.patch",
  4167. // "parameterOrder": [
  4168. // "userId",
  4169. // "id"
  4170. // ],
  4171. // "parameters": {
  4172. // "id": {
  4173. // "description": "The ID of the label to update.",
  4174. // "location": "path",
  4175. // "required": true,
  4176. // "type": "string"
  4177. // },
  4178. // "userId": {
  4179. // "default": "me",
  4180. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4181. // "location": "path",
  4182. // "required": true,
  4183. // "type": "string"
  4184. // }
  4185. // },
  4186. // "path": "{userId}/labels/{id}",
  4187. // "request": {
  4188. // "$ref": "Label"
  4189. // },
  4190. // "response": {
  4191. // "$ref": "Label"
  4192. // },
  4193. // "scopes": [
  4194. // "https://mail.google.com/",
  4195. // "https://www.googleapis.com/auth/gmail.labels",
  4196. // "https://www.googleapis.com/auth/gmail.modify"
  4197. // ]
  4198. // }
  4199. }
  4200. // method id "gmail.users.labels.update":
  4201. type UsersLabelsUpdateCall struct {
  4202. s *Service
  4203. userId string
  4204. id string
  4205. label *Label
  4206. urlParams_ gensupport.URLParams
  4207. ctx_ context.Context
  4208. header_ http.Header
  4209. }
  4210. // Update: Updates the specified label.
  4211. func (r *UsersLabelsService) Update(userId string, id string, label *Label) *UsersLabelsUpdateCall {
  4212. c := &UsersLabelsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4213. c.userId = userId
  4214. c.id = id
  4215. c.label = label
  4216. return c
  4217. }
  4218. // Fields allows partial responses to be retrieved. See
  4219. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4220. // for more information.
  4221. func (c *UsersLabelsUpdateCall) Fields(s ...googleapi.Field) *UsersLabelsUpdateCall {
  4222. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4223. return c
  4224. }
  4225. // Context sets the context to be used in this call's Do method. Any
  4226. // pending HTTP request will be aborted if the provided context is
  4227. // canceled.
  4228. func (c *UsersLabelsUpdateCall) Context(ctx context.Context) *UsersLabelsUpdateCall {
  4229. c.ctx_ = ctx
  4230. return c
  4231. }
  4232. // Header returns an http.Header that can be modified by the caller to
  4233. // add HTTP headers to the request.
  4234. func (c *UsersLabelsUpdateCall) Header() http.Header {
  4235. if c.header_ == nil {
  4236. c.header_ = make(http.Header)
  4237. }
  4238. return c.header_
  4239. }
  4240. func (c *UsersLabelsUpdateCall) doRequest(alt string) (*http.Response, error) {
  4241. reqHeaders := make(http.Header)
  4242. for k, v := range c.header_ {
  4243. reqHeaders[k] = v
  4244. }
  4245. reqHeaders.Set("User-Agent", c.s.userAgent())
  4246. var body io.Reader = nil
  4247. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  4248. if err != nil {
  4249. return nil, err
  4250. }
  4251. reqHeaders.Set("Content-Type", "application/json")
  4252. c.urlParams_.Set("alt", alt)
  4253. c.urlParams_.Set("prettyPrint", "false")
  4254. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  4255. urls += "?" + c.urlParams_.Encode()
  4256. req, err := http.NewRequest("PUT", urls, body)
  4257. if err != nil {
  4258. return nil, err
  4259. }
  4260. req.Header = reqHeaders
  4261. googleapi.Expand(req.URL, map[string]string{
  4262. "userId": c.userId,
  4263. "id": c.id,
  4264. })
  4265. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4266. }
  4267. // Do executes the "gmail.users.labels.update" call.
  4268. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  4269. // code is an error. Response headers are in either
  4270. // *Label.ServerResponse.Header or (if a response was returned at all)
  4271. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4272. // check whether the returned error was because http.StatusNotModified
  4273. // was returned.
  4274. func (c *UsersLabelsUpdateCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  4275. gensupport.SetOptions(c.urlParams_, opts...)
  4276. res, err := c.doRequest("json")
  4277. if res != nil && res.StatusCode == http.StatusNotModified {
  4278. if res.Body != nil {
  4279. res.Body.Close()
  4280. }
  4281. return nil, &googleapi.Error{
  4282. Code: res.StatusCode,
  4283. Header: res.Header,
  4284. }
  4285. }
  4286. if err != nil {
  4287. return nil, err
  4288. }
  4289. defer googleapi.CloseBody(res)
  4290. if err := googleapi.CheckResponse(res); err != nil {
  4291. return nil, err
  4292. }
  4293. ret := &Label{
  4294. ServerResponse: googleapi.ServerResponse{
  4295. Header: res.Header,
  4296. HTTPStatusCode: res.StatusCode,
  4297. },
  4298. }
  4299. target := &ret
  4300. if err := gensupport.DecodeResponse(target, res); err != nil {
  4301. return nil, err
  4302. }
  4303. return ret, nil
  4304. // {
  4305. // "description": "Updates the specified label.",
  4306. // "httpMethod": "PUT",
  4307. // "id": "gmail.users.labels.update",
  4308. // "parameterOrder": [
  4309. // "userId",
  4310. // "id"
  4311. // ],
  4312. // "parameters": {
  4313. // "id": {
  4314. // "description": "The ID of the label to update.",
  4315. // "location": "path",
  4316. // "required": true,
  4317. // "type": "string"
  4318. // },
  4319. // "userId": {
  4320. // "default": "me",
  4321. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4322. // "location": "path",
  4323. // "required": true,
  4324. // "type": "string"
  4325. // }
  4326. // },
  4327. // "path": "{userId}/labels/{id}",
  4328. // "request": {
  4329. // "$ref": "Label"
  4330. // },
  4331. // "response": {
  4332. // "$ref": "Label"
  4333. // },
  4334. // "scopes": [
  4335. // "https://mail.google.com/",
  4336. // "https://www.googleapis.com/auth/gmail.labels",
  4337. // "https://www.googleapis.com/auth/gmail.modify"
  4338. // ]
  4339. // }
  4340. }
  4341. // method id "gmail.users.messages.batchDelete":
  4342. type UsersMessagesBatchDeleteCall struct {
  4343. s *Service
  4344. userId string
  4345. batchdeletemessagesrequest *BatchDeleteMessagesRequest
  4346. urlParams_ gensupport.URLParams
  4347. ctx_ context.Context
  4348. header_ http.Header
  4349. }
  4350. // BatchDelete: Deletes many messages by message ID. Provides no
  4351. // guarantees that messages were not already deleted or even existed at
  4352. // all.
  4353. func (r *UsersMessagesService) BatchDelete(userId string, batchdeletemessagesrequest *BatchDeleteMessagesRequest) *UsersMessagesBatchDeleteCall {
  4354. c := &UsersMessagesBatchDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4355. c.userId = userId
  4356. c.batchdeletemessagesrequest = batchdeletemessagesrequest
  4357. return c
  4358. }
  4359. // Fields allows partial responses to be retrieved. See
  4360. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4361. // for more information.
  4362. func (c *UsersMessagesBatchDeleteCall) Fields(s ...googleapi.Field) *UsersMessagesBatchDeleteCall {
  4363. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4364. return c
  4365. }
  4366. // Context sets the context to be used in this call's Do method. Any
  4367. // pending HTTP request will be aborted if the provided context is
  4368. // canceled.
  4369. func (c *UsersMessagesBatchDeleteCall) Context(ctx context.Context) *UsersMessagesBatchDeleteCall {
  4370. c.ctx_ = ctx
  4371. return c
  4372. }
  4373. // Header returns an http.Header that can be modified by the caller to
  4374. // add HTTP headers to the request.
  4375. func (c *UsersMessagesBatchDeleteCall) Header() http.Header {
  4376. if c.header_ == nil {
  4377. c.header_ = make(http.Header)
  4378. }
  4379. return c.header_
  4380. }
  4381. func (c *UsersMessagesBatchDeleteCall) doRequest(alt string) (*http.Response, error) {
  4382. reqHeaders := make(http.Header)
  4383. for k, v := range c.header_ {
  4384. reqHeaders[k] = v
  4385. }
  4386. reqHeaders.Set("User-Agent", c.s.userAgent())
  4387. var body io.Reader = nil
  4388. body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchdeletemessagesrequest)
  4389. if err != nil {
  4390. return nil, err
  4391. }
  4392. reqHeaders.Set("Content-Type", "application/json")
  4393. c.urlParams_.Set("alt", alt)
  4394. c.urlParams_.Set("prettyPrint", "false")
  4395. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/batchDelete")
  4396. urls += "?" + c.urlParams_.Encode()
  4397. req, err := http.NewRequest("POST", urls, body)
  4398. if err != nil {
  4399. return nil, err
  4400. }
  4401. req.Header = reqHeaders
  4402. googleapi.Expand(req.URL, map[string]string{
  4403. "userId": c.userId,
  4404. })
  4405. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4406. }
  4407. // Do executes the "gmail.users.messages.batchDelete" call.
  4408. func (c *UsersMessagesBatchDeleteCall) Do(opts ...googleapi.CallOption) error {
  4409. gensupport.SetOptions(c.urlParams_, opts...)
  4410. res, err := c.doRequest("json")
  4411. if err != nil {
  4412. return err
  4413. }
  4414. defer googleapi.CloseBody(res)
  4415. if err := googleapi.CheckResponse(res); err != nil {
  4416. return err
  4417. }
  4418. return nil
  4419. // {
  4420. // "description": "Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.",
  4421. // "httpMethod": "POST",
  4422. // "id": "gmail.users.messages.batchDelete",
  4423. // "parameterOrder": [
  4424. // "userId"
  4425. // ],
  4426. // "parameters": {
  4427. // "userId": {
  4428. // "default": "me",
  4429. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4430. // "location": "path",
  4431. // "required": true,
  4432. // "type": "string"
  4433. // }
  4434. // },
  4435. // "path": "{userId}/messages/batchDelete",
  4436. // "request": {
  4437. // "$ref": "BatchDeleteMessagesRequest"
  4438. // },
  4439. // "scopes": [
  4440. // "https://mail.google.com/"
  4441. // ]
  4442. // }
  4443. }
  4444. // method id "gmail.users.messages.batchModify":
  4445. type UsersMessagesBatchModifyCall struct {
  4446. s *Service
  4447. userId string
  4448. batchmodifymessagesrequest *BatchModifyMessagesRequest
  4449. urlParams_ gensupport.URLParams
  4450. ctx_ context.Context
  4451. header_ http.Header
  4452. }
  4453. // BatchModify: Modifies the labels on the specified messages.
  4454. func (r *UsersMessagesService) BatchModify(userId string, batchmodifymessagesrequest *BatchModifyMessagesRequest) *UsersMessagesBatchModifyCall {
  4455. c := &UsersMessagesBatchModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4456. c.userId = userId
  4457. c.batchmodifymessagesrequest = batchmodifymessagesrequest
  4458. return c
  4459. }
  4460. // Fields allows partial responses to be retrieved. See
  4461. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4462. // for more information.
  4463. func (c *UsersMessagesBatchModifyCall) Fields(s ...googleapi.Field) *UsersMessagesBatchModifyCall {
  4464. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4465. return c
  4466. }
  4467. // Context sets the context to be used in this call's Do method. Any
  4468. // pending HTTP request will be aborted if the provided context is
  4469. // canceled.
  4470. func (c *UsersMessagesBatchModifyCall) Context(ctx context.Context) *UsersMessagesBatchModifyCall {
  4471. c.ctx_ = ctx
  4472. return c
  4473. }
  4474. // Header returns an http.Header that can be modified by the caller to
  4475. // add HTTP headers to the request.
  4476. func (c *UsersMessagesBatchModifyCall) Header() http.Header {
  4477. if c.header_ == nil {
  4478. c.header_ = make(http.Header)
  4479. }
  4480. return c.header_
  4481. }
  4482. func (c *UsersMessagesBatchModifyCall) doRequest(alt string) (*http.Response, error) {
  4483. reqHeaders := make(http.Header)
  4484. for k, v := range c.header_ {
  4485. reqHeaders[k] = v
  4486. }
  4487. reqHeaders.Set("User-Agent", c.s.userAgent())
  4488. var body io.Reader = nil
  4489. body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchmodifymessagesrequest)
  4490. if err != nil {
  4491. return nil, err
  4492. }
  4493. reqHeaders.Set("Content-Type", "application/json")
  4494. c.urlParams_.Set("alt", alt)
  4495. c.urlParams_.Set("prettyPrint", "false")
  4496. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/batchModify")
  4497. urls += "?" + c.urlParams_.Encode()
  4498. req, err := http.NewRequest("POST", urls, body)
  4499. if err != nil {
  4500. return nil, err
  4501. }
  4502. req.Header = reqHeaders
  4503. googleapi.Expand(req.URL, map[string]string{
  4504. "userId": c.userId,
  4505. })
  4506. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4507. }
  4508. // Do executes the "gmail.users.messages.batchModify" call.
  4509. func (c *UsersMessagesBatchModifyCall) Do(opts ...googleapi.CallOption) error {
  4510. gensupport.SetOptions(c.urlParams_, opts...)
  4511. res, err := c.doRequest("json")
  4512. if err != nil {
  4513. return err
  4514. }
  4515. defer googleapi.CloseBody(res)
  4516. if err := googleapi.CheckResponse(res); err != nil {
  4517. return err
  4518. }
  4519. return nil
  4520. // {
  4521. // "description": "Modifies the labels on the specified messages.",
  4522. // "httpMethod": "POST",
  4523. // "id": "gmail.users.messages.batchModify",
  4524. // "parameterOrder": [
  4525. // "userId"
  4526. // ],
  4527. // "parameters": {
  4528. // "userId": {
  4529. // "default": "me",
  4530. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4531. // "location": "path",
  4532. // "required": true,
  4533. // "type": "string"
  4534. // }
  4535. // },
  4536. // "path": "{userId}/messages/batchModify",
  4537. // "request": {
  4538. // "$ref": "BatchModifyMessagesRequest"
  4539. // },
  4540. // "scopes": [
  4541. // "https://mail.google.com/",
  4542. // "https://www.googleapis.com/auth/gmail.modify"
  4543. // ]
  4544. // }
  4545. }
  4546. // method id "gmail.users.messages.delete":
  4547. type UsersMessagesDeleteCall struct {
  4548. s *Service
  4549. userId string
  4550. id string
  4551. urlParams_ gensupport.URLParams
  4552. ctx_ context.Context
  4553. header_ http.Header
  4554. }
  4555. // Delete: Immediately and permanently deletes the specified message.
  4556. // This operation cannot be undone. Prefer messages.trash instead.
  4557. func (r *UsersMessagesService) Delete(userId string, id string) *UsersMessagesDeleteCall {
  4558. c := &UsersMessagesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4559. c.userId = userId
  4560. c.id = id
  4561. return c
  4562. }
  4563. // Fields allows partial responses to be retrieved. See
  4564. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4565. // for more information.
  4566. func (c *UsersMessagesDeleteCall) Fields(s ...googleapi.Field) *UsersMessagesDeleteCall {
  4567. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4568. return c
  4569. }
  4570. // Context sets the context to be used in this call's Do method. Any
  4571. // pending HTTP request will be aborted if the provided context is
  4572. // canceled.
  4573. func (c *UsersMessagesDeleteCall) Context(ctx context.Context) *UsersMessagesDeleteCall {
  4574. c.ctx_ = ctx
  4575. return c
  4576. }
  4577. // Header returns an http.Header that can be modified by the caller to
  4578. // add HTTP headers to the request.
  4579. func (c *UsersMessagesDeleteCall) Header() http.Header {
  4580. if c.header_ == nil {
  4581. c.header_ = make(http.Header)
  4582. }
  4583. return c.header_
  4584. }
  4585. func (c *UsersMessagesDeleteCall) doRequest(alt string) (*http.Response, error) {
  4586. reqHeaders := make(http.Header)
  4587. for k, v := range c.header_ {
  4588. reqHeaders[k] = v
  4589. }
  4590. reqHeaders.Set("User-Agent", c.s.userAgent())
  4591. var body io.Reader = nil
  4592. c.urlParams_.Set("alt", alt)
  4593. c.urlParams_.Set("prettyPrint", "false")
  4594. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
  4595. urls += "?" + c.urlParams_.Encode()
  4596. req, err := http.NewRequest("DELETE", urls, body)
  4597. if err != nil {
  4598. return nil, err
  4599. }
  4600. req.Header = reqHeaders
  4601. googleapi.Expand(req.URL, map[string]string{
  4602. "userId": c.userId,
  4603. "id": c.id,
  4604. })
  4605. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4606. }
  4607. // Do executes the "gmail.users.messages.delete" call.
  4608. func (c *UsersMessagesDeleteCall) Do(opts ...googleapi.CallOption) error {
  4609. gensupport.SetOptions(c.urlParams_, opts...)
  4610. res, err := c.doRequest("json")
  4611. if err != nil {
  4612. return err
  4613. }
  4614. defer googleapi.CloseBody(res)
  4615. if err := googleapi.CheckResponse(res); err != nil {
  4616. return err
  4617. }
  4618. return nil
  4619. // {
  4620. // "description": "Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer messages.trash instead.",
  4621. // "httpMethod": "DELETE",
  4622. // "id": "gmail.users.messages.delete",
  4623. // "parameterOrder": [
  4624. // "userId",
  4625. // "id"
  4626. // ],
  4627. // "parameters": {
  4628. // "id": {
  4629. // "description": "The ID of the message to delete.",
  4630. // "location": "path",
  4631. // "required": true,
  4632. // "type": "string"
  4633. // },
  4634. // "userId": {
  4635. // "default": "me",
  4636. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4637. // "location": "path",
  4638. // "required": true,
  4639. // "type": "string"
  4640. // }
  4641. // },
  4642. // "path": "{userId}/messages/{id}",
  4643. // "scopes": [
  4644. // "https://mail.google.com/"
  4645. // ]
  4646. // }
  4647. }
  4648. // method id "gmail.users.messages.get":
  4649. type UsersMessagesGetCall struct {
  4650. s *Service
  4651. userId string
  4652. id string
  4653. urlParams_ gensupport.URLParams
  4654. ifNoneMatch_ string
  4655. ctx_ context.Context
  4656. header_ http.Header
  4657. }
  4658. // Get: Gets the specified message.
  4659. func (r *UsersMessagesService) Get(userId string, id string) *UsersMessagesGetCall {
  4660. c := &UsersMessagesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4661. c.userId = userId
  4662. c.id = id
  4663. return c
  4664. }
  4665. // Format sets the optional parameter "format": The format to return the
  4666. // message in.
  4667. //
  4668. // Possible values:
  4669. // "full" (default)
  4670. // "metadata"
  4671. // "minimal"
  4672. // "raw"
  4673. func (c *UsersMessagesGetCall) Format(format string) *UsersMessagesGetCall {
  4674. c.urlParams_.Set("format", format)
  4675. return c
  4676. }
  4677. // MetadataHeaders sets the optional parameter "metadataHeaders": When
  4678. // given and format is METADATA, only include headers specified.
  4679. func (c *UsersMessagesGetCall) MetadataHeaders(metadataHeaders ...string) *UsersMessagesGetCall {
  4680. c.urlParams_.SetMulti("metadataHeaders", append([]string{}, metadataHeaders...))
  4681. return c
  4682. }
  4683. // Fields allows partial responses to be retrieved. See
  4684. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4685. // for more information.
  4686. func (c *UsersMessagesGetCall) Fields(s ...googleapi.Field) *UsersMessagesGetCall {
  4687. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4688. return c
  4689. }
  4690. // IfNoneMatch sets the optional parameter which makes the operation
  4691. // fail if the object's ETag matches the given value. This is useful for
  4692. // getting updates only after the object has changed since the last
  4693. // request. Use googleapi.IsNotModified to check whether the response
  4694. // error from Do is the result of In-None-Match.
  4695. func (c *UsersMessagesGetCall) IfNoneMatch(entityTag string) *UsersMessagesGetCall {
  4696. c.ifNoneMatch_ = entityTag
  4697. return c
  4698. }
  4699. // Context sets the context to be used in this call's Do method. Any
  4700. // pending HTTP request will be aborted if the provided context is
  4701. // canceled.
  4702. func (c *UsersMessagesGetCall) Context(ctx context.Context) *UsersMessagesGetCall {
  4703. c.ctx_ = ctx
  4704. return c
  4705. }
  4706. // Header returns an http.Header that can be modified by the caller to
  4707. // add HTTP headers to the request.
  4708. func (c *UsersMessagesGetCall) Header() http.Header {
  4709. if c.header_ == nil {
  4710. c.header_ = make(http.Header)
  4711. }
  4712. return c.header_
  4713. }
  4714. func (c *UsersMessagesGetCall) doRequest(alt string) (*http.Response, error) {
  4715. reqHeaders := make(http.Header)
  4716. for k, v := range c.header_ {
  4717. reqHeaders[k] = v
  4718. }
  4719. reqHeaders.Set("User-Agent", c.s.userAgent())
  4720. if c.ifNoneMatch_ != "" {
  4721. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  4722. }
  4723. var body io.Reader = nil
  4724. c.urlParams_.Set("alt", alt)
  4725. c.urlParams_.Set("prettyPrint", "false")
  4726. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
  4727. urls += "?" + c.urlParams_.Encode()
  4728. req, err := http.NewRequest("GET", urls, body)
  4729. if err != nil {
  4730. return nil, err
  4731. }
  4732. req.Header = reqHeaders
  4733. googleapi.Expand(req.URL, map[string]string{
  4734. "userId": c.userId,
  4735. "id": c.id,
  4736. })
  4737. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4738. }
  4739. // Do executes the "gmail.users.messages.get" call.
  4740. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4741. // code is an error. Response headers are in either
  4742. // *Message.ServerResponse.Header or (if a response was returned at all)
  4743. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4744. // check whether the returned error was because http.StatusNotModified
  4745. // was returned.
  4746. func (c *UsersMessagesGetCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4747. gensupport.SetOptions(c.urlParams_, opts...)
  4748. res, err := c.doRequest("json")
  4749. if res != nil && res.StatusCode == http.StatusNotModified {
  4750. if res.Body != nil {
  4751. res.Body.Close()
  4752. }
  4753. return nil, &googleapi.Error{
  4754. Code: res.StatusCode,
  4755. Header: res.Header,
  4756. }
  4757. }
  4758. if err != nil {
  4759. return nil, err
  4760. }
  4761. defer googleapi.CloseBody(res)
  4762. if err := googleapi.CheckResponse(res); err != nil {
  4763. return nil, err
  4764. }
  4765. ret := &Message{
  4766. ServerResponse: googleapi.ServerResponse{
  4767. Header: res.Header,
  4768. HTTPStatusCode: res.StatusCode,
  4769. },
  4770. }
  4771. target := &ret
  4772. if err := gensupport.DecodeResponse(target, res); err != nil {
  4773. return nil, err
  4774. }
  4775. return ret, nil
  4776. // {
  4777. // "description": "Gets the specified message.",
  4778. // "httpMethod": "GET",
  4779. // "id": "gmail.users.messages.get",
  4780. // "parameterOrder": [
  4781. // "userId",
  4782. // "id"
  4783. // ],
  4784. // "parameters": {
  4785. // "format": {
  4786. // "default": "full",
  4787. // "description": "The format to return the message in.",
  4788. // "enum": [
  4789. // "full",
  4790. // "metadata",
  4791. // "minimal",
  4792. // "raw"
  4793. // ],
  4794. // "enumDescriptions": [
  4795. // "",
  4796. // "",
  4797. // "",
  4798. // ""
  4799. // ],
  4800. // "location": "query",
  4801. // "type": "string"
  4802. // },
  4803. // "id": {
  4804. // "description": "The ID of the message to retrieve.",
  4805. // "location": "path",
  4806. // "required": true,
  4807. // "type": "string"
  4808. // },
  4809. // "metadataHeaders": {
  4810. // "description": "When given and format is METADATA, only include headers specified.",
  4811. // "location": "query",
  4812. // "repeated": true,
  4813. // "type": "string"
  4814. // },
  4815. // "userId": {
  4816. // "default": "me",
  4817. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4818. // "location": "path",
  4819. // "required": true,
  4820. // "type": "string"
  4821. // }
  4822. // },
  4823. // "path": "{userId}/messages/{id}",
  4824. // "response": {
  4825. // "$ref": "Message"
  4826. // },
  4827. // "scopes": [
  4828. // "https://mail.google.com/",
  4829. // "https://www.googleapis.com/auth/gmail.metadata",
  4830. // "https://www.googleapis.com/auth/gmail.modify",
  4831. // "https://www.googleapis.com/auth/gmail.readonly"
  4832. // ]
  4833. // }
  4834. }
  4835. // method id "gmail.users.messages.import":
  4836. type UsersMessagesImportCall struct {
  4837. s *Service
  4838. userId string
  4839. message *Message
  4840. urlParams_ gensupport.URLParams
  4841. mediaInfo_ *gensupport.MediaInfo
  4842. ctx_ context.Context
  4843. header_ http.Header
  4844. }
  4845. // Import: Imports a message into only this user's mailbox, with
  4846. // standard email delivery scanning and classification similar to
  4847. // receiving via SMTP. Does not send a message.
  4848. func (r *UsersMessagesService) Import(userId string, message *Message) *UsersMessagesImportCall {
  4849. c := &UsersMessagesImportCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4850. c.userId = userId
  4851. c.message = message
  4852. return c
  4853. }
  4854. // Deleted sets the optional parameter "deleted": Mark the email as
  4855. // permanently deleted (not TRASH) and only visible in Google Vault to a
  4856. // Vault administrator. Only used for G Suite accounts.
  4857. func (c *UsersMessagesImportCall) Deleted(deleted bool) *UsersMessagesImportCall {
  4858. c.urlParams_.Set("deleted", fmt.Sprint(deleted))
  4859. return c
  4860. }
  4861. // InternalDateSource sets the optional parameter "internalDateSource":
  4862. // Source for Gmail's internal date of the message.
  4863. //
  4864. // Possible values:
  4865. // "dateHeader" (default)
  4866. // "receivedTime"
  4867. func (c *UsersMessagesImportCall) InternalDateSource(internalDateSource string) *UsersMessagesImportCall {
  4868. c.urlParams_.Set("internalDateSource", internalDateSource)
  4869. return c
  4870. }
  4871. // NeverMarkSpam sets the optional parameter "neverMarkSpam": Ignore the
  4872. // Gmail spam classifier decision and never mark this email as SPAM in
  4873. // the mailbox.
  4874. func (c *UsersMessagesImportCall) NeverMarkSpam(neverMarkSpam bool) *UsersMessagesImportCall {
  4875. c.urlParams_.Set("neverMarkSpam", fmt.Sprint(neverMarkSpam))
  4876. return c
  4877. }
  4878. // ProcessForCalendar sets the optional parameter "processForCalendar":
  4879. // Process calendar invites in the email and add any extracted meetings
  4880. // to the Google Calendar for this user.
  4881. func (c *UsersMessagesImportCall) ProcessForCalendar(processForCalendar bool) *UsersMessagesImportCall {
  4882. c.urlParams_.Set("processForCalendar", fmt.Sprint(processForCalendar))
  4883. return c
  4884. }
  4885. // Media specifies the media to upload in one or more chunks. The chunk
  4886. // size may be controlled by supplying a MediaOption generated by
  4887. // googleapi.ChunkSize. The chunk size defaults to
  4888. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  4889. // upload request will be determined by sniffing the contents of r,
  4890. // unless a MediaOption generated by googleapi.ContentType is
  4891. // supplied.
  4892. // At most one of Media and ResumableMedia may be set.
  4893. func (c *UsersMessagesImportCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesImportCall {
  4894. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  4895. return c
  4896. }
  4897. // ResumableMedia specifies the media to upload in chunks and can be
  4898. // canceled with ctx.
  4899. //
  4900. // Deprecated: use Media instead.
  4901. //
  4902. // At most one of Media and ResumableMedia may be set. mediaType
  4903. // identifies the MIME media type of the upload, such as "image/png". If
  4904. // mediaType is "", it will be auto-detected. The provided ctx will
  4905. // supersede any context previously provided to the Context method.
  4906. func (c *UsersMessagesImportCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesImportCall {
  4907. c.ctx_ = ctx
  4908. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  4909. return c
  4910. }
  4911. // ProgressUpdater provides a callback function that will be called
  4912. // after every chunk. It should be a low-latency function in order to
  4913. // not slow down the upload operation. This should only be called when
  4914. // using ResumableMedia (as opposed to Media).
  4915. func (c *UsersMessagesImportCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesImportCall {
  4916. c.mediaInfo_.SetProgressUpdater(pu)
  4917. return c
  4918. }
  4919. // Fields allows partial responses to be retrieved. See
  4920. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4921. // for more information.
  4922. func (c *UsersMessagesImportCall) Fields(s ...googleapi.Field) *UsersMessagesImportCall {
  4923. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4924. return c
  4925. }
  4926. // Context sets the context to be used in this call's Do method. Any
  4927. // pending HTTP request will be aborted if the provided context is
  4928. // canceled.
  4929. // This context will supersede any context previously provided to the
  4930. // ResumableMedia method.
  4931. func (c *UsersMessagesImportCall) Context(ctx context.Context) *UsersMessagesImportCall {
  4932. c.ctx_ = ctx
  4933. return c
  4934. }
  4935. // Header returns an http.Header that can be modified by the caller to
  4936. // add HTTP headers to the request.
  4937. func (c *UsersMessagesImportCall) Header() http.Header {
  4938. if c.header_ == nil {
  4939. c.header_ = make(http.Header)
  4940. }
  4941. return c.header_
  4942. }
  4943. func (c *UsersMessagesImportCall) doRequest(alt string) (*http.Response, error) {
  4944. reqHeaders := make(http.Header)
  4945. for k, v := range c.header_ {
  4946. reqHeaders[k] = v
  4947. }
  4948. reqHeaders.Set("User-Agent", c.s.userAgent())
  4949. var body io.Reader = nil
  4950. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  4951. if err != nil {
  4952. return nil, err
  4953. }
  4954. reqHeaders.Set("Content-Type", "application/json")
  4955. c.urlParams_.Set("alt", alt)
  4956. c.urlParams_.Set("prettyPrint", "false")
  4957. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/import")
  4958. if c.mediaInfo_ != nil {
  4959. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  4960. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  4961. }
  4962. if body == nil {
  4963. body = new(bytes.Buffer)
  4964. reqHeaders.Set("Content-Type", "application/json")
  4965. }
  4966. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  4967. defer cleanup()
  4968. urls += "?" + c.urlParams_.Encode()
  4969. req, err := http.NewRequest("POST", urls, body)
  4970. if err != nil {
  4971. return nil, err
  4972. }
  4973. req.Header = reqHeaders
  4974. req.GetBody = getBody
  4975. googleapi.Expand(req.URL, map[string]string{
  4976. "userId": c.userId,
  4977. })
  4978. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4979. }
  4980. // Do executes the "gmail.users.messages.import" call.
  4981. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4982. // code is an error. Response headers are in either
  4983. // *Message.ServerResponse.Header or (if a response was returned at all)
  4984. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4985. // check whether the returned error was because http.StatusNotModified
  4986. // was returned.
  4987. func (c *UsersMessagesImportCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4988. gensupport.SetOptions(c.urlParams_, opts...)
  4989. res, err := c.doRequest("json")
  4990. if res != nil && res.StatusCode == http.StatusNotModified {
  4991. if res.Body != nil {
  4992. res.Body.Close()
  4993. }
  4994. return nil, &googleapi.Error{
  4995. Code: res.StatusCode,
  4996. Header: res.Header,
  4997. }
  4998. }
  4999. if err != nil {
  5000. return nil, err
  5001. }
  5002. defer googleapi.CloseBody(res)
  5003. if err := googleapi.CheckResponse(res); err != nil {
  5004. return nil, err
  5005. }
  5006. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  5007. if rx != nil {
  5008. rx.Client = c.s.client
  5009. rx.UserAgent = c.s.userAgent()
  5010. ctx := c.ctx_
  5011. if ctx == nil {
  5012. ctx = context.TODO()
  5013. }
  5014. res, err = rx.Upload(ctx)
  5015. if err != nil {
  5016. return nil, err
  5017. }
  5018. defer res.Body.Close()
  5019. if err := googleapi.CheckResponse(res); err != nil {
  5020. return nil, err
  5021. }
  5022. }
  5023. ret := &Message{
  5024. ServerResponse: googleapi.ServerResponse{
  5025. Header: res.Header,
  5026. HTTPStatusCode: res.StatusCode,
  5027. },
  5028. }
  5029. target := &ret
  5030. if err := gensupport.DecodeResponse(target, res); err != nil {
  5031. return nil, err
  5032. }
  5033. return ret, nil
  5034. // {
  5035. // "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.",
  5036. // "httpMethod": "POST",
  5037. // "id": "gmail.users.messages.import",
  5038. // "mediaUpload": {
  5039. // "accept": [
  5040. // "message/rfc822"
  5041. // ],
  5042. // "maxSize": "50MB",
  5043. // "protocols": {
  5044. // "resumable": {
  5045. // "multipart": true,
  5046. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages/import"
  5047. // },
  5048. // "simple": {
  5049. // "multipart": true,
  5050. // "path": "/upload/gmail/v1/users/{userId}/messages/import"
  5051. // }
  5052. // }
  5053. // },
  5054. // "parameterOrder": [
  5055. // "userId"
  5056. // ],
  5057. // "parameters": {
  5058. // "deleted": {
  5059. // "default": "false",
  5060. // "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.",
  5061. // "location": "query",
  5062. // "type": "boolean"
  5063. // },
  5064. // "internalDateSource": {
  5065. // "default": "dateHeader",
  5066. // "description": "Source for Gmail's internal date of the message.",
  5067. // "enum": [
  5068. // "dateHeader",
  5069. // "receivedTime"
  5070. // ],
  5071. // "enumDescriptions": [
  5072. // "",
  5073. // ""
  5074. // ],
  5075. // "location": "query",
  5076. // "type": "string"
  5077. // },
  5078. // "neverMarkSpam": {
  5079. // "default": "false",
  5080. // "description": "Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.",
  5081. // "location": "query",
  5082. // "type": "boolean"
  5083. // },
  5084. // "processForCalendar": {
  5085. // "default": "false",
  5086. // "description": "Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.",
  5087. // "location": "query",
  5088. // "type": "boolean"
  5089. // },
  5090. // "userId": {
  5091. // "default": "me",
  5092. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5093. // "location": "path",
  5094. // "required": true,
  5095. // "type": "string"
  5096. // }
  5097. // },
  5098. // "path": "{userId}/messages/import",
  5099. // "request": {
  5100. // "$ref": "Message"
  5101. // },
  5102. // "response": {
  5103. // "$ref": "Message"
  5104. // },
  5105. // "scopes": [
  5106. // "https://mail.google.com/",
  5107. // "https://www.googleapis.com/auth/gmail.insert",
  5108. // "https://www.googleapis.com/auth/gmail.modify"
  5109. // ],
  5110. // "supportsMediaUpload": true
  5111. // }
  5112. }
  5113. // method id "gmail.users.messages.insert":
  5114. type UsersMessagesInsertCall struct {
  5115. s *Service
  5116. userId string
  5117. message *Message
  5118. urlParams_ gensupport.URLParams
  5119. mediaInfo_ *gensupport.MediaInfo
  5120. ctx_ context.Context
  5121. header_ http.Header
  5122. }
  5123. // Insert: Directly inserts a message into only this user's mailbox
  5124. // similar to IMAP APPEND, bypassing most scanning and classification.
  5125. // Does not send a message.
  5126. func (r *UsersMessagesService) Insert(userId string, message *Message) *UsersMessagesInsertCall {
  5127. c := &UsersMessagesInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5128. c.userId = userId
  5129. c.message = message
  5130. return c
  5131. }
  5132. // Deleted sets the optional parameter "deleted": Mark the email as
  5133. // permanently deleted (not TRASH) and only visible in Google Vault to a
  5134. // Vault administrator. Only used for G Suite accounts.
  5135. func (c *UsersMessagesInsertCall) Deleted(deleted bool) *UsersMessagesInsertCall {
  5136. c.urlParams_.Set("deleted", fmt.Sprint(deleted))
  5137. return c
  5138. }
  5139. // InternalDateSource sets the optional parameter "internalDateSource":
  5140. // Source for Gmail's internal date of the message.
  5141. //
  5142. // Possible values:
  5143. // "dateHeader"
  5144. // "receivedTime" (default)
  5145. func (c *UsersMessagesInsertCall) InternalDateSource(internalDateSource string) *UsersMessagesInsertCall {
  5146. c.urlParams_.Set("internalDateSource", internalDateSource)
  5147. return c
  5148. }
  5149. // Media specifies the media to upload in one or more chunks. The chunk
  5150. // size may be controlled by supplying a MediaOption generated by
  5151. // googleapi.ChunkSize. The chunk size defaults to
  5152. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  5153. // upload request will be determined by sniffing the contents of r,
  5154. // unless a MediaOption generated by googleapi.ContentType is
  5155. // supplied.
  5156. // At most one of Media and ResumableMedia may be set.
  5157. func (c *UsersMessagesInsertCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesInsertCall {
  5158. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  5159. return c
  5160. }
  5161. // ResumableMedia specifies the media to upload in chunks and can be
  5162. // canceled with ctx.
  5163. //
  5164. // Deprecated: use Media instead.
  5165. //
  5166. // At most one of Media and ResumableMedia may be set. mediaType
  5167. // identifies the MIME media type of the upload, such as "image/png". If
  5168. // mediaType is "", it will be auto-detected. The provided ctx will
  5169. // supersede any context previously provided to the Context method.
  5170. func (c *UsersMessagesInsertCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesInsertCall {
  5171. c.ctx_ = ctx
  5172. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  5173. return c
  5174. }
  5175. // ProgressUpdater provides a callback function that will be called
  5176. // after every chunk. It should be a low-latency function in order to
  5177. // not slow down the upload operation. This should only be called when
  5178. // using ResumableMedia (as opposed to Media).
  5179. func (c *UsersMessagesInsertCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesInsertCall {
  5180. c.mediaInfo_.SetProgressUpdater(pu)
  5181. return c
  5182. }
  5183. // Fields allows partial responses to be retrieved. See
  5184. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5185. // for more information.
  5186. func (c *UsersMessagesInsertCall) Fields(s ...googleapi.Field) *UsersMessagesInsertCall {
  5187. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5188. return c
  5189. }
  5190. // Context sets the context to be used in this call's Do method. Any
  5191. // pending HTTP request will be aborted if the provided context is
  5192. // canceled.
  5193. // This context will supersede any context previously provided to the
  5194. // ResumableMedia method.
  5195. func (c *UsersMessagesInsertCall) Context(ctx context.Context) *UsersMessagesInsertCall {
  5196. c.ctx_ = ctx
  5197. return c
  5198. }
  5199. // Header returns an http.Header that can be modified by the caller to
  5200. // add HTTP headers to the request.
  5201. func (c *UsersMessagesInsertCall) Header() http.Header {
  5202. if c.header_ == nil {
  5203. c.header_ = make(http.Header)
  5204. }
  5205. return c.header_
  5206. }
  5207. func (c *UsersMessagesInsertCall) doRequest(alt string) (*http.Response, error) {
  5208. reqHeaders := make(http.Header)
  5209. for k, v := range c.header_ {
  5210. reqHeaders[k] = v
  5211. }
  5212. reqHeaders.Set("User-Agent", c.s.userAgent())
  5213. var body io.Reader = nil
  5214. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  5215. if err != nil {
  5216. return nil, err
  5217. }
  5218. reqHeaders.Set("Content-Type", "application/json")
  5219. c.urlParams_.Set("alt", alt)
  5220. c.urlParams_.Set("prettyPrint", "false")
  5221. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
  5222. if c.mediaInfo_ != nil {
  5223. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  5224. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  5225. }
  5226. if body == nil {
  5227. body = new(bytes.Buffer)
  5228. reqHeaders.Set("Content-Type", "application/json")
  5229. }
  5230. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  5231. defer cleanup()
  5232. urls += "?" + c.urlParams_.Encode()
  5233. req, err := http.NewRequest("POST", urls, body)
  5234. if err != nil {
  5235. return nil, err
  5236. }
  5237. req.Header = reqHeaders
  5238. req.GetBody = getBody
  5239. googleapi.Expand(req.URL, map[string]string{
  5240. "userId": c.userId,
  5241. })
  5242. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5243. }
  5244. // Do executes the "gmail.users.messages.insert" call.
  5245. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5246. // code is an error. Response headers are in either
  5247. // *Message.ServerResponse.Header or (if a response was returned at all)
  5248. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5249. // check whether the returned error was because http.StatusNotModified
  5250. // was returned.
  5251. func (c *UsersMessagesInsertCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5252. gensupport.SetOptions(c.urlParams_, opts...)
  5253. res, err := c.doRequest("json")
  5254. if res != nil && res.StatusCode == http.StatusNotModified {
  5255. if res.Body != nil {
  5256. res.Body.Close()
  5257. }
  5258. return nil, &googleapi.Error{
  5259. Code: res.StatusCode,
  5260. Header: res.Header,
  5261. }
  5262. }
  5263. if err != nil {
  5264. return nil, err
  5265. }
  5266. defer googleapi.CloseBody(res)
  5267. if err := googleapi.CheckResponse(res); err != nil {
  5268. return nil, err
  5269. }
  5270. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  5271. if rx != nil {
  5272. rx.Client = c.s.client
  5273. rx.UserAgent = c.s.userAgent()
  5274. ctx := c.ctx_
  5275. if ctx == nil {
  5276. ctx = context.TODO()
  5277. }
  5278. res, err = rx.Upload(ctx)
  5279. if err != nil {
  5280. return nil, err
  5281. }
  5282. defer res.Body.Close()
  5283. if err := googleapi.CheckResponse(res); err != nil {
  5284. return nil, err
  5285. }
  5286. }
  5287. ret := &Message{
  5288. ServerResponse: googleapi.ServerResponse{
  5289. Header: res.Header,
  5290. HTTPStatusCode: res.StatusCode,
  5291. },
  5292. }
  5293. target := &ret
  5294. if err := gensupport.DecodeResponse(target, res); err != nil {
  5295. return nil, err
  5296. }
  5297. return ret, nil
  5298. // {
  5299. // "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.",
  5300. // "httpMethod": "POST",
  5301. // "id": "gmail.users.messages.insert",
  5302. // "mediaUpload": {
  5303. // "accept": [
  5304. // "message/rfc822"
  5305. // ],
  5306. // "maxSize": "50MB",
  5307. // "protocols": {
  5308. // "resumable": {
  5309. // "multipart": true,
  5310. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages"
  5311. // },
  5312. // "simple": {
  5313. // "multipart": true,
  5314. // "path": "/upload/gmail/v1/users/{userId}/messages"
  5315. // }
  5316. // }
  5317. // },
  5318. // "parameterOrder": [
  5319. // "userId"
  5320. // ],
  5321. // "parameters": {
  5322. // "deleted": {
  5323. // "default": "false",
  5324. // "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.",
  5325. // "location": "query",
  5326. // "type": "boolean"
  5327. // },
  5328. // "internalDateSource": {
  5329. // "default": "receivedTime",
  5330. // "description": "Source for Gmail's internal date of the message.",
  5331. // "enum": [
  5332. // "dateHeader",
  5333. // "receivedTime"
  5334. // ],
  5335. // "enumDescriptions": [
  5336. // "",
  5337. // ""
  5338. // ],
  5339. // "location": "query",
  5340. // "type": "string"
  5341. // },
  5342. // "userId": {
  5343. // "default": "me",
  5344. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5345. // "location": "path",
  5346. // "required": true,
  5347. // "type": "string"
  5348. // }
  5349. // },
  5350. // "path": "{userId}/messages",
  5351. // "request": {
  5352. // "$ref": "Message"
  5353. // },
  5354. // "response": {
  5355. // "$ref": "Message"
  5356. // },
  5357. // "scopes": [
  5358. // "https://mail.google.com/",
  5359. // "https://www.googleapis.com/auth/gmail.insert",
  5360. // "https://www.googleapis.com/auth/gmail.modify"
  5361. // ],
  5362. // "supportsMediaUpload": true
  5363. // }
  5364. }
  5365. // method id "gmail.users.messages.list":
  5366. type UsersMessagesListCall struct {
  5367. s *Service
  5368. userId string
  5369. urlParams_ gensupport.URLParams
  5370. ifNoneMatch_ string
  5371. ctx_ context.Context
  5372. header_ http.Header
  5373. }
  5374. // List: Lists the messages in the user's mailbox.
  5375. func (r *UsersMessagesService) List(userId string) *UsersMessagesListCall {
  5376. c := &UsersMessagesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5377. c.userId = userId
  5378. return c
  5379. }
  5380. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  5381. // Include messages from SPAM and TRASH in the results.
  5382. func (c *UsersMessagesListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersMessagesListCall {
  5383. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  5384. return c
  5385. }
  5386. // LabelIds sets the optional parameter "labelIds": Only return messages
  5387. // with labels that match all of the specified label IDs.
  5388. func (c *UsersMessagesListCall) LabelIds(labelIds ...string) *UsersMessagesListCall {
  5389. c.urlParams_.SetMulti("labelIds", append([]string{}, labelIds...))
  5390. return c
  5391. }
  5392. // MaxResults sets the optional parameter "maxResults": Maximum number
  5393. // of messages to return.
  5394. func (c *UsersMessagesListCall) MaxResults(maxResults int64) *UsersMessagesListCall {
  5395. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  5396. return c
  5397. }
  5398. // PageToken sets the optional parameter "pageToken": Page token to
  5399. // retrieve a specific page of results in the list.
  5400. func (c *UsersMessagesListCall) PageToken(pageToken string) *UsersMessagesListCall {
  5401. c.urlParams_.Set("pageToken", pageToken)
  5402. return c
  5403. }
  5404. // Q sets the optional parameter "q": Only return messages matching the
  5405. // specified query. Supports the same query format as the Gmail search
  5406. // box. For example, "from:someuser@example.com
  5407. // rfc822msgid:<somemsgid@example.com> is:unread". Parameter cannot be
  5408. // used when accessing the api using the gmail.metadata scope.
  5409. func (c *UsersMessagesListCall) Q(q string) *UsersMessagesListCall {
  5410. c.urlParams_.Set("q", q)
  5411. return c
  5412. }
  5413. // Fields allows partial responses to be retrieved. See
  5414. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5415. // for more information.
  5416. func (c *UsersMessagesListCall) Fields(s ...googleapi.Field) *UsersMessagesListCall {
  5417. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5418. return c
  5419. }
  5420. // IfNoneMatch sets the optional parameter which makes the operation
  5421. // fail if the object's ETag matches the given value. This is useful for
  5422. // getting updates only after the object has changed since the last
  5423. // request. Use googleapi.IsNotModified to check whether the response
  5424. // error from Do is the result of In-None-Match.
  5425. func (c *UsersMessagesListCall) IfNoneMatch(entityTag string) *UsersMessagesListCall {
  5426. c.ifNoneMatch_ = entityTag
  5427. return c
  5428. }
  5429. // Context sets the context to be used in this call's Do method. Any
  5430. // pending HTTP request will be aborted if the provided context is
  5431. // canceled.
  5432. func (c *UsersMessagesListCall) Context(ctx context.Context) *UsersMessagesListCall {
  5433. c.ctx_ = ctx
  5434. return c
  5435. }
  5436. // Header returns an http.Header that can be modified by the caller to
  5437. // add HTTP headers to the request.
  5438. func (c *UsersMessagesListCall) Header() http.Header {
  5439. if c.header_ == nil {
  5440. c.header_ = make(http.Header)
  5441. }
  5442. return c.header_
  5443. }
  5444. func (c *UsersMessagesListCall) doRequest(alt string) (*http.Response, error) {
  5445. reqHeaders := make(http.Header)
  5446. for k, v := range c.header_ {
  5447. reqHeaders[k] = v
  5448. }
  5449. reqHeaders.Set("User-Agent", c.s.userAgent())
  5450. if c.ifNoneMatch_ != "" {
  5451. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  5452. }
  5453. var body io.Reader = nil
  5454. c.urlParams_.Set("alt", alt)
  5455. c.urlParams_.Set("prettyPrint", "false")
  5456. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
  5457. urls += "?" + c.urlParams_.Encode()
  5458. req, err := http.NewRequest("GET", urls, body)
  5459. if err != nil {
  5460. return nil, err
  5461. }
  5462. req.Header = reqHeaders
  5463. googleapi.Expand(req.URL, map[string]string{
  5464. "userId": c.userId,
  5465. })
  5466. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5467. }
  5468. // Do executes the "gmail.users.messages.list" call.
  5469. // Exactly one of *ListMessagesResponse or error will be non-nil. Any
  5470. // non-2xx status code is an error. Response headers are in either
  5471. // *ListMessagesResponse.ServerResponse.Header or (if a response was
  5472. // returned at all) in error.(*googleapi.Error).Header. Use
  5473. // googleapi.IsNotModified to check whether the returned error was
  5474. // because http.StatusNotModified was returned.
  5475. func (c *UsersMessagesListCall) Do(opts ...googleapi.CallOption) (*ListMessagesResponse, error) {
  5476. gensupport.SetOptions(c.urlParams_, opts...)
  5477. res, err := c.doRequest("json")
  5478. if res != nil && res.StatusCode == http.StatusNotModified {
  5479. if res.Body != nil {
  5480. res.Body.Close()
  5481. }
  5482. return nil, &googleapi.Error{
  5483. Code: res.StatusCode,
  5484. Header: res.Header,
  5485. }
  5486. }
  5487. if err != nil {
  5488. return nil, err
  5489. }
  5490. defer googleapi.CloseBody(res)
  5491. if err := googleapi.CheckResponse(res); err != nil {
  5492. return nil, err
  5493. }
  5494. ret := &ListMessagesResponse{
  5495. ServerResponse: googleapi.ServerResponse{
  5496. Header: res.Header,
  5497. HTTPStatusCode: res.StatusCode,
  5498. },
  5499. }
  5500. target := &ret
  5501. if err := gensupport.DecodeResponse(target, res); err != nil {
  5502. return nil, err
  5503. }
  5504. return ret, nil
  5505. // {
  5506. // "description": "Lists the messages in the user's mailbox.",
  5507. // "httpMethod": "GET",
  5508. // "id": "gmail.users.messages.list",
  5509. // "parameterOrder": [
  5510. // "userId"
  5511. // ],
  5512. // "parameters": {
  5513. // "includeSpamTrash": {
  5514. // "default": "false",
  5515. // "description": "Include messages from SPAM and TRASH in the results.",
  5516. // "location": "query",
  5517. // "type": "boolean"
  5518. // },
  5519. // "labelIds": {
  5520. // "description": "Only return messages with labels that match all of the specified label IDs.",
  5521. // "location": "query",
  5522. // "repeated": true,
  5523. // "type": "string"
  5524. // },
  5525. // "maxResults": {
  5526. // "default": "100",
  5527. // "description": "Maximum number of messages to return.",
  5528. // "format": "uint32",
  5529. // "location": "query",
  5530. // "type": "integer"
  5531. // },
  5532. // "pageToken": {
  5533. // "description": "Page token to retrieve a specific page of results in the list.",
  5534. // "location": "query",
  5535. // "type": "string"
  5536. // },
  5537. // "q": {
  5538. // "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.",
  5539. // "location": "query",
  5540. // "type": "string"
  5541. // },
  5542. // "userId": {
  5543. // "default": "me",
  5544. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5545. // "location": "path",
  5546. // "required": true,
  5547. // "type": "string"
  5548. // }
  5549. // },
  5550. // "path": "{userId}/messages",
  5551. // "response": {
  5552. // "$ref": "ListMessagesResponse"
  5553. // },
  5554. // "scopes": [
  5555. // "https://mail.google.com/",
  5556. // "https://www.googleapis.com/auth/gmail.metadata",
  5557. // "https://www.googleapis.com/auth/gmail.modify",
  5558. // "https://www.googleapis.com/auth/gmail.readonly"
  5559. // ]
  5560. // }
  5561. }
  5562. // Pages invokes f for each page of results.
  5563. // A non-nil error returned from f will halt the iteration.
  5564. // The provided context supersedes any context provided to the Context method.
  5565. func (c *UsersMessagesListCall) Pages(ctx context.Context, f func(*ListMessagesResponse) error) error {
  5566. c.ctx_ = ctx
  5567. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  5568. for {
  5569. x, err := c.Do()
  5570. if err != nil {
  5571. return err
  5572. }
  5573. if err := f(x); err != nil {
  5574. return err
  5575. }
  5576. if x.NextPageToken == "" {
  5577. return nil
  5578. }
  5579. c.PageToken(x.NextPageToken)
  5580. }
  5581. }
  5582. // method id "gmail.users.messages.modify":
  5583. type UsersMessagesModifyCall struct {
  5584. s *Service
  5585. userId string
  5586. id string
  5587. modifymessagerequest *ModifyMessageRequest
  5588. urlParams_ gensupport.URLParams
  5589. ctx_ context.Context
  5590. header_ http.Header
  5591. }
  5592. // Modify: Modifies the labels on the specified message.
  5593. func (r *UsersMessagesService) Modify(userId string, id string, modifymessagerequest *ModifyMessageRequest) *UsersMessagesModifyCall {
  5594. c := &UsersMessagesModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5595. c.userId = userId
  5596. c.id = id
  5597. c.modifymessagerequest = modifymessagerequest
  5598. return c
  5599. }
  5600. // Fields allows partial responses to be retrieved. See
  5601. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5602. // for more information.
  5603. func (c *UsersMessagesModifyCall) Fields(s ...googleapi.Field) *UsersMessagesModifyCall {
  5604. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5605. return c
  5606. }
  5607. // Context sets the context to be used in this call's Do method. Any
  5608. // pending HTTP request will be aborted if the provided context is
  5609. // canceled.
  5610. func (c *UsersMessagesModifyCall) Context(ctx context.Context) *UsersMessagesModifyCall {
  5611. c.ctx_ = ctx
  5612. return c
  5613. }
  5614. // Header returns an http.Header that can be modified by the caller to
  5615. // add HTTP headers to the request.
  5616. func (c *UsersMessagesModifyCall) Header() http.Header {
  5617. if c.header_ == nil {
  5618. c.header_ = make(http.Header)
  5619. }
  5620. return c.header_
  5621. }
  5622. func (c *UsersMessagesModifyCall) doRequest(alt string) (*http.Response, error) {
  5623. reqHeaders := make(http.Header)
  5624. for k, v := range c.header_ {
  5625. reqHeaders[k] = v
  5626. }
  5627. reqHeaders.Set("User-Agent", c.s.userAgent())
  5628. var body io.Reader = nil
  5629. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifymessagerequest)
  5630. if err != nil {
  5631. return nil, err
  5632. }
  5633. reqHeaders.Set("Content-Type", "application/json")
  5634. c.urlParams_.Set("alt", alt)
  5635. c.urlParams_.Set("prettyPrint", "false")
  5636. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/modify")
  5637. urls += "?" + c.urlParams_.Encode()
  5638. req, err := http.NewRequest("POST", urls, body)
  5639. if err != nil {
  5640. return nil, err
  5641. }
  5642. req.Header = reqHeaders
  5643. googleapi.Expand(req.URL, map[string]string{
  5644. "userId": c.userId,
  5645. "id": c.id,
  5646. })
  5647. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5648. }
  5649. // Do executes the "gmail.users.messages.modify" call.
  5650. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5651. // code is an error. Response headers are in either
  5652. // *Message.ServerResponse.Header or (if a response was returned at all)
  5653. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5654. // check whether the returned error was because http.StatusNotModified
  5655. // was returned.
  5656. func (c *UsersMessagesModifyCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5657. gensupport.SetOptions(c.urlParams_, opts...)
  5658. res, err := c.doRequest("json")
  5659. if res != nil && res.StatusCode == http.StatusNotModified {
  5660. if res.Body != nil {
  5661. res.Body.Close()
  5662. }
  5663. return nil, &googleapi.Error{
  5664. Code: res.StatusCode,
  5665. Header: res.Header,
  5666. }
  5667. }
  5668. if err != nil {
  5669. return nil, err
  5670. }
  5671. defer googleapi.CloseBody(res)
  5672. if err := googleapi.CheckResponse(res); err != nil {
  5673. return nil, err
  5674. }
  5675. ret := &Message{
  5676. ServerResponse: googleapi.ServerResponse{
  5677. Header: res.Header,
  5678. HTTPStatusCode: res.StatusCode,
  5679. },
  5680. }
  5681. target := &ret
  5682. if err := gensupport.DecodeResponse(target, res); err != nil {
  5683. return nil, err
  5684. }
  5685. return ret, nil
  5686. // {
  5687. // "description": "Modifies the labels on the specified message.",
  5688. // "httpMethod": "POST",
  5689. // "id": "gmail.users.messages.modify",
  5690. // "parameterOrder": [
  5691. // "userId",
  5692. // "id"
  5693. // ],
  5694. // "parameters": {
  5695. // "id": {
  5696. // "description": "The ID of the message to modify.",
  5697. // "location": "path",
  5698. // "required": true,
  5699. // "type": "string"
  5700. // },
  5701. // "userId": {
  5702. // "default": "me",
  5703. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5704. // "location": "path",
  5705. // "required": true,
  5706. // "type": "string"
  5707. // }
  5708. // },
  5709. // "path": "{userId}/messages/{id}/modify",
  5710. // "request": {
  5711. // "$ref": "ModifyMessageRequest"
  5712. // },
  5713. // "response": {
  5714. // "$ref": "Message"
  5715. // },
  5716. // "scopes": [
  5717. // "https://mail.google.com/",
  5718. // "https://www.googleapis.com/auth/gmail.modify"
  5719. // ]
  5720. // }
  5721. }
  5722. // method id "gmail.users.messages.send":
  5723. type UsersMessagesSendCall struct {
  5724. s *Service
  5725. userId string
  5726. message *Message
  5727. urlParams_ gensupport.URLParams
  5728. mediaInfo_ *gensupport.MediaInfo
  5729. ctx_ context.Context
  5730. header_ http.Header
  5731. }
  5732. // Send: Sends the specified message to the recipients in the To, Cc,
  5733. // and Bcc headers.
  5734. func (r *UsersMessagesService) Send(userId string, message *Message) *UsersMessagesSendCall {
  5735. c := &UsersMessagesSendCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5736. c.userId = userId
  5737. c.message = message
  5738. return c
  5739. }
  5740. // Media specifies the media to upload in one or more chunks. The chunk
  5741. // size may be controlled by supplying a MediaOption generated by
  5742. // googleapi.ChunkSize. The chunk size defaults to
  5743. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  5744. // upload request will be determined by sniffing the contents of r,
  5745. // unless a MediaOption generated by googleapi.ContentType is
  5746. // supplied.
  5747. // At most one of Media and ResumableMedia may be set.
  5748. func (c *UsersMessagesSendCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesSendCall {
  5749. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  5750. return c
  5751. }
  5752. // ResumableMedia specifies the media to upload in chunks and can be
  5753. // canceled with ctx.
  5754. //
  5755. // Deprecated: use Media instead.
  5756. //
  5757. // At most one of Media and ResumableMedia may be set. mediaType
  5758. // identifies the MIME media type of the upload, such as "image/png". If
  5759. // mediaType is "", it will be auto-detected. The provided ctx will
  5760. // supersede any context previously provided to the Context method.
  5761. func (c *UsersMessagesSendCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesSendCall {
  5762. c.ctx_ = ctx
  5763. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  5764. return c
  5765. }
  5766. // ProgressUpdater provides a callback function that will be called
  5767. // after every chunk. It should be a low-latency function in order to
  5768. // not slow down the upload operation. This should only be called when
  5769. // using ResumableMedia (as opposed to Media).
  5770. func (c *UsersMessagesSendCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesSendCall {
  5771. c.mediaInfo_.SetProgressUpdater(pu)
  5772. return c
  5773. }
  5774. // Fields allows partial responses to be retrieved. See
  5775. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5776. // for more information.
  5777. func (c *UsersMessagesSendCall) Fields(s ...googleapi.Field) *UsersMessagesSendCall {
  5778. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5779. return c
  5780. }
  5781. // Context sets the context to be used in this call's Do method. Any
  5782. // pending HTTP request will be aborted if the provided context is
  5783. // canceled.
  5784. // This context will supersede any context previously provided to the
  5785. // ResumableMedia method.
  5786. func (c *UsersMessagesSendCall) Context(ctx context.Context) *UsersMessagesSendCall {
  5787. c.ctx_ = ctx
  5788. return c
  5789. }
  5790. // Header returns an http.Header that can be modified by the caller to
  5791. // add HTTP headers to the request.
  5792. func (c *UsersMessagesSendCall) Header() http.Header {
  5793. if c.header_ == nil {
  5794. c.header_ = make(http.Header)
  5795. }
  5796. return c.header_
  5797. }
  5798. func (c *UsersMessagesSendCall) doRequest(alt string) (*http.Response, error) {
  5799. reqHeaders := make(http.Header)
  5800. for k, v := range c.header_ {
  5801. reqHeaders[k] = v
  5802. }
  5803. reqHeaders.Set("User-Agent", c.s.userAgent())
  5804. var body io.Reader = nil
  5805. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  5806. if err != nil {
  5807. return nil, err
  5808. }
  5809. reqHeaders.Set("Content-Type", "application/json")
  5810. c.urlParams_.Set("alt", alt)
  5811. c.urlParams_.Set("prettyPrint", "false")
  5812. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/send")
  5813. if c.mediaInfo_ != nil {
  5814. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  5815. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  5816. }
  5817. if body == nil {
  5818. body = new(bytes.Buffer)
  5819. reqHeaders.Set("Content-Type", "application/json")
  5820. }
  5821. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  5822. defer cleanup()
  5823. urls += "?" + c.urlParams_.Encode()
  5824. req, err := http.NewRequest("POST", urls, body)
  5825. if err != nil {
  5826. return nil, err
  5827. }
  5828. req.Header = reqHeaders
  5829. req.GetBody = getBody
  5830. googleapi.Expand(req.URL, map[string]string{
  5831. "userId": c.userId,
  5832. })
  5833. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5834. }
  5835. // Do executes the "gmail.users.messages.send" call.
  5836. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5837. // code is an error. Response headers are in either
  5838. // *Message.ServerResponse.Header or (if a response was returned at all)
  5839. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5840. // check whether the returned error was because http.StatusNotModified
  5841. // was returned.
  5842. func (c *UsersMessagesSendCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  5843. gensupport.SetOptions(c.urlParams_, opts...)
  5844. res, err := c.doRequest("json")
  5845. if res != nil && res.StatusCode == http.StatusNotModified {
  5846. if res.Body != nil {
  5847. res.Body.Close()
  5848. }
  5849. return nil, &googleapi.Error{
  5850. Code: res.StatusCode,
  5851. Header: res.Header,
  5852. }
  5853. }
  5854. if err != nil {
  5855. return nil, err
  5856. }
  5857. defer googleapi.CloseBody(res)
  5858. if err := googleapi.CheckResponse(res); err != nil {
  5859. return nil, err
  5860. }
  5861. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  5862. if rx != nil {
  5863. rx.Client = c.s.client
  5864. rx.UserAgent = c.s.userAgent()
  5865. ctx := c.ctx_
  5866. if ctx == nil {
  5867. ctx = context.TODO()
  5868. }
  5869. res, err = rx.Upload(ctx)
  5870. if err != nil {
  5871. return nil, err
  5872. }
  5873. defer res.Body.Close()
  5874. if err := googleapi.CheckResponse(res); err != nil {
  5875. return nil, err
  5876. }
  5877. }
  5878. ret := &Message{
  5879. ServerResponse: googleapi.ServerResponse{
  5880. Header: res.Header,
  5881. HTTPStatusCode: res.StatusCode,
  5882. },
  5883. }
  5884. target := &ret
  5885. if err := gensupport.DecodeResponse(target, res); err != nil {
  5886. return nil, err
  5887. }
  5888. return ret, nil
  5889. // {
  5890. // "description": "Sends the specified message to the recipients in the To, Cc, and Bcc headers.",
  5891. // "httpMethod": "POST",
  5892. // "id": "gmail.users.messages.send",
  5893. // "mediaUpload": {
  5894. // "accept": [
  5895. // "message/rfc822"
  5896. // ],
  5897. // "maxSize": "35MB",
  5898. // "protocols": {
  5899. // "resumable": {
  5900. // "multipart": true,
  5901. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages/send"
  5902. // },
  5903. // "simple": {
  5904. // "multipart": true,
  5905. // "path": "/upload/gmail/v1/users/{userId}/messages/send"
  5906. // }
  5907. // }
  5908. // },
  5909. // "parameterOrder": [
  5910. // "userId"
  5911. // ],
  5912. // "parameters": {
  5913. // "userId": {
  5914. // "default": "me",
  5915. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5916. // "location": "path",
  5917. // "required": true,
  5918. // "type": "string"
  5919. // }
  5920. // },
  5921. // "path": "{userId}/messages/send",
  5922. // "request": {
  5923. // "$ref": "Message"
  5924. // },
  5925. // "response": {
  5926. // "$ref": "Message"
  5927. // },
  5928. // "scopes": [
  5929. // "https://mail.google.com/",
  5930. // "https://www.googleapis.com/auth/gmail.compose",
  5931. // "https://www.googleapis.com/auth/gmail.modify",
  5932. // "https://www.googleapis.com/auth/gmail.send"
  5933. // ],
  5934. // "supportsMediaUpload": true
  5935. // }
  5936. }
  5937. // method id "gmail.users.messages.trash":
  5938. type UsersMessagesTrashCall struct {
  5939. s *Service
  5940. userId string
  5941. id string
  5942. urlParams_ gensupport.URLParams
  5943. ctx_ context.Context
  5944. header_ http.Header
  5945. }
  5946. // Trash: Moves the specified message to the trash.
  5947. func (r *UsersMessagesService) Trash(userId string, id string) *UsersMessagesTrashCall {
  5948. c := &UsersMessagesTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5949. c.userId = userId
  5950. c.id = id
  5951. return c
  5952. }
  5953. // Fields allows partial responses to be retrieved. See
  5954. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5955. // for more information.
  5956. func (c *UsersMessagesTrashCall) Fields(s ...googleapi.Field) *UsersMessagesTrashCall {
  5957. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5958. return c
  5959. }
  5960. // Context sets the context to be used in this call's Do method. Any
  5961. // pending HTTP request will be aborted if the provided context is
  5962. // canceled.
  5963. func (c *UsersMessagesTrashCall) Context(ctx context.Context) *UsersMessagesTrashCall {
  5964. c.ctx_ = ctx
  5965. return c
  5966. }
  5967. // Header returns an http.Header that can be modified by the caller to
  5968. // add HTTP headers to the request.
  5969. func (c *UsersMessagesTrashCall) Header() http.Header {
  5970. if c.header_ == nil {
  5971. c.header_ = make(http.Header)
  5972. }
  5973. return c.header_
  5974. }
  5975. func (c *UsersMessagesTrashCall) doRequest(alt string) (*http.Response, error) {
  5976. reqHeaders := make(http.Header)
  5977. for k, v := range c.header_ {
  5978. reqHeaders[k] = v
  5979. }
  5980. reqHeaders.Set("User-Agent", c.s.userAgent())
  5981. var body io.Reader = nil
  5982. c.urlParams_.Set("alt", alt)
  5983. c.urlParams_.Set("prettyPrint", "false")
  5984. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/trash")
  5985. urls += "?" + c.urlParams_.Encode()
  5986. req, err := http.NewRequest("POST", urls, body)
  5987. if err != nil {
  5988. return nil, err
  5989. }
  5990. req.Header = reqHeaders
  5991. googleapi.Expand(req.URL, map[string]string{
  5992. "userId": c.userId,
  5993. "id": c.id,
  5994. })
  5995. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5996. }
  5997. // Do executes the "gmail.users.messages.trash" call.
  5998. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  5999. // code is an error. Response headers are in either
  6000. // *Message.ServerResponse.Header or (if a response was returned at all)
  6001. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  6002. // check whether the returned error was because http.StatusNotModified
  6003. // was returned.
  6004. func (c *UsersMessagesTrashCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  6005. gensupport.SetOptions(c.urlParams_, opts...)
  6006. res, err := c.doRequest("json")
  6007. if res != nil && res.StatusCode == http.StatusNotModified {
  6008. if res.Body != nil {
  6009. res.Body.Close()
  6010. }
  6011. return nil, &googleapi.Error{
  6012. Code: res.StatusCode,
  6013. Header: res.Header,
  6014. }
  6015. }
  6016. if err != nil {
  6017. return nil, err
  6018. }
  6019. defer googleapi.CloseBody(res)
  6020. if err := googleapi.CheckResponse(res); err != nil {
  6021. return nil, err
  6022. }
  6023. ret := &Message{
  6024. ServerResponse: googleapi.ServerResponse{
  6025. Header: res.Header,
  6026. HTTPStatusCode: res.StatusCode,
  6027. },
  6028. }
  6029. target := &ret
  6030. if err := gensupport.DecodeResponse(target, res); err != nil {
  6031. return nil, err
  6032. }
  6033. return ret, nil
  6034. // {
  6035. // "description": "Moves the specified message to the trash.",
  6036. // "httpMethod": "POST",
  6037. // "id": "gmail.users.messages.trash",
  6038. // "parameterOrder": [
  6039. // "userId",
  6040. // "id"
  6041. // ],
  6042. // "parameters": {
  6043. // "id": {
  6044. // "description": "The ID of the message to Trash.",
  6045. // "location": "path",
  6046. // "required": true,
  6047. // "type": "string"
  6048. // },
  6049. // "userId": {
  6050. // "default": "me",
  6051. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  6052. // "location": "path",
  6053. // "required": true,
  6054. // "type": "string"
  6055. // }
  6056. // },
  6057. // "path": "{userId}/messages/{id}/trash",
  6058. // "response": {
  6059. // "$ref": "Message"
  6060. // },
  6061. // "scopes": [
  6062. // "https://mail.google.com/",
  6063. // "https://www.googleapis.com/auth/gmail.modify"
  6064. // ]
  6065. // }
  6066. }
  6067. // method id "gmail.users.messages.untrash":
  6068. type UsersMessagesUntrashCall struct {
  6069. s *Service
  6070. userId string
  6071. id string
  6072. urlParams_ gensupport.URLParams
  6073. ctx_ context.Context
  6074. header_ http.Header
  6075. }
  6076. // Untrash: Removes the specified message from the trash.
  6077. func (r *UsersMessagesService) Untrash(userId string, id string) *UsersMessagesUntrashCall {
  6078. c := &UsersMessagesUntrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6079. c.userId = userId
  6080. c.id = id
  6081. return c
  6082. }
  6083. // Fields allows partial responses to be retrieved. See
  6084. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6085. // for more information.
  6086. func (c *UsersMessagesUntrashCall) Fields(s ...googleapi.Field) *UsersMessagesUntrashCall {
  6087. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6088. return c
  6089. }
  6090. // Context sets the context to be used in this call's Do method. Any
  6091. // pending HTTP request will be aborted if the provided context is
  6092. // canceled.
  6093. func (c *UsersMessagesUntrashCall) Context(ctx context.Context) *UsersMessagesUntrashCall {
  6094. c.ctx_ = ctx
  6095. return c
  6096. }
  6097. // Header returns an http.Header that can be modified by the caller to
  6098. // add HTTP headers to the request.
  6099. func (c *UsersMessagesUntrashCall) Header() http.Header {
  6100. if c.header_ == nil {
  6101. c.header_ = make(http.Header)
  6102. }
  6103. return c.header_
  6104. }
  6105. func (c *UsersMessagesUntrashCall) doRequest(alt string) (*http.Response, error) {
  6106. reqHeaders := make(http.Header)
  6107. for k, v := range c.header_ {
  6108. reqHeaders[k] = v
  6109. }
  6110. reqHeaders.Set("User-Agent", c.s.userAgent())
  6111. var body io.Reader = nil
  6112. c.urlParams_.Set("alt", alt)
  6113. c.urlParams_.Set("prettyPrint", "false")
  6114. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/untrash")
  6115. urls += "?" + c.urlParams_.Encode()
  6116. req, err := http.NewRequest("POST", urls, body)
  6117. if err != nil {
  6118. return nil, err
  6119. }
  6120. req.Header = reqHeaders
  6121. googleapi.Expand(req.URL, map[string]string{
  6122. "userId": c.userId,
  6123. "id": c.id,
  6124. })
  6125. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6126. }
  6127. // Do executes the "gmail.users.messages.untrash" call.
  6128. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  6129. // code is an error. Response headers are in either
  6130. // *Message.ServerResponse.Header or (if a response was returned at all)
  6131. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  6132. // check whether the returned error was because http.StatusNotModified
  6133. // was returned.
  6134. func (c *UsersMessagesUntrashCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  6135. gensupport.SetOptions(c.urlParams_, opts...)
  6136. res, err := c.doRequest("json")
  6137. if res != nil && res.StatusCode == http.StatusNotModified {
  6138. if res.Body != nil {
  6139. res.Body.Close()
  6140. }
  6141. return nil, &googleapi.Error{
  6142. Code: res.StatusCode,
  6143. Header: res.Header,
  6144. }
  6145. }
  6146. if err != nil {
  6147. return nil, err
  6148. }
  6149. defer googleapi.CloseBody(res)
  6150. if err := googleapi.CheckResponse(res); err != nil {
  6151. return nil, err
  6152. }
  6153. ret := &Message{
  6154. ServerResponse: googleapi.ServerResponse{
  6155. Header: res.Header,
  6156. HTTPStatusCode: res.StatusCode,
  6157. },
  6158. }
  6159. target := &ret
  6160. if err := gensupport.DecodeResponse(target, res); err != nil {
  6161. return nil, err
  6162. }
  6163. return ret, nil
  6164. // {
  6165. // "description": "Removes the specified message from the trash.",
  6166. // "httpMethod": "POST",
  6167. // "id": "gmail.users.messages.untrash",
  6168. // "parameterOrder": [
  6169. // "userId",
  6170. // "id"
  6171. // ],
  6172. // "parameters": {
  6173. // "id": {
  6174. // "description": "The ID of the message to remove from Trash.",
  6175. // "location": "path",
  6176. // "required": true,
  6177. // "type": "string"
  6178. // },
  6179. // "userId": {
  6180. // "default": "me",
  6181. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  6182. // "location": "path",
  6183. // "required": true,
  6184. // "type": "string"
  6185. // }
  6186. // },
  6187. // "path": "{userId}/messages/{id}/untrash",
  6188. // "response": {
  6189. // "$ref": "Message"
  6190. // },
  6191. // "scopes": [
  6192. // "https://mail.google.com/",
  6193. // "https://www.googleapis.com/auth/gmail.modify"
  6194. // ]
  6195. // }
  6196. }
  6197. // method id "gmail.users.messages.attachments.get":
  6198. type UsersMessagesAttachmentsGetCall struct {
  6199. s *Service
  6200. userId string
  6201. messageId string
  6202. id string
  6203. urlParams_ gensupport.URLParams
  6204. ifNoneMatch_ string
  6205. ctx_ context.Context
  6206. header_ http.Header
  6207. }
  6208. // Get: Gets the specified message attachment.
  6209. func (r *UsersMessagesAttachmentsService) Get(userId string, messageId string, id string) *UsersMessagesAttachmentsGetCall {
  6210. c := &UsersMessagesAttachmentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6211. c.userId = userId
  6212. c.messageId = messageId
  6213. c.id = id
  6214. return c
  6215. }
  6216. // Fields allows partial responses to be retrieved. See
  6217. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6218. // for more information.
  6219. func (c *UsersMessagesAttachmentsGetCall) Fields(s ...googleapi.Field) *UsersMessagesAttachmentsGetCall {
  6220. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6221. return c
  6222. }
  6223. // IfNoneMatch sets the optional parameter which makes the operation
  6224. // fail if the object's ETag matches the given value. This is useful for
  6225. // getting updates only after the object has changed since the last
  6226. // request. Use googleapi.IsNotModified to check whether the response
  6227. // error from Do is the result of In-None-Match.
  6228. func (c *UsersMessagesAttachmentsGetCall) IfNoneMatch(entityTag string) *UsersMessagesAttachmentsGetCall {
  6229. c.ifNoneMatch_ = entityTag
  6230. return c
  6231. }
  6232. // Context sets the context to be used in this call's Do method. Any
  6233. // pending HTTP request will be aborted if the provided context is
  6234. // canceled.
  6235. func (c *UsersMessagesAttachmentsGetCall) Context(ctx context.Context) *UsersMessagesAttachmentsGetCall {
  6236. c.ctx_ = ctx
  6237. return c
  6238. }
  6239. // Header returns an http.Header that can be modified by the caller to
  6240. // add HTTP headers to the request.
  6241. func (c *UsersMessagesAttachmentsGetCall) Header() http.Header {
  6242. if c.header_ == nil {
  6243. c.header_ = make(http.Header)
  6244. }
  6245. return c.header_
  6246. }
  6247. func (c *UsersMessagesAttachmentsGetCall) doRequest(alt string) (*http.Response, error) {
  6248. reqHeaders := make(http.Header)
  6249. for k, v := range c.header_ {
  6250. reqHeaders[k] = v
  6251. }
  6252. reqHeaders.Set("User-Agent", c.s.userAgent())
  6253. if c.ifNoneMatch_ != "" {
  6254. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6255. }
  6256. var body io.Reader = nil
  6257. c.urlParams_.Set("alt", alt)
  6258. c.urlParams_.Set("prettyPrint", "false")
  6259. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{messageId}/attachments/{id}")
  6260. urls += "?" + c.urlParams_.Encode()
  6261. req, err := http.NewRequest("GET", urls, body)
  6262. if err != nil {
  6263. return nil, err
  6264. }
  6265. req.Header = reqHeaders
  6266. googleapi.Expand(req.URL, map[string]string{
  6267. "userId": c.userId,
  6268. "messageId": c.messageId,
  6269. "id": c.id,
  6270. })
  6271. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6272. }
  6273. // Do executes the "gmail.users.messages.attachments.get" call.
  6274. // Exactly one of *MessagePartBody or error will be non-nil. Any non-2xx
  6275. // status code is an error. Response headers are in either
  6276. // *MessagePartBody.ServerResponse.Header or (if a response was returned
  6277. // at all) in error.(*googleapi.Error).Header. Use
  6278. // googleapi.IsNotModified to check whether the returned error was
  6279. // because http.StatusNotModified was returned.
  6280. func (c *UsersMessagesAttachmentsGetCall) Do(opts ...googleapi.CallOption) (*MessagePartBody, error) {
  6281. gensupport.SetOptions(c.urlParams_, opts...)
  6282. res, err := c.doRequest("json")
  6283. if res != nil && res.StatusCode == http.StatusNotModified {
  6284. if res.Body != nil {
  6285. res.Body.Close()
  6286. }
  6287. return nil, &googleapi.Error{
  6288. Code: res.StatusCode,
  6289. Header: res.Header,
  6290. }
  6291. }
  6292. if err != nil {
  6293. return nil, err
  6294. }
  6295. defer googleapi.CloseBody(res)
  6296. if err := googleapi.CheckResponse(res); err != nil {
  6297. return nil, err
  6298. }
  6299. ret := &MessagePartBody{
  6300. ServerResponse: googleapi.ServerResponse{
  6301. Header: res.Header,
  6302. HTTPStatusCode: res.StatusCode,
  6303. },
  6304. }
  6305. target := &ret
  6306. if err := gensupport.DecodeResponse(target, res); err != nil {
  6307. return nil, err
  6308. }
  6309. return ret, nil
  6310. // {
  6311. // "description": "Gets the specified message attachment.",
  6312. // "httpMethod": "GET",
  6313. // "id": "gmail.users.messages.attachments.get",
  6314. // "parameterOrder": [
  6315. // "userId",
  6316. // "messageId",
  6317. // "id"
  6318. // ],
  6319. // "parameters": {
  6320. // "id": {
  6321. // "description": "The ID of the attachment.",
  6322. // "location": "path",
  6323. // "required": true,
  6324. // "type": "string"
  6325. // },
  6326. // "messageId": {
  6327. // "description": "The ID of the message containing the attachment.",
  6328. // "location": "path",
  6329. // "required": true,
  6330. // "type": "string"
  6331. // },
  6332. // "userId": {
  6333. // "default": "me",
  6334. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  6335. // "location": "path",
  6336. // "required": true,
  6337. // "type": "string"
  6338. // }
  6339. // },
  6340. // "path": "{userId}/messages/{messageId}/attachments/{id}",
  6341. // "response": {
  6342. // "$ref": "MessagePartBody"
  6343. // },
  6344. // "scopes": [
  6345. // "https://mail.google.com/",
  6346. // "https://www.googleapis.com/auth/gmail.modify",
  6347. // "https://www.googleapis.com/auth/gmail.readonly"
  6348. // ]
  6349. // }
  6350. }
  6351. // method id "gmail.users.settings.getAutoForwarding":
  6352. type UsersSettingsGetAutoForwardingCall struct {
  6353. s *Service
  6354. userId string
  6355. urlParams_ gensupport.URLParams
  6356. ifNoneMatch_ string
  6357. ctx_ context.Context
  6358. header_ http.Header
  6359. }
  6360. // GetAutoForwarding: Gets the auto-forwarding setting for the specified
  6361. // account.
  6362. func (r *UsersSettingsService) GetAutoForwarding(userId string) *UsersSettingsGetAutoForwardingCall {
  6363. c := &UsersSettingsGetAutoForwardingCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6364. c.userId = userId
  6365. return c
  6366. }
  6367. // Fields allows partial responses to be retrieved. See
  6368. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6369. // for more information.
  6370. func (c *UsersSettingsGetAutoForwardingCall) Fields(s ...googleapi.Field) *UsersSettingsGetAutoForwardingCall {
  6371. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6372. return c
  6373. }
  6374. // IfNoneMatch sets the optional parameter which makes the operation
  6375. // fail if the object's ETag matches the given value. This is useful for
  6376. // getting updates only after the object has changed since the last
  6377. // request. Use googleapi.IsNotModified to check whether the response
  6378. // error from Do is the result of In-None-Match.
  6379. func (c *UsersSettingsGetAutoForwardingCall) IfNoneMatch(entityTag string) *UsersSettingsGetAutoForwardingCall {
  6380. c.ifNoneMatch_ = entityTag
  6381. return c
  6382. }
  6383. // Context sets the context to be used in this call's Do method. Any
  6384. // pending HTTP request will be aborted if the provided context is
  6385. // canceled.
  6386. func (c *UsersSettingsGetAutoForwardingCall) Context(ctx context.Context) *UsersSettingsGetAutoForwardingCall {
  6387. c.ctx_ = ctx
  6388. return c
  6389. }
  6390. // Header returns an http.Header that can be modified by the caller to
  6391. // add HTTP headers to the request.
  6392. func (c *UsersSettingsGetAutoForwardingCall) Header() http.Header {
  6393. if c.header_ == nil {
  6394. c.header_ = make(http.Header)
  6395. }
  6396. return c.header_
  6397. }
  6398. func (c *UsersSettingsGetAutoForwardingCall) doRequest(alt string) (*http.Response, error) {
  6399. reqHeaders := make(http.Header)
  6400. for k, v := range c.header_ {
  6401. reqHeaders[k] = v
  6402. }
  6403. reqHeaders.Set("User-Agent", c.s.userAgent())
  6404. if c.ifNoneMatch_ != "" {
  6405. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6406. }
  6407. var body io.Reader = nil
  6408. c.urlParams_.Set("alt", alt)
  6409. c.urlParams_.Set("prettyPrint", "false")
  6410. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/autoForwarding")
  6411. urls += "?" + c.urlParams_.Encode()
  6412. req, err := http.NewRequest("GET", urls, body)
  6413. if err != nil {
  6414. return nil, err
  6415. }
  6416. req.Header = reqHeaders
  6417. googleapi.Expand(req.URL, map[string]string{
  6418. "userId": c.userId,
  6419. })
  6420. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6421. }
  6422. // Do executes the "gmail.users.settings.getAutoForwarding" call.
  6423. // Exactly one of *AutoForwarding or error will be non-nil. Any non-2xx
  6424. // status code is an error. Response headers are in either
  6425. // *AutoForwarding.ServerResponse.Header or (if a response was returned
  6426. // at all) in error.(*googleapi.Error).Header. Use
  6427. // googleapi.IsNotModified to check whether the returned error was
  6428. // because http.StatusNotModified was returned.
  6429. func (c *UsersSettingsGetAutoForwardingCall) Do(opts ...googleapi.CallOption) (*AutoForwarding, error) {
  6430. gensupport.SetOptions(c.urlParams_, opts...)
  6431. res, err := c.doRequest("json")
  6432. if res != nil && res.StatusCode == http.StatusNotModified {
  6433. if res.Body != nil {
  6434. res.Body.Close()
  6435. }
  6436. return nil, &googleapi.Error{
  6437. Code: res.StatusCode,
  6438. Header: res.Header,
  6439. }
  6440. }
  6441. if err != nil {
  6442. return nil, err
  6443. }
  6444. defer googleapi.CloseBody(res)
  6445. if err := googleapi.CheckResponse(res); err != nil {
  6446. return nil, err
  6447. }
  6448. ret := &AutoForwarding{
  6449. ServerResponse: googleapi.ServerResponse{
  6450. Header: res.Header,
  6451. HTTPStatusCode: res.StatusCode,
  6452. },
  6453. }
  6454. target := &ret
  6455. if err := gensupport.DecodeResponse(target, res); err != nil {
  6456. return nil, err
  6457. }
  6458. return ret, nil
  6459. // {
  6460. // "description": "Gets the auto-forwarding setting for the specified account.",
  6461. // "httpMethod": "GET",
  6462. // "id": "gmail.users.settings.getAutoForwarding",
  6463. // "parameterOrder": [
  6464. // "userId"
  6465. // ],
  6466. // "parameters": {
  6467. // "userId": {
  6468. // "default": "me",
  6469. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6470. // "location": "path",
  6471. // "required": true,
  6472. // "type": "string"
  6473. // }
  6474. // },
  6475. // "path": "{userId}/settings/autoForwarding",
  6476. // "response": {
  6477. // "$ref": "AutoForwarding"
  6478. // },
  6479. // "scopes": [
  6480. // "https://mail.google.com/",
  6481. // "https://www.googleapis.com/auth/gmail.modify",
  6482. // "https://www.googleapis.com/auth/gmail.readonly",
  6483. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6484. // ]
  6485. // }
  6486. }
  6487. // method id "gmail.users.settings.getImap":
  6488. type UsersSettingsGetImapCall struct {
  6489. s *Service
  6490. userId string
  6491. urlParams_ gensupport.URLParams
  6492. ifNoneMatch_ string
  6493. ctx_ context.Context
  6494. header_ http.Header
  6495. }
  6496. // GetImap: Gets IMAP settings.
  6497. func (r *UsersSettingsService) GetImap(userId string) *UsersSettingsGetImapCall {
  6498. c := &UsersSettingsGetImapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6499. c.userId = userId
  6500. return c
  6501. }
  6502. // Fields allows partial responses to be retrieved. See
  6503. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6504. // for more information.
  6505. func (c *UsersSettingsGetImapCall) Fields(s ...googleapi.Field) *UsersSettingsGetImapCall {
  6506. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6507. return c
  6508. }
  6509. // IfNoneMatch sets the optional parameter which makes the operation
  6510. // fail if the object's ETag matches the given value. This is useful for
  6511. // getting updates only after the object has changed since the last
  6512. // request. Use googleapi.IsNotModified to check whether the response
  6513. // error from Do is the result of In-None-Match.
  6514. func (c *UsersSettingsGetImapCall) IfNoneMatch(entityTag string) *UsersSettingsGetImapCall {
  6515. c.ifNoneMatch_ = entityTag
  6516. return c
  6517. }
  6518. // Context sets the context to be used in this call's Do method. Any
  6519. // pending HTTP request will be aborted if the provided context is
  6520. // canceled.
  6521. func (c *UsersSettingsGetImapCall) Context(ctx context.Context) *UsersSettingsGetImapCall {
  6522. c.ctx_ = ctx
  6523. return c
  6524. }
  6525. // Header returns an http.Header that can be modified by the caller to
  6526. // add HTTP headers to the request.
  6527. func (c *UsersSettingsGetImapCall) Header() http.Header {
  6528. if c.header_ == nil {
  6529. c.header_ = make(http.Header)
  6530. }
  6531. return c.header_
  6532. }
  6533. func (c *UsersSettingsGetImapCall) doRequest(alt string) (*http.Response, error) {
  6534. reqHeaders := make(http.Header)
  6535. for k, v := range c.header_ {
  6536. reqHeaders[k] = v
  6537. }
  6538. reqHeaders.Set("User-Agent", c.s.userAgent())
  6539. if c.ifNoneMatch_ != "" {
  6540. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6541. }
  6542. var body io.Reader = nil
  6543. c.urlParams_.Set("alt", alt)
  6544. c.urlParams_.Set("prettyPrint", "false")
  6545. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/imap")
  6546. urls += "?" + c.urlParams_.Encode()
  6547. req, err := http.NewRequest("GET", urls, body)
  6548. if err != nil {
  6549. return nil, err
  6550. }
  6551. req.Header = reqHeaders
  6552. googleapi.Expand(req.URL, map[string]string{
  6553. "userId": c.userId,
  6554. })
  6555. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6556. }
  6557. // Do executes the "gmail.users.settings.getImap" call.
  6558. // Exactly one of *ImapSettings or error will be non-nil. Any non-2xx
  6559. // status code is an error. Response headers are in either
  6560. // *ImapSettings.ServerResponse.Header or (if a response was returned at
  6561. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  6562. // to check whether the returned error was because
  6563. // http.StatusNotModified was returned.
  6564. func (c *UsersSettingsGetImapCall) Do(opts ...googleapi.CallOption) (*ImapSettings, error) {
  6565. gensupport.SetOptions(c.urlParams_, opts...)
  6566. res, err := c.doRequest("json")
  6567. if res != nil && res.StatusCode == http.StatusNotModified {
  6568. if res.Body != nil {
  6569. res.Body.Close()
  6570. }
  6571. return nil, &googleapi.Error{
  6572. Code: res.StatusCode,
  6573. Header: res.Header,
  6574. }
  6575. }
  6576. if err != nil {
  6577. return nil, err
  6578. }
  6579. defer googleapi.CloseBody(res)
  6580. if err := googleapi.CheckResponse(res); err != nil {
  6581. return nil, err
  6582. }
  6583. ret := &ImapSettings{
  6584. ServerResponse: googleapi.ServerResponse{
  6585. Header: res.Header,
  6586. HTTPStatusCode: res.StatusCode,
  6587. },
  6588. }
  6589. target := &ret
  6590. if err := gensupport.DecodeResponse(target, res); err != nil {
  6591. return nil, err
  6592. }
  6593. return ret, nil
  6594. // {
  6595. // "description": "Gets IMAP settings.",
  6596. // "httpMethod": "GET",
  6597. // "id": "gmail.users.settings.getImap",
  6598. // "parameterOrder": [
  6599. // "userId"
  6600. // ],
  6601. // "parameters": {
  6602. // "userId": {
  6603. // "default": "me",
  6604. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6605. // "location": "path",
  6606. // "required": true,
  6607. // "type": "string"
  6608. // }
  6609. // },
  6610. // "path": "{userId}/settings/imap",
  6611. // "response": {
  6612. // "$ref": "ImapSettings"
  6613. // },
  6614. // "scopes": [
  6615. // "https://mail.google.com/",
  6616. // "https://www.googleapis.com/auth/gmail.modify",
  6617. // "https://www.googleapis.com/auth/gmail.readonly",
  6618. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6619. // ]
  6620. // }
  6621. }
  6622. // method id "gmail.users.settings.getPop":
  6623. type UsersSettingsGetPopCall struct {
  6624. s *Service
  6625. userId string
  6626. urlParams_ gensupport.URLParams
  6627. ifNoneMatch_ string
  6628. ctx_ context.Context
  6629. header_ http.Header
  6630. }
  6631. // GetPop: Gets POP settings.
  6632. func (r *UsersSettingsService) GetPop(userId string) *UsersSettingsGetPopCall {
  6633. c := &UsersSettingsGetPopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6634. c.userId = userId
  6635. return c
  6636. }
  6637. // Fields allows partial responses to be retrieved. See
  6638. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6639. // for more information.
  6640. func (c *UsersSettingsGetPopCall) Fields(s ...googleapi.Field) *UsersSettingsGetPopCall {
  6641. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6642. return c
  6643. }
  6644. // IfNoneMatch sets the optional parameter which makes the operation
  6645. // fail if the object's ETag matches the given value. This is useful for
  6646. // getting updates only after the object has changed since the last
  6647. // request. Use googleapi.IsNotModified to check whether the response
  6648. // error from Do is the result of In-None-Match.
  6649. func (c *UsersSettingsGetPopCall) IfNoneMatch(entityTag string) *UsersSettingsGetPopCall {
  6650. c.ifNoneMatch_ = entityTag
  6651. return c
  6652. }
  6653. // Context sets the context to be used in this call's Do method. Any
  6654. // pending HTTP request will be aborted if the provided context is
  6655. // canceled.
  6656. func (c *UsersSettingsGetPopCall) Context(ctx context.Context) *UsersSettingsGetPopCall {
  6657. c.ctx_ = ctx
  6658. return c
  6659. }
  6660. // Header returns an http.Header that can be modified by the caller to
  6661. // add HTTP headers to the request.
  6662. func (c *UsersSettingsGetPopCall) Header() http.Header {
  6663. if c.header_ == nil {
  6664. c.header_ = make(http.Header)
  6665. }
  6666. return c.header_
  6667. }
  6668. func (c *UsersSettingsGetPopCall) doRequest(alt string) (*http.Response, error) {
  6669. reqHeaders := make(http.Header)
  6670. for k, v := range c.header_ {
  6671. reqHeaders[k] = v
  6672. }
  6673. reqHeaders.Set("User-Agent", c.s.userAgent())
  6674. if c.ifNoneMatch_ != "" {
  6675. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6676. }
  6677. var body io.Reader = nil
  6678. c.urlParams_.Set("alt", alt)
  6679. c.urlParams_.Set("prettyPrint", "false")
  6680. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/pop")
  6681. urls += "?" + c.urlParams_.Encode()
  6682. req, err := http.NewRequest("GET", urls, body)
  6683. if err != nil {
  6684. return nil, err
  6685. }
  6686. req.Header = reqHeaders
  6687. googleapi.Expand(req.URL, map[string]string{
  6688. "userId": c.userId,
  6689. })
  6690. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6691. }
  6692. // Do executes the "gmail.users.settings.getPop" call.
  6693. // Exactly one of *PopSettings or error will be non-nil. Any non-2xx
  6694. // status code is an error. Response headers are in either
  6695. // *PopSettings.ServerResponse.Header or (if a response was returned at
  6696. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  6697. // to check whether the returned error was because
  6698. // http.StatusNotModified was returned.
  6699. func (c *UsersSettingsGetPopCall) Do(opts ...googleapi.CallOption) (*PopSettings, error) {
  6700. gensupport.SetOptions(c.urlParams_, opts...)
  6701. res, err := c.doRequest("json")
  6702. if res != nil && res.StatusCode == http.StatusNotModified {
  6703. if res.Body != nil {
  6704. res.Body.Close()
  6705. }
  6706. return nil, &googleapi.Error{
  6707. Code: res.StatusCode,
  6708. Header: res.Header,
  6709. }
  6710. }
  6711. if err != nil {
  6712. return nil, err
  6713. }
  6714. defer googleapi.CloseBody(res)
  6715. if err := googleapi.CheckResponse(res); err != nil {
  6716. return nil, err
  6717. }
  6718. ret := &PopSettings{
  6719. ServerResponse: googleapi.ServerResponse{
  6720. Header: res.Header,
  6721. HTTPStatusCode: res.StatusCode,
  6722. },
  6723. }
  6724. target := &ret
  6725. if err := gensupport.DecodeResponse(target, res); err != nil {
  6726. return nil, err
  6727. }
  6728. return ret, nil
  6729. // {
  6730. // "description": "Gets POP settings.",
  6731. // "httpMethod": "GET",
  6732. // "id": "gmail.users.settings.getPop",
  6733. // "parameterOrder": [
  6734. // "userId"
  6735. // ],
  6736. // "parameters": {
  6737. // "userId": {
  6738. // "default": "me",
  6739. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6740. // "location": "path",
  6741. // "required": true,
  6742. // "type": "string"
  6743. // }
  6744. // },
  6745. // "path": "{userId}/settings/pop",
  6746. // "response": {
  6747. // "$ref": "PopSettings"
  6748. // },
  6749. // "scopes": [
  6750. // "https://mail.google.com/",
  6751. // "https://www.googleapis.com/auth/gmail.modify",
  6752. // "https://www.googleapis.com/auth/gmail.readonly",
  6753. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6754. // ]
  6755. // }
  6756. }
  6757. // method id "gmail.users.settings.getVacation":
  6758. type UsersSettingsGetVacationCall struct {
  6759. s *Service
  6760. userId string
  6761. urlParams_ gensupport.URLParams
  6762. ifNoneMatch_ string
  6763. ctx_ context.Context
  6764. header_ http.Header
  6765. }
  6766. // GetVacation: Gets vacation responder settings.
  6767. func (r *UsersSettingsService) GetVacation(userId string) *UsersSettingsGetVacationCall {
  6768. c := &UsersSettingsGetVacationCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6769. c.userId = userId
  6770. return c
  6771. }
  6772. // Fields allows partial responses to be retrieved. See
  6773. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6774. // for more information.
  6775. func (c *UsersSettingsGetVacationCall) Fields(s ...googleapi.Field) *UsersSettingsGetVacationCall {
  6776. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6777. return c
  6778. }
  6779. // IfNoneMatch sets the optional parameter which makes the operation
  6780. // fail if the object's ETag matches the given value. This is useful for
  6781. // getting updates only after the object has changed since the last
  6782. // request. Use googleapi.IsNotModified to check whether the response
  6783. // error from Do is the result of In-None-Match.
  6784. func (c *UsersSettingsGetVacationCall) IfNoneMatch(entityTag string) *UsersSettingsGetVacationCall {
  6785. c.ifNoneMatch_ = entityTag
  6786. return c
  6787. }
  6788. // Context sets the context to be used in this call's Do method. Any
  6789. // pending HTTP request will be aborted if the provided context is
  6790. // canceled.
  6791. func (c *UsersSettingsGetVacationCall) Context(ctx context.Context) *UsersSettingsGetVacationCall {
  6792. c.ctx_ = ctx
  6793. return c
  6794. }
  6795. // Header returns an http.Header that can be modified by the caller to
  6796. // add HTTP headers to the request.
  6797. func (c *UsersSettingsGetVacationCall) Header() http.Header {
  6798. if c.header_ == nil {
  6799. c.header_ = make(http.Header)
  6800. }
  6801. return c.header_
  6802. }
  6803. func (c *UsersSettingsGetVacationCall) doRequest(alt string) (*http.Response, error) {
  6804. reqHeaders := make(http.Header)
  6805. for k, v := range c.header_ {
  6806. reqHeaders[k] = v
  6807. }
  6808. reqHeaders.Set("User-Agent", c.s.userAgent())
  6809. if c.ifNoneMatch_ != "" {
  6810. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  6811. }
  6812. var body io.Reader = nil
  6813. c.urlParams_.Set("alt", alt)
  6814. c.urlParams_.Set("prettyPrint", "false")
  6815. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/vacation")
  6816. urls += "?" + c.urlParams_.Encode()
  6817. req, err := http.NewRequest("GET", urls, body)
  6818. if err != nil {
  6819. return nil, err
  6820. }
  6821. req.Header = reqHeaders
  6822. googleapi.Expand(req.URL, map[string]string{
  6823. "userId": c.userId,
  6824. })
  6825. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6826. }
  6827. // Do executes the "gmail.users.settings.getVacation" call.
  6828. // Exactly one of *VacationSettings or error will be non-nil. Any
  6829. // non-2xx status code is an error. Response headers are in either
  6830. // *VacationSettings.ServerResponse.Header or (if a response was
  6831. // returned at all) in error.(*googleapi.Error).Header. Use
  6832. // googleapi.IsNotModified to check whether the returned error was
  6833. // because http.StatusNotModified was returned.
  6834. func (c *UsersSettingsGetVacationCall) Do(opts ...googleapi.CallOption) (*VacationSettings, error) {
  6835. gensupport.SetOptions(c.urlParams_, opts...)
  6836. res, err := c.doRequest("json")
  6837. if res != nil && res.StatusCode == http.StatusNotModified {
  6838. if res.Body != nil {
  6839. res.Body.Close()
  6840. }
  6841. return nil, &googleapi.Error{
  6842. Code: res.StatusCode,
  6843. Header: res.Header,
  6844. }
  6845. }
  6846. if err != nil {
  6847. return nil, err
  6848. }
  6849. defer googleapi.CloseBody(res)
  6850. if err := googleapi.CheckResponse(res); err != nil {
  6851. return nil, err
  6852. }
  6853. ret := &VacationSettings{
  6854. ServerResponse: googleapi.ServerResponse{
  6855. Header: res.Header,
  6856. HTTPStatusCode: res.StatusCode,
  6857. },
  6858. }
  6859. target := &ret
  6860. if err := gensupport.DecodeResponse(target, res); err != nil {
  6861. return nil, err
  6862. }
  6863. return ret, nil
  6864. // {
  6865. // "description": "Gets vacation responder settings.",
  6866. // "httpMethod": "GET",
  6867. // "id": "gmail.users.settings.getVacation",
  6868. // "parameterOrder": [
  6869. // "userId"
  6870. // ],
  6871. // "parameters": {
  6872. // "userId": {
  6873. // "default": "me",
  6874. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  6875. // "location": "path",
  6876. // "required": true,
  6877. // "type": "string"
  6878. // }
  6879. // },
  6880. // "path": "{userId}/settings/vacation",
  6881. // "response": {
  6882. // "$ref": "VacationSettings"
  6883. // },
  6884. // "scopes": [
  6885. // "https://mail.google.com/",
  6886. // "https://www.googleapis.com/auth/gmail.modify",
  6887. // "https://www.googleapis.com/auth/gmail.readonly",
  6888. // "https://www.googleapis.com/auth/gmail.settings.basic"
  6889. // ]
  6890. // }
  6891. }
  6892. // method id "gmail.users.settings.updateAutoForwarding":
  6893. type UsersSettingsUpdateAutoForwardingCall struct {
  6894. s *Service
  6895. userId string
  6896. autoforwarding *AutoForwarding
  6897. urlParams_ gensupport.URLParams
  6898. ctx_ context.Context
  6899. header_ http.Header
  6900. }
  6901. // UpdateAutoForwarding: Updates the auto-forwarding setting for the
  6902. // specified account. A verified forwarding address must be specified
  6903. // when auto-forwarding is enabled.
  6904. //
  6905. // This method is only available to service account clients that have
  6906. // been delegated domain-wide authority.
  6907. func (r *UsersSettingsService) UpdateAutoForwarding(userId string, autoforwarding *AutoForwarding) *UsersSettingsUpdateAutoForwardingCall {
  6908. c := &UsersSettingsUpdateAutoForwardingCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  6909. c.userId = userId
  6910. c.autoforwarding = autoforwarding
  6911. return c
  6912. }
  6913. // Fields allows partial responses to be retrieved. See
  6914. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  6915. // for more information.
  6916. func (c *UsersSettingsUpdateAutoForwardingCall) Fields(s ...googleapi.Field) *UsersSettingsUpdateAutoForwardingCall {
  6917. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  6918. return c
  6919. }
  6920. // Context sets the context to be used in this call's Do method. Any
  6921. // pending HTTP request will be aborted if the provided context is
  6922. // canceled.
  6923. func (c *UsersSettingsUpdateAutoForwardingCall) Context(ctx context.Context) *UsersSettingsUpdateAutoForwardingCall {
  6924. c.ctx_ = ctx
  6925. return c
  6926. }
  6927. // Header returns an http.Header that can be modified by the caller to
  6928. // add HTTP headers to the request.
  6929. func (c *UsersSettingsUpdateAutoForwardingCall) Header() http.Header {
  6930. if c.header_ == nil {
  6931. c.header_ = make(http.Header)
  6932. }
  6933. return c.header_
  6934. }
  6935. func (c *UsersSettingsUpdateAutoForwardingCall) doRequest(alt string) (*http.Response, error) {
  6936. reqHeaders := make(http.Header)
  6937. for k, v := range c.header_ {
  6938. reqHeaders[k] = v
  6939. }
  6940. reqHeaders.Set("User-Agent", c.s.userAgent())
  6941. var body io.Reader = nil
  6942. body, err := googleapi.WithoutDataWrapper.JSONReader(c.autoforwarding)
  6943. if err != nil {
  6944. return nil, err
  6945. }
  6946. reqHeaders.Set("Content-Type", "application/json")
  6947. c.urlParams_.Set("alt", alt)
  6948. c.urlParams_.Set("prettyPrint", "false")
  6949. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/autoForwarding")
  6950. urls += "?" + c.urlParams_.Encode()
  6951. req, err := http.NewRequest("PUT", urls, body)
  6952. if err != nil {
  6953. return nil, err
  6954. }
  6955. req.Header = reqHeaders
  6956. googleapi.Expand(req.URL, map[string]string{
  6957. "userId": c.userId,
  6958. })
  6959. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  6960. }
  6961. // Do executes the "gmail.users.settings.updateAutoForwarding" call.
  6962. // Exactly one of *AutoForwarding or error will be non-nil. Any non-2xx
  6963. // status code is an error. Response headers are in either
  6964. // *AutoForwarding.ServerResponse.Header or (if a response was returned
  6965. // at all) in error.(*googleapi.Error).Header. Use
  6966. // googleapi.IsNotModified to check whether the returned error was
  6967. // because http.StatusNotModified was returned.
  6968. func (c *UsersSettingsUpdateAutoForwardingCall) Do(opts ...googleapi.CallOption) (*AutoForwarding, error) {
  6969. gensupport.SetOptions(c.urlParams_, opts...)
  6970. res, err := c.doRequest("json")
  6971. if res != nil && res.StatusCode == http.StatusNotModified {
  6972. if res.Body != nil {
  6973. res.Body.Close()
  6974. }
  6975. return nil, &googleapi.Error{
  6976. Code: res.StatusCode,
  6977. Header: res.Header,
  6978. }
  6979. }
  6980. if err != nil {
  6981. return nil, err
  6982. }
  6983. defer googleapi.CloseBody(res)
  6984. if err := googleapi.CheckResponse(res); err != nil {
  6985. return nil, err
  6986. }
  6987. ret := &AutoForwarding{
  6988. ServerResponse: googleapi.ServerResponse{
  6989. Header: res.Header,
  6990. HTTPStatusCode: res.StatusCode,
  6991. },
  6992. }
  6993. target := &ret
  6994. if err := gensupport.DecodeResponse(target, res); err != nil {
  6995. return nil, err
  6996. }
  6997. return ret, nil
  6998. // {
  6999. // "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.",
  7000. // "httpMethod": "PUT",
  7001. // "id": "gmail.users.settings.updateAutoForwarding",
  7002. // "parameterOrder": [
  7003. // "userId"
  7004. // ],
  7005. // "parameters": {
  7006. // "userId": {
  7007. // "default": "me",
  7008. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7009. // "location": "path",
  7010. // "required": true,
  7011. // "type": "string"
  7012. // }
  7013. // },
  7014. // "path": "{userId}/settings/autoForwarding",
  7015. // "request": {
  7016. // "$ref": "AutoForwarding"
  7017. // },
  7018. // "response": {
  7019. // "$ref": "AutoForwarding"
  7020. // },
  7021. // "scopes": [
  7022. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  7023. // ]
  7024. // }
  7025. }
  7026. // method id "gmail.users.settings.updateImap":
  7027. type UsersSettingsUpdateImapCall struct {
  7028. s *Service
  7029. userId string
  7030. imapsettings *ImapSettings
  7031. urlParams_ gensupport.URLParams
  7032. ctx_ context.Context
  7033. header_ http.Header
  7034. }
  7035. // UpdateImap: Updates IMAP settings.
  7036. func (r *UsersSettingsService) UpdateImap(userId string, imapsettings *ImapSettings) *UsersSettingsUpdateImapCall {
  7037. c := &UsersSettingsUpdateImapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7038. c.userId = userId
  7039. c.imapsettings = imapsettings
  7040. return c
  7041. }
  7042. // Fields allows partial responses to be retrieved. See
  7043. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7044. // for more information.
  7045. func (c *UsersSettingsUpdateImapCall) Fields(s ...googleapi.Field) *UsersSettingsUpdateImapCall {
  7046. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7047. return c
  7048. }
  7049. // Context sets the context to be used in this call's Do method. Any
  7050. // pending HTTP request will be aborted if the provided context is
  7051. // canceled.
  7052. func (c *UsersSettingsUpdateImapCall) Context(ctx context.Context) *UsersSettingsUpdateImapCall {
  7053. c.ctx_ = ctx
  7054. return c
  7055. }
  7056. // Header returns an http.Header that can be modified by the caller to
  7057. // add HTTP headers to the request.
  7058. func (c *UsersSettingsUpdateImapCall) Header() http.Header {
  7059. if c.header_ == nil {
  7060. c.header_ = make(http.Header)
  7061. }
  7062. return c.header_
  7063. }
  7064. func (c *UsersSettingsUpdateImapCall) doRequest(alt string) (*http.Response, error) {
  7065. reqHeaders := make(http.Header)
  7066. for k, v := range c.header_ {
  7067. reqHeaders[k] = v
  7068. }
  7069. reqHeaders.Set("User-Agent", c.s.userAgent())
  7070. var body io.Reader = nil
  7071. body, err := googleapi.WithoutDataWrapper.JSONReader(c.imapsettings)
  7072. if err != nil {
  7073. return nil, err
  7074. }
  7075. reqHeaders.Set("Content-Type", "application/json")
  7076. c.urlParams_.Set("alt", alt)
  7077. c.urlParams_.Set("prettyPrint", "false")
  7078. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/imap")
  7079. urls += "?" + c.urlParams_.Encode()
  7080. req, err := http.NewRequest("PUT", urls, body)
  7081. if err != nil {
  7082. return nil, err
  7083. }
  7084. req.Header = reqHeaders
  7085. googleapi.Expand(req.URL, map[string]string{
  7086. "userId": c.userId,
  7087. })
  7088. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7089. }
  7090. // Do executes the "gmail.users.settings.updateImap" call.
  7091. // Exactly one of *ImapSettings or error will be non-nil. Any non-2xx
  7092. // status code is an error. Response headers are in either
  7093. // *ImapSettings.ServerResponse.Header or (if a response was returned at
  7094. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  7095. // to check whether the returned error was because
  7096. // http.StatusNotModified was returned.
  7097. func (c *UsersSettingsUpdateImapCall) Do(opts ...googleapi.CallOption) (*ImapSettings, error) {
  7098. gensupport.SetOptions(c.urlParams_, opts...)
  7099. res, err := c.doRequest("json")
  7100. if res != nil && res.StatusCode == http.StatusNotModified {
  7101. if res.Body != nil {
  7102. res.Body.Close()
  7103. }
  7104. return nil, &googleapi.Error{
  7105. Code: res.StatusCode,
  7106. Header: res.Header,
  7107. }
  7108. }
  7109. if err != nil {
  7110. return nil, err
  7111. }
  7112. defer googleapi.CloseBody(res)
  7113. if err := googleapi.CheckResponse(res); err != nil {
  7114. return nil, err
  7115. }
  7116. ret := &ImapSettings{
  7117. ServerResponse: googleapi.ServerResponse{
  7118. Header: res.Header,
  7119. HTTPStatusCode: res.StatusCode,
  7120. },
  7121. }
  7122. target := &ret
  7123. if err := gensupport.DecodeResponse(target, res); err != nil {
  7124. return nil, err
  7125. }
  7126. return ret, nil
  7127. // {
  7128. // "description": "Updates IMAP settings.",
  7129. // "httpMethod": "PUT",
  7130. // "id": "gmail.users.settings.updateImap",
  7131. // "parameterOrder": [
  7132. // "userId"
  7133. // ],
  7134. // "parameters": {
  7135. // "userId": {
  7136. // "default": "me",
  7137. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7138. // "location": "path",
  7139. // "required": true,
  7140. // "type": "string"
  7141. // }
  7142. // },
  7143. // "path": "{userId}/settings/imap",
  7144. // "request": {
  7145. // "$ref": "ImapSettings"
  7146. // },
  7147. // "response": {
  7148. // "$ref": "ImapSettings"
  7149. // },
  7150. // "scopes": [
  7151. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7152. // ]
  7153. // }
  7154. }
  7155. // method id "gmail.users.settings.updatePop":
  7156. type UsersSettingsUpdatePopCall struct {
  7157. s *Service
  7158. userId string
  7159. popsettings *PopSettings
  7160. urlParams_ gensupport.URLParams
  7161. ctx_ context.Context
  7162. header_ http.Header
  7163. }
  7164. // UpdatePop: Updates POP settings.
  7165. func (r *UsersSettingsService) UpdatePop(userId string, popsettings *PopSettings) *UsersSettingsUpdatePopCall {
  7166. c := &UsersSettingsUpdatePopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7167. c.userId = userId
  7168. c.popsettings = popsettings
  7169. return c
  7170. }
  7171. // Fields allows partial responses to be retrieved. See
  7172. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7173. // for more information.
  7174. func (c *UsersSettingsUpdatePopCall) Fields(s ...googleapi.Field) *UsersSettingsUpdatePopCall {
  7175. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7176. return c
  7177. }
  7178. // Context sets the context to be used in this call's Do method. Any
  7179. // pending HTTP request will be aborted if the provided context is
  7180. // canceled.
  7181. func (c *UsersSettingsUpdatePopCall) Context(ctx context.Context) *UsersSettingsUpdatePopCall {
  7182. c.ctx_ = ctx
  7183. return c
  7184. }
  7185. // Header returns an http.Header that can be modified by the caller to
  7186. // add HTTP headers to the request.
  7187. func (c *UsersSettingsUpdatePopCall) Header() http.Header {
  7188. if c.header_ == nil {
  7189. c.header_ = make(http.Header)
  7190. }
  7191. return c.header_
  7192. }
  7193. func (c *UsersSettingsUpdatePopCall) doRequest(alt string) (*http.Response, error) {
  7194. reqHeaders := make(http.Header)
  7195. for k, v := range c.header_ {
  7196. reqHeaders[k] = v
  7197. }
  7198. reqHeaders.Set("User-Agent", c.s.userAgent())
  7199. var body io.Reader = nil
  7200. body, err := googleapi.WithoutDataWrapper.JSONReader(c.popsettings)
  7201. if err != nil {
  7202. return nil, err
  7203. }
  7204. reqHeaders.Set("Content-Type", "application/json")
  7205. c.urlParams_.Set("alt", alt)
  7206. c.urlParams_.Set("prettyPrint", "false")
  7207. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/pop")
  7208. urls += "?" + c.urlParams_.Encode()
  7209. req, err := http.NewRequest("PUT", urls, body)
  7210. if err != nil {
  7211. return nil, err
  7212. }
  7213. req.Header = reqHeaders
  7214. googleapi.Expand(req.URL, map[string]string{
  7215. "userId": c.userId,
  7216. })
  7217. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7218. }
  7219. // Do executes the "gmail.users.settings.updatePop" call.
  7220. // Exactly one of *PopSettings or error will be non-nil. Any non-2xx
  7221. // status code is an error. Response headers are in either
  7222. // *PopSettings.ServerResponse.Header or (if a response was returned at
  7223. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  7224. // to check whether the returned error was because
  7225. // http.StatusNotModified was returned.
  7226. func (c *UsersSettingsUpdatePopCall) Do(opts ...googleapi.CallOption) (*PopSettings, error) {
  7227. gensupport.SetOptions(c.urlParams_, opts...)
  7228. res, err := c.doRequest("json")
  7229. if res != nil && res.StatusCode == http.StatusNotModified {
  7230. if res.Body != nil {
  7231. res.Body.Close()
  7232. }
  7233. return nil, &googleapi.Error{
  7234. Code: res.StatusCode,
  7235. Header: res.Header,
  7236. }
  7237. }
  7238. if err != nil {
  7239. return nil, err
  7240. }
  7241. defer googleapi.CloseBody(res)
  7242. if err := googleapi.CheckResponse(res); err != nil {
  7243. return nil, err
  7244. }
  7245. ret := &PopSettings{
  7246. ServerResponse: googleapi.ServerResponse{
  7247. Header: res.Header,
  7248. HTTPStatusCode: res.StatusCode,
  7249. },
  7250. }
  7251. target := &ret
  7252. if err := gensupport.DecodeResponse(target, res); err != nil {
  7253. return nil, err
  7254. }
  7255. return ret, nil
  7256. // {
  7257. // "description": "Updates POP settings.",
  7258. // "httpMethod": "PUT",
  7259. // "id": "gmail.users.settings.updatePop",
  7260. // "parameterOrder": [
  7261. // "userId"
  7262. // ],
  7263. // "parameters": {
  7264. // "userId": {
  7265. // "default": "me",
  7266. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7267. // "location": "path",
  7268. // "required": true,
  7269. // "type": "string"
  7270. // }
  7271. // },
  7272. // "path": "{userId}/settings/pop",
  7273. // "request": {
  7274. // "$ref": "PopSettings"
  7275. // },
  7276. // "response": {
  7277. // "$ref": "PopSettings"
  7278. // },
  7279. // "scopes": [
  7280. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7281. // ]
  7282. // }
  7283. }
  7284. // method id "gmail.users.settings.updateVacation":
  7285. type UsersSettingsUpdateVacationCall struct {
  7286. s *Service
  7287. userId string
  7288. vacationsettings *VacationSettings
  7289. urlParams_ gensupport.URLParams
  7290. ctx_ context.Context
  7291. header_ http.Header
  7292. }
  7293. // UpdateVacation: Updates vacation responder settings.
  7294. func (r *UsersSettingsService) UpdateVacation(userId string, vacationsettings *VacationSettings) *UsersSettingsUpdateVacationCall {
  7295. c := &UsersSettingsUpdateVacationCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7296. c.userId = userId
  7297. c.vacationsettings = vacationsettings
  7298. return c
  7299. }
  7300. // Fields allows partial responses to be retrieved. See
  7301. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7302. // for more information.
  7303. func (c *UsersSettingsUpdateVacationCall) Fields(s ...googleapi.Field) *UsersSettingsUpdateVacationCall {
  7304. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7305. return c
  7306. }
  7307. // Context sets the context to be used in this call's Do method. Any
  7308. // pending HTTP request will be aborted if the provided context is
  7309. // canceled.
  7310. func (c *UsersSettingsUpdateVacationCall) Context(ctx context.Context) *UsersSettingsUpdateVacationCall {
  7311. c.ctx_ = ctx
  7312. return c
  7313. }
  7314. // Header returns an http.Header that can be modified by the caller to
  7315. // add HTTP headers to the request.
  7316. func (c *UsersSettingsUpdateVacationCall) Header() http.Header {
  7317. if c.header_ == nil {
  7318. c.header_ = make(http.Header)
  7319. }
  7320. return c.header_
  7321. }
  7322. func (c *UsersSettingsUpdateVacationCall) doRequest(alt string) (*http.Response, error) {
  7323. reqHeaders := make(http.Header)
  7324. for k, v := range c.header_ {
  7325. reqHeaders[k] = v
  7326. }
  7327. reqHeaders.Set("User-Agent", c.s.userAgent())
  7328. var body io.Reader = nil
  7329. body, err := googleapi.WithoutDataWrapper.JSONReader(c.vacationsettings)
  7330. if err != nil {
  7331. return nil, err
  7332. }
  7333. reqHeaders.Set("Content-Type", "application/json")
  7334. c.urlParams_.Set("alt", alt)
  7335. c.urlParams_.Set("prettyPrint", "false")
  7336. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/vacation")
  7337. urls += "?" + c.urlParams_.Encode()
  7338. req, err := http.NewRequest("PUT", urls, body)
  7339. if err != nil {
  7340. return nil, err
  7341. }
  7342. req.Header = reqHeaders
  7343. googleapi.Expand(req.URL, map[string]string{
  7344. "userId": c.userId,
  7345. })
  7346. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7347. }
  7348. // Do executes the "gmail.users.settings.updateVacation" call.
  7349. // Exactly one of *VacationSettings or error will be non-nil. Any
  7350. // non-2xx status code is an error. Response headers are in either
  7351. // *VacationSettings.ServerResponse.Header or (if a response was
  7352. // returned at all) in error.(*googleapi.Error).Header. Use
  7353. // googleapi.IsNotModified to check whether the returned error was
  7354. // because http.StatusNotModified was returned.
  7355. func (c *UsersSettingsUpdateVacationCall) Do(opts ...googleapi.CallOption) (*VacationSettings, error) {
  7356. gensupport.SetOptions(c.urlParams_, opts...)
  7357. res, err := c.doRequest("json")
  7358. if res != nil && res.StatusCode == http.StatusNotModified {
  7359. if res.Body != nil {
  7360. res.Body.Close()
  7361. }
  7362. return nil, &googleapi.Error{
  7363. Code: res.StatusCode,
  7364. Header: res.Header,
  7365. }
  7366. }
  7367. if err != nil {
  7368. return nil, err
  7369. }
  7370. defer googleapi.CloseBody(res)
  7371. if err := googleapi.CheckResponse(res); err != nil {
  7372. return nil, err
  7373. }
  7374. ret := &VacationSettings{
  7375. ServerResponse: googleapi.ServerResponse{
  7376. Header: res.Header,
  7377. HTTPStatusCode: res.StatusCode,
  7378. },
  7379. }
  7380. target := &ret
  7381. if err := gensupport.DecodeResponse(target, res); err != nil {
  7382. return nil, err
  7383. }
  7384. return ret, nil
  7385. // {
  7386. // "description": "Updates vacation responder settings.",
  7387. // "httpMethod": "PUT",
  7388. // "id": "gmail.users.settings.updateVacation",
  7389. // "parameterOrder": [
  7390. // "userId"
  7391. // ],
  7392. // "parameters": {
  7393. // "userId": {
  7394. // "default": "me",
  7395. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7396. // "location": "path",
  7397. // "required": true,
  7398. // "type": "string"
  7399. // }
  7400. // },
  7401. // "path": "{userId}/settings/vacation",
  7402. // "request": {
  7403. // "$ref": "VacationSettings"
  7404. // },
  7405. // "response": {
  7406. // "$ref": "VacationSettings"
  7407. // },
  7408. // "scopes": [
  7409. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7410. // ]
  7411. // }
  7412. }
  7413. // method id "gmail.users.settings.delegates.create":
  7414. type UsersSettingsDelegatesCreateCall struct {
  7415. s *Service
  7416. userId string
  7417. delegate *Delegate
  7418. urlParams_ gensupport.URLParams
  7419. ctx_ context.Context
  7420. header_ http.Header
  7421. }
  7422. // Create: Adds a delegate with its verification status set directly to
  7423. // accepted, without sending any verification email. The delegate user
  7424. // must be a member of the same G Suite organization as the delegator
  7425. // user.
  7426. //
  7427. // Gmail imposes limtations on the number of delegates and delegators
  7428. // each user in a G Suite organization can have. These limits depend on
  7429. // your organization, but in general each user can have up to 25
  7430. // delegates and up to 10 delegators.
  7431. //
  7432. // Note that a delegate user must be referred to by their primary email
  7433. // address, and not an email alias.
  7434. //
  7435. // Also note that when a new delegate is created, there may be up to a
  7436. // one minute delay before the new delegate is available for use.
  7437. //
  7438. // This method is only available to service account clients that have
  7439. // been delegated domain-wide authority.
  7440. func (r *UsersSettingsDelegatesService) Create(userId string, delegate *Delegate) *UsersSettingsDelegatesCreateCall {
  7441. c := &UsersSettingsDelegatesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7442. c.userId = userId
  7443. c.delegate = delegate
  7444. return c
  7445. }
  7446. // Fields allows partial responses to be retrieved. See
  7447. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7448. // for more information.
  7449. func (c *UsersSettingsDelegatesCreateCall) Fields(s ...googleapi.Field) *UsersSettingsDelegatesCreateCall {
  7450. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7451. return c
  7452. }
  7453. // Context sets the context to be used in this call's Do method. Any
  7454. // pending HTTP request will be aborted if the provided context is
  7455. // canceled.
  7456. func (c *UsersSettingsDelegatesCreateCall) Context(ctx context.Context) *UsersSettingsDelegatesCreateCall {
  7457. c.ctx_ = ctx
  7458. return c
  7459. }
  7460. // Header returns an http.Header that can be modified by the caller to
  7461. // add HTTP headers to the request.
  7462. func (c *UsersSettingsDelegatesCreateCall) Header() http.Header {
  7463. if c.header_ == nil {
  7464. c.header_ = make(http.Header)
  7465. }
  7466. return c.header_
  7467. }
  7468. func (c *UsersSettingsDelegatesCreateCall) doRequest(alt string) (*http.Response, error) {
  7469. reqHeaders := make(http.Header)
  7470. for k, v := range c.header_ {
  7471. reqHeaders[k] = v
  7472. }
  7473. reqHeaders.Set("User-Agent", c.s.userAgent())
  7474. var body io.Reader = nil
  7475. body, err := googleapi.WithoutDataWrapper.JSONReader(c.delegate)
  7476. if err != nil {
  7477. return nil, err
  7478. }
  7479. reqHeaders.Set("Content-Type", "application/json")
  7480. c.urlParams_.Set("alt", alt)
  7481. c.urlParams_.Set("prettyPrint", "false")
  7482. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/delegates")
  7483. urls += "?" + c.urlParams_.Encode()
  7484. req, err := http.NewRequest("POST", urls, body)
  7485. if err != nil {
  7486. return nil, err
  7487. }
  7488. req.Header = reqHeaders
  7489. googleapi.Expand(req.URL, map[string]string{
  7490. "userId": c.userId,
  7491. })
  7492. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7493. }
  7494. // Do executes the "gmail.users.settings.delegates.create" call.
  7495. // Exactly one of *Delegate or error will be non-nil. Any non-2xx status
  7496. // code is an error. Response headers are in either
  7497. // *Delegate.ServerResponse.Header or (if a response was returned at
  7498. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  7499. // to check whether the returned error was because
  7500. // http.StatusNotModified was returned.
  7501. func (c *UsersSettingsDelegatesCreateCall) Do(opts ...googleapi.CallOption) (*Delegate, error) {
  7502. gensupport.SetOptions(c.urlParams_, opts...)
  7503. res, err := c.doRequest("json")
  7504. if res != nil && res.StatusCode == http.StatusNotModified {
  7505. if res.Body != nil {
  7506. res.Body.Close()
  7507. }
  7508. return nil, &googleapi.Error{
  7509. Code: res.StatusCode,
  7510. Header: res.Header,
  7511. }
  7512. }
  7513. if err != nil {
  7514. return nil, err
  7515. }
  7516. defer googleapi.CloseBody(res)
  7517. if err := googleapi.CheckResponse(res); err != nil {
  7518. return nil, err
  7519. }
  7520. ret := &Delegate{
  7521. ServerResponse: googleapi.ServerResponse{
  7522. Header: res.Header,
  7523. HTTPStatusCode: res.StatusCode,
  7524. },
  7525. }
  7526. target := &ret
  7527. if err := gensupport.DecodeResponse(target, res); err != nil {
  7528. return nil, err
  7529. }
  7530. return ret, nil
  7531. // {
  7532. // "description": "Adds a delegate with its verification status set directly to accepted, without sending any verification email. The delegate user must be a member of the same G Suite organization as the delegator user.\n\nGmail imposes limtations on the number of delegates and delegators each user in a G Suite organization can have. These limits depend on your organization, but in general each user can have up to 25 delegates and up to 10 delegators.\n\nNote that a delegate user must be referred to by their primary email address, and not an email alias.\n\nAlso note that when a new delegate is created, there may be up to a one minute delay before the new delegate is available for use.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  7533. // "httpMethod": "POST",
  7534. // "id": "gmail.users.settings.delegates.create",
  7535. // "parameterOrder": [
  7536. // "userId"
  7537. // ],
  7538. // "parameters": {
  7539. // "userId": {
  7540. // "default": "me",
  7541. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7542. // "location": "path",
  7543. // "required": true,
  7544. // "type": "string"
  7545. // }
  7546. // },
  7547. // "path": "{userId}/settings/delegates",
  7548. // "request": {
  7549. // "$ref": "Delegate"
  7550. // },
  7551. // "response": {
  7552. // "$ref": "Delegate"
  7553. // },
  7554. // "scopes": [
  7555. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  7556. // ]
  7557. // }
  7558. }
  7559. // method id "gmail.users.settings.delegates.delete":
  7560. type UsersSettingsDelegatesDeleteCall struct {
  7561. s *Service
  7562. userId string
  7563. delegateEmail string
  7564. urlParams_ gensupport.URLParams
  7565. ctx_ context.Context
  7566. header_ http.Header
  7567. }
  7568. // Delete: Removes the specified delegate (which can be of any
  7569. // verification status), and revokes any verification that may have been
  7570. // required for using it.
  7571. //
  7572. // Note that a delegate user must be referred to by their primary email
  7573. // address, and not an email alias.
  7574. //
  7575. // This method is only available to service account clients that have
  7576. // been delegated domain-wide authority.
  7577. func (r *UsersSettingsDelegatesService) Delete(userId string, delegateEmail string) *UsersSettingsDelegatesDeleteCall {
  7578. c := &UsersSettingsDelegatesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7579. c.userId = userId
  7580. c.delegateEmail = delegateEmail
  7581. return c
  7582. }
  7583. // Fields allows partial responses to be retrieved. See
  7584. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7585. // for more information.
  7586. func (c *UsersSettingsDelegatesDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsDelegatesDeleteCall {
  7587. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7588. return c
  7589. }
  7590. // Context sets the context to be used in this call's Do method. Any
  7591. // pending HTTP request will be aborted if the provided context is
  7592. // canceled.
  7593. func (c *UsersSettingsDelegatesDeleteCall) Context(ctx context.Context) *UsersSettingsDelegatesDeleteCall {
  7594. c.ctx_ = ctx
  7595. return c
  7596. }
  7597. // Header returns an http.Header that can be modified by the caller to
  7598. // add HTTP headers to the request.
  7599. func (c *UsersSettingsDelegatesDeleteCall) Header() http.Header {
  7600. if c.header_ == nil {
  7601. c.header_ = make(http.Header)
  7602. }
  7603. return c.header_
  7604. }
  7605. func (c *UsersSettingsDelegatesDeleteCall) doRequest(alt string) (*http.Response, error) {
  7606. reqHeaders := make(http.Header)
  7607. for k, v := range c.header_ {
  7608. reqHeaders[k] = v
  7609. }
  7610. reqHeaders.Set("User-Agent", c.s.userAgent())
  7611. var body io.Reader = nil
  7612. c.urlParams_.Set("alt", alt)
  7613. c.urlParams_.Set("prettyPrint", "false")
  7614. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/delegates/{delegateEmail}")
  7615. urls += "?" + c.urlParams_.Encode()
  7616. req, err := http.NewRequest("DELETE", urls, body)
  7617. if err != nil {
  7618. return nil, err
  7619. }
  7620. req.Header = reqHeaders
  7621. googleapi.Expand(req.URL, map[string]string{
  7622. "userId": c.userId,
  7623. "delegateEmail": c.delegateEmail,
  7624. })
  7625. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7626. }
  7627. // Do executes the "gmail.users.settings.delegates.delete" call.
  7628. func (c *UsersSettingsDelegatesDeleteCall) Do(opts ...googleapi.CallOption) error {
  7629. gensupport.SetOptions(c.urlParams_, opts...)
  7630. res, err := c.doRequest("json")
  7631. if err != nil {
  7632. return err
  7633. }
  7634. defer googleapi.CloseBody(res)
  7635. if err := googleapi.CheckResponse(res); err != nil {
  7636. return err
  7637. }
  7638. return nil
  7639. // {
  7640. // "description": "Removes the specified delegate (which can be of any verification status), and revokes any verification that may have been required for using it.\n\nNote that a delegate user must be referred to by their primary email address, and not an email alias.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  7641. // "httpMethod": "DELETE",
  7642. // "id": "gmail.users.settings.delegates.delete",
  7643. // "parameterOrder": [
  7644. // "userId",
  7645. // "delegateEmail"
  7646. // ],
  7647. // "parameters": {
  7648. // "delegateEmail": {
  7649. // "description": "The email address of the user to be removed as a delegate.",
  7650. // "location": "path",
  7651. // "required": true,
  7652. // "type": "string"
  7653. // },
  7654. // "userId": {
  7655. // "default": "me",
  7656. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7657. // "location": "path",
  7658. // "required": true,
  7659. // "type": "string"
  7660. // }
  7661. // },
  7662. // "path": "{userId}/settings/delegates/{delegateEmail}",
  7663. // "scopes": [
  7664. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  7665. // ]
  7666. // }
  7667. }
  7668. // method id "gmail.users.settings.delegates.get":
  7669. type UsersSettingsDelegatesGetCall struct {
  7670. s *Service
  7671. userId string
  7672. delegateEmail string
  7673. urlParams_ gensupport.URLParams
  7674. ifNoneMatch_ string
  7675. ctx_ context.Context
  7676. header_ http.Header
  7677. }
  7678. // Get: Gets the specified delegate.
  7679. //
  7680. // Note that a delegate user must be referred to by their primary email
  7681. // address, and not an email alias.
  7682. //
  7683. // This method is only available to service account clients that have
  7684. // been delegated domain-wide authority.
  7685. func (r *UsersSettingsDelegatesService) Get(userId string, delegateEmail string) *UsersSettingsDelegatesGetCall {
  7686. c := &UsersSettingsDelegatesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7687. c.userId = userId
  7688. c.delegateEmail = delegateEmail
  7689. return c
  7690. }
  7691. // Fields allows partial responses to be retrieved. See
  7692. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7693. // for more information.
  7694. func (c *UsersSettingsDelegatesGetCall) Fields(s ...googleapi.Field) *UsersSettingsDelegatesGetCall {
  7695. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7696. return c
  7697. }
  7698. // IfNoneMatch sets the optional parameter which makes the operation
  7699. // fail if the object's ETag matches the given value. This is useful for
  7700. // getting updates only after the object has changed since the last
  7701. // request. Use googleapi.IsNotModified to check whether the response
  7702. // error from Do is the result of In-None-Match.
  7703. func (c *UsersSettingsDelegatesGetCall) IfNoneMatch(entityTag string) *UsersSettingsDelegatesGetCall {
  7704. c.ifNoneMatch_ = entityTag
  7705. return c
  7706. }
  7707. // Context sets the context to be used in this call's Do method. Any
  7708. // pending HTTP request will be aborted if the provided context is
  7709. // canceled.
  7710. func (c *UsersSettingsDelegatesGetCall) Context(ctx context.Context) *UsersSettingsDelegatesGetCall {
  7711. c.ctx_ = ctx
  7712. return c
  7713. }
  7714. // Header returns an http.Header that can be modified by the caller to
  7715. // add HTTP headers to the request.
  7716. func (c *UsersSettingsDelegatesGetCall) Header() http.Header {
  7717. if c.header_ == nil {
  7718. c.header_ = make(http.Header)
  7719. }
  7720. return c.header_
  7721. }
  7722. func (c *UsersSettingsDelegatesGetCall) doRequest(alt string) (*http.Response, error) {
  7723. reqHeaders := make(http.Header)
  7724. for k, v := range c.header_ {
  7725. reqHeaders[k] = v
  7726. }
  7727. reqHeaders.Set("User-Agent", c.s.userAgent())
  7728. if c.ifNoneMatch_ != "" {
  7729. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  7730. }
  7731. var body io.Reader = nil
  7732. c.urlParams_.Set("alt", alt)
  7733. c.urlParams_.Set("prettyPrint", "false")
  7734. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/delegates/{delegateEmail}")
  7735. urls += "?" + c.urlParams_.Encode()
  7736. req, err := http.NewRequest("GET", urls, body)
  7737. if err != nil {
  7738. return nil, err
  7739. }
  7740. req.Header = reqHeaders
  7741. googleapi.Expand(req.URL, map[string]string{
  7742. "userId": c.userId,
  7743. "delegateEmail": c.delegateEmail,
  7744. })
  7745. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7746. }
  7747. // Do executes the "gmail.users.settings.delegates.get" call.
  7748. // Exactly one of *Delegate or error will be non-nil. Any non-2xx status
  7749. // code is an error. Response headers are in either
  7750. // *Delegate.ServerResponse.Header or (if a response was returned at
  7751. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  7752. // to check whether the returned error was because
  7753. // http.StatusNotModified was returned.
  7754. func (c *UsersSettingsDelegatesGetCall) Do(opts ...googleapi.CallOption) (*Delegate, error) {
  7755. gensupport.SetOptions(c.urlParams_, opts...)
  7756. res, err := c.doRequest("json")
  7757. if res != nil && res.StatusCode == http.StatusNotModified {
  7758. if res.Body != nil {
  7759. res.Body.Close()
  7760. }
  7761. return nil, &googleapi.Error{
  7762. Code: res.StatusCode,
  7763. Header: res.Header,
  7764. }
  7765. }
  7766. if err != nil {
  7767. return nil, err
  7768. }
  7769. defer googleapi.CloseBody(res)
  7770. if err := googleapi.CheckResponse(res); err != nil {
  7771. return nil, err
  7772. }
  7773. ret := &Delegate{
  7774. ServerResponse: googleapi.ServerResponse{
  7775. Header: res.Header,
  7776. HTTPStatusCode: res.StatusCode,
  7777. },
  7778. }
  7779. target := &ret
  7780. if err := gensupport.DecodeResponse(target, res); err != nil {
  7781. return nil, err
  7782. }
  7783. return ret, nil
  7784. // {
  7785. // "description": "Gets the specified delegate.\n\nNote that a delegate user must be referred to by their primary email address, and not an email alias.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  7786. // "httpMethod": "GET",
  7787. // "id": "gmail.users.settings.delegates.get",
  7788. // "parameterOrder": [
  7789. // "userId",
  7790. // "delegateEmail"
  7791. // ],
  7792. // "parameters": {
  7793. // "delegateEmail": {
  7794. // "description": "The email address of the user whose delegate relationship is to be retrieved.",
  7795. // "location": "path",
  7796. // "required": true,
  7797. // "type": "string"
  7798. // },
  7799. // "userId": {
  7800. // "default": "me",
  7801. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7802. // "location": "path",
  7803. // "required": true,
  7804. // "type": "string"
  7805. // }
  7806. // },
  7807. // "path": "{userId}/settings/delegates/{delegateEmail}",
  7808. // "response": {
  7809. // "$ref": "Delegate"
  7810. // },
  7811. // "scopes": [
  7812. // "https://mail.google.com/",
  7813. // "https://www.googleapis.com/auth/gmail.modify",
  7814. // "https://www.googleapis.com/auth/gmail.readonly",
  7815. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7816. // ]
  7817. // }
  7818. }
  7819. // method id "gmail.users.settings.delegates.list":
  7820. type UsersSettingsDelegatesListCall struct {
  7821. s *Service
  7822. userId string
  7823. urlParams_ gensupport.URLParams
  7824. ifNoneMatch_ string
  7825. ctx_ context.Context
  7826. header_ http.Header
  7827. }
  7828. // List: Lists the delegates for the specified account.
  7829. //
  7830. // This method is only available to service account clients that have
  7831. // been delegated domain-wide authority.
  7832. func (r *UsersSettingsDelegatesService) List(userId string) *UsersSettingsDelegatesListCall {
  7833. c := &UsersSettingsDelegatesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7834. c.userId = userId
  7835. return c
  7836. }
  7837. // Fields allows partial responses to be retrieved. See
  7838. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7839. // for more information.
  7840. func (c *UsersSettingsDelegatesListCall) Fields(s ...googleapi.Field) *UsersSettingsDelegatesListCall {
  7841. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7842. return c
  7843. }
  7844. // IfNoneMatch sets the optional parameter which makes the operation
  7845. // fail if the object's ETag matches the given value. This is useful for
  7846. // getting updates only after the object has changed since the last
  7847. // request. Use googleapi.IsNotModified to check whether the response
  7848. // error from Do is the result of In-None-Match.
  7849. func (c *UsersSettingsDelegatesListCall) IfNoneMatch(entityTag string) *UsersSettingsDelegatesListCall {
  7850. c.ifNoneMatch_ = entityTag
  7851. return c
  7852. }
  7853. // Context sets the context to be used in this call's Do method. Any
  7854. // pending HTTP request will be aborted if the provided context is
  7855. // canceled.
  7856. func (c *UsersSettingsDelegatesListCall) Context(ctx context.Context) *UsersSettingsDelegatesListCall {
  7857. c.ctx_ = ctx
  7858. return c
  7859. }
  7860. // Header returns an http.Header that can be modified by the caller to
  7861. // add HTTP headers to the request.
  7862. func (c *UsersSettingsDelegatesListCall) Header() http.Header {
  7863. if c.header_ == nil {
  7864. c.header_ = make(http.Header)
  7865. }
  7866. return c.header_
  7867. }
  7868. func (c *UsersSettingsDelegatesListCall) doRequest(alt string) (*http.Response, error) {
  7869. reqHeaders := make(http.Header)
  7870. for k, v := range c.header_ {
  7871. reqHeaders[k] = v
  7872. }
  7873. reqHeaders.Set("User-Agent", c.s.userAgent())
  7874. if c.ifNoneMatch_ != "" {
  7875. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  7876. }
  7877. var body io.Reader = nil
  7878. c.urlParams_.Set("alt", alt)
  7879. c.urlParams_.Set("prettyPrint", "false")
  7880. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/delegates")
  7881. urls += "?" + c.urlParams_.Encode()
  7882. req, err := http.NewRequest("GET", urls, body)
  7883. if err != nil {
  7884. return nil, err
  7885. }
  7886. req.Header = reqHeaders
  7887. googleapi.Expand(req.URL, map[string]string{
  7888. "userId": c.userId,
  7889. })
  7890. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  7891. }
  7892. // Do executes the "gmail.users.settings.delegates.list" call.
  7893. // Exactly one of *ListDelegatesResponse or error will be non-nil. Any
  7894. // non-2xx status code is an error. Response headers are in either
  7895. // *ListDelegatesResponse.ServerResponse.Header or (if a response was
  7896. // returned at all) in error.(*googleapi.Error).Header. Use
  7897. // googleapi.IsNotModified to check whether the returned error was
  7898. // because http.StatusNotModified was returned.
  7899. func (c *UsersSettingsDelegatesListCall) Do(opts ...googleapi.CallOption) (*ListDelegatesResponse, error) {
  7900. gensupport.SetOptions(c.urlParams_, opts...)
  7901. res, err := c.doRequest("json")
  7902. if res != nil && res.StatusCode == http.StatusNotModified {
  7903. if res.Body != nil {
  7904. res.Body.Close()
  7905. }
  7906. return nil, &googleapi.Error{
  7907. Code: res.StatusCode,
  7908. Header: res.Header,
  7909. }
  7910. }
  7911. if err != nil {
  7912. return nil, err
  7913. }
  7914. defer googleapi.CloseBody(res)
  7915. if err := googleapi.CheckResponse(res); err != nil {
  7916. return nil, err
  7917. }
  7918. ret := &ListDelegatesResponse{
  7919. ServerResponse: googleapi.ServerResponse{
  7920. Header: res.Header,
  7921. HTTPStatusCode: res.StatusCode,
  7922. },
  7923. }
  7924. target := &ret
  7925. if err := gensupport.DecodeResponse(target, res); err != nil {
  7926. return nil, err
  7927. }
  7928. return ret, nil
  7929. // {
  7930. // "description": "Lists the delegates for the specified account.\n\nThis method is only available to service account clients that have been delegated domain-wide authority.",
  7931. // "httpMethod": "GET",
  7932. // "id": "gmail.users.settings.delegates.list",
  7933. // "parameterOrder": [
  7934. // "userId"
  7935. // ],
  7936. // "parameters": {
  7937. // "userId": {
  7938. // "default": "me",
  7939. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  7940. // "location": "path",
  7941. // "required": true,
  7942. // "type": "string"
  7943. // }
  7944. // },
  7945. // "path": "{userId}/settings/delegates",
  7946. // "response": {
  7947. // "$ref": "ListDelegatesResponse"
  7948. // },
  7949. // "scopes": [
  7950. // "https://mail.google.com/",
  7951. // "https://www.googleapis.com/auth/gmail.modify",
  7952. // "https://www.googleapis.com/auth/gmail.readonly",
  7953. // "https://www.googleapis.com/auth/gmail.settings.basic"
  7954. // ]
  7955. // }
  7956. }
  7957. // method id "gmail.users.settings.filters.create":
  7958. type UsersSettingsFiltersCreateCall struct {
  7959. s *Service
  7960. userId string
  7961. filter *Filter
  7962. urlParams_ gensupport.URLParams
  7963. ctx_ context.Context
  7964. header_ http.Header
  7965. }
  7966. // Create: Creates a filter.
  7967. func (r *UsersSettingsFiltersService) Create(userId string, filter *Filter) *UsersSettingsFiltersCreateCall {
  7968. c := &UsersSettingsFiltersCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  7969. c.userId = userId
  7970. c.filter = filter
  7971. return c
  7972. }
  7973. // Fields allows partial responses to be retrieved. See
  7974. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  7975. // for more information.
  7976. func (c *UsersSettingsFiltersCreateCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersCreateCall {
  7977. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  7978. return c
  7979. }
  7980. // Context sets the context to be used in this call's Do method. Any
  7981. // pending HTTP request will be aborted if the provided context is
  7982. // canceled.
  7983. func (c *UsersSettingsFiltersCreateCall) Context(ctx context.Context) *UsersSettingsFiltersCreateCall {
  7984. c.ctx_ = ctx
  7985. return c
  7986. }
  7987. // Header returns an http.Header that can be modified by the caller to
  7988. // add HTTP headers to the request.
  7989. func (c *UsersSettingsFiltersCreateCall) Header() http.Header {
  7990. if c.header_ == nil {
  7991. c.header_ = make(http.Header)
  7992. }
  7993. return c.header_
  7994. }
  7995. func (c *UsersSettingsFiltersCreateCall) doRequest(alt string) (*http.Response, error) {
  7996. reqHeaders := make(http.Header)
  7997. for k, v := range c.header_ {
  7998. reqHeaders[k] = v
  7999. }
  8000. reqHeaders.Set("User-Agent", c.s.userAgent())
  8001. var body io.Reader = nil
  8002. body, err := googleapi.WithoutDataWrapper.JSONReader(c.filter)
  8003. if err != nil {
  8004. return nil, err
  8005. }
  8006. reqHeaders.Set("Content-Type", "application/json")
  8007. c.urlParams_.Set("alt", alt)
  8008. c.urlParams_.Set("prettyPrint", "false")
  8009. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters")
  8010. urls += "?" + c.urlParams_.Encode()
  8011. req, err := http.NewRequest("POST", urls, body)
  8012. if err != nil {
  8013. return nil, err
  8014. }
  8015. req.Header = reqHeaders
  8016. googleapi.Expand(req.URL, map[string]string{
  8017. "userId": c.userId,
  8018. })
  8019. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8020. }
  8021. // Do executes the "gmail.users.settings.filters.create" call.
  8022. // Exactly one of *Filter or error will be non-nil. Any non-2xx status
  8023. // code is an error. Response headers are in either
  8024. // *Filter.ServerResponse.Header or (if a response was returned at all)
  8025. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  8026. // check whether the returned error was because http.StatusNotModified
  8027. // was returned.
  8028. func (c *UsersSettingsFiltersCreateCall) Do(opts ...googleapi.CallOption) (*Filter, error) {
  8029. gensupport.SetOptions(c.urlParams_, opts...)
  8030. res, err := c.doRequest("json")
  8031. if res != nil && res.StatusCode == http.StatusNotModified {
  8032. if res.Body != nil {
  8033. res.Body.Close()
  8034. }
  8035. return nil, &googleapi.Error{
  8036. Code: res.StatusCode,
  8037. Header: res.Header,
  8038. }
  8039. }
  8040. if err != nil {
  8041. return nil, err
  8042. }
  8043. defer googleapi.CloseBody(res)
  8044. if err := googleapi.CheckResponse(res); err != nil {
  8045. return nil, err
  8046. }
  8047. ret := &Filter{
  8048. ServerResponse: googleapi.ServerResponse{
  8049. Header: res.Header,
  8050. HTTPStatusCode: res.StatusCode,
  8051. },
  8052. }
  8053. target := &ret
  8054. if err := gensupport.DecodeResponse(target, res); err != nil {
  8055. return nil, err
  8056. }
  8057. return ret, nil
  8058. // {
  8059. // "description": "Creates a filter.",
  8060. // "httpMethod": "POST",
  8061. // "id": "gmail.users.settings.filters.create",
  8062. // "parameterOrder": [
  8063. // "userId"
  8064. // ],
  8065. // "parameters": {
  8066. // "userId": {
  8067. // "default": "me",
  8068. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8069. // "location": "path",
  8070. // "required": true,
  8071. // "type": "string"
  8072. // }
  8073. // },
  8074. // "path": "{userId}/settings/filters",
  8075. // "request": {
  8076. // "$ref": "Filter"
  8077. // },
  8078. // "response": {
  8079. // "$ref": "Filter"
  8080. // },
  8081. // "scopes": [
  8082. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8083. // ]
  8084. // }
  8085. }
  8086. // method id "gmail.users.settings.filters.delete":
  8087. type UsersSettingsFiltersDeleteCall struct {
  8088. s *Service
  8089. userId string
  8090. id string
  8091. urlParams_ gensupport.URLParams
  8092. ctx_ context.Context
  8093. header_ http.Header
  8094. }
  8095. // Delete: Deletes a filter.
  8096. func (r *UsersSettingsFiltersService) Delete(userId string, id string) *UsersSettingsFiltersDeleteCall {
  8097. c := &UsersSettingsFiltersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8098. c.userId = userId
  8099. c.id = id
  8100. return c
  8101. }
  8102. // Fields allows partial responses to be retrieved. See
  8103. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8104. // for more information.
  8105. func (c *UsersSettingsFiltersDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersDeleteCall {
  8106. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8107. return c
  8108. }
  8109. // Context sets the context to be used in this call's Do method. Any
  8110. // pending HTTP request will be aborted if the provided context is
  8111. // canceled.
  8112. func (c *UsersSettingsFiltersDeleteCall) Context(ctx context.Context) *UsersSettingsFiltersDeleteCall {
  8113. c.ctx_ = ctx
  8114. return c
  8115. }
  8116. // Header returns an http.Header that can be modified by the caller to
  8117. // add HTTP headers to the request.
  8118. func (c *UsersSettingsFiltersDeleteCall) Header() http.Header {
  8119. if c.header_ == nil {
  8120. c.header_ = make(http.Header)
  8121. }
  8122. return c.header_
  8123. }
  8124. func (c *UsersSettingsFiltersDeleteCall) doRequest(alt string) (*http.Response, error) {
  8125. reqHeaders := make(http.Header)
  8126. for k, v := range c.header_ {
  8127. reqHeaders[k] = v
  8128. }
  8129. reqHeaders.Set("User-Agent", c.s.userAgent())
  8130. var body io.Reader = nil
  8131. c.urlParams_.Set("alt", alt)
  8132. c.urlParams_.Set("prettyPrint", "false")
  8133. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters/{id}")
  8134. urls += "?" + c.urlParams_.Encode()
  8135. req, err := http.NewRequest("DELETE", urls, body)
  8136. if err != nil {
  8137. return nil, err
  8138. }
  8139. req.Header = reqHeaders
  8140. googleapi.Expand(req.URL, map[string]string{
  8141. "userId": c.userId,
  8142. "id": c.id,
  8143. })
  8144. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8145. }
  8146. // Do executes the "gmail.users.settings.filters.delete" call.
  8147. func (c *UsersSettingsFiltersDeleteCall) Do(opts ...googleapi.CallOption) error {
  8148. gensupport.SetOptions(c.urlParams_, opts...)
  8149. res, err := c.doRequest("json")
  8150. if err != nil {
  8151. return err
  8152. }
  8153. defer googleapi.CloseBody(res)
  8154. if err := googleapi.CheckResponse(res); err != nil {
  8155. return err
  8156. }
  8157. return nil
  8158. // {
  8159. // "description": "Deletes a filter.",
  8160. // "httpMethod": "DELETE",
  8161. // "id": "gmail.users.settings.filters.delete",
  8162. // "parameterOrder": [
  8163. // "userId",
  8164. // "id"
  8165. // ],
  8166. // "parameters": {
  8167. // "id": {
  8168. // "description": "The ID of the filter to be deleted.",
  8169. // "location": "path",
  8170. // "required": true,
  8171. // "type": "string"
  8172. // },
  8173. // "userId": {
  8174. // "default": "me",
  8175. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8176. // "location": "path",
  8177. // "required": true,
  8178. // "type": "string"
  8179. // }
  8180. // },
  8181. // "path": "{userId}/settings/filters/{id}",
  8182. // "scopes": [
  8183. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8184. // ]
  8185. // }
  8186. }
  8187. // method id "gmail.users.settings.filters.get":
  8188. type UsersSettingsFiltersGetCall struct {
  8189. s *Service
  8190. userId string
  8191. id string
  8192. urlParams_ gensupport.URLParams
  8193. ifNoneMatch_ string
  8194. ctx_ context.Context
  8195. header_ http.Header
  8196. }
  8197. // Get: Gets a filter.
  8198. func (r *UsersSettingsFiltersService) Get(userId string, id string) *UsersSettingsFiltersGetCall {
  8199. c := &UsersSettingsFiltersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8200. c.userId = userId
  8201. c.id = id
  8202. return c
  8203. }
  8204. // Fields allows partial responses to be retrieved. See
  8205. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8206. // for more information.
  8207. func (c *UsersSettingsFiltersGetCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersGetCall {
  8208. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8209. return c
  8210. }
  8211. // IfNoneMatch sets the optional parameter which makes the operation
  8212. // fail if the object's ETag matches the given value. This is useful for
  8213. // getting updates only after the object has changed since the last
  8214. // request. Use googleapi.IsNotModified to check whether the response
  8215. // error from Do is the result of In-None-Match.
  8216. func (c *UsersSettingsFiltersGetCall) IfNoneMatch(entityTag string) *UsersSettingsFiltersGetCall {
  8217. c.ifNoneMatch_ = entityTag
  8218. return c
  8219. }
  8220. // Context sets the context to be used in this call's Do method. Any
  8221. // pending HTTP request will be aborted if the provided context is
  8222. // canceled.
  8223. func (c *UsersSettingsFiltersGetCall) Context(ctx context.Context) *UsersSettingsFiltersGetCall {
  8224. c.ctx_ = ctx
  8225. return c
  8226. }
  8227. // Header returns an http.Header that can be modified by the caller to
  8228. // add HTTP headers to the request.
  8229. func (c *UsersSettingsFiltersGetCall) Header() http.Header {
  8230. if c.header_ == nil {
  8231. c.header_ = make(http.Header)
  8232. }
  8233. return c.header_
  8234. }
  8235. func (c *UsersSettingsFiltersGetCall) doRequest(alt string) (*http.Response, error) {
  8236. reqHeaders := make(http.Header)
  8237. for k, v := range c.header_ {
  8238. reqHeaders[k] = v
  8239. }
  8240. reqHeaders.Set("User-Agent", c.s.userAgent())
  8241. if c.ifNoneMatch_ != "" {
  8242. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8243. }
  8244. var body io.Reader = nil
  8245. c.urlParams_.Set("alt", alt)
  8246. c.urlParams_.Set("prettyPrint", "false")
  8247. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters/{id}")
  8248. urls += "?" + c.urlParams_.Encode()
  8249. req, err := http.NewRequest("GET", urls, body)
  8250. if err != nil {
  8251. return nil, err
  8252. }
  8253. req.Header = reqHeaders
  8254. googleapi.Expand(req.URL, map[string]string{
  8255. "userId": c.userId,
  8256. "id": c.id,
  8257. })
  8258. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8259. }
  8260. // Do executes the "gmail.users.settings.filters.get" call.
  8261. // Exactly one of *Filter or error will be non-nil. Any non-2xx status
  8262. // code is an error. Response headers are in either
  8263. // *Filter.ServerResponse.Header or (if a response was returned at all)
  8264. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  8265. // check whether the returned error was because http.StatusNotModified
  8266. // was returned.
  8267. func (c *UsersSettingsFiltersGetCall) Do(opts ...googleapi.CallOption) (*Filter, error) {
  8268. gensupport.SetOptions(c.urlParams_, opts...)
  8269. res, err := c.doRequest("json")
  8270. if res != nil && res.StatusCode == http.StatusNotModified {
  8271. if res.Body != nil {
  8272. res.Body.Close()
  8273. }
  8274. return nil, &googleapi.Error{
  8275. Code: res.StatusCode,
  8276. Header: res.Header,
  8277. }
  8278. }
  8279. if err != nil {
  8280. return nil, err
  8281. }
  8282. defer googleapi.CloseBody(res)
  8283. if err := googleapi.CheckResponse(res); err != nil {
  8284. return nil, err
  8285. }
  8286. ret := &Filter{
  8287. ServerResponse: googleapi.ServerResponse{
  8288. Header: res.Header,
  8289. HTTPStatusCode: res.StatusCode,
  8290. },
  8291. }
  8292. target := &ret
  8293. if err := gensupport.DecodeResponse(target, res); err != nil {
  8294. return nil, err
  8295. }
  8296. return ret, nil
  8297. // {
  8298. // "description": "Gets a filter.",
  8299. // "httpMethod": "GET",
  8300. // "id": "gmail.users.settings.filters.get",
  8301. // "parameterOrder": [
  8302. // "userId",
  8303. // "id"
  8304. // ],
  8305. // "parameters": {
  8306. // "id": {
  8307. // "description": "The ID of the filter to be fetched.",
  8308. // "location": "path",
  8309. // "required": true,
  8310. // "type": "string"
  8311. // },
  8312. // "userId": {
  8313. // "default": "me",
  8314. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8315. // "location": "path",
  8316. // "required": true,
  8317. // "type": "string"
  8318. // }
  8319. // },
  8320. // "path": "{userId}/settings/filters/{id}",
  8321. // "response": {
  8322. // "$ref": "Filter"
  8323. // },
  8324. // "scopes": [
  8325. // "https://mail.google.com/",
  8326. // "https://www.googleapis.com/auth/gmail.modify",
  8327. // "https://www.googleapis.com/auth/gmail.readonly",
  8328. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8329. // ]
  8330. // }
  8331. }
  8332. // method id "gmail.users.settings.filters.list":
  8333. type UsersSettingsFiltersListCall struct {
  8334. s *Service
  8335. userId string
  8336. urlParams_ gensupport.URLParams
  8337. ifNoneMatch_ string
  8338. ctx_ context.Context
  8339. header_ http.Header
  8340. }
  8341. // List: Lists the message filters of a Gmail user.
  8342. func (r *UsersSettingsFiltersService) List(userId string) *UsersSettingsFiltersListCall {
  8343. c := &UsersSettingsFiltersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8344. c.userId = userId
  8345. return c
  8346. }
  8347. // Fields allows partial responses to be retrieved. See
  8348. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8349. // for more information.
  8350. func (c *UsersSettingsFiltersListCall) Fields(s ...googleapi.Field) *UsersSettingsFiltersListCall {
  8351. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8352. return c
  8353. }
  8354. // IfNoneMatch sets the optional parameter which makes the operation
  8355. // fail if the object's ETag matches the given value. This is useful for
  8356. // getting updates only after the object has changed since the last
  8357. // request. Use googleapi.IsNotModified to check whether the response
  8358. // error from Do is the result of In-None-Match.
  8359. func (c *UsersSettingsFiltersListCall) IfNoneMatch(entityTag string) *UsersSettingsFiltersListCall {
  8360. c.ifNoneMatch_ = entityTag
  8361. return c
  8362. }
  8363. // Context sets the context to be used in this call's Do method. Any
  8364. // pending HTTP request will be aborted if the provided context is
  8365. // canceled.
  8366. func (c *UsersSettingsFiltersListCall) Context(ctx context.Context) *UsersSettingsFiltersListCall {
  8367. c.ctx_ = ctx
  8368. return c
  8369. }
  8370. // Header returns an http.Header that can be modified by the caller to
  8371. // add HTTP headers to the request.
  8372. func (c *UsersSettingsFiltersListCall) Header() http.Header {
  8373. if c.header_ == nil {
  8374. c.header_ = make(http.Header)
  8375. }
  8376. return c.header_
  8377. }
  8378. func (c *UsersSettingsFiltersListCall) doRequest(alt string) (*http.Response, error) {
  8379. reqHeaders := make(http.Header)
  8380. for k, v := range c.header_ {
  8381. reqHeaders[k] = v
  8382. }
  8383. reqHeaders.Set("User-Agent", c.s.userAgent())
  8384. if c.ifNoneMatch_ != "" {
  8385. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8386. }
  8387. var body io.Reader = nil
  8388. c.urlParams_.Set("alt", alt)
  8389. c.urlParams_.Set("prettyPrint", "false")
  8390. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/filters")
  8391. urls += "?" + c.urlParams_.Encode()
  8392. req, err := http.NewRequest("GET", urls, body)
  8393. if err != nil {
  8394. return nil, err
  8395. }
  8396. req.Header = reqHeaders
  8397. googleapi.Expand(req.URL, map[string]string{
  8398. "userId": c.userId,
  8399. })
  8400. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8401. }
  8402. // Do executes the "gmail.users.settings.filters.list" call.
  8403. // Exactly one of *ListFiltersResponse or error will be non-nil. Any
  8404. // non-2xx status code is an error. Response headers are in either
  8405. // *ListFiltersResponse.ServerResponse.Header or (if a response was
  8406. // returned at all) in error.(*googleapi.Error).Header. Use
  8407. // googleapi.IsNotModified to check whether the returned error was
  8408. // because http.StatusNotModified was returned.
  8409. func (c *UsersSettingsFiltersListCall) Do(opts ...googleapi.CallOption) (*ListFiltersResponse, error) {
  8410. gensupport.SetOptions(c.urlParams_, opts...)
  8411. res, err := c.doRequest("json")
  8412. if res != nil && res.StatusCode == http.StatusNotModified {
  8413. if res.Body != nil {
  8414. res.Body.Close()
  8415. }
  8416. return nil, &googleapi.Error{
  8417. Code: res.StatusCode,
  8418. Header: res.Header,
  8419. }
  8420. }
  8421. if err != nil {
  8422. return nil, err
  8423. }
  8424. defer googleapi.CloseBody(res)
  8425. if err := googleapi.CheckResponse(res); err != nil {
  8426. return nil, err
  8427. }
  8428. ret := &ListFiltersResponse{
  8429. ServerResponse: googleapi.ServerResponse{
  8430. Header: res.Header,
  8431. HTTPStatusCode: res.StatusCode,
  8432. },
  8433. }
  8434. target := &ret
  8435. if err := gensupport.DecodeResponse(target, res); err != nil {
  8436. return nil, err
  8437. }
  8438. return ret, nil
  8439. // {
  8440. // "description": "Lists the message filters of a Gmail user.",
  8441. // "httpMethod": "GET",
  8442. // "id": "gmail.users.settings.filters.list",
  8443. // "parameterOrder": [
  8444. // "userId"
  8445. // ],
  8446. // "parameters": {
  8447. // "userId": {
  8448. // "default": "me",
  8449. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8450. // "location": "path",
  8451. // "required": true,
  8452. // "type": "string"
  8453. // }
  8454. // },
  8455. // "path": "{userId}/settings/filters",
  8456. // "response": {
  8457. // "$ref": "ListFiltersResponse"
  8458. // },
  8459. // "scopes": [
  8460. // "https://mail.google.com/",
  8461. // "https://www.googleapis.com/auth/gmail.modify",
  8462. // "https://www.googleapis.com/auth/gmail.readonly",
  8463. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8464. // ]
  8465. // }
  8466. }
  8467. // method id "gmail.users.settings.forwardingAddresses.create":
  8468. type UsersSettingsForwardingAddressesCreateCall struct {
  8469. s *Service
  8470. userId string
  8471. forwardingaddress *ForwardingAddress
  8472. urlParams_ gensupport.URLParams
  8473. ctx_ context.Context
  8474. header_ http.Header
  8475. }
  8476. // Create: Creates a forwarding address. If ownership verification is
  8477. // required, a message will be sent to the recipient and the resource's
  8478. // verification status will be set to pending; otherwise, the resource
  8479. // will be created with verification status set to accepted.
  8480. //
  8481. // This method is only available to service account clients that have
  8482. // been delegated domain-wide authority.
  8483. func (r *UsersSettingsForwardingAddressesService) Create(userId string, forwardingaddress *ForwardingAddress) *UsersSettingsForwardingAddressesCreateCall {
  8484. c := &UsersSettingsForwardingAddressesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8485. c.userId = userId
  8486. c.forwardingaddress = forwardingaddress
  8487. return c
  8488. }
  8489. // Fields allows partial responses to be retrieved. See
  8490. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8491. // for more information.
  8492. func (c *UsersSettingsForwardingAddressesCreateCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesCreateCall {
  8493. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8494. return c
  8495. }
  8496. // Context sets the context to be used in this call's Do method. Any
  8497. // pending HTTP request will be aborted if the provided context is
  8498. // canceled.
  8499. func (c *UsersSettingsForwardingAddressesCreateCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesCreateCall {
  8500. c.ctx_ = ctx
  8501. return c
  8502. }
  8503. // Header returns an http.Header that can be modified by the caller to
  8504. // add HTTP headers to the request.
  8505. func (c *UsersSettingsForwardingAddressesCreateCall) Header() http.Header {
  8506. if c.header_ == nil {
  8507. c.header_ = make(http.Header)
  8508. }
  8509. return c.header_
  8510. }
  8511. func (c *UsersSettingsForwardingAddressesCreateCall) doRequest(alt string) (*http.Response, error) {
  8512. reqHeaders := make(http.Header)
  8513. for k, v := range c.header_ {
  8514. reqHeaders[k] = v
  8515. }
  8516. reqHeaders.Set("User-Agent", c.s.userAgent())
  8517. var body io.Reader = nil
  8518. body, err := googleapi.WithoutDataWrapper.JSONReader(c.forwardingaddress)
  8519. if err != nil {
  8520. return nil, err
  8521. }
  8522. reqHeaders.Set("Content-Type", "application/json")
  8523. c.urlParams_.Set("alt", alt)
  8524. c.urlParams_.Set("prettyPrint", "false")
  8525. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses")
  8526. urls += "?" + c.urlParams_.Encode()
  8527. req, err := http.NewRequest("POST", urls, body)
  8528. if err != nil {
  8529. return nil, err
  8530. }
  8531. req.Header = reqHeaders
  8532. googleapi.Expand(req.URL, map[string]string{
  8533. "userId": c.userId,
  8534. })
  8535. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8536. }
  8537. // Do executes the "gmail.users.settings.forwardingAddresses.create" call.
  8538. // Exactly one of *ForwardingAddress or error will be non-nil. Any
  8539. // non-2xx status code is an error. Response headers are in either
  8540. // *ForwardingAddress.ServerResponse.Header or (if a response was
  8541. // returned at all) in error.(*googleapi.Error).Header. Use
  8542. // googleapi.IsNotModified to check whether the returned error was
  8543. // because http.StatusNotModified was returned.
  8544. func (c *UsersSettingsForwardingAddressesCreateCall) Do(opts ...googleapi.CallOption) (*ForwardingAddress, error) {
  8545. gensupport.SetOptions(c.urlParams_, opts...)
  8546. res, err := c.doRequest("json")
  8547. if res != nil && res.StatusCode == http.StatusNotModified {
  8548. if res.Body != nil {
  8549. res.Body.Close()
  8550. }
  8551. return nil, &googleapi.Error{
  8552. Code: res.StatusCode,
  8553. Header: res.Header,
  8554. }
  8555. }
  8556. if err != nil {
  8557. return nil, err
  8558. }
  8559. defer googleapi.CloseBody(res)
  8560. if err := googleapi.CheckResponse(res); err != nil {
  8561. return nil, err
  8562. }
  8563. ret := &ForwardingAddress{
  8564. ServerResponse: googleapi.ServerResponse{
  8565. Header: res.Header,
  8566. HTTPStatusCode: res.StatusCode,
  8567. },
  8568. }
  8569. target := &ret
  8570. if err := gensupport.DecodeResponse(target, res); err != nil {
  8571. return nil, err
  8572. }
  8573. return ret, nil
  8574. // {
  8575. // "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.",
  8576. // "httpMethod": "POST",
  8577. // "id": "gmail.users.settings.forwardingAddresses.create",
  8578. // "parameterOrder": [
  8579. // "userId"
  8580. // ],
  8581. // "parameters": {
  8582. // "userId": {
  8583. // "default": "me",
  8584. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8585. // "location": "path",
  8586. // "required": true,
  8587. // "type": "string"
  8588. // }
  8589. // },
  8590. // "path": "{userId}/settings/forwardingAddresses",
  8591. // "request": {
  8592. // "$ref": "ForwardingAddress"
  8593. // },
  8594. // "response": {
  8595. // "$ref": "ForwardingAddress"
  8596. // },
  8597. // "scopes": [
  8598. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  8599. // ]
  8600. // }
  8601. }
  8602. // method id "gmail.users.settings.forwardingAddresses.delete":
  8603. type UsersSettingsForwardingAddressesDeleteCall struct {
  8604. s *Service
  8605. userId string
  8606. forwardingEmail string
  8607. urlParams_ gensupport.URLParams
  8608. ctx_ context.Context
  8609. header_ http.Header
  8610. }
  8611. // Delete: Deletes the specified forwarding address and revokes any
  8612. // verification that may have been required.
  8613. //
  8614. // This method is only available to service account clients that have
  8615. // been delegated domain-wide authority.
  8616. func (r *UsersSettingsForwardingAddressesService) Delete(userId string, forwardingEmail string) *UsersSettingsForwardingAddressesDeleteCall {
  8617. c := &UsersSettingsForwardingAddressesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8618. c.userId = userId
  8619. c.forwardingEmail = forwardingEmail
  8620. return c
  8621. }
  8622. // Fields allows partial responses to be retrieved. See
  8623. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8624. // for more information.
  8625. func (c *UsersSettingsForwardingAddressesDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesDeleteCall {
  8626. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8627. return c
  8628. }
  8629. // Context sets the context to be used in this call's Do method. Any
  8630. // pending HTTP request will be aborted if the provided context is
  8631. // canceled.
  8632. func (c *UsersSettingsForwardingAddressesDeleteCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesDeleteCall {
  8633. c.ctx_ = ctx
  8634. return c
  8635. }
  8636. // Header returns an http.Header that can be modified by the caller to
  8637. // add HTTP headers to the request.
  8638. func (c *UsersSettingsForwardingAddressesDeleteCall) Header() http.Header {
  8639. if c.header_ == nil {
  8640. c.header_ = make(http.Header)
  8641. }
  8642. return c.header_
  8643. }
  8644. func (c *UsersSettingsForwardingAddressesDeleteCall) doRequest(alt string) (*http.Response, error) {
  8645. reqHeaders := make(http.Header)
  8646. for k, v := range c.header_ {
  8647. reqHeaders[k] = v
  8648. }
  8649. reqHeaders.Set("User-Agent", c.s.userAgent())
  8650. var body io.Reader = nil
  8651. c.urlParams_.Set("alt", alt)
  8652. c.urlParams_.Set("prettyPrint", "false")
  8653. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses/{forwardingEmail}")
  8654. urls += "?" + c.urlParams_.Encode()
  8655. req, err := http.NewRequest("DELETE", urls, body)
  8656. if err != nil {
  8657. return nil, err
  8658. }
  8659. req.Header = reqHeaders
  8660. googleapi.Expand(req.URL, map[string]string{
  8661. "userId": c.userId,
  8662. "forwardingEmail": c.forwardingEmail,
  8663. })
  8664. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8665. }
  8666. // Do executes the "gmail.users.settings.forwardingAddresses.delete" call.
  8667. func (c *UsersSettingsForwardingAddressesDeleteCall) Do(opts ...googleapi.CallOption) error {
  8668. gensupport.SetOptions(c.urlParams_, opts...)
  8669. res, err := c.doRequest("json")
  8670. if err != nil {
  8671. return err
  8672. }
  8673. defer googleapi.CloseBody(res)
  8674. if err := googleapi.CheckResponse(res); err != nil {
  8675. return err
  8676. }
  8677. return nil
  8678. // {
  8679. // "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.",
  8680. // "httpMethod": "DELETE",
  8681. // "id": "gmail.users.settings.forwardingAddresses.delete",
  8682. // "parameterOrder": [
  8683. // "userId",
  8684. // "forwardingEmail"
  8685. // ],
  8686. // "parameters": {
  8687. // "forwardingEmail": {
  8688. // "description": "The forwarding address to be deleted.",
  8689. // "location": "path",
  8690. // "required": true,
  8691. // "type": "string"
  8692. // },
  8693. // "userId": {
  8694. // "default": "me",
  8695. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8696. // "location": "path",
  8697. // "required": true,
  8698. // "type": "string"
  8699. // }
  8700. // },
  8701. // "path": "{userId}/settings/forwardingAddresses/{forwardingEmail}",
  8702. // "scopes": [
  8703. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  8704. // ]
  8705. // }
  8706. }
  8707. // method id "gmail.users.settings.forwardingAddresses.get":
  8708. type UsersSettingsForwardingAddressesGetCall struct {
  8709. s *Service
  8710. userId string
  8711. forwardingEmail string
  8712. urlParams_ gensupport.URLParams
  8713. ifNoneMatch_ string
  8714. ctx_ context.Context
  8715. header_ http.Header
  8716. }
  8717. // Get: Gets the specified forwarding address.
  8718. func (r *UsersSettingsForwardingAddressesService) Get(userId string, forwardingEmail string) *UsersSettingsForwardingAddressesGetCall {
  8719. c := &UsersSettingsForwardingAddressesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8720. c.userId = userId
  8721. c.forwardingEmail = forwardingEmail
  8722. return c
  8723. }
  8724. // Fields allows partial responses to be retrieved. See
  8725. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8726. // for more information.
  8727. func (c *UsersSettingsForwardingAddressesGetCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesGetCall {
  8728. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8729. return c
  8730. }
  8731. // IfNoneMatch sets the optional parameter which makes the operation
  8732. // fail if the object's ETag matches the given value. This is useful for
  8733. // getting updates only after the object has changed since the last
  8734. // request. Use googleapi.IsNotModified to check whether the response
  8735. // error from Do is the result of In-None-Match.
  8736. func (c *UsersSettingsForwardingAddressesGetCall) IfNoneMatch(entityTag string) *UsersSettingsForwardingAddressesGetCall {
  8737. c.ifNoneMatch_ = entityTag
  8738. return c
  8739. }
  8740. // Context sets the context to be used in this call's Do method. Any
  8741. // pending HTTP request will be aborted if the provided context is
  8742. // canceled.
  8743. func (c *UsersSettingsForwardingAddressesGetCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesGetCall {
  8744. c.ctx_ = ctx
  8745. return c
  8746. }
  8747. // Header returns an http.Header that can be modified by the caller to
  8748. // add HTTP headers to the request.
  8749. func (c *UsersSettingsForwardingAddressesGetCall) Header() http.Header {
  8750. if c.header_ == nil {
  8751. c.header_ = make(http.Header)
  8752. }
  8753. return c.header_
  8754. }
  8755. func (c *UsersSettingsForwardingAddressesGetCall) doRequest(alt string) (*http.Response, error) {
  8756. reqHeaders := make(http.Header)
  8757. for k, v := range c.header_ {
  8758. reqHeaders[k] = v
  8759. }
  8760. reqHeaders.Set("User-Agent", c.s.userAgent())
  8761. if c.ifNoneMatch_ != "" {
  8762. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8763. }
  8764. var body io.Reader = nil
  8765. c.urlParams_.Set("alt", alt)
  8766. c.urlParams_.Set("prettyPrint", "false")
  8767. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses/{forwardingEmail}")
  8768. urls += "?" + c.urlParams_.Encode()
  8769. req, err := http.NewRequest("GET", urls, body)
  8770. if err != nil {
  8771. return nil, err
  8772. }
  8773. req.Header = reqHeaders
  8774. googleapi.Expand(req.URL, map[string]string{
  8775. "userId": c.userId,
  8776. "forwardingEmail": c.forwardingEmail,
  8777. })
  8778. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8779. }
  8780. // Do executes the "gmail.users.settings.forwardingAddresses.get" call.
  8781. // Exactly one of *ForwardingAddress or error will be non-nil. Any
  8782. // non-2xx status code is an error. Response headers are in either
  8783. // *ForwardingAddress.ServerResponse.Header or (if a response was
  8784. // returned at all) in error.(*googleapi.Error).Header. Use
  8785. // googleapi.IsNotModified to check whether the returned error was
  8786. // because http.StatusNotModified was returned.
  8787. func (c *UsersSettingsForwardingAddressesGetCall) Do(opts ...googleapi.CallOption) (*ForwardingAddress, error) {
  8788. gensupport.SetOptions(c.urlParams_, opts...)
  8789. res, err := c.doRequest("json")
  8790. if res != nil && res.StatusCode == http.StatusNotModified {
  8791. if res.Body != nil {
  8792. res.Body.Close()
  8793. }
  8794. return nil, &googleapi.Error{
  8795. Code: res.StatusCode,
  8796. Header: res.Header,
  8797. }
  8798. }
  8799. if err != nil {
  8800. return nil, err
  8801. }
  8802. defer googleapi.CloseBody(res)
  8803. if err := googleapi.CheckResponse(res); err != nil {
  8804. return nil, err
  8805. }
  8806. ret := &ForwardingAddress{
  8807. ServerResponse: googleapi.ServerResponse{
  8808. Header: res.Header,
  8809. HTTPStatusCode: res.StatusCode,
  8810. },
  8811. }
  8812. target := &ret
  8813. if err := gensupport.DecodeResponse(target, res); err != nil {
  8814. return nil, err
  8815. }
  8816. return ret, nil
  8817. // {
  8818. // "description": "Gets the specified forwarding address.",
  8819. // "httpMethod": "GET",
  8820. // "id": "gmail.users.settings.forwardingAddresses.get",
  8821. // "parameterOrder": [
  8822. // "userId",
  8823. // "forwardingEmail"
  8824. // ],
  8825. // "parameters": {
  8826. // "forwardingEmail": {
  8827. // "description": "The forwarding address to be retrieved.",
  8828. // "location": "path",
  8829. // "required": true,
  8830. // "type": "string"
  8831. // },
  8832. // "userId": {
  8833. // "default": "me",
  8834. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8835. // "location": "path",
  8836. // "required": true,
  8837. // "type": "string"
  8838. // }
  8839. // },
  8840. // "path": "{userId}/settings/forwardingAddresses/{forwardingEmail}",
  8841. // "response": {
  8842. // "$ref": "ForwardingAddress"
  8843. // },
  8844. // "scopes": [
  8845. // "https://mail.google.com/",
  8846. // "https://www.googleapis.com/auth/gmail.modify",
  8847. // "https://www.googleapis.com/auth/gmail.readonly",
  8848. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8849. // ]
  8850. // }
  8851. }
  8852. // method id "gmail.users.settings.forwardingAddresses.list":
  8853. type UsersSettingsForwardingAddressesListCall struct {
  8854. s *Service
  8855. userId string
  8856. urlParams_ gensupport.URLParams
  8857. ifNoneMatch_ string
  8858. ctx_ context.Context
  8859. header_ http.Header
  8860. }
  8861. // List: Lists the forwarding addresses for the specified account.
  8862. func (r *UsersSettingsForwardingAddressesService) List(userId string) *UsersSettingsForwardingAddressesListCall {
  8863. c := &UsersSettingsForwardingAddressesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  8864. c.userId = userId
  8865. return c
  8866. }
  8867. // Fields allows partial responses to be retrieved. See
  8868. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  8869. // for more information.
  8870. func (c *UsersSettingsForwardingAddressesListCall) Fields(s ...googleapi.Field) *UsersSettingsForwardingAddressesListCall {
  8871. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  8872. return c
  8873. }
  8874. // IfNoneMatch sets the optional parameter which makes the operation
  8875. // fail if the object's ETag matches the given value. This is useful for
  8876. // getting updates only after the object has changed since the last
  8877. // request. Use googleapi.IsNotModified to check whether the response
  8878. // error from Do is the result of In-None-Match.
  8879. func (c *UsersSettingsForwardingAddressesListCall) IfNoneMatch(entityTag string) *UsersSettingsForwardingAddressesListCall {
  8880. c.ifNoneMatch_ = entityTag
  8881. return c
  8882. }
  8883. // Context sets the context to be used in this call's Do method. Any
  8884. // pending HTTP request will be aborted if the provided context is
  8885. // canceled.
  8886. func (c *UsersSettingsForwardingAddressesListCall) Context(ctx context.Context) *UsersSettingsForwardingAddressesListCall {
  8887. c.ctx_ = ctx
  8888. return c
  8889. }
  8890. // Header returns an http.Header that can be modified by the caller to
  8891. // add HTTP headers to the request.
  8892. func (c *UsersSettingsForwardingAddressesListCall) Header() http.Header {
  8893. if c.header_ == nil {
  8894. c.header_ = make(http.Header)
  8895. }
  8896. return c.header_
  8897. }
  8898. func (c *UsersSettingsForwardingAddressesListCall) doRequest(alt string) (*http.Response, error) {
  8899. reqHeaders := make(http.Header)
  8900. for k, v := range c.header_ {
  8901. reqHeaders[k] = v
  8902. }
  8903. reqHeaders.Set("User-Agent", c.s.userAgent())
  8904. if c.ifNoneMatch_ != "" {
  8905. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  8906. }
  8907. var body io.Reader = nil
  8908. c.urlParams_.Set("alt", alt)
  8909. c.urlParams_.Set("prettyPrint", "false")
  8910. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/forwardingAddresses")
  8911. urls += "?" + c.urlParams_.Encode()
  8912. req, err := http.NewRequest("GET", urls, body)
  8913. if err != nil {
  8914. return nil, err
  8915. }
  8916. req.Header = reqHeaders
  8917. googleapi.Expand(req.URL, map[string]string{
  8918. "userId": c.userId,
  8919. })
  8920. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  8921. }
  8922. // Do executes the "gmail.users.settings.forwardingAddresses.list" call.
  8923. // Exactly one of *ListForwardingAddressesResponse or error will be
  8924. // non-nil. Any non-2xx status code is an error. Response headers are in
  8925. // either *ListForwardingAddressesResponse.ServerResponse.Header or (if
  8926. // a response was returned at all) in error.(*googleapi.Error).Header.
  8927. // Use googleapi.IsNotModified to check whether the returned error was
  8928. // because http.StatusNotModified was returned.
  8929. func (c *UsersSettingsForwardingAddressesListCall) Do(opts ...googleapi.CallOption) (*ListForwardingAddressesResponse, error) {
  8930. gensupport.SetOptions(c.urlParams_, opts...)
  8931. res, err := c.doRequest("json")
  8932. if res != nil && res.StatusCode == http.StatusNotModified {
  8933. if res.Body != nil {
  8934. res.Body.Close()
  8935. }
  8936. return nil, &googleapi.Error{
  8937. Code: res.StatusCode,
  8938. Header: res.Header,
  8939. }
  8940. }
  8941. if err != nil {
  8942. return nil, err
  8943. }
  8944. defer googleapi.CloseBody(res)
  8945. if err := googleapi.CheckResponse(res); err != nil {
  8946. return nil, err
  8947. }
  8948. ret := &ListForwardingAddressesResponse{
  8949. ServerResponse: googleapi.ServerResponse{
  8950. Header: res.Header,
  8951. HTTPStatusCode: res.StatusCode,
  8952. },
  8953. }
  8954. target := &ret
  8955. if err := gensupport.DecodeResponse(target, res); err != nil {
  8956. return nil, err
  8957. }
  8958. return ret, nil
  8959. // {
  8960. // "description": "Lists the forwarding addresses for the specified account.",
  8961. // "httpMethod": "GET",
  8962. // "id": "gmail.users.settings.forwardingAddresses.list",
  8963. // "parameterOrder": [
  8964. // "userId"
  8965. // ],
  8966. // "parameters": {
  8967. // "userId": {
  8968. // "default": "me",
  8969. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  8970. // "location": "path",
  8971. // "required": true,
  8972. // "type": "string"
  8973. // }
  8974. // },
  8975. // "path": "{userId}/settings/forwardingAddresses",
  8976. // "response": {
  8977. // "$ref": "ListForwardingAddressesResponse"
  8978. // },
  8979. // "scopes": [
  8980. // "https://mail.google.com/",
  8981. // "https://www.googleapis.com/auth/gmail.modify",
  8982. // "https://www.googleapis.com/auth/gmail.readonly",
  8983. // "https://www.googleapis.com/auth/gmail.settings.basic"
  8984. // ]
  8985. // }
  8986. }
  8987. // method id "gmail.users.settings.sendAs.create":
  8988. type UsersSettingsSendAsCreateCall struct {
  8989. s *Service
  8990. userId string
  8991. sendas *SendAs
  8992. urlParams_ gensupport.URLParams
  8993. ctx_ context.Context
  8994. header_ http.Header
  8995. }
  8996. // Create: Creates a custom "from" send-as alias. If an SMTP MSA is
  8997. // specified, Gmail will attempt to connect to the SMTP service to
  8998. // validate the configuration before creating the alias. If ownership
  8999. // verification is required for the alias, a message will be sent to the
  9000. // email address and the resource's verification status will be set to
  9001. // pending; otherwise, the resource will be created with verification
  9002. // status set to accepted. If a signature is provided, Gmail will
  9003. // sanitize the HTML before saving it with the alias.
  9004. //
  9005. // This method is only available to service account clients that have
  9006. // been delegated domain-wide authority.
  9007. func (r *UsersSettingsSendAsService) Create(userId string, sendas *SendAs) *UsersSettingsSendAsCreateCall {
  9008. c := &UsersSettingsSendAsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9009. c.userId = userId
  9010. c.sendas = sendas
  9011. return c
  9012. }
  9013. // Fields allows partial responses to be retrieved. See
  9014. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9015. // for more information.
  9016. func (c *UsersSettingsSendAsCreateCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsCreateCall {
  9017. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9018. return c
  9019. }
  9020. // Context sets the context to be used in this call's Do method. Any
  9021. // pending HTTP request will be aborted if the provided context is
  9022. // canceled.
  9023. func (c *UsersSettingsSendAsCreateCall) Context(ctx context.Context) *UsersSettingsSendAsCreateCall {
  9024. c.ctx_ = ctx
  9025. return c
  9026. }
  9027. // Header returns an http.Header that can be modified by the caller to
  9028. // add HTTP headers to the request.
  9029. func (c *UsersSettingsSendAsCreateCall) Header() http.Header {
  9030. if c.header_ == nil {
  9031. c.header_ = make(http.Header)
  9032. }
  9033. return c.header_
  9034. }
  9035. func (c *UsersSettingsSendAsCreateCall) doRequest(alt string) (*http.Response, error) {
  9036. reqHeaders := make(http.Header)
  9037. for k, v := range c.header_ {
  9038. reqHeaders[k] = v
  9039. }
  9040. reqHeaders.Set("User-Agent", c.s.userAgent())
  9041. var body io.Reader = nil
  9042. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sendas)
  9043. if err != nil {
  9044. return nil, err
  9045. }
  9046. reqHeaders.Set("Content-Type", "application/json")
  9047. c.urlParams_.Set("alt", alt)
  9048. c.urlParams_.Set("prettyPrint", "false")
  9049. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs")
  9050. urls += "?" + c.urlParams_.Encode()
  9051. req, err := http.NewRequest("POST", urls, body)
  9052. if err != nil {
  9053. return nil, err
  9054. }
  9055. req.Header = reqHeaders
  9056. googleapi.Expand(req.URL, map[string]string{
  9057. "userId": c.userId,
  9058. })
  9059. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9060. }
  9061. // Do executes the "gmail.users.settings.sendAs.create" call.
  9062. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  9063. // code is an error. Response headers are in either
  9064. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  9065. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  9066. // check whether the returned error was because http.StatusNotModified
  9067. // was returned.
  9068. func (c *UsersSettingsSendAsCreateCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  9069. gensupport.SetOptions(c.urlParams_, opts...)
  9070. res, err := c.doRequest("json")
  9071. if res != nil && res.StatusCode == http.StatusNotModified {
  9072. if res.Body != nil {
  9073. res.Body.Close()
  9074. }
  9075. return nil, &googleapi.Error{
  9076. Code: res.StatusCode,
  9077. Header: res.Header,
  9078. }
  9079. }
  9080. if err != nil {
  9081. return nil, err
  9082. }
  9083. defer googleapi.CloseBody(res)
  9084. if err := googleapi.CheckResponse(res); err != nil {
  9085. return nil, err
  9086. }
  9087. ret := &SendAs{
  9088. ServerResponse: googleapi.ServerResponse{
  9089. Header: res.Header,
  9090. HTTPStatusCode: res.StatusCode,
  9091. },
  9092. }
  9093. target := &ret
  9094. if err := gensupport.DecodeResponse(target, res); err != nil {
  9095. return nil, err
  9096. }
  9097. return ret, nil
  9098. // {
  9099. // "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.",
  9100. // "httpMethod": "POST",
  9101. // "id": "gmail.users.settings.sendAs.create",
  9102. // "parameterOrder": [
  9103. // "userId"
  9104. // ],
  9105. // "parameters": {
  9106. // "userId": {
  9107. // "default": "me",
  9108. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9109. // "location": "path",
  9110. // "required": true,
  9111. // "type": "string"
  9112. // }
  9113. // },
  9114. // "path": "{userId}/settings/sendAs",
  9115. // "request": {
  9116. // "$ref": "SendAs"
  9117. // },
  9118. // "response": {
  9119. // "$ref": "SendAs"
  9120. // },
  9121. // "scopes": [
  9122. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9123. // ]
  9124. // }
  9125. }
  9126. // method id "gmail.users.settings.sendAs.delete":
  9127. type UsersSettingsSendAsDeleteCall struct {
  9128. s *Service
  9129. userId string
  9130. sendAsEmail string
  9131. urlParams_ gensupport.URLParams
  9132. ctx_ context.Context
  9133. header_ http.Header
  9134. }
  9135. // Delete: Deletes the specified send-as alias. Revokes any verification
  9136. // that may have been required for using it.
  9137. //
  9138. // This method is only available to service account clients that have
  9139. // been delegated domain-wide authority.
  9140. func (r *UsersSettingsSendAsService) Delete(userId string, sendAsEmail string) *UsersSettingsSendAsDeleteCall {
  9141. c := &UsersSettingsSendAsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9142. c.userId = userId
  9143. c.sendAsEmail = sendAsEmail
  9144. return c
  9145. }
  9146. // Fields allows partial responses to be retrieved. See
  9147. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9148. // for more information.
  9149. func (c *UsersSettingsSendAsDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsDeleteCall {
  9150. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9151. return c
  9152. }
  9153. // Context sets the context to be used in this call's Do method. Any
  9154. // pending HTTP request will be aborted if the provided context is
  9155. // canceled.
  9156. func (c *UsersSettingsSendAsDeleteCall) Context(ctx context.Context) *UsersSettingsSendAsDeleteCall {
  9157. c.ctx_ = ctx
  9158. return c
  9159. }
  9160. // Header returns an http.Header that can be modified by the caller to
  9161. // add HTTP headers to the request.
  9162. func (c *UsersSettingsSendAsDeleteCall) Header() http.Header {
  9163. if c.header_ == nil {
  9164. c.header_ = make(http.Header)
  9165. }
  9166. return c.header_
  9167. }
  9168. func (c *UsersSettingsSendAsDeleteCall) doRequest(alt string) (*http.Response, error) {
  9169. reqHeaders := make(http.Header)
  9170. for k, v := range c.header_ {
  9171. reqHeaders[k] = v
  9172. }
  9173. reqHeaders.Set("User-Agent", c.s.userAgent())
  9174. var body io.Reader = nil
  9175. c.urlParams_.Set("alt", alt)
  9176. c.urlParams_.Set("prettyPrint", "false")
  9177. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  9178. urls += "?" + c.urlParams_.Encode()
  9179. req, err := http.NewRequest("DELETE", urls, body)
  9180. if err != nil {
  9181. return nil, err
  9182. }
  9183. req.Header = reqHeaders
  9184. googleapi.Expand(req.URL, map[string]string{
  9185. "userId": c.userId,
  9186. "sendAsEmail": c.sendAsEmail,
  9187. })
  9188. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9189. }
  9190. // Do executes the "gmail.users.settings.sendAs.delete" call.
  9191. func (c *UsersSettingsSendAsDeleteCall) Do(opts ...googleapi.CallOption) error {
  9192. gensupport.SetOptions(c.urlParams_, opts...)
  9193. res, err := c.doRequest("json")
  9194. if err != nil {
  9195. return err
  9196. }
  9197. defer googleapi.CloseBody(res)
  9198. if err := googleapi.CheckResponse(res); err != nil {
  9199. return err
  9200. }
  9201. return nil
  9202. // {
  9203. // "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.",
  9204. // "httpMethod": "DELETE",
  9205. // "id": "gmail.users.settings.sendAs.delete",
  9206. // "parameterOrder": [
  9207. // "userId",
  9208. // "sendAsEmail"
  9209. // ],
  9210. // "parameters": {
  9211. // "sendAsEmail": {
  9212. // "description": "The send-as alias to be deleted.",
  9213. // "location": "path",
  9214. // "required": true,
  9215. // "type": "string"
  9216. // },
  9217. // "userId": {
  9218. // "default": "me",
  9219. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9220. // "location": "path",
  9221. // "required": true,
  9222. // "type": "string"
  9223. // }
  9224. // },
  9225. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  9226. // "scopes": [
  9227. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9228. // ]
  9229. // }
  9230. }
  9231. // method id "gmail.users.settings.sendAs.get":
  9232. type UsersSettingsSendAsGetCall struct {
  9233. s *Service
  9234. userId string
  9235. sendAsEmail string
  9236. urlParams_ gensupport.URLParams
  9237. ifNoneMatch_ string
  9238. ctx_ context.Context
  9239. header_ http.Header
  9240. }
  9241. // Get: Gets the specified send-as alias. Fails with an HTTP 404 error
  9242. // if the specified address is not a member of the collection.
  9243. func (r *UsersSettingsSendAsService) Get(userId string, sendAsEmail string) *UsersSettingsSendAsGetCall {
  9244. c := &UsersSettingsSendAsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9245. c.userId = userId
  9246. c.sendAsEmail = sendAsEmail
  9247. return c
  9248. }
  9249. // Fields allows partial responses to be retrieved. See
  9250. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9251. // for more information.
  9252. func (c *UsersSettingsSendAsGetCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsGetCall {
  9253. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9254. return c
  9255. }
  9256. // IfNoneMatch sets the optional parameter which makes the operation
  9257. // fail if the object's ETag matches the given value. This is useful for
  9258. // getting updates only after the object has changed since the last
  9259. // request. Use googleapi.IsNotModified to check whether the response
  9260. // error from Do is the result of In-None-Match.
  9261. func (c *UsersSettingsSendAsGetCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsGetCall {
  9262. c.ifNoneMatch_ = entityTag
  9263. return c
  9264. }
  9265. // Context sets the context to be used in this call's Do method. Any
  9266. // pending HTTP request will be aborted if the provided context is
  9267. // canceled.
  9268. func (c *UsersSettingsSendAsGetCall) Context(ctx context.Context) *UsersSettingsSendAsGetCall {
  9269. c.ctx_ = ctx
  9270. return c
  9271. }
  9272. // Header returns an http.Header that can be modified by the caller to
  9273. // add HTTP headers to the request.
  9274. func (c *UsersSettingsSendAsGetCall) Header() http.Header {
  9275. if c.header_ == nil {
  9276. c.header_ = make(http.Header)
  9277. }
  9278. return c.header_
  9279. }
  9280. func (c *UsersSettingsSendAsGetCall) doRequest(alt string) (*http.Response, error) {
  9281. reqHeaders := make(http.Header)
  9282. for k, v := range c.header_ {
  9283. reqHeaders[k] = v
  9284. }
  9285. reqHeaders.Set("User-Agent", c.s.userAgent())
  9286. if c.ifNoneMatch_ != "" {
  9287. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  9288. }
  9289. var body io.Reader = nil
  9290. c.urlParams_.Set("alt", alt)
  9291. c.urlParams_.Set("prettyPrint", "false")
  9292. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  9293. urls += "?" + c.urlParams_.Encode()
  9294. req, err := http.NewRequest("GET", urls, body)
  9295. if err != nil {
  9296. return nil, err
  9297. }
  9298. req.Header = reqHeaders
  9299. googleapi.Expand(req.URL, map[string]string{
  9300. "userId": c.userId,
  9301. "sendAsEmail": c.sendAsEmail,
  9302. })
  9303. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9304. }
  9305. // Do executes the "gmail.users.settings.sendAs.get" call.
  9306. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  9307. // code is an error. Response headers are in either
  9308. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  9309. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  9310. // check whether the returned error was because http.StatusNotModified
  9311. // was returned.
  9312. func (c *UsersSettingsSendAsGetCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  9313. gensupport.SetOptions(c.urlParams_, opts...)
  9314. res, err := c.doRequest("json")
  9315. if res != nil && res.StatusCode == http.StatusNotModified {
  9316. if res.Body != nil {
  9317. res.Body.Close()
  9318. }
  9319. return nil, &googleapi.Error{
  9320. Code: res.StatusCode,
  9321. Header: res.Header,
  9322. }
  9323. }
  9324. if err != nil {
  9325. return nil, err
  9326. }
  9327. defer googleapi.CloseBody(res)
  9328. if err := googleapi.CheckResponse(res); err != nil {
  9329. return nil, err
  9330. }
  9331. ret := &SendAs{
  9332. ServerResponse: googleapi.ServerResponse{
  9333. Header: res.Header,
  9334. HTTPStatusCode: res.StatusCode,
  9335. },
  9336. }
  9337. target := &ret
  9338. if err := gensupport.DecodeResponse(target, res); err != nil {
  9339. return nil, err
  9340. }
  9341. return ret, nil
  9342. // {
  9343. // "description": "Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection.",
  9344. // "httpMethod": "GET",
  9345. // "id": "gmail.users.settings.sendAs.get",
  9346. // "parameterOrder": [
  9347. // "userId",
  9348. // "sendAsEmail"
  9349. // ],
  9350. // "parameters": {
  9351. // "sendAsEmail": {
  9352. // "description": "The send-as alias to be retrieved.",
  9353. // "location": "path",
  9354. // "required": true,
  9355. // "type": "string"
  9356. // },
  9357. // "userId": {
  9358. // "default": "me",
  9359. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9360. // "location": "path",
  9361. // "required": true,
  9362. // "type": "string"
  9363. // }
  9364. // },
  9365. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  9366. // "response": {
  9367. // "$ref": "SendAs"
  9368. // },
  9369. // "scopes": [
  9370. // "https://mail.google.com/",
  9371. // "https://www.googleapis.com/auth/gmail.modify",
  9372. // "https://www.googleapis.com/auth/gmail.readonly",
  9373. // "https://www.googleapis.com/auth/gmail.settings.basic"
  9374. // ]
  9375. // }
  9376. }
  9377. // method id "gmail.users.settings.sendAs.list":
  9378. type UsersSettingsSendAsListCall struct {
  9379. s *Service
  9380. userId string
  9381. urlParams_ gensupport.URLParams
  9382. ifNoneMatch_ string
  9383. ctx_ context.Context
  9384. header_ http.Header
  9385. }
  9386. // List: Lists the send-as aliases for the specified account. The result
  9387. // includes the primary send-as address associated with the account as
  9388. // well as any custom "from" aliases.
  9389. func (r *UsersSettingsSendAsService) List(userId string) *UsersSettingsSendAsListCall {
  9390. c := &UsersSettingsSendAsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9391. c.userId = userId
  9392. return c
  9393. }
  9394. // Fields allows partial responses to be retrieved. See
  9395. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9396. // for more information.
  9397. func (c *UsersSettingsSendAsListCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsListCall {
  9398. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9399. return c
  9400. }
  9401. // IfNoneMatch sets the optional parameter which makes the operation
  9402. // fail if the object's ETag matches the given value. This is useful for
  9403. // getting updates only after the object has changed since the last
  9404. // request. Use googleapi.IsNotModified to check whether the response
  9405. // error from Do is the result of In-None-Match.
  9406. func (c *UsersSettingsSendAsListCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsListCall {
  9407. c.ifNoneMatch_ = entityTag
  9408. return c
  9409. }
  9410. // Context sets the context to be used in this call's Do method. Any
  9411. // pending HTTP request will be aborted if the provided context is
  9412. // canceled.
  9413. func (c *UsersSettingsSendAsListCall) Context(ctx context.Context) *UsersSettingsSendAsListCall {
  9414. c.ctx_ = ctx
  9415. return c
  9416. }
  9417. // Header returns an http.Header that can be modified by the caller to
  9418. // add HTTP headers to the request.
  9419. func (c *UsersSettingsSendAsListCall) Header() http.Header {
  9420. if c.header_ == nil {
  9421. c.header_ = make(http.Header)
  9422. }
  9423. return c.header_
  9424. }
  9425. func (c *UsersSettingsSendAsListCall) doRequest(alt string) (*http.Response, error) {
  9426. reqHeaders := make(http.Header)
  9427. for k, v := range c.header_ {
  9428. reqHeaders[k] = v
  9429. }
  9430. reqHeaders.Set("User-Agent", c.s.userAgent())
  9431. if c.ifNoneMatch_ != "" {
  9432. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  9433. }
  9434. var body io.Reader = nil
  9435. c.urlParams_.Set("alt", alt)
  9436. c.urlParams_.Set("prettyPrint", "false")
  9437. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs")
  9438. urls += "?" + c.urlParams_.Encode()
  9439. req, err := http.NewRequest("GET", urls, body)
  9440. if err != nil {
  9441. return nil, err
  9442. }
  9443. req.Header = reqHeaders
  9444. googleapi.Expand(req.URL, map[string]string{
  9445. "userId": c.userId,
  9446. })
  9447. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9448. }
  9449. // Do executes the "gmail.users.settings.sendAs.list" call.
  9450. // Exactly one of *ListSendAsResponse or error will be non-nil. Any
  9451. // non-2xx status code is an error. Response headers are in either
  9452. // *ListSendAsResponse.ServerResponse.Header or (if a response was
  9453. // returned at all) in error.(*googleapi.Error).Header. Use
  9454. // googleapi.IsNotModified to check whether the returned error was
  9455. // because http.StatusNotModified was returned.
  9456. func (c *UsersSettingsSendAsListCall) Do(opts ...googleapi.CallOption) (*ListSendAsResponse, error) {
  9457. gensupport.SetOptions(c.urlParams_, opts...)
  9458. res, err := c.doRequest("json")
  9459. if res != nil && res.StatusCode == http.StatusNotModified {
  9460. if res.Body != nil {
  9461. res.Body.Close()
  9462. }
  9463. return nil, &googleapi.Error{
  9464. Code: res.StatusCode,
  9465. Header: res.Header,
  9466. }
  9467. }
  9468. if err != nil {
  9469. return nil, err
  9470. }
  9471. defer googleapi.CloseBody(res)
  9472. if err := googleapi.CheckResponse(res); err != nil {
  9473. return nil, err
  9474. }
  9475. ret := &ListSendAsResponse{
  9476. ServerResponse: googleapi.ServerResponse{
  9477. Header: res.Header,
  9478. HTTPStatusCode: res.StatusCode,
  9479. },
  9480. }
  9481. target := &ret
  9482. if err := gensupport.DecodeResponse(target, res); err != nil {
  9483. return nil, err
  9484. }
  9485. return ret, nil
  9486. // {
  9487. // "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.",
  9488. // "httpMethod": "GET",
  9489. // "id": "gmail.users.settings.sendAs.list",
  9490. // "parameterOrder": [
  9491. // "userId"
  9492. // ],
  9493. // "parameters": {
  9494. // "userId": {
  9495. // "default": "me",
  9496. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9497. // "location": "path",
  9498. // "required": true,
  9499. // "type": "string"
  9500. // }
  9501. // },
  9502. // "path": "{userId}/settings/sendAs",
  9503. // "response": {
  9504. // "$ref": "ListSendAsResponse"
  9505. // },
  9506. // "scopes": [
  9507. // "https://mail.google.com/",
  9508. // "https://www.googleapis.com/auth/gmail.modify",
  9509. // "https://www.googleapis.com/auth/gmail.readonly",
  9510. // "https://www.googleapis.com/auth/gmail.settings.basic"
  9511. // ]
  9512. // }
  9513. }
  9514. // method id "gmail.users.settings.sendAs.patch":
  9515. type UsersSettingsSendAsPatchCall struct {
  9516. s *Service
  9517. userId string
  9518. sendAsEmail string
  9519. sendas *SendAs
  9520. urlParams_ gensupport.URLParams
  9521. ctx_ context.Context
  9522. header_ http.Header
  9523. }
  9524. // Patch: Updates a send-as alias. If a signature is provided, Gmail
  9525. // will sanitize the HTML before saving it with the alias.
  9526. //
  9527. // Addresses other than the primary address for the account can only be
  9528. // updated by service account clients that have been delegated
  9529. // domain-wide authority. This method supports patch semantics.
  9530. func (r *UsersSettingsSendAsService) Patch(userId string, sendAsEmail string, sendas *SendAs) *UsersSettingsSendAsPatchCall {
  9531. c := &UsersSettingsSendAsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9532. c.userId = userId
  9533. c.sendAsEmail = sendAsEmail
  9534. c.sendas = sendas
  9535. return c
  9536. }
  9537. // Fields allows partial responses to be retrieved. See
  9538. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9539. // for more information.
  9540. func (c *UsersSettingsSendAsPatchCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsPatchCall {
  9541. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9542. return c
  9543. }
  9544. // Context sets the context to be used in this call's Do method. Any
  9545. // pending HTTP request will be aborted if the provided context is
  9546. // canceled.
  9547. func (c *UsersSettingsSendAsPatchCall) Context(ctx context.Context) *UsersSettingsSendAsPatchCall {
  9548. c.ctx_ = ctx
  9549. return c
  9550. }
  9551. // Header returns an http.Header that can be modified by the caller to
  9552. // add HTTP headers to the request.
  9553. func (c *UsersSettingsSendAsPatchCall) Header() http.Header {
  9554. if c.header_ == nil {
  9555. c.header_ = make(http.Header)
  9556. }
  9557. return c.header_
  9558. }
  9559. func (c *UsersSettingsSendAsPatchCall) doRequest(alt string) (*http.Response, error) {
  9560. reqHeaders := make(http.Header)
  9561. for k, v := range c.header_ {
  9562. reqHeaders[k] = v
  9563. }
  9564. reqHeaders.Set("User-Agent", c.s.userAgent())
  9565. var body io.Reader = nil
  9566. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sendas)
  9567. if err != nil {
  9568. return nil, err
  9569. }
  9570. reqHeaders.Set("Content-Type", "application/json")
  9571. c.urlParams_.Set("alt", alt)
  9572. c.urlParams_.Set("prettyPrint", "false")
  9573. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  9574. urls += "?" + c.urlParams_.Encode()
  9575. req, err := http.NewRequest("PATCH", urls, body)
  9576. if err != nil {
  9577. return nil, err
  9578. }
  9579. req.Header = reqHeaders
  9580. googleapi.Expand(req.URL, map[string]string{
  9581. "userId": c.userId,
  9582. "sendAsEmail": c.sendAsEmail,
  9583. })
  9584. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9585. }
  9586. // Do executes the "gmail.users.settings.sendAs.patch" call.
  9587. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  9588. // code is an error. Response headers are in either
  9589. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  9590. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  9591. // check whether the returned error was because http.StatusNotModified
  9592. // was returned.
  9593. func (c *UsersSettingsSendAsPatchCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  9594. gensupport.SetOptions(c.urlParams_, opts...)
  9595. res, err := c.doRequest("json")
  9596. if res != nil && res.StatusCode == http.StatusNotModified {
  9597. if res.Body != nil {
  9598. res.Body.Close()
  9599. }
  9600. return nil, &googleapi.Error{
  9601. Code: res.StatusCode,
  9602. Header: res.Header,
  9603. }
  9604. }
  9605. if err != nil {
  9606. return nil, err
  9607. }
  9608. defer googleapi.CloseBody(res)
  9609. if err := googleapi.CheckResponse(res); err != nil {
  9610. return nil, err
  9611. }
  9612. ret := &SendAs{
  9613. ServerResponse: googleapi.ServerResponse{
  9614. Header: res.Header,
  9615. HTTPStatusCode: res.StatusCode,
  9616. },
  9617. }
  9618. target := &ret
  9619. if err := gensupport.DecodeResponse(target, res); err != nil {
  9620. return nil, err
  9621. }
  9622. return ret, nil
  9623. // {
  9624. // "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.",
  9625. // "httpMethod": "PATCH",
  9626. // "id": "gmail.users.settings.sendAs.patch",
  9627. // "parameterOrder": [
  9628. // "userId",
  9629. // "sendAsEmail"
  9630. // ],
  9631. // "parameters": {
  9632. // "sendAsEmail": {
  9633. // "description": "The send-as alias to be updated.",
  9634. // "location": "path",
  9635. // "required": true,
  9636. // "type": "string"
  9637. // },
  9638. // "userId": {
  9639. // "default": "me",
  9640. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9641. // "location": "path",
  9642. // "required": true,
  9643. // "type": "string"
  9644. // }
  9645. // },
  9646. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  9647. // "request": {
  9648. // "$ref": "SendAs"
  9649. // },
  9650. // "response": {
  9651. // "$ref": "SendAs"
  9652. // },
  9653. // "scopes": [
  9654. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9655. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9656. // ]
  9657. // }
  9658. }
  9659. // method id "gmail.users.settings.sendAs.update":
  9660. type UsersSettingsSendAsUpdateCall struct {
  9661. s *Service
  9662. userId string
  9663. sendAsEmail string
  9664. sendas *SendAs
  9665. urlParams_ gensupport.URLParams
  9666. ctx_ context.Context
  9667. header_ http.Header
  9668. }
  9669. // Update: Updates a send-as alias. If a signature is provided, Gmail
  9670. // will sanitize the HTML before saving it with the alias.
  9671. //
  9672. // Addresses other than the primary address for the account can only be
  9673. // updated by service account clients that have been delegated
  9674. // domain-wide authority.
  9675. func (r *UsersSettingsSendAsService) Update(userId string, sendAsEmail string, sendas *SendAs) *UsersSettingsSendAsUpdateCall {
  9676. c := &UsersSettingsSendAsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9677. c.userId = userId
  9678. c.sendAsEmail = sendAsEmail
  9679. c.sendas = sendas
  9680. return c
  9681. }
  9682. // Fields allows partial responses to be retrieved. See
  9683. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9684. // for more information.
  9685. func (c *UsersSettingsSendAsUpdateCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsUpdateCall {
  9686. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9687. return c
  9688. }
  9689. // Context sets the context to be used in this call's Do method. Any
  9690. // pending HTTP request will be aborted if the provided context is
  9691. // canceled.
  9692. func (c *UsersSettingsSendAsUpdateCall) Context(ctx context.Context) *UsersSettingsSendAsUpdateCall {
  9693. c.ctx_ = ctx
  9694. return c
  9695. }
  9696. // Header returns an http.Header that can be modified by the caller to
  9697. // add HTTP headers to the request.
  9698. func (c *UsersSettingsSendAsUpdateCall) Header() http.Header {
  9699. if c.header_ == nil {
  9700. c.header_ = make(http.Header)
  9701. }
  9702. return c.header_
  9703. }
  9704. func (c *UsersSettingsSendAsUpdateCall) doRequest(alt string) (*http.Response, error) {
  9705. reqHeaders := make(http.Header)
  9706. for k, v := range c.header_ {
  9707. reqHeaders[k] = v
  9708. }
  9709. reqHeaders.Set("User-Agent", c.s.userAgent())
  9710. var body io.Reader = nil
  9711. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sendas)
  9712. if err != nil {
  9713. return nil, err
  9714. }
  9715. reqHeaders.Set("Content-Type", "application/json")
  9716. c.urlParams_.Set("alt", alt)
  9717. c.urlParams_.Set("prettyPrint", "false")
  9718. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}")
  9719. urls += "?" + c.urlParams_.Encode()
  9720. req, err := http.NewRequest("PUT", urls, body)
  9721. if err != nil {
  9722. return nil, err
  9723. }
  9724. req.Header = reqHeaders
  9725. googleapi.Expand(req.URL, map[string]string{
  9726. "userId": c.userId,
  9727. "sendAsEmail": c.sendAsEmail,
  9728. })
  9729. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9730. }
  9731. // Do executes the "gmail.users.settings.sendAs.update" call.
  9732. // Exactly one of *SendAs or error will be non-nil. Any non-2xx status
  9733. // code is an error. Response headers are in either
  9734. // *SendAs.ServerResponse.Header or (if a response was returned at all)
  9735. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  9736. // check whether the returned error was because http.StatusNotModified
  9737. // was returned.
  9738. func (c *UsersSettingsSendAsUpdateCall) Do(opts ...googleapi.CallOption) (*SendAs, error) {
  9739. gensupport.SetOptions(c.urlParams_, opts...)
  9740. res, err := c.doRequest("json")
  9741. if res != nil && res.StatusCode == http.StatusNotModified {
  9742. if res.Body != nil {
  9743. res.Body.Close()
  9744. }
  9745. return nil, &googleapi.Error{
  9746. Code: res.StatusCode,
  9747. Header: res.Header,
  9748. }
  9749. }
  9750. if err != nil {
  9751. return nil, err
  9752. }
  9753. defer googleapi.CloseBody(res)
  9754. if err := googleapi.CheckResponse(res); err != nil {
  9755. return nil, err
  9756. }
  9757. ret := &SendAs{
  9758. ServerResponse: googleapi.ServerResponse{
  9759. Header: res.Header,
  9760. HTTPStatusCode: res.StatusCode,
  9761. },
  9762. }
  9763. target := &ret
  9764. if err := gensupport.DecodeResponse(target, res); err != nil {
  9765. return nil, err
  9766. }
  9767. return ret, nil
  9768. // {
  9769. // "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.",
  9770. // "httpMethod": "PUT",
  9771. // "id": "gmail.users.settings.sendAs.update",
  9772. // "parameterOrder": [
  9773. // "userId",
  9774. // "sendAsEmail"
  9775. // ],
  9776. // "parameters": {
  9777. // "sendAsEmail": {
  9778. // "description": "The send-as alias to be updated.",
  9779. // "location": "path",
  9780. // "required": true,
  9781. // "type": "string"
  9782. // },
  9783. // "userId": {
  9784. // "default": "me",
  9785. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9786. // "location": "path",
  9787. // "required": true,
  9788. // "type": "string"
  9789. // }
  9790. // },
  9791. // "path": "{userId}/settings/sendAs/{sendAsEmail}",
  9792. // "request": {
  9793. // "$ref": "SendAs"
  9794. // },
  9795. // "response": {
  9796. // "$ref": "SendAs"
  9797. // },
  9798. // "scopes": [
  9799. // "https://www.googleapis.com/auth/gmail.settings.basic",
  9800. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9801. // ]
  9802. // }
  9803. }
  9804. // method id "gmail.users.settings.sendAs.verify":
  9805. type UsersSettingsSendAsVerifyCall struct {
  9806. s *Service
  9807. userId string
  9808. sendAsEmail string
  9809. urlParams_ gensupport.URLParams
  9810. ctx_ context.Context
  9811. header_ http.Header
  9812. }
  9813. // Verify: Sends a verification email to the specified send-as alias
  9814. // address. The verification status must be pending.
  9815. //
  9816. // This method is only available to service account clients that have
  9817. // been delegated domain-wide authority.
  9818. func (r *UsersSettingsSendAsService) Verify(userId string, sendAsEmail string) *UsersSettingsSendAsVerifyCall {
  9819. c := &UsersSettingsSendAsVerifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9820. c.userId = userId
  9821. c.sendAsEmail = sendAsEmail
  9822. return c
  9823. }
  9824. // Fields allows partial responses to be retrieved. See
  9825. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9826. // for more information.
  9827. func (c *UsersSettingsSendAsVerifyCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsVerifyCall {
  9828. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9829. return c
  9830. }
  9831. // Context sets the context to be used in this call's Do method. Any
  9832. // pending HTTP request will be aborted if the provided context is
  9833. // canceled.
  9834. func (c *UsersSettingsSendAsVerifyCall) Context(ctx context.Context) *UsersSettingsSendAsVerifyCall {
  9835. c.ctx_ = ctx
  9836. return c
  9837. }
  9838. // Header returns an http.Header that can be modified by the caller to
  9839. // add HTTP headers to the request.
  9840. func (c *UsersSettingsSendAsVerifyCall) Header() http.Header {
  9841. if c.header_ == nil {
  9842. c.header_ = make(http.Header)
  9843. }
  9844. return c.header_
  9845. }
  9846. func (c *UsersSettingsSendAsVerifyCall) doRequest(alt string) (*http.Response, error) {
  9847. reqHeaders := make(http.Header)
  9848. for k, v := range c.header_ {
  9849. reqHeaders[k] = v
  9850. }
  9851. reqHeaders.Set("User-Agent", c.s.userAgent())
  9852. var body io.Reader = nil
  9853. c.urlParams_.Set("alt", alt)
  9854. c.urlParams_.Set("prettyPrint", "false")
  9855. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/verify")
  9856. urls += "?" + c.urlParams_.Encode()
  9857. req, err := http.NewRequest("POST", urls, body)
  9858. if err != nil {
  9859. return nil, err
  9860. }
  9861. req.Header = reqHeaders
  9862. googleapi.Expand(req.URL, map[string]string{
  9863. "userId": c.userId,
  9864. "sendAsEmail": c.sendAsEmail,
  9865. })
  9866. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9867. }
  9868. // Do executes the "gmail.users.settings.sendAs.verify" call.
  9869. func (c *UsersSettingsSendAsVerifyCall) Do(opts ...googleapi.CallOption) error {
  9870. gensupport.SetOptions(c.urlParams_, opts...)
  9871. res, err := c.doRequest("json")
  9872. if err != nil {
  9873. return err
  9874. }
  9875. defer googleapi.CloseBody(res)
  9876. if err := googleapi.CheckResponse(res); err != nil {
  9877. return err
  9878. }
  9879. return nil
  9880. // {
  9881. // "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.",
  9882. // "httpMethod": "POST",
  9883. // "id": "gmail.users.settings.sendAs.verify",
  9884. // "parameterOrder": [
  9885. // "userId",
  9886. // "sendAsEmail"
  9887. // ],
  9888. // "parameters": {
  9889. // "sendAsEmail": {
  9890. // "description": "The send-as alias to be verified.",
  9891. // "location": "path",
  9892. // "required": true,
  9893. // "type": "string"
  9894. // },
  9895. // "userId": {
  9896. // "default": "me",
  9897. // "description": "User's email address. The special value \"me\" can be used to indicate the authenticated user.",
  9898. // "location": "path",
  9899. // "required": true,
  9900. // "type": "string"
  9901. // }
  9902. // },
  9903. // "path": "{userId}/settings/sendAs/{sendAsEmail}/verify",
  9904. // "scopes": [
  9905. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  9906. // ]
  9907. // }
  9908. }
  9909. // method id "gmail.users.settings.sendAs.smimeInfo.delete":
  9910. type UsersSettingsSendAsSmimeInfoDeleteCall struct {
  9911. s *Service
  9912. userId string
  9913. sendAsEmail string
  9914. id string
  9915. urlParams_ gensupport.URLParams
  9916. ctx_ context.Context
  9917. header_ http.Header
  9918. }
  9919. // Delete: Deletes the specified S/MIME config for the specified send-as
  9920. // alias.
  9921. func (r *UsersSettingsSendAsSmimeInfoService) Delete(userId string, sendAsEmail string, id string) *UsersSettingsSendAsSmimeInfoDeleteCall {
  9922. c := &UsersSettingsSendAsSmimeInfoDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  9923. c.userId = userId
  9924. c.sendAsEmail = sendAsEmail
  9925. c.id = id
  9926. return c
  9927. }
  9928. // Fields allows partial responses to be retrieved. See
  9929. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  9930. // for more information.
  9931. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoDeleteCall {
  9932. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  9933. return c
  9934. }
  9935. // Context sets the context to be used in this call's Do method. Any
  9936. // pending HTTP request will be aborted if the provided context is
  9937. // canceled.
  9938. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoDeleteCall {
  9939. c.ctx_ = ctx
  9940. return c
  9941. }
  9942. // Header returns an http.Header that can be modified by the caller to
  9943. // add HTTP headers to the request.
  9944. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Header() http.Header {
  9945. if c.header_ == nil {
  9946. c.header_ = make(http.Header)
  9947. }
  9948. return c.header_
  9949. }
  9950. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) doRequest(alt string) (*http.Response, error) {
  9951. reqHeaders := make(http.Header)
  9952. for k, v := range c.header_ {
  9953. reqHeaders[k] = v
  9954. }
  9955. reqHeaders.Set("User-Agent", c.s.userAgent())
  9956. var body io.Reader = nil
  9957. c.urlParams_.Set("alt", alt)
  9958. c.urlParams_.Set("prettyPrint", "false")
  9959. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}")
  9960. urls += "?" + c.urlParams_.Encode()
  9961. req, err := http.NewRequest("DELETE", urls, body)
  9962. if err != nil {
  9963. return nil, err
  9964. }
  9965. req.Header = reqHeaders
  9966. googleapi.Expand(req.URL, map[string]string{
  9967. "userId": c.userId,
  9968. "sendAsEmail": c.sendAsEmail,
  9969. "id": c.id,
  9970. })
  9971. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  9972. }
  9973. // Do executes the "gmail.users.settings.sendAs.smimeInfo.delete" call.
  9974. func (c *UsersSettingsSendAsSmimeInfoDeleteCall) Do(opts ...googleapi.CallOption) error {
  9975. gensupport.SetOptions(c.urlParams_, opts...)
  9976. res, err := c.doRequest("json")
  9977. if err != nil {
  9978. return err
  9979. }
  9980. defer googleapi.CloseBody(res)
  9981. if err := googleapi.CheckResponse(res); err != nil {
  9982. return err
  9983. }
  9984. return nil
  9985. // {
  9986. // "description": "Deletes the specified S/MIME config for the specified send-as alias.",
  9987. // "httpMethod": "DELETE",
  9988. // "id": "gmail.users.settings.sendAs.smimeInfo.delete",
  9989. // "parameterOrder": [
  9990. // "userId",
  9991. // "sendAsEmail",
  9992. // "id"
  9993. // ],
  9994. // "parameters": {
  9995. // "id": {
  9996. // "description": "The immutable ID for the SmimeInfo.",
  9997. // "location": "path",
  9998. // "required": true,
  9999. // "type": "string"
  10000. // },
  10001. // "sendAsEmail": {
  10002. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  10003. // "location": "path",
  10004. // "required": true,
  10005. // "type": "string"
  10006. // },
  10007. // "userId": {
  10008. // "default": "me",
  10009. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10010. // "location": "path",
  10011. // "required": true,
  10012. // "type": "string"
  10013. // }
  10014. // },
  10015. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}",
  10016. // "scopes": [
  10017. // "https://www.googleapis.com/auth/gmail.settings.basic",
  10018. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  10019. // ]
  10020. // }
  10021. }
  10022. // method id "gmail.users.settings.sendAs.smimeInfo.get":
  10023. type UsersSettingsSendAsSmimeInfoGetCall struct {
  10024. s *Service
  10025. userId string
  10026. sendAsEmail string
  10027. id string
  10028. urlParams_ gensupport.URLParams
  10029. ifNoneMatch_ string
  10030. ctx_ context.Context
  10031. header_ http.Header
  10032. }
  10033. // Get: Gets the specified S/MIME config for the specified send-as
  10034. // alias.
  10035. func (r *UsersSettingsSendAsSmimeInfoService) Get(userId string, sendAsEmail string, id string) *UsersSettingsSendAsSmimeInfoGetCall {
  10036. c := &UsersSettingsSendAsSmimeInfoGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10037. c.userId = userId
  10038. c.sendAsEmail = sendAsEmail
  10039. c.id = id
  10040. return c
  10041. }
  10042. // Fields allows partial responses to be retrieved. See
  10043. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10044. // for more information.
  10045. func (c *UsersSettingsSendAsSmimeInfoGetCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoGetCall {
  10046. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10047. return c
  10048. }
  10049. // IfNoneMatch sets the optional parameter which makes the operation
  10050. // fail if the object's ETag matches the given value. This is useful for
  10051. // getting updates only after the object has changed since the last
  10052. // request. Use googleapi.IsNotModified to check whether the response
  10053. // error from Do is the result of In-None-Match.
  10054. func (c *UsersSettingsSendAsSmimeInfoGetCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsSmimeInfoGetCall {
  10055. c.ifNoneMatch_ = entityTag
  10056. return c
  10057. }
  10058. // Context sets the context to be used in this call's Do method. Any
  10059. // pending HTTP request will be aborted if the provided context is
  10060. // canceled.
  10061. func (c *UsersSettingsSendAsSmimeInfoGetCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoGetCall {
  10062. c.ctx_ = ctx
  10063. return c
  10064. }
  10065. // Header returns an http.Header that can be modified by the caller to
  10066. // add HTTP headers to the request.
  10067. func (c *UsersSettingsSendAsSmimeInfoGetCall) Header() http.Header {
  10068. if c.header_ == nil {
  10069. c.header_ = make(http.Header)
  10070. }
  10071. return c.header_
  10072. }
  10073. func (c *UsersSettingsSendAsSmimeInfoGetCall) doRequest(alt string) (*http.Response, error) {
  10074. reqHeaders := make(http.Header)
  10075. for k, v := range c.header_ {
  10076. reqHeaders[k] = v
  10077. }
  10078. reqHeaders.Set("User-Agent", c.s.userAgent())
  10079. if c.ifNoneMatch_ != "" {
  10080. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  10081. }
  10082. var body io.Reader = nil
  10083. c.urlParams_.Set("alt", alt)
  10084. c.urlParams_.Set("prettyPrint", "false")
  10085. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}")
  10086. urls += "?" + c.urlParams_.Encode()
  10087. req, err := http.NewRequest("GET", urls, body)
  10088. if err != nil {
  10089. return nil, err
  10090. }
  10091. req.Header = reqHeaders
  10092. googleapi.Expand(req.URL, map[string]string{
  10093. "userId": c.userId,
  10094. "sendAsEmail": c.sendAsEmail,
  10095. "id": c.id,
  10096. })
  10097. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10098. }
  10099. // Do executes the "gmail.users.settings.sendAs.smimeInfo.get" call.
  10100. // Exactly one of *SmimeInfo or error will be non-nil. Any non-2xx
  10101. // status code is an error. Response headers are in either
  10102. // *SmimeInfo.ServerResponse.Header or (if a response was returned at
  10103. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  10104. // to check whether the returned error was because
  10105. // http.StatusNotModified was returned.
  10106. func (c *UsersSettingsSendAsSmimeInfoGetCall) Do(opts ...googleapi.CallOption) (*SmimeInfo, error) {
  10107. gensupport.SetOptions(c.urlParams_, opts...)
  10108. res, err := c.doRequest("json")
  10109. if res != nil && res.StatusCode == http.StatusNotModified {
  10110. if res.Body != nil {
  10111. res.Body.Close()
  10112. }
  10113. return nil, &googleapi.Error{
  10114. Code: res.StatusCode,
  10115. Header: res.Header,
  10116. }
  10117. }
  10118. if err != nil {
  10119. return nil, err
  10120. }
  10121. defer googleapi.CloseBody(res)
  10122. if err := googleapi.CheckResponse(res); err != nil {
  10123. return nil, err
  10124. }
  10125. ret := &SmimeInfo{
  10126. ServerResponse: googleapi.ServerResponse{
  10127. Header: res.Header,
  10128. HTTPStatusCode: res.StatusCode,
  10129. },
  10130. }
  10131. target := &ret
  10132. if err := gensupport.DecodeResponse(target, res); err != nil {
  10133. return nil, err
  10134. }
  10135. return ret, nil
  10136. // {
  10137. // "description": "Gets the specified S/MIME config for the specified send-as alias.",
  10138. // "httpMethod": "GET",
  10139. // "id": "gmail.users.settings.sendAs.smimeInfo.get",
  10140. // "parameterOrder": [
  10141. // "userId",
  10142. // "sendAsEmail",
  10143. // "id"
  10144. // ],
  10145. // "parameters": {
  10146. // "id": {
  10147. // "description": "The immutable ID for the SmimeInfo.",
  10148. // "location": "path",
  10149. // "required": true,
  10150. // "type": "string"
  10151. // },
  10152. // "sendAsEmail": {
  10153. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  10154. // "location": "path",
  10155. // "required": true,
  10156. // "type": "string"
  10157. // },
  10158. // "userId": {
  10159. // "default": "me",
  10160. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10161. // "location": "path",
  10162. // "required": true,
  10163. // "type": "string"
  10164. // }
  10165. // },
  10166. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}",
  10167. // "response": {
  10168. // "$ref": "SmimeInfo"
  10169. // },
  10170. // "scopes": [
  10171. // "https://mail.google.com/",
  10172. // "https://www.googleapis.com/auth/gmail.modify",
  10173. // "https://www.googleapis.com/auth/gmail.readonly",
  10174. // "https://www.googleapis.com/auth/gmail.settings.basic",
  10175. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  10176. // ]
  10177. // }
  10178. }
  10179. // method id "gmail.users.settings.sendAs.smimeInfo.insert":
  10180. type UsersSettingsSendAsSmimeInfoInsertCall struct {
  10181. s *Service
  10182. userId string
  10183. sendAsEmail string
  10184. smimeinfo *SmimeInfo
  10185. urlParams_ gensupport.URLParams
  10186. ctx_ context.Context
  10187. header_ http.Header
  10188. }
  10189. // Insert: Insert (upload) the given S/MIME config for the specified
  10190. // send-as alias. Note that pkcs12 format is required for the key.
  10191. func (r *UsersSettingsSendAsSmimeInfoService) Insert(userId string, sendAsEmail string, smimeinfo *SmimeInfo) *UsersSettingsSendAsSmimeInfoInsertCall {
  10192. c := &UsersSettingsSendAsSmimeInfoInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10193. c.userId = userId
  10194. c.sendAsEmail = sendAsEmail
  10195. c.smimeinfo = smimeinfo
  10196. return c
  10197. }
  10198. // Fields allows partial responses to be retrieved. See
  10199. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10200. // for more information.
  10201. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoInsertCall {
  10202. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10203. return c
  10204. }
  10205. // Context sets the context to be used in this call's Do method. Any
  10206. // pending HTTP request will be aborted if the provided context is
  10207. // canceled.
  10208. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoInsertCall {
  10209. c.ctx_ = ctx
  10210. return c
  10211. }
  10212. // Header returns an http.Header that can be modified by the caller to
  10213. // add HTTP headers to the request.
  10214. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Header() http.Header {
  10215. if c.header_ == nil {
  10216. c.header_ = make(http.Header)
  10217. }
  10218. return c.header_
  10219. }
  10220. func (c *UsersSettingsSendAsSmimeInfoInsertCall) doRequest(alt string) (*http.Response, error) {
  10221. reqHeaders := make(http.Header)
  10222. for k, v := range c.header_ {
  10223. reqHeaders[k] = v
  10224. }
  10225. reqHeaders.Set("User-Agent", c.s.userAgent())
  10226. var body io.Reader = nil
  10227. body, err := googleapi.WithoutDataWrapper.JSONReader(c.smimeinfo)
  10228. if err != nil {
  10229. return nil, err
  10230. }
  10231. reqHeaders.Set("Content-Type", "application/json")
  10232. c.urlParams_.Set("alt", alt)
  10233. c.urlParams_.Set("prettyPrint", "false")
  10234. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo")
  10235. urls += "?" + c.urlParams_.Encode()
  10236. req, err := http.NewRequest("POST", urls, body)
  10237. if err != nil {
  10238. return nil, err
  10239. }
  10240. req.Header = reqHeaders
  10241. googleapi.Expand(req.URL, map[string]string{
  10242. "userId": c.userId,
  10243. "sendAsEmail": c.sendAsEmail,
  10244. })
  10245. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10246. }
  10247. // Do executes the "gmail.users.settings.sendAs.smimeInfo.insert" call.
  10248. // Exactly one of *SmimeInfo or error will be non-nil. Any non-2xx
  10249. // status code is an error. Response headers are in either
  10250. // *SmimeInfo.ServerResponse.Header or (if a response was returned at
  10251. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  10252. // to check whether the returned error was because
  10253. // http.StatusNotModified was returned.
  10254. func (c *UsersSettingsSendAsSmimeInfoInsertCall) Do(opts ...googleapi.CallOption) (*SmimeInfo, error) {
  10255. gensupport.SetOptions(c.urlParams_, opts...)
  10256. res, err := c.doRequest("json")
  10257. if res != nil && res.StatusCode == http.StatusNotModified {
  10258. if res.Body != nil {
  10259. res.Body.Close()
  10260. }
  10261. return nil, &googleapi.Error{
  10262. Code: res.StatusCode,
  10263. Header: res.Header,
  10264. }
  10265. }
  10266. if err != nil {
  10267. return nil, err
  10268. }
  10269. defer googleapi.CloseBody(res)
  10270. if err := googleapi.CheckResponse(res); err != nil {
  10271. return nil, err
  10272. }
  10273. ret := &SmimeInfo{
  10274. ServerResponse: googleapi.ServerResponse{
  10275. Header: res.Header,
  10276. HTTPStatusCode: res.StatusCode,
  10277. },
  10278. }
  10279. target := &ret
  10280. if err := gensupport.DecodeResponse(target, res); err != nil {
  10281. return nil, err
  10282. }
  10283. return ret, nil
  10284. // {
  10285. // "description": "Insert (upload) the given S/MIME config for the specified send-as alias. Note that pkcs12 format is required for the key.",
  10286. // "httpMethod": "POST",
  10287. // "id": "gmail.users.settings.sendAs.smimeInfo.insert",
  10288. // "parameterOrder": [
  10289. // "userId",
  10290. // "sendAsEmail"
  10291. // ],
  10292. // "parameters": {
  10293. // "sendAsEmail": {
  10294. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  10295. // "location": "path",
  10296. // "required": true,
  10297. // "type": "string"
  10298. // },
  10299. // "userId": {
  10300. // "default": "me",
  10301. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10302. // "location": "path",
  10303. // "required": true,
  10304. // "type": "string"
  10305. // }
  10306. // },
  10307. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo",
  10308. // "request": {
  10309. // "$ref": "SmimeInfo"
  10310. // },
  10311. // "response": {
  10312. // "$ref": "SmimeInfo"
  10313. // },
  10314. // "scopes": [
  10315. // "https://www.googleapis.com/auth/gmail.settings.basic",
  10316. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  10317. // ]
  10318. // }
  10319. }
  10320. // method id "gmail.users.settings.sendAs.smimeInfo.list":
  10321. type UsersSettingsSendAsSmimeInfoListCall struct {
  10322. s *Service
  10323. userId string
  10324. sendAsEmail string
  10325. urlParams_ gensupport.URLParams
  10326. ifNoneMatch_ string
  10327. ctx_ context.Context
  10328. header_ http.Header
  10329. }
  10330. // List: Lists S/MIME configs for the specified send-as alias.
  10331. func (r *UsersSettingsSendAsSmimeInfoService) List(userId string, sendAsEmail string) *UsersSettingsSendAsSmimeInfoListCall {
  10332. c := &UsersSettingsSendAsSmimeInfoListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10333. c.userId = userId
  10334. c.sendAsEmail = sendAsEmail
  10335. return c
  10336. }
  10337. // Fields allows partial responses to be retrieved. See
  10338. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10339. // for more information.
  10340. func (c *UsersSettingsSendAsSmimeInfoListCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoListCall {
  10341. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10342. return c
  10343. }
  10344. // IfNoneMatch sets the optional parameter which makes the operation
  10345. // fail if the object's ETag matches the given value. This is useful for
  10346. // getting updates only after the object has changed since the last
  10347. // request. Use googleapi.IsNotModified to check whether the response
  10348. // error from Do is the result of In-None-Match.
  10349. func (c *UsersSettingsSendAsSmimeInfoListCall) IfNoneMatch(entityTag string) *UsersSettingsSendAsSmimeInfoListCall {
  10350. c.ifNoneMatch_ = entityTag
  10351. return c
  10352. }
  10353. // Context sets the context to be used in this call's Do method. Any
  10354. // pending HTTP request will be aborted if the provided context is
  10355. // canceled.
  10356. func (c *UsersSettingsSendAsSmimeInfoListCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoListCall {
  10357. c.ctx_ = ctx
  10358. return c
  10359. }
  10360. // Header returns an http.Header that can be modified by the caller to
  10361. // add HTTP headers to the request.
  10362. func (c *UsersSettingsSendAsSmimeInfoListCall) Header() http.Header {
  10363. if c.header_ == nil {
  10364. c.header_ = make(http.Header)
  10365. }
  10366. return c.header_
  10367. }
  10368. func (c *UsersSettingsSendAsSmimeInfoListCall) doRequest(alt string) (*http.Response, error) {
  10369. reqHeaders := make(http.Header)
  10370. for k, v := range c.header_ {
  10371. reqHeaders[k] = v
  10372. }
  10373. reqHeaders.Set("User-Agent", c.s.userAgent())
  10374. if c.ifNoneMatch_ != "" {
  10375. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  10376. }
  10377. var body io.Reader = nil
  10378. c.urlParams_.Set("alt", alt)
  10379. c.urlParams_.Set("prettyPrint", "false")
  10380. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo")
  10381. urls += "?" + c.urlParams_.Encode()
  10382. req, err := http.NewRequest("GET", urls, body)
  10383. if err != nil {
  10384. return nil, err
  10385. }
  10386. req.Header = reqHeaders
  10387. googleapi.Expand(req.URL, map[string]string{
  10388. "userId": c.userId,
  10389. "sendAsEmail": c.sendAsEmail,
  10390. })
  10391. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10392. }
  10393. // Do executes the "gmail.users.settings.sendAs.smimeInfo.list" call.
  10394. // Exactly one of *ListSmimeInfoResponse or error will be non-nil. Any
  10395. // non-2xx status code is an error. Response headers are in either
  10396. // *ListSmimeInfoResponse.ServerResponse.Header or (if a response was
  10397. // returned at all) in error.(*googleapi.Error).Header. Use
  10398. // googleapi.IsNotModified to check whether the returned error was
  10399. // because http.StatusNotModified was returned.
  10400. func (c *UsersSettingsSendAsSmimeInfoListCall) Do(opts ...googleapi.CallOption) (*ListSmimeInfoResponse, error) {
  10401. gensupport.SetOptions(c.urlParams_, opts...)
  10402. res, err := c.doRequest("json")
  10403. if res != nil && res.StatusCode == http.StatusNotModified {
  10404. if res.Body != nil {
  10405. res.Body.Close()
  10406. }
  10407. return nil, &googleapi.Error{
  10408. Code: res.StatusCode,
  10409. Header: res.Header,
  10410. }
  10411. }
  10412. if err != nil {
  10413. return nil, err
  10414. }
  10415. defer googleapi.CloseBody(res)
  10416. if err := googleapi.CheckResponse(res); err != nil {
  10417. return nil, err
  10418. }
  10419. ret := &ListSmimeInfoResponse{
  10420. ServerResponse: googleapi.ServerResponse{
  10421. Header: res.Header,
  10422. HTTPStatusCode: res.StatusCode,
  10423. },
  10424. }
  10425. target := &ret
  10426. if err := gensupport.DecodeResponse(target, res); err != nil {
  10427. return nil, err
  10428. }
  10429. return ret, nil
  10430. // {
  10431. // "description": "Lists S/MIME configs for the specified send-as alias.",
  10432. // "httpMethod": "GET",
  10433. // "id": "gmail.users.settings.sendAs.smimeInfo.list",
  10434. // "parameterOrder": [
  10435. // "userId",
  10436. // "sendAsEmail"
  10437. // ],
  10438. // "parameters": {
  10439. // "sendAsEmail": {
  10440. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  10441. // "location": "path",
  10442. // "required": true,
  10443. // "type": "string"
  10444. // },
  10445. // "userId": {
  10446. // "default": "me",
  10447. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10448. // "location": "path",
  10449. // "required": true,
  10450. // "type": "string"
  10451. // }
  10452. // },
  10453. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo",
  10454. // "response": {
  10455. // "$ref": "ListSmimeInfoResponse"
  10456. // },
  10457. // "scopes": [
  10458. // "https://mail.google.com/",
  10459. // "https://www.googleapis.com/auth/gmail.modify",
  10460. // "https://www.googleapis.com/auth/gmail.readonly",
  10461. // "https://www.googleapis.com/auth/gmail.settings.basic",
  10462. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  10463. // ]
  10464. // }
  10465. }
  10466. // method id "gmail.users.settings.sendAs.smimeInfo.setDefault":
  10467. type UsersSettingsSendAsSmimeInfoSetDefaultCall struct {
  10468. s *Service
  10469. userId string
  10470. sendAsEmail string
  10471. id string
  10472. urlParams_ gensupport.URLParams
  10473. ctx_ context.Context
  10474. header_ http.Header
  10475. }
  10476. // SetDefault: Sets the default S/MIME config for the specified send-as
  10477. // alias.
  10478. func (r *UsersSettingsSendAsSmimeInfoService) SetDefault(userId string, sendAsEmail string, id string) *UsersSettingsSendAsSmimeInfoSetDefaultCall {
  10479. c := &UsersSettingsSendAsSmimeInfoSetDefaultCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10480. c.userId = userId
  10481. c.sendAsEmail = sendAsEmail
  10482. c.id = id
  10483. return c
  10484. }
  10485. // Fields allows partial responses to be retrieved. See
  10486. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10487. // for more information.
  10488. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Fields(s ...googleapi.Field) *UsersSettingsSendAsSmimeInfoSetDefaultCall {
  10489. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10490. return c
  10491. }
  10492. // Context sets the context to be used in this call's Do method. Any
  10493. // pending HTTP request will be aborted if the provided context is
  10494. // canceled.
  10495. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Context(ctx context.Context) *UsersSettingsSendAsSmimeInfoSetDefaultCall {
  10496. c.ctx_ = ctx
  10497. return c
  10498. }
  10499. // Header returns an http.Header that can be modified by the caller to
  10500. // add HTTP headers to the request.
  10501. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Header() http.Header {
  10502. if c.header_ == nil {
  10503. c.header_ = make(http.Header)
  10504. }
  10505. return c.header_
  10506. }
  10507. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) doRequest(alt string) (*http.Response, error) {
  10508. reqHeaders := make(http.Header)
  10509. for k, v := range c.header_ {
  10510. reqHeaders[k] = v
  10511. }
  10512. reqHeaders.Set("User-Agent", c.s.userAgent())
  10513. var body io.Reader = nil
  10514. c.urlParams_.Set("alt", alt)
  10515. c.urlParams_.Set("prettyPrint", "false")
  10516. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault")
  10517. urls += "?" + c.urlParams_.Encode()
  10518. req, err := http.NewRequest("POST", urls, body)
  10519. if err != nil {
  10520. return nil, err
  10521. }
  10522. req.Header = reqHeaders
  10523. googleapi.Expand(req.URL, map[string]string{
  10524. "userId": c.userId,
  10525. "sendAsEmail": c.sendAsEmail,
  10526. "id": c.id,
  10527. })
  10528. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10529. }
  10530. // Do executes the "gmail.users.settings.sendAs.smimeInfo.setDefault" call.
  10531. func (c *UsersSettingsSendAsSmimeInfoSetDefaultCall) Do(opts ...googleapi.CallOption) error {
  10532. gensupport.SetOptions(c.urlParams_, opts...)
  10533. res, err := c.doRequest("json")
  10534. if err != nil {
  10535. return err
  10536. }
  10537. defer googleapi.CloseBody(res)
  10538. if err := googleapi.CheckResponse(res); err != nil {
  10539. return err
  10540. }
  10541. return nil
  10542. // {
  10543. // "description": "Sets the default S/MIME config for the specified send-as alias.",
  10544. // "httpMethod": "POST",
  10545. // "id": "gmail.users.settings.sendAs.smimeInfo.setDefault",
  10546. // "parameterOrder": [
  10547. // "userId",
  10548. // "sendAsEmail",
  10549. // "id"
  10550. // ],
  10551. // "parameters": {
  10552. // "id": {
  10553. // "description": "The immutable ID for the SmimeInfo.",
  10554. // "location": "path",
  10555. // "required": true,
  10556. // "type": "string"
  10557. // },
  10558. // "sendAsEmail": {
  10559. // "description": "The email address that appears in the \"From:\" header for mail sent using this alias.",
  10560. // "location": "path",
  10561. // "required": true,
  10562. // "type": "string"
  10563. // },
  10564. // "userId": {
  10565. // "default": "me",
  10566. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10567. // "location": "path",
  10568. // "required": true,
  10569. // "type": "string"
  10570. // }
  10571. // },
  10572. // "path": "{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault",
  10573. // "scopes": [
  10574. // "https://www.googleapis.com/auth/gmail.settings.basic",
  10575. // "https://www.googleapis.com/auth/gmail.settings.sharing"
  10576. // ]
  10577. // }
  10578. }
  10579. // method id "gmail.users.threads.delete":
  10580. type UsersThreadsDeleteCall struct {
  10581. s *Service
  10582. userId string
  10583. id string
  10584. urlParams_ gensupport.URLParams
  10585. ctx_ context.Context
  10586. header_ http.Header
  10587. }
  10588. // Delete: Immediately and permanently deletes the specified thread.
  10589. // This operation cannot be undone. Prefer threads.trash instead.
  10590. func (r *UsersThreadsService) Delete(userId string, id string) *UsersThreadsDeleteCall {
  10591. c := &UsersThreadsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10592. c.userId = userId
  10593. c.id = id
  10594. return c
  10595. }
  10596. // Fields allows partial responses to be retrieved. See
  10597. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10598. // for more information.
  10599. func (c *UsersThreadsDeleteCall) Fields(s ...googleapi.Field) *UsersThreadsDeleteCall {
  10600. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10601. return c
  10602. }
  10603. // Context sets the context to be used in this call's Do method. Any
  10604. // pending HTTP request will be aborted if the provided context is
  10605. // canceled.
  10606. func (c *UsersThreadsDeleteCall) Context(ctx context.Context) *UsersThreadsDeleteCall {
  10607. c.ctx_ = ctx
  10608. return c
  10609. }
  10610. // Header returns an http.Header that can be modified by the caller to
  10611. // add HTTP headers to the request.
  10612. func (c *UsersThreadsDeleteCall) Header() http.Header {
  10613. if c.header_ == nil {
  10614. c.header_ = make(http.Header)
  10615. }
  10616. return c.header_
  10617. }
  10618. func (c *UsersThreadsDeleteCall) doRequest(alt string) (*http.Response, error) {
  10619. reqHeaders := make(http.Header)
  10620. for k, v := range c.header_ {
  10621. reqHeaders[k] = v
  10622. }
  10623. reqHeaders.Set("User-Agent", c.s.userAgent())
  10624. var body io.Reader = nil
  10625. c.urlParams_.Set("alt", alt)
  10626. c.urlParams_.Set("prettyPrint", "false")
  10627. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
  10628. urls += "?" + c.urlParams_.Encode()
  10629. req, err := http.NewRequest("DELETE", urls, body)
  10630. if err != nil {
  10631. return nil, err
  10632. }
  10633. req.Header = reqHeaders
  10634. googleapi.Expand(req.URL, map[string]string{
  10635. "userId": c.userId,
  10636. "id": c.id,
  10637. })
  10638. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10639. }
  10640. // Do executes the "gmail.users.threads.delete" call.
  10641. func (c *UsersThreadsDeleteCall) Do(opts ...googleapi.CallOption) error {
  10642. gensupport.SetOptions(c.urlParams_, opts...)
  10643. res, err := c.doRequest("json")
  10644. if err != nil {
  10645. return err
  10646. }
  10647. defer googleapi.CloseBody(res)
  10648. if err := googleapi.CheckResponse(res); err != nil {
  10649. return err
  10650. }
  10651. return nil
  10652. // {
  10653. // "description": "Immediately and permanently deletes the specified thread. This operation cannot be undone. Prefer threads.trash instead.",
  10654. // "httpMethod": "DELETE",
  10655. // "id": "gmail.users.threads.delete",
  10656. // "parameterOrder": [
  10657. // "userId",
  10658. // "id"
  10659. // ],
  10660. // "parameters": {
  10661. // "id": {
  10662. // "description": "ID of the Thread to delete.",
  10663. // "location": "path",
  10664. // "required": true,
  10665. // "type": "string"
  10666. // },
  10667. // "userId": {
  10668. // "default": "me",
  10669. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10670. // "location": "path",
  10671. // "required": true,
  10672. // "type": "string"
  10673. // }
  10674. // },
  10675. // "path": "{userId}/threads/{id}",
  10676. // "scopes": [
  10677. // "https://mail.google.com/"
  10678. // ]
  10679. // }
  10680. }
  10681. // method id "gmail.users.threads.get":
  10682. type UsersThreadsGetCall struct {
  10683. s *Service
  10684. userId string
  10685. id string
  10686. urlParams_ gensupport.URLParams
  10687. ifNoneMatch_ string
  10688. ctx_ context.Context
  10689. header_ http.Header
  10690. }
  10691. // Get: Gets the specified thread.
  10692. func (r *UsersThreadsService) Get(userId string, id string) *UsersThreadsGetCall {
  10693. c := &UsersThreadsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10694. c.userId = userId
  10695. c.id = id
  10696. return c
  10697. }
  10698. // Format sets the optional parameter "format": The format to return the
  10699. // messages in.
  10700. //
  10701. // Possible values:
  10702. // "full" (default)
  10703. // "metadata"
  10704. // "minimal"
  10705. func (c *UsersThreadsGetCall) Format(format string) *UsersThreadsGetCall {
  10706. c.urlParams_.Set("format", format)
  10707. return c
  10708. }
  10709. // MetadataHeaders sets the optional parameter "metadataHeaders": When
  10710. // given and format is METADATA, only include headers specified.
  10711. func (c *UsersThreadsGetCall) MetadataHeaders(metadataHeaders ...string) *UsersThreadsGetCall {
  10712. c.urlParams_.SetMulti("metadataHeaders", append([]string{}, metadataHeaders...))
  10713. return c
  10714. }
  10715. // Fields allows partial responses to be retrieved. See
  10716. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10717. // for more information.
  10718. func (c *UsersThreadsGetCall) Fields(s ...googleapi.Field) *UsersThreadsGetCall {
  10719. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10720. return c
  10721. }
  10722. // IfNoneMatch sets the optional parameter which makes the operation
  10723. // fail if the object's ETag matches the given value. This is useful for
  10724. // getting updates only after the object has changed since the last
  10725. // request. Use googleapi.IsNotModified to check whether the response
  10726. // error from Do is the result of In-None-Match.
  10727. func (c *UsersThreadsGetCall) IfNoneMatch(entityTag string) *UsersThreadsGetCall {
  10728. c.ifNoneMatch_ = entityTag
  10729. return c
  10730. }
  10731. // Context sets the context to be used in this call's Do method. Any
  10732. // pending HTTP request will be aborted if the provided context is
  10733. // canceled.
  10734. func (c *UsersThreadsGetCall) Context(ctx context.Context) *UsersThreadsGetCall {
  10735. c.ctx_ = ctx
  10736. return c
  10737. }
  10738. // Header returns an http.Header that can be modified by the caller to
  10739. // add HTTP headers to the request.
  10740. func (c *UsersThreadsGetCall) Header() http.Header {
  10741. if c.header_ == nil {
  10742. c.header_ = make(http.Header)
  10743. }
  10744. return c.header_
  10745. }
  10746. func (c *UsersThreadsGetCall) doRequest(alt string) (*http.Response, error) {
  10747. reqHeaders := make(http.Header)
  10748. for k, v := range c.header_ {
  10749. reqHeaders[k] = v
  10750. }
  10751. reqHeaders.Set("User-Agent", c.s.userAgent())
  10752. if c.ifNoneMatch_ != "" {
  10753. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  10754. }
  10755. var body io.Reader = nil
  10756. c.urlParams_.Set("alt", alt)
  10757. c.urlParams_.Set("prettyPrint", "false")
  10758. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
  10759. urls += "?" + c.urlParams_.Encode()
  10760. req, err := http.NewRequest("GET", urls, body)
  10761. if err != nil {
  10762. return nil, err
  10763. }
  10764. req.Header = reqHeaders
  10765. googleapi.Expand(req.URL, map[string]string{
  10766. "userId": c.userId,
  10767. "id": c.id,
  10768. })
  10769. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10770. }
  10771. // Do executes the "gmail.users.threads.get" call.
  10772. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  10773. // code is an error. Response headers are in either
  10774. // *Thread.ServerResponse.Header or (if a response was returned at all)
  10775. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  10776. // check whether the returned error was because http.StatusNotModified
  10777. // was returned.
  10778. func (c *UsersThreadsGetCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  10779. gensupport.SetOptions(c.urlParams_, opts...)
  10780. res, err := c.doRequest("json")
  10781. if res != nil && res.StatusCode == http.StatusNotModified {
  10782. if res.Body != nil {
  10783. res.Body.Close()
  10784. }
  10785. return nil, &googleapi.Error{
  10786. Code: res.StatusCode,
  10787. Header: res.Header,
  10788. }
  10789. }
  10790. if err != nil {
  10791. return nil, err
  10792. }
  10793. defer googleapi.CloseBody(res)
  10794. if err := googleapi.CheckResponse(res); err != nil {
  10795. return nil, err
  10796. }
  10797. ret := &Thread{
  10798. ServerResponse: googleapi.ServerResponse{
  10799. Header: res.Header,
  10800. HTTPStatusCode: res.StatusCode,
  10801. },
  10802. }
  10803. target := &ret
  10804. if err := gensupport.DecodeResponse(target, res); err != nil {
  10805. return nil, err
  10806. }
  10807. return ret, nil
  10808. // {
  10809. // "description": "Gets the specified thread.",
  10810. // "httpMethod": "GET",
  10811. // "id": "gmail.users.threads.get",
  10812. // "parameterOrder": [
  10813. // "userId",
  10814. // "id"
  10815. // ],
  10816. // "parameters": {
  10817. // "format": {
  10818. // "default": "full",
  10819. // "description": "The format to return the messages in.",
  10820. // "enum": [
  10821. // "full",
  10822. // "metadata",
  10823. // "minimal"
  10824. // ],
  10825. // "enumDescriptions": [
  10826. // "",
  10827. // "",
  10828. // ""
  10829. // ],
  10830. // "location": "query",
  10831. // "type": "string"
  10832. // },
  10833. // "id": {
  10834. // "description": "The ID of the thread to retrieve.",
  10835. // "location": "path",
  10836. // "required": true,
  10837. // "type": "string"
  10838. // },
  10839. // "metadataHeaders": {
  10840. // "description": "When given and format is METADATA, only include headers specified.",
  10841. // "location": "query",
  10842. // "repeated": true,
  10843. // "type": "string"
  10844. // },
  10845. // "userId": {
  10846. // "default": "me",
  10847. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  10848. // "location": "path",
  10849. // "required": true,
  10850. // "type": "string"
  10851. // }
  10852. // },
  10853. // "path": "{userId}/threads/{id}",
  10854. // "response": {
  10855. // "$ref": "Thread"
  10856. // },
  10857. // "scopes": [
  10858. // "https://mail.google.com/",
  10859. // "https://www.googleapis.com/auth/gmail.metadata",
  10860. // "https://www.googleapis.com/auth/gmail.modify",
  10861. // "https://www.googleapis.com/auth/gmail.readonly"
  10862. // ]
  10863. // }
  10864. }
  10865. // method id "gmail.users.threads.list":
  10866. type UsersThreadsListCall struct {
  10867. s *Service
  10868. userId string
  10869. urlParams_ gensupport.URLParams
  10870. ifNoneMatch_ string
  10871. ctx_ context.Context
  10872. header_ http.Header
  10873. }
  10874. // List: Lists the threads in the user's mailbox.
  10875. func (r *UsersThreadsService) List(userId string) *UsersThreadsListCall {
  10876. c := &UsersThreadsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  10877. c.userId = userId
  10878. return c
  10879. }
  10880. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  10881. // Include threads from SPAM and TRASH in the results.
  10882. func (c *UsersThreadsListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersThreadsListCall {
  10883. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  10884. return c
  10885. }
  10886. // LabelIds sets the optional parameter "labelIds": Only return threads
  10887. // with labels that match all of the specified label IDs.
  10888. func (c *UsersThreadsListCall) LabelIds(labelIds ...string) *UsersThreadsListCall {
  10889. c.urlParams_.SetMulti("labelIds", append([]string{}, labelIds...))
  10890. return c
  10891. }
  10892. // MaxResults sets the optional parameter "maxResults": Maximum number
  10893. // of threads to return.
  10894. func (c *UsersThreadsListCall) MaxResults(maxResults int64) *UsersThreadsListCall {
  10895. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  10896. return c
  10897. }
  10898. // PageToken sets the optional parameter "pageToken": Page token to
  10899. // retrieve a specific page of results in the list.
  10900. func (c *UsersThreadsListCall) PageToken(pageToken string) *UsersThreadsListCall {
  10901. c.urlParams_.Set("pageToken", pageToken)
  10902. return c
  10903. }
  10904. // Q sets the optional parameter "q": Only return threads matching the
  10905. // specified query. Supports the same query format as the Gmail search
  10906. // box. For example, "from:someuser@example.com rfc822msgid: is:unread".
  10907. // Parameter cannot be used when accessing the api using the
  10908. // gmail.metadata scope.
  10909. func (c *UsersThreadsListCall) Q(q string) *UsersThreadsListCall {
  10910. c.urlParams_.Set("q", q)
  10911. return c
  10912. }
  10913. // Fields allows partial responses to be retrieved. See
  10914. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  10915. // for more information.
  10916. func (c *UsersThreadsListCall) Fields(s ...googleapi.Field) *UsersThreadsListCall {
  10917. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  10918. return c
  10919. }
  10920. // IfNoneMatch sets the optional parameter which makes the operation
  10921. // fail if the object's ETag matches the given value. This is useful for
  10922. // getting updates only after the object has changed since the last
  10923. // request. Use googleapi.IsNotModified to check whether the response
  10924. // error from Do is the result of In-None-Match.
  10925. func (c *UsersThreadsListCall) IfNoneMatch(entityTag string) *UsersThreadsListCall {
  10926. c.ifNoneMatch_ = entityTag
  10927. return c
  10928. }
  10929. // Context sets the context to be used in this call's Do method. Any
  10930. // pending HTTP request will be aborted if the provided context is
  10931. // canceled.
  10932. func (c *UsersThreadsListCall) Context(ctx context.Context) *UsersThreadsListCall {
  10933. c.ctx_ = ctx
  10934. return c
  10935. }
  10936. // Header returns an http.Header that can be modified by the caller to
  10937. // add HTTP headers to the request.
  10938. func (c *UsersThreadsListCall) Header() http.Header {
  10939. if c.header_ == nil {
  10940. c.header_ = make(http.Header)
  10941. }
  10942. return c.header_
  10943. }
  10944. func (c *UsersThreadsListCall) doRequest(alt string) (*http.Response, error) {
  10945. reqHeaders := make(http.Header)
  10946. for k, v := range c.header_ {
  10947. reqHeaders[k] = v
  10948. }
  10949. reqHeaders.Set("User-Agent", c.s.userAgent())
  10950. if c.ifNoneMatch_ != "" {
  10951. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  10952. }
  10953. var body io.Reader = nil
  10954. c.urlParams_.Set("alt", alt)
  10955. c.urlParams_.Set("prettyPrint", "false")
  10956. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads")
  10957. urls += "?" + c.urlParams_.Encode()
  10958. req, err := http.NewRequest("GET", urls, body)
  10959. if err != nil {
  10960. return nil, err
  10961. }
  10962. req.Header = reqHeaders
  10963. googleapi.Expand(req.URL, map[string]string{
  10964. "userId": c.userId,
  10965. })
  10966. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  10967. }
  10968. // Do executes the "gmail.users.threads.list" call.
  10969. // Exactly one of *ListThreadsResponse or error will be non-nil. Any
  10970. // non-2xx status code is an error. Response headers are in either
  10971. // *ListThreadsResponse.ServerResponse.Header or (if a response was
  10972. // returned at all) in error.(*googleapi.Error).Header. Use
  10973. // googleapi.IsNotModified to check whether the returned error was
  10974. // because http.StatusNotModified was returned.
  10975. func (c *UsersThreadsListCall) Do(opts ...googleapi.CallOption) (*ListThreadsResponse, error) {
  10976. gensupport.SetOptions(c.urlParams_, opts...)
  10977. res, err := c.doRequest("json")
  10978. if res != nil && res.StatusCode == http.StatusNotModified {
  10979. if res.Body != nil {
  10980. res.Body.Close()
  10981. }
  10982. return nil, &googleapi.Error{
  10983. Code: res.StatusCode,
  10984. Header: res.Header,
  10985. }
  10986. }
  10987. if err != nil {
  10988. return nil, err
  10989. }
  10990. defer googleapi.CloseBody(res)
  10991. if err := googleapi.CheckResponse(res); err != nil {
  10992. return nil, err
  10993. }
  10994. ret := &ListThreadsResponse{
  10995. ServerResponse: googleapi.ServerResponse{
  10996. Header: res.Header,
  10997. HTTPStatusCode: res.StatusCode,
  10998. },
  10999. }
  11000. target := &ret
  11001. if err := gensupport.DecodeResponse(target, res); err != nil {
  11002. return nil, err
  11003. }
  11004. return ret, nil
  11005. // {
  11006. // "description": "Lists the threads in the user's mailbox.",
  11007. // "httpMethod": "GET",
  11008. // "id": "gmail.users.threads.list",
  11009. // "parameterOrder": [
  11010. // "userId"
  11011. // ],
  11012. // "parameters": {
  11013. // "includeSpamTrash": {
  11014. // "default": "false",
  11015. // "description": "Include threads from SPAM and TRASH in the results.",
  11016. // "location": "query",
  11017. // "type": "boolean"
  11018. // },
  11019. // "labelIds": {
  11020. // "description": "Only return threads with labels that match all of the specified label IDs.",
  11021. // "location": "query",
  11022. // "repeated": true,
  11023. // "type": "string"
  11024. // },
  11025. // "maxResults": {
  11026. // "default": "100",
  11027. // "description": "Maximum number of threads to return.",
  11028. // "format": "uint32",
  11029. // "location": "query",
  11030. // "type": "integer"
  11031. // },
  11032. // "pageToken": {
  11033. // "description": "Page token to retrieve a specific page of results in the list.",
  11034. // "location": "query",
  11035. // "type": "string"
  11036. // },
  11037. // "q": {
  11038. // "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.",
  11039. // "location": "query",
  11040. // "type": "string"
  11041. // },
  11042. // "userId": {
  11043. // "default": "me",
  11044. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  11045. // "location": "path",
  11046. // "required": true,
  11047. // "type": "string"
  11048. // }
  11049. // },
  11050. // "path": "{userId}/threads",
  11051. // "response": {
  11052. // "$ref": "ListThreadsResponse"
  11053. // },
  11054. // "scopes": [
  11055. // "https://mail.google.com/",
  11056. // "https://www.googleapis.com/auth/gmail.metadata",
  11057. // "https://www.googleapis.com/auth/gmail.modify",
  11058. // "https://www.googleapis.com/auth/gmail.readonly"
  11059. // ]
  11060. // }
  11061. }
  11062. // Pages invokes f for each page of results.
  11063. // A non-nil error returned from f will halt the iteration.
  11064. // The provided context supersedes any context provided to the Context method.
  11065. func (c *UsersThreadsListCall) Pages(ctx context.Context, f func(*ListThreadsResponse) error) error {
  11066. c.ctx_ = ctx
  11067. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  11068. for {
  11069. x, err := c.Do()
  11070. if err != nil {
  11071. return err
  11072. }
  11073. if err := f(x); err != nil {
  11074. return err
  11075. }
  11076. if x.NextPageToken == "" {
  11077. return nil
  11078. }
  11079. c.PageToken(x.NextPageToken)
  11080. }
  11081. }
  11082. // method id "gmail.users.threads.modify":
  11083. type UsersThreadsModifyCall struct {
  11084. s *Service
  11085. userId string
  11086. id string
  11087. modifythreadrequest *ModifyThreadRequest
  11088. urlParams_ gensupport.URLParams
  11089. ctx_ context.Context
  11090. header_ http.Header
  11091. }
  11092. // Modify: Modifies the labels applied to the thread. This applies to
  11093. // all messages in the thread.
  11094. func (r *UsersThreadsService) Modify(userId string, id string, modifythreadrequest *ModifyThreadRequest) *UsersThreadsModifyCall {
  11095. c := &UsersThreadsModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  11096. c.userId = userId
  11097. c.id = id
  11098. c.modifythreadrequest = modifythreadrequest
  11099. return c
  11100. }
  11101. // Fields allows partial responses to be retrieved. See
  11102. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  11103. // for more information.
  11104. func (c *UsersThreadsModifyCall) Fields(s ...googleapi.Field) *UsersThreadsModifyCall {
  11105. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  11106. return c
  11107. }
  11108. // Context sets the context to be used in this call's Do method. Any
  11109. // pending HTTP request will be aborted if the provided context is
  11110. // canceled.
  11111. func (c *UsersThreadsModifyCall) Context(ctx context.Context) *UsersThreadsModifyCall {
  11112. c.ctx_ = ctx
  11113. return c
  11114. }
  11115. // Header returns an http.Header that can be modified by the caller to
  11116. // add HTTP headers to the request.
  11117. func (c *UsersThreadsModifyCall) Header() http.Header {
  11118. if c.header_ == nil {
  11119. c.header_ = make(http.Header)
  11120. }
  11121. return c.header_
  11122. }
  11123. func (c *UsersThreadsModifyCall) doRequest(alt string) (*http.Response, error) {
  11124. reqHeaders := make(http.Header)
  11125. for k, v := range c.header_ {
  11126. reqHeaders[k] = v
  11127. }
  11128. reqHeaders.Set("User-Agent", c.s.userAgent())
  11129. var body io.Reader = nil
  11130. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifythreadrequest)
  11131. if err != nil {
  11132. return nil, err
  11133. }
  11134. reqHeaders.Set("Content-Type", "application/json")
  11135. c.urlParams_.Set("alt", alt)
  11136. c.urlParams_.Set("prettyPrint", "false")
  11137. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/modify")
  11138. urls += "?" + c.urlParams_.Encode()
  11139. req, err := http.NewRequest("POST", urls, body)
  11140. if err != nil {
  11141. return nil, err
  11142. }
  11143. req.Header = reqHeaders
  11144. googleapi.Expand(req.URL, map[string]string{
  11145. "userId": c.userId,
  11146. "id": c.id,
  11147. })
  11148. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  11149. }
  11150. // Do executes the "gmail.users.threads.modify" call.
  11151. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  11152. // code is an error. Response headers are in either
  11153. // *Thread.ServerResponse.Header or (if a response was returned at all)
  11154. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  11155. // check whether the returned error was because http.StatusNotModified
  11156. // was returned.
  11157. func (c *UsersThreadsModifyCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  11158. gensupport.SetOptions(c.urlParams_, opts...)
  11159. res, err := c.doRequest("json")
  11160. if res != nil && res.StatusCode == http.StatusNotModified {
  11161. if res.Body != nil {
  11162. res.Body.Close()
  11163. }
  11164. return nil, &googleapi.Error{
  11165. Code: res.StatusCode,
  11166. Header: res.Header,
  11167. }
  11168. }
  11169. if err != nil {
  11170. return nil, err
  11171. }
  11172. defer googleapi.CloseBody(res)
  11173. if err := googleapi.CheckResponse(res); err != nil {
  11174. return nil, err
  11175. }
  11176. ret := &Thread{
  11177. ServerResponse: googleapi.ServerResponse{
  11178. Header: res.Header,
  11179. HTTPStatusCode: res.StatusCode,
  11180. },
  11181. }
  11182. target := &ret
  11183. if err := gensupport.DecodeResponse(target, res); err != nil {
  11184. return nil, err
  11185. }
  11186. return ret, nil
  11187. // {
  11188. // "description": "Modifies the labels applied to the thread. This applies to all messages in the thread.",
  11189. // "httpMethod": "POST",
  11190. // "id": "gmail.users.threads.modify",
  11191. // "parameterOrder": [
  11192. // "userId",
  11193. // "id"
  11194. // ],
  11195. // "parameters": {
  11196. // "id": {
  11197. // "description": "The ID of the thread to modify.",
  11198. // "location": "path",
  11199. // "required": true,
  11200. // "type": "string"
  11201. // },
  11202. // "userId": {
  11203. // "default": "me",
  11204. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  11205. // "location": "path",
  11206. // "required": true,
  11207. // "type": "string"
  11208. // }
  11209. // },
  11210. // "path": "{userId}/threads/{id}/modify",
  11211. // "request": {
  11212. // "$ref": "ModifyThreadRequest"
  11213. // },
  11214. // "response": {
  11215. // "$ref": "Thread"
  11216. // },
  11217. // "scopes": [
  11218. // "https://mail.google.com/",
  11219. // "https://www.googleapis.com/auth/gmail.modify"
  11220. // ]
  11221. // }
  11222. }
  11223. // method id "gmail.users.threads.trash":
  11224. type UsersThreadsTrashCall struct {
  11225. s *Service
  11226. userId string
  11227. id string
  11228. urlParams_ gensupport.URLParams
  11229. ctx_ context.Context
  11230. header_ http.Header
  11231. }
  11232. // Trash: Moves the specified thread to the trash.
  11233. func (r *UsersThreadsService) Trash(userId string, id string) *UsersThreadsTrashCall {
  11234. c := &UsersThreadsTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  11235. c.userId = userId
  11236. c.id = id
  11237. return c
  11238. }
  11239. // Fields allows partial responses to be retrieved. See
  11240. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  11241. // for more information.
  11242. func (c *UsersThreadsTrashCall) Fields(s ...googleapi.Field) *UsersThreadsTrashCall {
  11243. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  11244. return c
  11245. }
  11246. // Context sets the context to be used in this call's Do method. Any
  11247. // pending HTTP request will be aborted if the provided context is
  11248. // canceled.
  11249. func (c *UsersThreadsTrashCall) Context(ctx context.Context) *UsersThreadsTrashCall {
  11250. c.ctx_ = ctx
  11251. return c
  11252. }
  11253. // Header returns an http.Header that can be modified by the caller to
  11254. // add HTTP headers to the request.
  11255. func (c *UsersThreadsTrashCall) Header() http.Header {
  11256. if c.header_ == nil {
  11257. c.header_ = make(http.Header)
  11258. }
  11259. return c.header_
  11260. }
  11261. func (c *UsersThreadsTrashCall) doRequest(alt string) (*http.Response, error) {
  11262. reqHeaders := make(http.Header)
  11263. for k, v := range c.header_ {
  11264. reqHeaders[k] = v
  11265. }
  11266. reqHeaders.Set("User-Agent", c.s.userAgent())
  11267. var body io.Reader = nil
  11268. c.urlParams_.Set("alt", alt)
  11269. c.urlParams_.Set("prettyPrint", "false")
  11270. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/trash")
  11271. urls += "?" + c.urlParams_.Encode()
  11272. req, err := http.NewRequest("POST", urls, body)
  11273. if err != nil {
  11274. return nil, err
  11275. }
  11276. req.Header = reqHeaders
  11277. googleapi.Expand(req.URL, map[string]string{
  11278. "userId": c.userId,
  11279. "id": c.id,
  11280. })
  11281. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  11282. }
  11283. // Do executes the "gmail.users.threads.trash" call.
  11284. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  11285. // code is an error. Response headers are in either
  11286. // *Thread.ServerResponse.Header or (if a response was returned at all)
  11287. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  11288. // check whether the returned error was because http.StatusNotModified
  11289. // was returned.
  11290. func (c *UsersThreadsTrashCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  11291. gensupport.SetOptions(c.urlParams_, opts...)
  11292. res, err := c.doRequest("json")
  11293. if res != nil && res.StatusCode == http.StatusNotModified {
  11294. if res.Body != nil {
  11295. res.Body.Close()
  11296. }
  11297. return nil, &googleapi.Error{
  11298. Code: res.StatusCode,
  11299. Header: res.Header,
  11300. }
  11301. }
  11302. if err != nil {
  11303. return nil, err
  11304. }
  11305. defer googleapi.CloseBody(res)
  11306. if err := googleapi.CheckResponse(res); err != nil {
  11307. return nil, err
  11308. }
  11309. ret := &Thread{
  11310. ServerResponse: googleapi.ServerResponse{
  11311. Header: res.Header,
  11312. HTTPStatusCode: res.StatusCode,
  11313. },
  11314. }
  11315. target := &ret
  11316. if err := gensupport.DecodeResponse(target, res); err != nil {
  11317. return nil, err
  11318. }
  11319. return ret, nil
  11320. // {
  11321. // "description": "Moves the specified thread to the trash.",
  11322. // "httpMethod": "POST",
  11323. // "id": "gmail.users.threads.trash",
  11324. // "parameterOrder": [
  11325. // "userId",
  11326. // "id"
  11327. // ],
  11328. // "parameters": {
  11329. // "id": {
  11330. // "description": "The ID of the thread to Trash.",
  11331. // "location": "path",
  11332. // "required": true,
  11333. // "type": "string"
  11334. // },
  11335. // "userId": {
  11336. // "default": "me",
  11337. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  11338. // "location": "path",
  11339. // "required": true,
  11340. // "type": "string"
  11341. // }
  11342. // },
  11343. // "path": "{userId}/threads/{id}/trash",
  11344. // "response": {
  11345. // "$ref": "Thread"
  11346. // },
  11347. // "scopes": [
  11348. // "https://mail.google.com/",
  11349. // "https://www.googleapis.com/auth/gmail.modify"
  11350. // ]
  11351. // }
  11352. }
  11353. // method id "gmail.users.threads.untrash":
  11354. type UsersThreadsUntrashCall struct {
  11355. s *Service
  11356. userId string
  11357. id string
  11358. urlParams_ gensupport.URLParams
  11359. ctx_ context.Context
  11360. header_ http.Header
  11361. }
  11362. // Untrash: Removes the specified thread from the trash.
  11363. func (r *UsersThreadsService) Untrash(userId string, id string) *UsersThreadsUntrashCall {
  11364. c := &UsersThreadsUntrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  11365. c.userId = userId
  11366. c.id = id
  11367. return c
  11368. }
  11369. // Fields allows partial responses to be retrieved. See
  11370. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  11371. // for more information.
  11372. func (c *UsersThreadsUntrashCall) Fields(s ...googleapi.Field) *UsersThreadsUntrashCall {
  11373. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  11374. return c
  11375. }
  11376. // Context sets the context to be used in this call's Do method. Any
  11377. // pending HTTP request will be aborted if the provided context is
  11378. // canceled.
  11379. func (c *UsersThreadsUntrashCall) Context(ctx context.Context) *UsersThreadsUntrashCall {
  11380. c.ctx_ = ctx
  11381. return c
  11382. }
  11383. // Header returns an http.Header that can be modified by the caller to
  11384. // add HTTP headers to the request.
  11385. func (c *UsersThreadsUntrashCall) Header() http.Header {
  11386. if c.header_ == nil {
  11387. c.header_ = make(http.Header)
  11388. }
  11389. return c.header_
  11390. }
  11391. func (c *UsersThreadsUntrashCall) doRequest(alt string) (*http.Response, error) {
  11392. reqHeaders := make(http.Header)
  11393. for k, v := range c.header_ {
  11394. reqHeaders[k] = v
  11395. }
  11396. reqHeaders.Set("User-Agent", c.s.userAgent())
  11397. var body io.Reader = nil
  11398. c.urlParams_.Set("alt", alt)
  11399. c.urlParams_.Set("prettyPrint", "false")
  11400. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/untrash")
  11401. urls += "?" + c.urlParams_.Encode()
  11402. req, err := http.NewRequest("POST", urls, body)
  11403. if err != nil {
  11404. return nil, err
  11405. }
  11406. req.Header = reqHeaders
  11407. googleapi.Expand(req.URL, map[string]string{
  11408. "userId": c.userId,
  11409. "id": c.id,
  11410. })
  11411. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  11412. }
  11413. // Do executes the "gmail.users.threads.untrash" call.
  11414. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  11415. // code is an error. Response headers are in either
  11416. // *Thread.ServerResponse.Header or (if a response was returned at all)
  11417. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  11418. // check whether the returned error was because http.StatusNotModified
  11419. // was returned.
  11420. func (c *UsersThreadsUntrashCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  11421. gensupport.SetOptions(c.urlParams_, opts...)
  11422. res, err := c.doRequest("json")
  11423. if res != nil && res.StatusCode == http.StatusNotModified {
  11424. if res.Body != nil {
  11425. res.Body.Close()
  11426. }
  11427. return nil, &googleapi.Error{
  11428. Code: res.StatusCode,
  11429. Header: res.Header,
  11430. }
  11431. }
  11432. if err != nil {
  11433. return nil, err
  11434. }
  11435. defer googleapi.CloseBody(res)
  11436. if err := googleapi.CheckResponse(res); err != nil {
  11437. return nil, err
  11438. }
  11439. ret := &Thread{
  11440. ServerResponse: googleapi.ServerResponse{
  11441. Header: res.Header,
  11442. HTTPStatusCode: res.StatusCode,
  11443. },
  11444. }
  11445. target := &ret
  11446. if err := gensupport.DecodeResponse(target, res); err != nil {
  11447. return nil, err
  11448. }
  11449. return ret, nil
  11450. // {
  11451. // "description": "Removes the specified thread from the trash.",
  11452. // "httpMethod": "POST",
  11453. // "id": "gmail.users.threads.untrash",
  11454. // "parameterOrder": [
  11455. // "userId",
  11456. // "id"
  11457. // ],
  11458. // "parameters": {
  11459. // "id": {
  11460. // "description": "The ID of the thread to remove from Trash.",
  11461. // "location": "path",
  11462. // "required": true,
  11463. // "type": "string"
  11464. // },
  11465. // "userId": {
  11466. // "default": "me",
  11467. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  11468. // "location": "path",
  11469. // "required": true,
  11470. // "type": "string"
  11471. // }
  11472. // },
  11473. // "path": "{userId}/threads/{id}/untrash",
  11474. // "response": {
  11475. // "$ref": "Thread"
  11476. // },
  11477. // "scopes": [
  11478. // "https://mail.google.com/",
  11479. // "https://www.googleapis.com/auth/gmail.modify"
  11480. // ]
  11481. // }
  11482. }