google-apps-chat-v1 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23084a0c6d282c4e30dee50c303214fd1433a36b71147224f483bd873b6be3e9
4
- data.tar.gz: c2bf76cef3b5466ffef720602d7d351b361ad9b495f63c182b1e166a859c0d88
3
+ metadata.gz: 1861e365a7c4f5d3ce0ae6a625179734b81824c00c63395ef257169ce20c005e
4
+ data.tar.gz: 7fa751aeb695d45b5e6bc54fc8edab0c4387b87e95b8e6a7dbe060facc50d9b8
5
5
  SHA512:
6
- metadata.gz: '0825ffe7320e2a370dba900d23d6965cef3e7c348f187076616b428075a1343cd50299d763068044461a3b6139842ad0638378d06ca5dcff230954b0b6aa15c5'
7
- data.tar.gz: f4177a0ff4271497567ad2187a4e2c9c8a48c1fd9e07e0ce22431b78f091c3bf7b6041850b8d1036e7a765da594c3d17207ff14938ef41a1aa4eb4e4ef4c8c4d
6
+ metadata.gz: 466bd266329ec0414fdd8e4df1926f2261bfad840d9d11457ab05f1d5736d291627df3291301a4d8a56000c7dcab6f4dc46c21456029e1d8c8166ce28fe4c425
7
+ data.tar.gz: bc240045e3aeebda768342eeffd5b9fb8e2087ecc3dc2b1f97df54f092cdb022b24b5bbbf67f76e7d543fc3b70b540eed288db9d51986a12406d09961ae80413
@@ -106,6 +106,11 @@ module Google
106
106
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
107
107
  }
108
108
 
109
+ default_config.rpcs.search_messages.timeout = 30.0
110
+ default_config.rpcs.search_messages.retry_policy = {
111
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
112
+ }
113
+
109
114
  default_config.rpcs.get_attachment.timeout = 30.0
