Class: Repull::KVApi

Inherits:
Object
  • Object
show all
Defined in:
lib/repull/api/kv_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ KVApi

Returns a new instance of KVApi.



19
20
21
# File 'lib/repull/api/kv_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/repull/api/kv_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#clear_kv(prefix, opts = {}) ⇒ ClearKv200Response

Clear KV entries by prefix Bulk-deletes every key in the project whose name starts with ‘prefix`. The `prefix` parameter is required — there is no "delete every key in this project" shortcut; pass an empty `prefix` is rejected with 422 to prevent accidental wipes. Returns the number of rows removed.

Parameters:

  • prefix (String)

    Required. Keys starting with this string are deleted.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:



28
29
30
31
# File 'lib/repull/api/kv_api.rb', line 28

def clear_kv(prefix, opts = {})
  data, _status_code, _headers = clear_kv_with_http_info(prefix, opts)
  data
end

#clear_kv_with_http_info(prefix, opts = {}) ⇒ Array<(ClearKv200Response, Integer, Hash)>

Clear KV entries by prefix Bulk-deletes every key in the project whose name starts with &#x60;prefix&#x60;. The &#x60;prefix&#x60; parameter is required — there is no &quot;delete every key in this project&quot; shortcut; pass an empty &#x60;prefix&#x60; is rejected with 422 to prevent accidental wipes. Returns the number of rows removed.

Parameters:

  • prefix (String)

    Required. Keys starting with this string are deleted.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:

  • (Array<(ClearKv200Response, Integer, Hash)>)

    ClearKv200Response data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/repull/api/kv_api.rb', line 39

def clear_kv_with_http_info(prefix, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KVApi.clear_kv ...'
  end
  # verify the required parameter 'prefix' is set
  if @api_client.config.client_side_validation && prefix.nil?
    fail ArgumentError, "Missing the required parameter 'prefix' when calling KVApi.clear_kv"
  end
  # resource path
  local_var_path = '/v1/kv'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'prefix'] = prefix
  query_params[:'project_id'] = opts[:'project_id'] if !opts[:'project_id'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ClearKv200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"KVApi.clear_kv",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KVApi#clear_kv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_kv(key, opts = {}) ⇒ DeleteKv200Response

Delete a KV entry Removes a single key. Returns ‘{ deleted: true }` if the row was present, `{ deleted: false }` if it was already absent — both are 200 (idempotent).

