lib/xway/api/endpoints.rb in xway-0.0.1.beta vs lib/xway/api/endpoints.rb in xway-0.0.2.beta
- old
+ new
@@ -7,39 +7,70 @@
def create options={}
Request.new 'post', '/applications', options
end
- def find options={app: ':name'}
- Request.new 'get', "/applications/#{options[:app]}"
+ def find options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'get', "/applications/#{options[:name]}"
end
- def update options={app: ':name'}
- Request.new 'put', "/applications/#{options[:app]}"
+ def update options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'put', "/applications/#{options[:name]}"
end
- def delete options={app: ':name'}
- Request.new 'delete', "/applications/#{options[:app]}"
+ def delete options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'delete', "/applications/#{options[:name]}"
end
- def log options={app: ':name'}
- Request.new 'get', "/applications/#{options[:app]}/log"
+ def log options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'get', "/applications/#{options[:name]}/log"
end
- def start options={app: ':name'}
- Request.new 'post', "/applications/#{options[:app]}/start"
+ def start options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'post', "/applications/#{options[:name]}/start"
end
- def stop options={app: ':name'}
- Request.new 'post', "/applications/#{options[:app]}/stop"
+ def stop options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'post', "/applications/#{options[:name]}/stop"
end
- def restart options={app: ':name'}
- Request.new 'post', "/applications/#{options[:app]}/restart"
+ def restart options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'post', "/applications/#{options[:name]}/restart"
end
- def redeploy options={app: ':name'}
- Request.new 'post', "/applications/#{options[:app]}/redeploy"
+ def redeploy options={}
+ require_options options, :name
+ options[:name] ||= ':name'
+ Request.new 'post', "/applications/#{options[:name]}/redeploy"
+ end
+
+ private
+
+ def require_options options, *keys
+ missing_keys = []
+ keys.each do |key|
+ if !options || options[key] == nil || options[key] == ''
+ missing_keys << key
+ end
+ end
+ unless missing_keys.empty?
+ raise MissingParameter, "Missing app parameter(s): "\
+ "#{missing_keys.map(&:to_s).join(', ')}"
+ end
end
end
end
end