Sha256: b0e50b666ea5316adada9f96c4e18f7e050399e2349c77f8cf35ebeeba099784

Contents?: true

Size: 1.07 KB

Versions: 31

Compression:

Stored size: 1.07 KB

Contents

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

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

      def set_field(id, field, value)
        get("/devices/#{id}/set/#{field}/#{value}").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

31 entries across 31 versions & 1 rubygems

Version Path
onering-client-0.0.80 lib/onering/plugins/devices.rb
onering-client-0.0.79 lib/onering/plugins/devices.rb
onering-client-0.0.78 lib/onering/plugins/devices.rb
onering-client-0.0.77 lib/onering/plugins/devices.rb
onering-client-0.0.76 lib/onering/plugins/devices.rb
onering-client-0.0.75 lib/onering/plugins/devices.rb
onering-client-0.0.74 lib/onering/plugins/devices.rb
onering-client-0.0.73 lib/onering/plugins/devices.rb
onering-client-0.0.72 lib/onering/plugins/devices.rb
onering-client-0.0.71 lib/onering/plugins/devices.rb
onering-client-0.0.70 lib/onering/plugins/devices.rb
onering-client-0.0.69 lib/onering/plugins/devices.rb
onering-client-0.0.68 lib/onering/plugins/devices.rb
onering-client-0.0.67 lib/onering/plugins/devices.rb
onering-client-0.0.66 lib/onering/plugins/devices.rb
onering-client-0.0.65 lib/onering/plugins/devices.rb
onering-client-0.0.64 lib/onering/plugins/devices.rb
onering-client-0.0.63 lib/onering/plugins/devices.rb
onering-client-0.0.62 lib/onering/plugins/devices.rb
onering-client-0.0.61 lib/onering/plugins/devices.rb