~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/google.golang.org/api/admin/email_migration_v2/admin-gen.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Package admin provides access to the Email Migration API v2.
 
2
//
 
3
// See https://developers.google.com/admin-sdk/email-migration/v2/
 
4
//
 
5
// Usage example:
 
6
//
 
7
//   import "google.golang.org/api/admin/email_migration_v2"
 
8
//   ...
 
9
//   adminService, err := admin.New(oauthHttpClient)
 
10
package admin
 
11
 
 
12
import (
 
13
        "bytes"
 
14
        "encoding/json"
 
15
        "errors"
 
16
        "fmt"
 
17
        "google.golang.org/api/googleapi"
 
18
        "io"
 
19
        "net/http"
 
20
        "net/url"
 
21
        "strconv"
 
22
        "strings"
 
23
)
 
24
 
 
25
// Always reference these packages, just in case the auto-generated code
 
26
// below doesn't.
 
27
var _ = bytes.NewBuffer
 
28
var _ = strconv.Itoa
 
29
var _ = fmt.Sprintf
 
30
var _ = json.NewDecoder
 
31
var _ = io.Copy
 
32
var _ = url.Parse
 
33
var _ = googleapi.Version
 
34
var _ = errors.New
 
35
var _ = strings.Replace
 
36
 
 
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/"
 
41
 
 
42
// OAuth2 scopes used by this API.
 
43
const (
 
44
        // Manage email messages of users on your domain
 
45
        EmailMigrationScope = "https://www.googleapis.com/auth/email.migration"
 
46
)
 
47
 
 
48
func New(client *http.Client) (*Service, error) {
 
49
        if client == nil {
 
50
                return nil, errors.New("client is nil")
 
51
        }
 
52
        s := &Service{client: client, BasePath: basePath}
 
53
        s.Mail = NewMailService(s)
 
54
        return s, nil
 
55
}
 
56
 
 
57
type Service struct {
 
58
        client   *http.Client
 
59
        BasePath string // API endpoint base URL
 
60
 
 
61
        Mail *MailService
 
62
}
 
63
 
 
64
func NewMailService(s *Service) *MailService {
 
65
        rs := &MailService{s: s}
 
66
        return rs
 
67
}
 
68
 
 
69
type MailService struct {
 
70
        s *Service
 
71
}
 
72
 
 
73
type MailItem struct {
 
74
        // IsDeleted: Boolean indicating if the mail is deleted (used in Vault)
 
75
        IsDeleted bool `json:"isDeleted,omitempty"`
 
76
 
 
77
        // IsDraft: Boolean indicating if the mail is draft
 
78
        IsDraft bool `json:"isDraft,omitempty"`
 
79
 
 
80
        // IsInbox: Boolean indicating if the mail is in inbox
 
81
        IsInbox bool `json:"isInbox,omitempty"`
 
82
 
 
83
        // IsSent: Boolean indicating if the mail is in 'sent mails'
 
84
        IsSent bool `json:"isSent,omitempty"`
 
85
 
 
86
        // IsStarred: Boolean indicating if the mail is starred
 
87
        IsStarred bool `json:"isStarred,omitempty"`
 
88
 
 
89
        // IsTrash: Boolean indicating if the mail is in trash
 
90
        IsTrash bool `json:"isTrash,omitempty"`
 
91
 
 
92
        // IsUnread: Boolean indicating if the mail is unread
 
93
        IsUnread bool `json:"isUnread,omitempty"`
 
94
 
 
95
        // Kind: Kind of resource this is.
 
96
        Kind string `json:"kind,omitempty"`
 
97
 
 
98
        // Labels: List of labels (strings)
 
99
        Labels []string `json:"labels,omitempty"`
 
100
}
 
101
 
 
102
// method id "emailMigration.mail.insert":
 
103
 
 
104
type MailInsertCall struct {
 
105
        s        *Service
 
106
        userKey  string
 
107
        mailitem *MailItem
 
108
        opt_     map[string]interface{}
 
109
        media_   io.Reader
 
110
}
 
111
 
 
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{})}
 
115
        c.userKey = userKey
 
116
        c.mailitem = mailitem
 
117
        return c
 
118
}
 
119
func (c *MailInsertCall) Media(r io.Reader) *MailInsertCall {
 
120
        c.media_ = r
 
121
        return c
 
122
}
 
123
 
 
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)
 
129
        return c
 
130
}
 
131
 
 
132
func (c *MailInsertCall) Do() error {
 
133
        var body io.Reader = nil
 
134
        body, err := googleapi.WithoutDataWrapper.JSONReader(c.mailitem)
 
135
        if err != nil {
 
136
                return err
 
137
        }
 
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))
 
143
        }
 
144
        urls := googleapi.ResolveRelative(c.s.BasePath, "{userKey}/mail")
 
145
        if c.media_ != nil {
 
146
                urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
 
147
                params.Set("uploadType", "multipart")
 
148
        }
 
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,
 
154
        })
 
155
        if hasMedia_ {
 
156
                req.ContentLength = contentLength_
 
157
        }
 
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)
 
161
        if err != nil {
 
162
                return err
 
163
        }
 
164
        defer googleapi.CloseBody(res)
 
165
        if err := googleapi.CheckResponse(res); err != nil {
 
166
                return err
 
167
        }
 
168
        return nil
 
169
        // {
 
170
        //   "description": "Insert Mail into Google's Gmail backends",
 
171
        //   "httpMethod": "POST",
 
172
        //   "id": "emailMigration.mail.insert",
 
173
        //   "mediaUpload": {
 
174
        //     "accept": [
 
175
        //       "message/rfc822"
 
176
        //     ],
 
177
        //     "maxSize": "35MB",
 
178
        //     "protocols": {
 
179
        //       "resumable": {
 
180
        //         "multipart": true,
 
181
        //         "path": "/resumable/upload/email/v2/users/{userKey}/mail"
 
182
        //       },
 
183
        //       "simple": {
 
184
        //         "multipart": true,
 
185
        //         "path": "/upload/email/v2/users/{userKey}/mail"
 
186
        //       }
 
187
        //     }
 
188
        //   },
 
189
        //   "parameterOrder": [
 
190
        //     "userKey"
 
191
        //   ],
 
192
        //   "parameters": {
 
193
        //     "userKey": {
 
194
        //       "description": "The email or immutable id of the user",
 
195
        //       "location": "path",
 
196
        //       "required": true,
 
197
        //       "type": "string"
 
198
        //     }
 
199
        //   },
 
200
        //   "path": "{userKey}/mail",
 
201
        //   "request": {
 
202
        //     "$ref": "MailItem"
 
203
        //   },
 
204
        //   "scopes": [
 
205
        //     "https://www.googleapis.com/auth/email.migration"
 
206
        //   ],
 
207
        //   "supportsMediaUpload": true
 
208
        // }
 
209
 
 
210
}