class AptlyAPI::Package
This class represents an Aptly Package
Attributes
architecture[R]
description[R]
name[R]
priority[R]
version[R]
Public Class Methods
new(server, json)
click to toggle source
Creates a new Package
definitation with data json
located on server
# File lib/package.rb, line 12 def initialize(server, json) @server = server @http = Net::HTTP.new(@server.host, @server.port) info = hget("/api/packages/#{json}") if !info.is_a?(Integer) @name = info['Package'] @description = info['Description'] @architecture = info['Architecture'] @priority = info['Priority'] @version = info['Version'] end end
Protected Instance Methods
hdelete(path)
click to toggle source
Sends HTTP delete call to path
# File lib/package.rb, line 63 def hdelete(path) request = Net::HTTP::Delete.new("#{@server.path}#{URI.escape(path)}") response = @http.request(request) return response.code.to_i end
hget(path)
click to toggle source
Get an hash of JSON data from server path
# File lib/package.rb, line 32 def hget(path) request = Net::HTTP::Get.new("#{@server.path}#{URI.escape(path)}") response = @http.request(request) if response.code.to_i != 200 return response.code.to_i end return JSON.parse(response.body) end
hpost(path, data)
click to toggle source
Post data
hash to path
as JSON
# File lib/package.rb, line 43 def hpost(path, data) request = Net::HTTP::Post.new("#{@server.path}#{URI.escape(path)}") request.add_field('Content-Type', 'application/json') request.body = data.to_json response = @http.request(request) return response.code.to_i end
hput(path, data)
click to toggle source
Put data
hash to path
as JSON
# File lib/package.rb, line 53 def hput(path, data) request = Net::HTTP::Put.new("#{@server.path}#{URI.escape(path)}") request.add_field('Content-Type', 'application/json') request.body = data.to_json response = @http.request(request) return response.code.to_i end