case conversion question

7 views
Skip to first unread message

Tim

unread,
Jun 7, 2016, 12:53:47 PM6/7/16
to Ansible Development
hey folks,

I'm making a module, and have a REST api that I'm working with that returns all its values in camelCase and I wanted to return them in a module to my end users in the snake_case that ansible uses.

I was wondering if Ansible came with a utility method to do this, or if I should back my own?

Thanks,
tim

Matt Martz

unread,
Jun 7, 2016, 3:14:31 PM6/7/16
to Tim, Ansible Development
The ec2 module_utils have a function called camel_dict_to_snake_dict

If you are using Ansible 2.1, modules can import specific things from module_utils, so you could use:

from ansible.module_utils.ec2 import camel_dict_to_snake_dict

Not sure if there is anything to be cautious of, but it may work for you.

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Reply all
Reply to author
Forward
0 new messages