Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloud tenants to API #14731

Merged
merged 5 commits into from
Apr 17, 2017
Merged

Add cloud tenants to API #14731

merged 5 commits into from
Apr 17, 2017

Conversation

tzumainn
Copy link
Contributor

Add cloud tenant show / show list, and subcollection to providers

module Subcollections
module CloudTenants
def cloud_tenants_query_resource(object)
object.respond_to?(:cloud_tenants) ? object.cloud_tenants : []
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you mix this into a collection that doesn't respond to :cloud_tenants? If not, does object.cloud_tenants suffice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the potential is definitely there if we discover we want to mix this into more places. I know that accommodating for cases like this is a pretty big deal in the UI, so using respond_to felt safer!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if it's anticipating a need for it later, it would be better in the simpler form for now. If you can prove that it's needed in a later revision (through testing, which you'd need to provide anyway) you can always change that when it's needed. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, I'll make the change!

config/api.yml Outdated
:subcollection_actions:
:get:
- :name: read
:identifier: cloud_tenant_show
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be cloud_tenant_show_list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, you're right - thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out that this seems correct, at least for purposes of passing the providers_spec.rb. I'm following the existing pattern used by load balancers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide more details of the failure?

@tzumainn
Copy link
Contributor Author

@imtayadeway Thanks for the review! I corrected the line in config/api.yml. Let me know if you feel strongly about respond_to!

@tzumainn
Copy link
Contributor Author

@imtayadeway Thanks again! I've made a few more changes/comments.

end

it 'queries a single cloud tenant' do
api_basic_authorize subcollection_action_identifier(:providers, :cloud_tenants, :read, :get)
Copy link
Contributor

Choose a reason for hiding this comment

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

It is probably this one that is failing - it's pointing to the wrong identifier. This needs to be action_identifier(:cloud_tenants, :read, :subresource_actions, :get)


it 'queries all cloud tenants' do
api_basic_authorize subcollection_action_identifier(:providers, :cloud_tenants, :read, :get)
expected = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but can you group verification steps (this expected) together at the bottom?

@tzumainn
Copy link
Contributor Author

@imtayadeway Ahhhh, I get it. Fix is as you predicted, and I've grouped the 'expect' code together as requested. Let me know if you'd like any other changes!

cloud_tenant = FactoryGirl.create(:cloud_tenant)
api_basic_authorize collection_action_identifier(:cloud_tenants, :read, :get)

expected = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, but I think this would read better similarly grouped with the other verification steps

@imtayadeway
Copy link
Contributor

Great work, @tzumainn, this LGTM with just one nit above 👍

@tzumainn
Copy link
Contributor Author

@imtayadeway whoops, makes sense to me - nit fixed. Thanks!

@miq-bot
Copy link
Member

miq-bot commented Apr 12, 2017

Checked commits tzumainn/manageiq@023200e~...dece235 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
6 files checked, 0 offenses detected
Everything looks good. 🏆

@abellotti
Copy link
Member

Thanks @tzumainn for the API Enhancement.

@abellotti abellotti merged commit 27e1ab0 into ManageIQ:master Apr 17, 2017
@abellotti abellotti added this to the Sprint 59 Ending Apr 24, 2017 milestone Apr 17, 2017
@tzumainn
Copy link
Contributor Author

@miq-bot add_label bug,fine/yes

@tzumainn
Copy link
Contributor Author

this is a dependency for ManageIQ/manageiq-ui-classic#1343

@simaishi
Copy link
Contributor

simaishi commented Jun 2, 2017

simaishi pushed a commit that referenced this pull request Jun 2, 2017
@simaishi
Copy link
Contributor

simaishi commented Jun 2, 2017

Fine backport details:

$ git log -1
commit a2b8ebec79d5ee373d2ed5fa87c6e4ad4d5d6e80
Author: Alberto Bellotti <abellotti@users.noreply.github.com>
Date:   Mon Apr 17 17:08:46 2017 -0400

    Merge pull request #14731 from tzumainn/cloud-tenant-api
    
    Add cloud tenants to API
    (cherry picked from commit 27e1ab00e90b79ce379d3938d01e24dc1492a996)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1458377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants