# Path: ansible/module_utils/hashivault.py
# def hashivault_argspec():
#     argument_spec = dict(
#         url=dict(required=False, default=os.environ.get('VAULT_ADDR', ''), type='str'),
#         ca_cert=dict(required=False, default=os.environ.get('VAULT_CACERT', ''), type='str'),
#         ca_path=dict(required=False, default=os.environ.get('VAULT_CAPATH', ''), type='str'),
#         client_cert=dict(required=False, default=os.environ.get('VAULT_CLIENT_CERT', ''), type='str'),
#         client_key=dict(required=False, default=os.environ.get('VAULT_CLIENT_KEY', ''), type='str'),
#         verify=dict(required=False, default=(not os.environ.get('VAULT_SKIP_VERIFY', '')), type='bool'),
#         authtype=dict(required=False, default=os.environ.get('VAULT_AUTHTYPE', 'token'), type='str'),
#         login_mount_point=dict(required=False, default=os.environ.get('VAULT_LOGIN_MOUNT_POINT', None), type='str'),
#         token=dict(required=False, fallback=(hashivault_default_token, ''), type='str', no_log=True),
#         username=dict(required=False, default=os.environ.get('VAULT_USER', ''), type='str'),
#         password=dict(required=False, fallback=(env_fallback, ['VAULT_PASSWORD']), type='str', no_log=True),
#         role_id=dict(required=False, fallback=(env_fallback, ['VAULT_ROLE_ID']), type='str', no_log=True),
#         secret_id=dict(required=False, fallback=(env_fallback, ['VAULT_SECRET_ID']), type='str', no_log=True),
#         aws_header=dict(required=False, fallback=(env_fallback, ['VAULT_AWS_HEADER']), type='str', no_log=True),
#         namespace=dict(required=False, default=os.environ.get('VAULT_NAMESPACE', None), type='str')
#     )
#     return argument_spec
# 
# Path: ansible/module_utils/hashivault.py
# def hashivault_auth_client(params):
#     client = hashivault_client(params)
#     return hashivault_auth(client, params)
# 
# Path: ansible/module_utils/hashivault.py
# def hashivault_init(argument_spec, supports_check_mode=False, required_if=None, required_together=None,
#                     required_one_of=None, mutually_exclusive=None):
#     module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=supports_check_mode,
#                            required_if=required_if, required_together=required_together,
#                            required_one_of=required_one_of, mutually_exclusive=mutually_exclusive)
#     module.no_log_values.discard('0')
#     module.no_log_values.discard(0)
#     module.no_log_values.discard('1')
#     module.no_log_values.discard(1)
#     module.no_log_values.discard(True)
#     module.no_log_values.discard(False)
#     module.no_log_values.discard('ttl')
#     return module
# 
# Path: ansible/module_utils/hashivault.py
# def hashiwrapper(function):
#     def wrapper(*args, **kwargs):
#         result = {"changed": False, "rc": 0}
#         result.update(function(*args, **kwargs))
#         return result
#     return wrapper
# 
# Path: ansible/module_utils/hashivault.py
# def get_keys_updated(desired_state, current_state, ignore=None):
#     """Return list of keys that have different values
# 
#     Recursively walks dict object to compare all keys
# 
#     :param desired_state: The state user desires.
#     :type desired_state: dict
#     :param current_state: The state that currently exists.
#     :type current_state: dict
#     :param ignore: Ignore these keys.
#     :type ignore: list
# 
#     :return: Different items
#     :rtype: list
#     """
# 
#     if ignore is None:
#         ignore = []
# 
#     differences = []
#     for key in desired_state.keys():
#         if key in ignore:
#             continue
#         if (key not in current_state):
#             differences.append(key)
#             continue
#         new_value = desired_state[key]
#         old_value = current_state[key]
#         if 'ttl' in key:
#             if _convert_to_seconds(old_value) != _convert_to_seconds(new_value):
#                 differences.append(key)
#         elif not _compare_state(new_value, old_value):
#             differences.append(key)
#     return differences


from ansible.module_utils.hashivault import hashivault_argspec
from ansible.module_utils.hashivault import hashivault_auth_client
from ansible.module_utils.hashivault import hashivault_init
from ansible.module_utils.hashivault import hashiwrapper
from ansible.module_utils.hashivault import get_keys_updated
from hvac.exceptions import InvalidPath
    pem_keys:
        description:
            - Optional list of PEM-formatted public keys or certificates used to verify the signatures of Kubernetes
              service account JWTs. If a certificate is given, its public key will be extracted.
    issuer:
        description:
            - Optional JWT issuer. If no issuer is specified, then this plugin will use kubernetes.io/serviceaccount as
              the default issuer (Available in hvac 0.10.2).
extends_documentation_fragment: hashivault
'''
EXAMPLES = '''
---
- hosts: localhost
  tasks:
    - hashivault_k8s_auth_config:
        kubernetes_host: https://192.168.99.100:8443
        kubernetes_ca_cert: "-----BEGIN CERTIFICATE-----\n.....\n-----END CERTIFICATE-----"