110
115
  default_config.rpcs.get_attachment.retry_policy = {
111
116
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
@@ -1500,6 +1505,286 @@ module Google
1500
1505
  raise ::Google::Cloud::Error.from_error(e)
1501
1506
  end
1502
1507
 
1508
+ ##
1509
+ # Searches for messages in Google Chat that the calling user has access to.
1510
+ # Returns a list of messages matching the search criteria.
1511
+ #
1512
+ # To search across all spaces the user has access to, set `parent` to
1513
+ # `spaces/-`. Using any other value for `parent` results in an
1514
+ # `INVALID_ARGUMENT` error. The returned messages have their `name` field
1515
+ # populated with the full resource name, which includes the specific `space`
1516
+ # in which the message resides.
1517
+ #
1518
+ # This API doesn't return all message types. The types of messages listed
1519
+ # below aren't included in the response. Use
1520
+ # {::Google::Apps::Chat::V1::ChatService::Client#list_messages ListMessages} to list all
1521
+ # messages.
1522
+ #
1523
+ # - Private Messages that are visible to the authenticated user.
1524
+ # - Messages posted by Chat apps in spaces or group chats.
1525
+ # - Messages in a Chat app DM.
1526
+ # - Messages from blocked users.
1527
+ # - Messages in spaces that the caller has muted.
1528
+ #
1529
+ # Requires [user
1530
+ # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1531
+ # with one of the following [authorization
1532
+ # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1533
+ #
1534
+ # - `https://www.googleapis.com/auth/chat.messages.readonly`
1535
+ # - `https://www.googleapis.com/auth/chat.messages`
1536
+ #
1537
+ # @overload search_messages(request, options = nil)
1538
+ # Pass arguments to `search_messages` via a request object, either of type
1539
+ # {::Google::Apps::Chat::V1::SearchMessagesRequest} or an equivalent Hash.
1540
+ #
1541
+ # @param request [::Google::Apps::Chat::V1::SearchMessagesRequest, ::Hash]
1542
+ # A request object representing the call parameters. Required. To specify no
1543
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1544
+ # @param options [::Gapic::CallOptions, ::Hash]
1545
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1546
+ #
1547
+ # @overload search_messages(parent: nil, filter: nil, page_size: nil, page_token: nil, order_by: nil, view: nil)
1548
+ # Pass arguments to `search_messages` via keyword arguments. Note that at
1549
+ # least one keyword argument is required. To specify no parameters, or to keep all
1550
+ # the default parameter values, pass an empty Hash as a request object (see above).
1551
+ #
1552
+ # @param parent [::String]
1553
+ # Required. The resource name of the space to search within.
1554
+ #
1555
+ # To search across all spaces the user has access to, set this field to
1556
+ # `spaces/-`. Using any other value for `parent` results in an
1557
+ # `INVALID_ARGUMENT` error.
1558
+ #
1559
+ # To limit the search to one or more spaces, use `space.name` or
1560
+ # `space.display_name` in the `filter`.
1561
+ # @param filter [::String]
1562
+ # Required. A search query.
1563
+ #
1564
+ # The query can specify one or more search keywords, which are used to filter
1565
+ # the results,
1566
+ #
1567
+ # You can also filter the results using the following message fields:
1568
+ #
1569
+ # - `create_time`: Accepts a timestamp in
1570
+ # [RFC-3339](https://www.rfc-editor.org/rfc/rfc3339) format and the
1571
+ # supported comparison operators are: `<` and `>=`.
1572
+ # - `sender.name`: The resource name of the sender (`users/{user}`). Only
1573
+ # supports `=`. You can use the e-mail as an alias for `{user}`. For
1574
+ # example, `users/example@gmail.com`, where `example@gmail.com` is the
1575
+ # e-mail of the Google Chat user.
1576
+ # - `space.name`: The resource name of the space where the message is posted.
1577
+ # (`spaces/{space}`). Only supports `=`. If this filter is not set, the
1578
+ # search is performed across all direct messages and spaces the user has
1579
+ # access to as a space member.
1580
+ # - `space.display_name`: Supports the operator `:` (has) and filters spaces
1581
+ # based on a partial match of their display name. Results are limited to
1582
+ # the top five space matches. For example, `space.display_name:Project`
1583
+ # searches for messages in the top five spaces that contain the word
1584
+ # "Project" in their display names.
1585
+ # - `attachment`: Supports the operator `:*` (has any) to check for the
1586
+ # presence of attachments. If `attachment:*` is specified, only messages
1587
+ # that have at least one attachment are returned.
1588
+ # - `annotations.user_mentions.user.name`: The resource name of the mentioned
1589
+ # user (`users/{user}`). Only supports `:` (has). For example:
1590
+ # `annotations.user_mentions.user.name:"users/1234567890"` returns only
1591
+ # messages that contain a mention to the specified user. Alternatively, the
1592
+ # alias `me` can be used to filter for messages that mention the caller
1593
+ # user, for example: `annotations.user_mentions.user.name:users/me`. You
1594
+ # can also use the e-mail as an alias for `{user}`, for example,
1595
+ # `users/example@gmail.com`.
1596
+ #
1597
+ # For advanced filtering, the following functions are also available:
1598
+ #
1599
+ # - `has_link()`: Returns only messages that have at least one hyperlink in
1600
+ # the message text.
1601
+ # - `is_unread()`: Filters out messages that have been read by the calling
1602
+ # user.
1603
+ #
1604
+ # Using the `space.display_name` filter requires that the calling credentials
1605
+ # include one of the following [authorization
1606
+ # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1607
+ #
1608
+ # - `https://www.googleapis.com/auth/chat.spaces.readonly`
1609
+ # - `https://www.googleapis.com/auth/chat.spaces`
1610
+ #
1611
+ # Using the `is_unread()` filter requires that the calling credentials
1612
+ # include one of the following [authorization
1613
+ # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1614
+ #
1615
+ # - `https://www.googleapis.com/auth/chat.users.readstate.readonly`
1616
+ # - `https://www.googleapis.com/auth/chat.users.readstate`
1617
+ #
1618
+ #
1619
+ # Across different fields, only `AND` operators are supported. A valid
1620
+ # example is `sender.name = "users/1234567890" AND is_unread()`. The word
1621
+ # `AND` is optional and is implied if omitted. For example, `sender.name =
1622
+ # "users/1234567890" is_unread()` is valid and is equivalent to the previous
1623
+ # example. An invalid example is `sender.name = "users/1234567890" OR
1624
+ # is_unread()` because `OR` is not supported between different fields.
1625
+ #
1626
+ # Among the same field:
1627
+ #
1628
+ # - `create_time` supports only `AND`, and can only be used to represent
1629
+ # an interval, such as `create_time >= "2022-01-01T00:00:00+00:00" AND
1630
+ # create_time < "2023-01-01T00:00:00+00:00"`.
1631
+ # - `sender.name` supports only the `OR` operator, for example:
1632
+ # `sender.name = "users/1234567890" OR sender.name = "users/0987654321"`.
1633
+ # - `space.name` supports only the `OR` operator, for example:
1634
+ # `space.name = "spaces/ABCDEFGH" OR space.name = "spaces/QWERTYUI"`.
1635
+ # - `space.display_name` supports the operators `AND` and `OR`, but not a
1636
+ # mix of both. For example:
1637
+ # `space.display_name:Project AND space.display_name:Tasks` returns
1638
+ # messages that are in spaces with display names containing both `Project`
1639
+ # and `Tasks`, whereas
1640
+ # `space.display_name:Project OR space.display_name:Tasks` returns messages
1641
+ # that are in spaces with display names containing either `Project` or
1642
+ # `Tasks` or both.
1643
+ # - `annotations.user_mentions.user.name` supports the operators `AND` and
1644
+ # `OR`, but not a mix of both. For example:
1645
+ # `annotations.user_mentions.user.name:"users/1234567890" AND
1646
+ # annotations.user_mentions.user.name:"users/0987654321"` returns only
1647
+ # messages that mentions both users, whereas
1648
+ # `annotations.user_mentions.user.name:"users/1234567890" OR
1649
+ # annotations.user_mentions.user.name:"users/0987654321"` returns messages
1650
+ # that mention either user or both.
1651
+ #
1652
+ # Parentheses are required to disambiguate operator precedence when combining
1653
+ # `AND` and `OR` operators in the same query. For example:
1654
+ # `(sender.name="users/me" OR sender.name="users/123456") AND is_unread()`.
1655
+ # Otherwise, parentheses are optional.
1656
+ #
1657
+ # The following example queries are valid:
1658
+ #
1659
+ # ```
1660
+ # "Pending reports" AND create_time >= "2023-01-01T00:00:00Z"
1661
+ #
1662
+ # sender.name = "users/example@gmail.com"
1663
+ #
1664
+ # annotations.user_mentions.user.name:"users/0987654321"
1665
+ #
1666
+ # attachment:* AND space.name = "spaces/ABCDEFGH"
1667
+ #
1668
+ # tasks AND is_unread() AND sender.name = "users/1234567890"
1669
+ #
1670
+ # "things to do" "urgent"
1671
+ #
1672
+ # (sender.name = "users/1234567890")
1673
+ # AND (create_time < "2023-05-01T00:00:00Z")
1674
+ #
1675
+ # tasks AND space.name = "spaces/ABCDEFGH" AND has_link()
1676
+ #
1677
+ # "project one" is_unread()
1678
+ #
1679
+ # space.display_name:Project tasks
1680
+ # ```
1681
+ #
1682
+ # The maximum query length is 1,000 characters.
1683
+ #
1684
+ # Invalid queries are rejected by the server with an `INVALID_ARGUMENT`
1685
+ # error.
1686
+ # @param page_size [::Integer]
1687
+ # Optional. The maximum number of results to return. The service may return
1688
+ # fewer than this value.
1689
+ #
1690
+ # If unspecified, at most 25 are returned.
1691
+ #
1692
+ # The maximum value is 100. If you use a value more than 100, it's
1693
+ # automatically changed to 100.
1694
+ # @param page_token [::String]
1695
+ # Optional. A token, received from the previous search messages call. Provide
1696
+ # this parameter to retrieve the subsequent page.
1697
+ #
1698
+ # When paginating, all other parameters provided should match the call that
1699
+ # provided the page token. Passing different values to the other parameters
1700
+ # might lead to unexpected results.
1701
+ # @param order_by [::String]
1702
+ # Optional. How the results list is ordered.
1703
+ #
1704
+ # Supported attributes to order by are:
1705
+ #
1706
+ # - `create_time`: Sorts the results by the time of the message creation.
1707
+ # Default value.
1708
+ # - `relevance`: Sorts the results by relevance.
1709
+ # [Developer Preview](https://developers.google.com/workspace/preview).
1710
+ #
1711
+ # The default ordering is `create_time desc`. Only a single order per query
1712
+ # (`create_time` or `relevance`) is supported. Only descending order (`desc`)
1713
+ # is supported, and it must be specified after the order attribute.
1714
+ # @param view [::Google::Apps::Chat::V1::SearchMessagesRequest::SearchMessagesView]
1715
+ # Optional. Specifies what kind of search results view to return. The default
1716
+ # is `SEARCH_MESSAGES_VIEW_BASIC`.
1717
+ #
1718
+ # @yield [response, operation] Access the result along with the RPC operation
1719
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Apps::Chat::V1::SearchMessageResult>]
1720
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1721
+ #
1722
+ # @return [::Gapic::PagedEnumerable<::Google::Apps::Chat::V1::SearchMessageResult>]
1723
+ #
1724
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1725
+ #
1726
+ # @example Basic example
1727
+ # require "google/apps/chat/v1"
1728
+ #
1729
+ # # Create a client object. The client can be reused for multiple calls.
1730
+ # client = Google::Apps::Chat::V1::ChatService::Client.new
1731
+ #
1732
+ # # Create a request. To set request fields, pass in keyword arguments.
1733
+ # request = Google::Apps::Chat::V1::SearchMessagesRequest.new
1734
+ #
1735
+ # # Call the search_messages method.
1736
+ # result = client.search_messages request
1737
+ #
1738
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
1739
+ # # over elements, and API calls will be issued to fetch pages as needed.
1740
+ # result.each do |item|
1741
+ # # Each element is of type ::Google::Apps::Chat::V1::SearchMessageResult.
1742
+ # p item
1743
+ # end
1744
+ #
1745
+ def search_messages request, options = nil
1746
+ raise ::ArgumentError, "request must be provided" if request.nil?
1747
+
1748
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::SearchMessagesRequest
1749
+
1750
+ # Converts hash and nil to an options object
1751
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1752
+
1753
+ # Customize the options with defaults
1754
+ metadata = @config.rpcs.search_messages.metadata.to_h
1755
+
1756
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
1757
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1758
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1759
+ gapic_version: ::Google::Apps::Chat::V1::VERSION
1760
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
1761
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1762
+
1763
+ header_params = {}
1764
+ if request.parent
1765
+ header_params["parent"] = request.parent
1766
+ end
1767
+
1768
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1769
+ metadata[:"x-goog-request-params"] ||= request_params_header
1770
+
1771
+ options.apply_defaults timeout: @config.rpcs.search_messages.timeout,
1772
+ metadata: metadata,
1773
+ retry_policy: @config.rpcs.search_messages.retry_policy
1774
+
1775
+ options.apply_defaults timeout: @config.timeout,
1776
+ metadata: @config.metadata,
1777
+ retry_policy: @config.retry_policy
1778
+
1779
+ @chat_service_stub.call_rpc :search_messages, request, options: options do |response, operation|
1780
+ response = ::Gapic::PagedEnumerable.new @chat_service_stub, :search_messages, request, response, operation, options
1781
+ yield response, operation if block_given?
1782
+ throw :response, response
1783
+ end
1784
+ rescue ::GRPC::BadStatus => e
1785
+ raise ::Google::Cloud::Error.from_error(e)
1786
+ end
1787
+
1503
1788
  ##
