Debian Codegraph @

ansible_collections/amazon/aws/plugins/module_utils/batch.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2017 Ansible Project
4 #
5 # This code is part of Ansible, but is an independent component.
6 # This particular file snippet, and this file snippet only, is BSD licensed.
7 # Modules you write using this snippet, which is embedded dynamically by Ansible
8 # still belong to the author of the module, and may assign their own license
9 # to the complete work.
10 #
11 # Redistribution and use in source and binary forms, with or without modification,
12 # are permitted provided that the following conditions are met:
13 #
14 # * Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # * Redistributions in binary form must reproduce the above copyright notice,
17 # this list of conditions and the following disclaimer in the documentation
18 # and/or other materials provided with the distribution.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
28 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 """
31 This module adds shared support for Batch modules.
32 """
33
34 from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict
35
36
37 def cc(key):
38 """
39 Changes python key into Camel case equivalent. For example, 'compute_environment_name' becomes
40 'computeEnvironmentName'.
41
42 :param key:
43 :return:
44 """
45 components = key.split("_")
46 return components[0] + "".join([token.capitalize() for token in components[1:]])
47
48
49 def set_api_params(module, module_params):
50 """
51 Sets module parameters to those expected by the boto3 API.
52 :param module:
53 :param module_params:
54 :return:
55 """
56 api_params = dict((k, v) for k, v in dict(module.params).items() if k in module_params and v is not None)
57 return snake_dict_to_camel_dict(api_params)