aws_clim 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +38 -8
- data/lib/aws_clim/version.rb +1 -1
- data/lib/aws_clim.rb +4 -55
- metadata +1 -2
- data/aws_clim-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac0cd640f3b253853487800afc8dce04cfc1792d3322d62099d0d3ec0e6988e4
|
4
|
+
data.tar.gz: 39eeb60f7b3ec2613a7a3c6ef12ff772c437412fa1ebffd2d1c9a3fe4cc59c24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 456cda408a13813578cad9b2c777e982e8c95bdb4de14e55503fe0a7cf9124e2e03d34d49a9552d07a5924e9dc2e1d87f5a065794ae3b92ea0b102dac1d168d2
|
7
|
+
data.tar.gz: b054f592c2f7584e8e3ee9facd0e59f1b01b165a5c2ae44fcf1e206e34e6cab1a0c1c9fba978cde57a0fef3bbd3aa264a6a1f6a00af21be32dfded73050561c5
|
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# AwsClim
|
2
2
|
|
3
|
-
|
3
|
+
AwsClim is a light wrapper around `aws cli` tool. it adds some convenience when calling the command and
|
4
|
+
dealing with the results.
|
4
5
|
|
5
|
-
|
6
|
+
- Maps all aws services as a method on AwsClim instance.
|
7
|
+
- Set format as JSON as default.
|
8
|
+
- Deals with arguments as Array, Hash or simply string
|
9
|
+
- Parses all results as JSON
|
10
|
+
- Returns an `OpenStruct.new(error: true, success: false, data: err)` when error happens.
|
11
|
+
- Returns an `OpenStruct.new(error: false, success: true, data: JSON.parse(out, object_class: OpenStruct))` when command returns successfuly.
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
@@ -22,18 +28,42 @@ Or install it yourself as:
|
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
31
|
+
```
|
32
|
+
aws = AwsClim.new()
|
33
|
+
```
|
26
34
|
|
27
|
-
|
35
|
+
By calling new without parameters AwsClim uses the profile `default`(see https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_profiles.html to learn about aws profiles).
|
36
|
+
To set a different profile use profile argument on new.
|
28
37
|
|
29
|
-
|
38
|
+
```
|
39
|
+
aws = AwsClim.new(profile: 'other-profile')
|
40
|
+
```
|
30
41
|
|
31
|
-
|
42
|
+
With a instance of AwsClim call aws services by its name and pass subcommands and options:
|
32
43
|
|
33
|
-
|
44
|
+
Examples:
|
34
45
|
|
35
|
-
|
46
|
+
```
|
47
|
+
# Subcommand
|
36
48
|
|
49
|
+
aws.iam('list-users').data.Users
|
50
|
+
```
|
51
|
+
|
52
|
+
```
|
53
|
+
# Subcommand + Arguments
|
54
|
+
|
55
|
+
result = aws.apigateway('put-method-response', {
|
56
|
+
'rest-api-id' => rest_api['id'],
|
57
|
+
'resource-id' => resource['id'],
|
58
|
+
'http-method' => 'GET',
|
59
|
+
'status-code' => '200',
|
60
|
+
'response-parameters' => 'method.response.header.access-control-allow-origin=false'
|
61
|
+
})
|
62
|
+
|
63
|
+
result.success?
|
64
|
+
result.error?
|
65
|
+
result.data
|
66
|
+
```
|
37
67
|
|
38
68
|
## License
|
39
69
|
|
data/lib/aws_clim/version.rb
CHANGED
data/lib/aws_clim.rb
CHANGED
@@ -1,63 +1,13 @@
|
|
1
|
+
require 'ostruct'
|
1
2
|
require 'json'
|
2
3
|
require 'open3'
|
3
4
|
|
4
5
|
class AwsClim
|
5
|
-
def initialize(profile
|
6
|
+
def initialize(profile: 'default', global_options: {})
|
6
7
|
@profile = profile
|
7
8
|
@global_options = global_options
|
8
9
|
end
|
9
10
|
|
10
|
-
class SimpleResult
|
11
|
-
attr_reader :data
|
12
|
-
|
13
|
-
def initialize(data)
|
14
|
-
@data = data
|
15
|
-
end
|
16
|
-
|
17
|
-
def error?
|
18
|
-
false
|
19
|
-
end
|
20
|
-
|
21
|
-
def success?
|
22
|
-
true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class ItemsResult < SimpleResult
|
27
|
-
include Enumerable
|
28
|
-
|
29
|
-
attr_reader :data, :items
|
30
|
-
|
31
|
-
def initialize(data)
|
32
|
-
super
|
33
|
-
@items = data['items']
|
34
|
-
end
|
35
|
-
|
36
|
-
def each(&block)
|
37
|
-
@data.fetch('items').each(&block)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class ErrorResult
|
42
|
-
attr_reader :message
|
43
|
-
|
44
|
-
def initialize(message)
|
45
|
-
@message = message
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_s
|
49
|
-
"Error: #{@message}"
|
50
|
-
end
|
51
|
-
|
52
|
-
def success?
|
53
|
-
false
|
54
|
-
end
|
55
|
-
|
56
|
-
def error?
|
57
|
-
true
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
11
|
%w(
|
62
12
|
accessanalyzer
|
63
13
|
account
|
@@ -388,10 +338,9 @@ class AwsClim
|
|
388
338
|
out, err, status = Open3.capture3(cmd)
|
389
339
|
|
390
340
|
if status.success?
|
391
|
-
|
392
|
-
result.key?('items') ? ItemsResult.new(result) : SimpleResult.new(result)
|
341
|
+
OpenStruct.new(success?: true, error?: false, data: JSON.parse(out, object_class: OpenStruct))
|
393
342
|
else
|
394
|
-
|
343
|
+
OpenStruct.new(success?: false, error?: true, data: err)
|
395
344
|
end
|
396
345
|
end
|
397
346
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_clim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew S Aguiar
|
@@ -24,7 +24,6 @@ files:
|
|
24
24
|
- Gemfile.lock
|
25
25
|
- LICENSE.txt
|
26
26
|
- README.md
|
27
|
-
- aws_clim-0.1.0.gem
|
28
27
|
- aws_clim.gemspec
|
29
28
|
- bin/console
|
30
29
|
- lib/aws_clim.rb
|
data/aws_clim-0.1.0.gem
DELETED
Binary file
|