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

metric rollups api #4

Merged
merged 5 commits into from
Aug 23, 2017
Merged

metric rollups api #4

merged 5 commits into from
Aug 23, 2017

Conversation

jntullo
Copy link

@jntullo jntullo commented Aug 8, 2017

Dependent on: ManageIQ/manageiq#15549

Metric rollups API requires the following parameters:

  • resource_type
  • capture_interval ('hourly' or 'daily')
  • start_date

Optional parameters:

  • resource_ids
    • If no resource_ids are specified, it will return all of the metric rollups for that collection
  • end_date
    • if no end_date is specified, it will use the current date
  • limit
    • If no limit is specified, the default value in the api settings will be used.

Paging

  • Paging will be automatically applied to these metric rollup requests
  • the limit may be overriden, but is set by default in the api settings (use parameter limit to override)

Examples

Minimum attributes:

GET /api/metric_rollups?resource_type=VmOrTemplate&resource_ids=[1,2,3]&capture_interval=hourly&start_date='2017-08-22 08:57:52 -0400'

End date:

GET /api/metric_rollups?resource_type=VmOrTemplate&resource_ids=[1,2,3]&capture_interval=hourly&start_date=2017-08-01&end_date=2017-08-22

Limit:

GET /api/metric_rollups?resource_type=VmOrTemplate&resource_ids=[1,2,3]&capture_interval=hourly&start_date=2017-08-01&end_date=2017-08-22&limit=2000

Dates are in the format:

YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ

@miq_bot add_label wip, api
@miq-bot assign @abellotti

@jntullo
Copy link
Author

jntullo commented Aug 14, 2017

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] metric rollups api metric rollups api Aug 14, 2017
@miq-bot miq-bot removed the wip label Aug 14, 2017
@abellotti
Copy link
Member

could you update the PR description to mention dates in the API supported form (YYYY-MM-DD & YYYY-MM-DDTHH:MM:SSZ)

@abellotti
Copy link
Member

LGTM!! Thanks @jntullo, minor changes needed.

@miq-bot
Copy link
Member

miq-bot commented Aug 22, 2017

Checked commits jntullo/manageiq-api@74ea576~...b79642d with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks fine. 🏆

@abellotti
Copy link
Member

Thanks @jntullo for the update. LGTM!!

Please have a follow-up PR for the codeclimate issue, thanks.

@abellotti abellotti merged commit 3859b87 into ManageIQ:master Aug 23, 2017
@jntullo jntullo mentioned this pull request Aug 23, 2017
@abellotti abellotti added this to the Sprint 68 Ending Sep 4, 2017 milestone Aug 24, 2017
@abellotti
Copy link
Member

abellotti commented Sep 5, 2017

Hi @jntullo we will need all these parameters supported by the cli, exe/manageiq-api. Thanks.

NickLaMuro added a commit to NickLaMuro/manageiq-api that referenced this pull request Dec 5, 2018
The fix here simply matches up the `if` checks used in:

- `Api::ReportsController#reports_search_conditions`
- `MiqReport.for_user`

to both use `User#report_admin_user?`

* * *

Further background info:

This bug is the result of a collision between the following two PRs:

- ManageIQ/manageiq#15472
- ManageIQ/manageiq#17444

The first PR, ManageIQ/manageiq#15472, introduces:

`Api::ReportsController#reports_search_conditions`

Which uses `unless User.current_user.admin?` to check if it should use
the `where_clause` from the `MiqReport.for_user` for the search
conditions (passed into a `ActiveRecord` `.where` farther up the stack).
The idea for this initial check is building this where clause only makes
sense if it isn't an `all`, otherwise where it is used will cause an
error in Postgres syntax because of `... WHERE ()` being passed

This, however, doesn't match the `user.admin_user?`(at the time of
ManageIQ/manageiq#15472) check that is done in `.for_user` method,
which means it would be called for users that don't match the `admin`
username, but still are part of either of the following roles

- `"EvmRole-super_administrator"`
- `"EvmRole-administrator"`

The bug in question:

https://bugzilla.redhat.com/show_bug.cgi?id=1650531

tested this with a custom role, which doesn't match either of those two
roles, so the `User#admin?` check and `User#admin_user?` check happened
to be equivalent in `5.9` (see comment ManageIQ#4 in BZ link), but not `5.10`.
But, if the replication steps had instead said to:

- Create a user, "User1", that is part of the "EvmGroup-administrator"
  group

This would have also failed in the same way on `5.9` as it does on
`5.10` currently.

This fails on 5.10, though, because in ManageIQ/manageiq#17444, the
`admin_user?` method changes to `report_admin_user?`, and it's
functionality also now checks if the role is valid for querying the
group role's product features the user has access to, and it only has an
eject for the role that happens to be `admin?`.  Meaning that the
`admin` "super user" still has no problem with this query, but any other
user that could still count as a `report_admin_user?` would (both users
in the `EvmGroup-administrator` role and just having the proper features
enabled)
NickLaMuro added a commit to NickLaMuro/manageiq-api that referenced this pull request Dec 5, 2018
The fix here simply matches up the `if` checks used in:

- `Api::ReportsController#reports_search_conditions`
- `MiqReport.for_user`

to both use `User#report_admin_user?`

* * *

Further background info:

This bug is the result of a collision between the following two PRs:

- ManageIQ/manageiq#15472
- ManageIQ/manageiq#17444

The first PR, ManageIQ/manageiq#15472, introduces:

`Api::ReportsController#reports_search_conditions`

Which uses `unless User.current_user.admin?` to check if it should use
the `where_clause` from the `MiqReport.for_user` for the search
conditions (passed into a `ActiveRecord` `.where` farther up the stack).
The idea for this initial check is building this where clause only makes
sense if it isn't an `all`, otherwise where it is used will cause an
error in Postgres syntax because of `... WHERE ()` being passed

This, however, doesn't match the `user.admin_user?`(at the time of
ManageIQ/manageiq#15472) check that is done in `.for_user` method,
which means it would be called for users that don't match the `admin`
username, but still are part of either of the following roles

- `"EvmRole-super_administrator"`
- `"EvmRole-administrator"`

The bug in question:

https://bugzilla.redhat.com/show_bug.cgi?id=1650531

tested this with a custom role, which doesn't match either of those two
roles, so the `User#admin?` check and `User#admin_user?` check happened
to be equivalent in `5.9` (see comment ManageIQ#4 in BZ link), but not `5.10`.
But, if the replication steps had instead said to:

- Create a user, "User1", that is part of the "EvmGroup-administrator"
  group

This would have also failed in the same way on `5.9` as it does on
`5.10` currently.

This fails on 5.10, though, because in ManageIQ/manageiq#17444, the
`admin_user?` method changes to `report_admin_user?`, and it's
functionality also now checks if the role is valid for querying the
group role's product features the user has access to, and it only has an
eject for the role that happens to be `admin?`.  Meaning that the
`admin` "super user" still has no problem with this query, but any other
user that could still count as a `report_admin_user?` would (both users
in the `EvmGroup-administrator` role and just having the proper features
enabled)

Fixes:  https://bugzilla.redhat.com/show_bug.cgi?id=1650531
@agrare agrare mentioned this pull request Nov 18, 2021
1 task
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.

3 participants