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

Expose MiqEvent/EmsEvent group/levels in event stream OPTIONS #1099

Merged
merged 2 commits into from
Nov 22, 2021

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented Nov 10, 2021

Part of #1090

Depends on:

OPTIONS http://localhost:3000/api/event_streams

RESPONSE:

{
    "attributes": [
        "availability_zone_id",
        "chain_id",
        "container_group_id",
        "container_group_name",
        "container_id",
        "container_name",
        "container_namespace",
        "container_node_id",
        "container_node_name",
        "container_replicator_id",
        "container_replicator_name",
        "created_on",
        "dest_ems_cluster_id",
        "dest_ems_cluster_name",
        "dest_ems_cluster_uid",
        "dest_host_id",
        "dest_host_name",
        "dest_vm_ems_ref",
        "dest_vm_location",
        "dest_vm_name",
        "dest_vm_or_template_id",
        "ems_cluster_id",
        "ems_cluster_name",
        "ems_cluster_uid",
        "ems_id",
        "ems_ref",
        "event_type",
        "full_data",
        "generating_ems_id",
        "group_id",
        "host_id",
        "host_name",
        "id",
        "is_task",
        "message",
        "physical_chassis_id",
        "physical_server_id",
        "physical_switch_id",
        "source",
        "target_id",
        "target_type",
        "tenant_id",
        "timestamp",
        "type",
        "user_id",
        "username",
        "vm_ems_ref",
        "vm_location",
        "vm_name",
        "vm_or_template_id"
    ],
    "virtual_attributes": [
        "group",
        "group_level",
        "group_name",
        "href_slug",
        "region_description",
        "region_number"
    ],
    "relationships": [
        "availability_zone",
        "container_group",
        "container_node",
        "container_replicator",
        "dest_host",
        "dest_miq_template",
        "dest_vm",
        "dest_vm_or_template",
        "ext_management_system",
        "generating_ems",
        "host",
        "miq_template",
        "physical_chassis",
        "physical_server",
        "physical_switch",
        "service",
        "target",
        "vm",
        "vm_or_template"
    ],
    "subcollections": [],
    "data": {
        "timeline_events": {
            "EmsEvent": {
                "description": "Management Events",
                "group_names": {
                    "other": "Other",
                    "addition": "Creation/Addition",
                    "configuration": "Configuration/Reconfiguration",
                    "console": "Console Activity",
                    "deletion": "Deletion/Removal",
                    "general": "General Activity",
                    "import_export": "Import/Export",
                    "migration": "Migration/Vmotion",
                    "network": "Network",
                    "power": "Power Activity",
                    "snapshot": "Snapshot Activity",
                    "status": "Status",
                    "storage": "Storage",
                    "update": "Update",
                    "firmware": "Firmware",
                    "devices": "Devices",
                    "login": "Login",
                    "security": "Security"
                },
                "group_levels": {
                    "critical": "Critical",
                    "detail": "Detail",
                    "warning": "Warning"
                }
            },
            "MiqEvent": {
                "description": "Policy Events",
                "group_names": {
                    "other": "Other",
                    "ems_operations": "Provider Operation",
                    "host_operations": "Host Operation",
                    "compliance": "Compliance",
                    "tags": "Company Tag",
                    "vm_operational": "VM Operation",
                    "vm_configurational": "VM Configuration",
                    "vm_process": "VM Lifecycle",
                    "service_process": "Service Lifecycle",
                    "orchestration_process": "Orchestration Lifecycle",
                    "storage_operational": "Datastore Operation",
                    "container_operations": "Container Operation",
                    "physical_server_operations": "Physical Server Operation",
                    "evm_operations": "Appliance Operation",
                    "middleware_operations": "Middleware Operation",
                    "auth_validation": "Authentication Validation (Provider)",
                    "authentication": "Authentication Validation"
                },
                "group_levels": {
                    "success": "Success",
                    "failure": "Failure",
                    "detail": "Detail"
                }
            }
        }
    }
}

@Fryguy
Copy link
Member

Fryguy commented Nov 11, 2021