Parameters:

  • key (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:



95
96
97
98
# File 'lib/repull/api/kv_api.rb', line 95

def delete_kv(key, opts = {})
  data, _status_code, _headers = delete_kv_with_http_info(key, opts)
  data
end

#delete_kv_with_http_info(key, opts = {}) ⇒ Array<(DeleteKv200Response, Integer, Hash)>

Delete a KV entry Removes a single key. Returns &#x60;{ deleted: true }&#x60; if the row was present, &#x60;{ deleted: false }&#x60; if it was already absent — both are 200 (idempotent).

Parameters:

  • key (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:

  • (Array<(DeleteKv200Response, Integer, Hash)>)

    DeleteKv200Response data, response status code and response headers



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/repull/api/kv_api.rb', line 106

def delete_kv_with_http_info(key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KVApi.delete_kv ...'
  end
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    fail ArgumentError, "Missing the required parameter 'key' when calling KVApi.delete_kv"
  end
  # resource path
  local_var_path = '/v1/kv/{key}'.sub('{key}', CGI.escape(key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'project_id'] = opts[:'project_id'] if !opts[:'project_id'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DeleteKv200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"KVApi.delete_kv",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KVApi#delete_kv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_kv(key, opts = {}) ⇒ ListKv200ResponseDataInner

Get a KV entry Fetches a single key. Returns 404 when the key does not exist OR has expired (rows past ‘ttl_at` are filtered from reads). Cross-tenant lookups also return 404 — the API never reveals existence of another customer’s keys.

Parameters:

  • key (String)

    KV key. URL-encode &#x60;/&#x60;, &#x60;:&#x60;, etc. so they survive routing.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:



161
162
163
164
# File 'lib/repull/api/kv_api.rb', line 161

def get_kv(key, opts = {})
  data, _status_code, _headers = get_kv_with_http_info(key, opts)
  data
end

#get_kv_with_http_info(key, opts = {}) ⇒ Array<(ListKv200ResponseDataInner, Integer, Hash)>

Get a KV entry Fetches a single key. Returns 404 when the key does not exist OR has expired (rows past &#x60;ttl_at&#x60; are filtered from reads). Cross-tenant lookups also return 404 — the API never reveals existence of another customer&#39;s keys.

Parameters:

  • key (String)

    KV key. URL-encode &#x60;/&#x60;, &#x60;:&#x60;, etc. so they survive routing.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:

  • (Array<(ListKv200ResponseDataInner, Integer, Hash)>)

    ListKv200ResponseDataInner data, response status code and response headers



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/repull/api/kv_api.rb', line 172

def get_kv_with_http_info(key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KVApi.get_kv ...'
  end
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    fail ArgumentError, "Missing the required parameter 'key' when calling KVApi.get_kv"
  end
  # resource path
  local_var_path = '/v1/kv/{key}'.sub('{key}', CGI.escape(key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'project_id'] = opts[:'project_id'] if !opts[:'project_id'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListKv200ResponseDataInner'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"KVApi.get_kv",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KVApi#get_kv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_kv(opts = {}) ⇒ ListKv200Response

List KV entries Returns every non-expired key-value row in the given project, sorted ascending by key. Use ‘prefix` to scope to a key namespace (e.g. `prefix=user:42:` to fetch all entries for one user). Hard cap of 1,000 rows per response — for projects approaching that, paginate by walking prefix buckets.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String)

    Project namespace. Defaults to &#x60;default&#x60;. Free-form string the customer chooses (typically the Studio project id). (default to ‘default’)

  • :prefix (String)

    Restrict to keys starting with this string. &#x60;LIKE&#x60; wildcards (&#x60;%&#x60;, &#x60;_&#x60;) are escaped — pass them literally.

Returns:



227
228
229
230
# File 'lib/repull/api/kv_api.rb', line 227

def list_kv(opts = {})
  data, _status_code, _headers = list_kv_with_http_info(opts)
  data
end

#list_kv_with_http_info(opts = {}) ⇒ Array<(ListKv200Response, Integer, Hash)>

List KV entries Returns every non-expired key-value row in the given project, sorted ascending by key. Use &#x60;prefix&#x60; to scope to a key namespace (e.g. &#x60;prefix&#x3D;user:42:&#x60; to fetch all entries for one user). Hard cap of 1,000 rows per response — for projects approaching that, paginate by walking prefix buckets.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String)

    Project namespace. Defaults to &#x60;default&#x60;. Free-form string the customer chooses (typically the Studio project id). (default to ‘default’)

  • :prefix (String)

    Restrict to keys starting with this string. &#x60;LIKE&#x60; wildcards (&#x60;%&#x60;, &#x60;_&#x60;) are escaped — pass them literally.

Returns:

  • (Array<(ListKv200Response, Integer, Hash)>)

    ListKv200Response data, response status code and response headers



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/repull/api/kv_api.rb', line 238

def list_kv_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KVApi.list_kv ...'
  end
  # resource path
  local_var_path = '/v1/kv'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'project_id'] = opts[:'project_id'] if !opts[:'project_id'].nil?
  query_params[:'prefix'] = opts[:'prefix'] if !opts[:'prefix'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListKv200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"KVApi.list_kv",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KVApi#list_kv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#set_kv(key, set_kv_request, opts = {}) ⇒ ListKv200ResponseDataInner

Set a KV entry Upserts a key. The full row is replaced — there is no partial update. Pass ‘ttl_seconds` (positive integer) to auto-expire the row; omit for no expiry. Caps: 64 KiB per row (key bytes + value JSON bytes), 1 MiB per customer (sum across ALL projects/keys). Over either cap returns 413.

Parameters:

  • key (String)
  • set_kv_request (SetKvRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:



291
292
293
294
# File 'lib/repull/api/kv_api.rb', line 291

def set_kv(key, set_kv_request, opts = {})
  data, _status_code, _headers = set_kv_with_http_info(key, set_kv_request, opts)
  data
end

#set_kv_with_http_info(key, set_kv_request, opts = {}) ⇒ Array<(ListKv200ResponseDataInner, Integer, Hash)>

Set a KV entry Upserts a key. The full row is replaced — there is no partial update. Pass &#x60;ttl_seconds&#x60; (positive integer) to auto-expire the row; omit for no expiry. Caps: 64 KiB per row (key bytes + value JSON bytes), 1 MiB per customer (sum across ALL projects/keys). Over either cap returns 413.

Parameters:

  • key (String)
  • set_kv_request (SetKvRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :project_id (String) — default: default to 'default'

Returns:

  • (Array<(ListKv200ResponseDataInner, Integer, Hash)>)

    ListKv200ResponseDataInner data, response status code and response headers



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/repull/api/kv_api.rb', line 303

def set_kv_with_http_info(key, set_kv_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KVApi.set_kv ...'
  end
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    fail ArgumentError, "Missing the required parameter 'key' when calling KVApi.set_kv"
  end
  # verify the required parameter 'set_kv_request' is set
  if @api_client.config.client_side_validation && set_kv_request.nil?
    fail ArgumentError, "Missing the required parameter 'set_kv_request' when calling KVApi.set_kv"
  end
  # resource path
  local_var_path = '/v1/kv/{key}'.sub('{key}', CGI.escape(key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'project_id'] = opts[:'project_id'] if !opts[:'project_id'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(set_kv_request)

  # return_type
  return_type = opts[:debug_return_type] || 'ListKv200ResponseDataInner'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"KVApi.set_kv",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KVApi#set_kv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end