diff --git a/google-apps-chat-v1/.owlbot-manifest.json b/google-apps-chat-v1/.owlbot-manifest.json index 6b749df9be9f..780b98d1d9c4 100644 --- a/google-apps-chat-v1/.owlbot-manifest.json +++ b/google-apps-chat-v1/.owlbot-manifest.json @@ -27,6 +27,7 @@ "lib/google/chat/v1/action_status_pb.rb", "lib/google/chat/v1/annotation_pb.rb", "lib/google/chat/v1/attachment_pb.rb", + "lib/google/chat/v1/availability_pb.rb", "lib/google/chat/v1/chat_service_pb.rb", "lib/google/chat/v1/chat_service_services_pb.rb", "lib/google/chat/v1/contextual_addon_pb.rb", @@ -58,6 +59,7 @@ "proto_docs/google/chat/v1/action_status.rb", "proto_docs/google/chat/v1/annotation.rb", "proto_docs/google/chat/v1/attachment.rb", + "proto_docs/google/chat/v1/availability.rb", "proto_docs/google/chat/v1/contextual_addon.rb", "proto_docs/google/chat/v1/deletion_metadata.rb", "proto_docs/google/chat/v1/event_payload.rb", @@ -101,6 +103,7 @@ "snippets/chat_service/find_direct_message.rb", "snippets/chat_service/find_group_chats.rb", "snippets/chat_service/get_attachment.rb", + "snippets/chat_service/get_availability.rb", "snippets/chat_service/get_custom_emoji.rb", "snippets/chat_service/get_membership.rb", "snippets/chat_service/get_message.rb", @@ -117,10 +120,14 @@ "snippets/chat_service/list_sections.rb", "snippets/chat_service/list_space_events.rb", "snippets/chat_service/list_spaces.rb", + "snippets/chat_service/mark_as_active.rb", + "snippets/chat_service/mark_as_away.rb", + "snippets/chat_service/mark_as_do_not_disturb.rb", "snippets/chat_service/move_section_item.rb", "snippets/chat_service/position_section.rb", "snippets/chat_service/search_spaces.rb", "snippets/chat_service/set_up_space.rb", + "snippets/chat_service/update_availability.rb", "snippets/chat_service/update_membership.rb", "snippets/chat_service/update_message.rb", "snippets/chat_service/update_section.rb", diff --git a/google-apps-chat-v1/gapic_metadata.json b/google-apps-chat-v1/gapic_metadata.json index d87e86a2906f..f7cc7986af71 100644 --- a/google-apps-chat-v1/gapic_metadata.json +++ b/google-apps-chat-v1/gapic_metadata.json @@ -170,6 +170,31 @@ "get_thread_read_state" ] }, + "GetAvailability": { + "methods": [ + "get_availability" + ] + }, + "MarkAsActive": { + "methods": [ + "mark_as_active" + ] + }, + "MarkAsAway": { + "methods": [ + "mark_as_away" + ] + }, + "MarkAsDoNotDisturb": { + "methods": [ + "mark_as_do_not_disturb" + ] + }, + "UpdateAvailability": { + "methods": [ + "update_availability" + ] + }, "GetSpaceEvent": { "methods": [ "get_space_event" diff --git a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/client.rb b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/client.rb index 4a5d603edafa..1d99e604328e 100644 --- a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/client.rb +++ b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/client.rb @@ -231,6 +231,31 @@ def self.configure initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } + default_config.rpcs.get_availability.timeout = 30.0 + default_config.rpcs.get_availability.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.mark_as_active.timeout = 30.0 + default_config.rpcs.mark_as_active.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.mark_as_away.timeout = 30.0 + default_config.rpcs.mark_as_away.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.mark_as_do_not_disturb.timeout = 30.0 + default_config.rpcs.mark_as_do_not_disturb.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.update_availability.timeout = 30.0 + default_config.rpcs.update_availability.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] @@ -4749,6 +4774,542 @@ def get_thread_read_state request, options = nil raise ::Google::Cloud::Error.from_error(e) end + ## + # Returns availability information for a human user in Google Chat. For + # example, this can be used to check if a user is online or away, or to + # retrieve their custom status message. + # + # This method only retrieves the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with one of the following [authorization + # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability.readonly` + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload get_availability(request, options = nil) + # Pass arguments to `get_availability` via a request object, either of type + # {::Google::Apps::Chat::V1::GetAvailabilityRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::GetAvailabilityRequest, ::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 get_availability(name: nil) + # Pass arguments to `get_availability` 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 name [::String] + # Required. The resource name of the availability to retrieve. + # + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @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::GetAvailabilityRequest.new + # + # # Call the get_availability method. + # result = client.get_availability request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def get_availability request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::GetAvailabilityRequest + + # 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.get_availability.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.name + header_params["name"] = request.name + 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.get_availability.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_availability.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.call_rpc :get_availability, 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 + + ## + # Marks user as `ACTIVE` in Google Chat. + # + # Sets the user's availability state to `ACTIVE`. The `ACTIVE` state + # lasts until the specified expiration, at which point the user's state + # becomes `AWAY`. Note that if the user is actively using Chat, the `ACTIVE` + # state duration may extend beyond the provided expiration. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload mark_as_active(request, options = nil) + # Pass arguments to `mark_as_active` via a request object, either of type + # {::Google::Apps::Chat::V1::MarkAsActiveRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::MarkAsActiveRequest, ::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 mark_as_active(name: nil, expire_time: nil, ttl: nil) + # Pass arguments to `mark_as_active` 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 name [::String] + # Required. The resource name of the availability to mark as active. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @param expire_time [::Google::Protobuf::Timestamp, ::Hash] + # The absolute timestamp when the ACTIVE state expires. + # + # Note: The following parameters are mutually exclusive: `expire_time`, `ttl`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # @param ttl [::Google::Protobuf::Duration, ::Hash] + # The duration from the current time until the ACTIVE state expires. + # Using a short TTL can effectively reset the user's state to be based + # on activity after this brief duration. + # + # Note: The following parameters are mutually exclusive: `ttl`, `expire_time`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @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::MarkAsActiveRequest.new + # + # # Call the mark_as_active method. + # result = client.mark_as_active request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def mark_as_active request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::MarkAsActiveRequest + + # 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.mark_as_active.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.name + header_params["name"] = request.name + 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.mark_as_active.timeout, + metadata: metadata, + retry_policy: @config.rpcs.mark_as_active.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.call_rpc :mark_as_active, 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 + + ## + # Marks user as `AWAY` in Google Chat. + # + # Sets the user's state to away and is not affected by the user's + # activity. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload mark_as_away(request, options = nil) + # Pass arguments to `mark_as_away` via a request object, either of type + # {::Google::Apps::Chat::V1::MarkAsAwayRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::MarkAsAwayRequest, ::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 mark_as_away(name: nil) + # Pass arguments to `mark_as_away` 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 name [::String] + # Required. The resource name of the availability to mark as away. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @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::MarkAsAwayRequest.new + # + # # Call the mark_as_away method. + # result = client.mark_as_away request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def mark_as_away request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::MarkAsAwayRequest + + # 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.mark_as_away.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.name + header_params["name"] = request.name + 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.mark_as_away.timeout, + metadata: metadata, + retry_policy: @config.rpcs.mark_as_away.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.call_rpc :mark_as_away, 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 + + ## + # Marks user as `DO_NOT_DISTURB` in Google Chat. + # + # Sets a user's availability state to `DO_NOT_DISTURB` until a specified + # expiration time. + # When in `DO_NOT_DISTURB`, users typically won't receive notifications. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload mark_as_do_not_disturb(request, options = nil) + # Pass arguments to `mark_as_do_not_disturb` via a request object, either of type + # {::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest, ::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 mark_as_do_not_disturb(name: nil, expire_time: nil, ttl: nil) + # Pass arguments to `mark_as_do_not_disturb` 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 name [::String] + # Required. The resource name of the availability to mark as Do Not Disturb. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @param expire_time [::Google::Protobuf::Timestamp, ::Hash] + # The absolute timestamp when the DND state expires. + # + # Note: The following parameters are mutually exclusive: `expire_time`, `ttl`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # @param ttl [::Google::Protobuf::Duration, ::Hash] + # The duration from the current time until the DND state expires. + # + # Note: The following parameters are mutually exclusive: `ttl`, `expire_time`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @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::MarkAsDoNotDisturbRequest.new + # + # # Call the mark_as_do_not_disturb method. + # result = client.mark_as_do_not_disturb request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def mark_as_do_not_disturb request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest + + # 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.mark_as_do_not_disturb.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.name + header_params["name"] = request.name + 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.mark_as_do_not_disturb.timeout, + metadata: metadata, + retry_policy: @config.rpcs.mark_as_do_not_disturb.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.call_rpc :mark_as_do_not_disturb, 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 + + ## + # Updates availability information for a human user. Only the `custom_status` + # field can be updated through this method. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with one of the following [authorization + # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload update_availability(request, options = nil) + # Pass arguments to `update_availability` via a request object, either of type + # {::Google::Apps::Chat::V1::UpdateAvailabilityRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::UpdateAvailabilityRequest, ::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 update_availability(availability: nil, update_mask: nil) + # Pass arguments to `update_availability` 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 availability [::Google::Apps::Chat::V1::Availability, ::Hash] + # Required. The availability to update. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. The list of fields to update. + # The only field that can be updated is `custom_status`. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @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::UpdateAvailabilityRequest.new + # + # # Call the update_availability method. + # result = client.update_availability request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def update_availability request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::UpdateAvailabilityRequest + + # 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.update_availability.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.availability&.name + header_params["availability.name"] = request.availability.name + 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.update_availability.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_availability.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.call_rpc :update_availability, 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 + ## # Returns an event from a Google Chat space. The [event # payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload) @@ -6401,6 +6962,31 @@ class Rpcs # attr_reader :get_thread_read_state ## + # RPC-specific configuration for `get_availability` + # @return [::Gapic::Config::Method] + # + attr_reader :get_availability + ## + # RPC-specific configuration for `mark_as_active` + # @return [::Gapic::Config::Method] + # + attr_reader :mark_as_active + ## + # RPC-specific configuration for `mark_as_away` + # @return [::Gapic::Config::Method] + # + attr_reader :mark_as_away + ## + # RPC-specific configuration for `mark_as_do_not_disturb` + # @return [::Gapic::Config::Method] + # + attr_reader :mark_as_do_not_disturb + ## + # RPC-specific configuration for `update_availability` + # @return [::Gapic::Config::Method] + # + attr_reader :update_availability + ## # RPC-specific configuration for `get_space_event` # @return [::Gapic::Config::Method] # @@ -6522,6 +7108,16 @@ def initialize parent_rpcs = nil @update_space_read_state = ::Gapic::Config::Method.new update_space_read_state_config get_thread_read_state_config = parent_rpcs.get_thread_read_state if parent_rpcs.respond_to? :get_thread_read_state @get_thread_read_state = ::Gapic::Config::Method.new get_thread_read_state_config + get_availability_config = parent_rpcs.get_availability if parent_rpcs.respond_to? :get_availability + @get_availability = ::Gapic::Config::Method.new get_availability_config + mark_as_active_config = parent_rpcs.mark_as_active if parent_rpcs.respond_to? :mark_as_active + @mark_as_active = ::Gapic::Config::Method.new mark_as_active_config + mark_as_away_config = parent_rpcs.mark_as_away if parent_rpcs.respond_to? :mark_as_away + @mark_as_away = ::Gapic::Config::Method.new mark_as_away_config + mark_as_do_not_disturb_config = parent_rpcs.mark_as_do_not_disturb if parent_rpcs.respond_to? :mark_as_do_not_disturb + @mark_as_do_not_disturb = ::Gapic::Config::Method.new mark_as_do_not_disturb_config + update_availability_config = parent_rpcs.update_availability if parent_rpcs.respond_to? :update_availability + @update_availability = ::Gapic::Config::Method.new update_availability_config get_space_event_config = parent_rpcs.get_space_event if parent_rpcs.respond_to? :get_space_event @get_space_event = ::Gapic::Config::Method.new get_space_event_config list_space_events_config = parent_rpcs.list_space_events if parent_rpcs.respond_to? :list_space_events diff --git a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/credentials.rb b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/credentials.rb index 8f9eb35856cb..35eeb76568bb 100644 --- a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/credentials.rb +++ b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/credentials.rb @@ -55,6 +55,8 @@ class Credentials < ::Google::Auth::Credentials "https://www.googleapis.com/auth/chat.spaces", "https://www.googleapis.com/auth/chat.spaces.create", "https://www.googleapis.com/auth/chat.spaces.readonly", + "https://www.googleapis.com/auth/chat.users.availability", + "https://www.googleapis.com/auth/chat.users.availability.readonly", "https://www.googleapis.com/auth/chat.users.readstate", "https://www.googleapis.com/auth/chat.users.readstate.readonly", "https://www.googleapis.com/auth/chat.users.sections", diff --git a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/paths.rb b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/paths.rb index 71cf61467c27..a9550ccf4f6b 100644 --- a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/paths.rb +++ b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/paths.rb @@ -43,6 +43,20 @@ def attachment_path space:, message:, attachment: "spaces/#{space}/messages/#{message}/attachments/#{attachment}" end + ## + # Create a fully-qualified Availability resource string. + # + # The resource will be in the following format: + # + # `users/{user}/availability` + # + # @param user [String] + # + # @return [::String] + def availability_path user: + "users/#{user}/availability" + end + ## # Create a fully-qualified CustomEmoji resource string. # diff --git a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/client.rb b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/client.rb index 3655f64b1f23..9fff4b9e231b 100644 --- a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/client.rb +++ b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/client.rb @@ -233,6 +233,31 @@ def self.configure initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } + default_config.rpcs.get_availability.timeout = 30.0 + default_config.rpcs.get_availability.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.mark_as_active.timeout = 30.0 + default_config.rpcs.mark_as_active.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.mark_as_away.timeout = 30.0 + default_config.rpcs.mark_as_away.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.mark_as_do_not_disturb.timeout = 30.0 + default_config.rpcs.mark_as_do_not_disturb.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config.rpcs.update_availability.timeout = 30.0 + default_config.rpcs.update_availability.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] @@ -4582,6 +4607,507 @@ def get_thread_read_state request, options = nil raise ::Google::Cloud::Error.from_error(e) end + ## + # Returns availability information for a human user in Google Chat. For + # example, this can be used to check if a user is online or away, or to + # retrieve their custom status message. + # + # This method only retrieves the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with one of the following [authorization + # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability.readonly` + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload get_availability(request, options = nil) + # Pass arguments to `get_availability` via a request object, either of type + # {::Google::Apps::Chat::V1::GetAvailabilityRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::GetAvailabilityRequest, ::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 get_availability(name: nil) + # Pass arguments to `get_availability` 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 name [::String] + # Required. The resource name of the availability to retrieve. + # + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @raise [::Google::Cloud::Error] if the REST call 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::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Apps::Chat::V1::GetAvailabilityRequest.new + # + # # Call the get_availability method. + # result = client.get_availability request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def get_availability request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::GetAvailabilityRequest + + # 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 + call_metadata = @config.rpcs.get_availability.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_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, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_availability.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_availability.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.get_availability request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Marks user as `ACTIVE` in Google Chat. + # + # Sets the user's availability state to `ACTIVE`. The `ACTIVE` state + # lasts until the specified expiration, at which point the user's state + # becomes `AWAY`. Note that if the user is actively using Chat, the `ACTIVE` + # state duration may extend beyond the provided expiration. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload mark_as_active(request, options = nil) + # Pass arguments to `mark_as_active` via a request object, either of type + # {::Google::Apps::Chat::V1::MarkAsActiveRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::MarkAsActiveRequest, ::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 mark_as_active(name: nil, expire_time: nil, ttl: nil) + # Pass arguments to `mark_as_active` 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 name [::String] + # Required. The resource name of the availability to mark as active. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @param expire_time [::Google::Protobuf::Timestamp, ::Hash] + # The absolute timestamp when the ACTIVE state expires. + # + # Note: The following parameters are mutually exclusive: `expire_time`, `ttl`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # @param ttl [::Google::Protobuf::Duration, ::Hash] + # The duration from the current time until the ACTIVE state expires. + # Using a short TTL can effectively reset the user's state to be based + # on activity after this brief duration. + # + # Note: The following parameters are mutually exclusive: `ttl`, `expire_time`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @raise [::Google::Cloud::Error] if the REST call 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::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Apps::Chat::V1::MarkAsActiveRequest.new + # + # # Call the mark_as_active method. + # result = client.mark_as_active request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def mark_as_active request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::MarkAsActiveRequest + + # 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 + call_metadata = @config.rpcs.mark_as_active.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_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, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.mark_as_active.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.mark_as_active.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.mark_as_active request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Marks user as `AWAY` in Google Chat. + # + # Sets the user's state to away and is not affected by the user's + # activity. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload mark_as_away(request, options = nil) + # Pass arguments to `mark_as_away` via a request object, either of type + # {::Google::Apps::Chat::V1::MarkAsAwayRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::MarkAsAwayRequest, ::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 mark_as_away(name: nil) + # Pass arguments to `mark_as_away` 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 name [::String] + # Required. The resource name of the availability to mark as away. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @raise [::Google::Cloud::Error] if the REST call 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::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Apps::Chat::V1::MarkAsAwayRequest.new + # + # # Call the mark_as_away method. + # result = client.mark_as_away request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def mark_as_away request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::MarkAsAwayRequest + + # 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 + call_metadata = @config.rpcs.mark_as_away.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_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, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.mark_as_away.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.mark_as_away.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.mark_as_away request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Marks user as `DO_NOT_DISTURB` in Google Chat. + # + # Sets a user's availability state to `DO_NOT_DISTURB` until a specified + # expiration time. + # When in `DO_NOT_DISTURB`, users typically won't receive notifications. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload mark_as_do_not_disturb(request, options = nil) + # Pass arguments to `mark_as_do_not_disturb` via a request object, either of type + # {::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest, ::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 mark_as_do_not_disturb(name: nil, expire_time: nil, ttl: nil) + # Pass arguments to `mark_as_do_not_disturb` 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 name [::String] + # Required. The resource name of the availability to mark as Do Not Disturb. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @param expire_time [::Google::Protobuf::Timestamp, ::Hash] + # The absolute timestamp when the DND state expires. + # + # Note: The following parameters are mutually exclusive: `expire_time`, `ttl`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # @param ttl [::Google::Protobuf::Duration, ::Hash] + # The duration from the current time until the DND state expires. + # + # Note: The following parameters are mutually exclusive: `ttl`, `expire_time`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @raise [::Google::Cloud::Error] if the REST call 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::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest.new + # + # # Call the mark_as_do_not_disturb method. + # result = client.mark_as_do_not_disturb request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def mark_as_do_not_disturb request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest + + # 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 + call_metadata = @config.rpcs.mark_as_do_not_disturb.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_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, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.mark_as_do_not_disturb.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.mark_as_do_not_disturb.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.mark_as_do_not_disturb request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates availability information for a human user. Only the `custom_status` + # field can be updated through this method. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with one of the following [authorization + # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + # + # @overload update_availability(request, options = nil) + # Pass arguments to `update_availability` via a request object, either of type + # {::Google::Apps::Chat::V1::UpdateAvailabilityRequest} or an equivalent Hash. + # + # @param request [::Google::Apps::Chat::V1::UpdateAvailabilityRequest, ::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 update_availability(availability: nil, update_mask: nil) + # Pass arguments to `update_availability` 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 availability [::Google::Apps::Chat::V1::Availability, ::Hash] + # Required. The availability to update. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. The list of fields to update. + # The only field that can be updated is `custom_status`. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # + # @raise [::Google::Cloud::Error] if the REST call 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::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Apps::Chat::V1::UpdateAvailabilityRequest.new + # + # # Call the update_availability method. + # result = client.update_availability request + # + # # The returned object is of type Google::Apps::Chat::V1::Availability. + # p result + # + def update_availability request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::UpdateAvailabilityRequest + + # 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 + call_metadata = @config.rpcs.update_availability.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_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, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_availability.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_availability.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @chat_service_stub.update_availability request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + ## # Returns an event from a Google Chat space. The [event # payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload) @@ -6120,6 +6646,31 @@ class Rpcs # attr_reader :get_thread_read_state ## + # RPC-specific configuration for `get_availability` + # @return [::Gapic::Config::Method] + # + attr_reader :get_availability + ## + # RPC-specific configuration for `mark_as_active` + # @return [::Gapic::Config::Method] + # + attr_reader :mark_as_active + ## + # RPC-specific configuration for `mark_as_away` + # @return [::Gapic::Config::Method] + # + attr_reader :mark_as_away + ## + # RPC-specific configuration for `mark_as_do_not_disturb` + # @return [::Gapic::Config::Method] + # + attr_reader :mark_as_do_not_disturb + ## + # RPC-specific configuration for `update_availability` + # @return [::Gapic::Config::Method] + # + attr_reader :update_availability + ## # RPC-specific configuration for `get_space_event` # @return [::Gapic::Config::Method] # @@ -6241,6 +6792,16 @@ def initialize parent_rpcs = nil @update_space_read_state = ::Gapic::Config::Method.new update_space_read_state_config get_thread_read_state_config = parent_rpcs.get_thread_read_state if parent_rpcs.respond_to? :get_thread_read_state @get_thread_read_state = ::Gapic::Config::Method.new get_thread_read_state_config + get_availability_config = parent_rpcs.get_availability if parent_rpcs.respond_to? :get_availability + @get_availability = ::Gapic::Config::Method.new get_availability_config + mark_as_active_config = parent_rpcs.mark_as_active if parent_rpcs.respond_to? :mark_as_active + @mark_as_active = ::Gapic::Config::Method.new mark_as_active_config + mark_as_away_config = parent_rpcs.mark_as_away if parent_rpcs.respond_to? :mark_as_away + @mark_as_away = ::Gapic::Config::Method.new mark_as_away_config + mark_as_do_not_disturb_config = parent_rpcs.mark_as_do_not_disturb if parent_rpcs.respond_to? :mark_as_do_not_disturb + @mark_as_do_not_disturb = ::Gapic::Config::Method.new mark_as_do_not_disturb_config + update_availability_config = parent_rpcs.update_availability if parent_rpcs.respond_to? :update_availability + @update_availability = ::Gapic::Config::Method.new update_availability_config get_space_event_config = parent_rpcs.get_space_event if parent_rpcs.respond_to? :get_space_event @get_space_event = ::Gapic::Config::Method.new get_space_event_config list_space_events_config = parent_rpcs.list_space_events if parent_rpcs.respond_to? :list_space_events diff --git a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/service_stub.rb b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/service_stub.rb index 959013011914..c51be812100e 100644 --- a/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/service_stub.rb +++ b/google-apps-chat-v1/lib/google/apps/chat/v1/chat_service/rest/service_stub.rb @@ -1353,6 +1353,206 @@ def get_thread_read_state request_pb, options = nil end end + ## + # Baseline implementation for the get_availability REST call + # + # @param request_pb [::Google::Apps::Chat::V1::GetAvailabilityRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # A result object deserialized from the server's reply + def get_availability request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_availability_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + method_name: "get_availability", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Apps::Chat::V1::Availability.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the mark_as_active REST call + # + # @param request_pb [::Google::Apps::Chat::V1::MarkAsActiveRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # A result object deserialized from the server's reply + def mark_as_active request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_mark_as_active_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + method_name: "mark_as_active", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Apps::Chat::V1::Availability.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the mark_as_away REST call + # + # @param request_pb [::Google::Apps::Chat::V1::MarkAsAwayRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # A result object deserialized from the server's reply + def mark_as_away request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_mark_as_away_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + method_name: "mark_as_away", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Apps::Chat::V1::Availability.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the mark_as_do_not_disturb REST call + # + # @param request_pb [::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # A result object deserialized from the server's reply + def mark_as_do_not_disturb request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_mark_as_do_not_disturb_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + method_name: "mark_as_do_not_disturb", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Apps::Chat::V1::Availability.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the update_availability REST call + # + # @param request_pb [::Google::Apps::Chat::V1::UpdateAvailabilityRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Apps::Chat::V1::Availability] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Apps::Chat::V1::Availability] + # A result object deserialized from the server's reply + def update_availability request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_availability_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + method_name: "update_availability", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Apps::Chat::V1::Availability.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + ## # Baseline implementation for the get_space_event REST call # @@ -2469,6 +2669,115 @@ def self.transcode_get_thread_read_state_request request_pb transcoder.transcode request_pb end + ## + # @private + # + # GRPC transcoding helper method for the get_availability REST call + # + # @param request_pb [::Google::Apps::Chat::V1::GetAvailabilityRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_availability_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^users/[^/]+/availability/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the mark_as_active REST call + # + # @param request_pb [::Google::Apps::Chat::V1::MarkAsActiveRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_mark_as_active_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{name}:markAsActive", + body: "*", + matches: [ + ["name", %r{^users/[^/]+/availability/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the mark_as_away REST call + # + # @param request_pb [::Google::Apps::Chat::V1::MarkAsAwayRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_mark_as_away_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{name}:markAsAway", + body: "*", + matches: [ + ["name", %r{^users/[^/]+/availability/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the mark_as_do_not_disturb REST call + # + # @param request_pb [::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_mark_as_do_not_disturb_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{name}:markAsDoNotDisturb", + body: "*", + matches: [ + ["name", %r{^users/[^/]+/availability/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_availability REST call + # + # @param request_pb [::Google::Apps::Chat::V1::UpdateAvailabilityRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_availability_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/v1/{availability.name}", + body: "availability", + matches: [ + ["availability.name", %r{^users/[^/]+/availability/?$}, false] + ] + ) + transcoder.transcode request_pb + end + ## # @private # diff --git a/google-apps-chat-v1/lib/google/chat/v1/availability_pb.rb b/google-apps-chat-v1/lib/google/chat/v1/availability_pb.rb new file mode 100644 index 000000000000..cfdae67559b2 --- /dev/null +++ b/google-apps-chat-v1/lib/google/chat/v1/availability_pb.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/chat/v1/availability.proto + +require 'google/protobuf' + +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/chat/v1/reaction_pb' +require 'google/protobuf/duration_pb' +require 'google/protobuf/field_mask_pb' +require 'google/protobuf/timestamp_pb' + + +descriptor_data = "\n!google/chat/v1/availability.proto\x12\x0egoogle.chat.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1dgoogle/chat/v1/reaction.proto\x1a\x1egoogle/protobuf/duration.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xa7\x03\n\x0c\x41vailability\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x36\n\x05state\x18\x02 \x01(\x0e\x32\".google.chat.v1.Availability.StateB\x03\xe0\x41\x03\x12L\n\x17\x64o_not_disturb_metadata\x18\x03 \x01(\x0b\x32$.google.chat.v1.DoNotDisturbMetadataB\x03\xe0\x41\x03H\x00\x12\x38\n\rcustom_status\x18\x04 \x01(\x0b\x32\x1c.google.chat.v1.CustomStatusB\x03\xe0\x41\x01\"R\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\n\n\x06\x41\x43TIVE\x10\x01\x12\x08\n\x04IDLE\x10\x02\x12\x08\n\x04\x41WAY\x10\x03\x12\x12\n\x0e\x44O_NOT_DISTURB\x10\x04:^\xea\x41[\n chat.googleapis.com/Availability\x12\x19users/{user}/availability*\x0e\x61vailabilities2\x0c\x61vailabilityB\x10\n\x0estate_metadata\"\xbc\x01\n\x0c\x43ustomStatus\x12\x11\n\x04text\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12)\n\x05\x65moji\x18\x02 \x01(\x0b\x32\x15.google.chat.v1.EmojiB\x03\xe0\x41\x02\x12\x31\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12-\n\x03ttl\x18\x04 \x01(\x0b\x32\x19.google.protobuf.DurationB\x03\xe0\x41\x04H\x00\x42\x0c\n\nexpiration\"P\n\x14\x44oNotDisturbMetadata\x12\x38\n\x0f\x65xpiration_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\"P\n\x16GetAvailabilityRequest\x12\x36\n\x04name\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n chat.googleapis.com/Availability\"\x8a\x01\n\x19UpdateAvailabilityRequest\x12\x37\n\x0c\x61vailability\x18\x01 \x01(\x0b\x32\x1c.google.chat.v1.AvailabilityB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\"\xb8\x01\n\x13MarkAsActiveRequest\x12\x36\n\x04name\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n chat.googleapis.com/Availability\x12\x31\n\x0b\x65xpire_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12(\n\x03ttl\x18\x03 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x42\x0c\n\nexpiration\"K\n\x11MarkAsAwayRequest\x12\x36\n\x04name\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n chat.googleapis.com/Availability\"\xbe\x01\n\x19MarkAsDoNotDisturbRequest\x12\x36\n\x04name\x18\x01 \x01(\tB(\xe0\x41\x02\xfa\x41\"\n chat.googleapis.com/Availability\x12\x31\n\x0b\x65xpire_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12(\n\x03ttl\x18\x03 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x42\x0c\n\nexpirationB\xaa\x01\n\x12\x63om.google.chat.v1B\x11\x41vailabilityProtoP\x01Z,cloud.google.com/go/chat/apiv1/chatpb;chatpb\xa2\x02\x0b\x44YNAPIProto\xaa\x02\x13Google.Apps.Chat.V1\xca\x02\x13Google\\Apps\\Chat\\V1\xea\x02\x16Google::Apps::Chat::V1b\x06proto3" + +pool = ::Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Google + module Apps + module Chat + module V1 + Availability = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.Availability").msgclass + Availability::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.Availability.State").enummodule + CustomStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.CustomStatus").msgclass + DoNotDisturbMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.DoNotDisturbMetadata").msgclass + GetAvailabilityRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.GetAvailabilityRequest").msgclass + UpdateAvailabilityRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.UpdateAvailabilityRequest").msgclass + MarkAsActiveRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.MarkAsActiveRequest").msgclass + MarkAsAwayRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.MarkAsAwayRequest").msgclass + MarkAsDoNotDisturbRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.chat.v1.MarkAsDoNotDisturbRequest").msgclass + end + end + end +end diff --git a/google-apps-chat-v1/lib/google/chat/v1/chat_service_pb.rb b/google-apps-chat-v1/lib/google/chat/v1/chat_service_pb.rb index 7670924d5cb7..0060333dd3ff 100644 --- a/google-apps-chat-v1/lib/google/chat/v1/chat_service_pb.rb +++ b/google-apps-chat-v1/lib/google/chat/v1/chat_service_pb.rb @@ -7,6 +7,7 @@ require 'google/api/annotations_pb' require 'google/api/client_pb' require 'google/chat/v1/attachment_pb' +require 'google/chat/v1/availability_pb' require 'google/chat/v1/membership_pb' require 'google/chat/v1/message_pb' require 'google/chat/v1/reaction_pb' @@ -20,7 +21,7 @@ require 'google/protobuf/empty_pb' -descriptor_data = "\n!google/chat/v1/chat_service.proto\x12\x0egoogle.chat.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/chat/v1/attachment.proto\x1a\x1fgoogle/chat/v1/membership.proto\x1a\x1cgoogle/chat/v1/message.proto\x1a\x1dgoogle/chat/v1/reaction.proto\x1a\x1cgoogle/chat/v1/section.proto\x1a\x1agoogle/chat/v1/space.proto\x1a google/chat/v1/space_event.proto\x1a/google/chat/v1/space_notification_setting.proto\x1a%google/chat/v1/space_read_state.proto\x1a google/chat/v1/space_setup.proto\x1a&google/chat/v1/thread_read_state.proto\x1a\x1bgoogle/protobuf/empty.proto2\xd1@\n\x0b\x43hatService\x12\x9b\x01\n\rCreateMessage\x12$.google.chat.v1.CreateMessageRequest\x1a\x17.google.chat.v1.Message\"K\xda\x41\x19parent,message,message_id\x82\xd3\xe4\x93\x02)\"\x1e/v1/{parent=spaces/*}/messages:\x07message\x12\x8a\x01\n\x0cListMessages\x12#.google.chat.v1.ListMessagesRequest\x1a$.google.chat.v1.ListMessagesResponse\"/\xda\x41\x06parent\x82\xd3\xe4\x93\x02 \x12\x1e/v1/{parent=spaces/*}/messages\x12\x92\x01\n\x0fListMemberships\x12&.google.chat.v1.ListMembershipsRequest\x1a\'.google.chat.v1.ListMembershipsResponse\".\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1/{parent=spaces/*}/members\x12\x7f\n\rGetMembership\x12$.google.chat.v1.GetMembershipRequest\x1a\x1a.google.chat.v1.Membership\",\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1/{name=spaces/*/members/*}\x12w\n\nGetMessage\x12!.google.chat.v1.GetMessageRequest\x1a\x17.google.chat.v1.Message\"-\xda\x41\x04name\x82\xd3\xe4\x93\x02 \x12\x1e/v1/{name=spaces/*/messages/*}\x12\xd1\x01\n\rUpdateMessage\x12$.google.chat.v1.UpdateMessageRequest\x1a\x17.google.chat.v1.Message\"\x80\x01\xda\x41\x13message,update_mask\x82\xd3\xe4\x93\x02\x64\x1a&/v1/{message.name=spaces/*/messages/*}:\x07messageZ12&/v1/{message.name=spaces/*/messages/*}:\x07message\x12|\n\rDeleteMessage\x12$.google.chat.v1.DeleteMessageRequest\x1a\x16.google.protobuf.Empty\"-\xda\x41\x04name\x82\xd3\xe4\x93\x02 *\x1e/v1/{name=spaces/*/messages/*}\x12\x8e\x01\n\rGetAttachment\x12$.google.chat.v1.GetAttachmentRequest\x1a\x1a.google.chat.v1.Attachment\";\xda\x41\x04name\x82\xd3\xe4\x93\x02.\x12,/v1/{name=spaces/*/messages/*/attachments/*}\x12\x9a\x01\n\x10UploadAttachment\x12\'.google.chat.v1.UploadAttachmentRequest\x1a(.google.chat.v1.UploadAttachmentResponse\"3\x82\xd3\xe4\x93\x02-\"(/v1/{parent=spaces/*}/attachments:upload:\x01*\x12j\n\nListSpaces\x12!.google.chat.v1.ListSpacesRequest\x1a\".google.chat.v1.ListSpacesResponse\"\x15\xda\x41\x00\x82\xd3\xe4\x93\x02\x0c\x12\n/v1/spaces\x12w\n\x0cSearchSpaces\x12#.google.chat.v1.SearchSpacesRequest\x1a$.google.chat.v1.SearchSpacesResponse\"\x1c\xda\x41\x00\x82\xd3\xe4\x93\x02\x13\x12\x11/v1/spaces:search\x12\x66\n\x08GetSpace\x12\x1f.google.chat.v1.GetSpaceRequest\x1a\x15.google.chat.v1.Space\"\"\xda\x41\x04name\x82\xd3\xe4\x93\x02\x15\x12\x13/v1/{name=spaces/*}\x12k\n\x0b\x43reateSpace\x12\".google.chat.v1.CreateSpaceRequest\x1a\x15.google.chat.v1.Space\"!\xda\x41\x05space\x82\xd3\xe4\x93\x02\x13\"\n/v1/spaces:\x05space\x12\x63\n\nSetUpSpace\x12!.google.chat.v1.SetUpSpaceRequest\x1a\x15.google.chat.v1.Space\"\x1b\x82\xd3\xe4\x93\x02\x15\"\x10/v1/spaces:setup:\x01*\x12\x86\x01\n\x0bUpdateSpace\x12\".google.chat.v1.UpdateSpaceRequest\x1a\x15.google.chat.v1.Space\"<\xda\x41\x11space,update_mask\x82\xd3\xe4\x93\x02\"2\x19/v1/{space.name=spaces/*}:\x05space\x12m\n\x0b\x44\x65leteSpace\x12\".google.chat.v1.DeleteSpaceRequest\x1a\x16.google.protobuf.Empty\"\"\xda\x41\x04name\x82\xd3\xe4\x93\x02\x15*\x13/v1/{name=spaces/*}\x12\x9d\x01\n\x13\x43ompleteImportSpace\x12*.google.chat.v1.CompleteImportSpaceRequest\x1a+.google.chat.v1.CompleteImportSpaceResponse\"-\x82\xd3\xe4\x93\x02\'\"\"/v1/{name=spaces/*}:completeImport:\x01*\x12z\n\x11\x46indDirectMessage\x12(.google.chat.v1.FindDirectMessageRequest\x1a\x15.google.chat.v1.Space\"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/v1/spaces:findDirectMessage\x12\x82\x01\n\x0e\x46indGroupChats\x12%.google.chat.v1.FindGroupChatsRequest\x1a&.google.chat.v1.FindGroupChatsResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/v1/spaces:findGroupChats\x12\x9e\x01\n\x10\x43reateMembership\x12\'.google.chat.v1.CreateMembershipRequest\x1a\x1a.google.chat.v1.Membership\"E\xda\x41\x11parent,membership\x82\xd3\xe4\x93\x02+\"\x1d/v1/{parent=spaces/*}/members:\nmembership\x12\xae\x01\n\x10UpdateMembership\x12\'.google.chat.v1.UpdateMembershipRequest\x1a\x1a.google.chat.v1.Membership\"U\xda\x41\x16membership,update_mask\x82\xd3\xe4\x93\x02\x36\x32(/v1/{membership.name=spaces/*/members/*}:\nmembership\x12\x85\x01\n\x10\x44\x65leteMembership\x12\'.google.chat.v1.DeleteMembershipRequest\x1a\x1a.google.chat.v1.Membership\",\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1f*\x1d/v1/{name=spaces/*/members/*}\x12\xa1\x01\n\x0e\x43reateReaction\x12%.google.chat.v1.CreateReactionRequest\x1a\x18.google.chat.v1.Reaction\"N\xda\x41\x0fparent,reaction\x82\xd3\xe4\x93\x02\x36\"*/v1/{parent=spaces/*/messages/*}/reactions:\x08reaction\x12\x99\x01\n\rListReactions\x12$.google.chat.v1.ListReactionsRequest\x1a%.google.chat.v1.ListReactionsResponse\";\xda\x41\x06parent\x82\xd3\xe4\x93\x02,\x12*/v1/{parent=spaces/*/messages/*}/reactions\x12\x8a\x01\n\x0e\x44\x65leteReaction\x12%.google.chat.v1.DeleteReactionRequest\x1a\x16.google.protobuf.Empty\"9\xda\x41\x04name\x82\xd3\xe4\x93\x02,**/v1/{name=spaces/*/messages/*/reactions/*}\x12\x91\x01\n\x11\x43reateCustomEmoji\x12(.google.chat.v1.CreateCustomEmojiRequest\x1a\x1b.google.chat.v1.CustomEmoji\"5\xda\x41\x0c\x63ustom_emoji\x82\xd3\xe4\x93\x02 \"\x10/v1/customEmojis:\x0c\x63ustom_emoji\x12~\n\x0eGetCustomEmoji\x12%.google.chat.v1.GetCustomEmojiRequest\x1a\x1b.google.chat.v1.CustomEmoji\"(\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1b\x12\x19/v1/{name=customEmojis/*}\x12\x82\x01\n\x10ListCustomEmojis\x12\'.google.chat.v1.ListCustomEmojisRequest\x1a(.google.chat.v1.ListCustomEmojisResponse\"\x1b\xda\x41\x00\x82\xd3\xe4\x93\x02\x12\x12\x10/v1/customEmojis\x12\x7f\n\x11\x44\x65leteCustomEmoji\x12(.google.chat.v1.DeleteCustomEmojiRequest\x1a\x16.google.protobuf.Empty\"(\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1b*\x19/v1/{name=customEmojis/*}\x12\x98\x01\n\x11GetSpaceReadState\x12(.google.chat.v1.GetSpaceReadStateRequest\x1a\x1e.google.chat.v1.SpaceReadState\"9\xda\x41\x04name\x82\xd3\xe4\x93\x02,\x12*/v1/{name=users/*/spaces/*/spaceReadState}\x12\xd9\x01\n\x14UpdateSpaceReadState\x12+.google.chat.v1.UpdateSpaceReadStateRequest\x1a\x1e.google.chat.v1.SpaceReadState\"t\xda\x41\x1cspace_read_state,update_mask\x82\xd3\xe4\x93\x02O2;/v1/{space_read_state.name=users/*/spaces/*/spaceReadState}:\x10space_read_state\x12\xa6\x01\n\x12GetThreadReadState\x12).google.chat.v1.GetThreadReadStateRequest\x1a\x1f.google.chat.v1.ThreadReadState\"D\xda\x41\x04name\x82\xd3\xe4\x93\x02\x37\x12\x35/v1/{name=users/*/spaces/*/threads/*/threadReadState}\x12\x83\x01\n\rGetSpaceEvent\x12$.google.chat.v1.GetSpaceEventRequest\x1a\x1a.google.chat.v1.SpaceEvent\"0\xda\x41\x04name\x82\xd3\xe4\x93\x02#\x12!/v1/{name=spaces/*/spaceEvents/*}\x12\x9d\x01\n\x0fListSpaceEvents\x12&.google.chat.v1.ListSpaceEventsRequest\x1a\'.google.chat.v1.ListSpaceEventsResponse\"9\xda\x41\rparent,filter\x82\xd3\xe4\x93\x02#\x12!/v1/{parent=spaces/*}/spaceEvents\x12\xc0\x01\n\x1bGetSpaceNotificationSetting\x12\x32.google.chat.v1.GetSpaceNotificationSettingRequest\x1a(.google.chat.v1.SpaceNotificationSetting\"C\xda\x41\x04name\x82\xd3\xe4\x93\x02\x36\x12\x34/v1/{name=users/*/spaces/*/spaceNotificationSetting}\x12\xa0\x02\n\x1eUpdateSpaceNotificationSetting\x12\x35.google.chat.v1.UpdateSpaceNotificationSettingRequest\x1a(.google.chat.v1.SpaceNotificationSetting\"\x9c\x01\xda\x41&space_notification_setting,update_mask\x82\xd3\xe4\x93\x02m2O/v1/{space_notification_setting.name=users/*/spaces/*/spaceNotificationSetting}:\x1aspace_notification_setting\x12\x8f\x01\n\rCreateSection\x12$.google.chat.v1.CreateSectionRequest\x1a\x17.google.chat.v1.Section\"?\xda\x41\x0eparent,section\x82\xd3\xe4\x93\x02(\"\x1d/v1/{parent=users/*}/sections:\x07section\x12{\n\rDeleteSection\x12$.google.chat.v1.DeleteSectionRequest\x1a\x16.google.protobuf.Empty\",\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1f*\x1d/v1/{name=users/*/sections/*}\x12\x9c\x01\n\rUpdateSection\x12$.google.chat.v1.UpdateSectionRequest\x1a\x17.google.chat.v1.Section\"L\xda\x41\x13section,update_mask\x82\xd3\xe4\x93\x02\x30\x32%/v1/{section.name=users/*/sections/*}:\x07section\x12\x89\x01\n\x0cListSections\x12#.google.chat.v1.ListSectionsRequest\x1a$.google.chat.v1.ListSectionsResponse\".\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1/{parent=users/*}/sections\x12\x95\x01\n\x0fPositionSection\x12&.google.chat.v1.PositionSectionRequest\x1a\'.google.chat.v1.PositionSectionResponse\"1\x82\xd3\xe4\x93\x02+\"&/v1/{name=users/*/sections/*}:position:\x01*\x12\x9d\x01\n\x10ListSectionItems\x12\'.google.chat.v1.ListSectionItemsRequest\x1a(.google.chat.v1.ListSectionItemsResponse\"6\xda\x41\x06parent\x82\xd3\xe4\x93\x02\'\x12%/v1/{parent=users/*/sections/*}/items\x12\xaf\x01\n\x0fMoveSectionItem\x12&.google.chat.v1.MoveSectionItemRequest\x1a\'.google.chat.v1.MoveSectionItemResponse\"K\xda\x41\x13name,target_section\x82\xd3\xe4\x93\x02/\"*/v1/{name=users/*/sections/*/items/*}:move:\x01*\x1a\xbe\x0e\xca\x41\x13\x63hat.googleapis.com\xd2\x41\xa4\x0ehttps://www.googleapis.com/auth/chat.admin.delete,https://www.googleapis.com/auth/chat.admin.memberships,https://www.googleapis.com/auth/chat.admin.memberships.readonly,https://www.googleapis.com/auth/chat.admin.spaces,https://www.googleapis.com/auth/chat.admin.spaces.readonly,https://www.googleapis.com/auth/chat.app.delete,https://www.googleapis.com/auth/chat.app.memberships,https://www.googleapis.com/auth/chat.app.memberships.readonly,https://www.googleapis.com/auth/chat.app.messages.readonly,https://www.googleapis.com/auth/chat.app.spaces,https://www.googleapis.com/auth/chat.app.spaces.create,https://www.googleapis.com/auth/chat.app.spaces.readonly,https://www.googleapis.com/auth/chat.bot,https://www.googleapis.com/auth/chat.customemojis,https://www.googleapis.com/auth/chat.customemojis.readonly,https://www.googleapis.com/auth/chat.delete,https://www.googleapis.com/auth/chat.import,https://www.googleapis.com/auth/chat.memberships,https://www.googleapis.com/auth/chat.memberships.app,https://www.googleapis.com/auth/chat.memberships.readonly,https://www.googleapis.com/auth/chat.messages,https://www.googleapis.com/auth/chat.messages.create,https://www.googleapis.com/auth/chat.messages.reactions,https://www.googleapis.com/auth/chat.messages.reactions.create,https://www.googleapis.com/auth/chat.messages.reactions.readonly,https://www.googleapis.com/auth/chat.messages.readonly,https://www.googleapis.com/auth/chat.spaces,https://www.googleapis.com/auth/chat.spaces.create,https://www.googleapis.com/auth/chat.spaces.readonly,https://www.googleapis.com/auth/chat.users.readstate,https://www.googleapis.com/auth/chat.users.readstate.readonly,https://www.googleapis.com/auth/chat.users.sections,https://www.googleapis.com/auth/chat.users.sections.readonly,https://www.googleapis.com/auth/chat.users.spacesettingsB\xa9\x01\n\x12\x63om.google.chat.v1B\x10\x43hatServiceProtoP\x01Z,cloud.google.com/go/chat/apiv1/chatpb;chatpb\xa2\x02\x0b\x44YNAPIProto\xaa\x02\x13Google.Apps.Chat.V1\xca\x02\x13Google\\Apps\\Chat\\V1\xea\x02\x16Google::Apps::Chat::V1b\x06proto3" +descriptor_data = "\n!google/chat/v1/chat_service.proto\x12\x0egoogle.chat.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/chat/v1/attachment.proto\x1a!google/chat/v1/availability.proto\x1a\x1fgoogle/chat/v1/membership.proto\x1a\x1cgoogle/chat/v1/message.proto\x1a\x1dgoogle/chat/v1/reaction.proto\x1a\x1cgoogle/chat/v1/section.proto\x1a\x1agoogle/chat/v1/space.proto\x1a google/chat/v1/space_event.proto\x1a/google/chat/v1/space_notification_setting.proto\x1a%google/chat/v1/space_read_state.proto\x1a google/chat/v1/space_setup.proto\x1a&google/chat/v1/thread_read_state.proto\x1a\x1bgoogle/protobuf/empty.proto2\xc6G\n\x0b\x43hatService\x12\x9b\x01\n\rCreateMessage\x12$.google.chat.v1.CreateMessageRequest\x1a\x17.google.chat.v1.Message\"K\xda\x41\x19parent,message,message_id\x82\xd3\xe4\x93\x02)\"\x1e/v1/{parent=spaces/*}/messages:\x07message\x12\x8a\x01\n\x0cListMessages\x12#.google.chat.v1.ListMessagesRequest\x1a$.google.chat.v1.ListMessagesResponse\"/\xda\x41\x06parent\x82\xd3\xe4\x93\x02 \x12\x1e/v1/{parent=spaces/*}/messages\x12\x92\x01\n\x0fListMemberships\x12&.google.chat.v1.ListMembershipsRequest\x1a\'.google.chat.v1.ListMembershipsResponse\".\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1/{parent=spaces/*}/members\x12\x7f\n\rGetMembership\x12$.google.chat.v1.GetMembershipRequest\x1a\x1a.google.chat.v1.Membership\",\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1/{name=spaces/*/members/*}\x12w\n\nGetMessage\x12!.google.chat.v1.GetMessageRequest\x1a\x17.google.chat.v1.Message\"-\xda\x41\x04name\x82\xd3\xe4\x93\x02 \x12\x1e/v1/{name=spaces/*/messages/*}\x12\xd1\x01\n\rUpdateMessage\x12$.google.chat.v1.UpdateMessageRequest\x1a\x17.google.chat.v1.Message\"\x80\x01\xda\x41\x13message,update_mask\x82\xd3\xe4\x93\x02\x64\x1a&/v1/{message.name=spaces/*/messages/*}:\x07messageZ12&/v1/{message.name=spaces/*/messages/*}:\x07message\x12|\n\rDeleteMessage\x12$.google.chat.v1.DeleteMessageRequest\x1a\x16.google.protobuf.Empty\"-\xda\x41\x04name\x82\xd3\xe4\x93\x02 *\x1e/v1/{name=spaces/*/messages/*}\x12\x8e\x01\n\rGetAttachment\x12$.google.chat.v1.GetAttachmentRequest\x1a\x1a.google.chat.v1.Attachment\";\xda\x41\x04name\x82\xd3\xe4\x93\x02.\x12,/v1/{name=spaces/*/messages/*/attachments/*}\x12\x9a\x01\n\x10UploadAttachment\x12\'.google.chat.v1.UploadAttachmentRequest\x1a(.google.chat.v1.UploadAttachmentResponse\"3\x82\xd3\xe4\x93\x02-\"(/v1/{parent=spaces/*}/attachments:upload:\x01*\x12j\n\nListSpaces\x12!.google.chat.v1.ListSpacesRequest\x1a\".google.chat.v1.ListSpacesResponse\"\x15\xda\x41\x00\x82\xd3\xe4\x93\x02\x0c\x12\n/v1/spaces\x12w\n\x0cSearchSpaces\x12#.google.chat.v1.SearchSpacesRequest\x1a$.google.chat.v1.SearchSpacesResponse\"\x1c\xda\x41\x00\x82\xd3\xe4\x93\x02\x13\x12\x11/v1/spaces:search\x12\x66\n\x08GetSpace\x12\x1f.google.chat.v1.GetSpaceRequest\x1a\x15.google.chat.v1.Space\"\"\xda\x41\x04name\x82\xd3\xe4\x93\x02\x15\x12\x13/v1/{name=spaces/*}\x12k\n\x0b\x43reateSpace\x12\".google.chat.v1.CreateSpaceRequest\x1a\x15.google.chat.v1.Space\"!\xda\x41\x05space\x82\xd3\xe4\x93\x02\x13\"\n/v1/spaces:\x05space\x12\x63\n\nSetUpSpace\x12!.google.chat.v1.SetUpSpaceRequest\x1a\x15.google.chat.v1.Space\"\x1b\x82\xd3\xe4\x93\x02\x15\"\x10/v1/spaces:setup:\x01*\x12\x86\x01\n\x0bUpdateSpace\x12\".google.chat.v1.UpdateSpaceRequest\x1a\x15.google.chat.v1.Space\"<\xda\x41\x11space,update_mask\x82\xd3\xe4\x93\x02\"2\x19/v1/{space.name=spaces/*}:\x05space\x12m\n\x0b\x44\x65leteSpace\x12\".google.chat.v1.DeleteSpaceRequest\x1a\x16.google.protobuf.Empty\"\"\xda\x41\x04name\x82\xd3\xe4\x93\x02\x15*\x13/v1/{name=spaces/*}\x12\x9d\x01\n\x13\x43ompleteImportSpace\x12*.google.chat.v1.CompleteImportSpaceRequest\x1a+.google.chat.v1.CompleteImportSpaceResponse\"-\x82\xd3\xe4\x93\x02\'\"\"/v1/{name=spaces/*}:completeImport:\x01*\x12z\n\x11\x46indDirectMessage\x12(.google.chat.v1.FindDirectMessageRequest\x1a\x15.google.chat.v1.Space\"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/v1/spaces:findDirectMessage\x12\x82\x01\n\x0e\x46indGroupChats\x12%.google.chat.v1.FindGroupChatsRequest\x1a&.google.chat.v1.FindGroupChatsResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/v1/spaces:findGroupChats\x12\x9e\x01\n\x10\x43reateMembership\x12\'.google.chat.v1.CreateMembershipRequest\x1a\x1a.google.chat.v1.Membership\"E\xda\x41\x11parent,membership\x82\xd3\xe4\x93\x02+\"\x1d/v1/{parent=spaces/*}/members:\nmembership\x12\xae\x01\n\x10UpdateMembership\x12\'.google.chat.v1.UpdateMembershipRequest\x1a\x1a.google.chat.v1.Membership\"U\xda\x41\x16membership,update_mask\x82\xd3\xe4\x93\x02\x36\x32(/v1/{membership.name=spaces/*/members/*}:\nmembership\x12\x85\x01\n\x10\x44\x65leteMembership\x12\'.google.chat.v1.DeleteMembershipRequest\x1a\x1a.google.chat.v1.Membership\",\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1f*\x1d/v1/{name=spaces/*/members/*}\x12\xa1\x01\n\x0e\x43reateReaction\x12%.google.chat.v1.CreateReactionRequest\x1a\x18.google.chat.v1.Reaction\"N\xda\x41\x0fparent,reaction\x82\xd3\xe4\x93\x02\x36\"*/v1/{parent=spaces/*/messages/*}/reactions:\x08reaction\x12\x99\x01\n\rListReactions\x12$.google.chat.v1.ListReactionsRequest\x1a%.google.chat.v1.ListReactionsResponse\";\xda\x41\x06parent\x82\xd3\xe4\x93\x02,\x12*/v1/{parent=spaces/*/messages/*}/reactions\x12\x8a\x01\n\x0e\x44\x65leteReaction\x12%.google.chat.v1.DeleteReactionRequest\x1a\x16.google.protobuf.Empty\"9\xda\x41\x04name\x82\xd3\xe4\x93\x02,**/v1/{name=spaces/*/messages/*/reactions/*}\x12\x91\x01\n\x11\x43reateCustomEmoji\x12(.google.chat.v1.CreateCustomEmojiRequest\x1a\x1b.google.chat.v1.CustomEmoji\"5\xda\x41\x0c\x63ustom_emoji\x82\xd3\xe4\x93\x02 \"\x10/v1/customEmojis:\x0c\x63ustom_emoji\x12~\n\x0eGetCustomEmoji\x12%.google.chat.v1.GetCustomEmojiRequest\x1a\x1b.google.chat.v1.CustomEmoji\"(\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1b\x12\x19/v1/{name=customEmojis/*}\x12\x82\x01\n\x10ListCustomEmojis\x12\'.google.chat.v1.ListCustomEmojisRequest\x1a(.google.chat.v1.ListCustomEmojisResponse\"\x1b\xda\x41\x00\x82\xd3\xe4\x93\x02\x12\x12\x10/v1/customEmojis\x12\x7f\n\x11\x44\x65leteCustomEmoji\x12(.google.chat.v1.DeleteCustomEmojiRequest\x1a\x16.google.protobuf.Empty\"(\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1b*\x19/v1/{name=customEmojis/*}\x12\x98\x01\n\x11GetSpaceReadState\x12(.google.chat.v1.GetSpaceReadStateRequest\x1a\x1e.google.chat.v1.SpaceReadState\"9\xda\x41\x04name\x82\xd3\xe4\x93\x02,\x12*/v1/{name=users/*/spaces/*/spaceReadState}\x12\xd9\x01\n\x14UpdateSpaceReadState\x12+.google.chat.v1.UpdateSpaceReadStateRequest\x1a\x1e.google.chat.v1.SpaceReadState\"t\xda\x41\x1cspace_read_state,update_mask\x82\xd3\xe4\x93\x02O2;/v1/{space_read_state.name=users/*/spaces/*/spaceReadState}:\x10space_read_state\x12\xa6\x01\n\x12GetThreadReadState\x12).google.chat.v1.GetThreadReadStateRequest\x1a\x1f.google.chat.v1.ThreadReadState\"D\xda\x41\x04name\x82\xd3\xe4\x93\x02\x37\x12\x35/v1/{name=users/*/spaces/*/threads/*/threadReadState}\x12\x87\x01\n\x0fGetAvailability\x12&.google.chat.v1.GetAvailabilityRequest\x1a\x1c.google.chat.v1.Availability\".\xda\x41\x04name\x82\xd3\xe4\x93\x02!\x12\x1f/v1/{name=users/*/availability}\x12\x8a\x01\n\x0cMarkAsActive\x12#.google.chat.v1.MarkAsActiveRequest\x1a\x1c.google.chat.v1.Availability\"7\x82\xd3\xe4\x93\x02\x31\",/v1/{name=users/*/availability}:markAsActive:\x01*\x12\x84\x01\n\nMarkAsAway\x12!.google.chat.v1.MarkAsAwayRequest\x1a\x1c.google.chat.v1.Availability\"5\x82\xd3\xe4\x93\x02/\"*/v1/{name=users/*/availability}:markAsAway:\x01*\x12\x9c\x01\n\x12MarkAsDoNotDisturb\x12).google.chat.v1.MarkAsDoNotDisturbRequest\x1a\x1c.google.chat.v1.Availability\"=\x82\xd3\xe4\x93\x02\x37\"2/v1/{name=users/*/availability}:markAsDoNotDisturb:\x01*\x12\xbc\x01\n\x12UpdateAvailability\x12).google.chat.v1.UpdateAvailabilityRequest\x1a\x1c.google.chat.v1.Availability\"]\xda\x41\x18\x61vailability,update_mask\x82\xd3\xe4\x93\x02<2,/v1/{availability.name=users/*/availability}:\x0c\x61vailability\x12\x83\x01\n\rGetSpaceEvent\x12$.google.chat.v1.GetSpaceEventRequest\x1a\x1a.google.chat.v1.SpaceEvent\"0\xda\x41\x04name\x82\xd3\xe4\x93\x02#\x12!/v1/{name=spaces/*/spaceEvents/*}\x12\x9d\x01\n\x0fListSpaceEvents\x12&.google.chat.v1.ListSpaceEventsRequest\x1a\'.google.chat.v1.ListSpaceEventsResponse\"9\xda\x41\rparent,filter\x82\xd3\xe4\x93\x02#\x12!/v1/{parent=spaces/*}/spaceEvents\x12\xc0\x01\n\x1bGetSpaceNotificationSetting\x12\x32.google.chat.v1.GetSpaceNotificationSettingRequest\x1a(.google.chat.v1.SpaceNotificationSetting\"C\xda\x41\x04name\x82\xd3\xe4\x93\x02\x36\x12\x34/v1/{name=users/*/spaces/*/spaceNotificationSetting}\x12\xa0\x02\n\x1eUpdateSpaceNotificationSetting\x12\x35.google.chat.v1.UpdateSpaceNotificationSettingRequest\x1a(.google.chat.v1.SpaceNotificationSetting\"\x9c\x01\xda\x41&space_notification_setting,update_mask\x82\xd3\xe4\x93\x02m2O/v1/{space_notification_setting.name=users/*/spaces/*/spaceNotificationSetting}:\x1aspace_notification_setting\x12\x8f\x01\n\rCreateSection\x12$.google.chat.v1.CreateSectionRequest\x1a\x17.google.chat.v1.Section\"?\xda\x41\x0eparent,section\x82\xd3\xe4\x93\x02(\"\x1d/v1/{parent=users/*}/sections:\x07section\x12{\n\rDeleteSection\x12$.google.chat.v1.DeleteSectionRequest\x1a\x16.google.protobuf.Empty\",\xda\x41\x04name\x82\xd3\xe4\x93\x02\x1f*\x1d/v1/{name=users/*/sections/*}\x12\x9c\x01\n\rUpdateSection\x12$.google.chat.v1.UpdateSectionRequest\x1a\x17.google.chat.v1.Section\"L\xda\x41\x13section,update_mask\x82\xd3\xe4\x93\x02\x30\x32%/v1/{section.name=users/*/sections/*}:\x07section\x12\x89\x01\n\x0cListSections\x12#.google.chat.v1.ListSectionsRequest\x1a$.google.chat.v1.ListSectionsResponse\".\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1/{parent=users/*}/sections\x12\x95\x01\n\x0fPositionSection\x12&.google.chat.v1.PositionSectionRequest\x1a\'.google.chat.v1.PositionSectionResponse\"1\x82\xd3\xe4\x93\x02+\"&/v1/{name=users/*/sections/*}:position:\x01*\x12\x9d\x01\n\x10ListSectionItems\x12\'.google.chat.v1.ListSectionItemsRequest\x1a(.google.chat.v1.ListSectionItemsResponse\"6\xda\x41\x06parent\x82\xd3\xe4\x93\x02\'\x12%/v1/{parent=users/*/sections/*}/items\x12\xaf\x01\n\x0fMoveSectionItem\x12&.google.chat.v1.MoveSectionItemRequest\x1a\'.google.chat.v1.MoveSectionItemResponse\"K\xda\x41\x13name,target_section\x82\xd3\xe4\x93\x02/\"*/v1/{name=users/*/sections/*/items/*}:move:\x01*\x1a\xb7\x0f\xca\x41\x13\x63hat.googleapis.com\xd2\x41\x9d\x0fhttps://www.googleapis.com/auth/chat.admin.delete,https://www.googleapis.com/auth/chat.admin.memberships,https://www.googleapis.com/auth/chat.admin.memberships.readonly,https://www.googleapis.com/auth/chat.admin.spaces,https://www.googleapis.com/auth/chat.admin.spaces.readonly,https://www.googleapis.com/auth/chat.app.delete,https://www.googleapis.com/auth/chat.app.memberships,https://www.googleapis.com/auth/chat.app.memberships.readonly,https://www.googleapis.com/auth/chat.app.messages.readonly,https://www.googleapis.com/auth/chat.app.spaces,https://www.googleapis.com/auth/chat.app.spaces.create,https://www.googleapis.com/auth/chat.app.spaces.readonly,https://www.googleapis.com/auth/chat.bot,https://www.googleapis.com/auth/chat.customemojis,https://www.googleapis.com/auth/chat.customemojis.readonly,https://www.googleapis.com/auth/chat.delete,https://www.googleapis.com/auth/chat.import,https://www.googleapis.com/auth/chat.memberships,https://www.googleapis.com/auth/chat.memberships.app,https://www.googleapis.com/auth/chat.memberships.readonly,https://www.googleapis.com/auth/chat.messages,https://www.googleapis.com/auth/chat.messages.create,https://www.googleapis.com/auth/chat.messages.reactions,https://www.googleapis.com/auth/chat.messages.reactions.create,https://www.googleapis.com/auth/chat.messages.reactions.readonly,https://www.googleapis.com/auth/chat.messages.readonly,https://www.googleapis.com/auth/chat.spaces,https://www.googleapis.com/auth/chat.spaces.create,https://www.googleapis.com/auth/chat.spaces.readonly,https://www.googleapis.com/auth/chat.users.availability,https://www.googleapis.com/auth/chat.users.availability.readonly,https://www.googleapis.com/auth/chat.users.readstate,https://www.googleapis.com/auth/chat.users.readstate.readonly,https://www.googleapis.com/auth/chat.users.sections,https://www.googleapis.com/auth/chat.users.sections.readonly,https://www.googleapis.com/auth/chat.users.spacesettingsB\xa9\x01\n\x12\x63om.google.chat.v1B\x10\x43hatServiceProtoP\x01Z,cloud.google.com/go/chat/apiv1/chatpb;chatpb\xa2\x02\x0b\x44YNAPIProto\xaa\x02\x13Google.Apps.Chat.V1\xca\x02\x13Google\\Apps\\Chat\\V1\xea\x02\x16Google::Apps::Chat::V1b\x06proto3" pool = ::Google::Protobuf::DescriptorPool.generated_pool pool.add_serialized_file(descriptor_data) diff --git a/google-apps-chat-v1/lib/google/chat/v1/chat_service_services_pb.rb b/google-apps-chat-v1/lib/google/chat/v1/chat_service_services_pb.rb index 3615fac13faa..b5dbf7ddb1e0 100644 --- a/google-apps-chat-v1/lib/google/chat/v1/chat_service_services_pb.rb +++ b/google-apps-chat-v1/lib/google/chat/v1/chat_service_services_pb.rb @@ -828,6 +828,77 @@ class Service # - `https://www.googleapis.com/auth/chat.users.readstate.readonly` # - `https://www.googleapis.com/auth/chat.users.readstate` rpc :GetThreadReadState, ::Google::Apps::Chat::V1::GetThreadReadStateRequest, ::Google::Apps::Chat::V1::ThreadReadState + # Returns availability information for a human user in Google Chat. For + # example, this can be used to check if a user is online or away, or to + # retrieve their custom status message. + # + # This method only retrieves the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with one of the following [authorization + # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability.readonly` + # - `https://www.googleapis.com/auth/chat.users.availability` + rpc :GetAvailability, ::Google::Apps::Chat::V1::GetAvailabilityRequest, ::Google::Apps::Chat::V1::Availability + # Marks user as `ACTIVE` in Google Chat. + # + # Sets the user's availability state to `ACTIVE`. The `ACTIVE` state + # lasts until the specified expiration, at which point the user's state + # becomes `AWAY`. Note that if the user is actively using Chat, the `ACTIVE` + # state duration may extend beyond the provided expiration. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + rpc :MarkAsActive, ::Google::Apps::Chat::V1::MarkAsActiveRequest, ::Google::Apps::Chat::V1::Availability + # Marks user as `AWAY` in Google Chat. + # + # Sets the user's state to away and is not affected by the user's + # activity. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + rpc :MarkAsAway, ::Google::Apps::Chat::V1::MarkAsAwayRequest, ::Google::Apps::Chat::V1::Availability + # Marks user as `DO_NOT_DISTURB` in Google Chat. + # + # Sets a user's availability state to `DO_NOT_DISTURB` until a specified + # expiration time. + # When in `DO_NOT_DISTURB`, users typically won't receive notifications. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with [authorization + # scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + rpc :MarkAsDoNotDisturb, ::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest, ::Google::Apps::Chat::V1::Availability + # Updates availability information for a human user. Only the `custom_status` + # field can be updated through this method. + # + # This method only updates the authenticated user's availability. + # + # Requires [user + # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + # with one of the following [authorization + # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + # + # - `https://www.googleapis.com/auth/chat.users.availability` + rpc :UpdateAvailability, ::Google::Apps::Chat::V1::UpdateAvailabilityRequest, ::Google::Apps::Chat::V1::Availability # Returns an event from a Google Chat space. The [event # payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload) # contains the most recent version of the resource that changed. For example, diff --git a/google-apps-chat-v1/proto_docs/google/chat/v1/availability.rb b/google-apps-chat-v1/proto_docs/google/chat/v1/availability.rb new file mode 100644 index 000000000000..67ed89affad2 --- /dev/null +++ b/google-apps-chat-v1/proto_docs/google/chat/v1/availability.rb @@ -0,0 +1,214 @@ +# frozen_string_literal: true + +# Copyright 2026 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! + + +module Google + module Apps + module Chat + module V1 + # Represents a user's current availability information in Google Chat, + # including their state (for example, Active, Away, Do Not Disturb) and any + # custom status. + # @!attribute [rw] name + # @return [::String] + # Identifier. Resource name of the user's availability. + # + # Format: `users/{user}/availability` + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @!attribute [r] state + # @return [::Google::Apps::Chat::V1::Availability::State] + # Output only. The user's current availability state. + # @!attribute [r] do_not_disturb_metadata + # @return [::Google::Apps::Chat::V1::DoNotDisturbMetadata] + # Output only. Metadata if the user state is set to DO_NOT_DISTURB. + # @!attribute [rw] custom_status + # @return [::Google::Apps::Chat::V1::CustomStatus] + # Optional. The user's custom status. + class Availability + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Represents the current availability state of the user. + module State + # Default value. The state is unspecified. + STATE_UNSPECIFIED = 0 + + # The user is currently active, based on recent activity. + ACTIVE = 1 + + # The user is currently idle. This state indicates a period of inactivity + # after being ACTIVE, before potentially transitioning to AWAY. + IDLE = 2 + + # The user is currently away. This can be either automatically set after + # a period of inactivity in ACTIVE or IDLE state, or it can be manually set + # by the user. When manually set via `MarkAsAway`, this state persists + # regardless of user activity. + AWAY = 3 + + # The user is in Do Not Disturb state, which is manually set. + DO_NOT_DISTURB = 4 + end + end + + # Represents a user's custom status in Google Chat. + # This includes a short text message with an optional emoji that a user sets to + # give more context about their availability. + # @!attribute [rw] text + # @return [::String] + # Required. The text of the custom status. This will be a string with maximum + # length of 64. + # @!attribute [rw] emoji + # @return [::Google::Apps::Chat::V1::Emoji] + # Required. The emoji of the custom status. Only Unicode emojis are + # supported; custom emojis are not supported. + # @!attribute [rw] expire_time + # @return [::Google::Protobuf::Timestamp] + # The timestamp when the custom status expires. + # + # Note: The following fields are mutually exclusive: `expire_time`, `ttl`. If a field in that set is populated, all other fields in the set will automatically be cleared. + # @!attribute [rw] ttl + # @return [::Google::Protobuf::Duration] + # Input only. The time-to-live duration after which the custom status + # expires. + # + # Note: The following fields are mutually exclusive: `ttl`, `expire_time`. If a field in that set is populated, all other fields in the set will automatically be cleared. + class CustomStatus + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Metadata associated with the `DO_NOT_DISTURB` availability state, + # specifying when the state is set to expire. + # @!attribute [r] expiration_time + # @return [::Google::Protobuf::Timestamp] + # Output only. Timestamp until which the user should be marked as + # DO_NOT_DISTURB. This can be maximum of 1 year in the future. + class DoNotDisturbMetadata + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetAvailability` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the availability to retrieve. + # + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + class GetAvailabilityRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateAvailability` method. + # @!attribute [rw] availability + # @return [::Google::Apps::Chat::V1::Availability] + # Required. The availability to update. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. The list of fields to update. + # The only field that can be updated is `custom_status`. + class UpdateAvailabilityRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `MarkAsActive` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the availability to mark as active. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @!attribute [rw] expire_time + # @return [::Google::Protobuf::Timestamp] + # The absolute timestamp when the ACTIVE state expires. + # + # Note: The following fields are mutually exclusive: `expire_time`, `ttl`. If a field in that set is populated, all other fields in the set will automatically be cleared. + # @!attribute [rw] ttl + # @return [::Google::Protobuf::Duration] + # The duration from the current time until the ACTIVE state expires. + # Using a short TTL can effectively reset the user's state to be based + # on activity after this brief duration. + # + # Note: The following fields are mutually exclusive: `ttl`, `expire_time`. If a field in that set is populated, all other fields in the set will automatically be cleared. + class MarkAsActiveRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `MarkAsAway` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the availability to mark as away. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + class MarkAsAwayRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `MarkAsDoNotDisturb` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the availability to mark as Do Not Disturb. + # Format: users/\\{user}/availability + # + # `{user}` is the id for the Person in the People API or Admin SDK directory + # API. For example, `users/123456789`. + # + # The user's email address or `me` can also be used as an alias to refer to + # the caller. For example, `users/user@example.com` or `users/me`. + # @!attribute [rw] expire_time + # @return [::Google::Protobuf::Timestamp] + # The absolute timestamp when the DND state expires. + # + # Note: The following fields are mutually exclusive: `expire_time`, `ttl`. If a field in that set is populated, all other fields in the set will automatically be cleared. + # @!attribute [rw] ttl + # @return [::Google::Protobuf::Duration] + # The duration from the current time until the DND state expires. + # + # Note: The following fields are mutually exclusive: `ttl`, `expire_time`. If a field in that set is populated, all other fields in the set will automatically be cleared. + class MarkAsDoNotDisturbRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end +end diff --git a/google-apps-chat-v1/snippets/chat_service/get_availability.rb b/google-apps-chat-v1/snippets/chat_service/get_availability.rb new file mode 100644 index 000000000000..48fe7319111e --- /dev/null +++ b/google-apps-chat-v1/snippets/chat_service/get_availability.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 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! + +# [START chat_v1_generated_ChatService_GetAvailability_sync] +require "google/apps/chat/v1" + +## +# Snippet for the get_availability call in the ChatService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Apps::Chat::V1::ChatService::Client#get_availability. +# +def get_availability + # 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::GetAvailabilityRequest.new + + # Call the get_availability method. + result = client.get_availability request + + # The returned object is of type Google::Apps::Chat::V1::Availability. + p result +end +# [END chat_v1_generated_ChatService_GetAvailability_sync] diff --git a/google-apps-chat-v1/snippets/chat_service/mark_as_active.rb b/google-apps-chat-v1/snippets/chat_service/mark_as_active.rb new file mode 100644 index 000000000000..035b2446db58 --- /dev/null +++ b/google-apps-chat-v1/snippets/chat_service/mark_as_active.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 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! + +# [START chat_v1_generated_ChatService_MarkAsActive_sync] +require "google/apps/chat/v1" + +## +# Snippet for the mark_as_active call in the ChatService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Apps::Chat::V1::ChatService::Client#mark_as_active. +# +def mark_as_active + # 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::MarkAsActiveRequest.new + + # Call the mark_as_active method. + result = client.mark_as_active request + + # The returned object is of type Google::Apps::Chat::V1::Availability. + p result +end +# [END chat_v1_generated_ChatService_MarkAsActive_sync] diff --git a/google-apps-chat-v1/snippets/chat_service/mark_as_away.rb b/google-apps-chat-v1/snippets/chat_service/mark_as_away.rb new file mode 100644 index 000000000000..6d61753f02f1 --- /dev/null +++ b/google-apps-chat-v1/snippets/chat_service/mark_as_away.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 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! + +# [START chat_v1_generated_ChatService_MarkAsAway_sync] +require "google/apps/chat/v1" + +## +# Snippet for the mark_as_away call in the ChatService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Apps::Chat::V1::ChatService::Client#mark_as_away. +# +def mark_as_away + # 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::MarkAsAwayRequest.new + + # Call the mark_as_away method. + result = client.mark_as_away request + + # The returned object is of type Google::Apps::Chat::V1::Availability. + p result +end +# [END chat_v1_generated_ChatService_MarkAsAway_sync] diff --git a/google-apps-chat-v1/snippets/chat_service/mark_as_do_not_disturb.rb b/google-apps-chat-v1/snippets/chat_service/mark_as_do_not_disturb.rb new file mode 100644 index 000000000000..3b5ea10e9745 --- /dev/null +++ b/google-apps-chat-v1/snippets/chat_service/mark_as_do_not_disturb.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 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! + +# [START chat_v1_generated_ChatService_MarkAsDoNotDisturb_sync] +require "google/apps/chat/v1" + +## +# Snippet for the mark_as_do_not_disturb call in the ChatService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Apps::Chat::V1::ChatService::Client#mark_as_do_not_disturb. +# +def mark_as_do_not_disturb + # 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::MarkAsDoNotDisturbRequest.new + + # Call the mark_as_do_not_disturb method. + result = client.mark_as_do_not_disturb request + + # The returned object is of type Google::Apps::Chat::V1::Availability. + p result +end +# [END chat_v1_generated_ChatService_MarkAsDoNotDisturb_sync] diff --git a/google-apps-chat-v1/snippets/chat_service/update_availability.rb b/google-apps-chat-v1/snippets/chat_service/update_availability.rb new file mode 100644 index 000000000000..679c1bd7ebd7 --- /dev/null +++ b/google-apps-chat-v1/snippets/chat_service/update_availability.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 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! + +# [START chat_v1_generated_ChatService_UpdateAvailability_sync] +require "google/apps/chat/v1" + +## +# Snippet for the update_availability call in the ChatService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Apps::Chat::V1::ChatService::Client#update_availability. +# +def update_availability + # 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::UpdateAvailabilityRequest.new + + # Call the update_availability method. + result = client.update_availability request + + # The returned object is of type Google::Apps::Chat::V1::Availability. + p result +end +# [END chat_v1_generated_ChatService_UpdateAvailability_sync] diff --git a/google-apps-chat-v1/snippets/snippet_metadata_google.chat.v1.json b/google-apps-chat-v1/snippets/snippet_metadata_google.chat.v1.json index 5db520bc7264..7b4a46c3a027 100644 --- a/google-apps-chat-v1/snippets/snippet_metadata_google.chat.v1.json +++ b/google-apps-chat-v1/snippets/snippet_metadata_google.chat.v1.json @@ -1291,6 +1291,206 @@ } ] }, + { + "region_tag": "chat_v1_generated_ChatService_GetAvailability_sync", + "title": "Snippet for the get_availability call in the ChatService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Apps::Chat::V1::ChatService::Client#get_availability.", + "file": "chat_service/get_availability.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_availability", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client#get_availability", + "async": false, + "parameters": [ + { + "type": "::Google::Apps::Chat::V1::GetAvailabilityRequest", + "name": "request" + } + ], + "result_type": "::Google::Apps::Chat::V1::Availability", + "client": { + "short_name": "ChatService::Client", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client" + }, + "method": { + "short_name": "GetAvailability", + "full_name": "google.chat.v1.ChatService.GetAvailability", + "service": { + "short_name": "ChatService", + "full_name": "google.chat.v1.ChatService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "chat_v1_generated_ChatService_MarkAsActive_sync", + "title": "Snippet for the mark_as_active call in the ChatService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Apps::Chat::V1::ChatService::Client#mark_as_active.", + "file": "chat_service/mark_as_active.rb", + "language": "RUBY", + "client_method": { + "short_name": "mark_as_active", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client#mark_as_active", + "async": false, + "parameters": [ + { + "type": "::Google::Apps::Chat::V1::MarkAsActiveRequest", + "name": "request" + } + ], + "result_type": "::Google::Apps::Chat::V1::Availability", + "client": { + "short_name": "ChatService::Client", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client" + }, + "method": { + "short_name": "MarkAsActive", + "full_name": "google.chat.v1.ChatService.MarkAsActive", + "service": { + "short_name": "ChatService", + "full_name": "google.chat.v1.ChatService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "chat_v1_generated_ChatService_MarkAsAway_sync", + "title": "Snippet for the mark_as_away call in the ChatService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Apps::Chat::V1::ChatService::Client#mark_as_away.", + "file": "chat_service/mark_as_away.rb", + "language": "RUBY", + "client_method": { + "short_name": "mark_as_away", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client#mark_as_away", + "async": false, + "parameters": [ + { + "type": "::Google::Apps::Chat::V1::MarkAsAwayRequest", + "name": "request" + } + ], + "result_type": "::Google::Apps::Chat::V1::Availability", + "client": { + "short_name": "ChatService::Client", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client" + }, + "method": { + "short_name": "MarkAsAway", + "full_name": "google.chat.v1.ChatService.MarkAsAway", + "service": { + "short_name": "ChatService", + "full_name": "google.chat.v1.ChatService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "chat_v1_generated_ChatService_MarkAsDoNotDisturb_sync", + "title": "Snippet for the mark_as_do_not_disturb call in the ChatService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Apps::Chat::V1::ChatService::Client#mark_as_do_not_disturb.", + "file": "chat_service/mark_as_do_not_disturb.rb", + "language": "RUBY", + "client_method": { + "short_name": "mark_as_do_not_disturb", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client#mark_as_do_not_disturb", + "async": false, + "parameters": [ + { + "type": "::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest", + "name": "request" + } + ], + "result_type": "::Google::Apps::Chat::V1::Availability", + "client": { + "short_name": "ChatService::Client", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client" + }, + "method": { + "short_name": "MarkAsDoNotDisturb", + "full_name": "google.chat.v1.ChatService.MarkAsDoNotDisturb", + "service": { + "short_name": "ChatService", + "full_name": "google.chat.v1.ChatService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "chat_v1_generated_ChatService_UpdateAvailability_sync", + "title": "Snippet for the update_availability call in the ChatService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Apps::Chat::V1::ChatService::Client#update_availability.", + "file": "chat_service/update_availability.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_availability", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client#update_availability", + "async": false, + "parameters": [ + { + "type": "::Google::Apps::Chat::V1::UpdateAvailabilityRequest", + "name": "request" + } + ], + "result_type": "::Google::Apps::Chat::V1::Availability", + "client": { + "short_name": "ChatService::Client", + "full_name": "::Google::Apps::Chat::V1::ChatService::Client" + }, + "method": { + "short_name": "UpdateAvailability", + "full_name": "google.chat.v1.ChatService.UpdateAvailability", + "service": { + "short_name": "ChatService", + "full_name": "google.chat.v1.ChatService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, { "region_tag": "chat_v1_generated_ChatService_GetSpaceEvent_sync", "title": "Snippet for the get_space_event call in the ChatService service", diff --git a/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_paths_test.rb b/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_paths_test.rb index a77707cdc4f1..fb40b11dd771 100644 --- a/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_paths_test.rb +++ b/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_paths_test.rb @@ -53,6 +53,18 @@ def test_attachment_path end end + def test_availability_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Apps::Chat::V1::ChatService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.availability_path user: "value0" + assert_equal "users/value0/availability", path + end + end + def test_custom_emoji_path grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure ::Gapic::ServiceStub.stub :new, DummyStub.new do diff --git a/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_rest_test.rb b/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_rest_test.rb index 960207003219..9678bd4cb61d 100644 --- a/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_rest_test.rb +++ b/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_rest_test.rb @@ -1856,6 +1856,279 @@ def test_get_thread_read_state end end + def test_get_availability + # Create test objects. + client_result = ::Google::Apps::Chat::V1::Availability.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_availability_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:, method_name:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Apps::Chat::V1::ChatService::Rest::ServiceStub.stub :transcode_get_availability_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_availability_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + c.get_availability({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + c.get_availability name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + c.get_availability ::Google::Apps::Chat::V1::GetAvailabilityRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + c.get_availability({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + c.get_availability(::Google::Apps::Chat::V1::GetAvailabilityRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_availability_client_stub.call_count + end + end + end + + def test_mark_as_active + # Create test objects. + client_result = ::Google::Apps::Chat::V1::Availability.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + expire_time = {} + + mark_as_active_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:, method_name:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Apps::Chat::V1::ChatService::Rest::ServiceStub.stub :transcode_mark_as_active_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, mark_as_active_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + c.mark_as_active({ name: name, expire_time: expire_time }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + c.mark_as_active name: name, expire_time: expire_time do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + c.mark_as_active ::Google::Apps::Chat::V1::MarkAsActiveRequest.new(name: name, expire_time: expire_time) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + c.mark_as_active({ name: name, expire_time: expire_time }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + c.mark_as_active(::Google::Apps::Chat::V1::MarkAsActiveRequest.new(name: name, expire_time: expire_time), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, mark_as_active_client_stub.call_count + end + end + end + + def test_mark_as_away + # Create test objects. + client_result = ::Google::Apps::Chat::V1::Availability.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + mark_as_away_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:, method_name:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Apps::Chat::V1::ChatService::Rest::ServiceStub.stub :transcode_mark_as_away_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, mark_as_away_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + c.mark_as_away({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + c.mark_as_away name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + c.mark_as_away ::Google::Apps::Chat::V1::MarkAsAwayRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + c.mark_as_away({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + c.mark_as_away(::Google::Apps::Chat::V1::MarkAsAwayRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, mark_as_away_client_stub.call_count + end + end + end + + def test_mark_as_do_not_disturb + # Create test objects. + client_result = ::Google::Apps::Chat::V1::Availability.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + expire_time = {} + + mark_as_do_not_disturb_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:, method_name:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Apps::Chat::V1::ChatService::Rest::ServiceStub.stub :transcode_mark_as_do_not_disturb_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, mark_as_do_not_disturb_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + c.mark_as_do_not_disturb({ name: name, expire_time: expire_time }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + c.mark_as_do_not_disturb name: name, expire_time: expire_time do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + c.mark_as_do_not_disturb ::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest.new(name: name, expire_time: expire_time) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + c.mark_as_do_not_disturb({ name: name, expire_time: expire_time }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + c.mark_as_do_not_disturb(::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest.new(name: name, expire_time: expire_time), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, mark_as_do_not_disturb_client_stub.call_count + end + end + end + + def test_update_availability + # Create test objects. + client_result = ::Google::Apps::Chat::V1::Availability.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + availability = {} + update_mask = {} + + update_availability_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:, method_name:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Apps::Chat::V1::ChatService::Rest::ServiceStub.stub :transcode_update_availability_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_availability_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + c.update_availability({ availability: availability, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + c.update_availability availability: availability, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + c.update_availability ::Google::Apps::Chat::V1::UpdateAvailabilityRequest.new(availability: availability, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + c.update_availability({ availability: availability, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + c.update_availability(::Google::Apps::Chat::V1::UpdateAvailabilityRequest.new(availability: availability, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_availability_client_stub.call_count + end + end + end + def test_get_space_event # Create test objects. client_result = ::Google::Apps::Chat::V1::SpaceEvent.new diff --git a/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_test.rb b/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_test.rb index b1b281d1824b..51f7a3d124c7 100644 --- a/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_test.rb +++ b/google-apps-chat-v1/test/google/apps/chat/v1/chat_service_test.rb @@ -2054,6 +2054,304 @@ def test_get_thread_read_state end end + def test_get_availability + # Create GRPC objects. + grpc_response = ::Google::Apps::Chat::V1::Availability.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_availability_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_availability, name + assert_kind_of ::Google::Apps::Chat::V1::GetAvailabilityRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_availability_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + c.get_availability({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + c.get_availability name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + c.get_availability ::Google::Apps::Chat::V1::GetAvailabilityRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + c.get_availability({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + c.get_availability(::Google::Apps::Chat::V1::GetAvailabilityRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_availability_client_stub.call_rpc_count + end + end + + def test_mark_as_active + # Create GRPC objects. + grpc_response = ::Google::Apps::Chat::V1::Availability.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + expire_time = {} + + mark_as_active_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :mark_as_active, name + assert_kind_of ::Google::Apps::Chat::V1::MarkAsActiveRequest, request + assert_equal "hello world", request["name"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::Timestamp), request["expire_time"] + assert_equal :expire_time, request.expiration + refute_nil options + end + + Gapic::ServiceStub.stub :new, mark_as_active_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + c.mark_as_active({ name: name, expire_time: expire_time }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + c.mark_as_active name: name, expire_time: expire_time do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + c.mark_as_active ::Google::Apps::Chat::V1::MarkAsActiveRequest.new(name: name, expire_time: expire_time) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + c.mark_as_active({ name: name, expire_time: expire_time }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + c.mark_as_active(::Google::Apps::Chat::V1::MarkAsActiveRequest.new(name: name, expire_time: expire_time), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, mark_as_active_client_stub.call_rpc_count + end + end + + def test_mark_as_away + # Create GRPC objects. + grpc_response = ::Google::Apps::Chat::V1::Availability.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + mark_as_away_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :mark_as_away, name + assert_kind_of ::Google::Apps::Chat::V1::MarkAsAwayRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, mark_as_away_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + c.mark_as_away({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + c.mark_as_away name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + c.mark_as_away ::Google::Apps::Chat::V1::MarkAsAwayRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + c.mark_as_away({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + c.mark_as_away(::Google::Apps::Chat::V1::MarkAsAwayRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, mark_as_away_client_stub.call_rpc_count + end + end + + def test_mark_as_do_not_disturb + # Create GRPC objects. + grpc_response = ::Google::Apps::Chat::V1::Availability.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + expire_time = {} + + mark_as_do_not_disturb_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :mark_as_do_not_disturb, name + assert_kind_of ::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest, request + assert_equal "hello world", request["name"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::Timestamp), request["expire_time"] + assert_equal :expire_time, request.expiration + refute_nil options + end + + Gapic::ServiceStub.stub :new, mark_as_do_not_disturb_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + c.mark_as_do_not_disturb({ name: name, expire_time: expire_time }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + c.mark_as_do_not_disturb name: name, expire_time: expire_time do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + c.mark_as_do_not_disturb ::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest.new(name: name, expire_time: expire_time) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + c.mark_as_do_not_disturb({ name: name, expire_time: expire_time }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + c.mark_as_do_not_disturb(::Google::Apps::Chat::V1::MarkAsDoNotDisturbRequest.new(name: name, expire_time: expire_time), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, mark_as_do_not_disturb_client_stub.call_rpc_count + end + end + + def test_update_availability + # Create GRPC objects. + grpc_response = ::Google::Apps::Chat::V1::Availability.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + availability = {} + update_mask = {} + + update_availability_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_availability, name + assert_kind_of ::Google::Apps::Chat::V1::UpdateAvailabilityRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Apps::Chat::V1::Availability), request["availability"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_availability_client_stub do + # Create client + c = ::Google::Apps::Chat::V1::ChatService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + c.update_availability({ availability: availability, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + c.update_availability availability: availability, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + c.update_availability ::Google::Apps::Chat::V1::UpdateAvailabilityRequest.new(availability: availability, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + c.update_availability({ availability: availability, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + c.update_availability(::Google::Apps::Chat::V1::UpdateAvailabilityRequest.new(availability: availability, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_availability_client_stub.call_rpc_count + end + end + def test_get_space_event # Create GRPC objects. grpc_response = ::Google::Apps::Chat::V1::SpaceEvent.new