salt-api 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 295222261bd3f155d1557197be73c76185ae10a0
4
- data.tar.gz: f95b391cb805461a6075304af2688fbe1238643f
3
+ metadata.gz: fe9a4ef81da864ac063adcf8395bcd525bf668ae
4
+ data.tar.gz: 2fd665f9c80083d03cce40a6956b2cccc031bc0d
5
5
  SHA512:
6
- metadata.gz: 0310d924e740f482cc36b24794d9f90a6bdc6385a67002d128d34bc64a1bf43372fcb12d08d25b2ebcdfb5ab6ba8437deea08ba71f1163d47d0f16597a3c6f8e
7
- data.tar.gz: 115f856688124636dfa1ee650651682af1331bf5106da6a23072da5e8031eb4a1e9834f93a2f36d5daff835fb5fb1656350a606ef4739da64efacbe28ed6b865
6
+ metadata.gz: 37670e0c4712b16f7ee1fc04fb8d8500d6d762e10e591a6562e08ea2c91837f4861a3026ae6e1c8e20661d65243f8efab5ba8e88a7248f6bf8cbb0df9fa05e3e
7
+ data.tar.gz: 382de37d0717b03f5374a7546d9e4da7967038aa0fd8bf806f8fc732d31008c9d70ec2f2e86a90eb530b7892d388125a76d640756df7a08722e92cf5743d8a17
data/README.md CHANGED
@@ -35,6 +35,16 @@ end
35
35
  puts Salt::Api.minions
36
36
  ```
37
37
 
38
+ ```
39
+ require 'salt/api'
40
+
41
+ Salt::Api.run(
42
+ client: 'local',
43
+ tgt: '*',
44
+ fun: 'test.ping'
45
+ )
46
+ ```
47
+
38
48
  ## Development
39
49
 
40
50
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/salt/api.rb CHANGED
@@ -3,6 +3,7 @@ require "salt/api/configure"
3
3
  require "salt/api/client"
4
4
  require "salt/api/minions"
5
5
  require "salt/api/events"
6
+ require "salt/api/run"
6
7
 
7
8
  module Salt
8
9
  module Api
@@ -10,5 +11,6 @@ module Salt
10
11
  extend Client
11
12
  extend Minions
12
13
  extend Events
14
+ extend Run
13
15
  end
14
16
  end
@@ -0,0 +1,19 @@
1
+ module Salt
2
+ module Api
3
+ module Run
4
+ def run(args)
5
+ req = Net::HTTP::Post.new("/")
6
+ req['X-Auth-Token'] = token
7
+ req['Accept'] = "application/x-yaml"
8
+ req['Content-Type'] = "application/json"
9
+ req.body = args.to_json
10
+
11
+ resp = client.request(req)
12
+ raise "Get request to /run failed (#{resp})" unless resp.kind_of? Net::HTTPSuccess
13
+ parsed_resp = YAML.load(resp.body)["return"]
14
+ raise "Multiple results? (#{parsed_resp.inspect})" if parsed_resp.length > 1
15
+ parsed_resp.first
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Salt
2
2
  module Api
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salt-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua B. Bussdieker
@@ -87,6 +87,7 @@ files:
87
87
  - lib/salt/api/configure.rb
88
88
  - lib/salt/api/events.rb
89
89
  - lib/salt/api/minions.rb
90
+ - lib/salt/api/run.rb
90
91
  - lib/salt/api/version.rb
91
92
  - salt-api.gemspec
92
93
  homepage: https://github.com/jbussdieker/ruby-salt-api