'''


def main():
    argspec = hashivault_argspec()
    argspec['mount_point'] = dict(required=False, type='str', default='kubernetes')
    argspec['kubernetes_host'] = dict(required=False, type='str', default=None)
    argspec['token_reviewer_jwt'] = dict(required=False, type='str', default=None)
    argspec['kubernetes_ca_cert'] = dict(required=False, type='str', default=None)
    argspec['pem_keys'] = dict(required=False, type='list', default=None)
    argspec['issuer'] = dict(required=False, type='str', default=None)
    required_together = [['kubernetes_host', 'kubernetes_ca_cert']]


# Path: ansible/module_utils/hashivault.py
# def hashivault_argspec():
#     argument_spec = dict(
#         url=dict(required=False, default=os.environ.get('VAULT_ADDR', ''), type='str'),
#         ca_cert=dict(required=False, default=os.environ.get('VAULT_CACERT', ''), type='str'),
#         ca_path=dict(required=False, default=os.environ.get('VAULT_CAPATH', ''), type='str'),
#         client_cert=dict(required=False, default=os.environ.get('VAULT_CLIENT_CERT', ''), type='str'),
#         client_key=dict(required=False, default=os.environ.get('VAULT_CLIENT_KEY', ''), type='str'),
#         verify=dict(required=False, default=(not os.environ.get('VAULT_SKIP_VERIFY', '')), type='bool'),
#         authtype=dict(required=False, default=os.environ.get('VAULT_AUTHTYPE', 'token'), type='str'),
#         login_mount_point=dict(required=False, default=os.environ.get('VAULT_LOGIN_MOUNT_POINT', None), type='str'),
#         token=dict(required=False, fallback=(hashivault_default_token, ''), type='str', no_log=True),
#         username=dict(required=False, default=os.environ.get('VAULT_USER', ''), type='str'),
#         password=dict(required=False, fallback=(env_fallback, ['VAULT_PASSWORD']), type='str', no_log=True),
#         role_id=dict(required=False, fallback=(env_fallback, ['VAULT_ROLE_ID']), type='str', no_log=True),
#         secret_id=dict(required=False, fallback=(env_fallback, ['VAULT_SECRET_ID']), type='str', no_log=True),
#         aws_header=dict(required=False, fallback=(env_fallback, ['VAULT_AWS_HEADER']), type='str', no_log=True),
#         namespace=dict(required=False, default=os.environ.get('VAULT_NAMESPACE', None), type='str')
#     )
#     return argument_spec
# 
# Path: ansible/module_utils/hashivault.py
# def hashivault_auth_client(params):
#     client = hashivault_client(params)
#     return hashivault_auth(client, params)
# 
# Path: ansible/module_utils/hashivault.py
# def hashivault_init(argument_spec, supports_check_mode=False, required_if=None, required_together=None,
#                     required_one_of=None, mutually_exclusive=None):
#     module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=supports_check_mode,
#                            required_if=required_if, required_together=required_together,
#                            required_one_of=required_one_of, mutually_exclusive=mutually_exclusive)
#     module.no_log_values.discard('0')
#     module.no_log_values.discard(0)
#     module.no_log_values.discard('1')
#     module.no_log_values.discard(1)
#     module.no_log_values.discard(True)
#     module.no_log_values.discard(False)
#     module.no_log_values.discard('ttl')
#     return module
# 
# Path: ansible/module_utils/hashivault.py
# def hashiwrapper(function):
#     def wrapper(*args, **kwargs):
#         result = {"changed": False, "rc": 0}
#         result.update(function(*args, **kwargs))
#         return result
#     return wrapper
# 
# Path: ansible/module_utils/hashivault.py
# def get_keys_updated(desired_state, current_state, ignore=None):
#     """Return list of keys that have different values
# 
#     Recursively walks dict object to compare all keys
# 
#     :param desired_state: The state user desires.
#     :type desired_state: dict
#     :param current_state: The state that currently exists.
#     :type current_state: dict
#     :param ignore: Ignore these keys.
#     :type ignore: list
# 
#     :return: Different items
#     :rtype: list
#     """
# 
#     if ignore is None:
#         ignore = []
# 
#     differences = []
#     for key in desired_state.keys():
#         if key in ignore:
#             continue
#         if (key not in current_state):
#             differences.append(key)
#             continue
#         new_value = desired_state[key]
#         old_value = current_state[key]
#         if 'ttl' in key:
#             if _convert_to_seconds(old_value) != _convert_to_seconds(new_value):
#                 differences.append(key)
#         elif not _compare_state(new_value, old_value):
#             differences.append(key)
#     return differences


# Path: ansible/modules/hashivault/hashivault_k8s_auth_config.py
from ansible.module_utils.hashivault import hashivault_argspec
from ansible.module_utils.hashivault import hashivault_auth_client
from ansible.module_utils.hashivault import hashivault_init
from ansible.module_utils.hashivault import hashiwrapper
from ansible.module_utils.hashivault import get_keys_updated
from hvac.exceptions import InvalidPath

    pem_keys:
        description:
            - Optional list of PEM-formatted public keys or certificates used to verify the signatures of Kubernetes
              service account JWTs. If a certificate is given, its public key will be extracted.
    issuer:
        description:
            - Optional JWT issuer. If no issuer is specified, then this plugin will use kubernetes.io/serviceaccount as
              the default issuer (Available in hvac 0.10.2).
extends_documentation_fragment: hashivault
'''
EXAMPLES = '''
---
- hosts: localhost
  tasks:
    - hashivault_k8s_auth_config:
        kubernetes_host: https://192.168.99.100:8443
        kubernetes_ca_cert: "-----BEGIN CERTIFICATE-----\n.....\n-----END CERTIFICATE-----"
'''


def main():
    argspec = hashivault_argspec()
    argspec['mount_point'] = dict(required=False, type='str', default='kubernetes')
    argspec['kubernetes_host'] = dict(required=False, type='str', default=None)
    argspec['token_reviewer_jwt'] = dict(required=False, type='str', default=None)
    argspec['kubernetes_ca_cert'] = dict(required=False, type='str', default=None)
    argspec['pem_keys'] = dict(required=False, type='list', default=None)
    argspec['issuer'] = dict(required=False, type='str', default=None)
    required_together = [['kubernetes_host', 'kubernetes_ca_cert']]


    module = hashivault_init(argspec, supports_check_mode=True, required_together=required_together)