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

fixes #3491 - API v2 rabl templates base, main, show for each controller #1062

Closed
wants to merge 3 commits into from

Conversation

isratrade
Copy link
Member

base.json.rabl - usually contains :id, :name and possibly another important attribute

main.json.rabl - extends 'base' and adds attributes, but no :child nodes
- index.json.rabl extends the 'main' template

show.json.rabl - extends 'main' and adds :child nodes
- currently, 'show' may not have anything different other than extending 'main', but this will probably change in PR
fixes #3492 to add nested routes and relationships in responses.

@isratrade
Copy link
Member Author

@tstrachota, I completed all the controllers.

@domcleal
Copy link
Contributor

Where will base be used?

@isratrade
Copy link
Member Author

@domcleal in base is used in child nodes of an object. It will be more obvious in my next PR, fixes #3492

@isratrade
Copy link
Member Author

@domcleal, ping?

@mbacovsky
Copy link
Member

Is index for host not extending main or base intentionally? If I would like to add IP, environment and model to index to match UI, where should it go? Could you please explain a bit why is host attrs divided this way?

@ohadlevy
Copy link
Member

ohadlevy commented Dec 3, 2013

I tend to agree, at least the attributes that directly assigned to the host (such as ipaddress) will not impact performance and would be very useful.

@mbacovsky
Copy link
Member

Why audits and plugins do not follow this convention?
What do you think about max line length in rabl templates or visually grouping the attributes? Some of the views are difficult to edit/check?

Other than that I like it. At first I was hesitant about the main and base separation, but the use of base in nested resources makes a lot of sense. The views look nice and consistent this way.

@isratrade
Copy link
Member Author

@mbacovsky, yes I have been meaning to add the host's attributes to be more comprehensive

@mbacovsky
Copy link
Member

@isratrade cool, thanks!

@mbacovsky
Copy link
Member

Some more comments:

  • in operating systems I'd suggest to move major and minor attrs to base. That way we can get version to associations.
  • having template attr in main in config_templates causes returning the templates itself in index. Was that intentional?

@@ -1,3 +1,3 @@
object @architecture

attributes :name, :id, :created_at, :operatingsystem_ids, :updated_at
Copy link
Contributor

Choose a reason for hiding this comment

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

lost operating systems? Shouldn't this be a child node?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, has many attributes will be in PR #1062

attributes :id, :login, :firstname, :lastname, :mail, :admin, :auth_source_id, :auth_source_name, :last_login_on,
:domains_andor, :hostgroups_andor, :facts_andor, :filter_on_owner, :compute_resources_andor,
:created_at, :updated_at
extends "api/v2/users/main"

child :auth_source do
extends "api/v2/auth_source_ldaps/show"
Copy link
Contributor

Choose a reason for hiding this comment

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

base?

@domcleal
Copy link
Contributor

domcleal commented Dec 5, 2013

Broadly looks good, thanks. Some things that came up a few times in my comments were:

  1. base not always used for child nodes
  2. some "create" templates use show, some use base - I think they should be show
  3. some has_many relationships were just IDs rather than child nodes (unsure if you want to address this now though)

@isratrade
Copy link
Member Author

@domcleal, I was just having this PR be adding the base, main, show templates and then clean up which attributes are in which file and DRY up things in another PR, but I will do it in this PR.

@domcleal
Copy link
Contributor

domcleal commented Dec 5, 2013

@isratrade ok, I think we should have a go at getting it right now, hopefully most are quick fixes anyway

@isratrade
Copy link
Member Author

@domcleal, re-committed as a separate commit to squash after review.

@isratrade
Copy link
Member Author

@domcleal, it's much cleaner now. Thanks for your thorough review. +1

@isratrade
Copy link
Member Author

@mbacovsky, I moved fullname to operatingsystems/base so I don't need to move major and minor

@isratrade
Copy link
Member Author

@mbacovsky, can you explain what you mean by your comment above
What do you think about max line length in rabl templates or visually grouping the attributes? Some of the views are difficult to edit/check?
Can you give an example?

@isratrade
Copy link
Member Author

@mbacovsky, I added a new commit for audits/base and main.

@isratrade
Copy link
Member Author

@mbacovsky, is there anything I read to change with api/plugins. I think I may have squashed and fixed this already.

@domcleal
Copy link
Contributor

domcleal commented Dec 5, 2013

Oh, maybe plugins doesn't need to change as the controller only supports index.

@mbacovsky
Copy link
Member

👍
I like the changes and I'm okay with the plugins.
@isratrade By max line length I meant, that the lines in the rabl are too long e.g. hosts/main.rabl. I'd prefer to have some style conventions to make it easier to read. This is example of longish rabl formatting that I find easier to read https://github.com/Katello/katello/blob/master/app/views/katello/api/v2/systems/show.json.rabl What do you think?

@domcleal
Copy link
Contributor

domcleal commented Dec 9, 2013

I agree with @mbacovsky, this would be very useful for future reviews, though I'm going to merge this as-is for now. Thanks for the extra pair of eyes!

Merged as 2e46934 for Foreman 1.4.0, thanks @isratrade.

@domcleal domcleal closed this Dec 9, 2013
@isratrade
Copy link
Member Author

@mbacovsky, I agree with re-factoring in the future in the make the rabl files easier to read.

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