
    Vh                         d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d dlmZ d dlmZ 	 d d	lmZ d
Z e       Z G d de
      Zy
# e$ rZeZY d
Z[d
Z[ww xY w)    )absolute_importdivisionprint_functionan  
name: revbitspss
author: RevBits (@RevBits) <info@revbits.com>
short_description: Get secrets from RevBits PAM server
version_added: 4.1.0
description:
  - Uses the revbits_ansible Python SDK to get Secrets from RevBits PAM Server using API key authentication with the REST
    API.
requirements:
  - revbits_ansible - U(https://pypi.org/project/revbits_ansible/)
options:
  _terms:
    description:
      - This will be an array of keys for secrets which you want to fetch from RevBits PAM.
    required: true
    type: list
    elements: string
  base_url:
    description:
      - This will be the base URL of the server, for example V(https://server-url-here).
    required: true
    type: string
  api_key:
    description:
      - This will be the API key for authentication. You can get it from the RevBits PAM secret manager module.
    required: true
    type: string
z
_list:
  description:
    - The JSON responses which you can access with defined keys.
    - If you are fetching secrets named as UUID, PASSWORD it will gives you the dict of all secrets.
  type: list
  elements: dict
a  
---
- hosts: localhost
  vars:
    secret: >-
      {{
        lookup(
          'community.general.revbitspss',
          'UUIDPAM', 'DB_PASS',
          base_url='https://server-url-here',
          api_key='API_KEY_GOES_HERE'
        )
      }}
  tasks:
    - ansible.builtin.debug:
        msg: >-
          UUIDPAM is {{ (secret['UUIDPAM']) }} and DB_PASS is {{ (secret['DB_PASS']) }}
)
LookupBase)Display)AnsibleError)
raise_fromSecretServerNc                   "    e Zd Zed        Zd Zy)LookupModulec                     t        di | S )N r
   )server_parameterss    o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/lookup/revbitspss.pyClientzLookupModule.ClientT   s    0/00    c                    t         rt        t        d      t                | j                  ||       t        j                  | j                  d      | j                  d      d      }g }|D ]=  }	 t        j                  d|        |j                  ||j                  |      i       ? |S # t        $ r}t        d|j                         d }~ww xY w)Nz4revbits_ansible must be installed to use this plugin)var_optionsdirectbase_urlapi_key)r   r   z'Secret Server lookup of Secret with ID zSecret Server lookup failure: )ANOTHER_LIBRARY_IMPORT_ERRORr	   r   set_optionsr   r   
get_optiondisplayvvvappendget_pam_secret	Exceptionmessage)selfterms	variableskwargssecret_serverresulttermerrors           r   runzLookupModule.runX   s    'ST, 	Yv>$++ OOJ7??95
  	UDUEdVLMt]%A%A$%GHI	U   U"%CEMM?#STTUs   1:B//	C8CCN)__name__
__module____qualname__staticmethodr   r*   r   r   r   r   r   R   s    1 1r   r   )
__future__r   r   r   type__metaclass__DOCUMENTATIONRETURNEXAMPLESansible.plugins.lookupr   ansible.utils.displayr   ansible.errorsr   ansible.module_utils.sixr	   pam.revbits_ansible.serverr   r   ImportErrorimp_excr   r   r   r   r   <module>r<      ss   
 A @:
& . ) ' /(7 $(  ):   +#* +s   A AAA