-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
fcm-gen.go
1347 lines (1212 loc) · 49.1 KB
/
fcm-gen.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated file. DO NOT EDIT.
// Package fcm provides access to the Firebase Cloud Messaging API.
//
// For product documentation, see: https://firebase.google.com/docs/cloud-messaging
//
// Creating a client
//
// Usage example:
//
// import "google.golang.org/api/fcm/v1"
// ...
// ctx := context.Background()
// fcmService, err := fcm.NewService(ctx)
//
// In this example, Google Application Default Credentials are used for authentication.
//
// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
//
// Other authentication options
//
// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
//
// fcmService, err := fcm.NewService(ctx, option.WithAPIKey("AIza..."))
//
// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
//
// config := &oauth2.Config{...}
// // ...
// token, err := config.Exchange(ctx, ...)
// fcmService, err := fcm.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
//
// See https://godoc.org/google.golang.org/api/option/ for details on options.
package fcm // import "google.golang.org/api/fcm/v1"
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"strings"
googleapi "google.golang.org/api/googleapi"
gensupport "google.golang.org/api/internal/gensupport"
option "google.golang.org/api/option"
htransport "google.golang.org/api/transport/http"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
const apiId = "fcm:v1"
const apiName = "fcm"
const apiVersion = "v1"
const basePath = "https://fcm.googleapis.com/"
// OAuth2 scopes used by this API.
const (
// View and manage your data across Google Cloud Platform services
CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
)
// NewService creates a new Service.
func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
scopesOption := option.WithScopes(
"https://www.googleapis.com/auth/cloud-platform",
)
// NOTE: prepend, so we don't override user-specified scopes.
opts = append([]option.ClientOption{scopesOption}, opts...)
client, endpoint, err := htransport.NewClient(ctx, opts...)
if err != nil {
return nil, err
}
s, err := New(client)
if err != nil {
return nil, err
}
if endpoint != "" {
s.BasePath = endpoint
}
return s, nil
}
// New creates a new Service. It uses the provided http.Client for requests.
//
// Deprecated: please use NewService instead.
// To provide a custom HTTP client, use option.WithHTTPClient.
// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Projects = NewProjectsService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Projects *ProjectsService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewProjectsService(s *Service) *ProjectsService {
rs := &ProjectsService{s: s}
rs.Messages = NewProjectsMessagesService(s)
return rs
}
type ProjectsService struct {
s *Service
Messages *ProjectsMessagesService
}
func NewProjectsMessagesService(s *Service) *ProjectsMessagesService {
rs := &ProjectsMessagesService{s: s}
return rs
}
type ProjectsMessagesService struct {
s *Service
}
// AndroidConfig: Android specific options for messages sent
// through
// [FCM connection server](https://goo.gl/4GLdUl).
type AndroidConfig struct {
// CollapseKey: An identifier of a group of messages that can be
// collapsed, so that only
// the last message gets sent when delivery can be resumed. A maximum of
// 4
// different collapse keys is allowed at any given time.
CollapseKey string `json:"collapseKey,omitempty"`
// Data: Arbitrary key/value payload. If present, it will
// override
// google.firebase.fcm.v1.Message.data.
Data map[string]string `json:"data,omitempty"`
// DirectBootOk: If set to true, messages will be allowed to be
// delivered to the app while
// the device is in direct boot mode. See [Support Direct
// Boot
// mode](https://developer.android.com/training/articles/direct-boot
// ).
DirectBootOk bool `json:"directBootOk,omitempty"`
// FcmOptions: Options for features provided by the FCM SDK for Android.
FcmOptions *AndroidFcmOptions `json:"fcmOptions,omitempty"`
// Notification: Notification to send to android devices.
Notification *AndroidNotification `json:"notification,omitempty"`
// Priority: Message priority. Can take "normal" and "high" values.
// For more information, see [Setting the priority of
// a
// message](https://goo.gl/GjONJv).
//
// Possible values:
// "NORMAL" - Default priority for data messages. Normal priority
// messages won't open
// network connections on a sleeping device, and their delivery may
// be
// delayed to conserve the battery. For less time-sensitive messages,
// such
// as notifications of new email or other data to sync, choose
// normal
// delivery priority.
// "HIGH" - Default priority for notification messages. FCM attempts
// to deliver high
// priority messages immediately, allowing the FCM service to wake
// a
// sleeping device when possible and open a network connection to your
// app
// server. Apps with instant messaging, chat, or voice call alerts,
// for
// example, generally need to open a network connection and make sure
// FCM
// delivers the message to the device without delay. Set high priority
// if
// the message is time-critical and requires the user's
// immediate
// interaction, but beware that setting your messages to high
// priority
// contributes more to battery drain compared with normal priority
// messages.
Priority string `json:"priority,omitempty"`
// RestrictedPackageName: Package name of the application where the
// registration token must match in
// order to receive the message.
RestrictedPackageName string `json:"restrictedPackageName,omitempty"`
// Ttl: How long (in seconds) the message should be kept in FCM storage
// if the
// device is offline. The maximum time to live supported is 4 weeks, and
// the
// default value is 4 weeks if not set. Set it to 0 if want to send
// the
// message immediately.
// In JSON format, the Duration type is encoded as a string rather than
// an
// object, where the string ends in the suffix "s" (indicating seconds)
// and
// is preceded by the number of seconds, with nanoseconds expressed
// as
// fractional seconds. For example, 3 seconds with 0 nanoseconds should
// be
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond
// should
// be expressed in JSON format as "3.000000001s". The ttl will be
// rounded down
// to the nearest second.
Ttl string `json:"ttl,omitempty"`
// ForceSendFields is a list of field names (e.g. "CollapseKey") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "CollapseKey") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *AndroidConfig) MarshalJSON() ([]byte, error) {
type NoMethod AndroidConfig
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// AndroidFcmOptions: Options for features provided by the FCM SDK for
// Android.
type AndroidFcmOptions struct {
// AnalyticsLabel: Label associated with the message's analytics data.
AnalyticsLabel string `json:"analyticsLabel,omitempty"`
// ForceSendFields is a list of field names (e.g. "AnalyticsLabel") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "AnalyticsLabel") to
// include in API requests with the JSON null value. By default, fields
// with empty values are omitted from API requests. However, any field
// with an empty value appearing in NullFields will be sent to the
// server as null. It is an error if a field in this list has a
// non-empty value. This may be used to include null fields in Patch
// requests.
NullFields []string `json:"-"`
}
func (s *AndroidFcmOptions) MarshalJSON() ([]byte, error) {
type NoMethod AndroidFcmOptions
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// AndroidNotification: Notification to send to android devices.
type AndroidNotification struct {
// Body: The notification's body text. If present, it will
// override
// google.firebase.fcm.v1.Notification.body.
Body string `json:"body,omitempty"`
// BodyLocArgs: Variable string values to be used in place of the format
// specifiers in
// body_loc_key to use to localize the body text to the user's
// current
// localization.
// See [Formatting and Styling](https://goo.gl/MalYE3) for more
// information.
BodyLocArgs []string `json:"bodyLocArgs,omitempty"`
// BodyLocKey: The key to the body string in the app's string resources
// to use to localize
// the body text to the user's current localization.
// See [String Resources](https://goo.gl/NdFZGI) for more information.
BodyLocKey string `json:"bodyLocKey,omitempty"`
// ChannelId: The [notification's
// channel
// id](https://developer.android.com/guide/topics/ui/notifiers/no
// tifications#ManageChannels)
// (new in Android O). The app must create a channel with this channel
// ID
// before any notification with this channel ID is received. If you
// don't send
// this channel ID in the request, or if the channel ID provided has not
// yet
// been created by the app, FCM uses the channel ID specified in the
// app
// manifest.
ChannelId string `json:"channelId,omitempty"`
// ClickAction: The action associated with a user click on the
// notification.
// If specified, an activity with a matching intent filter is launched
// when
// a user clicks on the notification.
ClickAction string `json:"clickAction,omitempty"`
// Color: The notification's icon color, expressed in #rrggbb format.
Color string `json:"color,omitempty"`
// DefaultLightSettings: If set to true, use the Android framework's
// default LED light settings for
// the notification. Default values are specified
// in
// [config.xml](https://android.googlesource.com/platform/frameworks/b
// ase/+/master/core/res/res/values/config.xml).
// If `default_light_settings` is set to true and `light_settings` is
// also
// set, the user-specified `light_settings` is used instead of
// the
// default value.
DefaultLightSettings bool `json:"defaultLightSettings,omitempty"`
// DefaultSound: If set to true, use the Android framework's default
// sound for the
// notification. Default values are specified
// in
// [config.xml](https://android.googlesource.com/platform/frameworks/b
// ase/+/master/core/res/res/values/config.xml).
DefaultSound bool `json:"defaultSound,omitempty"`
// DefaultVibrateTimings: If set to true, use the Android framework's
// default vibrate pattern for the
// notification. Default values are specified
// in
// [config.xml](https://android.googlesource.com/platform/frameworks/b
// ase/+/master/core/res/res/values/config.xml).
// If `default_vibrate_timings` is set to true and `vibrate_timings` is
// also
// set, the default value is used instead of the
// user-specified
// `vibrate_timings`.
DefaultVibrateTimings bool `json:"defaultVibrateTimings,omitempty"`
// EventTime: Set the time that the event in the notification occurred.
// Notifications in
// the panel are sorted by this time. A point in time is represented
// using
// [protobuf.Timestamp](https://developers.google.com/protocol-buff
// ers/docs/reference/java/com/google/protobuf/Timestamp).
EventTime string `json:"eventTime,omitempty"`
// Icon: The notification's icon.
// Sets the notification icon to myicon for drawable resource myicon.
// If you don't send this key in the request, FCM displays the launcher
// icon
// specified in your app manifest.
Icon string `json:"icon,omitempty"`
// Image: Contains the URL of an image that is going to be displayed in
// a
// notification. If present, it will
// override
// google.firebase.fcm.v1.Notification.image.
Image string `json:"image,omitempty"`
// LightSettings: Settings to control the notification's LED blinking
// rate and color if LED
// is available on the device. The total blinking time is controlled by
// the
// OS.
LightSettings *LightSettings `json:"lightSettings,omitempty"`
// LocalOnly: Set whether or not this notification is relevant only to
// the current
// device. Some notifications can be bridged to other devices for
// remote
// display, such as a Wear OS watch. This hint can be set to recommend
// this
// notification not be bridged. See [Wear
// OS
// guides](https://developer.android.com/training/wearables/notificati
// ons/bridger#existing-method-of-preventing-bridging)
LocalOnly bool `json:"localOnly,omitempty"`
// NotificationCount: Sets the number of items this notification
// represents. May be displayed as
// a badge count for launchers that support badging.See
// [Notification
// Badge](https://developer.android.com/training/notify-use
// r/badges).
// For example, this might be useful if you're using just one
// notification to
// represent multiple new messages but you want the count here to
// represent
// the number of total new messages.
// If zero or unspecified, systems that support badging use the default,
// which
// is to increment a number displayed on the long-press menu each time a
// new
// notification arrives.
NotificationCount int64 `json:"notificationCount,omitempty"`
// NotificationPriority: Set the relative priority for this
// notification. Priority is an indication
// of how much of the user's attention should be consumed by
// this
// notification. Low-priority notifications may be hidden from the user
// in
// certain situations, while the user might be interrupted for
// a
// higher-priority notification. The effect of setting the same
// priorities may
// differ slightly on different platforms. Note this priority differs
// from
// `AndroidMessagePriority`. This priority is processed by the client
// after
// the message has been delivered,
// whereas
// [AndroidMessagePriority](https://firebase.google.com/docs/refe
// rence/fcm/rest/v1/projects.messages#androidmessagepriority)
// is an FCM concept that controls when the message is delivered.
//
// Possible values:
// "PRIORITY_UNSPECIFIED" - If priority is unspecified, notification
// priority is set to
// `PRIORITY_DEFAULT`.
// "PRIORITY_MIN" - Lowest notification priority. Notifications with
// this `PRIORITY_MIN`
// might not be shown to the user except under special
// circumstances,
// such as detailed notification logs.
// "PRIORITY_LOW" - Lower notification priority. The UI may choose to
// show the notifications
// smaller, or at a different position in the list, compared
// with
// notifications with `PRIORITY_DEFAULT`.
// "PRIORITY_DEFAULT" - Default notification priority. If the
// application does not prioritize its
// own notifications, use this value for all notifications.
// "PRIORITY_HIGH" - Higher notification priority. Use this for more
// important notifications
// or alerts. The UI may choose to show these notifications larger, or
// at a
// different position in the notification lists, compared with
// notifications
// with `PRIORITY_DEFAULT`.
// "PRIORITY_MAX" - Highest notification priority. Use this for the
// application's most
// important items that require the user's prompt attention or input.
NotificationPriority string `json:"notificationPriority,omitempty"`
// Sound: The sound to play when the device receives the
// notification.
// Supports "default" or the filename of a sound resource bundled in the
// app.
// Sound files must reside in /res/raw/.
Sound string `json:"sound,omitempty"`
// Sticky: When set to false or unset, the notification is
// automatically
// dismissed when the user clicks it in the panel. When set to true,
// the
// notification persists even when the user clicks it.
Sticky bool `json:"sticky,omitempty"`
// Tag: Identifier used to replace existing notifications in the
// notification
// drawer.
// If not specified, each request creates a new notification.
// If specified and a notification with the same tag is already being
// shown,
// the new notification replaces the existing one in the notification
// drawer.
Tag string `json:"tag,omitempty"`
// Ticker: Sets the "ticker" text, which is sent to accessibility
// services.
// Prior to API level 21 (`Lollipop`), sets the text that is displayed
// in the
// status bar when the notification first arrives.
Ticker string `json:"ticker,omitempty"`
// Title: The notification's title. If present, it will
// override
// google.firebase.fcm.v1.Notification.title.
Title string `json:"title,omitempty"`
// TitleLocArgs: Variable string values to be used in place of the
// format specifiers in
// title_loc_key to use to localize the title text to the user's
// current
// localization.
// See [Formatting and Styling](https://goo.gl/MalYE3) for more
// information.
TitleLocArgs []string `json:"titleLocArgs,omitempty"`
// TitleLocKey: The key to the title string in the app's string
// resources to use to
// localize the title text to the user's current localization.
// See [String Resources](https://goo.gl/NdFZGI) for more information.
TitleLocKey string `json:"titleLocKey,omitempty"`
// VibrateTimings: Set the vibration pattern to use. Pass in an array
// of
// [protobuf.Duration](https://developers.google.com/protocol-buffers/
// docs/reference/google.protobuf#google.protobuf.Duration)
// to turn on or off the vibrator. The first value indicates the
// `Duration` to
// wait before turning the vibrator on. The next value indicates
// the
// `Duration` to keep the vibrator on. Subsequent values alternate
// between
// `Duration` to turn the vibrator off and to turn the vibrator on.
// If `vibrate_timings` is set and `default_vibrate_timings` is set to
// `true`,
// the default value is used instead of the user-specified
// `vibrate_timings`.
VibrateTimings []string `json:"vibrateTimings,omitempty"`
// Visibility: Set
// the
// [Notification.visibility](https://developer.android.com/reference/
// android/app/Notification.html#visibility)
// of the notification.
//
// Possible values:
// "VISIBILITY_UNSPECIFIED" - If unspecified, default to
// `Visibility.PRIVATE`.
// "PRIVATE" - Show this notification on all lockscreens, but conceal
// sensitive or
// private information on secure lockscreens.
// "PUBLIC" - Show this notification in its entirety on all
// lockscreens.
// "SECRET" - Do not reveal any part of this notification on a secure
// lockscreen.
Visibility string `json:"visibility,omitempty"`
// ForceSendFields is a list of field names (e.g. "Body") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Body") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *AndroidNotification) MarshalJSON() ([]byte, error) {
type NoMethod AndroidNotification
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ApnsConfig: [Apple Push Notification Service](https://goo.gl/MXRTPa)
// specific options.
type ApnsConfig struct {
// FcmOptions: Options for features provided by the FCM SDK for iOS.
FcmOptions *ApnsFcmOptions `json:"fcmOptions,omitempty"`
// Headers: HTTP request headers defined in Apple Push Notification
// Service. Refer to
// [APNs
// request
// headers](https://developer.apple.com/documentation/usernotific
// ations/setting_up_a_remote_notification_server/sending_notification_re
// quests_to_apns)
// for supported headers, e.g. "apns-priority": "10".
Headers map[string]string `json:"headers,omitempty"`
// Payload: APNs payload as a JSON object, including both `aps`
// dictionary and custom
// payload. See [Payload
// Key
// Reference](https://developer.apple.com/documentation/usernotificat
// ions/setting_up_a_remote_notification_server/generating_a_remote_notif
// ication).
// If present, it overrides
// google.firebase.fcm.v1.Notification.title
// and google.firebase.fcm.v1.Notification.body.
Payload googleapi.RawMessage `json:"payload,omitempty"`
// ForceSendFields is a list of field names (e.g. "FcmOptions") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "FcmOptions") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *ApnsConfig) MarshalJSON() ([]byte, error) {
type NoMethod ApnsConfig
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ApnsFcmOptions: Options for features provided by the FCM SDK for iOS.
type ApnsFcmOptions struct {
// AnalyticsLabel: Label associated with the message's analytics data.
AnalyticsLabel string `json:"analyticsLabel,omitempty"`
// Image: Contains the URL of an image that is going to be displayed in
// a
// notification. If present, it will
// override
// google.firebase.fcm.v1.Notification.image.
Image string `json:"image,omitempty"`
// ForceSendFields is a list of field names (e.g. "AnalyticsLabel") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "AnalyticsLabel") to
// include in API requests with the JSON null value. By default, fields
// with empty values are omitted from API requests. However, any field
// with an empty value appearing in NullFields will be sent to the
// server as null. It is an error if a field in this list has a
// non-empty value. This may be used to include null fields in Patch
// requests.
NullFields []string `json:"-"`
}
func (s *ApnsFcmOptions) MarshalJSON() ([]byte, error) {
type NoMethod ApnsFcmOptions
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Color: Represents a color in the RGBA color space. This
// representation is designed
// for simplicity of conversion to/from color representations in
// various
// languages over compactness; for example, the fields of this
// representation
// can be trivially provided to the constructor of "java.awt.Color" in
// Java; it
// can also be trivially provided to UIColor's
// "+colorWithRed:green:blue:alpha"
// method in iOS; and, with just a little work, it can be easily
// formatted into
// a CSS "rgba()" string in JavaScript, as well.
//
// Note: this proto does not carry information about the absolute color
// space
// that should be used to interpret the RGB value (e.g. sRGB, Adobe
// RGB,
// DCI-P3, BT.2020, etc.). By default, applications SHOULD assume the
// sRGB color
// space.
//
// Example (Java):
//
// import com.google.type.Color;
//
// // ...
// public static java.awt.Color fromProto(Color protocolor) {
// float alpha = protocolor.hasAlpha()
// ? protocolor.getAlpha().getValue()
// : 1.0;
//
// return new java.awt.Color(
// protocolor.getRed(),
// protocolor.getGreen(),
// protocolor.getBlue(),
// alpha);
// }
//
// public static Color toProto(java.awt.Color color) {
// float red = (float) color.getRed();
// float green = (float) color.getGreen();
// float blue = (float) color.getBlue();
// float denominator = 255.0;
// Color.Builder resultBuilder =
// Color
// .newBuilder()
// .setRed(red / denominator)
// .setGreen(green / denominator)
// .setBlue(blue / denominator);
// int alpha = color.getAlpha();
// if (alpha != 255) {
// result.setAlpha(
// FloatValue
// .newBuilder()
// .setValue(((float) alpha) / denominator)
// .build());
// }
// return resultBuilder.build();
// }
// // ...
//
// Example (iOS / Obj-C):
//
// // ...
// static UIColor* fromProto(Color* protocolor) {
// float red = [protocolor red];
// float green = [protocolor green];
// float blue = [protocolor blue];
// FloatValue* alpha_wrapper = [protocolor alpha];
// float alpha = 1.0;
// if (alpha_wrapper != nil) {
// alpha = [alpha_wrapper value];
// }
// return [UIColor colorWithRed:red green:green blue:blue
// alpha:alpha];
// }
//
// static Color* toProto(UIColor* color) {
// CGFloat red, green, blue, alpha;
// if (![color getRed:&red green:&green blue:&blue
// alpha:&alpha]) {
// return nil;
// }
// Color* result = [[Color alloc] init];
// [result setRed:red];
// [result setGreen:green];
// [result setBlue:blue];
// if (alpha <= 0.9999) {
// [result setAlpha:floatWrapperWithValue(alpha)];
// }
// [result autorelease];
// return result;
// }
// // ...
//
// Example (JavaScript):
//
// // ...
//
// var protoToCssColor = function(rgb_color) {
// var redFrac = rgb_color.red || 0.0;
// var greenFrac = rgb_color.green || 0.0;
// var blueFrac = rgb_color.blue || 0.0;
// var red = Math.floor(redFrac * 255);
// var green = Math.floor(greenFrac * 255);
// var blue = Math.floor(blueFrac * 255);
//
// if (!('alpha' in rgb_color)) {
// return rgbToCssColor_(red, green, blue);
// }
//
// var alphaFrac = rgb_color.alpha.value || 0.0;
// var rgbParams = [red, green, blue].join(',');
// return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
// };
//
// var rgbToCssColor_ = function(red, green, blue) {
// var rgbNumber = new Number((red << 16) | (green << 8) | blue);
// var hexString = rgbNumber.toString(16);
// var missingZeros = 6 - hexString.length;
// var resultBuilder = ['#'];
// for (var i = 0; i < missingZeros; i++) {
// resultBuilder.push('0');
// }
// resultBuilder.push(hexString);
// return resultBuilder.join('');
// };
//
// // ...
type Color struct {
// Alpha: The fraction of this color that should be applied to the
// pixel. That is,
// the final pixel color is defined by the equation:
//
// pixel color = alpha * (this color) + (1.0 - alpha) * (background
// color)
//
// This means that a value of 1.0 corresponds to a solid color,
// whereas
// a value of 0.0 corresponds to a completely transparent color.
// This
// uses a wrapper message rather than a simple float scalar so that it
// is
// possible to distinguish between a default value and the value being
// unset.
// If omitted, this color object is to be rendered as a solid color
// (as if the alpha value had been explicitly given with a value of
// 1.0).
Alpha float64 `json:"alpha,omitempty"`
// Blue: The amount of blue in the color as a value in the interval [0,
// 1].
Blue float64 `json:"blue,omitempty"`
// Green: The amount of green in the color as a value in the interval
// [0, 1].
Green float64 `json:"green,omitempty"`
// Red: The amount of red in the color as a value in the interval [0,
// 1].
Red float64 `json:"red,omitempty"`
// ForceSendFields is a list of field names (e.g. "Alpha") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Alpha") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Color) MarshalJSON() ([]byte, error) {
type NoMethod Color
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
func (s *Color) UnmarshalJSON(data []byte) error {
type NoMethod Color
var s1 struct {
Alpha gensupport.JSONFloat64 `json:"alpha"`
Blue gensupport.JSONFloat64 `json:"blue"`
Green gensupport.JSONFloat64 `json:"green"`
Red gensupport.JSONFloat64 `json:"red"`
*NoMethod
}
s1.NoMethod = (*NoMethod)(s)
if err := json.Unmarshal(data, &s1); err != nil {
return err
}
s.Alpha = float64(s1.Alpha)
s.Blue = float64(s1.Blue)
s.Green = float64(s1.Green)
s.Red = float64(s1.Red)
return nil
}
// FcmOptions: Platform independent options for features provided by the
// FCM SDKs.
type FcmOptions struct {
// AnalyticsLabel: Label associated with the message's analytics data.
AnalyticsLabel string `json:"analyticsLabel,omitempty"`
// ForceSendFields is a list of field names (e.g. "AnalyticsLabel") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "AnalyticsLabel") to
// include in API requests with the JSON null value. By default, fields
// with empty values are omitted from API requests. However, any field
// with an empty value appearing in NullFields will be sent to the
// server as null. It is an error if a field in this list has a
// non-empty value. This may be used to include null fields in Patch
// requests.
NullFields []string `json:"-"`
}
func (s *FcmOptions) MarshalJSON() ([]byte, error) {
type NoMethod FcmOptions
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// LightSettings: Settings to control notification LED.
type LightSettings struct {
// Color: Required. Set `color` of the LED
// with
// [google.type.Color](https://github.com/googleapis/googleapis/blob
// /master/google/type/color.proto).
Color *Color `json:"color,omitempty"`
// LightOffDuration: Required. Along with `light_on_duration `, define
// the blink rate of LED
// flashes. Resolution defined
// by
// [proto.Duration](https://developers.google.com/protocol-buffers/doc
// s/reference/google.protobuf#google.protobuf.Duration)
LightOffDuration string `json:"lightOffDuration,omitempty"`
// LightOnDuration: Required. Along with `light_off_duration`, define
// the blink rate of LED
// flashes. Resolution defined
// by
// [proto.Duration](https://developers.google.com/protocol-buffers/doc
// s/reference/google.protobuf#google.protobuf.Duration)
LightOnDuration string `json:"lightOnDuration,omitempty"`
// ForceSendFields is a list of field names (e.g. "Color") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Color") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *LightSettings) MarshalJSON() ([]byte, error) {
type NoMethod LightSettings
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Message: Message to send by Firebase Cloud Messaging Service.
type Message struct {
// Android: Input only. Android specific options for messages sent
// through
// [FCM connection server](https://goo.gl/4GLdUl).
Android *AndroidConfig `json:"android,omitempty"`
// Apns: Input only. [Apple Push Notification
// Service](https://goo.gl/MXRTPa)
// specific options.
Apns *ApnsConfig `json:"apns,omitempty"`
// Condition: Condition to send a message to,
// e.g. "'foo' in topics && 'bar' in topics".
Condition string `json:"condition,omitempty"`
// Data: Input only. Arbitrary key/value payload. The key should not be
// a reserved
// word ("from", "message_type", or any word starting with "google" or
// "gcm").
Data map[string]string `json:"data,omitempty"`
// FcmOptions: Input only. Template for FCM SDK feature options to use
// across all
// platforms.
FcmOptions *FcmOptions `json:"fcmOptions,omitempty"`
// Name: Output Only. The identifier of the message sent, in the format
// of
// `projects/*/messages/{message_id}`.
Name string `json:"name,omitempty"`
// Notification: Input only. Basic notification template to use across
// all platforms.