Class: Api::V2::SnapshotsController
- Inherits:
-
V2::BaseController
- Object
- V2::BaseController
- Api::V2::SnapshotsController
- Includes:
- Api::Version2, Foreman::Controller::Parameters::Snapshot
- Defined in:
- app/controllers/api/v2/snapshots_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
53 54 55 56 57 58 |
# File 'app/controllers/api/v2/snapshots_controller.rb', line 53 def create @snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge( include_ram: Foreman::Cast.to_bool(params[:include_ram]), quiesce: Foreman::Cast.to_bool(params[:quiesce]) )) process_response @snapshot.create end |
#destroy ⇒ Object
73 74 75 |
# File 'app/controllers/api/v2/snapshots_controller.rb', line 73 def destroy process_response @snapshot.destroy end |
#index ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/api/v2/snapshots_controller.rb', line 17 def index if params[:search] search = params[:search].match(/^\s*name\s*=\s*(\w+)\s*$/) || params[:search].match(/^\s*name\s*=\s*"([^"]+)"\s*$/) raise "Field '#{params[:search]}' not recognized for searching!" unless search snapshot = resource_class.find_for_host_by_name(@host, search[1]) @snapshots = if snapshot [snapshot].paginate() else [] end else @snapshots = resource_scope_for_index end end |
#revert ⇒ Object
81 82 83 |
# File 'app/controllers/api/v2/snapshots_controller.rb', line 81 def revert process_response @snapshot.revert end |
#show ⇒ Object
37 38 |
# File 'app/controllers/api/v2/snapshots_controller.rb', line 37 def show end |
#update ⇒ Object
65 66 67 |
# File 'app/controllers/api/v2/snapshots_controller.rb', line 65 def update process_response @snapshot.update(snapshot_params) end |