titantic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f9194f27ef4f9c650e60aa2cc3246398b2693cc
4
+ data.tar.gz: b06fed33aa91e7969794d8eb3181ed19b7552b81
5
+ SHA512:
6
+ metadata.gz: 64cfbc94e69f1754b11e74f11e0a3ffcf29463ef879655fdeca31e69cb6cc4d42be68e3ac8a9e55e71c0fbef737cd3d082dc6477dc54f36edd758070cd9d1ce5
7
+ data.tar.gz: a3e557fdfe041c14371dd5d653fa9f798a36b0d4690f25c8e8b0ce435ba09bd9a7c4634aca6aae4dda184811db51a35b9492690bc2e4d5a8cda08350e54dd381
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ .gitconfig
20
+ *.swp
data/.titantic ADDED
@@ -0,0 +1,3 @@
1
+ aws_secret_access_key: 'secret_access_key'
2
+ aws_access_key_id: 'access_key_id'
3
+
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'thor'
4
+ gem 'fog'
5
+ gem 'unf'
6
+
7
+ group :development, :test do
8
+ gem 'minitest'
9
+ gem 'minitest-debugger'
10
+ gem 'minitest-ansi'
11
+ gem 'minitest-emoji'
12
+ gem 'minitest-growl'
13
+ gem 'rake'
14
+ gem 'pry'
15
+ gem 'minitest-vcr'
16
+ gem 'webmock', '<1.16'
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,80 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ ansi (1.4.3)
6
+ builder (3.2.2)
7
+ coderay (1.1.0)
8
+ crack (0.4.2)
9
+ safe_yaml (~> 1.0.0)
10
+ database_cleaner (1.2.0)
11
+ excon (0.31.0)
12
+ fog (1.20.0)
13
+ builder
14
+ excon (~> 0.31.0)
15
+ formatador (~> 0.2.0)
16
+ mime-types
17
+ multi_json (~> 1.0)
18
+ net-scp (~> 1.1)
19
+ net-ssh (>= 2.1.3)
20
+ nokogiri (>= 1.5.11)
21
+ formatador (0.2.4)
22
+ growl (1.0.3)
23
+ method_source (0.8.2)
24
+ mime-types (2.1)
25
+ mini_portile (0.5.2)
26
+ minispec-metadata (2.0.0)
27
+ minitest
28
+ minitest (5.3.1)
29
+ minitest-ansi (0.1.2)
30
+ ansi (~> 1.3)
31
+ minitest (>= 2.5)
32
+ minitest-debugger (1.0.2)
33
+ minitest (~> 5.0)
34
+ minitest-emoji (2.0.0)
35
+ minitest-growl (0.0.3)
36
+ growl
37
+ minitest
38
+ minitest-vcr (0.1.0)
39
+ database_cleaner (>= 1.0.1)
40
+ minispec-metadata (~> 2.0.0)
41
+ minitest (>= 4.7.5)
42
+ vcr (~> 2.8.0)
43
+ multi_json (1.9.0)
44
+ net-scp (1.1.2)
45
+ net-ssh (>= 2.6.5)
46
+ net-ssh (2.8.0)
47
+ nokogiri (1.6.1)
48
+ mini_portile (~> 0.5.0)
49
+ pry (0.9.12.6)
50
+ coderay (~> 1.0)
51
+ method_source (~> 0.8)
52
+ slop (~> 3.4)
53
+ rake (10.1.1)
54
+ safe_yaml (1.0.2)
55
+ slop (3.5.0)
56
+ thor (0.18.1)
57
+ unf (0.1.4)
58
+ unf_ext
59
+ unf_ext (0.0.6)
60
+ vcr (2.8.0)
61
+ webmock (1.15.2)
62
+ addressable (>= 2.2.7)
63
+ crack (>= 0.3.2)
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ fog
70
+ minitest
71
+ minitest-ansi
72
+ minitest-debugger
73
+ minitest-emoji
74
+ minitest-growl
75
+ minitest-vcr
76
+ pry
77
+ rake
78
+ thor
79
+ unf
80
+ webmock (< 1.16)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Nathan Claburn
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ titantic
2
+ ========
3
+
4
+ A very simple [Glacier](http://aws.amazon.com/glacier/) command line client
5
+
6
+ Overview
7
+ ---------
8
+ Titantic is meant to be a bare bones [Glacier](http://aws.amazon.com/glacier/) command line client. The main purpose of Titantic is to so it can be easily used by backup scripts in cron jobs, etc. Titantic uses [Fog](http://github.com/fog/fog) underneath for all [Glacier](http://aws.amazon.com/glacier/) communication.
9
+
10
+ Configuration
11
+ ---------
12
+ Currently Titantic uses the same configuration as [Fog](http://github.com/fog/fog). Titantic searches for configuration in 3 ways.
13
+
14
+ 1. A file in the current directory named `.titantic`
15
+ 2. A file in the user's home directory named `.titantic`
16
+ 3. An environment variable named `TITANTIC_CONFIG` that points to a yaml file
17
+
18
+
19
+ Usage
20
+ ---------
21
+ The command set for Titantic is focused on getting data to [Glacier](http://aws.amazon.com/glacier/). At the moment there is no method to retrieve archives or even vault content listings.
22
+
23
+ <pre>
24
+ Commands:
25
+ titantic.rb create_vault [VAULT] # create a new vault
26
+ titantic.rb delete_vault [VAULT] # delete a vault with the ...
27
+ titantic.rb help [COMMAND] # Describe available comma...
28
+ titantic.rb list_vaults # retrieve a listing of va...
29
+ titantic.rb upload [VAULT] [BODY] [DESCRIPTION] # upload the given archive...
30
+ </pre>
31
+
32
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ t.test_files = ['test/titantic_test.rb']
6
+ t.verbose = true
7
+ end
data/bin/titantic ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'titantic'
4
+ Titantic.new(ARGV)
@@ -0,0 +1,84 @@
1
+ require 'thor'
2
+ require 'yaml'
3
+ require 'openssl'
4
+ require 'fog'
5
+
6
+ class Titantic < Thor
7
+
8
+ def initialize(args = [], options = {}, configs = {})
9
+ super
10
+
11
+ if File.exists?('.titantic')
12
+ config = YAML.load_file('.titantic')
13
+ elsif File.exists?(File.join(Dir.home, '.titantic'))
14
+ config = YAML.load_file(File.join(Dir.home, '.titantic'))
15
+ else
16
+ if(ENV['TITANTIC_CONFIG'])
17
+ File.exists?(ENV['TITANTIC_CONFIG'])
18
+ config = YAML.load_file(ENV['TITANTIC_CONFIG'])
19
+ end
20
+ end
21
+
22
+ unless config
23
+ puts "Could not load configuration."
24
+ puts "Titantic configuration is YAML format and must exist in 1 of 3 places"
25
+ puts "1. in the current directory as a file named '.titantic' "
26
+ puts "2. in the current user's home directory as a file named '.titantic' "
27
+ puts "3. as a file path specified by the environment variable 'TITANTIC_CONFIG'"
28
+ end
29
+
30
+ @glacier = Fog::AWS::Glacier.new config
31
+ end
32
+
33
+ desc 'upload [VAULT] [BODY] [DESCRIPTION]', 'upload the given archive into the given vault'
34
+ def upload_archive(vault_name, body, options = {})
35
+ vault = @glacier.vaults.get vault_name
36
+ unless vault
37
+ print Hash[ status: 'error', error: "Vault #{vault_name} does not exist" ].to_json
38
+ return
39
+ end
40
+
41
+ unless File.exists?(body)
42
+ print Hash[ status: 'error', error: "Archive #{body} does not exist" ].to_json
43
+ return
44
+ end
45
+
46
+ body = File.read(body)
47
+ response = @glacier.create_archive(vault_name, body, options)
48
+
49
+ if response.status == 201
50
+ print Hash[ status: 'success' ].to_json
51
+ return
52
+ end
53
+
54
+ print [ status: 'error', error: response.headers ].to_json
55
+ end
56
+
57
+ desc 'create_vault [VAULT]', 'create a new vault'
58
+ def create_vault(vault_name)
59
+ begin
60
+ vault = @glacier.vaults.create :id => vault_name
61
+ rescue Exception => e
62
+ print [ status: 'error', error: e.to_s]
63
+ end
64
+ print vault.to_json
65
+ end
66
+
67
+ desc 'delete_vault [VAULT]', 'delete a vault with the given name'
68
+ def delete_vault(vault_name)
69
+ vault = @glacier.vaults.get vault_name
70
+ unless vault
71
+ print Hash[ status: 'error', error: "Vault #{vault_name} does not exist" ].to_json
72
+ return
73
+ end
74
+ print @glacier.delete_vault(vault_name).data.to_json
75
+ end
76
+
77
+ desc 'list_vaults', 'retrieve a listing of vault names'
78
+ def list_vaults
79
+ response = @glacier.list_vaults
80
+ print response.data[:body]["VaultList"].collect{ |v| v["VaultName"] }.to_json
81
+ end
82
+ end
83
+
84
+ Titantic.start(ARGV)
@@ -0,0 +1,3 @@
1
+ module Titantic
2
+ VERSION = "0.0.1"
3
+ end
data/lib/titantic.rb ADDED
@@ -0,0 +1 @@
1
+ require 'titantic/titantic'
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.20.0
12
+ Date:
13
+ - Sun, 30 Mar 2014 21:40:18 +0000
14
+ X-Amz-Date:
15
+ - 20140330T214018Z
16
+ X-Amz-Glacier-Version:
17
+ - '2012-06-01'
18
+ Authorization:
19
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
20
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=request_signature
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: ''
25
+ headers:
26
+ X-Amzn-Requestid:
27
+ - request_id
28
+ Content-Type:
29
+ - application/json
30
+ Content-Length:
31
+ - '214'
32
+ Date:
33
+ - Sun, 30 Mar 2014 21:40:19 GMT
34
+ body:
35
+ encoding: UTF-8
36
+ string: "{\"CreationDate\":\"2014-03-11T03:09:28.824Z\",\"LastInventoryDate\":\"2014-03-24T22:15:31.553Z\",\"NumberOfArchives\":3,\"SizeInBytes\":98379,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/test\",\"VaultName\":\"test\"}"
37
+ http_version:
38
+ recorded_at: Sun, 30 Mar 2014 21:40:19 GMT
39
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,151 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/blah
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.20.0
12
+ Date:
13
+ - Sun, 30 Mar 2014 21:40:19 +0000
14
+ X-Amz-Date:
15
+ - 20140330T214019Z
16
+ X-Amz-Glacier-Version:
17
+ - '2012-06-01'
18
+ Authorization:
19
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
20
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
21
+ response:
22
+ status:
23
+ code: 404
24
+ message: ''
25
+ headers:
26
+ X-Amzn-Requestid:
27
+ - some_request_id
28
+ Content-Type:
29
+ - application/json
30
+ Content-Length:
31
+ - '140'
32
+ Date:
33
+ - Sun, 30 Mar 2014 21:40:19 GMT
34
+ body:
35
+ encoding: UTF-8
36
+ string: "{\"code\":\"ResourceNotFoundException\",\"message\":\"Vault not found
37
+ for ARN: arn:aws:glacier:gvaults/blah\",\"type\":\"Client\"}"
38
+ http_version:
39
+ recorded_at: Sun, 30 Mar 2014 21:40:19 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/blah
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ User-Agent:
48
+ - fog/1.20.0
49
+ Date:
50
+ - Sun, 30 Mar 2014 21:40:19 +0000
51
+ X-Amz-Date:
52
+ - 20140330T214019Z
53
+ X-Amz-Glacier-Version:
54
+ - '2012-06-01'
55
+ Authorization:
56
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
57
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
58
+ response:
59
+ status:
60
+ code: 404
61
+ message: ''
62
+ headers:
63
+ X-Amzn-Requestid:
64
+ - some_request_id
65
+ Content-Type:
66
+ - application/json
67
+ Content-Length:
68
+ - '140'
69
+ Date:
70
+ - Sun, 30 Mar 2014 21:40:19 GMT
71
+ body:
72
+ encoding: UTF-8
73
+ string: "{\"code\":\"ResourceNotFoundException\",\"message\":\"Vault not found
74
+ for ARN: arn:aws:glacier:gvaults/blah\",\"type\":\"Client\"}"
75
+ http_version:
76
+ recorded_at: Sun, 30 Mar 2014 21:40:19 GMT
77
+ - request:
78
+ method: get
79
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/blah
80
+ body:
81
+ encoding: US-ASCII
82
+ string: ''
83
+ headers:
84
+ User-Agent:
85
+ - fog/1.20.0
86
+ Date:
87
+ - Sun, 30 Mar 2014 21:40:19 +0000
88
+ X-Amz-Date:
89
+ - 20140330T214019Z
90
+ X-Amz-Glacier-Version:
91
+ - '2012-06-01'
92
+ Authorization:
93
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
94
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
95
+ response:
96
+ status:
97
+ code: 404
98
+ message: ''
99
+ headers:
100
+ X-Amzn-Requestid:
101
+ - some_request_id
102
+ Content-Type:
103
+ - application/json
104
+ Content-Length:
105
+ - '140'
106
+ Date:
107
+ - Sun, 30 Mar 2014 21:40:19 GMT
108
+ body:
109
+ encoding: UTF-8
110
+ string: "{\"code\":\"ResourceNotFoundException\",\"message\":\"Vault not found
111
+ for ARN: arn:aws:glacier:gvaults/blah\",\"type\":\"Client\"}"
112
+ http_version:
113
+ recorded_at: Sun, 30 Mar 2014 21:40:20 GMT
114
+ - request:
115
+ method: get
116
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/blah
117
+ body:
118
+ encoding: US-ASCII
119
+ string: ''
120
+ headers:
121
+ User-Agent:
122
+ - fog/1.20.0
123
+ Date:
124
+ - Sun, 30 Mar 2014 21:40:19 +0000
125
+ X-Amz-Date:
126
+ - 20140330T214019Z
127
+ X-Amz-Glacier-Version:
128
+ - '2012-06-01'
129
+ Authorization:
130
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
131
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
132
+ response:
133
+ status:
134
+ code: 404
135
+ message: ''
136
+ headers:
137
+ X-Amzn-Requestid:
138
+ - some_request_id
139
+ Content-Type:
140
+ - application/json
141
+ Content-Length:
142
+ - '140'
143
+ Date:
144
+ - Sun, 30 Mar 2014 21:40:19 GMT
145
+ body:
146
+ encoding: UTF-8
147
+ string: "{\"code\":\"ResourceNotFoundException\",\"message\":\"Vault not found
148
+ for ARN: arn:aws:glacier:gvaults/blah\",\"type\":\"Client\"}"
149
+ http_version:
150
+ recorded_at: Sun, 30 Mar 2014 21:40:20 GMT
151
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,89 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.20.0
12
+ Date:
13
+ - Sun, 30 Mar 2014 21:40:20 +0000
14
+ X-Amz-Date:
15
+ - 20140330T214020Z
16
+ X-Amz-Glacier-Version:
17
+ - '2012-06-01'
18
+ Authorization:
19
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
20
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: ''
25
+ headers:
26
+ X-Amzn-Requestid:
27
+ - some_request_id
28
+ Content-Type:
29
+ - application/json
30
+ Content-Length:
31
+ - '214'
32
+ Date:
33
+ - Sun, 30 Mar 2014 21:40:20 GMT
34
+ body:
35
+ encoding: UTF-8
36
+ string: "{\"CreationDate\":\"2014-03-11T03:09:28.824Z\",\"LastInventoryDate\":\"2014-03-24T22:15:31.553Z\",\"NumberOfArchives\":3,\"SizeInBytes\":98379,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/test\",\"VaultName\":\"test\"}"
37
+ http_version:
38
+ recorded_at: Sun, 30 Mar 2014 21:40:20 GMT
39
+ - request:
40
+ method: post
41
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/test/archives
42
+ body:
43
+ encoding: UTF-8
44
+ string: |
45
+ this is a test text file
46
+ headers:
47
+ User-Agent:
48
+ - fog/1.20.0
49
+ Content-Length:
50
+ - '25'
51
+ X-Amz-Content-Sha256:
52
+ - 9f1506a6916acdcd3552dd6225a2b28179a76f9c8dcd6bbc025c71556229c2ac
53
+ X-Amz-Sha256-Tree-Hash:
54
+ - 9f1506a6916acdcd3552dd6225a2b28179a76f9c8dcd6bbc025c71556229c2ac
55
+ Date:
56
+ - Sun, 30 Mar 2014 21:40:20 +0000
57
+ X-Amz-Date:
58
+ - 20140330T214020Z
59
+ X-Amz-Glacier-Version:
60
+ - '2012-06-01'
61
+ Authorization:
62
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
63
+ SignedHeaders=content-length;date;host;x-amz-content-sha256;x-amz-date;x-amz-glacier-version;x-amz-sha256-tree-hash,
64
+ Signature=some_signature
65
+ response:
66
+ status:
67
+ code: 201
68
+ message: ''
69
+ headers:
70
+ X-Amzn-Requestid:
71
+ - some_request_id
72
+ X-Amz-Sha256-Tree-Hash:
73
+ - 9f1506a6916acdcd3552dd6225a2b28179a76f9c8dcd6bbc025c71556229c2ac
74
+ Location:
75
+ - "/some_vault_location/vaults/test/archives/e43XYyIx7i7fdG9QmYcrTw8uR5JDtZRAk-GVgtW_e-BNRo5SgGhRmcVoSisbiJha2zparQ4A-rj5PD2BttENA3iu106i7OMPHGHnChocLIgJe1YwfMbH54mluDBLTwZC2FRCPSBQFA"
76
+ X-Amz-Archive-Id:
77
+ - e43XYyIx7i7fdG9QmYcrTw8uR5JDtZRAk-GVgtW_e-BNRo5SgGhRmcVoSisbiJha2zparQ4A-rj5PD2BttENA3iu106i7OMPHGHnChocLIgJe1YwfMbH54mluDBLTwZC2FRCPSBQFA
78
+ Content-Type:
79
+ - application/json
80
+ Content-Length:
81
+ - '2'
82
+ Date:
83
+ - Sun, 30 Mar 2014 21:40:20 GMT
84
+ body:
85
+ encoding: UTF-8
86
+ string: "{}"
87
+ http_version:
88
+ recorded_at: Sun, 30 Mar 2014 21:40:21 GMT
89
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,77 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.20.0
12
+ Date:
13
+ - Sun, 30 Mar 2014 21:40:22 +0000
14
+ X-Amz-Date:
15
+ - 20140330T214022Z
16
+ X-Amz-Glacier-Version:
17
+ - '2012-06-01'
18
+ Authorization:
19
+ - AWS4-HMAC-SHA256 Credential=some_credential/20140330/us-east-1/glacier/aws4_request,
20
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
21
+ response:
22
+ status:
23
+ code: 201
24
+ message: ''
25
+ headers:
26
+ X-Amzn-Requestid:
27
+ - some_request_id
28
+ Location:
29
+ - "/some_vault_place/vaults/test"
30
+ Content-Type:
31
+ - application/json
32
+ Content-Length:
33
+ - '2'
34
+ Date:
35
+ - Sun, 30 Mar 2014 21:40:21 GMT
36
+ body:
37
+ encoding: UTF-8
38
+ string: "{}"
39
+ http_version:
40
+ recorded_at: Sun, 30 Mar 2014 21:40:22 GMT
41
+ - request:
42
+ method: get
43
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/test
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ''
47
+ headers:
48
+ User-Agent:
49
+ - fog/1.20.0
50
+ Date:
51
+ - Sun, 30 Mar 2014 21:40:22 +0000
52
+ X-Amz-Date:
53
+ - 20140330T214022Z
54
+ X-Amz-Glacier-Version:
55
+ - '2012-06-01'
56
+ Authorization:
57
+ - AWS4-HMAC-SHA256 Credential=some_credential/20140330/us-east-1/glacier/aws4_request,
58
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: ''
63
+ headers:
64
+ X-Amzn-Requestid:
65
+ - some_request_id
66
+ Content-Type:
67
+ - application/json
68
+ Content-Length:
69
+ - '214'
70
+ Date:
71
+ - Sun, 30 Mar 2014 21:40:22 GMT
72
+ body:
73
+ encoding: UTF-8
74
+ string: "{\"CreationDate\":\"2014-03-11T03:09:28.824Z\",\"LastInventoryDate\":\"2014-03-24T22:15:31.553Z\",\"NumberOfArchives\":3,\"SizeInBytes\":98379,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/test\",\"VaultName\":\"test\"}"
75
+ http_version:
76
+ recorded_at: Sun, 30 Mar 2014 21:40:22 GMT
77
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.20.0
12
+ Date:
13
+ - Sun, 30 Mar 2014 21:40:22 +0000
14
+ X-Amz-Date:
15
+ - 20140330T214022Z
16
+ X-Amz-Glacier-Version:
17
+ - '2012-06-01'
18
+ Authorization:
19
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
20
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: ''
25
+ headers:
26
+ X-Amzn-Requestid:
27
+ - some_request_id
28
+ Content-Type:
29
+ - application/json
30
+ Content-Length:
31
+ - '684'
32
+ Date:
33
+ - Sun, 30 Mar 2014 21:40:23 GMT
34
+ body:
35
+ encoding: UTF-8
36
+ string: "{\"Marker\":null,\"VaultList\":[{\"CreationDate\":\"2014-02-22T20:10:56.989Z\",\"LastInventoryDate\":\"2014-02-23T16:36:05.615Z\",\"NumberOfArchives\":0,\"SizeInBytes\":0,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/Images\",\"VaultName\":\"Images\"},{\"CreationDate\":\"2012-09-09T14:56:11.033Z\",\"LastInventoryDate\":\"2012-09-13T14:04:02.055Z\",\"NumberOfArchives\":13795,\"SizeInBytes\":59899548908,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/mp3s\",\"VaultName\":\"mp3s\"},{\"CreationDate\":\"2014-03-11T03:09:28.824Z\",\"LastInventoryDate\":\"2014-03-24T22:15:31.553Z\",\"NumberOfArchives\":3,\"SizeInBytes\":98379,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/test\",\"VaultName\":\"test\"}]}"
37
+ http_version:
38
+ recorded_at: Sun, 30 Mar 2014 21:40:23 GMT
39
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,145 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/deleteme
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.20.0
12
+ Date:
13
+ - Sun, 30 Mar 2014 21:40:21 +0000
14
+ X-Amz-Date:
15
+ - 20140330T214021Z
16
+ X-Amz-Glacier-Version:
17
+ - '2012-06-01'
18
+ Authorization:
19
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
20
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
21
+ response:
22
+ status:
23
+ code: 201
24
+ message: ''
25
+ headers:
26
+ X-Amzn-Requestid:
27
+ - some_request_id
28
+ Location:
29
+ - "/vault_thing/vaults/deleteme"
30
+ Content-Type:
31
+ - application/json
32
+ Content-Length:
33
+ - '2'
34
+ Date:
35
+ - Sun, 30 Mar 2014 21:40:20 GMT
36
+ body:
37
+ encoding: UTF-8
38
+ string: "{}"
39
+ http_version:
40
+ recorded_at: Sun, 30 Mar 2014 21:40:21 GMT
41
+ - request:
42
+ method: get
43
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/deleteme
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ''
47
+ headers:
48
+ User-Agent:
49
+ - fog/1.20.0
50
+ Date:
51
+ - Sun, 30 Mar 2014 21:40:21 +0000
52
+ X-Amz-Date:
53
+ - 20140330T214021Z
54
+ X-Amz-Glacier-Version:
55
+ - '2012-06-01'
56
+ Authorization:
57
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
58
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: ''
63
+ headers:
64
+ X-Amzn-Requestid:
65
+ - some_request_id
66
+ Content-Type:
67
+ - application/json
68
+ Content-Length:
69
+ - '196'
70
+ Date:
71
+ - Sun, 30 Mar 2014 21:40:20 GMT
72
+ body:
73
+ encoding: UTF-8
74
+ string: "{\"CreationDate\":\"2014-03-30T21:40:21.549Z\",\"LastInventoryDate\":null,\"NumberOfArchives\":0,\"SizeInBytes\":0,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/deleteme\",\"VaultName\":\"deleteme\"}"
75
+ http_version:
76
+ recorded_at: Sun, 30 Mar 2014 21:40:21 GMT
77
+ - request:
78
+ method: get
79
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/deleteme
80
+ body:
81
+ encoding: US-ASCII
82
+ string: ''
83
+ headers:
84
+ User-Agent:
85
+ - fog/1.20.0
86
+ Date:
87
+ - Sun, 30 Mar 2014 21:40:21 +0000
88
+ X-Amz-Date:
89
+ - 20140330T214021Z
90
+ X-Amz-Glacier-Version:
91
+ - '2012-06-01'
92
+ Authorization:
93
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
94
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
95
+ response:
96
+ status:
97
+ code: 200
98
+ message: ''
99
+ headers:
100
+ X-Amzn-Requestid:
101
+ - Vco-some_request_id
102
+ Content-Type:
103
+ - application/json
104
+ Content-Length:
105
+ - '196'
106
+ Date:
107
+ - Sun, 30 Mar 2014 21:40:21 GMT
108
+ body:
109
+ encoding: UTF-8
110
+ string: "{\"CreationDate\":\"2014-03-30T21:40:21.549Z\",\"LastInventoryDate\":null,\"NumberOfArchives\":0,\"SizeInBytes\":0,\"VaultARN\":\"arn:aws:glacier:us-east-1:blahblahblah:vaults/deleteme\",\"VaultName\":\"deleteme\"}"
111
+ http_version:
112
+ recorded_at: Sun, 30 Mar 2014 21:40:21 GMT
113
+ - request:
114
+ method: delete
115
+ uri: https://glacier.us-east-1.amazonaws.com/-/vaults/deleteme
116
+ body:
117
+ encoding: US-ASCII
118
+ string: ''
119
+ headers:
120
+ User-Agent:
121
+ - fog/1.20.0
122
+ Date:
123
+ - Sun, 30 Mar 2014 21:40:21 +0000
124
+ X-Amz-Date:
125
+ - 20140330T214021Z
126
+ X-Amz-Glacier-Version:
127
+ - '2012-06-01'
128
+ Authorization:
129
+ - AWS4-HMAC-SHA256 Credential=secret_credential/20140330/us-east-1/glacier/aws4_request,
130
+ SignedHeaders=date;host;x-amz-date;x-amz-glacier-version, Signature=some_signature
131
+ response:
132
+ status:
133
+ code: 204
134
+ message: ''
135
+ headers:
136
+ X-Amzn-Requestid:
137
+ - some_request_id
138
+ Date:
139
+ - Sun, 30 Mar 2014 21:40:21 GMT
140
+ body:
141
+ encoding: UTF-8
142
+ string: ''
143
+ http_version:
144
+ recorded_at: Sun, 30 Mar 2014 21:40:21 GMT
145
+ recorded_with: VCR 2.8.0
data/test/test.txt ADDED
@@ -0,0 +1 @@
1
+ this is a test text file
@@ -0,0 +1,14 @@
1
+ require 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'vcr'
4
+ require 'minitest-vcr'
5
+ require 'webmock'
6
+
7
+
8
+ VCR.configure do |c|
9
+ c.cassette_library_dir = 'test/cassettes'
10
+ c.hook_into :webmock
11
+ end
12
+
13
+
14
+ MinitestVcr::Spec.configure!
@@ -0,0 +1,55 @@
1
+ require 'titantic/titantic'
2
+ require 'test_helper'
3
+
4
+ class TitanticTest < MiniTest::Test
5
+ include MiniTest::Assertions
6
+ def setup
7
+ end
8
+
9
+ describe 'Archive services', :vcr do
10
+ #describe 'Archive services' do
11
+ it 'uploads the given archive' do
12
+ titantic = Titantic.new
13
+ out = capture_io { titantic.upload_archive("test", "test/test.txt", description: 'some description', account_id: '-') }
14
+ assert_equal Hash[ "status" => "success"], JSON.parse(out[0])
15
+ end
16
+
17
+ it 'fails to upload the given archive because vault does not exist' do
18
+ titantic = Titantic.new
19
+ out = capture_io { titantic.upload_archive("blah", "test/test.txt", description: 'some description', account_id: '-') }
20
+ assert_equal Hash["status" => "error", "error" => "Vault blah does not exist"], JSON.parse(out[0])
21
+ end
22
+
23
+ it 'fails to upload the given archive because archive does not exist on disk' do
24
+ titantic = Titantic.new
25
+ out = capture_io { titantic.upload_archive("test", "no archive", description: 'some description', account_id: '-') }
26
+ assert_equal Hash["status" => "error", "error" => "Archive no archive does not exist"], JSON.parse(out[0])
27
+ end
28
+ end
29
+
30
+ describe 'Vault services', :vcr do
31
+ #describe 'Vault services' do
32
+ it 'creates a new vault' do
33
+ titantic = Titantic.new
34
+ out = capture_io { titantic.create_vault("test") }
35
+ data = JSON.parse(out[0])
36
+ data["arn"] = "arn:aws:glacier:someserver:vaults/test"
37
+ assert_equal Hash["id" => "test", "created_at" => "2014-03-11 03:09:28 UTC", "last_inventory_at" => "2014-03-24 22:15:31 UTC", "number_of_archives" => 3, "size_in_bytes" => 98379, "arn" => "arn:aws:glacier:someserver:vaults/test"], data
38
+ end
39
+
40
+ it 'should delete a vault' do
41
+ titantic = Titantic.new
42
+ titantic.create_vault("deleteme")
43
+ out = capture_io { titantic.delete_vault("deleteme") }
44
+ data = JSON.parse(out[0])
45
+ data["headers"]["X-Amzn-Requestid"] = 'some id'
46
+ assert_equal Hash["body" => "", "headers" => { "X-Amzn-Requestid" => "some id", "Date" => "Sun, 30 Mar 2014 21:40:21 GMT"}, "status" => 204, "remote_ip" => "127.0.0.1"], data
47
+ end
48
+
49
+ it 'list all vaults' do
50
+ titantic = Titantic.new
51
+ out = capture_io { titantic.list_vaults }
52
+ assert_equal ["Images","mp3s","test"], JSON.parse(out[0])
53
+ end
54
+ end
55
+ end
data/titantic.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'titantic/version'
5
+ require 'bundler'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "titantic"
9
+ spec.version = Titantic::VERSION
10
+ spec.authors = ["Nathan Claburn"]
11
+ spec.email = ["nathan.claburn@1st-edge.com"]
12
+ spec.summary = %q{A very simple AWS Glacier command line utility based on Fog.}
13
+ spec.description = %q{Titantic is meant to be a very simple Glacier command line utility. The primary focus is for it to be used in backup scripts and cron jobs.}
14
+ spec.homepage = "http://github.com/nclaburn/titantic"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake", "~> 10.1"
24
+ spec.add_development_dependency "minitest", "~> 5.3"
25
+
26
+ Bundler.require(:default, :development)
27
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: titantic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Claburn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.3'
55
+ description: Titantic is meant to be a very simple Glacier command line utility. The
56
+ primary focus is for it to be used in backup scripts and cron jobs.
57
+ email:
58
+ - nathan.claburn@1st-edge.com
59
+ executables:
60
+ - titantic
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".titantic"
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/titantic
72
+ - lib/titantic.rb
73
+ - lib/titantic/titantic.rb
74
+ - lib/titantic/version.rb
75
+ - test/cassettes/Archive_services/fails_to_upload_the_given_archive_because_archive_does_not_exist_on_disk.yml
76
+ - test/cassettes/Archive_services/fails_to_upload_the_given_archive_because_vault_does_not_exist.yml
77
+ - test/cassettes/Archive_services/uploads_the_given_archive.yml
78
+ - test/cassettes/Vault_services/creates_a_new_vault.yml
79
+ - test/cassettes/Vault_services/list_all_vaults.yml
80
+ - test/cassettes/Vault_services/should_delete_a_vault.yml
81
+ - test/test.txt
82
+ - test/test_helper.rb
83
+ - test/titantic_test.rb
84
+ - titantic.gemspec
85
+ homepage: http://github.com/nclaburn/titantic
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.0
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: A very simple AWS Glacier command line utility based on Fog.
109
+ test_files:
110
+ - test/cassettes/Archive_services/fails_to_upload_the_given_archive_because_archive_does_not_exist_on_disk.yml
111
+ - test/cassettes/Archive_services/fails_to_upload_the_given_archive_because_vault_does_not_exist.yml
112
+ - test/cassettes/Archive_services/uploads_the_given_archive.yml
113
+ - test/cassettes/Vault_services/creates_a_new_vault.yml
114
+ - test/cassettes/Vault_services/list_all_vaults.yml
115
+ - test/cassettes/Vault_services/should_delete_a_vault.yml
116
+ - test/test.txt
117
+ - test/test_helper.rb
118
+ - test/titantic_test.rb