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.
 
 
 

254 line
7.4 KiB

  1. // Package repeated provides access to the Example API.
  2. //
  3. // Usage example:
  4. //
  5. // import "google.golang.org/api/repeated/v1"
  6. // ...
  7. // repeatedService, err := repeated.New(oauthHttpClient)
  8. package repeated // import "google.golang.org/api/repeated/v1"
  9. import (
  10. "bytes"
  11. "encoding/json"
  12. "errors"
  13. "fmt"
  14. context "golang.org/x/net/context"
  15. ctxhttp "golang.org/x/net/context/ctxhttp"
  16. gensupport "google.golang.org/api/gensupport"
  17. googleapi "google.golang.org/api/googleapi"
  18. "io"
  19. "net/http"
  20. "net/url"
  21. "strconv"
  22. "strings"
  23. )
  24. // Always reference these packages, just in case the auto-generated code
  25. // below doesn't.
  26. var _ = bytes.NewBuffer
  27. var _ = strconv.Itoa
  28. var _ = fmt.Sprintf
  29. var _ = json.NewDecoder
  30. var _ = io.Copy
  31. var _ = url.Parse
  32. var _ = gensupport.MarshalJSON
  33. var _ = googleapi.Version
  34. var _ = errors.New
  35. var _ = strings.Replace
  36. var _ = context.Canceled
  37. var _ = ctxhttp.Do
  38. const apiId = "repeated:v1"
  39. const apiName = "repeated"
  40. const apiVersion = "v1"
  41. const basePath = "https://www.googleapis.com/discovery/v1/apis"
  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.Accounts = NewAccountsService(s)
  48. return s, nil
  49. }
  50. type Service struct {
  51. client *http.Client
  52. BasePath string // API endpoint base URL
  53. UserAgent string // optional additional User-Agent fragment
  54. Accounts *AccountsService
  55. }
  56. func (s *Service) userAgent() string {
  57. if s.UserAgent == "" {
  58. return googleapi.UserAgent
  59. }
  60. return googleapi.UserAgent + " " + s.UserAgent
  61. }
  62. func NewAccountsService(s *Service) *AccountsService {
  63. rs := &AccountsService{s: s}
  64. rs.Reports = NewAccountsReportsService(s)
  65. return rs
  66. }
  67. type AccountsService struct {
  68. s *Service
  69. Reports *AccountsReportsService
  70. }
  71. func NewAccountsReportsService(s *Service) *AccountsReportsService {
  72. rs := &AccountsReportsService{s: s}
  73. return rs
  74. }
  75. type AccountsReportsService struct {
  76. s *Service
  77. }
  78. // method id "adsense.accounts.reports.generate":
  79. type AccountsReportsGenerateCall struct {
  80. s *Service
  81. accountId string
  82. urlParams_ gensupport.URLParams
  83. ifNoneMatch_ string
  84. ctx_ context.Context
  85. header_ http.Header
  86. }
  87. // Generate: Generate an AdSense report based on the report request sent
  88. // in the query parameters. Returns the result as JSON; to retrieve
  89. // output in CSV format specify "alt=csv" as a query parameter.
  90. func (r *AccountsReportsService) Generate(ids []int64, currency string, accountId string, dimension []string) *AccountsReportsGenerateCall {
  91. c := &AccountsReportsGenerateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  92. var ids_ []string
  93. for _, v := range ids {
  94. ids_ = append(ids_, fmt.Sprint(v))
  95. }
  96. c.urlParams_.SetMulti("ids", ids_)
  97. c.urlParams_.Set("currency", currency)
  98. c.accountId = accountId
  99. c.urlParams_.SetMulti("dimension", append([]string{}, dimension...))
  100. return c
  101. }
  102. // Currency sets the optional parameter "currency": Optional currency to
  103. // use when reporting on monetary metrics. Defaults to the account's
  104. // currency if not set.
  105. func (c *AccountsReportsGenerateCall) Currency(currency string) *AccountsReportsGenerateCall {
  106. c.urlParams_.Set("currency", currency)
  107. return c
  108. }
  109. // Dimension sets the optional parameter "dimension": Dimensions to base
  110. // the report on.
  111. func (c *AccountsReportsGenerateCall) Dimension(dimension ...string) *AccountsReportsGenerateCall {
  112. c.urlParams_.SetMulti("dimension", append([]string{}, dimension...))
  113. return c
  114. }
  115. // Ids sets the optional parameter "ids": Select only user profiles with
  116. // these IDs.
  117. func (c *AccountsReportsGenerateCall) Ids(ids ...int64) *AccountsReportsGenerateCall {
  118. var ids_ []string
  119. for _, v := range ids {
  120. ids_ = append(ids_, fmt.Sprint(v))
  121. }
  122. c.urlParams_.SetMulti("ids", ids_)
  123. return c
  124. }
  125. // Fields allows partial responses to be retrieved. See
  126. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  127. // for more information.
  128. func (c *AccountsReportsGenerateCall) Fields(s ...googleapi.Field) *AccountsReportsGenerateCall {
  129. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  130. return c
  131. }
  132. // IfNoneMatch sets the optional parameter which makes the operation
  133. // fail if the object's ETag matches the given value. This is useful for
  134. // getting updates only after the object has changed since the last
  135. // request. Use googleapi.IsNotModified to check whether the response
  136. // error from Do is the result of In-None-Match.
  137. func (c *AccountsReportsGenerateCall) IfNoneMatch(entityTag string) *AccountsReportsGenerateCall {
  138. c.ifNoneMatch_ = entityTag
  139. return c
  140. }
  141. // Context sets the context to be used in this call's Do method. Any
  142. // pending HTTP request will be aborted if the provided context is
  143. // canceled.
  144. func (c *AccountsReportsGenerateCall) Context(ctx context.Context) *AccountsReportsGenerateCall {
  145. c.ctx_ = ctx
  146. return c
  147. }
  148. // Header returns an http.Header that can be modified by the caller to
  149. // add HTTP headers to the request.
  150. func (c *AccountsReportsGenerateCall) Header() http.Header {
  151. if c.header_ == nil {
  152. c.header_ = make(http.Header)
  153. }
  154. return c.header_
  155. }
  156. func (c *AccountsReportsGenerateCall) doRequest(alt string) (*http.Response, error) {
  157. reqHeaders := make(http.Header)
  158. for k, v := range c.header_ {
  159. reqHeaders[k] = v
  160. }
  161. reqHeaders.Set("User-Agent", c.s.userAgent())
  162. if c.ifNoneMatch_ != "" {
  163. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  164. }
  165. var body io.Reader = nil
  166. c.urlParams_.Set("alt", alt)
  167. urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{accountId}/reports")
  168. urls += "?" + c.urlParams_.Encode()
  169. req, _ := http.NewRequest("GET", urls, body)
  170. req.Header = reqHeaders
  171. googleapi.Expand(req.URL, map[string]string{
  172. "accountId": c.accountId,
  173. })
  174. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  175. }
  176. // Do executes the "adsense.accounts.reports.generate" call.
  177. func (c *AccountsReportsGenerateCall) Do(opts ...googleapi.CallOption) error {
  178. gensupport.SetOptions(c.urlParams_, opts...)
  179. res, err := c.doRequest("json")
  180. if err != nil {
  181. return err
  182. }
  183. defer googleapi.CloseBody(res)
  184. if err := googleapi.CheckResponse(res); err != nil {
  185. return err
  186. }
  187. return nil
  188. // {
  189. // "description": "Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify \"alt=csv\" as a query parameter.",
  190. // "httpMethod": "GET",
  191. // "id": "adsense.accounts.reports.generate",
  192. // "parameterOrder": [
  193. // "ids",
  194. // "currency",
  195. // "accountId",
  196. // "dimension"
  197. // ],
  198. // "parameters": {
  199. // "accountId": {
  200. // "description": "Account upon which to report.",
  201. // "location": "path",
  202. // "required": true,
  203. // "type": "string"
  204. // },
  205. // "currency": {
  206. // "description": "Optional currency to use when reporting on monetary metrics. Defaults to the account's currency if not set.",
  207. // "location": "query",
  208. // "pattern": "[a-zA-Z]+",
  209. // "type": "string"
  210. // },
  211. // "dimension": {
  212. // "description": "Dimensions to base the report on.",
  213. // "location": "query",
  214. // "pattern": "[a-zA-Z_]+",
  215. // "repeated": true,
  216. // "type": "string"
  217. // },
  218. // "ids": {
  219. // "description": "Select only user profiles with these IDs.",
  220. // "format": "int64",
  221. // "location": "query",
  222. // "repeated": true,
  223. // "type": "string"
  224. // }
  225. // },
  226. // "path": "accounts/{accountId}/reports"
  227. // }
  228. }