case conversion question

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

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.