You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

411 lines
13 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package playcustomapp provides access to the Google Play Custom App Publishing API.
  6. //
  7. // For product documentation, see: https://developers.google.com/android/work/play/custom-app-api
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/playcustomapp/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // playcustomappService, err := playcustomapp.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  25. //
  26. // playcustomappService, err := playcustomapp.NewService(ctx, option.WithAPIKey("AIza..."))
  27. //
  28. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  29. //
  30. // config := &oauth2.Config{...}
  31. // // ...
  32. // token, err := config.Exchange(ctx, ...)
  33. // playcustomappService, err := playcustomapp.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  34. //
  35. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  36. package playcustomapp // import "google.golang.org/api/playcustomapp/v1"
  37. import (
  38. "bytes"
  39. "context"
  40. "encoding/json"
  41. "errors"
  42. "fmt"
  43. "io"
  44. "net/http"
  45. "net/url"
  46. "strconv"
  47. "strings"
  48. gensupport "google.golang.org/api/gensupport"
  49. googleapi "google.golang.org/api/googleapi"
  50. option "google.golang.org/api/option"
  51. htransport "google.golang.org/api/transport/http"
  52. )
  53. // Always reference these packages, just in case the auto-generated code
  54. // below doesn't.
  55. var _ = bytes.NewBuffer
  56. var _ = strconv.Itoa
  57. var _ = fmt.Sprintf
  58. var _ = json.NewDecoder
  59. var _ = io.Copy
  60. var _ = url.Parse
  61. var _ = gensupport.MarshalJSON
  62. var _ = googleapi.Version
  63. var _ = errors.New
  64. var _ = strings.Replace
  65. var _ = context.Canceled
  66. const apiId = "playcustomapp:v1"
  67. const apiName = "playcustomapp"
  68. const apiVersion = "v1"
  69. const basePath = "https://www.googleapis.com/playcustomapp/v1/accounts/"
  70. // OAuth2 scopes used by this API.
  71. const (
  72. // View and manage your Google Play Developer account
  73. AndroidpublisherScope = "https://www.googleapis.com/auth/androidpublisher"
  74. )
  75. // NewService creates a new Service.
  76. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  77. scopesOption := option.WithScopes(
  78. "https://www.googleapis.com/auth/androidpublisher",
  79. )
  80. // NOTE: prepend, so we don't override user-specified scopes.
  81. opts = append([]option.ClientOption{scopesOption}, opts...)
  82. client, endpoint, err := htransport.NewClient(ctx, opts...)
  83. if err != nil {
  84. return nil, err
  85. }
  86. s, err := New(client)
  87. if err != nil {
  88. return nil, err
  89. }
  90. if endpoint != "" {
  91. s.BasePath = endpoint
  92. }
  93. return s, nil
  94. }
  95. // New creates a new Service. It uses the provided http.Client for requests.
  96. //
  97. // Deprecated: please use NewService instead.
  98. // To provide a custom HTTP client, use option.WithHTTPClient.
  99. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  100. func New(client *http.Client) (*Service, error) {
  101. if client == nil {
  102. return nil, errors.New("client is nil")
  103. }
  104. s := &Service{client: client, BasePath: basePath}
  105. s.Accounts = NewAccountsService(s)
  106. return s, nil
  107. }
  108. type Service struct {
  109. client *http.Client
  110. BasePath string // API endpoint base URL
  111. UserAgent string // optional additional User-Agent fragment
  112. Accounts *AccountsService
  113. }
  114. func (s *Service) userAgent() string {
  115. if s.UserAgent == "" {
  116. return googleapi.UserAgent
  117. }
  118. return googleapi.UserAgent + " " + s.UserAgent
  119. }
  120. func NewAccountsService(s *Service) *AccountsService {
  121. rs := &AccountsService{s: s}
  122. rs.CustomApps = NewAccountsCustomAppsService(s)
  123. return rs
  124. }
  125. type AccountsService struct {
  126. s *Service
  127. CustomApps *AccountsCustomAppsService
  128. }
  129. func NewAccountsCustomAppsService(s *Service) *AccountsCustomAppsService {
  130. rs := &AccountsCustomAppsService{s: s}
  131. return rs
  132. }
  133. type AccountsCustomAppsService struct {
  134. s *Service
  135. }
  136. // CustomApp: This resource represents a custom app.
  137. type CustomApp struct {
  138. // LanguageCode: Default listing language in BCP 47 format.
  139. LanguageCode string `json:"languageCode,omitempty"`
  140. // Title: Title for the Android app.
  141. Title string `json:"title,omitempty"`
  142. // ServerResponse contains the HTTP response code and headers from the
  143. // server.
  144. googleapi.ServerResponse `json:"-"`
  145. // ForceSendFields is a list of field names (e.g. "LanguageCode") to
  146. // unconditionally include in API requests. By default, fields with
  147. // empty values are omitted from API requests. However, any non-pointer,
  148. // non-interface field appearing in ForceSendFields will be sent to the
  149. // server regardless of whether the field is empty or not. This may be
  150. // used to include empty fields in Patch requests.
  151. ForceSendFields []string `json:"-"`
  152. // NullFields is a list of field names (e.g. "LanguageCode") to include
  153. // in API requests with the JSON null value. By default, fields with
  154. // empty values are omitted from API requests. However, any field with
  155. // an empty value appearing in NullFields will be sent to the server as
  156. // null. It is an error if a field in this list has a non-empty value.
  157. // This may be used to include null fields in Patch requests.
  158. NullFields []string `json:"-"`
  159. }
  160. func (s *CustomApp) MarshalJSON() ([]byte, error) {
  161. type NoMethod CustomApp
  162. raw := NoMethod(*s)
  163. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  164. }
  165. // method id "playcustomapp.accounts.customApps.create":
  166. type AccountsCustomAppsCreateCall struct {
  167. s *Service
  168. account int64
  169. customapp *CustomApp
  170. urlParams_ gensupport.URLParams
  171. mediaInfo_ *gensupport.MediaInfo
  172. ctx_ context.Context
  173. header_ http.Header
  174. }
  175. // Create: Create and publish a new custom app.
  176. func (r *AccountsCustomAppsService) Create(account int64, customapp *CustomApp) *AccountsCustomAppsCreateCall {
  177. c := &AccountsCustomAppsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  178. c.account = account
  179. c.customapp = customapp
  180. return c
  181. }
  182. // Media specifies the media to upload in one or more chunks. The chunk
  183. // size may be controlled by supplying a MediaOption generated by
  184. // googleapi.ChunkSize. The chunk size defaults to
  185. // googleapi.DefaultUploadChunkSize.The Content-Type header used in the
  186. // upload request will be determined by sniffing the contents of r,
  187. // unless a MediaOption generated by googleapi.ContentType is
  188. // supplied.
  189. // At most one of Media and ResumableMedia may be set.
  190. func (c *AccountsCustomAppsCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *AccountsCustomAppsCreateCall {
  191. c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options)
  192. return c
  193. }
  194. // ResumableMedia specifies the media to upload in chunks and can be
  195. // canceled with ctx.
  196. //
  197. // Deprecated: use Media instead.
  198. //
  199. // At most one of Media and ResumableMedia may be set. mediaType
  200. // identifies the MIME media type of the upload, such as "image/png". If
  201. // mediaType is "", it will be auto-detected. The provided ctx will
  202. // supersede any context previously provided to the Context method.
  203. func (c *AccountsCustomAppsCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *AccountsCustomAppsCreateCall {
  204. c.ctx_ = ctx
  205. c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType)
  206. return c
  207. }
  208. // ProgressUpdater provides a callback function that will be called
  209. // after every chunk. It should be a low-latency function in order to
  210. // not slow down the upload operation. This should only be called when
  211. // using ResumableMedia (as opposed to Media).
  212. func (c *AccountsCustomAppsCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *AccountsCustomAppsCreateCall {
  213. c.mediaInfo_.SetProgressUpdater(pu)
  214. return c
  215. }
  216. // Fields allows partial responses to be retrieved. See
  217. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  218. // for more information.
  219. func (c *AccountsCustomAppsCreateCall) Fields(s ...googleapi.Field) *AccountsCustomAppsCreateCall {
  220. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  221. return c
  222. }
  223. // Context sets the context to be used in this call's Do method. Any
  224. // pending HTTP request will be aborted if the provided context is
  225. // canceled.
  226. // This context will supersede any context previously provided to the
  227. // ResumableMedia method.
  228. func (c *AccountsCustomAppsCreateCall) Context(ctx context.Context) *AccountsCustomAppsCreateCall {
  229. c.ctx_ = ctx
  230. return c
  231. }
  232. // Header returns an http.Header that can be modified by the caller to
  233. // add HTTP headers to the request.
  234. func (c *AccountsCustomAppsCreateCall) Header() http.Header {
  235. if c.header_ == nil {
  236. c.header_ = make(http.Header)
  237. }
  238. return c.header_
  239. }
  240. func (c *AccountsCustomAppsCreateCall) doRequest(alt string) (*http.Response, error) {
  241. reqHeaders := make(http.Header)
  242. for k, v := range c.header_ {
  243. reqHeaders[k] = v
  244. }
  245. reqHeaders.Set("User-Agent", c.s.userAgent())
  246. var body io.Reader = nil
  247. body, err := googleapi.WithoutDataWrapper.JSONReader(c.customapp)
  248. if err != nil {
  249. return nil, err
  250. }
  251. reqHeaders.Set("Content-Type", "application/json")
  252. c.urlParams_.Set("alt", alt)
  253. c.urlParams_.Set("prettyPrint", "false")
  254. urls := googleapi.ResolveRelative(c.s.BasePath, "{account}/customApps")
  255. if c.mediaInfo_ != nil {
  256. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  257. c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType())
  258. }
  259. if body == nil {
  260. body = new(bytes.Buffer)
  261. reqHeaders.Set("Content-Type", "application/json")
  262. }
  263. body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body)
  264. defer cleanup()
  265. urls += "?" + c.urlParams_.Encode()
  266. req, err := http.NewRequest("POST", urls, body)
  267. if err != nil {
  268. return nil, err
  269. }
  270. req.Header = reqHeaders
  271. req.GetBody = getBody
  272. googleapi.Expand(req.URL, map[string]string{
  273. "account": strconv.FormatInt(c.account, 10),
  274. })
  275. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  276. }
  277. // Do executes the "playcustomapp.accounts.customApps.create" call.
  278. // Exactly one of *CustomApp or error will be non-nil. Any non-2xx
  279. // status code is an error. Response headers are in either
  280. // *CustomApp.ServerResponse.Header or (if a response was returned at
  281. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  282. // to check whether the returned error was because
  283. // http.StatusNotModified was returned.
  284. func (c *AccountsCustomAppsCreateCall) Do(opts ...googleapi.CallOption) (*CustomApp, error) {
  285. gensupport.SetOptions(c.urlParams_, opts...)
  286. res, err := c.doRequest("json")
  287. if res != nil && res.StatusCode == http.StatusNotModified {
  288. if res.Body != nil {
  289. res.Body.Close()
  290. }
  291. return nil, &googleapi.Error{
  292. Code: res.StatusCode,
  293. Header: res.Header,
  294. }
  295. }
  296. if err != nil {
  297. return nil, err
  298. }
  299. defer googleapi.CloseBody(res)
  300. if err := googleapi.CheckResponse(res); err != nil {
  301. return nil, err
  302. }
  303. rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location"))
  304. if rx != nil {
  305. rx.Client = c.s.client
  306. rx.UserAgent = c.s.userAgent()
  307. ctx := c.ctx_
  308. if ctx == nil {
  309. ctx = context.TODO()
  310. }
  311. res, err = rx.Upload(ctx)
  312. if err != nil {
  313. return nil, err
  314. }
  315. defer res.Body.Close()
  316. if err := googleapi.CheckResponse(res); err != nil {
  317. return nil, err
  318. }
  319. }
  320. ret := &CustomApp{
  321. ServerResponse: googleapi.ServerResponse{
  322. Header: res.Header,
  323. HTTPStatusCode: res.StatusCode,
  324. },
  325. }
  326. target := &ret
  327. if err := gensupport.DecodeResponse(target, res); err != nil {
  328. return nil, err
  329. }
  330. return ret, nil
  331. // {
  332. // "description": "Create and publish a new custom app.",
  333. // "httpMethod": "POST",
  334. // "id": "playcustomapp.accounts.customApps.create",
  335. // "mediaUpload": {
  336. // "accept": [
  337. // "*/*"
  338. // ],
  339. // "maxSize": "100MB",
  340. // "protocols": {
  341. // "resumable": {
  342. // "multipart": true,
  343. // "path": "/resumable/upload/playcustomapp/v1/accounts/{account}/customApps"
  344. // },
  345. // "simple": {
  346. // "multipart": true,
  347. // "path": "/upload/playcustomapp/v1/accounts/{account}/customApps"
  348. // }
  349. // }
  350. // },
  351. // "parameterOrder": [
  352. // "account"
  353. // ],
  354. // "parameters": {
  355. // "account": {
  356. // "description": "Developer account ID.",
  357. // "format": "int64",
  358. // "location": "path",
  359. // "required": true,
  360. // "type": "string"
  361. // }
  362. // },
  363. // "path": "{account}/customApps",
  364. // "request": {
  365. // "$ref": "CustomApp"
  366. // },
  367. // "response": {
  368. // "$ref": "CustomApp"
  369. // },
  370. // "scopes": [
  371. // "https://www.googleapis.com/auth/androidpublisher"
  372. // ],
  373. // "supportsMediaUpload": true
  374. // }
  375. }