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.
 
 
 

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