Class: Aws::OpenSearchMemory::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::OpenSearchMemory::Client
- Includes:
- ClientStubs
- Defined in:
- gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb
Overview
An API client for OpenSearchMemory. To construct a client, you need to configure a :region and :credentials.
client = Aws::OpenSearchMemory::Client.new(
region: region_name,
credentials: credentials,
# ...
)
For details on configuring region and credentials see the developer guide.
See #initialize for a full list of supported configuration options.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
API Operations collapse
-
#batch_get_event(params = {}) ⇒ Types::BatchGetEventOutput
Gets up to 10 events by ID, each as
GetEventreturns it, including its payload. -
#create_event(params = {}) ⇒ Types::CreateEventOutput
Submits an event (conversation turns, structured data, or a PDF document stored in Amazon S3) to a session in a space.
-
#create_memory(params = {}) ⇒ Types::CreateMemoryOutput
Writes a memory that you have already formed, without extracting it from events.
-
#create_space(params = {}) ⇒ Types::CreateSpaceResponse
Creates a space.
-
#delete_event(params = {}) ⇒ Types::DeleteEventOutput
Deletes an event.
-
#delete_memory(params = {}) ⇒ Types::DeleteMemoryOutput
Deletes a memory, including its content and embedding.
-
#delete_space(params = {}) ⇒ Types::DeleteSpaceResponse
Deletes a space and its memories.
-
#get_event(params = {}) ⇒ Types::GetEventOutput
Gets an event by ID, including its payload.
-
#get_memory(params = {}) ⇒ Types::GetMemoryOutput
Gets a memory by ID, as returned by
SearchMemoriesorListMemories. -
#get_space(params = {}) ⇒ Types::GetSpaceResponse
Returns a space's configuration and status.
-
#list_events(params = {}) ⇒ Types::ListEventsOutput
Lists the events in a session, sorted by time.
-
#list_memories(params = {}) ⇒ Types::ListMemoriesOutput
Lists a space's memories without a query, for example the most recent memories or the memories of one strategy.
-
#list_spaces(params = {}) ⇒ Types::ListSpacesResponse
Lists the spaces in your account in the current Region.
-
#list_tags_for_resource(params = {}) ⇒ Types::ListTagsForResourceResponse
Lists the tags for the specified space.
-
#search_events(params = {}) ⇒ Types::SearchEventsOutput
Searches a space's events by relevance.
-
#search_memories(params = {}) ⇒ Types::SearchMemoriesOutput
Searches a space's memories by relevance.
-
#tag_resource(params = {}) ⇒ Struct
Adds the specified tags to the specified space.
-
#untag_resource(params = {}) ⇒ Struct
Removes the specified tags from the specified space.
-
#update_memory(params = {}) ⇒ Types::UpdateMemoryOutput
Updates a memory in place.
-
#update_space(params = {}) ⇒ Types::UpdateSpaceResponse
Updates a space's memory strategies, retention settings, or extraction model.
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
-
#wait_until(waiter_name, params = {}, options = {}) {|w.waiter| ... } ⇒ Boolean
Polls an API operation until a resource enters a desired state.
Methods included from ClientStubs
#api_requests, #stub_data, #stub_responses
Methods inherited from Seahorse::Client::Base
add_plugin, api, clear_plugins, define, new, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
486 487 488 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 486 def initialize(*args) super end |
Instance Method Details
#batch_get_event(params = {}) ⇒ Types::BatchGetEventOutput
Gets up to 10 events by ID, each as GetEvent returns it, including
its payload.
If you supply actorId or sessionId, every requested event must
match it. Each event has its own outcome. The operation reports an
event that it can't return in errors instead of failing, with an
error code named for the exception that GetEvent would return for
it. The operation reports both an event that doesn't exist and an
event outside the supplied scope as RESOURCE_NOT_FOUND.
The exception is the space's customer managed AWS KMS key: if it is
disabled, pending deletion, can't be used for decryption, or was
deleted, the whole call fails with ValidationException, as
GetEvent does.
561 562 563 564 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 561 def batch_get_event(params = {}, = {}) req = build_request(:batch_get_event, params) req.send_request() end |
#create_event(params = {}) ⇒ Types::CreateEventOutput
Submits an event (conversation turns, structured data, or a PDF document stored in Amazon S3) to a session in a space.
The operation returns as soon as the event is saved. GetEvent and
ListEvents return it immediately. SearchEvents returns it after
it's indexed. SearchMemories returns memories extracted from it
only after a strategy's extraction trigger fires and the memories are
indexed.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
694 695 696 697 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 694 def create_event(params = {}, = {}) req = build_request(:create_event, params) req.send_request() end |
#create_memory(params = {}) ⇒ Types::CreateMemoryOutput
Writes a memory that you have already formed, without extracting it
from events. The service embeds the text as given and stores it as a
memory of the named strategy. To have the service extract memories
from conversation turns, use CreateEvent instead.
The operation returns before the memory is searchable. The returned
memoryId is final, but until the memory is indexed, GetMemory,
UpdateMemory, and DeleteMemory return ResourceNotFoundException
for it.
If the request would exceed the service's rate for embedding
requests, it fails with ThrottlingException. Retry with exponential
backoff.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
791 792 793 794 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 791 def create_memory(params = {}, = {}) req = build_request(:create_memory, params) req.send_request() end |
#create_space(params = {}) ⇒ Types::CreateSpaceResponse
Creates a space. A space is an AWS resource that stores the events you send and the memories extracted from them, and defines the memory strategies that extract those memories.
The operation returns before provisioning finishes, with status
CREATING. Call GetSpace until the status is ACTIVE, and then use
the space. If provisioning fails, the status becomes FAILED and
statusReason says why.
917 918 919 920 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 917 def create_space(params = {}, = {}) req = build_request(:create_space, params) req.send_request() end |
#delete_event(params = {}) ⇒ Types::DeleteEventOutput
Deletes an event. Deletion can't be undone. The event stops appearing
in SearchEvents results shortly after you delete it. Deleting an
event that doesn't exist returns ResourceNotFoundException.
Deleting an event doesn't delete the memories derived from it,
because a memory can combine content from several events. To remove
them, use DeleteMemory.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
973 974 975 976 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 973 def delete_event(params = {}, = {}) req = build_request(:delete_event, params) req.send_request() end |
#delete_memory(params = {}) ⇒ Types::DeleteMemoryOutput
Deletes a memory, including its content and embedding. Deletion can't be undone. Searches stop returning the memory shortly after you delete it.
Deleting a memory that no longer exists returns
ResourceNotFoundException, so the operation is not idempotent. If
you retry deletes, treat that error as success.
A memory past its expiry (set from the space's memoryExpiryDays
when the memory is written) reads as not found: the operation returns
ResourceNotFoundException, as for a memory that was already deleted.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
1034 1035 1036 1037 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1034 def delete_memory(params = {}, = {}) req = build_request(:delete_memory, params) req.send_request() end |
#delete_space(params = {}) ⇒ Types::DeleteSpaceResponse
Deletes a space and its memories. Deletion can't be undone. After you delete the space, you can't retrieve its events, and the service removes them when they reach their expiry.
The operation returns with status DELETING. When deletion
finishes, GetSpace returns ResourceNotFoundException. If deletion
fails, the status becomes FAILED. A space that is CREATING or
UPDATING can't be deleted until that finishes: the request fails
with ConflictException. Deleting a space that is already DELETING
returns DELETING again.
1073 1074 1075 1076 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1073 def delete_space(params = {}, = {}) req = build_request(:delete_space, params) req.send_request() end |
#get_event(params = {}) ⇒ Types::GetEventOutput
Gets an event by ID, including its payload.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
1135 1136 1137 1138 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1135 def get_event(params = {}, = {}) req = build_request(:get_event, params) req.send_request() end |
#get_memory(params = {}) ⇒ Types::GetMemoryOutput
Gets a memory by ID, as returned by SearchMemories or
ListMemories. A memory that doesn't exist returns
ResourceNotFoundException. Unlike SearchMemories, this operation
also returns memories that consolidation has superseded.
A memory past its expiry (set from the space's memoryExpiryDays
when the memory is written) reads as not found:
ResourceNotFoundException, the same answer as for an ID that does
not exist.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
1202 1203 1204 1205 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1202 def get_memory(params = {}, = {}) req = build_request(:get_memory, params) req.send_request() end |
#get_space(params = {}) ⇒ Types::GetSpaceResponse
Returns a space's configuration and status.
The following waiters are defined for this operation (see #wait_until for detailed usage):
- space_active
- space_deleted
1266 1267 1268 1269 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1266 def get_space(params = {}, = {}) req = build_request(:get_space, params) req.send_request() end |
#list_events(params = {}) ⇒ Types::ListEventsOutput
Lists the events in a session, sorted by time. Optionally limit the
results to events whose eventTimestamp falls between
eventTimestampAfter and eventTimestampBefore. Returns event
metadata only. Call GetEvent for the payload. For full-text or
relevance search, use SearchEvents.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1360 1361 1362 1363 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1360 def list_events(params = {}, = {}) req = build_request(:list_events, params) req.send_request() end |
#list_memories(params = {}) ⇒ Types::ListMemoriesOutput
Lists a space's memories without a query, for example the most recent
memories or the memories of one strategy. Filter by strategy and
optionally by owning actor or session, sort by creation or update
time, and page through the results. Results have no relevance score.
To query or filter by metadata, use SearchMemories.
If memories are written or deleted while you page, the results can
skip a memory or return it twice. You can page through only a limited
number of results. A request past that limit fails with
ValidationException (reason invalidNextToken), and the message
gives the limit.
Memories past their expiry (set from the space's memoryExpiryDays
when each memory is written) are left out. Unlike SearchMemories,
this operation also returns memories that consolidation has
superseded.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1469 1470 1471 1472 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1469 def list_memories(params = {}, = {}) req = build_request(:list_memories, params) req.send_request() end |
#list_spaces(params = {}) ⇒ Types::ListSpacesResponse
Lists the spaces in your account in the current Region.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1513 1514 1515 1516 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1513 def list_spaces(params = {}, = {}) req = build_request(:list_spaces, params) req.send_request() end |
#list_tags_for_resource(params = {}) ⇒ Types::ListTagsForResourceResponse
Lists the tags for the specified space.
1543 1544 1545 1546 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1543 def (params = {}, = {}) req = build_request(:list_tags_for_resource, params) req.send_request() end |
#search_events(params = {}) ⇒ Types::SearchEventsOutput
Searches a space's events by relevance. It works like
SearchMemories without the memory type and strategy selector. The
query is a subset of the OpenSearch Query DSL. The service validates
it, limits the search to the actor in actorId and the sessions in
sessionIds, and returns ranked results. Each result is the matching
chunk of an event, not the whole event. You can page through only a
limited number of results. A request past that limit fails with
ValidationException (reason invalidNextToken), and the message
gives the limit.
If the results are larger than 5 MiB, the request fails with
ValidationException (reason queryBodyTooLarge). Lower
maxResults.
If the request would exceed the service's rate for embedding
requests, it fails with ThrottlingException. Retry with exponential
backoff.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1669 1670 1671 1672 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1669 def search_events(params = {}, = {}) req = build_request(:search_events, params) req.send_request() end |
#search_memories(params = {}) ⇒ Types::SearchMemoriesOutput
Searches a space's memories by relevance. The query is a subset of
the OpenSearch Query DSL. The service validates it, limits the search
to the requested strategies and to the actor in actorId, and returns
one ranked list of memories. You can page through only a limited
number of results. A request past that limit fails with
ValidationException (reason invalidNextToken), and the message
gives the limit.
Memories past their expiry (set from the space's memoryExpiryDays
when each memory is written) are left out of the results. Only current
memories are returned: a memory that consolidation has superseded (an
older version of a fact that a newer memory replaced) is left out.
If the results are larger than 5 MiB, the request fails with
ValidationException (reason queryBodyTooLarge). Lower
maxResults.
If the request would exceed the service's rate for embedding
requests, it fails with ThrottlingException. Retry with exponential
backoff.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.
1797 1798 1799 1800 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1797 def search_memories(params = {}, = {}) req = build_request(:search_memories, params) req.send_request() end |
#tag_resource(params = {}) ⇒ Struct
Adds the specified tags to the specified space.
1828 1829 1830 1831 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1828 def tag_resource(params = {}, = {}) req = build_request(:tag_resource, params) req.send_request() end |
#untag_resource(params = {}) ⇒ Struct
Removes the specified tags from the specified space.
1854 1855 1856 1857 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1854 def untag_resource(params = {}, = {}) req = build_request(:untag_resource, params) req.send_request() end |
#update_memory(params = {}) ⇒ Types::UpdateMemoryOutput
Updates a memory in place. Supply only the fields to change. Omitted
fields keep their stored values. A request must supply content or
metadata, or it fails with ValidationException. Supplying
content re-embeds the memory. A change to metadata alone doesn't.
The memory keeps its memoryId across updates. Shortly after an
update, searches stop returning the previous content.
memoryType can't be changed. To change it, delete the memory and
create a new one.
A memory past its expiry (set from the space's memoryExpiryDays
when the memory is written) reads as not found: the operation fails
with ResourceNotFoundException and changes nothing. An update does
not move the expiry.
Concurrent updates to one memory are last-writer-wins. There is no version check. To avoid lost updates, serialize your updates to a memory.
If you supply content and the request would exceed the service's
rate for embedding requests, it fails with ThrottlingException.
Retry with exponential backoff.
If the space uses a customer managed AWS KMS key, the call can also
fail because of the key. It fails with AccessDeniedException if you
aren't allowed to use the key, and with ThrottlingException if AWS
KMS throttles the request. It fails with ValidationException if the
key is disabled, pending deletion, or deleted.
1961 1962 1963 1964 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 1961 def update_memory(params = {}, = {}) req = build_request(:update_memory, params) req.send_request() end |
#update_space(params = {}) ⇒ Types::UpdateSpaceResponse
Updates a space's memory strategies, retention settings, or extraction model. Supply only the fields to change. Omitted fields keep their current values.
If the request changes the set of strategies, a strategy's
configuration, a retention setting, or the extraction model, the space
moves to UPDATING. When the change is complete, the space returns to
ACTIVE, or moves to FAILED if the change can't be applied. While
the space is UPDATING, GetSpace returns the previous
configuration. A request that only changes strategy descriptions or
repeats the values the space has stored is applied immediately and
doesn't change the status. Sending a retention value that the space
never set also moves the space to UPDATING, even one that matches
the behavior without it, such as 90 for eventExpiryDays or 0 for
memoryExpiryDays. A space that is CREATING, UPDATING, or
DELETING can't be updated: the request fails with
ConflictException.
2067 2068 2069 2070 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 2067 def update_space(params = {}, = {}) req = build_request(:update_space, params) req.send_request() end |
#wait_until(waiter_name, params = {}, options = {}) {|w.waiter| ... } ⇒ Boolean
Polls an API operation until a resource enters a desired state.
Basic Usage
A waiter will call an API operation until:
- It is successful
- It enters a terminal state
- It makes the maximum number of attempts
In between attempts, the waiter will sleep.
# polls in a loop, sleeping between attempts
client.wait_until(waiter_name, params)
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You can pass configuration as the final arguments hash.
# poll for ~25 seconds
client.wait_until(waiter_name, params, {
max_attempts: 5,
delay: 5,
})
Callbacks
You can be notified before each polling attempt and before each
delay. If you throw :success or :failure from these callbacks,
it will terminate the waiter.
started_at = Time.now
client.wait_until(waiter_name, params, {
# disable max attempts
max_attempts: nil,
# poll for 1 hour, instead of a number of attempts
before_wait: -> (attempts, response) do
throw :failure if Time.now - started_at > 3600
end
})
Handling Errors
When a waiter is unsuccessful, it will raise an error. All of the failure errors extend from Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
Valid Waiters
The following table lists the valid waiter names, the operations they call,
and the default :delay and :max_attempts values.
| waiter_name | params | :delay | :max_attempts |
|---|---|---|---|
| space_active | #get_space | 10 | 60 |
| space_deleted | #get_space | 10 | 60 |
2183 2184 2185 2186 2187 |
# File 'gems/aws-sdk-opensearchmemory/lib/aws-sdk-opensearchmemory/client.rb', line 2183 def wait_until(waiter_name, params = {}, = {}) w = waiter(waiter_name, ) yield(w.waiter) if block_given? # deprecated w.wait(params) end |