rundeck 0.0.4 → 1.0.1

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: 31730efc03d57ef39d030de2aaec177f44d26a4e
4
- data.tar.gz: 193d25852a20e7a351760d90e4a9a311e1ed3210
3
+ metadata.gz: b7b621a7132091422a6aa3950967b078fc054949
4
+ data.tar.gz: 7d72079c260b9a6275735ac78ca95e8706fa78b6
5
5
  SHA512:
6
- metadata.gz: 7c0324e4bff89cbc319ad93c102c16927bb76928bd5be58f70679d570eb19d8a87f2ba895f6e2c9e2515d5da23193c065cbfce3d18661b18d85adefd952b8ae3
7
- data.tar.gz: 564b902d2ed2f4771495809585e32899d088ed7e289c6219cdbb9fab34d04d77e3efffb958668d34d51e414b6a850ca9af95e60311fe2914b5be701368f9dd3c
6
+ metadata.gz: 944acfc1b5262b541368af518080915062c060943171785cbd7fba87d1cb13c185db5ec369f6c54b02f03ae181265d686ebed0214e6e4c0a6140da6b5fce75ad
7
+ data.tar.gz: de90f30a173206965347ffea9e9812cce828604ba6571d0802378e675f5f3ccdd6c9172e289dbe5645a625997ecaff28131bcee7e3bc49b3d5062671787cee42
data/CHANGELOG.md CHANGED
@@ -1,2 +1,11 @@
1
- 0.0.4 (November 4, 2014)
2
- - First version with a CHANGELOG. Changes from here will be documented.
1
+ 1.0.1 (November 23, 2014)
2
+ - Version bump to push gem to RubyGems. Something during push caused an error
3
+ and re-pushing is not allowed.
4
+
5
+ 1.0.0 (November 23, 2014)
6
+ - First stable release
7
+ - Feature: Basic CRUD on Projects
8
+ - Feature: Token endpoints
9
+ - Feature: Most execution endpoints
10
+ - Feature: Job endpoints
11
+ - Feature: Private/Public key endpoints
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  # Rundeck Ruby Gem
2
2
 
