Module: Rundeck::Client::Project

Included in:
Rundeck::Client
Defined in:
lib/rundeck/client/project.rb

Overview

Defines methods related to projects.

Instance Method Summary collapse

Instance Method Details

#create_project(content, format = 'json', options = {}) ⇒ Rundeck::ObjectifiedHash

Create a project

Examples:

Rundeck.create_project('{ "name": "json_project" }', 'json')
Rundeck.create_project('<project><name>xml_project</name></project>', 'xml')

Parameters:

  • content (String)

    The job definition(s) as yaml or xml

  • format (String) (defaults to: 'json')

    The project creation format. ‘json|xml’, defaults to ‘json’

  • options (Hash) (defaults to: {})

    A set of options passed directly to HTTParty. See rubydoc.info/gems/httparty/HTTParty/ClassMethods

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

Raises:

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rundeck/client/project.rb', line 37

def create_project(content, format = 'json', options = {})
  options[:headers] = {} if options[:headers].nil?
  options[:headers] = if format == 'json'
                        options[:headers].merge!(
                            'Content-Type' => 'application/json')
                      elsif format == 'xml'
                        options[:headers].merge!(
                            'Content-Type' => 'application/xml')
                      else
                        fail Error::InvalidAttributes,
                             'format must be json or xml'
                      end
  options[:body] = content

  objectify post('/projects', options)['project']
end

#delete_project(name, options = {}) ⇒ Object

Delete a project

Examples:

Rundeck.delete_project('my_project')

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

  • nil

Raises:

See Also:



82
83
84
# File 'lib/rundeck/client/project.rb', line 82

def delete_project(name, options = {})
  objectify delete("/project/#{name}", options)
end

#project(name, options = {}) ⇒ Rundeck::ObjectifiedHash

Get a project by name

Examples:

Rundeck.project('anvils')

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

Raises:

See Also:



66
67
68
# File 'lib/rundeck/client/project.rb', line 66

def project(name, options = {})
  objectify get("/project/#{name}", options)['project']
end

#projects(options = {}) ⇒ Rundeck::ObjectifiedHash

Get all projects

Examples:

Rundeck.projects

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

Raises:

See Also:



16
17
18
# File 'lib/rundeck/client/project.rb', line 16

def projects(options = {})
  objectify get('/projects', options)['projects']
end