support/ruby/collins-client/lib/collins/asset.rb
def from_json json_hash, bare_asset = false
        (raise Collins::CollinsError.new("Invalid JSON specified for Asset.from_json")) if (json_hash.nil? || !json_hash.is_a?(Hash))
        json = deep_copy_hash json_hash
        json = if json["data"] then json["data"] else json end
        if bare_asset or !json.include?("ASSET") then
          asset = Collins::Asset.new json
        else
          asset = Collins::Asset.new json.delete("ASSET")
        end
        asset.send('ipmi='.to_sym, Collins::Ipmi.from_json(json.delete("IPMI")))
        asset.send('addresses='.to_sym, Collins::Address.from_json(json.delete("ADDRESSES")))
        asset.send('power='.to_sym, Collins::Power.from_json(json.delete("POWER")))
        asset.send('location=', json.delete("LOCATION"))
        asset.send('extras=', json)
        asset
      end
# Given a Hash deserialized from JSON, convert to an Asset
# @param [Hash] json_hash Asset representation
# @param [Boolean] bare_asset Exists for API compatability, largely not needed
# @return [Collins::Asset] The asset
# @raise [Collins::CollinsError] If the specified hash is invalid
Given a Hash deserialized from JSON, convert to an Asset
Given a Hash deserialized from JSON convert to an Asset
def from_json json_hash, bare_asset = false
        (raise Collins::CollinsError.new("Invalid JSON specified for Asset.from_json")) if (json_hash.nil? || !json_hash.is_a?(Hash))
        json = deep_copy_hash json_hash
        json = if json["data"] then json["data"] else json end
        if bare_asset or !json.include?("ASSET") then
          asset = Collins::Asset.new json
        else
          asset = Collins::Asset.new json.delete("ASSET")
        end
        asset.send('ipmi='.to_sym, Collins::Ipmi.from_json(json.delete("IPMI")))
        asset.send('addresses='.to_sym, Collins::Address.from_json(json.delete("ADDRESSES")))
        asset.send('power='.to_sym, Collins::Power.from_json(json.delete("POWER")))
        asset.send('location=', json.delete("LOCATION"))
        asset.send('extras=', json)
        asset
      end
def from_json json_hash , bare_asset = false ( raise Collins :: CollinsError . new ( "Invalid JSON specified for Asset.from_json" ) ) if ( json_hash . nil? || ! json_hash . is_a? ( Hash ) ) json = deep_copy_hash json_hash json = if json [ "data" ] then json [ "data" ] else json end if bare_asset or ! json . include? ( "ASSET" ) then asset = Collins :: Asset . new json else asset = Collins :: Asset . new json . delete ( "ASSET" ) end asset . send ( 'ipmi=' . to_sym , Collins :: Ipmi . from_json ( json . delete ( "IPMI" ) ) ) asset . send ( 'addresses=' . to_sym , Collins :: Address . from_json ( json . delete ( "ADDRESSES" ) ) ) asset . send ( 'power=' . to_sym , Collins :: Power . from_json ( json . delete ( "POWER" ) ) ) asset . send ( 'location=' , json . delete ( "LOCATION" ) ) asset . send ( 'extras=' , json ) asset end
Given a Hash deserialized from JSON, convert to an Asset
Given a Hash deserialized from JSON convert to an Asset
None
Collins::Asset
[Collins::CollinsError] If the specified hash is invalid
[ Collins :: CollinsError ] If the specified hash is invalid
json_hash
bare_asset
bare_asset Exists for API compatability, largely not needed
bare_asset Exists for API compatability largely not needed