Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

565 righe
18 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 adexperiencereport provides access to the Ad Experience Report API.
  6. //
  7. // For product documentation, see: https://developers.google.com/ad-experience-report/
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/adexperiencereport/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // adexperiencereportService, err := adexperiencereport.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. // adexperiencereportService, err := adexperiencereport.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. // adexperiencereportService, err := adexperiencereport.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 adexperiencereport // import "google.golang.org/api/adexperiencereport/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 = "adexperiencereport:v1"
  67. const apiName = "adexperiencereport"
  68. const apiVersion = "v1"
  69. const basePath = "https://adexperiencereport.googleapis.com/"
  70. // OAuth2 scopes used by this API.
  71. const (
  72. // Test scope for access to the Zoo service
  73. XapiZooScope = "https://www.googleapis.com/auth/xapi.zoo"
  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/xapi.zoo",
  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.Sites = NewSitesService(s)
  106. s.ViolatingSites = NewViolatingSitesService(s)
  107. return s, nil
  108. }
  109. type Service struct {
  110. client *http.Client
  111. BasePath string // API endpoint base URL
  112. UserAgent string // optional additional User-Agent fragment
  113. Sites *SitesService
  114. ViolatingSites *ViolatingSitesService
  115. }
  116. func (s *Service) userAgent() string {
  117. if s.UserAgent == "" {
  118. return googleapi.UserAgent
  119. }
  120. return googleapi.UserAgent + " " + s.UserAgent
  121. }
  122. func NewSitesService(s *Service) *SitesService {
  123. rs := &SitesService{s: s}
  124. return rs
  125. }
  126. type SitesService struct {
  127. s *Service
  128. }
  129. func NewViolatingSitesService(s *Service) *ViolatingSitesService {
  130. rs := &ViolatingSitesService{s: s}
  131. return rs
  132. }
  133. type ViolatingSitesService struct {
  134. s *Service
  135. }
  136. // PlatformSummary: Summary of the ad experience rating of a site for a
  137. // specific platform.
  138. type PlatformSummary struct {
  139. // BetterAdsStatus: The status of the site reviewed for the Better Ads
  140. // Standards.
  141. //
  142. // Possible values:
  143. // "UNKNOWN" - Not reviewed.
  144. // "PASSING" - Passing.
  145. // "WARNING" - Warning.
  146. // "FAILING" - Failing.
  147. BetterAdsStatus string `json:"betterAdsStatus,omitempty"`
  148. // EnforcementTime: The date on which ad filtering begins.
  149. EnforcementTime string `json:"enforcementTime,omitempty"`
  150. // FilterStatus: The ad filtering status of the site.
  151. //
  152. // Possible values:
  153. // "UNKNOWN" - N/A.
  154. // "ON" - Ad filtering is on.
  155. // "OFF" - Ad filtering is off.
  156. // "PAUSED" - Ad filtering is paused.
  157. // "PENDING" - Ad filtering is pending.
  158. FilterStatus string `json:"filterStatus,omitempty"`
  159. // LastChangeTime: The last time that the site changed status.
  160. LastChangeTime string `json:"lastChangeTime,omitempty"`
  161. // Region: The assigned regions for the site and platform.
  162. //
  163. // Possible values:
  164. // "REGION_UNKNOWN" - Ad standard not yet defined for your region.
  165. // "REGION_A" - Region A.
  166. // "REGION_B" - Region B.
  167. // "REGION_C" - Region C.
  168. Region []string `json:"region,omitempty"`
  169. // ReportUrl: A link that leads to a full ad experience report.
  170. ReportUrl string `json:"reportUrl,omitempty"`
  171. // UnderReview: Whether the site is currently under review.
  172. UnderReview bool `json:"underReview,omitempty"`
  173. // ForceSendFields is a list of field names (e.g. "BetterAdsStatus") to
  174. // unconditionally include in API requests. By default, fields with
  175. // empty values are omitted from API requests. However, any non-pointer,
  176. // non-interface field appearing in ForceSendFields will be sent to the
  177. // server regardless of whether the field is empty or not. This may be
  178. // used to include empty fields in Patch requests.
  179. ForceSendFields []string `json:"-"`
  180. // NullFields is a list of field names (e.g. "BetterAdsStatus") to
  181. // include in API requests with the JSON null value. By default, fields
  182. // with empty values are omitted from API requests. However, any field
  183. // with an empty value appearing in NullFields will be sent to the
  184. // server as null. It is an error if a field in this list has a
  185. // non-empty value. This may be used to include null fields in Patch
  186. // requests.
  187. NullFields []string `json:"-"`
  188. }
  189. func (s *PlatformSummary) MarshalJSON() ([]byte, error) {
  190. type NoMethod PlatformSummary
  191. raw := NoMethod(*s)
  192. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  193. }
  194. // SiteSummaryResponse: Response message for GetSiteSummary.
  195. type SiteSummaryResponse struct {
  196. // DesktopSummary: Summary for the desktop review of the site.
  197. DesktopSummary *PlatformSummary `json:"desktopSummary,omitempty"`
  198. // MobileSummary: Summary for the mobile review of the site.
  199. MobileSummary *PlatformSummary `json:"mobileSummary,omitempty"`
  200. // ReviewedSite: The name of the site reviewed.
  201. ReviewedSite string `json:"reviewedSite,omitempty"`
  202. // ServerResponse contains the HTTP response code and headers from the
  203. // server.
  204. googleapi.ServerResponse `json:"-"`
  205. // ForceSendFields is a list of field names (e.g. "DesktopSummary") to
  206. // unconditionally include in API requests. By default, fields with
  207. // empty values are omitted from API requests. However, any non-pointer,
  208. // non-interface field appearing in ForceSendFields will be sent to the
  209. // server regardless of whether the field is empty or not. This may be
  210. // used to include empty fields in Patch requests.
  211. ForceSendFields []string `json:"-"`
  212. // NullFields is a list of field names (e.g. "DesktopSummary") to
  213. // include in API requests with the JSON null value. By default, fields
  214. // with empty values are omitted from API requests. However, any field
  215. // with an empty value appearing in NullFields will be sent to the
  216. // server as null. It is an error if a field in this list has a
  217. // non-empty value. This may be used to include null fields in Patch
  218. // requests.
  219. NullFields []string `json:"-"`
  220. }
  221. func (s *SiteSummaryResponse) MarshalJSON() ([]byte, error) {
  222. type NoMethod SiteSummaryResponse
  223. raw := NoMethod(*s)
  224. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  225. }
  226. // ViolatingSitesResponse: Response message for ListViolatingSites.
  227. type ViolatingSitesResponse struct {
  228. // ViolatingSites: A list of summaries of violating sites.
  229. ViolatingSites []*SiteSummaryResponse `json:"violatingSites,omitempty"`
  230. // ServerResponse contains the HTTP response code and headers from the
  231. // server.
  232. googleapi.ServerResponse `json:"-"`
  233. // ForceSendFields is a list of field names (e.g. "ViolatingSites") to
  234. // unconditionally include in API requests. By default, fields with
  235. // empty values are omitted from API requests. However, any non-pointer,
  236. // non-interface field appearing in ForceSendFields will be sent to the
  237. // server regardless of whether the field is empty or not. This may be
  238. // used to include empty fields in Patch requests.
  239. ForceSendFields []string `json:"-"`
  240. // NullFields is a list of field names (e.g. "ViolatingSites") to
  241. // include in API requests with the JSON null value. By default, fields
  242. // with empty values are omitted from API requests. However, any field
  243. // with an empty value appearing in NullFields will be sent to the
  244. // server as null. It is an error if a field in this list has a
  245. // non-empty value. This may be used to include null fields in Patch
  246. // requests.
  247. NullFields []string `json:"-"`
  248. }
  249. func (s *ViolatingSitesResponse) MarshalJSON() ([]byte, error) {
  250. type NoMethod ViolatingSitesResponse
  251. raw := NoMethod(*s)
  252. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  253. }
  254. // method id "adexperiencereport.sites.get":
  255. type SitesGetCall struct {
  256. s *Service
  257. name string
  258. urlParams_ gensupport.URLParams
  259. ifNoneMatch_ string
  260. ctx_ context.Context
  261. header_ http.Header
  262. }
  263. // Get: Gets a summary of the ad experience rating of a site.
  264. func (r *SitesService) Get(name string) *SitesGetCall {
  265. c := &SitesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  266. c.name = name
  267. return c
  268. }
  269. // Fields allows partial responses to be retrieved. See
  270. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  271. // for more information.
  272. func (c *SitesGetCall) Fields(s ...googleapi.Field) *SitesGetCall {
  273. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  274. return c
  275. }
  276. // IfNoneMatch sets the optional parameter which makes the operation
  277. // fail if the object's ETag matches the given value. This is useful for
  278. // getting updates only after the object has changed since the last
  279. // request. Use googleapi.IsNotModified to check whether the response
  280. // error from Do is the result of In-None-Match.
  281. func (c *SitesGetCall) IfNoneMatch(entityTag string) *SitesGetCall {
  282. c.ifNoneMatch_ = entityTag
  283. return c
  284. }
  285. // Context sets the context to be used in this call's Do method. Any
  286. // pending HTTP request will be aborted if the provided context is
  287. // canceled.
  288. func (c *SitesGetCall) Context(ctx context.Context) *SitesGetCall {
  289. c.ctx_ = ctx
  290. return c
  291. }
  292. // Header returns an http.Header that can be modified by the caller to
  293. // add HTTP headers to the request.
  294. func (c *SitesGetCall) Header() http.Header {
  295. if c.header_ == nil {
  296. c.header_ = make(http.Header)
  297. }
  298. return c.header_
  299. }
  300. func (c *SitesGetCall) doRequest(alt string) (*http.Response, error) {
  301. reqHeaders := make(http.Header)
  302. for k, v := range c.header_ {
  303. reqHeaders[k] = v
  304. }
  305. reqHeaders.Set("User-Agent", c.s.userAgent())
  306. if c.ifNoneMatch_ != "" {
  307. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  308. }
  309. var body io.Reader = nil
  310. c.urlParams_.Set("alt", alt)
  311. c.urlParams_.Set("prettyPrint", "false")
  312. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  313. urls += "?" + c.urlParams_.Encode()
  314. req, err := http.NewRequest("GET", urls, body)
  315. if err != nil {
  316. return nil, err
  317. }
  318. req.Header = reqHeaders
  319. googleapi.Expand(req.URL, map[string]string{
  320. "name": c.name,
  321. })
  322. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  323. }
  324. // Do executes the "adexperiencereport.sites.get" call.
  325. // Exactly one of *SiteSummaryResponse or error will be non-nil. Any
  326. // non-2xx status code is an error. Response headers are in either
  327. // *SiteSummaryResponse.ServerResponse.Header or (if a response was
  328. // returned at all) in error.(*googleapi.Error).Header. Use
  329. // googleapi.IsNotModified to check whether the returned error was
  330. // because http.StatusNotModified was returned.
  331. func (c *SitesGetCall) Do(opts ...googleapi.CallOption) (*SiteSummaryResponse, error) {
  332. gensupport.SetOptions(c.urlParams_, opts...)
  333. res, err := c.doRequest("json")
  334. if res != nil && res.StatusCode == http.StatusNotModified {
  335. if res.Body != nil {
  336. res.Body.Close()
  337. }
  338. return nil, &googleapi.Error{
  339. Code: res.StatusCode,
  340. Header: res.Header,
  341. }
  342. }
  343. if err != nil {
  344. return nil, err
  345. }
  346. defer googleapi.CloseBody(res)
  347. if err := googleapi.CheckResponse(res); err != nil {
  348. return nil, err
  349. }
  350. ret := &SiteSummaryResponse{
  351. ServerResponse: googleapi.ServerResponse{
  352. Header: res.Header,
  353. HTTPStatusCode: res.StatusCode,
  354. },
  355. }
  356. target := &ret
  357. if err := gensupport.DecodeResponse(target, res); err != nil {
  358. return nil, err
  359. }
  360. return ret, nil
  361. // {
  362. // "description": "Gets a summary of the ad experience rating of a site.",
  363. // "flatPath": "v1/sites/{sitesId}",
  364. // "httpMethod": "GET",
  365. // "id": "adexperiencereport.sites.get",
  366. // "parameterOrder": [
  367. // "name"
  368. // ],
  369. // "parameters": {
  370. // "name": {
  371. // "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.",
  372. // "location": "path",
  373. // "pattern": "^sites/[^/]+$",
  374. // "required": true,
  375. // "type": "string"
  376. // }
  377. // },
  378. // "path": "v1/{+name}",
  379. // "response": {
  380. // "$ref": "SiteSummaryResponse"
  381. // },
  382. // "scopes": [
  383. // "https://www.googleapis.com/auth/xapi.zoo"
  384. // ]
  385. // }
  386. }
  387. // method id "adexperiencereport.violatingSites.list":
  388. type ViolatingSitesListCall struct {
  389. s *Service
  390. urlParams_ gensupport.URLParams
  391. ifNoneMatch_ string
  392. ctx_ context.Context
  393. header_ http.Header
  394. }
  395. // List: Lists sites with Ad Experience Report statuses of "Failing" or
  396. // "Warning".
  397. func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
  398. c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  399. return c
  400. }
  401. // Fields allows partial responses to be retrieved. See
  402. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  403. // for more information.
  404. func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
  405. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  406. return c
  407. }
  408. // IfNoneMatch sets the optional parameter which makes the operation
  409. // fail if the object's ETag matches the given value. This is useful for
  410. // getting updates only after the object has changed since the last
  411. // request. Use googleapi.IsNotModified to check whether the response
  412. // error from Do is the result of In-None-Match.
  413. func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
  414. c.ifNoneMatch_ = entityTag
  415. return c
  416. }
  417. // Context sets the context to be used in this call's Do method. Any
  418. // pending HTTP request will be aborted if the provided context is
  419. // canceled.
  420. func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
  421. c.ctx_ = ctx
  422. return c
  423. }
  424. // Header returns an http.Header that can be modified by the caller to
  425. // add HTTP headers to the request.
  426. func (c *ViolatingSitesListCall) Header() http.Header {
  427. if c.header_ == nil {
  428. c.header_ = make(http.Header)
  429. }
  430. return c.header_
  431. }
  432. func (c *ViolatingSitesListCall) doRequest(alt string) (*http.Response, error) {
  433. reqHeaders := make(http.Header)
  434. for k, v := range c.header_ {
  435. reqHeaders[k] = v
  436. }
  437. reqHeaders.Set("User-Agent", c.s.userAgent())
  438. if c.ifNoneMatch_ != "" {
  439. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  440. }
  441. var body io.Reader = nil
  442. c.urlParams_.Set("alt", alt)
  443. c.urlParams_.Set("prettyPrint", "false")
  444. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/violatingSites")
  445. urls += "?" + c.urlParams_.Encode()
  446. req, err := http.NewRequest("GET", urls, body)
  447. if err != nil {
  448. return nil, err
  449. }
  450. req.Header = reqHeaders
  451. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  452. }
  453. // Do executes the "adexperiencereport.violatingSites.list" call.
  454. // Exactly one of *ViolatingSitesResponse or error will be non-nil. Any
  455. // non-2xx status code is an error. Response headers are in either
  456. // *ViolatingSitesResponse.ServerResponse.Header or (if a response was
  457. // returned at all) in error.(*googleapi.Error).Header. Use
  458. // googleapi.IsNotModified to check whether the returned error was
  459. // because http.StatusNotModified was returned.
  460. func (c *ViolatingSitesListCall) Do(opts ...googleapi.CallOption) (*ViolatingSitesResponse, error) {
  461. gensupport.SetOptions(c.urlParams_, opts...)
  462. res, err := c.doRequest("json")
  463. if res != nil && res.StatusCode == http.StatusNotModified {
  464. if res.Body != nil {
  465. res.Body.Close()
  466. }
  467. return nil, &googleapi.Error{
  468. Code: res.StatusCode,
  469. Header: res.Header,
  470. }
  471. }
  472. if err != nil {
  473. return nil, err
  474. }
  475. defer googleapi.CloseBody(res)
  476. if err := googleapi.CheckResponse(res); err != nil {
  477. return nil, err
  478. }
  479. ret := &ViolatingSitesResponse{
  480. ServerResponse: googleapi.ServerResponse{
  481. Header: res.Header,
  482. HTTPStatusCode: res.StatusCode,
  483. },
  484. }
  485. target := &ret
  486. if err := gensupport.DecodeResponse(target, res); err != nil {
  487. return nil, err
  488. }
  489. return ret, nil
  490. // {
  491. // "description": "Lists sites with Ad Experience Report statuses of \"Failing\" or \"Warning\".",
  492. // "flatPath": "v1/violatingSites",
  493. // "httpMethod": "GET",
  494. // "id": "adexperiencereport.violatingSites.list",
  495. // "parameterOrder": [],
  496. // "parameters": {},
  497. // "path": "v1/violatingSites",
  498. // "response": {
  499. // "$ref": "ViolatingSitesResponse"
  500. // },
  501. // "scopes": [
  502. // "https://www.googleapis.com/auth/xapi.zoo"
  503. // ]
  504. // }
  505. }