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 mybusinessnotifications
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 = "mybusinessnotifications:v1"
90 const apiName = "mybusinessnotifications"
91 const apiVersion = "v1"
92 const basePath = "https://mybusinessnotifications.googleapis.com/"
93 const basePathTemplate = "https://mybusinessnotifications.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://mybusinessnotifications.mtls.googleapis.com/"
95
96
97 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
98 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
99 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
100 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
101 opts = append(opts, internaloption.EnableNewAuthLibrary())
102 client, endpoint, err := htransport.NewClient(ctx, opts...)
103 if err != nil {
104 return nil, err
105 }
106 s, err := New(client)
107 if err != nil {
108 return nil, err
109 }
110 if endpoint != "" {
111 s.BasePath = endpoint
112 }
113 return s, nil
114 }
115
116
117
118
119
120
121 func New(client *http.Client) (*Service, error) {
122 if client == nil {
123 return nil, errors.New("client is nil")
124 }
125 s := &Service{client: client, BasePath: basePath}
126 s.Accounts = NewAccountsService(s)
127 return s, nil
128 }
129
130 type Service struct {
131 client *http.Client
132 BasePath string
133 UserAgent string
134
135 Accounts *AccountsService
136 }
137
138 func (s *Service) userAgent() string {
139 if s.UserAgent == "" {
140 return googleapi.UserAgent
141 }
142 return googleapi.UserAgent + " " + s.UserAgent
143 }
144
145 func NewAccountsService(s *Service) *AccountsService {
146 rs := &AccountsService{s: s}
147 return rs
148 }
149
150 type AccountsService struct {
151 s *Service
152 }
153
154
155
156
157 type NotificationSetting struct {
158
159
160 Name string `json:"name,omitempty"`
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 NotificationTypes []string `json:"notificationTypes,omitempty"`
201
202
203
204
205
206 PubsubTopic string `json:"pubsubTopic,omitempty"`
207
208
209 googleapi.ServerResponse `json:"-"`
210
211
212
213
214
215 ForceSendFields []string `json:"-"`
216
217
218
219
220 NullFields []string `json:"-"`
221 }
222
223 func (s *NotificationSetting) MarshalJSON() ([]byte, error) {
224 type NoMethod NotificationSetting
225 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
226 }
227
228 type AccountsGetNotificationSettingCall struct {
229 s *Service
230 name string
231 urlParams_ gensupport.URLParams
232 ifNoneMatch_ string
233 ctx_ context.Context
234 header_ http.Header
235 }
236
237
238
239
240
241
242 func (r *AccountsService) GetNotificationSetting(name string) *AccountsGetNotificationSettingCall {
243 c := &AccountsGetNotificationSettingCall{s: r.s, urlParams_: make(gensupport.URLParams)}
244 c.name = name
245 return c
246 }
247
248
249
250
251 func (c *AccountsGetNotificationSettingCall) Fields(s ...googleapi.Field) *AccountsGetNotificationSettingCall {
252 c.urlParams_.Set("fields", googleapi.CombineFields(s))
253 return c
254 }
255
256
257
258
259 func (c *AccountsGetNotificationSettingCall) IfNoneMatch(entityTag string) *AccountsGetNotificationSettingCall {
260 c.ifNoneMatch_ = entityTag
261 return c
262 }
263
264
265 func (c *AccountsGetNotificationSettingCall) Context(ctx context.Context) *AccountsGetNotificationSettingCall {
266 c.ctx_ = ctx
267 return c
268 }
269
270
271
272 func (c *AccountsGetNotificationSettingCall) Header() http.Header {
273 if c.header_ == nil {
274 c.header_ = make(http.Header)
275 }
276 return c.header_
277 }
278
279 func (c *AccountsGetNotificationSettingCall) doRequest(alt string) (*http.Response, error) {
280 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
281 if c.ifNoneMatch_ != "" {
282 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
283 }
284 var body io.Reader = nil
285 c.urlParams_.Set("alt", alt)
286 c.urlParams_.Set("prettyPrint", "false")
287 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
288 urls += "?" + c.urlParams_.Encode()
289 req, err := http.NewRequest("GET", urls, body)
290 if err != nil {
291 return nil, err
292 }
293 req.Header = reqHeaders
294 googleapi.Expand(req.URL, map[string]string{
295 "name": c.name,
296 })
297 return gensupport.SendRequest(c.ctx_, c.s.client, req)
298 }
299
300
301
302
303
304
305
306 func (c *AccountsGetNotificationSettingCall) Do(opts ...googleapi.CallOption) (*NotificationSetting, error) {
307 gensupport.SetOptions(c.urlParams_, opts...)
308 res, err := c.doRequest("json")
309 if res != nil && res.StatusCode == http.StatusNotModified {
310 if res.Body != nil {
311 res.Body.Close()
312 }
313 return nil, gensupport.WrapError(&googleapi.Error{
314 Code: res.StatusCode,
315 Header: res.Header,
316 })
317 }
318 if err != nil {
319 return nil, err
320 }
321 defer googleapi.CloseBody(res)
322 if err := googleapi.CheckResponse(res); err != nil {
323 return nil, gensupport.WrapError(err)
324 }
325 ret := &NotificationSetting{
326 ServerResponse: googleapi.ServerResponse{
327 Header: res.Header,
328 HTTPStatusCode: res.StatusCode,
329 },
330 }
331 target := &ret
332 if err := gensupport.DecodeResponse(target, res); err != nil {
333 return nil, err
334 }
335 return ret, nil
336 }
337
338 type AccountsUpdateNotificationSettingCall struct {
339 s *Service
340 name string
341 notificationsetting *NotificationSetting
342 urlParams_ gensupport.URLParams
343 ctx_ context.Context
344 header_ http.Header
345 }
346
347
348
349
350
351
352
353
354
355
356 func (r *AccountsService) UpdateNotificationSetting(name string, notificationsetting *NotificationSetting) *AccountsUpdateNotificationSettingCall {
357 c := &AccountsUpdateNotificationSettingCall{s: r.s, urlParams_: make(gensupport.URLParams)}
358 c.name = name
359 c.notificationsetting = notificationsetting
360 return c
361 }
362
363
364
365
366 func (c *AccountsUpdateNotificationSettingCall) UpdateMask(updateMask string) *AccountsUpdateNotificationSettingCall {
367 c.urlParams_.Set("updateMask", updateMask)
368 return c
369 }
370
371
372
373
374 func (c *AccountsUpdateNotificationSettingCall) Fields(s ...googleapi.Field) *AccountsUpdateNotificationSettingCall {
375 c.urlParams_.Set("fields", googleapi.CombineFields(s))
376 return c
377 }
378
379
380 func (c *AccountsUpdateNotificationSettingCall) Context(ctx context.Context) *AccountsUpdateNotificationSettingCall {
381 c.ctx_ = ctx
382 return c
383 }
384
385
386
387 func (c *AccountsUpdateNotificationSettingCall) Header() http.Header {
388 if c.header_ == nil {
389 c.header_ = make(http.Header)
390 }
391 return c.header_
392 }
393
394 func (c *AccountsUpdateNotificationSettingCall) doRequest(alt string) (*http.Response, error) {
395 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
396 var body io.Reader = nil
397 body, err := googleapi.WithoutDataWrapper.JSONReader(c.notificationsetting)
398 if err != nil {
399 return nil, err
400 }
401 c.urlParams_.Set("alt", alt)
402 c.urlParams_.Set("prettyPrint", "false")
403 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
404 urls += "?" + c.urlParams_.Encode()
405 req, err := http.NewRequest("PATCH", urls, body)
406 if err != nil {
407 return nil, err
408 }
409 req.Header = reqHeaders
410 googleapi.Expand(req.URL, map[string]string{
411 "name": c.name,
412 })
413 return gensupport.SendRequest(c.ctx_, c.s.client, req)
414 }
415
416
417
418
419
420
421
422 func (c *AccountsUpdateNotificationSettingCall) Do(opts ...googleapi.CallOption) (*NotificationSetting, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
440 }
441 ret := &NotificationSetting{
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
View as plain text