Class: Rundeck::Project
- Inherits:
-
Object
show all
- Defined in:
- lib/rundeck-ruby/project.rb
Defined Under Namespace
Classes: ResourceQueryBuilder
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(session, hash) ⇒ Project
Returns a new instance of Project.
14
15
16
17
|
# File 'lib/rundeck-ruby/project.rb', line 14
def initialize(session, hash)
@session = session
@name = hash['name']
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
18
19
20
|
# File 'lib/rundeck-ruby/project.rb', line 18
def name
@name
end
|
#session ⇒ Object
Returns the value of attribute session.
18
19
20
|
# File 'lib/rundeck-ruby/project.rb', line 18
def session
@session
end
|
Class Method Details
.all(session) ⇒ Object
3
4
5
6
7
8
|
# File 'lib/rundeck-ruby/project.rb', line 3
def self.all(session)
@all ||= begin
result = session.get('api/3/projects', 'result', 'projects', 'project') || []
result.map{|hash| Project.new(session, hash)}
end
end
|
.find(session, name) ⇒ Object
10
11
12
|
# File 'lib/rundeck-ruby/project.rb', line 10
def self.find(session, name)
all(session).first{|p| p.name == name}
end
|
Instance Method Details
#job(id) ⇒ Object
26
27
28
|
# File 'lib/rundeck-ruby/project.rb', line 26
def job(id)
jobs.find{|j| j.id == id}
end
|
#jobs(force_reload = false) ⇒ Object
20
21
22
23
24
|
# File 'lib/rundeck-ruby/project.rb', line 20
def jobs(force_reload = false)
return @jobs unless @jobs.nil? || force_reload
result = session.get("api/2/jobs?project=#{name}", 'result', 'jobs', 'job') || []
@jobs = result.map{|hash| Job.from_hash(session, hash)}
end
|
#resource(resource_name) ⇒ Object
41
42
43
|
# File 'lib/rundeck-ruby/project.rb', line 41
def resource(resource_name)
session.get("api/1/resource/#{resource_name}?project=#{name}", 'project', 'node')
end
|
#resources {|qb| ... } ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rundeck-ruby/project.rb', line 30
def resources
qb = ResourceQueryBuilder.new
yield qb if block_given?
endpoint = "api/3/resources?project=#{name}&#{qb.query}"
pp endpoint
session.get(endpoint, 'project', 'node')
end
|