Class: Croesus::ResourceDSL

Inherits:
Object show all
Includes:
DSLHelpers, ModFactory
Defined in:
lib/croesus/dsl/resource_dsl.rb

Instance Method Summary collapse

Methods included from ModFactory

#add_description, #add_method, #add_root_endpoint

Methods included from Utils

#callable, #caller_name, #camelize, #class_name, #classify, #command_in_path?, #demodulize, #pluralize, #request_id, #retrier, #singularize, #terminal_dimensions, #twenty_four_hours_ago, #underscore, #utc_httpdate, #verify_options

Constructor Details

#initialize(name, &block) ⇒ ResourceDSL

Returns a new instance of ResourceDSL.



28
29
30
31
32
33
34
35
# File 'lib/croesus/dsl/resource_dsl.rb', line 28

def initialize(name, &block)
  Croesus::ModFactory.instance_method(:initialize).bind(self).call(name)
  instance_eval(&block)
  @description ||= description
  @root ||= root
  add_description(@description)
  add_root_endpoint(@root)
end

Instance Method Details

#delete(path, &block) ⇒ Object



53
# File 'lib/croesus/dsl/resource_dsl.rb', line 53

def delete(path,  &block) route 'DELETE',  path, &block end

#get(path, &block) ⇒ Object

The following HTTP methods are supported by the Delphix Appliance:

 GET - Retrieve data from the server where complex input is not needed.
       All GET requests are guaranteed to be read-only, but not all
       read-only requests are required to use GET. Simple input
       (strings, number, boolean values) can be passed as query
       parameters.
POST - Issue a read/write operation, or make a read-only call that
       requires complex input. The optional body of the call is
       expressed as JSON.

DELETE - Delete an object on the system. For languages that don’t provide

a native wrapper for DELETE, or for delete operations with
optional input, all delete operations can also be invoked as POST
to the same URL with /delete appended to it.


51
# File 'lib/croesus/dsl/resource_dsl.rb', line 51

def get(path,     &block) route 'GET',     path, &block end

#post(path, &block) ⇒ Object



52
# File 'lib/croesus/dsl/resource_dsl.rb', line 52

def post(path,    &block) route 'POST',    path, &block end

#route(verb, path, &block) ⇒ Object



55
56
57
# File 'lib/croesus/dsl/resource_dsl.rb', line 55

def route(verb, path, &block)
  add_method(Croesus::RouteDSL.new(verb, path, &block))
end