1504
1789
  # Gets the metadata of a message attachment. The attachment data is fetched
1505
1790
  # using the [media
@@ -6855,6 +7140,11 @@ module Google
6855
7140
  #
6856
7141
  attr_reader :delete_message
6857
7142
  ##
7143
+ # RPC-specific configuration for `search_messages`
7144
+ # @return [::Gapic::Config::Method]
7145
+ #
7146
+ attr_reader :search_messages
7147
+ ##
6858
7148
  # RPC-specific configuration for `get_attachment`
6859
7149
  # @return [::Gapic::Config::Method]
6860
7150
  #
@@ -7076,6 +7366,8 @@ module Google
7076
7366
  @update_message = ::Gapic::Config::Method.new update_message_config
7077
7367
  delete_message_config = parent_rpcs.delete_message if parent_rpcs.respond_to? :delete_message
7078
7368
  @delete_message = ::Gapic::Config::Method.new delete_message_config
7369
+ search_messages_config = parent_rpcs.search_messages if parent_rpcs.respond_to? :search_messages
7370
+ @search_messages = ::Gapic::Config::Method.new search_messages_config
7079
7371
  get_attachment_config = parent_rpcs.get_attachment if parent_rpcs.respond_to? :get_attachment
7080
7372
  @get_attachment = ::Gapic::Config::Method.new get_attachment_config