@jrafanie I'm wondering if we should nest these options one more level under data. That is, if we need to add something else to OPTIONS in the future, the root of the data payload is taken. Maybe:

      "data": {
-         "EmsEvent": {
+         "event_groups": {
+             "EmsEvent": {

(not sure on the name event_groups...we can debate that)


Not sure if the "data" nesting belongs here or in the backend PR. I feel like the backend method should return the hash startng at the "EmsEvent" level, but the API should be the one that constructs the data/event_groups levels

@jrafanie
Copy link
Member Author

Not sure if the "data" nesting belongs here or in the backend PR. I feel like the backend method should return the hash startng at the "EmsEvent" level, but the API should be the one that constructs the data/event_groups levels

I agree. I'll nest this in this PR. I like timeline_events as it summarizes the data below it...

    "data": {
        "timeline_events": {
            "EmsEvent": {
                "description": "Management Events",
                "group_names": {
                    "addition": "Creation/Addition",
                    ...
                    "security": "Security"
                },
                "group_levels": {
                    "critical": "Critical",
                    "detail": "Detail",
                    "warning": "Warning"
                }
            },
            "MiqEvent": {
                "description": "Policy Events",
                "group_names": {
                    "ems_operations": "Provider Operation",
                    ...
                    "authentication": "Authentication Validation"
                },
                "group_levels": {
                    "success": "Success",
                    "failure": "Failure"
                }
            }
        }
    }

@jrafanie jrafanie force-pushed the event_stream_options_for_api branch 2 times, most recently from 689b0b5 to cc071d5 Compare November 17, 2021 14:45
@jrafanie jrafanie changed the title [WIP] Expose MiqEvent/EmsEvent group/levels in event stream OPTIONS Expose MiqEvent/EmsEvent group/levels in event stream OPTIONS Nov 17, 2021
@jrafanie jrafanie removed the wip label Nov 17, 2021
@Fryguy
Copy link
Member

Fryguy commented Nov 22, 2021

Core PR is merged.

@Fryguy Fryguy closed this Nov 22, 2021
@Fryguy Fryguy reopened this Nov 22, 2021
The 'data' key in the response body can be simple or complex.  You can now
opt-out of generic data validation in the complex case by not providing the
data.  This lets you manually validate the data in the specs that know what part
of the structure is important, while retaining the rest of the options
expectations.
@jrafanie jrafanie force-pushed the event_stream_options_for_api branch 3 times, most recently from 761478c to 7a2c6de Compare November 22, 2021 21:19
expect(body["data"].keys).to eq(["timeline_events"])
expect(body["data"]["timeline_events"].keys.sort).to eq(%w[EmsEvent MiqEvent])
expect(body["data"]["timeline_events"]["EmsEvent"].keys.sort).to eq(%w[description group_levels group_names])
expect(body["data"]["timeline_events"]["EmsEvent"]["group_names"].keys.sort).to include("addition", "other")
Copy link
Member Author

Choose a reason for hiding this comment

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

There's no need to test for all of them, just one from the event_handling and the default one "other"

expect(body["data"]["timeline_events"]["EmsEvent"]["group_levels"].keys.sort).to eq(%w[critical detail warning])

expect(body["data"]["timeline_events"]["MiqEvent"].keys.sort).to eq(%w[description group_levels group_names])
expect(body["data"]["timeline_events"]["MiqEvent"]["group_names"].keys.sort).to include("auth_validation", "other")
Copy link
Member Author

Choose a reason for hiding this comment

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

same as above

@@ -966,7 +966,7 @@ def create_vms_by_name(names)
describe 'OPTIONS /api/vms' do
it 'returns the options information' do
options(api_vms_url)
expect_options_results(:vms)
expect_options_results(:vms, {})
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, this method defaulted to {} so we need to change the one caller that wasn't providing a hash and expected it to be defaulted.

The timeline_events key in the response body 'data' field contains information
on the type of events, their descriptions, group levels, group names, etc.

Currently, we only support EmsEvent and MiqEvent from event_streams.

Part of ManageIQ#1090
@miq-bot
Copy link
Member

miq-bot commented Nov 22, 2021

Checked commits jrafanie/manageiq-api@73bcdc2~...83c6c48 with ruby 2.6.3, rubocop 1.13.0, haml-lint 0.35.0, and yamllint
4 files checked, 0 offenses detected
Everything looks fine. 👍

@Fryguy Fryguy merged commit 298f098 into ManageIQ:master Nov 22, 2021
@jrafanie jrafanie deleted the event_stream_options_for_api branch November 22, 2021 21:40
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