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 playcustomapp
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 = "playcustomapp:v1"
90 const apiName = "playcustomapp"
91 const apiVersion = "v1"
92 const basePath = "https://playcustomapp.googleapis.com/"
93 const basePathTemplate = "https://playcustomapp.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://playcustomapp.mtls.googleapis.com/"
95
96
97 const (
98
99 AndroidpublisherScope = "https://www.googleapis.com/auth/androidpublisher"
100 )
101
102
103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
104 scopesOption := internaloption.WithDefaultScopes(
105 "https://www.googleapis.com/auth/androidpublisher",
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.Accounts = NewAccountsService(s)
138 return s, nil
139 }
140
141 type Service struct {
142 client *http.Client
143 BasePath string
144 UserAgent string
145
146 Accounts *AccountsService
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 NewAccountsService(s *Service) *AccountsService {
157 rs := &AccountsService{s: s}
158 rs.CustomApps = NewAccountsCustomAppsService(s)
159 return rs
160 }
161
162 type AccountsService struct {
163 s *Service
164
165 CustomApps *AccountsCustomAppsService
166 }
167
168 func NewAccountsCustomAppsService(s *Service) *AccountsCustomAppsService {
169 rs := &AccountsCustomAppsService{s: s}
170 return rs
171 }
172
173 type AccountsCustomAppsService struct {
174 s *Service
175 }
176
177
178 type CustomApp struct {
179
180 LanguageCode string `json:"languageCode,omitempty"`
181
182
183
184
185
186
187
188 Organizations []*Organization `json:"organizations,omitempty"`
189
190
191 PackageName string `json:"packageName,omitempty"`
192
193 Title string `json:"title,omitempty"`
194
195
196 googleapi.ServerResponse `json:"-"`
197
198
199
200
201
202 ForceSendFields []string `json:"-"`
203
204
205
206
207 NullFields []string `json:"-"`
208 }
209
210 func (s *CustomApp) MarshalJSON() ([]byte, error) {
211 type NoMethod CustomApp
212 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
213 }
214
215
216 type Organization struct {
217
218 OrganizationId string `json:"organizationId,omitempty"`
219
220
221 OrganizationName string `json:"organizationName,omitempty"`
222
223
224
225
226
227 ForceSendFields []string `json:"-"`
228
229
230
231
232 NullFields []string `json:"-"`
233 }
234
235 func (s *Organization) MarshalJSON() ([]byte, error) {
236 type NoMethod Organization
237 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
238 }
239
240 type AccountsCustomAppsCreateCall struct {
241 s *Service
242 account int64
243 customapp *CustomApp
244 urlParams_ gensupport.URLParams
245 mediaInfo_ *gensupport.MediaInfo
246 ctx_ context.Context
247 header_ http.Header
248 }
249
250
251
252
253 func (r *AccountsCustomAppsService) Create(account int64, customapp *CustomApp) *AccountsCustomAppsCreateCall {
254 c := &AccountsCustomAppsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
255 c.account = account
256 c.customapp = customapp
257 return c
258 }
259
260
261
262
263
264
265
266
267 func (c *AccountsCustomAppsCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *AccountsCustomAppsCreateCall {
268 c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
269 return c
270 }
271
272
273
274
275
276
277
278
279
280
281 func (c *AccountsCustomAppsCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *AccountsCustomAppsCreateCall {
282 c.ctx_ = ctx
283 c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
284 return c
285 }
286
287
288
289
290
291 func (c *AccountsCustomAppsCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *AccountsCustomAppsCreateCall {
292 c.mediaInfo_.SetProgressUpdater(pu)
293 return c
294 }
295
296
297
298
299 func (c *AccountsCustomAppsCreateCall) Fields(s ...googleapi.Field) *AccountsCustomAppsCreateCall {
300 c.urlParams_.Set("fields", googleapi.CombineFields(s))
301 return c
302 }
303
304
305
306
307 func (c *AccountsCustomAppsCreateCall) Context(ctx context.Context) *AccountsCustomAppsCreateCall {
308 c.ctx_ = ctx
309 return c
310 }
311
312
313
314 func (c *AccountsCustomAppsCreateCall) Header() http.Header {
315 if c.header_ == nil {
316 c.header_ = make(http.Header)
317 }
318 return c.header_
319 }
320
321 func (c *AccountsCustomAppsCreateCall) doRequest(alt string) (*http.Response, error) {
322 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
323 var body io.Reader = nil
324 body, err := googleapi.WithoutDataWrapper.JSONReader(c.customapp)
325 if err != nil {
326 return nil, err
327 }
328 c.urlParams_.Set("alt", alt)
329 c.urlParams_.Set("prettyPrint", "false")
330 urls := googleapi.ResolveRelative(c.s.BasePath, "playcustomapp/v1/accounts/{account}/customApps")
331 if c.mediaInfo_ != nil {
332 urls = googleapi.ResolveRelative(c.s.BasePath, "/upload/playcustomapp/v1/accounts/{account}/customApps")
333 c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
334 }
335 if body == nil {
336 body = new(bytes.Buffer)
337 reqHeaders.Set("Content-Type", "application/json")
338 }
339 body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
340 defer cleanup()
341 urls += "?" + c.urlParams_.Encode()
342 req, err := http.NewRequest("POST", urls, body)
343 if err != nil {
344 return nil, err
345 }
346 req.Header = reqHeaders
347 req.GetBody = getBody
348 googleapi.Expand(req.URL, map[string]string{
349 "account": strconv.FormatInt(c.account, 10),
350 })
351 return gensupport.SendRequest(c.ctx_, c.s.client, req)
352 }
353
354
355
356
357
358
359 func (c *AccountsCustomAppsCreateCall) Do(opts ...googleapi.CallOption) (*CustomApp, error) {
360 gensupport.SetOptions(c.urlParams_, opts...)
361 res, err := c.doRequest("json")
362 if res != nil && res.StatusCode == http.StatusNotModified {
363 if res.Body != nil {
364 res.Body.Close()
365 }
366 return nil, gensupport.WrapError(&googleapi.Error{
367 Code: res.StatusCode,
368 Header: res.Header,
369 })
370 }
371 if err != nil {
372 return nil, err
373 }
374 defer googleapi.CloseBody(res)
375 if err := googleapi.CheckResponse(res); err != nil {
376 return nil, gensupport.WrapError(err)
377 }
378 rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
379 if rx != nil {
380 rx.Client = c.s.client
381 rx.UserAgent = c.s.userAgent()
382 ctx := c.ctx_
383 if ctx == nil {
384 ctx = context.TODO()
385 }
386 res, err = rx.Upload(ctx)
387 if err != nil {
388 return nil, err
389 }
390 defer res.Body.Close()
391 if err := googleapi.CheckResponse(res); err != nil {
392 return nil, gensupport.WrapError(err)
393 }
394 }
395 ret := &CustomApp{
396 ServerResponse: googleapi.ServerResponse{
397 Header: res.Header,
398 HTTPStatusCode: res.StatusCode,
399 },
400 }
401 target := &ret
402 if err := gensupport.DecodeResponse(target, res); err != nil {
403 return nil, err
404 }
405 return ret, nil
406 }
407
View as plain text