Class: Shipeasy::Admin::Generated::APIKeysApi
- Inherits:
-
Object
- Object
- Shipeasy::Admin::Generated::APIKeysApi
- Defined in:
- lib/shipeasy_admin/api/api_keys_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_key(create_key_request, opts = {}) ⇒ CreateKeyResponse
Create an API key Mints a new API key and returns the plaintext token once — it is stored hashed and can never be retrieved again, so capture it on creation.
-
#create_key_with_http_info(create_key_request, opts = {}) ⇒ Array<(CreateKeyResponse, Integer, Hash)>
Create an API key Mints a new API key and returns the plaintext token once — it is stored hashed and can never be retrieved again, so capture it on creation.
-
#initialize(api_client = ApiClient.default) ⇒ APIKeysApi
constructor
A new instance of APIKeysApi.
-
#list_keys(opts = {}) ⇒ ListKeysResponse
List API keys Returns a single page of the project's API keys ordered by
created_at desc, id desc, in the standard{ data, next_cursor }envelope. -
#list_keys_with_http_info(opts = {}) ⇒ Array<(ListKeysResponse, Integer, Hash)>
List API keys Returns a single page of the project's API keys ordered by `created_at desc, id desc`, in the standard `{ data, next_cursor }` envelope.
-
#revoke_key(id, opts = {}) ⇒ RevokeKeyResponse
Revoke an API key Revokes a key by id — stamps its
revoked_atand deletes the hot-path KV entry so the token stops authenticating immediately. -
#revoke_key_with_http_info(id, opts = {}) ⇒ Array<(RevokeKeyResponse, Integer, Hash)>
Revoke an API key Revokes a key by id — stamps its `revoked_at` and deletes the hot-path KV entry so the token stops authenticating immediately.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ APIKeysApi
Returns a new instance of APIKeysApi.
19 20 21 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create_key(create_key_request, opts = {}) ⇒ CreateKeyResponse
Create an API key
Mints a new API key and returns the plaintext token once — it is stored hashed and can never be retrieved again, so capture it on creation. Only type is required. env is required for server and client keys (the key is bound to one environment, which is the read-env isolation boundary); for admin and ops keys env is ignored and the key is pinned to prod. Expiry is fixed for some types: admin keys always get a 90-day expiry and ops keys a short sliding window, regardless of expiresInDays. Only server/client keys count toward the plan key limit. Use cases - Back-end key — { \"type\": \"server\", \"env\": \"prod\" } for the production server SDK. - Public browser key — { \"type\": \"client\", \"env\": \"prod\", \"name\": \"marketing site\" } to embed in the browser SDK. - Scoped, expiring key — { \"type\": \"server\", \"env\": \"staging\", \"scopes\": [\"gates:evaluate\"], \"expiresInDays\": 30 } for a time-boxed integration.
28 29 30 31 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 28 def create_key(create_key_request, opts = {}) data, _status_code, _headers = create_key_with_http_info(create_key_request, opts) data end |
#create_key_with_http_info(create_key_request, opts = {}) ⇒ Array<(CreateKeyResponse, Integer, Hash)>
Create an API key Mints a new API key and returns the plaintext token once — it is stored hashed and can never be retrieved again, so capture it on creation. Only `type` is required. `env` is required for `server` and `client` keys (the key is bound to one environment, which is the read-env isolation boundary); for `admin` and `ops` keys `env` is ignored and the key is pinned to `prod`. Expiry is fixed for some types: `admin` keys always get a 90-day expiry and `ops` keys a short sliding window, regardless of `expiresInDays`. Only `server`/`client` keys count toward the plan key limit. Use cases - Back-end key — `{ "type": "server", "env": "prod" }` for the production server SDK. - Public browser key — `{ "type": "client", "env": "prod", "name": "marketing site" }` to embed in the browser SDK. - Scoped, expiring key — `{ "type": "server", "env": "staging", "scopes": ["gates:evaluate"], "expiresInDays": 30 }` for a time-boxed integration.
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 88 89 90 91 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 39 def create_key_with_http_info(create_key_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: APIKeysApi.create_key ...' end # verify the required parameter 'create_key_request' is set if @api_client.config.client_side_validation && create_key_request.nil? fail ArgumentError, "Missing the required parameter 'create_key_request' when calling APIKeysApi.create_key" end # resource path local_var_path = '/api/admin/keys' # 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 header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(create_key_request) # return_type return_type = opts[:debug_return_type] || 'CreateKeyResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"APIKeysApi.create_key", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: APIKeysApi#create_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_keys(opts = {}) ⇒ ListKeysResponse
List API keys
Returns a single page of the project's API keys ordered by created_at desc, id desc, in the standard { data, next_cursor } envelope. Use the cursor query parameter to paginate. Response fields are snake_case (created_at, revoked_at, created_by_email, last4). The raw token is never returned — only its last4 tail, so a held key can be matched against the masked row. Revoked keys are included (with a non-null revoked_at). Use case: Audit which keys exist for a project — surface stale or never-expiring keys, or drive a CI check that asserts no client key is still active in prod after a rotation.
100 101 102 103 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 100 def list_keys(opts = {}) data, _status_code, _headers = list_keys_with_http_info(opts) data end |
#list_keys_with_http_info(opts = {}) ⇒ Array<(ListKeysResponse, Integer, Hash)>
List API keys Returns a single page of the project's API keys ordered by `created_at desc, id desc`, in the standard `{ data, next_cursor }` envelope. Use the `cursor` query parameter to paginate. Response fields are snake_case (`created_at`, `revoked_at`, `created_by_email`, `last4`). The raw token is never returned — only its `last4` tail, so a held key can be matched against the masked row. Revoked keys are included (with a non-null `revoked_at`). Use case: Audit which keys exist for a project — surface stale or never-expiring keys, or drive a CI check that asserts no `client` key is still active in `prod` after a rotation.
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 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 112 def list_keys_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: APIKeysApi.list_keys ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling APIKeysApi.list_keys, must be smaller than or equal to 500.' 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_keys, must be greater than or equal to 1.' end # resource path local_var_path = '/api/admin/keys' # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].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'] header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ListKeysResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"APIKeysApi.list_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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: APIKeysApi#list_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#revoke_key(id, opts = {}) ⇒ RevokeKeyResponse
Revoke an API key
Revokes a key by id — stamps its revoked_at and deletes the hot-path KV entry so the token stops authenticating immediately. Takes no body. Idempotent: revoking an already-revoked key is a no-op and returns the same { id, revoked: true }. Returns 404 if no such key exists in the project. Use case: Rotate a leaked or stale credential — mint the replacement, then revoke the old key.
173 174 175 176 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 173 def revoke_key(id, opts = {}) data, _status_code, _headers = revoke_key_with_http_info(id, opts) data end |
#revoke_key_with_http_info(id, opts = {}) ⇒ Array<(RevokeKeyResponse, Integer, Hash)>
Revoke an API key Revokes a key by id — stamps its `revoked_at` and deletes the hot-path KV entry so the token stops authenticating immediately. Takes no body. Idempotent: revoking an already-revoked key is a no-op and returns the same `{ id, revoked: true }`. Returns `404` if no such key exists in the project. Use case: Rotate a leaked or stale credential — mint the replacement, then revoke the old key.
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 |
# File 'lib/shipeasy_admin/api/api_keys_api.rb', line 184 def revoke_key_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: APIKeysApi.revoke_key ...' end # resource path local_var_path = '/api/admin/keys/{id}/revoke'.sub('{id}', CGI.escape(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'] header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'RevokeKeyResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerSdkKey'] = opts.merge( :operation => :"APIKeysApi.revoke_key", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: APIKeysApi#revoke_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |