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

Override type when appropriate #78

Merged
merged 5 commits into from
Mar 2, 2017

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented Feb 28, 2017

The Tower API returns job_event summary types when querying the /job_plays/ endpoint.

In this PR we create a mechanism that allows us to force a type (in this case AnsibleTowerClient::JobPlay when we don't want to use the type column passed back by the Tower provider.

@syncrou
Copy link
Contributor Author

syncrou commented Feb 28, 2017

@miq-bot assign @bdunne

@miq-bot add_label enhancement

-cc @bzwei @gmcculloug

@syncrou syncrou force-pushed the override_type_when_appropriate branch 2 times, most recently from c375c3b to 80ef16d Compare February 28, 2017 16:24
@gmcculloug gmcculloug assigned gmcculloug and unassigned bdunne Feb 28, 2017
@gmcculloug
Copy link
Contributor

@bzwei Please review

@bzwei
Copy link
Contributor

bzwei commented Feb 28, 2017

@syncrou I think we can completely remove the dependency on the type thus class_from_type. https://github.com/ansible/ansible_tower_client_ruby/blob/master/lib/ansible_tower_client/collection.rb#L4 should always demand argument klass without default to nil.

You can see the first level list methods defined in Api such as jobs, projects, they all pass in the klass argument. For second level resources you should also pass in the klass argument, like what you just did for job/job_plays.

@syncrou
Copy link
Contributor Author

syncrou commented Mar 1, 2017

@bzwei - A quick overview of /unified_job_templates/ shows a collection of different types returned. Pulling out class_from_type and forcing that we set klass for every collection will no longer allow the gem to correctly handle the multi-typed collection returned in the above case.

@syncrou syncrou force-pushed the override_type_when_appropriate branch from 80ef16d to 0932b17 Compare March 1, 2017 22:12
@syncrou syncrou force-pushed the override_type_when_appropriate branch from 0932b17 to ba994d1 Compare March 1, 2017 22:14
Locks down the type for the groups collection

https://www.pivotaltracker.com/story/show/140561141
@miq-bot
Copy link
Collaborator

miq-bot commented Mar 2, 2017

Checked commits syncrou/ansible_tower_client@fb49c13~...be7f540 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
11 files checked, 0 offenses detected
Everything looks good. 🍪

@gmcculloug gmcculloug merged commit d4e0738 into ansible:master Mar 2, 2017
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.

5 participants