module RightScale::Api::GatewayExtend

Public Instance Methods

create(*args) click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 300
def create(*args)
  if args.last.is_a?(Hash)
    opts = args.pop
  else
    raise ArgumentError.new("create requires the last argument to be a Hash")
  end
  url = "#{parse_args(*args)}#{self.resource_plural_name}"
  location = connection.post(url, self.resource_post_name.to_sym => opts)
  newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ])
  newrecord.reload
  newrecord
end
filters() click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 291
def filters()
  []
end
find(*args) click to toggle source
Calls superclass method RightScale::Api::BaseExtend#find
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 238
def find(*args)
  if args.length > 1
    id = args.pop
    url = "#{parse_args(*args)}#{self.resource_plural_name}/#{id}"
    return self.new(connection.get(url))
  else
    return super(*args)
  end
end
find_all(*args) click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 248
def find_all(*args)
  a = Array.new
  url = "#{parse_args(*args)}#{self.resource_plural_name}"
  connection.get(url).each do |object|
    a << self.new(object)
  end
  return a
end
find_by(attrib, *args) { |s| ... } click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 227
def find_by(attrib, *args, &block)
  attrib = attrib.to_sym
  attrib = :name if attrib == :nickname
  if self.filters.include?(attrib)
    connection.logger("#{self} includes the filter '#{attrib}', you might be able to speed up this API call")
  end
  self.find_all(*args).select do |s|
    yield(s[attrib.to_s])
  end
end
find_with_filter(*args) click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 257
def find_with_filter(*args)
  filter_params = []
  filter = {}
  filter = args.pop if args.last.is_a?(Hash)
  filter.each { |key,val|
    unless self.filters.include?(key.to_sym)
      raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
    end
    filter_params << "#{key}==#{val}"
  }
  a = Array.new
  url = "#{parse_args(*args)}#{self.resource_plural_name}"
  connection.get(url, :filter => filter_params).each do |object|
    a << self.new(object)
  end
  return a
end
load(url) click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 275
def load(url)
  return self.new(connection.get(url))
end
load_all(url) click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 279
def load_all(url)
  a = Array.new
  connection.get(url).each do |object|
    a << self.new(object)
  end
  return a
end
parse_args() click to toggle source
# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 287
def parse_args()
  nil
end
resource_post_name() click to toggle source

Hack for McMultiCloudImageSetting class to fix a API quirk

# File lib/rest_connection/rightscale/rightscale_api_gateway.rb, line 296
def resource_post_name
  self.resource_singular_name
end