Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Expose playbooks off of projects #62

Merged
merged 3 commits into from
Jan 20, 2017

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented Jan 20, 2017

Playbooks are only available from a project.
This PR exposes /playbooks as a collection from said project.

The Tower API returns playbooks as an Array vs a Hash from POST, PUT, PATCH(able) endpoints.
The parse_result_set method was modified to handle each case appropriately while not breaking the existing lazy Enumerator behavior.

https://www.pivotaltracker.com/story/show/137293767

Testing Notes

conn = AnsibleTowerClient::Connection.new(
  :username => "username",
  :password => "password",
  :base_url => "https://dev-ansible-tower3.test.com/api/v1",
  :verify_ssl => OpenSSL::SSL::VERIFY_NONE
)
proj = conn.api.projects.find <id>
proj.playbooks.first
conn = AnsibleTowerClient::Connection.new(
  :username => "username",
  :password => "password",
  :base_url => "https://dev-ansible-tower3.test.com/api/v1",
  :verify_ssl => OpenSSL::SSL::VERIFY_NONE
)
proj = conn.api.projects.find <id>
proj.playbooks.each { |x| puts x }

Playbooks are only available from a project
I expose a playbooks as a collection from a project

The Tower API returns playbooks as an Array, vs a Hash from POST, PUT, PATCH(able) endpoints
The parse_result_set method was modified to handle each case

https://www.pivotaltracker.com/story/show/137293767
@syncrou
Copy link
Contributor Author

syncrou commented Jan 20, 2017

@miq-bot assign @bdunne

@miq-bot add_label enhancement

@syncrou syncrou force-pushed the expose_playbooks_off_of_projects branch from 04d335d to 8f6369a Compare January 20, 2017 22:30
def parse_result_set(body)
case body.class.name
when "Array" then
body.each { |result| @collection << result }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified to @collection = body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - it can.

No need to iterate over an array.
@miq-bot
Copy link
Collaborator

miq-bot commented Jan 20, 2017

Checked commits syncrou/ansible_tower_client@13be055~...fd8c6cf with ruby 2.2.6, rubocop 0.46.0, and haml-lint 0.19.0
3 files checked, 0 offenses detected
Everything looks good. ⭐

@bdunne bdunne merged commit 1abb87e into ansible:master Jan 20, 2017
bdunne added a commit that referenced this pull request Feb 2, 2017
Added
- Refactor `#endpoint` [(#64)](#64)
- Expose playbooks off of projects [(#62)](#62)

Changed
- Allow for alternative resource paths [(#66)](#66)
- Raise UnlicensedFeatureError when we receive HTTP 402 [(#65)](#65)

Fixed
- Adjusted project_spec to test on a Project [(#63)](#63)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants