Class: Telnyx::Resources::Storage::Kvs::Keys
- Inherits:
-
Object
- Object
- Telnyx::Resources::Storage::Kvs::Keys
- Defined in:
- lib/telnyx/resources/storage/kvs/keys.rb,
sig/telnyx/resources/storage/kvs/keys.rbs
Overview
Read and write keys within a KV namespace
Instance Method Summary collapse
-
#delete(key, id:, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Storage::Kvs::KeyDeleteParams for more details.
-
#initialize(client:) ⇒ Keys
constructor
private
A new instance of Keys.
-
#list(id, cursor: nil, limit: nil, prefix: nil, request_options: {}) ⇒ Telnyx::Internal::CursorFlatPagination<Telnyx::Models::Storage::Kvs::KeyListResponse>
Lists the keys in a namespace.
-
#retrieve(key, id:, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::Storage::Kvs::KeyRetrieveParams for more details.
-
#update(key, id:, body:, ttl_secs: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Storage::Kvs::KeyUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Keys
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Keys.
148 149 150 |
# File 'lib/telnyx/resources/storage/kvs/keys.rb', line 148 def initialize(client:) @client = client end |
Instance Method Details
#delete(key, id:, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Storage::Kvs::KeyDeleteParams for more details.
Deletes a key. Idempotent: deleting a key that does not exist still succeeds. The namespace itself must exist and be provisioned.
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/telnyx/resources/storage/kvs/keys.rb', line 131 def delete(key, params) parsed, = Telnyx::Storage::Kvs::KeyDeleteParams.dump_request(params) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["storage/kvs/%1$s/keys/%2$s", id, key], model: NilClass, options: ) end |
#list(id, cursor: nil, limit: nil, prefix: nil, request_options: {}) ⇒ Telnyx::Internal::CursorFlatPagination<Telnyx::Models::Storage::Kvs::KeyListResponse>
Lists the keys in a namespace. Returns key names and metadata only, never
values. Results are paginated with limit and an opaque cursor.
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/telnyx/resources/storage/kvs/keys.rb', line 101 def list(id, params = {}) parsed, = Telnyx::Storage::Kvs::KeyListParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["storage/kvs/%1$s/keys", id], query: query, page: Telnyx::Internal::CursorFlatPagination, model: Telnyx::Models::Storage::Kvs::KeyListResponse, options: ) end |
#retrieve(key, id:, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::Storage::Kvs::KeyRetrieveParams for more details.
Returns the raw stored value for a key. The response body is the value exactly
as it was written; the Content-Type header echoes the value's stored content
type (defaults to application/octet-stream).
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/telnyx/resources/storage/kvs/keys.rb', line 27 def retrieve(key, params) parsed, = Telnyx::Storage::Kvs::KeyRetrieveParams.dump_request(params) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["storage/kvs/%1$s/keys/%2$s", id, key], headers: {"accept" => "application/octet-stream"}, model: StringIO, options: ) end |
#update(key, id:, body:, ttl_secs: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Storage::Kvs::KeyUpdateParams for more details.
Creates or replaces the value for a key. The request body is stored verbatim as
the value — no base64, no JSON envelope — up to 1 MiB. The request's
Content-Type header is stored with the value and echoed back on retrieval.
Returns 201 when the key is created and 200 when an existing key is updated.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/telnyx/resources/storage/kvs/keys.rb', line 65 def update(key, params) parsed, = Telnyx::Storage::Kvs::KeyUpdateParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed.except(:body)) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["storage/kvs/%1$s/keys/%2$s", id, key], query: query, headers: {"content-type" => "application/octet-stream"}, body: parsed[:body], model: NilClass, options: ) end |