class AptlyCli::AptlySnapshot

Aptly class to work with Snapshot API

Public Instance Methods

snapshot_create(name, repo, description=nil) click to toggle source
# File lib/aptly_snapshot.rb, line 24
def snapshot_create(name, repo, description=nil)
  # Build uri to create snapshot, requires name of snap and name of repo
  uri = "/repos/#{repo}/" + 'snapshots'

  self.class.post(uri, :body => 
                  { 'Name' => name,
                    'Description' => description }.to_json,
                       :headers => { 'Content-Type' => 'application/json' })
end
snapshot_create_ref(name, description=nil, sourcesnapshots=[], packagerefs=[]) click to toggle source
# File lib/aptly_snapshot.rb, line 34
def snapshot_create_ref(name, description=nil,
                        sourcesnapshots=[], packagerefs=[])
  uri = '/snapshots'
  begin
    self.class.post(uri,
                    :body => { 'Name' => name, 'Description' => description,
                             'SourceSnapshots' => sourcesnapshots,
                             'PackageRefs' => packagerefs }.to_json,
                    :headers => { 'Content-Type' => 'application/json' })
  rescue HTTParty::Error => e
    return e
  end
end
snapshot_delete(name, force=nil) click to toggle source
# File lib/aptly_snapshot.rb, line 12
def snapshot_delete(name, force=nil)
  uri = "/snapshots/#{name}"
  uri += '?force=1' if force == true
  self.class.delete(uri)
end
snapshot_diff(name, with_snapshot) click to toggle source
# File lib/aptly_snapshot.rb, line 48
def snapshot_diff(name, with_snapshot)
  uri = "/snapshots/#{name}/diff/#{with_snapshot}"
  self.class.get(uri)
end
snapshot_list(sort=nil) click to toggle source
# File lib/aptly_snapshot.rb, line 18
def snapshot_list(sort=nil)
  uri = '/snapshots'
  uri += "?sort=#{sort}" if sort
  self.class.get(uri)
end
snapshot_show(name) click to toggle source
# File lib/aptly_snapshot.rb, line 69
def snapshot_show(name)
  uri = "/snapshots/#{name}"
  self.class.get(uri)
end
snapshot_update(name, new_name, description=nil) click to toggle source
# File lib/aptly_snapshot.rb, line 74
def snapshot_update(name, new_name, description=nil)
  uri = "/snapshots/#{name}"
  snap_name = if new_name.nil?
                name
              else
                new_name
              end
  @query = {}
  @query[:Name] = snap_name
  @query[:Description] = description unless description.nil?
  @query_json = @query.to_json
  begin
    self.class.put(uri, :body => @query_json, :headers =>
                   { 'Content-Type' => 'application/json' })
  rescue HTTParty::Error => e
    puts e
  end
end