7081
7373
  upload_attachment_config = parent_rpcs.upload_attachment if parent_rpcs.respond_to? :upload_attachment
@@ -108,6 +108,11 @@ module Google
108
108
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
109
109
  }
110
110
 
111
+ default_config.rpcs.search_messages.timeout = 30.0
112
+ default_config.rpcs.search_messages.retry_policy = {
113
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
114
+ }
115
+
111
116
  default_config.rpcs.get_attachment.timeout = 30.0
112
117
  default_config.rpcs.get_attachment.retry_policy = {
113
118
  initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
@@ -1444,6 +1449,279 @@ module Google
1444
1449
  raise ::Google::Cloud::Error.from_error(e)
1445
1450
  end
1446
1451
 
1452
+ ##
1453
+ # Searches for messages in Google Chat that the calling user has access to.
1454
+ # Returns a list of messages matching the search criteria.
1455
+ #
1456
+ # To search across all spaces the user has access to, set `parent` to
1457
+ # `spaces/-`. Using any other value for `parent` results in an
1458
+ # `INVALID_ARGUMENT` error. The returned messages have their `name` field
1459
+ # populated with the full resource name, which includes the specific `space`
1460
+ # in which the message resides.
1461
+ #
1462
+ # This API doesn't return all message types. The types of messages listed
1463
+ # below aren't included in the response. Use
1464
+ # {::Google::Apps::Chat::V1::ChatService::Rest::Client#list_messages ListMessages} to list all
1465
+ # messages.
1466
+ #
1467
+ # - Private Messages that are visible to the authenticated user.
1468
+ # - Messages posted by Chat apps in spaces or group chats.
1469
+ # - Messages in a Chat app DM.
1470
+ # - Messages from blocked users.
1471
+ # - Messages in spaces that the caller has muted.
1472
+ #
1473
+ # Requires [user
1474
+ # authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1475
+ # with one of the following [authorization
1476
+ # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1477
+ #
1478
+ # - `https://www.googleapis.com/auth/chat.messages.readonly`
1479
+ # - `https://www.googleapis.com/auth/chat.messages`
1480
+ #
1481
+ # @overload search_messages(request, options = nil)
1482
+ # Pass arguments to `search_messages` via a request object, either of type
1483
+ # {::Google::Apps::Chat::V1::SearchMessagesRequest} or an equivalent Hash.
1484
+ #
1485
+ # @param request [::Google::Apps::Chat::V1::SearchMessagesRequest, ::Hash]
1486
+ # A request object representing the call parameters. Required. To specify no
1487
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1488
+ # @param options [::Gapic::CallOptions, ::Hash]
1489
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1490
+ #
1491
+ # @overload search_messages(parent: nil, filter: nil, page_size: nil, page_token: nil, order_by: nil, view: nil)
1492
+ # Pass arguments to `search_messages` via keyword arguments. Note that at
1493
+ # least one keyword argument is required. To specify no parameters, or to keep all
1494
+ # the default parameter values, pass an empty Hash as a request object (see above).
1495
+ #
1496
+ # @param parent [::String]
1497
+ # Required. The resource name of the space to search within.
1498
+ #
1499
+ # To search across all spaces the user has access to, set this field to
1500
+ # `spaces/-`. Using any other value for `parent` results in an
1501
+ # `INVALID_ARGUMENT` error.
1502
+ #
1503
+ # To limit the search to one or more spaces, use `space.name` or
1504
+ # `space.display_name` in the `filter`.
1505
+ # @param filter [::String]
1506
+ # Required. A search query.
1507
+ #
1508
+ # The query can specify one or more search keywords, which are used to filter
1509
+ # the results,
1510
+ #
1511
+ # You can also filter the results using the following message fields:
1512
+ #
1513
+ # - `create_time`: Accepts a timestamp in
1514
+ # [RFC-3339](https://www.rfc-editor.org/rfc/rfc3339) format and the
1515
+ # supported comparison operators are: `<` and `>=`.
1516
+ # - `sender.name`: The resource name of the sender (`users/{user}`). Only
1517
+ # supports `=`. You can use the e-mail as an alias for `{user}`. For
1518
+ # example, `users/example@gmail.com`, where `example@gmail.com` is the
1519
+ # e-mail of the Google Chat user.
1520
+ # - `space.name`: The resource name of the space where the message is posted.
1521
+ # (`spaces/{space}`). Only supports `=`. If this filter is not set, the
1522
+ # search is performed across all direct messages and spaces the user has
1523
+ # access to as a space member.
1524
+ # - `space.display_name`: Supports the operator `:` (has) and filters spaces
1525
+ # based on a partial match of their display name. Results are limited to
1526
+ # the top five space matches. For example, `space.display_name:Project`
1527
+ # searches for messages in the top five spaces that contain the word
1528
+ # "Project" in their display names.
1529
+ # - `attachment`: Supports the operator `:*` (has any) to check for the
1530
+ # presence of attachments. If `attachment:*` is specified, only messages
1531
+ # that have at least one attachment are returned.
1532
+ # - `annotations.user_mentions.user.name`: The resource name of the mentioned
1533
+ # user (`users/{user}`). Only supports `:` (has). For example:
1534
+ # `annotations.user_mentions.user.name:"users/1234567890"` returns only
1535
+ # messages that contain a mention to the specified user. Alternatively, the
1536
+ # alias `me` can be used to filter for messages that mention the caller
1537
+ # user, for example: `annotations.user_mentions.user.name:users/me`. You
1538
+ # can also use the e-mail as an alias for `{user}`, for example,
1539
+ # `users/example@gmail.com`.
1540
+ #
1541
+ # For advanced filtering, the following functions are also available:
1542
+ #
1543
+ # - `has_link()`: Returns only messages that have at least one hyperlink in
1544
+ # the message text.
1545
+ # - `is_unread()`: Filters out messages that have been read by the calling
1546
+ # user.
1547
+ #
1548
+ # Using the `space.display_name` filter requires that the calling credentials
1549
+ # include one of the following [authorization
1550
+ # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1551
+ #
1552
+ # - `https://www.googleapis.com/auth/chat.spaces.readonly`
1553
+ # - `https://www.googleapis.com/auth/chat.spaces`
1554
+ #
1555
+ # Using the `is_unread()` filter requires that the calling credentials
1556
+ # include one of the following [authorization
1557
+ # scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1558
+ #
1559
+ # - `https://www.googleapis.com/auth/chat.users.readstate.readonly`
1560
+ # - `https://www.googleapis.com/auth/chat.users.readstate`
1561
+ #
1562
+ #
1563
+ # Across different fields, only `AND` operators are supported. A valid
1564
+ # example is `sender.name = "users/1234567890" AND is_unread()`. The word
1565
+ # `AND` is optional and is implied if omitted. For example, `sender.name =
1566
+ # "users/1234567890" is_unread()` is valid and is equivalent to the previous
1567
+ # example. An invalid example is `sender.name = "users/1234567890" OR
1568
+ # is_unread()` because `OR` is not supported between different fields.
1569
+ #
1570
+ # Among the same field:
1571
+ #
1572
+ # - `create_time` supports only `AND`, and can only be used to represent
1573
+ # an interval, such as `create_time >= "2022-01-01T00:00:00+00:00" AND
1574
+ # create_time < "2023-01-01T00:00:00+00:00"`.
1575
+ # - `sender.name` supports only the `OR` operator, for example:
1576
+ # `sender.name = "users/1234567890" OR sender.name = "users/0987654321"`.
1577
+ # - `space.name` supports only the `OR` operator, for example:
1578
+ # `space.name = "spaces/ABCDEFGH" OR space.name = "spaces/QWERTYUI"`.
1579
+ # - `space.display_name` supports the operators `AND` and `OR`, but not a
1580
+ # mix of both. For example:
1581
+ # `space.display_name:Project AND space.display_name:Tasks` returns
1582
+ # messages that are in spaces with display names containing both `Project`
1583
+ # and `Tasks`, whereas
1584
+ # `space.display_name:Project OR space.display_name:Tasks` returns messages
1585
+ # that are in spaces with display names containing either `Project` or
1586
+ # `Tasks` or both.
1587
+ # - `annotations.user_mentions.user.name` supports the operators `AND` and
1588
+ # `OR`, but not a mix of both. For example:
1589
+ # `annotations.user_mentions.user.name:"users/1234567890" AND
1590
+ # annotations.user_mentions.user.name:"users/0987654321"` returns only
1591
+ # messages that mentions both users, whereas
1592
+ # `annotations.user_mentions.user.name:"users/1234567890" OR
1593
+ # annotations.user_mentions.user.name:"users/0987654321"` returns messages
1594
+ # that mention either user or both.
1595
+ #
1596
+ # Parentheses are required to disambiguate operator precedence when combining
1597
+ # `AND` and `OR` operators in the same query. For example:
1598
+ # `(sender.name="users/me" OR sender.name="users/123456") AND is_unread()`.
1599
+ # Otherwise, parentheses are optional.
1600
+ #
1601
+ # The following example queries are valid:
1602
+ #
1603
+ # ```
1604
+ # "Pending reports" AND create_time >= "2023-01-01T00:00:00Z"
1605
+ #
1606
+ # sender.name = "users/example@gmail.com"
1607
+ #
1608
+ # annotations.user_mentions.user.name:"users/0987654321"
1609
+ #
1610
+ # attachment:* AND space.name = "spaces/ABCDEFGH"
1611
+ #
1612
+ # tasks AND is_unread() AND sender.name = "users/1234567890"
1613
+ #
1614
+ # "things to do" "urgent"
1615
+ #
1616
+ # (sender.name = "users/1234567890")
1617
+ # AND (create_time < "2023-05-01T00:00:00Z")
1618
+ #
1619
+ # tasks AND space.name = "spaces/ABCDEFGH" AND has_link()
1620
+ #
1621
+ # "project one" is_unread()
1622
+ #
1623
+ # space.display_name:Project tasks
1624
+ # ```
1625
+ #
1626
+ # The maximum query length is 1,000 characters.
1627
+ #
1628
+ # Invalid queries are rejected by the server with an `INVALID_ARGUMENT`
1629
+ # error.
1630
+ # @param page_size [::Integer]
1631
+ # Optional. The maximum number of results to return. The service may return
1632
+ # fewer than this value.
1633
+ #
1634
+ # If unspecified, at most 25 are returned.
1635
+ #
1636
+ # The maximum value is 100. If you use a value more than 100, it's
1637
+ # automatically changed to 100.
1638
+ # @param page_token [::String]
1639
+ # Optional. A token, received from the previous search messages call. Provide
1640
+ # this parameter to retrieve the subsequent page.
1641
+ #
1642
+ # When paginating, all other parameters provided should match the call that
1643
+ # provided the page token. Passing different values to the other parameters
1644
+ # might lead to unexpected results.
1645
+ # @param order_by [::String]
1646
+ # Optional. How the results list is ordered.
1647
+ #
1648
+ # Supported attributes to order by are:
1649
+ #
1650
+ # - `create_time`: Sorts the results by the time of the message creation.
1651
+ # Default value.
1652
+ # - `relevance`: Sorts the results by relevance.
1653
+ # [Developer Preview](https://developers.google.com/workspace/preview).
1654
+ #
1655
+ # The default ordering is `create_time desc`. Only a single order per query
1656
+ # (`create_time` or `relevance`) is supported. Only descending order (`desc`)
1657
+ # is supported, and it must be specified after the order attribute.
1658
+ # @param view [::Google::Apps::Chat::V1::SearchMessagesRequest::SearchMessagesView]
1659
+ # Optional. Specifies what kind of search results view to return. The default
1660
+ # is `SEARCH_MESSAGES_VIEW_BASIC`.
1661
+ # @yield [result, operation] Access the result along with the TransportOperation object
1662
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Apps::Chat::V1::SearchMessageResult>]
1663
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1664
+ #
1665
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Apps::Chat::V1::SearchMessageResult>]
1666
+ #
1667
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1668
+ #
1669
+ # @example Basic example
1670
+ # require "google/apps/chat/v1"
1671
+ #
1672
+ # # Create a client object. The client can be reused for multiple calls.
1673
+ # client = Google::Apps::Chat::V1::ChatService::Rest::Client.new
1674
+ #
1675
+ # # Create a request. To set request fields, pass in keyword arguments.
1676
+ # request = Google::Apps::Chat::V1::SearchMessagesRequest.new
1677
+ #
1678
+ # # Call the search_messages method.
1679
+ # result = client.search_messages request
1680
+ #
1681
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
1682
+ # # over elements, and API calls will be issued to fetch pages as needed.
1683
+ # result.each do |item|
1684
+ # # Each element is of type ::Google::Apps::Chat::V1::SearchMessageResult.
1685
+ # p item
1686
+ # end
1687
+ #
1688
+ def search_messages request, options = nil
1689
+ raise ::ArgumentError, "request must be provided" if request.nil?
1690
+
1691
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Apps::Chat::V1::SearchMessagesRequest
1692
+
1693
+ # Converts hash and nil to an options object
1694
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1695
+
1696
+ # Customize the options with defaults
1697
+ call_metadata = @config.rpcs.search_messages.metadata.to_h
1698
+
1699
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
1700
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1701
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1702
+ gapic_version: ::Google::Apps::Chat::V1::VERSION,
1703
+ transports_version_send: [:rest]
1704
+
1705
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
1706
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1707
+
1708
+ options.apply_defaults timeout: @config.rpcs.search_messages.timeout,
1709
+ metadata: call_metadata,
1710
+ retry_policy: @config.rpcs.search_messages.retry_policy
1711
+
1712
+ options.apply_defaults timeout: @config.timeout,
1713
+ metadata: @config.metadata,
1714
+ retry_policy: @config.retry_policy
1715
+
1716
+ @chat_service_stub.search_messages request, options do |result, operation|
1717
+ result = ::Gapic::Rest::PagedEnumerable.new @chat_service_stub, :search_messages, "results", request, result, options
1718
+ yield result, operation if block_given?
1719
+ throw :response, result
1720
+ end
1721
+ rescue ::Gapic::Rest::Error => e
1722
+ raise ::Google::Cloud::Error.from_error(e)
1723
+ end
1724
+
1447
1725
  ##
