Skip to content

Commit

Permalink
Merge pull request #196 from kkaempf/list_sub_views
Browse files Browse the repository at this point in the history
Implement View#list_views and View#list_views_with_details to access …
  • Loading branch information
katelovescode authored Feb 13, 2018
2 parents c27ee04 + df91131 commit d0965c4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/jenkins_api_client/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,38 @@ def remove_job(view_name, job_name)
@client.api_post_request(post_msg)
end

# List (sub-)views in a view
#
# @param [String] view_name
#
# @return [Array] view_names list of (sub-)views in the specified view
#
def list_views(view_name)
@logger.info "Obtaining the views present in view '#{view_name}'"
view_names = []
raise "The view #{view_name} doesn't exists on the server"\
unless exists?(view_name)
response_json = @client.api_get_request("/view/#{path_encode view_name}")
response_json["views"].each do |view|
view_names << view["name"]
end
view_names
end

# List (sub-)views in view along with their details
#
# @param [String] view_name
#
# @return [Array<Hash>] the details of (sub-)views in the specified view
#
def list_views_with_details(view_name)
@logger.info "Obtaining the views present in view '#{view_name}'"
raise "The view #{view_name} doesn't exists on the server"\
unless exists?(view_name)
response_json = @client.api_get_request("/view/#{path_encode view_name}")
response_json["views"]
end

# Obtain the configuration stored in config.xml of a specific view
#
# @param [String] view_name
Expand Down

0 comments on commit d0965c4

Please sign in to comment.