Sha256: 36dbf25601fa3aa8f3e1874489257a664fe229fd4bac46d52cc4a408266909e4

Contents?: true

Size: 1.16 KB

Versions: 21

Compression:

Stored size: 1.16 KB

Contents

module Onering
  class API
    class Devices < API
      def show(id)
        get("/devices/#{id}").parsed_response
      end

      def get_field(id, field)
        rv = get("/devices/#{id}/get/#{field}")
        rv.parsed_response rescue rv.response.body
      end

      def set_field(id, field, value)
        rv = get("/devices/#{id}/set/#{field}/#{value}")
        rv.parsed_response rescue rv.response.body
      end

      def list(field, options={
        :unique => true,
        :sort   => true,
        :filter => nil
      })
        qs = {
          :q => make_filter(options[:filter])
        } if options[:filter]

        rv = get("/devices/list/#{field}", {
          :query => qs
        }).parsed_response

        rv = rv.uniq if options[:unique]
        rv = rv.sort if options[:sort]

        return rv
      end

      def find(filter, options={})
        get("/devices/find/#{make_filter(filter)}").parsed_response
      end

      def save(id, data=nil, &block)
        if block_given?
          post("/devices/#{id}", {}, &block)
        else
          post("/devices/#{id}", {
            :body => data
          })
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
onering-client-0.1.2 lib/onering/plugins/devices.rb
onering-client-0.1.1 lib/onering/plugins/devices.rb
onering-client-0.0.99 lib/onering/plugins/devices.rb
onering-client-0.0.98 lib/onering/plugins/devices.rb
onering-client-0.0.97 lib/onering/plugins/devices.rb
onering-client-0.0.96 lib/onering/plugins/devices.rb
onering-client-0.0.95 lib/onering/plugins/devices.rb
onering-client-0.0.94 lib/onering/plugins/devices.rb
onering-client-0.0.93 lib/onering/plugins/devices.rb
onering-client-0.0.92 lib/onering/plugins/devices.rb
onering-client-0.0.91 lib/onering/plugins/devices.rb
onering-client-0.0.90 lib/onering/plugins/devices.rb
onering-client-0.0.89 lib/onering/plugins/devices.rb
onering-client-0.0.88 lib/onering/plugins/devices.rb
onering-client-0.0.87 lib/onering/plugins/devices.rb
onering-client-0.0.86 lib/onering/plugins/devices.rb
onering-client-0.0.85 lib/onering/plugins/devices.rb
onering-client-0.0.84 lib/onering/plugins/devices.rb
onering-client-0.0.83 lib/onering/plugins/devices.rb
onering-client-0.0.82 lib/onering/plugins/devices.rb