1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package groupsmigration
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "net/http"
61 "net/url"
62 "strconv"
63 "strings"
64
65 googleapi "google.golang.org/api/googleapi"
66 internal "google.golang.org/api/internal"
67 gensupport "google.golang.org/api/internal/gensupport"
68 option "google.golang.org/api/option"
69 internaloption "google.golang.org/api/option/internaloption"
70 htransport "google.golang.org/api/transport/http"
71 )
72
73
74
75 var _ = bytes.NewBuffer
76 var _ = strconv.Itoa
77 var _ = fmt.Sprintf
78 var _ = json.NewDecoder
79 var _ = io.Copy
80 var _ = url.Parse
81 var _ = gensupport.MarshalJSON
82 var _ = googleapi.Version
83 var _ = errors.New
84 var _ = strings.Replace
85 var _ = context.Canceled
86 var _ = internaloption.WithDefaultEndpoint
87 var _ = internal.Version
88
89 const apiId = "groupsmigration:v1"
90 const apiName = "groupsmigration"
91 const apiVersion = "v1"
92 const basePath = "https://groupsmigration.googleapis.com/"
93 const basePathTemplate = "https://groupsmigration.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://groupsmigration.mtls.googleapis.com/"
95
96
97 const (
98
99 AppsGroupsMigrationScope = "https://www.googleapis.com/auth/apps.groups.migration"
100 )
101
102
103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
104 scopesOption := internaloption.WithDefaultScopes(
105 "https://www.googleapis.com/auth/apps.groups.migration",
106 )
107
108 opts = append([]option.ClientOption{scopesOption}, opts...)
109 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
110 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
111 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
112 opts = append(opts, internaloption.EnableNewAuthLibrary())
113 client, endpoint, err := htransport.NewClient(ctx, opts...)
114 if err != nil {
115 return nil, err
116 }
117 s, err := New(client)
118 if err != nil {
119 return nil, err
120 }
121 if endpoint != "" {
122 s.BasePath = endpoint
123 }
124 return s, nil
125 }
126
127
128
129
130
131
132 func New(client *http.Client) (*Service, error) {
133 if client == nil {
134 return nil, errors.New("client is nil")
135 }
136 s := &Service{client: client, BasePath: basePath}
137 s.Archive = NewArchiveService(s)
138 return s, nil
139 }
140
141 type Service struct {
142 client *http.Client
143 BasePath string
144 UserAgent string
145
146 Archive *ArchiveService
147 }
148
149 func (s *Service) userAgent() string {
150 if s.UserAgent == "" {
151 return googleapi.UserAgent
152 }
153 return googleapi.UserAgent + " " + s.UserAgent
154 }
155
156 func NewArchiveService(s *Service) *ArchiveService {
157 rs := &ArchiveService{s: s}
158 return rs
159 }
160
161 type ArchiveService struct {
162 s *Service
163 }
164
165
166 type Groups struct {
167
168 Kind string `json:"kind,omitempty"`
169
170 ResponseCode string `json:"responseCode,omitempty"`
171
172
173 googleapi.ServerResponse `json:"-"`
174
175
176
177
178
179 ForceSendFields []string `json:"-"`
180
181
182
183
184 NullFields []string `json:"-"`
185 }
186
187 func (s *Groups) MarshalJSON() ([]byte, error) {
188 type NoMethod Groups
189 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
190 }
191
192 type ArchiveInsertCall struct {
193 s *Service
194 groupId string
195 urlParams_ gensupport.URLParams
196 mediaInfo_ *gensupport.MediaInfo
197 ctx_ context.Context
198 header_ http.Header
199 }
200
201
202
203
204 func (r *ArchiveService) Insert(groupId string) *ArchiveInsertCall {
205 c := &ArchiveInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
206 c.groupId = groupId
207 return c
208 }
209
210
211
212
213
214
215
216
217 func (c *ArchiveInsertCall) Media(r io.Reader, options ...googleapi.MediaOption) *ArchiveInsertCall {
218 c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
219 return c
220 }
221
222
223
224
225
226
227
228
229
230
231 func (c *ArchiveInsertCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *ArchiveInsertCall {
232 c.ctx_ = ctx
233 c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
234 return c
235 }
236
237
238
239
240
241 func (c *ArchiveInsertCall) ProgressUpdater(pu googleapi.ProgressUpdater) *ArchiveInsertCall {
242 c.mediaInfo_.SetProgressUpdater(pu)
243 return c
244 }
245
246
247
248
249 func (c *ArchiveInsertCall) Fields(s ...googleapi.Field) *ArchiveInsertCall {
250 c.urlParams_.Set("fields", googleapi.CombineFields(s))
251 return c
252 }
253
254
255
256
257 func (c *ArchiveInsertCall) Context(ctx context.Context) *ArchiveInsertCall {
258 c.ctx_ = ctx
259 return c
260 }
261
262
263
264 func (c *ArchiveInsertCall) Header() http.Header {
265 if c.header_ == nil {
266 c.header_ = make(http.Header)
267 }
268 return c.header_
269 }
270
271 func (c *ArchiveInsertCall) doRequest(alt string) (*http.Response, error) {
272 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
273 var body io.Reader = nil
274 c.urlParams_.Set("alt", alt)
275 c.urlParams_.Set("prettyPrint", "false")
276 urls := googleapi.ResolveRelative(c.s.BasePath, "groups/v1/groups/{groupId}/archive")
277 if c.mediaInfo_ != nil {
278 urls = googleapi.ResolveRelative(c.s.BasePath, "/upload/groups/v1/groups/{groupId}/archive")
279 c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
280 }
281 if body == nil {
282 body = new(bytes.Buffer)
283 reqHeaders.Set("Content-Type", "application/json")
284 }
285 body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
286 defer cleanup()
287 urls += "?" + c.urlParams_.Encode()
288 req, err := http.NewRequest("POST", urls, body)
289 if err != nil {
290 return nil, err
291 }
292 req.Header = reqHeaders
293 req.GetBody = getBody
294 googleapi.Expand(req.URL, map[string]string{
295 "groupId": c.groupId,
296 })
297 return gensupport.SendRequest(c.ctx_, c.s.client, req)
298 }
299
300
301
302
303
304
305 func (c *ArchiveInsertCall) Do(opts ...googleapi.CallOption) (*Groups, error) {
306 gensupport.SetOptions(c.urlParams_, opts...)
307 res, err := c.doRequest("json")
308 if res != nil && res.StatusCode == http.StatusNotModified {
309 if res.Body != nil {
310 res.Body.Close()
311 }
312 return nil, gensupport.WrapError(&googleapi.Error{
313 Code: res.StatusCode,
314 Header: res.Header,
315 })
316 }
317 if err != nil {
318 return nil, err
319 }
320 defer googleapi.CloseBody(res)
321 if err := googleapi.CheckResponse(res); err != nil {
322 return nil, gensupport.WrapError(err)
323 }
324 rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
325 if rx != nil {
326 rx.Client = c.s.client
327 rx.UserAgent = c.s.userAgent()
328 ctx := c.ctx_
329 if ctx == nil {
330 ctx = context.TODO()
331 }
332 res, err = rx.Upload(ctx)
333 if err != nil {
334 return nil, err
335 }
336 defer res.Body.Close()
337 if err := googleapi.CheckResponse(res); err != nil {
338 return nil, gensupport.WrapError(err)
339 }
340 }
341 ret := &Groups{
342 ServerResponse: googleapi.ServerResponse{
343 Header: res.Header,
344 HTTPStatusCode: res.StatusCode,
345 },
346 }
347 target := &ret
348 if err := gensupport.DecodeResponse(target, res); err != nil {
349 return nil, err
350 }
351 return ret, nil
352 }
353
View as plain text