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

Need to support keyword attributes in action calls #69

Open
abellotti opened this issue Apr 10, 2017 · 1 comment
Open

Need to support keyword attributes in action calls #69

abellotti opened this issue Apr 10, 2017 · 1 comment

Comments

@abellotti
Copy link
Member

For the Automate usage, users call model methods with just the arguments as needed.

From the API server usage, we're expecting the json representation,

for example, in the model:

ar = AutomationRequest.find(15)
ar.authorized?(userid)

From the API server side, to expose authorized?, we'd take in a user reference or userid,

miq.automation_requests.find(15).authorized?(:userid => userid)

However, the expectation, is that the following would work:

miq.automation_requests.find(15).authorized?(userid)

The API Server needs to be able to expose keyword name list for method and when the client defined such actions, it would be able to check for hash signatures or otherwise treat them as an array of parameter. In the latter case, the Client would convert the array to the proper json to send up to the server.

@mkanoor
Copy link

mkanoor commented Apr 17, 2017

@abellotti
In Ruby the method object has a method called parameters which gives you back the arguments of the method in order.

e.g.

def my_method(name, age, state="NJ")
puts "#{name} aged #{age} lives in the state of #{state}"
end

method(:my_method).parameters

=> [[:req, :name], [:req, :age], [:opt, :state]]

This way the post can send the JSON arguments in any order but once we get it on our side we can pass it in correctly. So as long as the parameter names used in the API client are using the same names as the one in AR models we should be able to invoke them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants