Class: ActionAgent::Api::ApiKeysController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ActionAgent::ApplicationController
- BaseController
- ActionAgent::Api::ApiKeysController
- Defined in:
- app/controllers/action_agent/api/api_keys_controller.rb
Overview
Platform API keys (Settings -> API Keys). The full token is returned exactly once — in the create response — and masked everywhere else.
Instance Method Summary collapse
-
#create ⇒ Object
POST /api/api_keys.
-
#destroy ⇒ Object
DELETE /api/api_keys/:id.
-
#index ⇒ Object
GET /api/api_keys.
Methods inherited from ActionAgent::ApplicationController
Instance Method Details
#create ⇒ Object
POST /api/api_keys
18 19 20 21 22 23 24 |
# File 'app/controllers/action_agent/api/api_keys_controller.rb', line 18 def create api_key = owned(ApiKey).create!(name: params.require(:name)) render json: { api_key: serialize(api_key).merge(token: api_key.token) }, status: :created end |
#destroy ⇒ Object
DELETE /api/api_keys/:id
27 28 29 30 |
# File 'app/controllers/action_agent/api/api_keys_controller.rb', line 27 def destroy owned(ApiKey).find(params[:id]).destroy! head :no_content end |
#index ⇒ Object
GET /api/api_keys
11 12 13 14 15 |
# File 'app/controllers/action_agent/api/api_keys_controller.rb', line 11 def index render json: { api_keys: owned(ApiKey).order(created_at: :desc).map { |key| serialize(key) } } end |