-
Notifications
You must be signed in to change notification settings - Fork 568
Expand file tree
/
Copy pathclient.rb
More file actions
6555 lines (6069 loc) · 352 KB
/
client.rb
File metadata and controls
6555 lines (6069 loc) · 352 KB
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
# frozen_string_literal: true
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
require "google/cloud/errors"
require "google/chat/v1/chat_service_pb"
module Google
module Apps
module Chat
module V1
module ChatService
##
# Client for the ChatService service.
#
# Enables developers to build Chat apps and
# integrations on Google Chat Platform.
#
class Client
# @private
API_VERSION = ""
# @private
DEFAULT_ENDPOINT_TEMPLATE = "chat.$UNIVERSE_DOMAIN$"
include Paths
# @private
attr_reader :chat_service_stub
##
# Configure the ChatService Client class.
#
# See {::Google::Apps::Chat::V1::ChatService::Client::Configuration}
# for a description of the configuration fields.
#
# @example
#
# # Modify the configuration for all ChatService clients
# ::Google::Apps::Chat::V1::ChatService::Client.configure do |config|
# config.timeout = 10.0
# end
#
# @yield [config] Configure the Client client.
# @yieldparam config [Client::Configuration]
#
# @return [Client::Configuration]
#
def self.configure
@configure ||= begin
namespace = ["Google", "Apps", "Chat", "V1"]
parent_config = while namespace.any?
parent_name = namespace.join "::"
parent_const = const_get parent_name
break parent_const.configure if parent_const.respond_to? :configure
namespace.pop
end
default_config = Client::Configuration.new parent_config
default_config.rpcs.create_message.timeout = 30.0
default_config.rpcs.create_message.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_messages.timeout = 30.0
default_config.rpcs.list_messages.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_memberships.timeout = 30.0
default_config.rpcs.list_memberships.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_membership.timeout = 30.0
default_config.rpcs.get_membership.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_message.timeout = 30.0
default_config.rpcs.get_message.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.update_message.timeout = 30.0
default_config.rpcs.update_message.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.delete_message.timeout = 30.0
default_config.rpcs.delete_message.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_attachment.timeout = 30.0
default_config.rpcs.get_attachment.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.upload_attachment.timeout = 30.0
default_config.rpcs.upload_attachment.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_spaces.timeout = 30.0
default_config.rpcs.list_spaces.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.search_spaces.timeout = 30.0
default_config.rpcs.search_spaces.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_space.timeout = 30.0
default_config.rpcs.get_space.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.create_space.timeout = 30.0
default_config.rpcs.create_space.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.set_up_space.timeout = 30.0
default_config.rpcs.set_up_space.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.update_space.timeout = 30.0
default_config.rpcs.update_space.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.delete_space.timeout = 30.0
default_config.rpcs.delete_space.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.complete_import_space.timeout = 30.0
default_config.rpcs.complete_import_space.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.find_direct_message.timeout = 30.0
default_config.rpcs.find_direct_message.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.find_group_chats.timeout = 30.0
default_config.rpcs.find_group_chats.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.create_membership.timeout = 30.0
default_config.rpcs.create_membership.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.update_membership.timeout = 30.0
default_config.rpcs.update_membership.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.delete_membership.timeout = 30.0
default_config.rpcs.delete_membership.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.create_reaction.timeout = 30.0
default_config.rpcs.create_reaction.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_reactions.timeout = 30.0
default_config.rpcs.list_reactions.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.delete_reaction.timeout = 30.0
default_config.rpcs.delete_reaction.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.create_custom_emoji.timeout = 30.0
default_config.rpcs.create_custom_emoji.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_custom_emoji.timeout = 30.0
default_config.rpcs.get_custom_emoji.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_custom_emojis.timeout = 30.0
default_config.rpcs.list_custom_emojis.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.delete_custom_emoji.timeout = 30.0
default_config.rpcs.delete_custom_emoji.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_space_read_state.timeout = 30.0
default_config.rpcs.get_space_read_state.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.update_space_read_state.timeout = 30.0
default_config.rpcs.update_space_read_state.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_thread_read_state.timeout = 30.0
default_config.rpcs.get_thread_read_state.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_space_event.timeout = 30.0
default_config.rpcs.get_space_event.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_space_events.timeout = 30.0
default_config.rpcs.list_space_events.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.get_space_notification_setting.timeout = 30.0
default_config.rpcs.get_space_notification_setting.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.update_space_notification_setting.timeout = 30.0
default_config.rpcs.update_space_notification_setting.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.create_section.timeout = 30.0
default_config.rpcs.create_section.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.delete_section.timeout = 30.0
default_config.rpcs.delete_section.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.update_section.timeout = 30.0
default_config.rpcs.update_section.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_sections.timeout = 30.0
default_config.rpcs.list_sections.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.position_section.timeout = 30.0
default_config.rpcs.position_section.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.list_section_items.timeout = 30.0
default_config.rpcs.list_section_items.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config.rpcs.move_section_item.timeout = 30.0
default_config.rpcs.move_section_item.retry_policy = {
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
}
default_config
end
yield @configure if block_given?
@configure
end
##
# Configure the ChatService Client instance.
#
# The configuration is set to the derived mode, meaning that values can be changed,
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
# should be made on {Client.configure}.
#
# See {::Google::Apps::Chat::V1::ChatService::Client::Configuration}
# for a description of the configuration fields.
#
# @yield [config] Configure the Client client.
# @yieldparam config [Client::Configuration]
#
# @return [Client::Configuration]
#
def configure
yield @config if block_given?
@config
end
##
# The effective universe domain
#
# @return [String]
#
def universe_domain
@chat_service_stub.universe_domain
end
##
# Create a new ChatService client object.
#
# @example
#
# # Create a client using the default configuration
# client = ::Google::Apps::Chat::V1::ChatService::Client.new
#
# # Create a client using a custom configuration
# client = ::Google::Apps::Chat::V1::ChatService::Client.new do |config|
# config.timeout = 10.0
# end
#
# @yield [config] Configure the ChatService client.
# @yieldparam config [Client::Configuration]
#
def initialize
# These require statements are intentionally placed here to initialize
# the gRPC module only when it's required.
# See https://github.com/googleapis/toolkit/issues/446
require "gapic/grpc"
require "google/chat/v1/chat_service_services_pb"
# Create the configuration object
@config = Configuration.new Client.configure
# Yield the configuration if needed
yield @config if block_given?
# Create credentials
credentials = @config.credentials
# Use self-signed JWT if the endpoint is unchanged from default,
# but only if the default endpoint does not have a region prefix.
enable_self_signed_jwt = @config.endpoint.nil? ||
(@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
!@config.endpoint.split(".").first.include?("-"))
credentials ||= Credentials.default scope: @config.scope,
enable_self_signed_jwt: enable_self_signed_jwt
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
credentials = Credentials.new credentials, scope: @config.scope
end
@quota_project_id = @config.quota_project
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
@chat_service_stub = ::Gapic::ServiceStub.new(
::Google::Apps::Chat::V1::ChatService::Stub,
credentials: credentials,
endpoint: @config.endpoint,
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
universe_domain: @config.universe_domain,
channel_args: @config.channel_args,
interceptors: @config.interceptors,
channel_pool_config: @config.channel_pool,
logger: @config.logger
)
@chat_service_stub.stub_logger&.info do |entry|
entry.set_system_name
entry.set_service
entry.message = "Created client for #{entry.service}"
entry.set_credentials_fields credentials
entry.set "customEndpoint", @config.endpoint if @config.endpoint
entry.set "defaultTimeout", @config.timeout if @config.timeout
entry.set "quotaProject", @quota_project_id if @quota_project_id
end
end
##
# The logger used for request/response debug logging.
#
# @return [Logger]
#
def logger
@chat_service_stub.logger
end
# Service calls
##
# Creates a message in a Google Chat space. For an example, see [Send a
# message](https://developers.google.com/workspace/chat/create-messages).
#
# Supports the following types of
# [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
#
# - [App
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
# with the authorization scope:
# - `https://www.googleapis.com/auth/chat.bot`
# - [User
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
# with one of the following authorization scopes:
# - `https://www.googleapis.com/auth/chat.messages.create`
# - `https://www.googleapis.com/auth/chat.messages`
# - `https://www.googleapis.com/auth/chat.import` (import mode spaces
# only)
#
# Chat attributes the message sender differently depending on the type of
# authentication that you use in your request.
#
# The following image shows how Chat attributes a message when you use app
# authentication. Chat displays the Chat app as the message
# sender. The content of the message can contain text (`text`), cards
# (`cardsV2`), and accessory widgets (`accessoryWidgets`).
#
# 
#
# The following image shows how Chat attributes a message when you use user
# authentication. Chat displays the user as the message sender and attributes
# the Chat app to the message by displaying its name. The content of message
# can only contain text (`text`).
#
# 
#
# The maximum message size, including the message contents, is 32,000 bytes.
#
# For
# [webhook](https://developers.google.com/workspace/chat/quickstart/webhooks)
# requests, the response doesn't contain the full message. The response only
# populates the `name` and `thread.name` fields in addition to the
# information that was in the request.
#
# @overload create_message(request, options = nil)
# Pass arguments to `create_message` via a request object, either of type
# {::Google::Apps::Chat::V1::CreateMessageRequest} or an equivalent Hash.
#
# @param request [::Google::Apps::Chat::V1::CreateMessageRequest, ::Hash]
# A request object representing the call parameters. Required. To specify no
# parameters, or to keep all the default parameter values, pass an empty Hash.
# @param options [::Gapic::CallOptions, ::Hash]
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
#
# @overload create_message(parent: nil, message: nil, thread_key: nil, request_id: nil, message_reply_option: nil, message_id: nil, create_message_notification_options: nil)
# Pass arguments to `create_message` via keyword arguments. Note that at
# least one keyword argument is required. To specify no parameters, or to keep all
# the default parameter values, pass an empty Hash as a request object (see above).
#
# @param parent [::String]
# Required. The resource name of the space in which to create a message.
#
# Format: `spaces/{space}`
# @param message [::Google::Apps::Chat::V1::Message, ::Hash]
# Required. Message body.
# @param thread_key [::String]
# Optional. Deprecated: Use
# {::Google::Apps::Chat::V1::Thread#thread_key thread.thread_key} instead. ID for the
# thread. Supports up to 4000 characters. To start or add to a thread, create
# a message and specify a `threadKey` or the
# {::Google::Apps::Chat::V1::Thread#name thread.name}. For example usage, see [Start or
# reply to a message
# thread](https://developers.google.com/workspace/chat/create-messages#create-message-thread).
# @param request_id [::String]
# Optional. A unique request ID for this message. Specifying an existing
# request ID returns the message created with that ID instead of creating a
# new message.
# @param message_reply_option [::Google::Apps::Chat::V1::CreateMessageRequest::MessageReplyOption]
# Optional. Specifies whether a message starts a thread or replies to one.
# Only supported in named spaces.
#
# When [responding to user
# interactions](https://developers.google.com/workspace/chat/receive-respond-interactions),
# this field is ignored. For interactions within a thread, the reply is
# created in the same thread. Otherwise, the reply is created as a new
# thread.
# @param message_id [::String]
# Optional. A custom ID for a message. Lets Chat apps get, update, or delete
# a message without needing to store the system-assigned ID in the message's
# resource name (represented in the message `name` field).
#
# The value for this field must meet the following requirements:
#
# * Begins with `client-`. For example, `client-custom-name` is a valid
# custom ID, but `custom-name` is not.
# * Contains up to 63 characters and only lowercase letters, numbers, and
# hyphens.
# * Is unique within a space. A Chat app can't use the same custom ID for
# different messages.
#
# For details, see [Name a
# message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message).
# @param create_message_notification_options [::Google::Apps::Chat::V1::CreateMessageNotificationOptions, ::Hash]
# Optional. Controls the notification behavior when the message is posted.
# To learn more, see [Force notifications or send silent
# messages](https://developer.google.com/workspace/chat/create-messages#force-notify-silent).
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Google::Apps::Chat::V1::Message]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Google::Apps::Chat::V1::Message]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
# @example Basic example
# require "google/apps/chat/v1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Apps::Chat::V1::ChatService::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Apps::Chat::V1::CreateMessageRequest.new
#
# # Call the create_message method.
# result = client.create_message request
#
# # The returned object is of type Google::Apps::Chat::V1::Message.
# p result
#
def create_message request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::CreateMessageRequest
# Converts hash and nil to an options object
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
metadata = @config.rpcs.create_message.metadata.to_h
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
lib_name: @config.lib_name, lib_version: @config.lib_version,
gapic_version: ::Google::Apps::Chat::V1::VERSION
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
header_params = {}
if request.parent
header_params["parent"] = request.parent
end
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
metadata[:"x-goog-request-params"] ||= request_params_header
options.apply_defaults timeout: @config.rpcs.create_message.timeout,
metadata: metadata,
retry_policy: @config.rpcs.create_message.retry_policy
options.apply_defaults timeout: @config.timeout,
metadata: @config.metadata,
retry_policy: @config.retry_policy
@chat_service_stub.call_rpc :create_message, request, options: options do |response, operation|
yield response, operation if block_given?
end
rescue ::GRPC::BadStatus => e
raise ::Google::Cloud::Error.from_error(e)
end
##
# Lists messages in a space that the caller is a member of, including
# messages from blocked members and spaces. System messages, like those
# announcing new space members, aren't included. If you list messages from a
# space with no messages, the response is an empty object. When using a
# REST/HTTP interface, the response contains an empty JSON object, `{}`.
# For an example, see
# [List
# messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/list).
#
# Supports the following types of
# [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
#
# - [App
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
# with [administrator
# approval](https://support.google.com/a?p=chat-app-auth)
# with the authorization scope:
# - `https://www.googleapis.com/auth/chat.app.messages.readonly`. When
# using this authentication scope, this method only returns public
# messages in a space. It doesn't include private messages.
#
# - [User
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
# with one of the following authorization scopes:
# - `https://www.googleapis.com/auth/chat.messages.readonly`
# - `https://www.googleapis.com/auth/chat.messages`
# - `https://www.googleapis.com/auth/chat.import` (import mode spaces
# only)
#
# @overload list_messages(request, options = nil)
# Pass arguments to `list_messages` via a request object, either of type
# {::Google::Apps::Chat::V1::ListMessagesRequest} or an equivalent Hash.
#
# @param request [::Google::Apps::Chat::V1::ListMessagesRequest, ::Hash]
# A request object representing the call parameters. Required. To specify no
# parameters, or to keep all the default parameter values, pass an empty Hash.
# @param options [::Gapic::CallOptions, ::Hash]
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
#
# @overload list_messages(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil, show_deleted: nil)
# Pass arguments to `list_messages` via keyword arguments. Note that at
# least one keyword argument is required. To specify no parameters, or to keep all
# the default parameter values, pass an empty Hash as a request object (see above).
#
# @param parent [::String]
# Required. The resource name of the space to list messages from.
#
# Format: `spaces/{space}`
# @param page_size [::Integer]
# Optional. The maximum number of messages returned. The service might return
# fewer messages than this value.
#
# If unspecified, at most 25 are returned.
#
# The maximum value is 1000. If you use a value more than 1000, it's
# automatically changed to 1000.
#
# Negative values return an `INVALID_ARGUMENT` error.
# @param page_token [::String]
# Optional. A page token received from a previous list messages call. Provide
# this parameter to retrieve the subsequent page.
#
# When paginating, all other parameters provided should match the call that
# provided the page token. Passing different values to the other parameters
# might lead to unexpected results.
# @param filter [::String]
# Optional. A query filter.
#
# You can filter messages by date (`create_time`) and thread (`thread.name`).
#
# To filter messages by the date they were created, specify the `create_time`
# with a timestamp in [RFC-3339](https://www.rfc-editor.org/rfc/rfc3339)
# format and double quotation marks. For example,
# `"2023-04-21T11:30:00-04:00"`. You can use the greater than operator `>` to
# list messages that were created after a timestamp, or the less than
# operator `<` to list messages that were created before a timestamp. To
# filter messages within a time interval, use the `AND` operator between two
# timestamps.
#
# To filter by thread, specify the `thread.name`, formatted as
# `spaces/{space}/threads/{thread}`. You can only specify one
# `thread.name` per query.
#
# To filter by both thread and date, use the `AND` operator in your query.
#
# For example, the following queries are valid:
#
# ```
# create_time > "2012-04-21T11:30:00-04:00"
#
# create_time > "2012-04-21T11:30:00-04:00" AND
# thread.name = spaces/AAAAAAAAAAA/threads/123
#
# create_time > "2012-04-21T11:30:00+00:00" AND
#
# create_time < "2013-01-01T00:00:00+00:00" AND
# thread.name = spaces/AAAAAAAAAAA/threads/123
#
# thread.name = spaces/AAAAAAAAAAA/threads/123
# ```
#
# Invalid queries are rejected by the server with an `INVALID_ARGUMENT`
# error.
# @param order_by [::String]
# Optional. How the list of messages is ordered. Specify a value to order by
# an ordering operation. Valid ordering operation values are as follows:
#
# - `ASC` for ascending.
#
# - `DESC` for descending.
#
# The default ordering is `create_time ASC`.
# @param show_deleted [::Boolean]
# Optional. Whether to include deleted messages. Deleted messages include
# deleted time and metadata about their deletion, but message content is
# unavailable.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Apps::Chat::V1::Message>]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Gapic::PagedEnumerable<::Google::Apps::Chat::V1::Message>]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
# @example Basic example
# require "google/apps/chat/v1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Apps::Chat::V1::ChatService::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Apps::Chat::V1::ListMessagesRequest.new
#
# # Call the list_messages method.
# result = client.list_messages request
#
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
# # over elements, and API calls will be issued to fetch pages as needed.
# result.each do |item|
# # Each element is of type ::Google::Apps::Chat::V1::Message.
# p item
# end
#
def list_messages request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::ListMessagesRequest
# Converts hash and nil to an options object
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
metadata = @config.rpcs.list_messages.metadata.to_h
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
lib_name: @config.lib_name, lib_version: @config.lib_version,
gapic_version: ::Google::Apps::Chat::V1::VERSION
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
header_params = {}
if request.parent
header_params["parent"] = request.parent
end
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
metadata[:"x-goog-request-params"] ||= request_params_header
options.apply_defaults timeout: @config.rpcs.list_messages.timeout,
metadata: metadata,
retry_policy: @config.rpcs.list_messages.retry_policy
options.apply_defaults timeout: @config.timeout,
metadata: @config.metadata,
retry_policy: @config.retry_policy
@chat_service_stub.call_rpc :list_messages, request, options: options do |response, operation|
response = ::Gapic::PagedEnumerable.new @chat_service_stub, :list_messages, request, response, operation, options
yield response, operation if block_given?
throw :response, response
end
rescue ::GRPC::BadStatus => e
raise ::Google::Cloud::Error.from_error(e)
end
##
# Lists memberships in a space. For an example, see [List users and Google
# Chat apps in a
# space](https://developers.google.com/workspace/chat/list-members). Listing
# memberships with [app
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
# lists memberships in spaces that the Chat app has
# access to, but excludes Chat app memberships,
# including its own. Listing memberships with
# [User
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
# lists memberships in spaces that the authenticated user has access to.
#
# Supports the following types of
# [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
#
# - [App
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
# with one of the following authorization scopes:
# - `https://www.googleapis.com/auth/chat.bot`
# - `https://www.googleapis.com/auth/chat.app.memberships` (requires
# [administrator approval](https://support.google.com/a?p=chat-app-auth))
#
# - [User
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
# with one of the following authorization scopes:
# - `https://www.googleapis.com/auth/chat.memberships.readonly`
# - `https://www.googleapis.com/auth/chat.memberships`
# - `https://www.googleapis.com/auth/chat.import` (import mode spaces
# only)
# - User authentication grants administrator privileges when an
# administrator account authenticates, `use_admin_access` is `true`, and
# one of the following authorization scopes is used:
# - `https://www.googleapis.com/auth/chat.admin.memberships.readonly`
# - `https://www.googleapis.com/auth/chat.admin.memberships`
#
# @overload list_memberships(request, options = nil)
# Pass arguments to `list_memberships` via a request object, either of type
# {::Google::Apps::Chat::V1::ListMembershipsRequest} or an equivalent Hash.
#
# @param request [::Google::Apps::Chat::V1::ListMembershipsRequest, ::Hash]
# A request object representing the call parameters. Required. To specify no
# parameters, or to keep all the default parameter values, pass an empty Hash.
# @param options [::Gapic::CallOptions, ::Hash]
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
#
# @overload list_memberships(parent: nil, page_size: nil, page_token: nil, filter: nil, show_groups: nil, show_invited: nil, use_admin_access: nil)
# Pass arguments to `list_memberships` via keyword arguments. Note that at
# least one keyword argument is required. To specify no parameters, or to keep all
# the default parameter values, pass an empty Hash as a request object (see above).
#
# @param parent [::String]
# Required. The resource name of the space for which to fetch a membership
# list.
#
# Format: spaces/\\{space}
# @param page_size [::Integer]
# Optional. The maximum number of memberships to return. The service might
# return fewer than this value.
#
# If unspecified, at most 100 memberships are returned.
#
# The maximum value is 1000. If you use a value more than 1000, it's
# automatically changed to 1000.
#
# Negative values return an `INVALID_ARGUMENT` error.
# @param page_token [::String]
# Optional. A page token, received from a previous call to list memberships.
# Provide this parameter to retrieve the subsequent page.
#
# When paginating, all other parameters provided should match the call that
# provided the page token. Passing different values to the other parameters
# might lead to unexpected results.
# @param filter [::String]
# Optional. A query filter.
#
# You can filter memberships by a member's role
# ([`role`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.members#membershiprole))
# and type
# ([`member.type`](https://developers.google.com/workspace/chat/api/reference/rest/v1/User#type)).
#
# To filter by role, set `role` to `ROLE_MEMBER` or `ROLE_MANAGER`.
#
# To filter by type, set `member.type` to `HUMAN` or `BOT`. You can also
# filter for `member.type` using the `!=` operator.
#
# To filter by both role and type, use the `AND` operator. To filter by
# either role or type, use the `OR` operator.
#
# Either `member.type = "HUMAN"` or `member.type != "BOT"` is required
# when `use_admin_access` is set to true. Other member type filters will be
# rejected.
#
# For example, the following queries are valid:
#
# ```
# role = "ROLE_MANAGER" OR role = "ROLE_MEMBER"
# member.type = "HUMAN" AND role = "ROLE_MANAGER"
#
# member.type != "BOT"
# ```
#
# The following queries are invalid:
#
# ```
# member.type = "HUMAN" AND member.type = "BOT"
# role = "ROLE_MANAGER" AND role = "ROLE_MEMBER"
# ```
#
# Invalid queries are rejected by the server with an `INVALID_ARGUMENT`
# error.
# @param show_groups [::Boolean]
# Optional. When `true`, also returns memberships associated with a
# {::Google::Apps::Chat::V1::Membership#group_member Google Group}, in
# addition to other types of memberships. If a
# {::Google::Apps::Chat::V1::ListMembershipsRequest#filter filter} is set,
# {::Google::Apps::Chat::V1::Membership#group_member Google Group}
# memberships that don't match the filter criteria aren't returned.
# @param show_invited [::Boolean]
# Optional. When `true`, also returns memberships associated with
# {::Google::Apps::Chat::V1::Membership::MembershipState::INVITED invited} members, in
# addition to other types of memberships. If a
# filter is set,
# {::Google::Apps::Chat::V1::Membership::MembershipState::INVITED invited} memberships
# that don't match the filter criteria aren't returned.
#
# Currently requires [user
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
# @param use_admin_access [::Boolean]
# Optional. When `true`, the method runs using the user's Google Workspace
# administrator privileges.
#
# The calling user must be a Google Workspace administrator with the
# [manage chat and spaces conversations
# privilege](https://support.google.com/a/answer/13369245).
#
# Requires either the `chat.admin.memberships.readonly` or
# `chat.admin.memberships` [OAuth 2.0
# scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
#
# Listing app memberships in a space isn't supported when using admin access.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Apps::Chat::V1::Membership>]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Gapic::PagedEnumerable<::Google::Apps::Chat::V1::Membership>]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
# @example Basic example
# require "google/apps/chat/v1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Apps::Chat::V1::ChatService::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Apps::Chat::V1::ListMembershipsRequest.new
#
# # Call the list_memberships method.
# result = client.list_memberships request
#
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
# # over elements, and API calls will be issued to fetch pages as needed.
# result.each do |item|
# # Each element is of type ::Google::Apps::Chat::V1::Membership.
# p item
# end
#
def list_memberships request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::ListMembershipsRequest
# Converts hash and nil to an options object
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
metadata = @config.rpcs.list_memberships.metadata.to_h
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
lib_name: @config.lib_name, lib_version: @config.lib_version,
gapic_version: ::Google::Apps::Chat::V1::VERSION
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
header_params = {}
if request.parent
header_params["parent"] = request.parent
end
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
metadata[:"x-goog-request-params"] ||= request_params_header
options.apply_defaults timeout: @config.rpcs.list_memberships.timeout,
metadata: metadata,
retry_policy: @config.rpcs.list_memberships.retry_policy
options.apply_defaults timeout: @config.timeout,
metadata: @config.metadata,
retry_policy: @config.retry_policy
@chat_service_stub.call_rpc :list_memberships, request, options: options do |response, operation|
response = ::Gapic::PagedEnumerable.new @chat_service_stub, :list_memberships, request, response, operation, options
yield response, operation if block_given?
throw :response, response
end
rescue ::GRPC::BadStatus => e
raise ::Google::Cloud::Error.from_error(e)
end
##
# Returns details about a membership. For an example, see
# [Get details about a user's or Google Chat app's
# membership](https://developers.google.com/workspace/chat/get-members).
#
# Supports the following types of
# [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
#
# - [App
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
# with one of the following authorization scopes:
# - `https://www.googleapis.com/auth/chat.bot`
# - `https://www.googleapis.com/auth/chat.app.memberships` (requires
# [administrator approval](https://support.google.com/a?p=chat-app-auth))
#
# - [User
# authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
# with one of the following authorization scopes:
# - `https://www.googleapis.com/auth/chat.memberships.readonly`
# - `https://www.googleapis.com/auth/chat.memberships`
# - User authentication grants administrator privileges when an
# administrator account authenticates, `use_admin_access` is `true`, and
# one of the following authorization scopes is used:
# - `https://www.googleapis.com/auth/chat.admin.memberships.readonly`
# - `https://www.googleapis.com/auth/chat.admin.memberships`
#