Class: Angarium::Api::EndpointsController
- Inherits:
-
BaseController
- Object
- BaseController
- Angarium::Api::EndpointsController
- Defined in:
- app/controllers/angarium/api/endpoints_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #enable ⇒ Object
- #index ⇒ Object
- #pause ⇒ Object
- #ping ⇒ Object
- #rotate_secret ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #verify ⇒ Object
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 16 def create # The owner comes from the policy's #owner (default: current_user), set # before authorize! so policy #create? can gate the target owner. endpoint = Angarium::Endpoint.new(endpoint_params) endpoint.owner = angarium_policy.owner endpoint.status = :unverified if angarium_policy.create_unverified? (endpoint) endpoint.save! # The signing secret is revealed once, on creation. render json: {endpoint: endpoint_json(endpoint, include_secret: true)}, status: :created end |
#destroy ⇒ Object
34 35 36 37 38 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 34 def destroy (@endpoint) @endpoint.destroy! head :no_content end |
#enable ⇒ Object
52 53 54 55 56 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 52 def enable (@endpoint) @endpoint.enable! render json: {endpoint: endpoint_json(@endpoint)} end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 6 def index render_collection(:endpoints, endpoint_scope.order(created_at: :desc)) { |e| endpoint_json(e) } end |
#pause ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 46 def pause (@endpoint) @endpoint.pause! render json: {endpoint: endpoint_json(@endpoint)} end |
#ping ⇒ Object
64 65 66 67 68 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 64 def ping (@endpoint) delivery = @endpoint.ping! render json: {delivery: delivery_json(delivery)}, status: :accepted end |
#rotate_secret ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 40 def rotate_secret (@endpoint) secret = @endpoint.rotate_secret! render json: {endpoint: endpoint_json(@endpoint), signing_secret: secret} end |
#show ⇒ Object
11 12 13 14 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 11 def show (@endpoint) render json: {endpoint: endpoint_json(@endpoint)} end |
#update ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 28 def update (@endpoint) @endpoint.update!(endpoint_params) render json: {endpoint: endpoint_json(@endpoint)} end |
#verify ⇒ Object
58 59 60 61 62 |
# File 'app/controllers/angarium/api/endpoints_controller.rb', line 58 def verify (@endpoint) @endpoint.verify! render json: {endpoint: endpoint_json(@endpoint)} end |