module TeamcityRuby class AgentPool extend TeamcityRuby::Resource attr_accessor :teamcity_id url_path "/agentPools" resource_name "agentPool" def self.create(name, options = {}) payload = { "name" => name }.to_json response = client.post("/agentPools", :body => payload) new(response) end def initialize(options = {}) @teamcity_id = options["id"] @name = options["name"] end def destroy! client.delete("/agentPools/id:#{teamcity_id}") end 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 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 end end