Sha256: 8d76df77eac0cfc14430e3db3fe6f3f5a51457cafbc138113796a795a34f90cb

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

module MicroServiceClient
	module Concerns
		module Controllers
			module Servers
				extend ActiveSupport::Concern

				def create
					MicroserviceServerInstallJob.perform_later(install_params)

					render :nothing => true, :status => 204
				end

				def destroy
					status = 403

					@server = MicroService::Server.where(uninstall_params).first
					if @server && @server.update_attributes(:uninstalled => true)
						status = 204
					end

					render :nothing => true, :status => status
				end

				private
					def json_params
						ActionController::Parameters.new(JSON.parse(request.body.read))
					end

					def uninstall_params
						data = json_params

						data.permit(
							:id,
							:secret,
						)
					end

					def install_params
						data = json_params

						data.permit(
							:client_id,
							:url,
							:secret,
						)
					end
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
micro_service_client-0.0.2 lib/micro_service_client/concerns/controllers/servers.rb
micro_service_client-0.0.1 lib/micro_service_client/concerns/controllers/servers.rb