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.
 
 
 

459 lines
15 KiB

  1. // Package abusiveexperiencereport provides access to the Abusive Experience Report API.
  2. //
  3. // See https://developers.google.com/abusive-experience-report/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/abusiveexperiencereport/v1"
  8. // ...
  9. // abusiveexperiencereportService, err := abusiveexperiencereport.New(oauthHttpClient)
  10. package abusiveexperiencereport // import "google.golang.org/api/abusiveexperiencereport/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 = "abusiveexperiencereport:v1"
  41. const apiName = "abusiveexperiencereport"
  42. const apiVersion = "v1"
  43. const basePath = "https://abusiveexperiencereport.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. // SiteSummaryResponse: Response message for GetSiteSummary.
  86. // Do not confuse with same message in google.ads.experiencereport.v1
  87. type SiteSummaryResponse struct {
  88. // AbusiveStatus: The status of the site reviewed for the abusive
  89. // experiences.
  90. //
  91. // Possible values:
  92. // "UNKNOWN" - Not reviewed.
  93. // "PASSING" - Passing.
  94. // "FAILING" - Failing.
  95. AbusiveStatus string `json:"abusiveStatus,omitempty"`
  96. // EnforcementTime: The date on which enforcement begins.
  97. EnforcementTime string `json:"enforcementTime,omitempty"`
  98. // FilterStatus: The abusive experience enforcement status of the site.
  99. //
  100. // Possible values:
  101. // "UNKNOWN" - N/A.
  102. // "ON" - Ad filtering is on.
  103. // "OFF" - Ad filtering is off.
  104. // "PAUSED" - Ad filtering is paused.
  105. // "PENDING" - Ad filtering is pending.
  106. FilterStatus string `json:"filterStatus,omitempty"`
  107. // LastChangeTime: The last time that the site changed status.
  108. LastChangeTime string `json:"lastChangeTime,omitempty"`
  109. // ReportUrl: A link that leads to a full abusive experience report.
  110. ReportUrl string `json:"reportUrl,omitempty"`
  111. // ReviewedSite: The name of the site reviewed.
  112. ReviewedSite string `json:"reviewedSite,omitempty"`
  113. // UnderReview: Whether the site is currently under review.
  114. UnderReview bool `json:"underReview,omitempty"`
  115. // ServerResponse contains the HTTP response code and headers from the
  116. // server.
  117. googleapi.ServerResponse `json:"-"`
  118. // ForceSendFields is a list of field names (e.g. "AbusiveStatus") to
  119. // unconditionally include in API requests. By default, fields with
  120. // empty values are omitted from API requests. However, any non-pointer,
  121. // non-interface field appearing in ForceSendFields will be sent to the
  122. // server regardless of whether the field is empty or not. This may be
  123. // used to include empty fields in Patch requests.
  124. ForceSendFields []string `json:"-"`
  125. // NullFields is a list of field names (e.g. "AbusiveStatus") to include
  126. // in API requests with the JSON null value. By default, fields with
  127. // empty values are omitted from API requests. However, any field with
  128. // an empty value appearing in NullFields will be sent to the server as
  129. // null. It is an error if a field in this list has a non-empty value.
  130. // This may be used to include null fields in Patch requests.
  131. NullFields []string `json:"-"`
  132. }
  133. func (s *SiteSummaryResponse) MarshalJSON() ([]byte, error) {
  134. type NoMethod SiteSummaryResponse
  135. raw := NoMethod(*s)
  136. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  137. }
  138. // ViolatingSitesResponse: Response message for ListViolatingSites.
  139. type ViolatingSitesResponse struct {
  140. // ViolatingSites: A list of summaries of violating sites.
  141. ViolatingSites []*SiteSummaryResponse `json:"violatingSites,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. "ViolatingSites") 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. "ViolatingSites") to
  153. // include in API requests with the JSON null value. By default, fields
  154. // with empty values are omitted from API requests. However, any field
  155. // with an empty value appearing in NullFields will be sent to the
  156. // server as null. It is an error if a field in this list has a
  157. // non-empty value. This may be used to include null fields in Patch
  158. // requests.
  159. NullFields []string `json:"-"`
  160. }
  161. func (s *ViolatingSitesResponse) MarshalJSON() ([]byte, error) {
  162. type NoMethod ViolatingSitesResponse
  163. raw := NoMethod(*s)
  164. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  165. }
  166. // method id "abusiveexperiencereport.sites.get":
  167. type SitesGetCall struct {
  168. s *Service
  169. name string
  170. urlParams_ gensupport.URLParams
  171. ifNoneMatch_ string
  172. ctx_ context.Context
  173. header_ http.Header
  174. }
  175. // Get: Gets a summary of the abusive experience rating of a site.
  176. func (r *SitesService) Get(name string) *SitesGetCall {
  177. c := &SitesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  178. c.name = name
  179. return c
  180. }
  181. // Fields allows partial responses to be retrieved. See
  182. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  183. // for more information.
  184. func (c *SitesGetCall) Fields(s ...googleapi.Field) *SitesGetCall {
  185. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  186. return c
  187. }
  188. // IfNoneMatch sets the optional parameter which makes the operation
  189. // fail if the object's ETag matches the given value. This is useful for
  190. // getting updates only after the object has changed since the last
  191. // request. Use googleapi.IsNotModified to check whether the response
  192. // error from Do is the result of In-None-Match.
  193. func (c *SitesGetCall) IfNoneMatch(entityTag string) *SitesGetCall {
  194. c.ifNoneMatch_ = entityTag
  195. return c
  196. }
  197. // Context sets the context to be used in this call's Do method. Any
  198. // pending HTTP request will be aborted if the provided context is
  199. // canceled.
  200. func (c *SitesGetCall) Context(ctx context.Context) *SitesGetCall {
  201. c.ctx_ = ctx
  202. return c
  203. }
  204. // Header returns an http.Header that can be modified by the caller to
  205. // add HTTP headers to the request.
  206. func (c *SitesGetCall) Header() http.Header {
  207. if c.header_ == nil {
  208. c.header_ = make(http.Header)
  209. }
  210. return c.header_
  211. }
  212. func (c *SitesGetCall) doRequest(alt string) (*http.Response, error) {
  213. reqHeaders := make(http.Header)
  214. for k, v := range c.header_ {
  215. reqHeaders[k] = v
  216. }
  217. reqHeaders.Set("User-Agent", c.s.userAgent())
  218. if c.ifNoneMatch_ != "" {
  219. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  220. }
  221. var body io.Reader = nil
  222. c.urlParams_.Set("alt", alt)
  223. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  224. urls += "?" + c.urlParams_.Encode()
  225. req, _ := http.NewRequest("GET", urls, body)
  226. req.Header = reqHeaders
  227. googleapi.Expand(req.URL, map[string]string{
  228. "name": c.name,
  229. })
  230. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  231. }
  232. // Do executes the "abusiveexperiencereport.sites.get" call.
  233. // Exactly one of *SiteSummaryResponse or error will be non-nil. Any
  234. // non-2xx status code is an error. Response headers are in either
  235. // *SiteSummaryResponse.ServerResponse.Header or (if a response was
  236. // returned at all) in error.(*googleapi.Error).Header. Use
  237. // googleapi.IsNotModified to check whether the returned error was
  238. // because http.StatusNotModified was returned.
  239. func (c *SitesGetCall) Do(opts ...googleapi.CallOption) (*SiteSummaryResponse, error) {
  240. gensupport.SetOptions(c.urlParams_, opts...)
  241. res, err := c.doRequest("json")
  242. if res != nil && res.StatusCode == http.StatusNotModified {
  243. if res.Body != nil {
  244. res.Body.Close()
  245. }
  246. return nil, &googleapi.Error{
  247. Code: res.StatusCode,
  248. Header: res.Header,
  249. }
  250. }
  251. if err != nil {
  252. return nil, err
  253. }
  254. defer googleapi.CloseBody(res)
  255. if err := googleapi.CheckResponse(res); err != nil {
  256. return nil, err
  257. }
  258. ret := &SiteSummaryResponse{
  259. ServerResponse: googleapi.ServerResponse{
  260. Header: res.Header,
  261. HTTPStatusCode: res.StatusCode,
  262. },
  263. }
  264. target := &ret
  265. if err := gensupport.DecodeResponse(target, res); err != nil {
  266. return nil, err
  267. }
  268. return ret, nil
  269. // {
  270. // "description": "Gets a summary of the abusive experience rating of a site.",
  271. // "flatPath": "v1/sites/{sitesId}",
  272. // "httpMethod": "GET",
  273. // "id": "abusiveexperiencereport.sites.get",
  274. // "parameterOrder": [
  275. // "name"
  276. // ],
  277. // "parameters": {
  278. // "name": {
  279. // "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.",
  280. // "location": "path",
  281. // "pattern": "^sites/[^/]+$",
  282. // "required": true,
  283. // "type": "string"
  284. // }
  285. // },
  286. // "path": "v1/{+name}",
  287. // "response": {
  288. // "$ref": "SiteSummaryResponse"
  289. // },
  290. // "scopes": [
  291. // "https://www.googleapis.com/auth/xapi.zoo"
  292. // ]
  293. // }
  294. }
  295. // method id "abusiveexperiencereport.violatingSites.list":
  296. type ViolatingSitesListCall struct {
  297. s *Service
  298. urlParams_ gensupport.URLParams
  299. ifNoneMatch_ string
  300. ctx_ context.Context
  301. header_ http.Header
  302. }
  303. // List: Lists sites with Abusive Experience Report statuses of
  304. // "Failing".
  305. func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
  306. c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  307. return c
  308. }
  309. // Fields allows partial responses to be retrieved. See
  310. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  311. // for more information.
  312. func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
  313. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  314. return c
  315. }
  316. // IfNoneMatch sets the optional parameter which makes the operation
  317. // fail if the object's ETag matches the given value. This is useful for
  318. // getting updates only after the object has changed since the last
  319. // request. Use googleapi.IsNotModified to check whether the response
  320. // error from Do is the result of In-None-Match.
  321. func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
  322. c.ifNoneMatch_ = entityTag
  323. return c
  324. }
  325. // Context sets the context to be used in this call's Do method. Any
  326. // pending HTTP request will be aborted if the provided context is
  327. // canceled.
  328. func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
  329. c.ctx_ = ctx
  330. return c
  331. }
  332. // Header returns an http.Header that can be modified by the caller to
  333. // add HTTP headers to the request.
  334. func (c *ViolatingSitesListCall) Header() http.Header {
  335. if c.header_ == nil {
  336. c.header_ = make(http.Header)
  337. }
  338. return c.header_
  339. }
  340. func (c *ViolatingSitesListCall) doRequest(alt string) (*http.Response, error) {
  341. reqHeaders := make(http.Header)
  342. for k, v := range c.header_ {
  343. reqHeaders[k] = v
  344. }
  345. reqHeaders.Set("User-Agent", c.s.userAgent())
  346. if c.ifNoneMatch_ != "" {
  347. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  348. }
  349. var body io.Reader = nil
  350. c.urlParams_.Set("alt", alt)
  351. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/violatingSites")
  352. urls += "?" + c.urlParams_.Encode()
  353. req, _ := http.NewRequest("GET", urls, body)
  354. req.Header = reqHeaders
  355. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  356. }
  357. // Do executes the "abusiveexperiencereport.violatingSites.list" call.
  358. // Exactly one of *ViolatingSitesResponse or error will be non-nil. Any
  359. // non-2xx status code is an error. Response headers are in either
  360. // *ViolatingSitesResponse.ServerResponse.Header or (if a response was
  361. // returned at all) in error.(*googleapi.Error).Header. Use
  362. // googleapi.IsNotModified to check whether the returned error was
  363. // because http.StatusNotModified was returned.
  364. func (c *ViolatingSitesListCall) Do(opts ...googleapi.CallOption) (*ViolatingSitesResponse, error) {
  365. gensupport.SetOptions(c.urlParams_, opts...)
  366. res, err := c.doRequest("json")
  367. if res != nil && res.StatusCode == http.StatusNotModified {
  368. if res.Body != nil {
  369. res.Body.Close()
  370. }
  371. return nil, &googleapi.Error{
  372. Code: res.StatusCode,
  373. Header: res.Header,
  374. }
  375. }
  376. if err != nil {
  377. return nil, err
  378. }
  379. defer googleapi.CloseBody(res)
  380. if err := googleapi.CheckResponse(res); err != nil {
  381. return nil, err
  382. }
  383. ret := &ViolatingSitesResponse{
  384. ServerResponse: googleapi.ServerResponse{
  385. Header: res.Header,
  386. HTTPStatusCode: res.StatusCode,
  387. },
  388. }
  389. target := &ret
  390. if err := gensupport.DecodeResponse(target, res); err != nil {
  391. return nil, err
  392. }
  393. return ret, nil
  394. // {
  395. // "description": "Lists sites with Abusive Experience Report statuses of \"Failing\".",
  396. // "flatPath": "v1/violatingSites",
  397. // "httpMethod": "GET",
  398. // "id": "abusiveexperiencereport.violatingSites.list",
  399. // "parameterOrder": [],
  400. // "parameters": {},
  401. // "path": "v1/violatingSites",
  402. // "response": {
  403. // "$ref": "ViolatingSitesResponse"
  404. // },
  405. // "scopes": [
  406. // "https://www.googleapis.com/auth/xapi.zoo"
  407. // ]
  408. // }
  409. }