1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package indexing
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "net/http"
61 "net/url"
62 "strconv"
63 "strings"
64
65 googleapi "google.golang.org/api/googleapi"
66 internal "google.golang.org/api/internal"
67 gensupport "google.golang.org/api/internal/gensupport"
68 option "google.golang.org/api/option"
69 internaloption "google.golang.org/api/option/internaloption"
70 htransport "google.golang.org/api/transport/http"
71 )
72
73
74
75 var _ = bytes.NewBuffer
76 var _ = strconv.Itoa
77 var _ = fmt.Sprintf
78 var _ = json.NewDecoder
79 var _ = io.Copy
80 var _ = url.Parse
81 var _ = gensupport.MarshalJSON
82 var _ = googleapi.Version
83 var _ = errors.New
84 var _ = strings.Replace
85 var _ = context.Canceled
86 var _ = internaloption.WithDefaultEndpoint
87 var _ = internal.Version
88
89 const apiId = "indexing:v3"
90 const apiName = "indexing"
91 const apiVersion = "v3"
92 const basePath = "https://indexing.googleapis.com/"
93 const basePathTemplate = "https://indexing.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://indexing.mtls.googleapis.com/"
95
96
97 const (
98
99 IndexingScope = "https://www.googleapis.com/auth/indexing"
100 )
101
102
103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
104 scopesOption := internaloption.WithDefaultScopes(
105 "https://www.googleapis.com/auth/indexing",
106 )
107
108 opts = append([]option.ClientOption{scopesOption}, opts...)
109 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
110 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
111 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
112 opts = append(opts, internaloption.EnableNewAuthLibrary())
113 client, endpoint, err := htransport.NewClient(ctx, opts...)
114 if err != nil {
115 return nil, err
116 }
117 s, err := New(client)
118 if err != nil {
119 return nil, err
120 }
121 if endpoint != "" {
122 s.BasePath = endpoint
123 }
124 return s, nil
125 }
126
127
128
129
130
131
132 func New(client *http.Client) (*Service, error) {
133 if client == nil {
134 return nil, errors.New("client is nil")
135 }
136 s := &Service{client: client, BasePath: basePath}
137 s.UrlNotifications = NewUrlNotificationsService(s)
138 return s, nil
139 }
140
141 type Service struct {
142 client *http.Client
143 BasePath string
144 UserAgent string
145
146 UrlNotifications *UrlNotificationsService
147 }
148
149 func (s *Service) userAgent() string {
150 if s.UserAgent == "" {
151 return googleapi.UserAgent
152 }
153 return googleapi.UserAgent + " " + s.UserAgent
154 }
155
156 func NewUrlNotificationsService(s *Service) *UrlNotificationsService {
157 rs := &UrlNotificationsService{s: s}
158 return rs
159 }
160
161 type UrlNotificationsService struct {
162 s *Service
163 }
164
165
166 type PublishUrlNotificationResponse struct {
167
168
169 UrlNotificationMetadata *UrlNotificationMetadata `json:"urlNotificationMetadata,omitempty"`
170
171
172 googleapi.ServerResponse `json:"-"`
173
174
175
176
177
178 ForceSendFields []string `json:"-"`
179
180
181
182
183 NullFields []string `json:"-"`
184 }
185
186 func (s *PublishUrlNotificationResponse) MarshalJSON() ([]byte, error) {
187 type NoMethod PublishUrlNotificationResponse
188 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
189 }
190
191
192
193 type UrlNotification struct {
194
195
196 NotifyTime string `json:"notifyTime,omitempty"`
197
198
199
200
201
202
203 Type string `json:"type,omitempty"`
204
205
206
207 Url string `json:"url,omitempty"`
208
209
210
211
212
213 ForceSendFields []string `json:"-"`
214
215
216
217
218 NullFields []string `json:"-"`
219 }
220
221 func (s *UrlNotification) MarshalJSON() ([]byte, error) {
222 type NoMethod UrlNotification
223 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
224 }
225
226
227
228 type UrlNotificationMetadata struct {
229
230 LatestRemove *UrlNotification `json:"latestRemove,omitempty"`
231
232 LatestUpdate *UrlNotification `json:"latestUpdate,omitempty"`
233
234 Url string `json:"url,omitempty"`
235
236
237 googleapi.ServerResponse `json:"-"`
238
239
240
241
242
243 ForceSendFields []string `json:"-"`
244
245
246
247
248 NullFields []string `json:"-"`
249 }
250
251 func (s *UrlNotificationMetadata) MarshalJSON() ([]byte, error) {
252 type NoMethod UrlNotificationMetadata
253 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
254 }
255
256 type UrlNotificationsGetMetadataCall struct {
257 s *Service
258 urlParams_ gensupport.URLParams
259 ifNoneMatch_ string
260 ctx_ context.Context
261 header_ http.Header
262 }
263
264
265
266
267 func (r *UrlNotificationsService) GetMetadata() *UrlNotificationsGetMetadataCall {
268 c := &UrlNotificationsGetMetadataCall{s: r.s, urlParams_: make(gensupport.URLParams)}
269 return c
270 }
271
272
273 func (c *UrlNotificationsGetMetadataCall) Url(url string) *UrlNotificationsGetMetadataCall {
274 c.urlParams_.Set("url", url)
275 return c
276 }
277
278
279
280
281 func (c *UrlNotificationsGetMetadataCall) Fields(s ...googleapi.Field) *UrlNotificationsGetMetadataCall {
282 c.urlParams_.Set("fields", googleapi.CombineFields(s))
283 return c
284 }
285
286
287
288
289 func (c *UrlNotificationsGetMetadataCall) IfNoneMatch(entityTag string) *UrlNotificationsGetMetadataCall {
290 c.ifNoneMatch_ = entityTag
291 return c
292 }
293
294
295 func (c *UrlNotificationsGetMetadataCall) Context(ctx context.Context) *UrlNotificationsGetMetadataCall {
296 c.ctx_ = ctx
297 return c
298 }
299
300
301
302 func (c *UrlNotificationsGetMetadataCall) Header() http.Header {
303 if c.header_ == nil {
304 c.header_ = make(http.Header)
305 }
306 return c.header_
307 }
308
309 func (c *UrlNotificationsGetMetadataCall) doRequest(alt string) (*http.Response, error) {
310 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
311 if c.ifNoneMatch_ != "" {
312 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
313 }
314 var body io.Reader = nil
315 c.urlParams_.Set("alt", alt)
316 c.urlParams_.Set("prettyPrint", "false")
317 urls := googleapi.ResolveRelative(c.s.BasePath, "v3/urlNotifications/metadata")
318 urls += "?" + c.urlParams_.Encode()
319 req, err := http.NewRequest("GET", urls, body)
320 if err != nil {
321 return nil, err
322 }
323 req.Header = reqHeaders
324 return gensupport.SendRequest(c.ctx_, c.s.client, req)
325 }
326
327
328
329
330
331
332
333 func (c *UrlNotificationsGetMetadataCall) Do(opts ...googleapi.CallOption) (*UrlNotificationMetadata, error) {
334 gensupport.SetOptions(c.urlParams_, opts...)
335 res, err := c.doRequest("json")
336 if res != nil && res.StatusCode == http.StatusNotModified {
337 if res.Body != nil {
338 res.Body.Close()
339 }
340 return nil, gensupport.WrapError(&googleapi.Error{
341 Code: res.StatusCode,
342 Header: res.Header,
343 })
344 }
345 if err != nil {
346 return nil, err
347 }
348 defer googleapi.CloseBody(res)
349 if err := googleapi.CheckResponse(res); err != nil {
350 return nil, gensupport.WrapError(err)
351 }
352 ret := &UrlNotificationMetadata{
353 ServerResponse: googleapi.ServerResponse{
354 Header: res.Header,
355 HTTPStatusCode: res.StatusCode,
356 },
357 }
358 target := &ret
359 if err := gensupport.DecodeResponse(target, res); err != nil {
360 return nil, err
361 }
362 return ret, nil
363 }
364
365 type UrlNotificationsPublishCall struct {
366 s *Service
367 urlnotification *UrlNotification
368 urlParams_ gensupport.URLParams
369 ctx_ context.Context
370 header_ http.Header
371 }
372
373
374 func (r *UrlNotificationsService) Publish(urlnotification *UrlNotification) *UrlNotificationsPublishCall {
375 c := &UrlNotificationsPublishCall{s: r.s, urlParams_: make(gensupport.URLParams)}
376 c.urlnotification = urlnotification
377 return c
378 }
379
380
381
382
383 func (c *UrlNotificationsPublishCall) Fields(s ...googleapi.Field) *UrlNotificationsPublishCall {
384 c.urlParams_.Set("fields", googleapi.CombineFields(s))
385 return c
386 }
387
388
389 func (c *UrlNotificationsPublishCall) Context(ctx context.Context) *UrlNotificationsPublishCall {
390 c.ctx_ = ctx
391 return c
392 }
393
394
395
396 func (c *UrlNotificationsPublishCall) Header() http.Header {
397 if c.header_ == nil {
398 c.header_ = make(http.Header)
399 }
400 return c.header_
401 }
402
403 func (c *UrlNotificationsPublishCall) doRequest(alt string) (*http.Response, error) {
404 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
405 var body io.Reader = nil
406 body, err := googleapi.WithoutDataWrapper.JSONReader(c.urlnotification)
407 if err != nil {
408 return nil, err
409 }
410 c.urlParams_.Set("alt", alt)
411 c.urlParams_.Set("prettyPrint", "false")
412 urls := googleapi.ResolveRelative(c.s.BasePath, "v3/urlNotifications:publish")
413 urls += "?" + c.urlParams_.Encode()
414 req, err := http.NewRequest("POST", urls, body)
415 if err != nil {
416 return nil, err
417 }
418 req.Header = reqHeaders
419 return gensupport.SendRequest(c.ctx_, c.s.client, req)
420 }
421
422
423
424
425
426
427
428 func (c *UrlNotificationsPublishCall) Do(opts ...googleapi.CallOption) (*PublishUrlNotificationResponse, error) {
429 gensupport.SetOptions(c.urlParams_, opts...)
430 res, err := c.doRequest("json")
431 if res != nil && res.StatusCode == http.StatusNotModified {
432 if res.Body != nil {
433 res.Body.Close()
434 }
435 return nil, gensupport.WrapError(&googleapi.Error{
436 Code: res.StatusCode,
437 Header: res.Header,
438 })
439 }
440 if err != nil {
441 return nil, err
442 }
443 defer googleapi.CloseBody(res)
444 if err := googleapi.CheckResponse(res); err != nil {
445 return nil, gensupport.WrapError(err)
446 }
447 ret := &PublishUrlNotificationResponse{
448 ServerResponse: googleapi.ServerResponse{
449 Header: res.Header,
450 HTTPStatusCode: res.StatusCode,
451 },
452 }
453 target := &ret
454 if err := gensupport.DecodeResponse(target, res); err != nil {
455 return nil, err
456 }
457 return ret, nil
458 }
459
View as plain text