-
Notifications
You must be signed in to change notification settings - Fork 92
feat(RHINENG-21887): Add OpenAPI spec for /hosts-view endpoint #3227
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
base: master
Are you sure you want to change the base?
feat(RHINENG-21887): Add OpenAPI spec for /hosts-view endpoint #3227
Conversation
Reviewer's GuideAdds a complete OpenAPI 3.0 specification for the new /hosts-view endpoint, including its query parameters, ordering/filtering options, response schema, and supporting component schemas for application-specific host metrics. Sequence diagram for GET /hosts-view request flowsequenceDiagram
actor ApiClient
participant InventoryAPI as InventoryAPI_service
ApiClient->>InventoryAPI: GET /hosts-view
activate InventoryAPI
InventoryAPI-->>InventoryAPI: Validate ApiKeyAuth
InventoryAPI-->>InventoryAPI: Parse query params
Note over InventoryAPI: displayName, fqdn, tagsParam, hostViewFieldsParam, hostViewAppFilterParam, hostViewOrderByParam, hostOrderHowParam, stalenessParam, pagination, etc.
InventoryAPI-->>InventoryAPI: Build host query
InventoryAPI-->>InventoryAPI: Apply app filters (HostViewApplicationFilter)
InventoryAPI-->>InventoryAPI: Apply ordering (hostViewOrderByParam)
InventoryAPI-->>InventoryAPI: Execute host and app joins
InventoryAPI-->>ApiClient: 200 HostViewQueryOutput (paginated HostViewHost[])
deactivate InventoryAPI
alt Invalid query or parameters
InventoryAPI-->>ApiClient: 400 Invalid request
end
Entity relationship diagram for host view response modelerDiagram
HostViewQueryOutput {
string page
string per_page
string total
HostViewHost[] results
}
HostViewHost {
string id
string display_name
string fqdn
string group_name
string updated
string last_check_in
string system_profile
HostApplicationsData app_data
}
HostApplicationsData {
AdvisorAppData advisor
VulnerabilityAppData vulnerability
PatchAppData patch
RemediationsAppData remediations
ComplianceAppData compliance
MalwareAppData malware
ImageBuilderAppData image_builder
}
AdvisorAppData {
int recommendations
int incidents
}
VulnerabilityAppData {
int total_cves
int critical_cves
int high_severity_cves
int cves_with_security_rules
int cves_with_known_exploits
}
PatchAppData {
int installable_advisories
string template
string rhsm_locked_version
}
RemediationsAppData {
int remediations_plans
}
ComplianceAppData {
int policies
datetime last_scan
}
MalwareAppData {
string last_status
int last_matches
datetime last_scan
}
ImageBuilderAppData {
string image_name
string image_status
}
HostViewQueryOutput ||--o{ HostViewHost : contains
HostViewHost ||--|| HostApplicationsData : has
HostApplicationsData ||--o| AdvisorAppData : advisor
HostApplicationsData ||--o| VulnerabilityAppData : vulnerability
HostApplicationsData ||--o| PatchAppData : patch
HostApplicationsData ||--o| RemediationsAppData : remediations
HostApplicationsData ||--o| ComplianceAppData : compliance
HostApplicationsData ||--o| MalwareAppData : malware
HostApplicationsData ||--o| ImageBuilderAppData : image_builder
Class diagram for new /hosts-view schemas and parametersclassDiagram
class HostViewQueryOutput {
<<schema>>
+int page
+int per_page
+int total
+HostViewHost[] results
}
class HostViewHost {
<<schema>>
+string id
+string display_name
+string fqdn
+string group_name
+string updated
+string last_check_in
+object system_profile
+HostApplicationsData app_data
}
class HostApplicationsData {
<<schema>>
+AdvisorAppData advisor
+VulnerabilityAppData vulnerability
+PatchAppData patch
+RemediationsAppData remediations
+ComplianceAppData compliance
+MalwareAppData malware
+ImageBuilderAppData image_builder
}
class AdvisorAppData {
<<schema>>
+int recommendations
+int incidents
}
class VulnerabilityAppData {
<<schema>>
+int total_cves
+int critical_cves
+int high_severity_cves
+int cves_with_security_rules
+int cves_with_known_exploits
}
class PatchAppData {
<<schema>>
+int installable_advisories
+string template
+string rhsm_locked_version
}
class RemediationsAppData {
<<schema>>
+int remediations_plans
}
class ComplianceAppData {
<<schema>>
+int policies
+datetime last_scan
}
class MalwareAppData {
<<schema>>
+string last_status
+int last_matches
+datetime last_scan
}
class ImageBuilderAppData {
<<schema>>
+string image_name
+string image_status
}
class HostViewFieldsObject {
<<schema>>
+bool app_data
+string[] advisor
+string[] vulnerability
+string[] patch
+string[] remediations
+string[] compliance
+string[] malware
+string[] image_builder
}
class HostViewApplicationFilter {
<<schema>>
+map<string,HostViewApplicationFilterField> applications
}
class HostViewApplicationFilterField {
<<schema>>
+map<string,HostViewFilterComparison> fields
}
class HostViewFilterComparison {
<<schema>>
+string eq
+string ne
+string gte
+string lte
}
class hostViewFieldsParam {
<<query_param>>
+string name
+string in
+HostViewFieldsObject schema
}
class hostViewAppFilterParam {
<<query_param>>
+string name
+string in
+HostViewApplicationFilter schema
}
class hostViewOrderByParam {
<<query_param>>
+string name
+string in
+string enum_display_name
+string enum_group_name
+string enum_updated
+string enum_operating_system
+string enum_last_check_in
+string enum_advisor_recommendations
+string enum_vulnerability_total_cves
+string enum_vulnerability_critical_cves
+string enum_patch_installable_advisories
+string enum_remediations_remediations_plans
+string enum_compliance_policies
+string enum_compliance_last_scan
+string enum_malware_last_matches
+string enum_malware_last_scan
}
HostViewQueryOutput --> HostViewHost : results
HostViewHost --> HostApplicationsData : app_data
HostApplicationsData --> AdvisorAppData
HostApplicationsData --> VulnerabilityAppData
HostApplicationsData --> PatchAppData
HostApplicationsData --> RemediationsAppData
HostApplicationsData --> ComplianceAppData
HostApplicationsData --> MalwareAppData
HostApplicationsData --> ImageBuilderAppData
HostViewFieldsObject <.. hostViewFieldsParam : schema
HostViewApplicationFilter <.. hostViewAppFilterParam : schema
HostViewApplicationFilterField --> HostViewFilterComparison : comparisons
HostViewApplicationFilter --> HostViewApplicationFilterField : fields_per_app
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The
HostViewApplicationFilterschema currently allows arbitraryapp_nameand field keys viaadditionalProperties, whileorder_byandHostApplicationsData/HostViewFieldsObjectenumerate a concrete set of apps and fields; consider tightening or documenting the allowed app/field combinations so clients get clearer validation/feedback when they send unsupported filter keys. - The
HostViewFilterComparisonschema types all operator values asstring, even for clearly numeric metrics (e.g.,critical_cves,installable_advisories); if the backend expects numbers, it may be worth using a numeric type here to give clients better contract guarantees.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `HostViewApplicationFilter` schema currently allows arbitrary `app_name` and field keys via `additionalProperties`, while `order_by` and `HostApplicationsData`/`HostViewFieldsObject` enumerate a concrete set of apps and fields; consider tightening or documenting the allowed app/field combinations so clients get clearer validation/feedback when they send unsupported filter keys.
- The `HostViewFilterComparison` schema types all operator values as `string`, even for clearly numeric metrics (e.g., `critical_cves`, `installable_advisories`); if the backend expects numbers, it may be worth using a numeric type here to give clients better contract guarantees.
## Individual Comments
### Comment 1
<location> `swagger/api.spec.yaml:1387-1396` </location>
<code_context>
+ hostViewOrderByParam:
</code_context>
<issue_to_address>
**issue:** The `order_by` description and enum look misaligned with the supported fields.
The `hostViewOrderByParam` description claims it accepts any host column or `app:field`, but the schema limits it to a small enum that excludes several existing metrics (e.g. `vulnerability:high_severity_cves`, `vulnerability:cves_with_security_rules`, `vulnerability:cves_with_known_exploits` from `VulnerabilityAppData`). Please either expand the enum to include all sortable fields or update the description to match the allowed values, so the API contract is clear for consumers and tooling.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
jpramos123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Please review and address below comments
kruai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Joao's comments; I also had a question about supported comparators.
4c46b6d to
452aacf
Compare
fstavela
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a note to the description of the new endpoint that it's not implemented yet.
5ed3745 to
af9fe21
Compare
ezr-ondrej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great first version, I'm ok to go ahead with this as is if we make sure to include the prefix to ensure users don't get confused (description is not enough IMO).
I've floted a thought about having the app specific fields defined in separate file, but that can easily be a follow-up 👍
80c0a5e to
af49e13
Compare
thearifismail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adarshdubey-star I got one question about what should be the endpoint? Here is a link to Google Doc, which is pretty much a todo check list: https://docs.google.com/document/d/1jaDzGP1bXzvAzGzn1RIhy9TIPp4KWgzhEGhdg2yMbqA/
884d062 to
501c6a2
Compare
|
/retest |
7dd6f09 to
47411ff
Compare
c0d44ee to
44f55ea
Compare
cdb1bd1 to
42274ff
Compare
jpramos123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM now!
If pipeline passes, feel free to merge.
|
/retest |
JIra -: RHINENG-21887
Add complete OpenAPI 3.0 spec for the new /hosts-view endpoint that provides
a unified view of host data combined with application-specific metrics.
Summary by Sourcery
Add OpenAPI documentation for a new /hosts-view endpoint that returns an aggregated view of hosts with optional application metrics and supports rich filtering and sorting.
New Features: