Class: SparteraApiSdk::APIKeysApi

Inherits:
Object
  • Object
show all
Defined in:
lib/spartera_api_sdk/api/api_keys_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ APIKeysApi

Returns a new instance of APIKeysApi.



19
20
21
# File 'lib/spartera_api_sdk/api/api_keys_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/spartera_api_sdk/api/api_keys_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_api_keys(company_id, api_keys_input, opts = {}) ⇒ CreateApiKeys200Response

Create single API key. Returns the actual sk_ key (only time it’s exposed) and api_key_id for future operations.

Parameters:

  • company_id (String)

    Unique identifier for the Company

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number for pagination (default to 1)

  • :limit (Integer)

    Number of items per page (default to 20)

  • :sort_by (String)

    Field to sort by

  • :sort_order (String)

    Sort order (ascending or descending) (default to ‘desc’)

  • :search (String)

    Search term to filter results

Returns:



32
33
34
35
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 32

def create_api_keys(company_id, api_keys_input, opts = {})
  data, _status_code, _headers = create_api_keys_with_http_info(company_id, api_keys_input, opts)
  data
end

#create_api_keys_api_keys_revoke(company_id, api_key_id, api_keys_input, opts = {}) ⇒ CreateApiKeys200Response

Explicitly revoke an API key with reason tracking. This is different from delete as it includes revocation metadata.

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:



152
153
154
155
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 152

def create_api_keys_api_keys_revoke(company_id, api_key_id, api_keys_input, opts = {})
  data, _status_code, _headers = create_api_keys_api_keys_revoke_with_http_info(company_id, api_key_id, api_keys_input, opts)
  data
end

#create_api_keys_api_keys_revoke_with_http_info(company_id, api_key_id, api_keys_input, opts = {}) ⇒ Array<(CreateApiKeys200Response, Integer, Hash)>

Explicitly revoke an API key with reason tracking. This is different from delete as it includes revocation metadata.

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:

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

    CreateApiKeys200Response data, response status code and response headers



163
164
165
166
167
168
169
170
171
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 163

def create_api_keys_api_keys_revoke_with_http_info(company_id, api_key_id, api_keys_input, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.create_api_keys_api_keys_revoke ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.create_api_keys_api_keys_revoke"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.create_api_keys_api_keys_revoke, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.create_api_keys_api_keys_revoke, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.create_api_keys_api_keys_revoke, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_key_id' is set
  if @api_client.config.client_side_validation && api_key_id.nil?
    fail ArgumentError, "Missing the required parameter 'api_key_id' when calling APIKeysApi.create_api_keys_api_keys_revoke"
  end
  if @api_client.config.client_side_validation && api_key_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.create_api_keys_api_keys_revoke, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && api_key_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.create_api_keys_api_keys_revoke, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && api_key_id !~ pattern
    fail ArgumentError, "invalid value for 'api_key_id' when calling APIKeysApi.create_api_keys_api_keys_revoke, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_keys_input' is set
  if @api_client.config.client_side_validation && api_keys_input.nil?
    fail ArgumentError, "Missing the required parameter 'api_keys_input' when calling APIKeysApi.create_api_keys_api_keys_revoke"
  end
  # resource path
  local_var_path = '/companies/{company_id}/api-keys/{api_key_id}/revoke'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'api_key_id' + '}', CGI.escape(api_key_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # 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(api_keys_input)

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

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.create_api_keys_api_keys_revoke",
    :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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: APIKeysApi#create_api_keys_api_keys_revoke\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_api_keys_with_http_info(company_id, api_keys_input, opts = {}) ⇒ Array<(CreateApiKeys200Response, Integer, Hash)>

Create single API key. Returns the actual sk_ key (only time it&#39;s exposed) and api_key_id for future operations.

Parameters:

  • company_id (String)

    Unique identifier for the Company

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number for pagination (default to 1)

  • :limit (Integer)

    Number of items per page (default to 20)

  • :sort_by (String)

    Field to sort by

  • :sort_order (String)

    Sort order (ascending or descending) (default to ‘desc’)

  • :search (String)

    Search term to filter results

Returns:

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

    CreateApiKeys200Response data, response status code and response headers



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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 47

def create_api_keys_with_http_info(company_id, api_keys_input, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.create_api_keys ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.create_api_keys"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.create_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.create_api_keys, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.create_api_keys, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_keys_input' is set
  if @api_client.config.client_side_validation && api_keys_input.nil?
    fail ArgumentError, "Missing the required parameter 'api_keys_input' when calling APIKeysApi.create_api_keys"
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling APIKeysApi.create_api_keys, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling APIKeysApi.create_api_keys, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling APIKeysApi.create_api_keys, must be greater than or equal to 1.'
  end

  allowable_values = ["asc", "desc"]
  if @api_client.config.client_side_validation && opts[:'sort_order'] && !allowable_values.include?(opts[:'sort_order'])
    fail ArgumentError, "invalid value for \"sort_order\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"search"]" when calling APIKeysApi.create_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"search"]" when calling APIKeysApi.create_api_keys, the character length must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/companies/{company_id}/api-keys'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?
  query_params[:'sort_order'] = opts[:'sort_order'] if !opts[:'sort_order'].nil?
  query_params[:'search'] = opts[:'search'] if !opts[:'search'].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(api_keys_input)

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

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.create_api_keys",
    :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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: APIKeysApi#create_api_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_api_keys(company_id, api_key_id, opts = {}) ⇒ DeleteApiKeys200Response

Delete (deactivate) single API key by api_key_id. Uses the api_key_id returned during creation for clean identification. Fixed to use correct primary key lookup.

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:



255
256
257
258
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 255

def delete_api_keys(company_id, api_key_id, opts = {})
  data, _status_code, _headers = delete_api_keys_with_http_info(company_id, api_key_id, opts)
  data
end

#delete_api_keys_with_http_info(company_id, api_key_id, opts = {}) ⇒ Array<(DeleteApiKeys200Response, Integer, Hash)>

Delete (deactivate) single API key by api_key_id. Uses the api_key_id returned during creation for clean identification. Fixed to use correct primary key lookup.

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:

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

    DeleteApiKeys200Response data, response status code and response headers



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
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
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 265

def delete_api_keys_with_http_info(company_id, api_key_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.delete_api_keys ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.delete_api_keys"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.delete_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.delete_api_keys, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.delete_api_keys, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_key_id' is set
  if @api_client.config.client_side_validation && api_key_id.nil?
    fail ArgumentError, "Missing the required parameter 'api_key_id' when calling APIKeysApi.delete_api_keys"
  end
  if @api_client.config.client_side_validation && api_key_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.delete_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && api_key_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.delete_api_keys, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && api_key_id !~ pattern
    fail ArgumentError, "invalid value for 'api_key_id' when calling APIKeysApi.delete_api_keys, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/companies/{company_id}/api-keys/{api_key_id}'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'api_key_id' + '}', CGI.escape(api_key_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # 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] || 'DeleteApiKeys200Response'

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.delete_api_keys",
    :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: APIKeysApi#delete_api_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_api_keys_by_id(company_id, api_key_id, opts = {}) ⇒ GetApiKeysById200Response

Get single API key by ID. Returns masked API key for security (sk_****1234).

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:



348
349
350
351
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 348

def get_api_keys_by_id(company_id, api_key_id, opts = {})
  data, _status_code, _headers = get_api_keys_by_id_with_http_info(company_id, api_key_id, opts)
  data
end

#get_api_keys_by_id_api_keys_stats(company_id, api_key_id, opts = {}) ⇒ GetApiKeysById200Response

Get usage statistics for a specific API key. Returns usage count, last used date, failed attempts, etc.

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:



441
442
443
444
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 441

def get_api_keys_by_id_api_keys_stats(company_id, api_key_id, opts = {})
  data, _status_code, _headers = get_api_keys_by_id_api_keys_stats_with_http_info(company_id, api_key_id, opts)
  data
end

#get_api_keys_by_id_api_keys_stats_with_http_info(company_id, api_key_id, opts = {}) ⇒ Array<(GetApiKeysById200Response, Integer, Hash)>

Get usage statistics for a specific API key. Returns usage count, last used date, failed attempts, etc.

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:

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

    GetApiKeysById200Response data, response status code and response headers



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 451

def get_api_keys_by_id_api_keys_stats_with_http_info(company_id, api_key_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.get_api_keys_by_id_api_keys_stats ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.get_api_keys_by_id_api_keys_stats"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.get_api_keys_by_id_api_keys_stats, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.get_api_keys_by_id_api_keys_stats, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.get_api_keys_by_id_api_keys_stats, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_key_id' is set
  if @api_client.config.client_side_validation && api_key_id.nil?
    fail ArgumentError, "Missing the required parameter 'api_key_id' when calling APIKeysApi.get_api_keys_by_id_api_keys_stats"
  end
  if @api_client.config.client_side_validation && api_key_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.get_api_keys_by_id_api_keys_stats, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && api_key_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.get_api_keys_by_id_api_keys_stats, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && api_key_id !~ pattern
    fail ArgumentError, "invalid value for 'api_key_id' when calling APIKeysApi.get_api_keys_by_id_api_keys_stats, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/companies/{company_id}/api-keys/{api_key_id}/stats'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'api_key_id' + '}', CGI.escape(api_key_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # 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] || 'GetApiKeysById200Response'

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.get_api_keys_by_id_api_keys_stats",
    :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: APIKeysApi#get_api_keys_by_id_api_keys_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_api_keys_by_id_with_http_info(company_id, api_key_id, opts = {}) ⇒ Array<(GetApiKeysById200Response, Integer, Hash)>

Get single API key by ID. Returns masked API key for security (sk_****1234).

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:

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

    GetApiKeysById200Response data, response status code and response headers



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 358

def get_api_keys_by_id_with_http_info(company_id, api_key_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.get_api_keys_by_id ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.get_api_keys_by_id"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.get_api_keys_by_id, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.get_api_keys_by_id, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.get_api_keys_by_id, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_key_id' is set
  if @api_client.config.client_side_validation && api_key_id.nil?
    fail ArgumentError, "Missing the required parameter 'api_key_id' when calling APIKeysApi.get_api_keys_by_id"
  end
  if @api_client.config.client_side_validation && api_key_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.get_api_keys_by_id, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && api_key_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.get_api_keys_by_id, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && api_key_id !~ pattern
    fail ArgumentError, "invalid value for 'api_key_id' when calling APIKeysApi.get_api_keys_by_id, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/companies/{company_id}/api-keys/{api_key_id}'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'api_key_id' + '}', CGI.escape(api_key_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # 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] || 'GetApiKeysById200Response'

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.get_api_keys_by_id",
    :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: APIKeysApi#get_api_keys_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_api_keys(company_id, opts = {}) ⇒ ListApiKeys200Response

Get all API keys for a company. Returns masked API keys for security (sk_****1234).

Parameters:

  • company_id (String)

    Unique identifier for the Company

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number for pagination (default to 1)

  • :limit (Integer)

    Number of items per page (default to 20)

  • :sort_by (String)

    Field to sort by

  • :sort_order (String)

    Sort order (ascending or descending) (default to ‘desc’)

  • :search (String)

    Search term to filter results

Returns:



538
539
540
541
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 538

def list_api_keys(company_id, opts = {})
  data, _status_code, _headers = list_api_keys_with_http_info(company_id, opts)
  data
end

#list_api_keys_with_http_info(company_id, opts = {}) ⇒ Array<(ListApiKeys200Response, Integer, Hash)>

Get all API keys for a company. Returns masked API keys for security (sk_****1234).

Parameters:

  • company_id (String)

    Unique identifier for the Company

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number for pagination (default to 1)

  • :limit (Integer)

    Number of items per page (default to 20)

  • :sort_by (String)

    Field to sort by

  • :sort_order (String)

    Sort order (ascending or descending) (default to ‘desc’)

  • :search (String)

    Search term to filter results

Returns:

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

    ListApiKeys200Response data, response status code and response headers



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 552

def list_api_keys_with_http_info(company_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.list_api_keys ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.list_api_keys"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.list_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.list_api_keys, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.list_api_keys, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling APIKeysApi.list_api_keys, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling APIKeysApi.list_api_keys, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling APIKeysApi.list_api_keys, must be greater than or equal to 1.'
  end

  allowable_values = ["asc", "desc"]
  if @api_client.config.client_side_validation && opts[:'sort_order'] && !allowable_values.include?(opts[:'sort_order'])
    fail ArgumentError, "invalid value for \"sort_order\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"search"]" when calling APIKeysApi.list_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"search"]" when calling APIKeysApi.list_api_keys, the character length must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/companies/{company_id}/api-keys'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?
  query_params[:'sort_order'] = opts[:'sort_order'] if !opts[:'sort_order'].nil?
  query_params[:'search'] = opts[:'search'] if !opts[:'search'].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] || 'ListApiKeys200Response'

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.list_api_keys",
    :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: APIKeysApi#list_api_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_api_keys(company_id, api_key_id, api_keys_update, opts = {}) ⇒ UpdateApiKeys200Response

Update an existing API key by ID. Can update metadata like name, expiration, rate limits, etc. Cannot update the actual key value (for security).

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:



648
649
650
651
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 648

def update_api_keys(company_id, api_key_id, api_keys_update, opts = {})
  data, _status_code, _headers = update_api_keys_with_http_info(company_id, api_key_id, api_keys_update, opts)
  data
end

#update_api_keys_with_http_info(company_id, api_key_id, api_keys_update, opts = {}) ⇒ Array<(UpdateApiKeys200Response, Integer, Hash)>

Update an existing API key by ID. Can update metadata like name, expiration, rate limits, etc. Cannot update the actual key value (for security).

Parameters:

  • company_id (String)

    Unique identifier for the Company

  • api_key_id (String)

    Unique identifier for the Api Key

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

    the optional parameters

Returns:

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

    UpdateApiKeys200Response data, response status code and response headers



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
# File 'lib/spartera_api_sdk/api/api_keys_api.rb', line 659

def update_api_keys_with_http_info(company_id, api_key_id, api_keys_update, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APIKeysApi.update_api_keys ...'
  end
  # verify the required parameter 'company_id' is set
  if @api_client.config.client_side_validation && company_id.nil?
    fail ArgumentError, "Missing the required parameter 'company_id' when calling APIKeysApi.update_api_keys"
  end
  if @api_client.config.client_side_validation && company_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.update_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && company_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "company_id" when calling APIKeysApi.update_api_keys, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && company_id !~ pattern
    fail ArgumentError, "invalid value for 'company_id' when calling APIKeysApi.update_api_keys, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_key_id' is set
  if @api_client.config.client_side_validation && api_key_id.nil?
    fail ArgumentError, "Missing the required parameter 'api_key_id' when calling APIKeysApi.update_api_keys"
  end
  if @api_client.config.client_side_validation && api_key_id.to_s.length > 255
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.update_api_keys, the character length must be smaller than or equal to 255.'
  end

  if @api_client.config.client_side_validation && api_key_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "api_key_id" when calling APIKeysApi.update_api_keys, the character length must be greater than or equal to 1.'
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_-]+$/)
  if @api_client.config.client_side_validation && api_key_id !~ pattern
    fail ArgumentError, "invalid value for 'api_key_id' when calling APIKeysApi.update_api_keys, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'api_keys_update' is set
  if @api_client.config.client_side_validation && api_keys_update.nil?
    fail ArgumentError, "Missing the required parameter 'api_keys_update' when calling APIKeysApi.update_api_keys"
  end
  # resource path
  local_var_path = '/companies/{company_id}/api-keys/{api_key_id}'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'api_key_id' + '}', CGI.escape(api_key_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # 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(api_keys_update)

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

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

  new_options = opts.merge(
    :operation => :"APIKeysApi.update_api_keys",
    :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(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: APIKeysApi#update_api_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end