~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/google.golang.org/api/groupsmigration/v1/groupsmigration-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 groupsmigration provides access to the Groups Migration API.
 
2
//
 
3
// See https://developers.google.com/google-apps/groups-migration/
 
4
//
 
5
// Usage example:
 
6
//
 
7
//   import "google.golang.org/api/groupsmigration/v1"
 
8
//   ...
 
9
//   groupsmigrationService, err := groupsmigration.New(oauthHttpClient)
 
10
package groupsmigration
 
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 = "groupsmigration:v1"
 
38
const apiName = "groupsmigration"
 
39
const apiVersion = "v1"
 
40
const basePath = "https://www.googleapis.com/groups/v1/groups/"
 
41
 
 
42
func New(client *http.Client) (*Service, error) {
 
43
        if client == nil {
 
44
                return nil, errors.New("client is nil")
 
45
        }
 
46
        s := &Service{client: client, BasePath: basePath}
 
47
        s.Archive = NewArchiveService(s)
 
48
        return s, nil
 
49
}
 
50
 
 
51
type Service struct {
 
52
        client   *http.Client
 
53
        BasePath string // API endpoint base URL
 
54
 
 
55
        Archive *ArchiveService
 
56
}
 
57
 
 
58
func NewArchiveService(s *Service) *ArchiveService {
 
59
        rs := &ArchiveService{s: s}
 
60
        return rs
 
61
}
 
62
 
 
63
type ArchiveService struct {
 
64
        s *Service
 
65
}
 
66
 
 
67
type Groups struct {
 
68
        // Kind: The kind of insert resource this is.
 
69
        Kind string `json:"kind,omitempty"`
 
70
 
 
71
        // ResponseCode: The status of the insert request.
 
72
        ResponseCode string `json:"responseCode,omitempty"`
 
73
}
 
74
 
 
75
// method id "groupsmigration.archive.insert":
 
76
 
 
77
type ArchiveInsertCall struct {
 
78
        s       *Service
 
79
        groupId string
 
80
        opt_    map[string]interface{}
 
81
        media_  io.Reader
 
82
}
 
83
 
 
84
// Insert: Inserts a new mail into the archive of the Google group.
 
85
func (r *ArchiveService) Insert(groupId string) *ArchiveInsertCall {
 
86
        c := &ArchiveInsertCall{s: r.s, opt_: make(map[string]interface{})}
 
87
        c.groupId = groupId
 
88
        return c
 
89
}
 
90
func (c *ArchiveInsertCall) Media(r io.Reader) *ArchiveInsertCall {
 
91
        c.media_ = r
 
92
        return c
 
93
}
 
94
 
 
95
// Fields allows partial responses to be retrieved.
 
96
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
 
97
// for more information.
 
98
func (c *ArchiveInsertCall) Fields(s ...googleapi.Field) *ArchiveInsertCall {
 
99
        c.opt_["fields"] = googleapi.CombineFields(s)
 
100
        return c
 
101
}
 
102
 
 
103
func (c *ArchiveInsertCall) Do() (*Groups, error) {
 
104
        var body io.Reader = nil
 
105
        params := make(url.Values)
 
106
        params.Set("alt", "json")
 
107
        if v, ok := c.opt_["fields"]; ok {
 
108
                params.Set("fields", fmt.Sprintf("%v", v))
 
109
        }
 
110
        urls := googleapi.ResolveRelative(c.s.BasePath, "{groupId}/archive")
 
111
        if c.media_ != nil {
 
112
                urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
 
113
                params.Set("uploadType", "multipart")
 
114
        }
 
115
        urls += "?" + params.Encode()
 
116
        body = new(bytes.Buffer)
 
117
        ctype := "application/json"
 
118
        contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
 
119
        req, _ := http.NewRequest("POST", urls, body)
 
120
        googleapi.Expand(req.URL, map[string]string{
 
121
                "groupId": c.groupId,
 
122
        })
 
123
        if hasMedia_ {
 
124
                req.ContentLength = contentLength_
 
125
        }
 
126
        req.Header.Set("Content-Type", ctype)
 
127
        req.Header.Set("User-Agent", "google-api-go-client/0.5")
 
128
        res, err := c.s.client.Do(req)
 
129
        if err != nil {
 
130
                return nil, err
 
131
        }
 
132
        defer googleapi.CloseBody(res)
 
133
        if err := googleapi.CheckResponse(res); err != nil {
 
134
                return nil, err
 
135
        }
 
136
        var ret *Groups
 
137
        if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
 
138
                return nil, err
 
139
        }
 
140
        return ret, nil
 
141
        // {
 
142
        //   "description": "Inserts a new mail into the archive of the Google group.",
 
143
        //   "httpMethod": "POST",
 
144
        //   "id": "groupsmigration.archive.insert",
 
145
        //   "mediaUpload": {
 
146
        //     "accept": [
 
147
        //       "message/rfc822"
 
148
        //     ],
 
149
        //     "maxSize": "16MB",
 
150
        //     "protocols": {
 
151
        //       "resumable": {
 
152
        //         "multipart": true,
 
153
        //         "path": "/resumable/upload/groups/v1/groups/{groupId}/archive"
 
154
        //       },
 
155
        //       "simple": {
 
156
        //         "multipart": true,
 
157
        //         "path": "/upload/groups/v1/groups/{groupId}/archive"
 
158
        //       }
 
159
        //     }
 
160
        //   },
 
161
        //   "parameterOrder": [
 
162
        //     "groupId"
 
163
        //   ],
 
164
        //   "parameters": {
 
165
        //     "groupId": {
 
166
        //       "description": "The group ID",
 
167
        //       "location": "path",
 
168
        //       "required": true,
 
169
        //       "type": "string"
 
170
        //     }
 
171
        //   },
 
172
        //   "path": "{groupId}/archive",
 
173
        //   "response": {
 
174
        //     "$ref": "Groups"
 
175
        //   },
 
176
        //   "supportsMediaUpload": true
 
177
        // }
 
178
 
 
179
}