Method: Proby::ProbyTask.create
- Defined in:
- lib/proby/proby_task.rb
.create(attributes = {}) ⇒ ProbyTask
Create a new Proby task.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/proby/proby_task.rb', line 119 def self.create(attributes={}) ensure_api_key_set raise InvalidParameterException.new("attributes are required") if attributes.nil? || attributes.empty? raise InvalidParameterException.new("name is required") unless !blank?(attributes[:name]) || !blank?(attributes['name']) raise InvalidParameterException.new("crontab is required") unless !blank?(attributes[:crontab]) || !blank?(attributes['crontab']) Proby.logger.info "Creating task with attributes: #{attributes.inspect}" response = post("/api/v1/tasks.json", :format => :json, :body => MultiJson.encode(:task => attributes), :headers => default_headers) if response.code == 201 new(response.parsed_response['task']) else handle_api_failure(response) end end |