Module: TeamCity::Client::Projects
- Included in:
- TeamCity::Client
- Defined in:
- lib/teamcity/client/projects.rb
Overview
Defines methods related to projects
Instance Method Summary collapse
-
#copy_project(source_project_id, target_project_name, options = {}) ⇒ Hashie::Mash
Copy another project.
-
#create_project(name) ⇒ Hashie::Mash
Create an empty project.
-
#delete_project(project_id) ⇒ nil
Delete a project.
-
#delete_project_parameter(project_id, parameter_name) ⇒ nil
Delete a project parameter.
-
#parent_project(options = {}) ⇒ Hashie::Mash
Get parent project.
-
#project(options = {}) ⇒ Hashie::Mash
Get project details.
-
#project_buildtypes(options = {}) ⇒ Array<Hashie::Mash> of build types (an empty array will be returne if none exist)
List of Build Configurations of a project.
-
#project_parameters(options = {}) ⇒ Array<Hashie::Mash>
List of parameters defined on a project.
-
#projects ⇒ Array<Hashie::Mash>?
List of projects.
-
#set_parent_project(project_id, parent_project_id) ⇒ Hashie::Mash
Set a parent for a given project.
-
#set_project_field(project_id, field_name, field_value) ⇒ String
Set a project field.
-
#set_project_parameter(project_id, parameter_name, parameter_value) ⇒ String
Set a project parameter (Create or Update).
Instance Method Details
#copy_project(source_project_id, target_project_name, options = {}) ⇒ Hashie::Mash
Copy another project
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/teamcity/client/projects.rb', line 75 def copy_project(source_project_id, target_project_name, ={}) attributes = { :name => target_project_name } payload = { 'sourceProject' => { locator: source_project_id } }.merge(attributes) post("projects", :content_type => :json, :accept => :json) do |req| req.body = payload.to_json end end |
#create_project(name) ⇒ Hashie::Mash
Create an empty project
60 61 62 63 64 |
# File 'lib/teamcity/client/projects.rb', line 60 def create_project(name) post("projects", :content_type => :text) do |req| req.body = name end end |
#delete_project(project_id) ⇒ nil
Delete a project
91 92 93 |
# File 'lib/teamcity/client/projects.rb', line 91 def delete_project(project_id) delete("projects/#{project_id}") end |
#delete_project_parameter(project_id, parameter_name) ⇒ nil
Delete a project parameter
100 101 102 103 104 |
# File 'lib/teamcity/client/projects.rb', line 100 def delete_project_parameter(project_id, parameter_name) path = "projects/#{project_id}/parameters/#{parameter_name}" delete(path, :accept => :text) return nil end |
#parent_project(options = {}) ⇒ Hashie::Mash
Get parent project
49 50 51 52 53 54 |
# File 'lib/teamcity/client/projects.rb', line 49 def parent_project(={}) () response = get("projects/#{locator()}/parentProject") return nil if response['id'] == '_Root' response end |
#project(options = {}) ⇒ Hashie::Mash
Get project details
19 20 21 22 |
# File 'lib/teamcity/client/projects.rb', line 19 def project(={}) () get("projects/#{locator()}") end |
#project_buildtypes(options = {}) ⇒ Array<Hashie::Mash> of build types (an empty array will be returne if none exist)
List of Build Configurations of a project
28 29 30 31 32 |
# File 'lib/teamcity/client/projects.rb', line 28 def project_buildtypes(={}) () response = get("projects/#{locator()}/buildTypes") response['buildType'] end |
#project_parameters(options = {}) ⇒ Array<Hashie::Mash>
List of parameters defined on a project
38 39 40 41 42 |
# File 'lib/teamcity/client/projects.rb', line 38 def project_parameters(={}) () response = get("projects/#{locator()}/parameters") response['property'] end |
#projects ⇒ Array<Hashie::Mash>?
List of projects
9 10 11 12 |
# File 'lib/teamcity/client/projects.rb', line 9 def projects response = get('projects') response['project'] end |
#set_parent_project(project_id, parent_project_id) ⇒ Hashie::Mash
Set a parent for a given project
149 150 151 152 153 154 155 156 |
# File 'lib/teamcity/client/projects.rb', line 149 def set_parent_project(project_id, parent_project_id) path = "projects/#{project_id}/parentProject" payload = { :id => parent_project_id } put(path, :content_type => :json, :accept => :json) do |req| req.body = payload.to_json end end |
#set_project_field(project_id, field_name, field_value) ⇒ String
Set a project field
133 134 135 136 137 138 |
# File 'lib/teamcity/client/projects.rb', line 133 def set_project_field(project_id, field_name, field_value) path = "projects/#{project_id}/#{field_name}" put(path, :content_type => :text, :accept => :text) do |req| req.body = field_value end end |
#set_project_parameter(project_id, parameter_name, parameter_value) ⇒ String
Set a project parameter (Create or Update)
113 114 115 116 117 118 |
# File 'lib/teamcity/client/projects.rb', line 113 def set_project_parameter(project_id, parameter_name, parameter_value) path = "projects/#{project_id}/parameters/#{parameter_name}" put(path, :content_type => :text, :accept => :text) do |req| req.body = parameter_value end end |