3
- [Website](http://dblessing.github.io/rundeck-ruby)
3
+ [Official Website](http://dblessing.github.io/rundeck-ruby) with examples,
4
+ documentation, and links to the RDoc technical documentation.
4
5
 
5
- ## Work in progress. Not yet stable
6
-
7
- **Note: Although the git repository is called 'rundeck-ruby', the gem is called 'Rundeck' on Rubygems.org. There is another gem called 'rundeck-ruby' on Rubygems.org and it is not affiliated with this project.**
6
+ **Note: Although the git repository is called 'rundeck-ruby', the gem is called 'rundeck' on Rubygems.org. There is another gem called 'rundeck-ruby' on Rubygems.org and it is not affiliated with this project.**
8
7
 
9
8
  [![Gem Version](https://badge.fury.io/rb/rundeck.svg)](http://badge.fury.io/rb/rundeck)
10
9
  [![Build Status](https://travis-ci.org/dblessing/rundeck-ruby.svg?branch=master)](https://travis-ci.org/dblessing/rundeck-ruby)
@@ -14,12 +13,17 @@
14
13
 
15
14
  A Ruby wrapper around the Rundeck API.
16
15
 
17
- This library will strive to achieve reliable,
18
- 100% coverage of the Rundeck API. Please submit an issue if you find a bug and feel
16
+ This library will strive to achieve reliable coverage of the Rundeck API.
17
+ Please submit an issue if you find a bug and feel
19
18
  free to submit a pull request to contribute fixes or new features.
20
19
 
21
- The layout and the code in this library is inspired by https://github.com/NARKOZ/gitlab.
22
- NARKOZ does a fantastic job of keeping code simple and achieving API feature parity.
20
+ Initial versions of this gem to not achieve 100% coverage of the Rundeck API.
21
+ Each release will include more and more endpoint support until there is 100%
22
+ coverage.
23
+
24
+ The layout and the code in this library is inspired by
25
+ https://github.com/NARKOZ/gitlab. NARKOZ does a fantastic job of keeping code
26
+ simple and achieving API feature parity.
23
27
 
24
28
  See http://dblessing.github.io/rundeck-ruby for documentation
25
29
 
@@ -55,6 +55,7 @@ module Rundeck
55
55
  include Job
56
56
  include Key
57
57
  include Project
58
+ include Token
58
59
 
59
60
  # Turn a hash into an object for easy accessibility.
60
61
  #
@@ -2,12 +2,6 @@ module Rundeck
2
2
  class Client
3
3
  # Defines methods related to executions.
4
4
  module Execution
5
- def project_options_query(project, options)
6
- options[:query] = {} if options[:query].nil?
7
- options[:query]['project'] = project
8
- options
9
- end
10
-
11
5
  # Execute a job
12
6
  #
13
7
  # @!macro has_optional_params
@@ -177,13 +171,13 @@ module Rundeck
177
171
  objectify get('/executions', options)['result']['executions']
178
172
  end
179
173
 
180
- # def execution_output()
181
- #
182
- # end
183
- #
184
- # def execution_output_with_state()
185
- #
186
- # end
174
+ private
175
+
176
+ def project_options_query(project, options)
177
+ options[:query] = {} if options[:query].nil?
178
+ options[:query]['project'] = project
179
+ options
180
+ end
187
181
  end
188
182
  end
189
183
  end
@@ -30,13 +30,12 @@ module Rundeck
30
30
 
31
31
  # Delete a job
32
32
  #
33
- # @TODO: What does this return?!
34
- #
35
33
  # @example
36
34
  # Rundeck.delete_job('c07518ef-b697-4792-9a59-5b4f08855b67')
37
35
  #
38
36
  # @param [String] id Job id
39
37
  # @!macro options
38
+ # @return [nil] if the delete is successful
40
39
  # @!macro exceptions
41
40
  def delete_job(id, options = {})
42
41
  delete("/job/#{id}", options)
@@ -23,7 +23,10 @@ module Rundeck
23
23
  # Rundeck API documentation for 'POST /api/11/projects' endpoint
24
24
  #
25
25
  # @example
26
- # @TODO: Example
26
+ # Rundeck.create_project('{ "name": "json_project" }', 'json')
27
+ #
28
+ # @example
29
+ # Rundeck.create_project('<project><name>xml_project</name></project>', 'xml')
27
30
  #
28
31
  # @param [String] content The job definition(s) as yaml or xml
29
32
  # @param [String] format The project creation format. 'json|xml',
@@ -0,0 +1,63 @@
1
+ module Rundeck
2
+ class Client
3
+ # Defines methods related to managing security.
4
+ module Token
5
+ # List all tokens, or all tokens for a specific user.
6
+ #
7
+ # @example
8
+ # Rundeck.tokens
9
+ #
10
+ # @example
11
+ # Rundeck.tokens('admin')
12
+ #
13
+ # @param [String] user List tokens for this user.
14
+ # @!macro options
15
+ # @return [Rundeck::ObjectifiedHash] if there is only a single token
16
+ # @return [Array<Rundeck::ObjectifiedHash>] if there are multiple tokens
17
+ # @!macro exceptions
18
+ def tokens(user = nil, options = {})
19
+ path = user.nil? ? '/tokens' : "/tokens/#{user}"
20
+ objectify get(path, options)['tokens']
21
+ end
22
+
23
+ # Get a specific token
24
+ #
25
+ # @example
26
+ # Rundeck.token('admin')
27
+ #
28
+ # @param [String] id The token id
29
+ # @!macro options
30
+ # @return [Rundeck::ObjectifiedHash]
31
+ # @!macro exceptions
32
+ def token(id, options = {})
33
+ objectify get("/token/#{id}", options)['token']
34
+ end
35
+
36
+ # Create a new token for a user
37
+ #
38
+ # @example
39
+ # Rundeck.create_token('user1')
40
+ #
41
+ # @param [String] user Create a token for this user
42
+ # @!macro options
43
+ # @return [Rundeck::ObjectifiedHash]
44
+ # @!macro exceptions
45
+ def create_token(user, options = {})
46
+ objectify post("/tokens/#{user}", options)['token']
47
+ end
48
+
49
+ # Delete a token
50
+ #
51
+ # @example
52
+ # Rundeck.delete_token('cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd')
53
+ #
54
+ # @param [String] id The token id
55
+ # @!macro options
56
+ # @return [nil] if the delete is successful
57
+ # @!macro exceptions
58
+ def delete_token(id, options = {})
59
+ delete("/token/#{id}", options)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -32,10 +32,6 @@ module Rundeck
32
32
  '12'
33
33
  end
34
34
 
35
- def endpoint=(endpoint)
36
- @endpoint = "#{endpoint}/api/#{api_version}"
37
- end
38
-
39
35
  # Resets all configuration options to the defaults.
40
36
  def reset
41
37
  self.endpoint = ENV['RUNDECK_ENDPOINT']
@@ -44,7 +44,7 @@ module Rundeck
44
44
  when 503 then fail Error::ServiceUnavailable, error_message(response)
45
45
  end
46
46
 
47
- response.parsed_response
47
+ handle_response(response)
48
48
  end
49
49
 
50
50
  # Sets a base_uri and default_params for requests.
@@ -55,7 +55,7 @@ module Rundeck
55
55
  end
56
56
  @api_token = api_token
57
57
 
58
- self.class.base_uri endpoint
58
+ self.class.base_uri "#{endpoint}/api/#{Rundeck.api_version}"
59
59
  end
60
60
 
61
61
  private
@@ -84,6 +84,12 @@ module Rundeck
84
84
  end
85
85
  end
86
86
 
87
+ def handle_response(response)
88
+ response.parsed_response
89
+ rescue MultiXml::ParseError
90
+ raise Error::Parsing, 'An unexpected error occurred. Please try again'
91
+ end
92
+
87
93
  def error_message(response)
88
94
  message = if response.parsed_response && response.parsed_response['result']
89
95
  response.parsed_response['result']['error'][1]['message']
@@ -1,3 +1,3 @@
1
1
  module Rundeck
2
- VERSION = '0.0.4'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://192.168.50.2:4440/api/12/tokens/admin
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ X-Rundeck-Auth-Token:
11
+ - cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
12
+ Accept:
13
+ - application/xml
14
+ response:
15
+ status:
16
+ code: 201
17
+ message: Created
18
+ headers:
19
+ Set-Cookie:
20
+ - JSESSIONID=1941ar9mgoofz1m1uwnn1ocgyy;Path=/
21
+ Expires:
22
+ - Thu, 01 Jan 1970 00:00:00 GMT
23
+ X-Rundeck-Api-Xml-Response-Wrapper:
24
+ - 'false'
25
+ Content-Type:
26
+ - application/xml;charset=UTF-8
27
+ X-Rundeck-Api-Version:
28
+ - '12'
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Server:
32
+ - Jetty(7.6.0.v20120127)
33
+ body:
34
+ encoding: UTF-8
35
+ string: <token id='cbsQgUIZBOyCgoipJAwKd1YgfcwPJ0FY' user='admin' />
36
+ http_version:
37
+ recorded_at: Sun, 23 Nov 2014 16:00:00 GMT
38
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://192.168.50.2:4440/api/12/token/cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Rundeck-Auth-Token:
11
+ - cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
12
+ Accept:
13
+ - application/xml
14
+ response:
15
+ status:
16
+ code: 204
17
+ message: No Content
18
+ headers:
19
+ Set-Cookie:
20
+ - JSESSIONID=13o1yjpqta9yx198hq507djfhw;Path=/
21
+ Expires:
22
+ - Thu, 01 Jan 1970 00:00:00 GMT
23
+ Content-Type:
24
+ - text/html;charset=UTF-8
25
+ Server:
26
+ - Jetty(7.6.0.v20120127)
27
+ body:
28
+ encoding: UTF-8
29
+ string: ''
30
+ http_version:
31
+ recorded_at: Sun, 23 Nov 2014 18:34:34 GMT
32
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://192.168.50.2:4440/api/12/token/123456
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Rundeck-Auth-Token:
11
+ - cbsQgUIZBOyCgoipJAwKd1YgfcwPJ0FY
12
+ Accept:
13
+ - application/xml
14
+ response:
15
+ status:
16
+ code: 404
17
+ message: Not Found
18
+ headers:
19
+ Set-Cookie:
20
+ - JSESSIONID=u1d9tztnztpug1t3g2mchrtg;Path=/
21
+ Expires:
22
+ - Thu, 01 Jan 1970 00:00:00 GMT
23
+ Content-Type:
24
+ - text/xml;charset=UTF-8
25
+ X-Rundeck-Api-Version:
26
+ - '12'
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Server:
30
+ - Jetty(7.6.0.v20120127)
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ <result error='true' apiversion='12'>
35
+ <error code='api.error.item.doesnotexist'>
36
+ <message>Token does not exist: 123456</message>
37
+ </error>
38
+ </result>
39
+ http_version:
40
+ recorded_at: Sun, 23 Nov 2014 18:37:05 GMT
41
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://192.168.50.2:4440/api/12/token/cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Rundeck-Auth-Token:
11
+ - cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
12
+ Accept:
13
+ - application/xml
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Set-Cookie:
20
+ - JSESSIONID=wtzic3qqbt2utce9f4dv8nin;Path=/
21
+ Expires:
22
+ - Thu, 01 Jan 1970 00:00:00 GMT
23
+ X-Rundeck-Api-Xml-Response-Wrapper:
24
+ - 'false'
25
+ Content-Type:
26
+ - application/xml;charset=UTF-8
27
+ X-Rundeck-Api-Version:
28
+ - '12'
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Server:
32
+ - Jetty(7.6.0.v20120127)
33
+ body:
34
+ encoding: UTF-8
35
+ string: <token id='cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd' user='admin' />
36
+ http_version:
37
+ recorded_at: Sun, 23 Nov 2014 15:47:50 GMT
38
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://192.168.50.2:4440/api/12/token/123456
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Rundeck-Auth-Token:
11
+ - cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
12
+ Accept:
13
+ - application/xml
14
+ response:
15
+ status:
16
+ code: 404
17
+ message: Not Found
18
+ headers:
19
+ Set-Cookie:
20
+ - JSESSIONID=1t9cqr0wjp3o2r25nlk84cvyg;Path=/
21
+ Expires:
22
+ - Thu, 01 Jan 1970 00:00:00 GMT
23
+ Content-Type:
24
+ - text/xml;charset=UTF-8
25
+ X-Rundeck-Api-Version:
26
+ - '12'
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Server:
30
+ - Jetty(7.6.0.v20120127)
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ <result error='true' apiversion='12'>
35
+ <error code='api.error.item.doesnotexist'>
36
+ <message>Token does not exist: 123456</message>
37
+ </error>
38
+ </result>
39
+ http_version:
40
+ recorded_at: Sun, 23 Nov 2014 15:47:50 GMT
41
+ recorded_with: VCR 2.9.3