1
// Package admin provides access to the Email Migration API v2.
3
// See https://developers.google.com/admin-sdk/email-migration/v2/
7
// import "google.golang.org/api/admin/email_migration_v2"
9
// adminService, err := admin.New(oauthHttpClient)
17
"google.golang.org/api/googleapi"
25
// Always reference these packages, just in case the auto-generated code
27
var _ = bytes.NewBuffer
30
var _ = json.NewDecoder
33
var _ = googleapi.Version
35
var _ = strings.Replace
37
const apiId = "admin:email_migration_v2"
38
const apiName = "admin"
39
const apiVersion = "email_migration_v2"
40
const basePath = "https://www.googleapis.com/email/v2/users/"
42
// OAuth2 scopes used by this API.
44
// Manage email messages of users on your domain
45
EmailMigrationScope = "https://www.googleapis.com/auth/email.migration"
48
func New(client *http.Client) (*Service, error) {
50
return nil, errors.New("client is nil")
52
s := &Service{client: client, BasePath: basePath}
53
s.Mail = NewMailService(s)
59
BasePath string // API endpoint base URL
64
func NewMailService(s *Service) *MailService {
65
rs := &MailService{s: s}
69
type MailService struct {
73
type MailItem struct {
74
// IsDeleted: Boolean indicating if the mail is deleted (used in Vault)
75
IsDeleted bool `json:"isDeleted,omitempty"`
77
// IsDraft: Boolean indicating if the mail is draft
78
IsDraft bool `json:"isDraft,omitempty"`
80
// IsInbox: Boolean indicating if the mail is in inbox
81
IsInbox bool `json:"isInbox,omitempty"`
83
// IsSent: Boolean indicating if the mail is in 'sent mails'
84
IsSent bool `json:"isSent,omitempty"`
86
// IsStarred: Boolean indicating if the mail is starred
87
IsStarred bool `json:"isStarred,omitempty"`
89
// IsTrash: Boolean indicating if the mail is in trash
90
IsTrash bool `json:"isTrash,omitempty"`
92
// IsUnread: Boolean indicating if the mail is unread
93
IsUnread bool `json:"isUnread,omitempty"`
95
// Kind: Kind of resource this is.
96
Kind string `json:"kind,omitempty"`
98
// Labels: List of labels (strings)
99
Labels []string `json:"labels,omitempty"`
102
// method id "emailMigration.mail.insert":
104
type MailInsertCall struct {
108
opt_ map[string]interface{}
112
// Insert: Insert Mail into Google's Gmail backends
113
func (r *MailService) Insert(userKey string, mailitem *MailItem) *MailInsertCall {
114
c := &MailInsertCall{s: r.s, opt_: make(map[string]interface{})}
116
c.mailitem = mailitem
119
func (c *MailInsertCall) Media(r io.Reader) *MailInsertCall {
124
// Fields allows partial responses to be retrieved.
125
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
126
// for more information.
127
func (c *MailInsertCall) Fields(s ...googleapi.Field) *MailInsertCall {
128
c.opt_["fields"] = googleapi.CombineFields(s)
132
func (c *MailInsertCall) Do() error {
133
var body io.Reader = nil
134
body, err := googleapi.WithoutDataWrapper.JSONReader(c.mailitem)
138
ctype := "application/json"
139
params := make(url.Values)
140
params.Set("alt", "json")
141
if v, ok := c.opt_["fields"]; ok {
142
params.Set("fields", fmt.Sprintf("%v", v))
144
urls := googleapi.ResolveRelative(c.s.BasePath, "{userKey}/mail")
146
urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
147
params.Set("uploadType", "multipart")
149
urls += "?" + params.Encode()
150
contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
151
req, _ := http.NewRequest("POST", urls, body)
152
googleapi.Expand(req.URL, map[string]string{
153
"userKey": c.userKey,
156
req.ContentLength = contentLength_
158
req.Header.Set("Content-Type", ctype)
159
req.Header.Set("User-Agent", "google-api-go-client/0.5")
160
res, err := c.s.client.Do(req)
164
defer googleapi.CloseBody(res)
165
if err := googleapi.CheckResponse(res); err != nil {
170
// "description": "Insert Mail into Google's Gmail backends",
171
// "httpMethod": "POST",
172
// "id": "emailMigration.mail.insert",
177
// "maxSize": "35MB",
180
// "multipart": true,
181
// "path": "/resumable/upload/email/v2/users/{userKey}/mail"
184
// "multipart": true,
185
// "path": "/upload/email/v2/users/{userKey}/mail"
189
// "parameterOrder": [
194
// "description": "The email or immutable id of the user",
195
// "location": "path",
200
// "path": "{userKey}/mail",
202
// "$ref": "MailItem"
205
// "https://www.googleapis.com/auth/email.migration"
207
// "supportsMediaUpload": true