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

[WIP] API for expression editor #712

Closed
wants to merge 3 commits into from

Conversation

lpichler
Copy link
Contributor

@lpichler lpichler commented Nov 19, 2019

this PR is needed ManageIQ/manageiq#19531

/api/expressions?model=<model>&autocomplete_actions[]=<exp_type>&written_input[]=...

<model> is base model - for example base model report
(ManageIQ::Providers::InfraManager::Vm) in model class name in string

<autocomplete_actions> - array of actions to determine which information should be retrieved by the API.

Supported autocomplete actions:

registry_value registry_data registry_key registry_operator
tag_value category tag_field tag_operator
exp_type entity field
operator expression_operator value check_operator count_operator

<written_input> - array of element with user input, for example:
Virtual Machine.Last Compliance History.Details

Examples:

expression_type

User Input: Virtual Machine

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine

=>

{
    "exp_type": [
        "Field",
        "Count of",
        "Tag",
        "Find"
    ]
}

List only tag (used for expression editor in group edit)

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&only_tag=true

=>

{
    "exp_type": [
        "Tag"
    ]
}

SECONDARY (DISPLAY) FILTER


/api/expressions?autocomplete_actions[]=exp_type&model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&secondary_filter=true&columns_order[]=...&columns[]=...

NOTE: it is columns_order is @edit[:new][:field_order] and columns is@edit[:new][:fields]

entity

User Input : NOTHING

/api/expressions?autocomplete_actions[]=entity&model=ManageIQ::Providers::InfraManager::Vm
=>
{
    "entity": [
        "Virtual Machine"
    ]
}

User Input : Virtual Machine

/api/expressions?autocomplete_actions[]=entity&model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine

=>

{
    "entity": [
        "Snapshots",
        "Compliance History",
        "Last Compliance History",
        "EVM Owner",
        "EVM Custom Attributes",
        "OS",
        ...
    ]
}

User Input : Virtual Machine Last Compliance History

/api/expressions?autocomplete_actions[]=entity&model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&written_input[]=Last Compliance History


=>

{
    "entity": [
        "Details"
        ...
    ]
}

User Input : Virtual Machine Last Compliance History Details

http://localhost:3090/api/expressions?autocomplete_actions[]=entity&model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&written_input[]=Last Compliance History&written_input[]=Details

=>

{
    "entity": []
}

field

User Input : NOTHING

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&autocomplete_actions[]=field
=>
{
    "field": [
        "Id",
        "Vendor",
        "Format",
        "Version",
        "Name",
        "Description",
        "Location",
        "Configuration XML",
        "Autostart",
        ...
        ]
}

User Input : Virtual Machine

/api/expressions?autocomplete_actions[]=field&model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine

=>

{
    "field": [
        "Id",
        "Vendor",
        "Format",
        "Version",
        "Name",
        "Description",
        "Location",
        "Configuration XML",
        "Autostart",
        ...
        ]
}

User Input: Virtual Machine Last Compliance History

/api/expressions?autocomplete_actions[]=field&model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&written_input[]=Last Compliance History
=>

{
    "field": [
        "Id",
        "Resource",
        "Resource Type",
        "Compliant",
        "Activity Sample - Timestamp (Day/Time)",
        "Date Updated",
        "Event Type",
        "Href Slug",
        "Region Number",
        "Region Description"
    ]
}

User Input: Virtual Machine Last Compliance History Details


/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&autocomplete_actions[]=field&written_input[]=Last Compliance History&written_input[]=Details`

{
    "field": [
        "Id",
        "Compliance",
        "Date Created",
        "Date Updated",
        "Miq Policy",
        "Miq Policy Desc",
        "Miq Policy Result",
        "Condition",
        "Condition Desc",
        "Condition Result",
        "Href Slug",
        "Region Number",
        "Region Description",
        "Asset Name"
    ]
}

registry_key

User Input: NOTHING

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&autocomplete_actions[]=registry_key

{
    "registry_key": [
        "HKLM\\SOFTWARE\\Microsoft\\Ole :",
        "HKLM\\SOFTWARE\\Microsoft\\Rpc :",
        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Browser :",
        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\DHCP :",
        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application :",
        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Security :",
        "HKLM\\SYSTEM\\CurrentControlSet\
        ...

registry_operator, registry_value

User Input: HKLM\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters :

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=HKLM\\SOFTWARE\\Microsoft\\Ole :&autocomplete_actions[]=registry_operator&autocomplete_actions[]=registry_value

{
    "registry_operator": [
        "KEY_EXIST"
    ],
    "registry_value": [
        "NtpServer"
    ]
}

registry_operator

User Input: HKLM\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters : NtpServer

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=HKLM\\SOFTWARE\\Microsoft\\Ole :&autocomplete_actions[]=registry_operator&written_input[]=EnableDCOM

{
    "registry_operator": [
        "VALUE_EXIST",
        "=",
        ...
    ]
}

registry_data

User Input: HKLM\\SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters : NtpServer =



/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=HKLM\\SOFTWARE\\Microsoft\\Ole :&written_input[]=EnableDCOM&autocomplete_actions[]=registry_data&written_input[]==

{
    "registry_data": [
        "Y"
    ]
}


tag_field

User Input: Virtual Machine or NOTHING

./api/expressions?model=ManageIQ::Providers::InfraManager::Vm&written_input[]=Virtual Machine&autocomplete_actions[]=tag_field

{
    "tag_field": [
        "Provider",
        "Cluster / Deployment Role",
        "Host / Node",
        "Miq Group",
        "Resource Pool",
        "Service",
        "Datastore",
        "User",
        "Container",
        "Build"]
 }
 

category

(it does not depend on user's input)

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&autocomplete_actions[]=category

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&autocomplete_actions[]=category


{
    "category": [
        "Auto Approve - Max CPU",
        "Auto Approve - Max Memory",
        "Auto Approve - Max Retirement Days",
        "Auto Approve - Max VM",
        "Cost Center",
        "Department",
        "EVM Operations",
        "Environment",
        "Exclusions",
       ..
}

tag_value

USER INPUT: Provider Auto Approve - Max CPU

/api/expressions?model=ManageIQ::Providers::InfraManager::Vm&autocomplete_actions[]=tag_value&written_input[]=Provider&written_input[]=Auto Approve - Max CPU

{
    "tag_value": [
        "1",
        "2",
        "3",
        "4",
        "5",
        "tagnew"
    ]
}

tag_operator, expression_operator, check_operator

(those don't depend on user's input)

    "expression_operator": [
        "AND",
        "OR"
    ]
}

{
    "tag_operator": [
        "CONTAINS"
    ]
}

@miq-bot miq-bot added the wip label Nov 19, 2019
@lpichler lpichler force-pushed the api_for_expression_editor branch from f850697 to 38f30e8 Compare November 19, 2019 15:03
@lpichler lpichler force-pushed the api_for_expression_editor branch from 38f30e8 to c27f9e2 Compare January 6, 2020 14:05
@miq-bot
Copy link
Member

miq-bot commented Jan 6, 2020

Checked commits lpichler/manageiq-api@d2dfba0~...c27f9e2 with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 4 offenses detected

app/controllers/api/expressions_controller.rb

config/api.yml

  • ⚠️ - Line 1274, Col 7 - indentation - wrong indentation: expected 4 but found 6
  • ⚠️ - Line 1280, Col 9 - indentation - wrong indentation: expected 6 but found 8

@miq-bot
Copy link
Member

miq-bot commented Jun 11, 2020

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s)

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

@miq-bot
Copy link
Member

miq-bot commented Dec 2, 2020

This pull request is not mergeable. Please rebase and repush.

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