Class: AptlyCli::AptlySnapshot
  
  
  
Overview
  
    
Aptly class to work with Snapshot API
   
 
  
  Instance Attribute Summary
  
  Attributes inherited from AptlyCommand
  #config
  
    
      Instance Method Summary
      collapse
    
    
      
        - 
  
    
      #snapshot_create(name, repo, description = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_create_ref(name, description = nil, sourcesnapshots = [], packagerefs = [])  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_delete(name, force = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_diff(name, with_snapshot)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_list(sort = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_search(name, search_options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_show(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #snapshot_update(name, new_name, description = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
    
  
  
  
  
  
  
  
  
  
  
  
  #delete, #get, #initialize, #post, #process_response, #put
  
  
    Instance Method Details
    
      
  
  
    #snapshot_create(name, repo, description = nil)  ⇒ Object 
  
  
  
  
    
      
24
25
26
27
28
29
30
31
32 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 24
def snapshot_create(name, repo, description=nil)
    uri = "/repos/#{repo}/" + 'snapshots'
  post(uri, :body =>
                  { 'Name' => name,
                    'Description' => description }.to_json,
                       :headers => { 'Content-Type' => 'application/json' })
end
     | 
  
 
    
      
  
  
    #snapshot_create_ref(name, description = nil, sourcesnapshots = [], packagerefs = [])  ⇒ Object 
  
  
  
  
    
      
34
35
36
37
38
39
40
41
42
43
44
45
46 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 34
def snapshot_create_ref(name, description=nil,
                        sourcesnapshots=[], packagerefs=[])
  uri = '/snapshots'
  begin
    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)  ⇒ Object 
  
  
  
  
    
      
12
13
14
15
16 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 12
def snapshot_delete(name, force=nil)
  uri = "/snapshots/#{name}"
  uri += '?force=1' if force == true
  delete(uri)
end
     | 
  
 
    
      
  
  
    #snapshot_diff(name, with_snapshot)  ⇒ Object 
  
  
  
  
    
      
48
49
50
51 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 48
def snapshot_diff(name, with_snapshot)
  uri = "/snapshots/#{name}/diff/#{with_snapshot}"
  get(uri)
end
     | 
  
 
    
      
  
  
    #snapshot_list(sort = nil)  ⇒ Object 
  
  
  
  
    
      
18
19
20
21
22 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 18
def snapshot_list(sort=nil)
  uri = '/snapshots'
  uri += "?sort=#{sort}" if sort
  get(uri)
end
     | 
  
 
    
      
  
  
    #snapshot_search(name, search_options = {})  ⇒ Object 
  
  
  
  
    
      
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 53
def snapshot_search(name, search_options={})
  uri = "/snapshots/#{name}/packages"
  @options = { query: {} }
  if search_options.key?(:format)
    @options[:query] = { format: search_options[:format].to_s }
  end
  if search_options.key?(:q)
    @options[:query] = { q: "Name (~ #{search_options[:q]})" }
  end
  @options[:query] = { withDeps:  '1' } if search_options[:withDeps] == true
  get(uri, @options)
end
     | 
  
 
    
      
  
  
    #snapshot_show(name)  ⇒ Object 
  
  
  
  
    
      
69
70
71
72 
     | 
    
      # File 'lib/aptly_snapshot.rb', line 69
def snapshot_show(name)
  uri = "/snapshots/#{name}"
  get(uri)
end
     | 
  
 
    
      
  
  
    #snapshot_update(name, new_name, description = nil)  ⇒ Object 
  
  
  
  
    
      
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 
     | 
    
      # 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
    put(uri, :body => @query_json, :headers =>
                   { 'Content-Type' => 'application/json' })
  rescue HTTParty::Error => e
    puts e
  end
end
     |