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

Generic Object method calling #93

Merged
merged 3 commits into from
Oct 6, 2017
Merged

Generic Object method calling #93

merged 3 commits into from
Oct 6, 2017

Conversation

jntullo
Copy link

@jntullo jntullo commented Sep 29, 2017

Adds calling of custom automate methods on Generic Objects.

Dependent upon ManageIQ/manageiq#16077 and ManageIQ/manageiq-automation_engine#74

Sample response with custom actions

{  
   "href":"http://localhost:3000/api/generic_objects/10000000000001",
   "name":"GO 2",
   ...
   "property_attributes":{  
      "start":true
   },
   "actions":[  
      {  
         "name":"edit",
         "method":"post",
         "href":"http://localhost:3000/api/generic_objects/10000000000001"
      },
     ...
      {  
         "name":"test_method",
         "method":"post",
         "href":"http://localhost:3000/api/generic_objects/10000000000001"
      },
      {  
         "name":"test_method_params",
         "method":"post",
         "href":"http://localhost:3000/api/generic_objects/10000000000001"
      }
   ]
}

Sample request for calling a method with parameters

This request sends in two numbers as an array (2 and 3) and adds them together, which can be seen from the task_results when checking the task after automate has executed the method.

Request:
{
  "action": "test_method_params",
  "parameters": [
    2,
    3
  ]
}
Response:
{  
   "success":true,
   "message":"Invoked method test_method_params for Generic Object id: 10000000000001",
   "task_id":"10000000245798",
   "task_href":"http://localhost:3000/api/tasks/10000000245798",
   "href":"http://localhost:3000/api/generic_objects/10000000245798"
}
Automate Method:
$evm.root['method_result'] = $evm.inputs['another_param'] + $evm.inputs['a_param']

Response from checking the task after automate completed:

GET http://localhost:3000/api/tasks/10000000245798?attributes=task_results
{  
   "href":"http://localhost:3000/api/tasks/10000000245798",
   "id":"10000000245798",
   "name":"Invoked method test_method_params for Generic Object id: 10000000000001",
   "state":"Finished",
   "status":"Ok",
   "message":"Task completed successfully",
   "userid":"admin",
   "created_on":"2017-10-06T14:09:09Z",
   "updated_on":"2017-10-06T14:09:15Z",
   "miq_server_id":"10000000000019",
   "task_results":5
}

Sample call with output from automate.log:

method_with_params

@miq-bot add_label enhancement, wip
@miq-bot assign @abellotti

@miq-bot
Copy link
Member

miq-bot commented Oct 3, 2017

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

{
:method_name => action,
:args => data['parameters'],
:set_user => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

@jntullo
Couldn't we just add the :user_id, :group_id, :tenant_id here.
I am guessing this call is only for calling the generic object methods

@jntullo jntullo changed the title [WIP] Generic Object method calling Generic Object method calling Oct 6, 2017
@miq-bot miq-bot removed the wip label Oct 6, 2017
@miq-bot
Copy link
Member

miq-bot commented Oct 6, 2017

Checked commits jntullo/manageiq-api@376e1a2~...0ada42c with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 👍

{
:method_name => action,
:args => data['parameters'],
:set_user => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

@jntullo Is this still needed? I think you replaced it with ':user'

@abellotti
Copy link
Member

Just kicked the tire here, LGTM !! Thanks @jntullo for this API Enhancement. 👍

@abellotti abellotti merged commit d82d214 into ManageIQ:master Oct 6, 2017
@abellotti abellotti added this to the Sprint 71 Ending Oct 16, 2017 milestone Oct 6, 2017
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.

4 participants