cloudpassage 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.pryrc +2 -0
- data/README.md +3 -6
- data/cloudpassage.gemspec +1 -0
- data/lib/cloudpassage/base.rb +31 -2
- data/lib/cloudpassage/collection.rb +6 -0
- data/lib/cloudpassage/pry.rb +21 -0
- data/lib/cloudpassage/servers.rb +21 -3
- data/lib/cloudpassage/single.rb +2 -0
- data/lib/cloudpassage/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b229da23dd88544d97d05aeb8f991ce305ae82ba
|
4
|
+
data.tar.gz: fe1e3d48969292f1a7c16a6817d9c2c1267b71d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2daa7886646f2835de34e79ef9a713c7cf1f8f06b99cb538b73413defef3ac8ee2e9e6ecccc2e04955a9d1facfbdf9088b97f03fb92848dde757cb6ef86bea97
|
7
|
+
data.tar.gz: 78341b7317293e9240c225daf49fd25315df0453af25878277b57512ae620e1c3fd5cafb79f174bbf80ef68997ffcceff2cda20a91865b091904bb5ef06a19a1
|
data/.gitignore
CHANGED
data/.pryrc
ADDED
data/README.md
CHANGED
@@ -71,14 +71,11 @@ Or install it yourself as:
|
|
71
71
|
### Allocating a user to login with on a server:
|
72
72
|
```ruby
|
73
73
|
server = find_server_you_want_use_here
|
74
|
-
|
75
|
-
|
76
|
-
begin
|
77
|
-
command = server.command(command_id)
|
78
|
-
end while not(command['id'] == 'completed')
|
74
|
+
command = server.accounts.create('user', 'group')
|
75
|
+
command.wait_for{done?}
|
79
76
|
|
80
77
|
# You can use this password to login as the user.
|
81
|
-
password = command
|
78
|
+
password = command.password
|
82
79
|
```
|
83
80
|
|
84
81
|
|
data/cloudpassage.gemspec
CHANGED
data/lib/cloudpassage/base.rb
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
+
require 'wait'
|
2
|
+
|
1
3
|
module Cloudpassage
|
4
|
+
def self.wait_options
|
5
|
+
{
|
6
|
+
:attempts => 50000,
|
7
|
+
:timeout => 60,
|
8
|
+
:delay => 5,
|
9
|
+
:debug => false
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
2
13
|
class Base
|
3
14
|
def initialize(token, base_resource, data=nil)
|
4
15
|
@token = token
|
@@ -23,13 +34,25 @@ module Cloudpassage
|
|
23
34
|
end
|
24
35
|
|
25
36
|
def method_missing(sym, *args, &block)
|
26
|
-
if (
|
27
|
-
|
37
|
+
if (data && data[sym])
|
38
|
+
data[sym]
|
28
39
|
else
|
29
40
|
super(sym, *args, &block)
|
30
41
|
end
|
31
42
|
end
|
32
43
|
|
44
|
+
# Allows us to use any one of:
|
45
|
+
# object.id
|
46
|
+
# object['id']
|
47
|
+
# object[:id]
|
48
|
+
def [](key)
|
49
|
+
data[key.to_sym]
|
50
|
+
end
|
51
|
+
|
52
|
+
def post(payload)
|
53
|
+
JSON.parse(@base_resource.post payload.to_json, headers)
|
54
|
+
end
|
55
|
+
|
33
56
|
# Convert class name to symbol.
|
34
57
|
# eg: CloudPassage::Users --> :users
|
35
58
|
def object_symbol
|
@@ -38,5 +61,11 @@ module Cloudpassage
|
|
38
61
|
class_name[index+2..-1].underscore.to_sym
|
39
62
|
end
|
40
63
|
|
64
|
+
def wait_for(options={}, &block)
|
65
|
+
Wait.new(Cloudpassage::wait_options.merge(options)).until do
|
66
|
+
reload
|
67
|
+
instance_eval &block
|
68
|
+
end
|
69
|
+
end
|
41
70
|
end
|
42
71
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cloudpassage'
|
3
|
+
|
4
|
+
module Cloudpassage::Pry
|
5
|
+
def cloudpassage(type)
|
6
|
+
type_section = section(type)
|
7
|
+
Cloudpassage::Api.new(Cloudpassage.token(type_section['id'], type_section['secret']))
|
8
|
+
end
|
9
|
+
|
10
|
+
def section(type)
|
11
|
+
yaml[type.to_s]
|
12
|
+
end
|
13
|
+
|
14
|
+
def yaml
|
15
|
+
@@yaml ||= YAML.load(File.read(config_file))
|
16
|
+
end
|
17
|
+
|
18
|
+
def config_file
|
19
|
+
ENV.fetch('CLOUDPASSAGE_CONFIG_FILE', "#{ENV['HOME']}/.cloudpassagerc")
|
20
|
+
end
|
21
|
+
end
|
data/lib/cloudpassage/servers.rb
CHANGED
@@ -18,17 +18,27 @@ module Cloudpassage
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def accounts
|
21
|
-
Accounts.new(@token, @base_resource['accounts'])
|
21
|
+
Accounts.new(self, @token, @base_resource['accounts'])
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def commands
|
26
|
+
Commands.new(@token, @base_resource['commands'])
|
22
27
|
end
|
23
28
|
|
24
29
|
def command(id)
|
25
|
-
|
30
|
+
commands.get(id)
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
29
34
|
class Accounts < Base
|
30
35
|
include Collection
|
31
36
|
|
37
|
+
def initialize(server, token, base_resource, data=nil)
|
38
|
+
@server = server
|
39
|
+
super(token, base_resource, data)
|
40
|
+
end
|
41
|
+
|
32
42
|
def singleton_class
|
33
43
|
Account
|
34
44
|
end
|
@@ -44,7 +54,7 @@ module Cloudpassage
|
|
44
54
|
:groups => groups,
|
45
55
|
:password => password_opts.merge(opts.fetch(:password, {})),
|
46
56
|
}}
|
47
|
-
|
57
|
+
@server.commands.get(post(payload)['command']['id'])
|
48
58
|
end
|
49
59
|
|
50
60
|
def reset(username, opts = {})
|
@@ -79,6 +89,14 @@ module Cloudpassage
|
|
79
89
|
end
|
80
90
|
end
|
81
91
|
|
92
|
+
class Commands < Base
|
93
|
+
include Collection
|
94
|
+
|
95
|
+
def singleton_class
|
96
|
+
Command
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
82
100
|
class Command < Single
|
83
101
|
def done?
|
84
102
|
self.reload
|
data/lib/cloudpassage/single.rb
CHANGED
data/lib/cloudpassage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudpassage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mshea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: wait
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.5.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.5.1
|
83
97
|
description: API client for cloudpassage
|
84
98
|
email:
|
85
99
|
- mike.shea@gmail.com
|
@@ -88,6 +102,7 @@ extensions: []
|
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
104
|
- .gitignore
|
105
|
+
- .pryrc
|
91
106
|
- Gemfile
|
92
107
|
- LICENSE.txt
|
93
108
|
- README.md
|
@@ -108,6 +123,7 @@ files:
|
|
108
123
|
- lib/cloudpassage/firewall_zones.rb
|
109
124
|
- lib/cloudpassage/groups.rb
|
110
125
|
- lib/cloudpassage/policies.rb
|
126
|
+
- lib/cloudpassage/pry.rb
|
111
127
|
- lib/cloudpassage/servers.rb
|
112
128
|
- lib/cloudpassage/single.rb
|
113
129
|
- lib/cloudpassage/users.rb
|