Class: TeamcityRuby::AgentPool
- Inherits:
-
Object
- Object
- TeamcityRuby::AgentPool
show all
- Extended by:
- Resource
- Defined in:
- lib/teamcity_ruby/agent_pool.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Resource
all, client, extended, find, locator, resource_name, url_path
Constructor Details
#initialize(options = {}) ⇒ AgentPool
Returns a new instance of AgentPool.
16
17
18
19
|
# File 'lib/teamcity_ruby/agent_pool.rb', line 16
def initialize(options = {})
@teamcity_id = options["id"].to_s
@name = options["name"]
end
|
Instance Attribute Details
#teamcity_id ⇒ Object
Returns the value of attribute teamcity_id.
5
6
7
|
# File 'lib/teamcity_ruby/agent_pool.rb', line 5
def teamcity_id
@teamcity_id
end
|
Class Method Details
.create(name, options = {}) ⇒ Object
10
11
12
13
14
|
# File 'lib/teamcity_ruby/agent_pool.rb', line 10
def self.create(name, options = {})
payload = { "name" => name }.to_json
response = client.post("/agentPools", :body => payload)
new(response)
end
|
Instance Method Details
#add_project(options = {}) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/teamcity_ruby/agent_pool.rb', line 25
def add_project(options = {})
raise "Agent pool needs a teamcity_id" unless self.teamcity_id
project_id = options.fetch(:project_id) { raise ":project_id is required" }
payload = { "id" => project_id }
response = client.post("/agentPools/id:#{self.teamcity_id}/projects", :body => payload.to_json)
end
|
#destroy! ⇒ Object
21
22
23
|
# File 'lib/teamcity_ruby/agent_pool.rb', line 21
def destroy!
client.delete("/agentPools/id:#{teamcity_id}")
end
|
#projects ⇒ Object
32
33
34
35
36
37
|
# File 'lib/teamcity_ruby/agent_pool.rb', line 32
def projects
raise "Agent pool needs a teamcity_id" unless self.teamcity_id
client.get("/agentPools/id:#{self.teamcity_id}/projects")["project"].map do |p|
Project.new(p)
end
end
|