1448
1726
  # Gets the metadata of a message attachment. The attachment data is fetched
1449
1727
  # using the [media
@@ -6539,6 +6817,11 @@ module Google
6539
6817
  #
6540
6818
  attr_reader :delete_message
6541
6819
  ##
6820
+ # RPC-specific configuration for `search_messages`
6821
+ # @return [::Gapic::Config::Method]
6822
+ #
6823
+ attr_reader :search_messages
6824
+ ##
6542
6825
  # RPC-specific configuration for `get_attachment`
6543
6826
  # @return [::Gapic::Config::Method]
6544
6827
  #
@@ -6760,6 +7043,8 @@ module Google
6760
7043
  @update_message = ::Gapic::Config::Method.new update_message_config
6761
7044
  delete_message_config = parent_rpcs.delete_message if parent_rpcs.respond_to? :delete_message
6762
7045
  @delete_message = ::Gapic::Config::Method.new delete_message_config
7046
+ search_messages_config = parent_rpcs.search_messages if parent_rpcs.respond_to? :search_messages
7047
+ @search_messages = ::Gapic::Config::Method.new search_messages_config
6763
7048
  get_attachment_config = parent_rpcs.get_attachment if parent_rpcs.respond_to? :get_attachment
6764
7049
  @get_attachment = ::Gapic::Config::Method.new get_attachment_config
6765
7050
  upload_attachment_config = parent_rpcs.upload_attachment if parent_rpcs.respond_to? :upload_attachment