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.
 
 
 

503 lines
16 KiB

  1. // Package adexperiencereport provides access to the Ad Experience Report API.
  2. //
  3. // See https://developers.google.com/ad-experience-report/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/adexperiencereport/v1"
  8. // ...
  9. // adexperiencereportService, err := adexperiencereport.New(oauthHttpClient)
  10. package adexperiencereport // import "google.golang.org/api/adexperiencereport/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "adexperiencereport:v1"
  41. const apiName = "adexperiencereport"
  42. const apiVersion = "v1"
  43. const basePath = "https://adexperiencereport.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Test scope for access to the Zoo service
  47. XapiZooScope = "https://www.googleapis.com/auth/xapi.zoo"
  48. )
  49. func New(client *http.Client) (*Service, error) {
  50. if client == nil {
  51. return nil, errors.New("client is nil")
  52. }
  53. s := &Service{client: client, BasePath: basePath}
  54. s.Sites = NewSitesService(s)
  55. s.ViolatingSites = NewViolatingSitesService(s)
  56. return s, nil
  57. }
  58. type Service struct {
  59. client *http.Client
  60. BasePath string // API endpoint base URL
  61. UserAgent string // optional additional User-Agent fragment
  62. Sites *SitesService
  63. ViolatingSites *ViolatingSitesService
  64. }
  65. func (s *Service) userAgent() string {
  66. if s.UserAgent == "" {
  67. return googleapi.UserAgent
  68. }
  69. return googleapi.UserAgent + " " + s.UserAgent
  70. }
  71. func NewSitesService(s *Service) *SitesService {
  72. rs := &SitesService{s: s}
  73. return rs
  74. }
  75. type SitesService struct {
  76. s *Service
  77. }
  78. func NewViolatingSitesService(s *Service) *ViolatingSitesService {
  79. rs := &ViolatingSitesService{s: s}
  80. return rs
  81. }
  82. type ViolatingSitesService struct {
  83. s *Service
  84. }
  85. // PlatformSummary: Summary of the ad experience rating of a site for a
  86. // specific platform.
  87. type PlatformSummary struct {
  88. // BetterAdsStatus: The status of the site reviewed for the Better Ads
  89. // Standards.
  90. //
  91. // Possible values:
  92. // "UNKNOWN" - Not reviewed.
  93. // "PASSING" - Passing.
  94. // "WARNING" - Warning.
  95. // "FAILING" - Failing.
  96. BetterAdsStatus string `json:"betterAdsStatus,omitempty"`
  97. // EnforcementTime: The date on which ad filtering begins.
  98. EnforcementTime string `json:"enforcementTime,omitempty"`
  99. // FilterStatus: The ad filtering status of the site.
  100. //
  101. // Possible values:
  102. // "UNKNOWN" - N/A.
  103. // "ON" - Ad filtering is on.
  104. // "OFF" - Ad filtering is off.
  105. // "PAUSED" - Ad filtering is paused.
  106. // "PENDING" - Ad filtering is pending.
  107. FilterStatus string `json:"filterStatus,omitempty"`
  108. // LastChangeTime: The last time that the site changed status.
  109. LastChangeTime string `json:"lastChangeTime,omitempty"`
  110. // Region: The assigned regions for the site and platform.
  111. //
  112. // Possible values:
  113. // "REGION_UNKNOWN" - Ad standard not yet defined for your region.
  114. // "REGION_A" - Region A.
  115. // "REGION_B" - Region B.
  116. Region []string `json:"region,omitempty"`
  117. // ReportUrl: A link that leads to a full ad experience report.
  118. ReportUrl string `json:"reportUrl,omitempty"`
  119. // UnderReview: Whether the site is currently under review.
  120. UnderReview bool `json:"underReview,omitempty"`
  121. // ForceSendFields is a list of field names (e.g. "BetterAdsStatus") to
  122. // unconditionally include in API requests. By default, fields with
  123. // empty values are omitted from API requests. However, any non-pointer,
  124. // non-interface field appearing in ForceSendFields will be sent to the
  125. // server regardless of whether the field is empty or not. This may be
  126. // used to include empty fields in Patch requests.
  127. ForceSendFields []string `json:"-"`
  128. // NullFields is a list of field names (e.g. "BetterAdsStatus") to
  129. // include in API requests with the JSON null value. By default, fields
  130. // with empty values are omitted from API requests. However, any field
  131. // with an empty value appearing in NullFields will be sent to the
  132. // server as null. It is an error if a field in this list has a
  133. // non-empty value. This may be used to include null fields in Patch
  134. // requests.
  135. NullFields []string `json:"-"`
  136. }
  137. func (s *PlatformSummary) MarshalJSON() ([]byte, error) {
  138. type NoMethod PlatformSummary
  139. raw := NoMethod(*s)
  140. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  141. }
  142. // SiteSummaryResponse: Response message for GetSiteSummary.
  143. // Do not confuse with same message in
  144. // google.chrome.abusiveexperiencereport.v1
  145. type SiteSummaryResponse struct {
  146. // DesktopSummary: Summary for the desktop review of the site.
  147. DesktopSummary *PlatformSummary `json:"desktopSummary,omitempty"`
  148. // MobileSummary: Summary for the mobile review of the site.
  149. MobileSummary *PlatformSummary `json:"mobileSummary,omitempty"`
  150. // ReviewedSite: The name of the site reviewed.
  151. ReviewedSite string `json:"reviewedSite,omitempty"`
  152. // ServerResponse contains the HTTP response code and headers from the
  153. // server.
  154. googleapi.ServerResponse `json:"-"`
  155. // ForceSendFields is a list of field names (e.g. "DesktopSummary") to
  156. // unconditionally include in API requests. By default, fields with
  157. // empty values are omitted from API requests. However, any non-pointer,
  158. // non-interface field appearing in ForceSendFields will be sent to the
  159. // server regardless of whether the field is empty or not. This may be
  160. // used to include empty fields in Patch requests.
  161. ForceSendFields []string `json:"-"`
  162. // NullFields is a list of field names (e.g. "DesktopSummary") to
  163. // include in API requests with the JSON null value. By default, fields
  164. // with empty values are omitted from API requests. However, any field
  165. // with an empty value appearing in NullFields will be sent to the
  166. // server as null. It is an error if a field in this list has a
  167. // non-empty value. This may be used to include null fields in Patch
  168. // requests.
  169. NullFields []string `json:"-"`
  170. }
  171. func (s *SiteSummaryResponse) MarshalJSON() ([]byte, error) {
  172. type NoMethod SiteSummaryResponse
  173. raw := NoMethod(*s)
  174. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  175. }
  176. // ViolatingSitesResponse: Response message for ListViolatingSites.
  177. type ViolatingSitesResponse struct {
  178. // ViolatingSites: A list of summaries of violating sites.
  179. ViolatingSites []*SiteSummaryResponse `json:"violatingSites,omitempty"`
  180. // ServerResponse contains the HTTP response code and headers from the
  181. // server.
  182. googleapi.ServerResponse `json:"-"`
  183. // ForceSendFields is a list of field names (e.g. "ViolatingSites") to
  184. // unconditionally include in API requests. By default, fields with
  185. // empty values are omitted from API requests. However, any non-pointer,
  186. // non-interface field appearing in ForceSendFields will be sent to the
  187. // server regardless of whether the field is empty or not. This may be
  188. // used to include empty fields in Patch requests.
  189. ForceSendFields []string `json:"-"`
  190. // NullFields is a list of field names (e.g. "ViolatingSites") to
  191. // include in API requests with the JSON null value. By default, fields
  192. // with empty values are omitted from API requests. However, any field
  193. // with an empty value appearing in NullFields will be sent to the
  194. // server as null. It is an error if a field in this list has a
  195. // non-empty value. This may be used to include null fields in Patch
  196. // requests.
  197. NullFields []string `json:"-"`
  198. }
  199. func (s *ViolatingSitesResponse) MarshalJSON() ([]byte, error) {
  200. type NoMethod ViolatingSitesResponse
  201. raw := NoMethod(*s)
  202. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  203. }
  204. // method id "adexperiencereport.sites.get":
  205. type SitesGetCall struct {
  206. s *Service
  207. name string
  208. urlParams_ gensupport.URLParams
  209. ifNoneMatch_ string
  210. ctx_ context.Context
  211. header_ http.Header
  212. }
  213. // Get: Gets a summary of the ad experience rating of a site.
  214. func (r *SitesService) Get(name string) *SitesGetCall {
  215. c := &SitesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  216. c.name = name
  217. return c
  218. }
  219. // Fields allows partial responses to be retrieved. See
  220. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  221. // for more information.
  222. func (c *SitesGetCall) Fields(s ...googleapi.Field) *SitesGetCall {
  223. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  224. return c
  225. }
  226. // IfNoneMatch sets the optional parameter which makes the operation
  227. // fail if the object's ETag matches the given value. This is useful for
  228. // getting updates only after the object has changed since the last
  229. // request. Use googleapi.IsNotModified to check whether the response
  230. // error from Do is the result of In-None-Match.
  231. func (c *SitesGetCall) IfNoneMatch(entityTag string) *SitesGetCall {
  232. c.ifNoneMatch_ = entityTag
  233. return c
  234. }
  235. // Context sets the context to be used in this call's Do method. Any
  236. // pending HTTP request will be aborted if the provided context is
  237. // canceled.
  238. func (c *SitesGetCall) Context(ctx context.Context) *SitesGetCall {
  239. c.ctx_ = ctx
  240. return c
  241. }
  242. // Header returns an http.Header that can be modified by the caller to
  243. // add HTTP headers to the request.
  244. func (c *SitesGetCall) Header() http.Header {
  245. if c.header_ == nil {
  246. c.header_ = make(http.Header)
  247. }
  248. return c.header_
  249. }
  250. func (c *SitesGetCall) doRequest(alt string) (*http.Response, error) {
  251. reqHeaders := make(http.Header)
  252. for k, v := range c.header_ {
  253. reqHeaders[k] = v
  254. }
  255. reqHeaders.Set("User-Agent", c.s.userAgent())
  256. if c.ifNoneMatch_ != "" {
  257. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  258. }
  259. var body io.Reader = nil
  260. c.urlParams_.Set("alt", alt)
  261. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  262. urls += "?" + c.urlParams_.Encode()
  263. req, _ := http.NewRequest("GET", urls, body)
  264. req.Header = reqHeaders
  265. googleapi.Expand(req.URL, map[string]string{
  266. "name": c.name,
  267. })
  268. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  269. }
  270. // Do executes the "adexperiencereport.sites.get" call.
  271. // Exactly one of *SiteSummaryResponse or error will be non-nil. Any
  272. // non-2xx status code is an error. Response headers are in either
  273. // *SiteSummaryResponse.ServerResponse.Header or (if a response was
  274. // returned at all) in error.(*googleapi.Error).Header. Use
  275. // googleapi.IsNotModified to check whether the returned error was
  276. // because http.StatusNotModified was returned.
  277. func (c *SitesGetCall) Do(opts ...googleapi.CallOption) (*SiteSummaryResponse, error) {
  278. gensupport.SetOptions(c.urlParams_, opts...)
  279. res, err := c.doRequest("json")
  280. if res != nil && res.StatusCode == http.StatusNotModified {
  281. if res.Body != nil {
  282. res.Body.Close()
  283. }
  284. return nil, &googleapi.Error{
  285. Code: res.StatusCode,
  286. Header: res.Header,
  287. }
  288. }
  289. if err != nil {
  290. return nil, err
  291. }
  292. defer googleapi.CloseBody(res)
  293. if err := googleapi.CheckResponse(res); err != nil {
  294. return nil, err
  295. }
  296. ret := &SiteSummaryResponse{
  297. ServerResponse: googleapi.ServerResponse{
  298. Header: res.Header,
  299. HTTPStatusCode: res.StatusCode,
  300. },
  301. }
  302. target := &ret
  303. if err := gensupport.DecodeResponse(target, res); err != nil {
  304. return nil, err
  305. }
  306. return ret, nil
  307. // {
  308. // "description": "Gets a summary of the ad experience rating of a site.",
  309. // "flatPath": "v1/sites/{sitesId}",
  310. // "httpMethod": "GET",
  311. // "id": "adexperiencereport.sites.get",
  312. // "parameterOrder": [
  313. // "name"
  314. // ],
  315. // "parameters": {
  316. // "name": {
  317. // "description": "The required site name. It should be the site property whose ad experiences\nmay have been reviewed, and it should be URL-encoded. For example,\nsites/https%3A%2F%2Fwww.google.com. The server will return an error of\nBAD_REQUEST if this field is not filled in. Note that if the site property\nis not yet verified in Search Console, the reportUrl field returned by the\nAPI will lead to the verification page, prompting the user to go through\nthat process before they can gain access to the Ad Experience Report.",
  318. // "location": "path",
  319. // "pattern": "^sites/[^/]+$",
  320. // "required": true,
  321. // "type": "string"
  322. // }
  323. // },
  324. // "path": "v1/{+name}",
  325. // "response": {
  326. // "$ref": "SiteSummaryResponse"
  327. // },
  328. // "scopes": [
  329. // "https://www.googleapis.com/auth/xapi.zoo"
  330. // ]
  331. // }
  332. }
  333. // method id "adexperiencereport.violatingSites.list":
  334. type ViolatingSitesListCall struct {
  335. s *Service
  336. urlParams_ gensupport.URLParams
  337. ifNoneMatch_ string
  338. ctx_ context.Context
  339. header_ http.Header
  340. }
  341. // List: Lists sites with Ad Experience Report statuses of "Failing" or
  342. // "Warning".
  343. func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
  344. c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  345. return c
  346. }
  347. // Fields allows partial responses to be retrieved. See
  348. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  349. // for more information.
  350. func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
  351. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  352. return c
  353. }
  354. // IfNoneMatch sets the optional parameter which makes the operation
  355. // fail if the object's ETag matches the given value. This is useful for
  356. // getting updates only after the object has changed since the last
  357. // request. Use googleapi.IsNotModified to check whether the response
  358. // error from Do is the result of In-None-Match.
  359. func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
  360. c.ifNoneMatch_ = entityTag
  361. return c
  362. }
  363. // Context sets the context to be used in this call's Do method. Any
  364. // pending HTTP request will be aborted if the provided context is
  365. // canceled.
  366. func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
  367. c.ctx_ = ctx
  368. return c
  369. }
  370. // Header returns an http.Header that can be modified by the caller to
  371. // add HTTP headers to the request.
  372. func (c *ViolatingSitesListCall) Header() http.Header {
  373. if c.header_ == nil {
  374. c.header_ = make(http.Header)
  375. }
  376. return c.header_
  377. }
  378. func (c *ViolatingSitesListCall) doRequest(alt string) (*http.Response, error) {
  379. reqHeaders := make(http.Header)
  380. for k, v := range c.header_ {
  381. reqHeaders[k] = v
  382. }
  383. reqHeaders.Set("User-Agent", c.s.userAgent())
  384. if c.ifNoneMatch_ != "" {
  385. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  386. }
  387. var body io.Reader = nil
  388. c.urlParams_.Set("alt", alt)
  389. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/violatingSites")
  390. urls += "?" + c.urlParams_.Encode()
  391. req, _ := http.NewRequest("GET", urls, body)
  392. req.Header = reqHeaders
  393. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  394. }
  395. // Do executes the "adexperiencereport.violatingSites.list" call.
  396. // Exactly one of *ViolatingSitesResponse or error will be non-nil. Any
  397. // non-2xx status code is an error. Response headers are in either
  398. // *ViolatingSitesResponse.ServerResponse.Header or (if a response was
  399. // returned at all) in error.(*googleapi.Error).Header. Use
  400. // googleapi.IsNotModified to check whether the returned error was
  401. // because http.StatusNotModified was returned.
  402. func (c *ViolatingSitesListCall) Do(opts ...googleapi.CallOption) (*ViolatingSitesResponse, error) {
  403. gensupport.SetOptions(c.urlParams_, opts...)
  404. res, err := c.doRequest("json")
  405. if res != nil && res.StatusCode == http.StatusNotModified {
  406. if res.Body != nil {
  407. res.Body.Close()
  408. }
  409. return nil, &googleapi.Error{
  410. Code: res.StatusCode,
  411. Header: res.Header,
  412. }
  413. }
  414. if err != nil {
  415. return nil, err
  416. }
  417. defer googleapi.CloseBody(res)
  418. if err := googleapi.CheckResponse(res); err != nil {
  419. return nil, err
  420. }
  421. ret := &ViolatingSitesResponse{
  422. ServerResponse: googleapi.ServerResponse{
  423. Header: res.Header,
  424. HTTPStatusCode: res.StatusCode,
  425. },
  426. }
  427. target := &ret
  428. if err := gensupport.DecodeResponse(target, res); err != nil {
  429. return nil, err
  430. }
  431. return ret, nil
  432. // {
  433. // "description": "Lists sites with Ad Experience Report statuses of \"Failing\" or \"Warning\".",
  434. // "flatPath": "v1/violatingSites",
  435. // "httpMethod": "GET",
  436. // "id": "adexperiencereport.violatingSites.list",
  437. // "parameterOrder": [],
  438. // "parameters": {},
  439. // "path": "v1/violatingSites",
  440. // "response": {
  441. // "$ref": "ViolatingSitesResponse"
  442. // },
  443. // "scopes": [
  444. // "https://www.googleapis.com/auth/xapi.zoo"
  445. // ]
  446. // }
  447. }