
    Vht.                         d dl mZmZmZ eZdZdZdZd dl	m
Z
mZmZmZmZ d dlmZ d dlmZ d dlmZ d	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functionu  
module: keycloak_component

short_description: Allows administration of Keycloak components using Keycloak API

version_added: 10.0.0

description:
  - This module allows the administration of Keycloak components using the Keycloak REST API. It requires access to the REST
    API using OpenID Connect; the user connecting and the realm being used must have the requisite access rights. In a default
    Keycloak installation, C(admin-cli) and an C(admin) user would work, as would a separate realm definition with the scope
    tailored to your needs and a user having the expected roles.
  - The names of module options are snake_cased versions of the camelCase ones found in the Keycloak API and its documentation
    at U(https://www.keycloak.org/docs-api/latest/rest-api/index.html). Aliases are provided so camelCased versions can be
    used as well.
attributes:
  check_mode:
    support: full
  diff_mode:
    support: full
  action_group:
    version_added: 10.2.0

options:
  state:
    description:
      - State of the Keycloak component.
      - On V(present), the component will be created (or updated if it exists already).
      - On V(absent), the component will be removed if it exists.
    choices: ['present', 'absent']
    default: 'present'
    type: str
  name:
    description:
      - Name of the component to create.
    type: str
    required: true
  parent_id:
    description:
      - The parent_id of the component. In practice the ID (name) of the realm.
    type: str
    required: true
  provider_id:
    description:
      - The name of the "provider ID" for the key.
    type: str
    required: true
  provider_type:
    description:
      - The name of the "provider type" for the key. That is, V(org.keycloak.storage.UserStorageProvider), V(org.keycloak.userprofile.UserProfileProvider),
        ...
      - See U(https://www.keycloak.org/docs/latest/server_development/index.html#_providers).
    type: str
    required: true
  config:
    description:
      - Configuration properties for the provider.
      - Contents vary depending on the provider type.
    type: dict

extends_documentation_fragment:
  - community.general.keycloak
  - community.general.keycloak.actiongroup_keycloak
  - community.general.attributes

author:
  - Björn Bösel (@fivetide)
a  
- name: Manage Keycloak User Storage Provider
  community.general.keycloak_component:
    auth_keycloak_url: http://localhost:8080/auth
    auth_username: keycloak
    auth_password: keycloak
    auth_realm: master
    name: my storage provider
    state: present
    parent_id: some_realm
    provider_id: my storage
    provider_type: "org.keycloak.storage.UserStorageProvider"
    config:
      myCustomKey: "my_custom_key"
      cachePolicy: "NO_CACHE"
      enabled: true
av  
end_state:
  description: Representation of the keycloak_component after module execution.
  returned: on success
  type: dict
  contains:
    id:
      description: ID of the component.
      type: str
      returned: when O(state=present)
      sample: 5b7ec13f-99da-46ad-8326-ab4c73cf4ce4
    name:
      description: Name of the component.
      type: str
      returned: when O(state=present)
      sample: mykey
    parentId:
      description: ID of the realm this key belongs to.
      type: str
      returned: when O(state=present)
      sample: myrealm
    providerId:
      description: The ID of the key provider.
      type: str
      returned: when O(state=present)
      sample: rsa
    providerType:
      description: The type of provider.
      type: str
      returned: when O(state=present)
    config:
      description: Component configuration.
      type: dict
)KeycloakAPIcamelkeycloak_argument_spec	get_tokenKeycloakError)AnsibleModule)	urlencode)deepcopyc            
      ^   t               } t        t        ddddg      t        dd      t        dd      t        dd      t        dd      t        d      	      }| j                  |       t        | dg d
gg dgddi      }t        ddi t        i i             }i }i |d<   	 t	        |j
                        }t        |      }t        t               j                               ddgz   }|j
                  D 	cg c]#  }	|	|vr|j
                  j                  |	      |	% }
}	|j
                  j                  d      }i }i |d<   |
D ]  }|dk(  r|j
                  j                  d      D ]  }g |d   t        |      <   |j
                  j                  d      |   }t        |t              rt        |      j!                         }nt        |      }|d   t        |         j#                  |        |j
                  j                  |      }||t        |      <    t%        |      }|j
                  j                  d      }|j
                  j                  d      }|j
                  j                  d      }|j
                  j                  d      }|j
                  j                  d      }|j
                  j                  d      }|j
                  j                  d      }|j'                  t)        t        |            |      }d }d}d|d<   |D ]  }|d   |k(  s|d   }||d<   ||d<   |j+                         D ]8  \  }}||   ||<   ||   ||   k7  s|dk7  s ||d||   d||   d z  }d|d<   : |d   j+                         D ]J  \  }}	 |d   |   xs g |d   |<   |d   |   |d   |   k7  s+|d!|d|d   |   d|d   |   d z  }d|d<   L  |r|dk(  r|d   rp|j.                  rt        ||      |d"<   |j0                  rd#|d$|j3                  d       |d%<   n5|j5                  ||       d#|d&|j3                  d       |d%<   nd'|z  |d%<   ||d(<   n|r`|dk(  r[|j.                  rt        |i       |d"<   |j0                  rd|d<   d)|z  |d%<   n|j7                  ||       d|d<   d*|z  |d%<   i |d(<   n{|s`|dk(  r[|j.                  rt        i |      |d"<   |j0                  rd|d<   d+|z  |d%<   n|j9                  ||       d|d<   d,|z  |d%<   ||d(<   n|s|dk(  rd|d<   d-|z  |d%<   i |d(<    |j:                  d.i | y # t        $ r&}|j                  t        |             Y d }~d }~ww xY wc c}	w # t,        $ r g |d   |<   Y w xY w)/Nstrpresentabsent)typedefaultchoicesT)r   requireddict)r   )statename	parent_idprovider_idprovider_typeconfig)token
auth_realmauth_usernameauth_password)r   r   r    refresh_tokenr   )argument_specsupports_check_moderequired_one_ofrequired_togetherrequired_byF )beforeafter)changedmsg	end_statediffr   )r+   r   r   r   r   forceenabledr   r*   idz: z -> z, zconfig.r-   z
Component z would be changed: r+   z
 changed: zComponent %s was in syncr,   zComponent %s would be deletedzComponent %s deletedzComponent %s would be createdzComponent %s createdzComponent %s not present )r   r   updater   r	   paramsr
   	fail_jsonr   r   listkeysgetr   
isinstanceboollowerappendr   get_componentsr   itemsKeyError_diff
check_modestripupdate_componentdelete_componentcreate_component	exit_json) r"   	meta_argsmoduleresultbefore_componentconnection_headerekcparams_to_ignorexcomponent_paramsr   	changesetcomponent_paramconfig_param	raw_valuevaluenew_param_valuechangeset_copyr   r.   r   r/   r   r   current_componentscomponent_idchanges	componentparampvs                                    x/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/keycloak_component.pymainr_      sK   *,My9h:OPut,ED1ed35
	I #/3-f,g/_.`(7'F	F %R2DRT<UVF !#X%%fmm4 
V.	/B2499;<?UU $*== :a$44))!,8  : : MM%%o6M IIh , @h& & 1 1( ; G;=	(#E,$78"MM--h7E	i.	N002E	NE(#E,$78??FG %mm//@O0?IeO,-@$ i(N ==V$DMMg&EMMg&Emm	*G--##M2KMM%%o6M!!+.I **9T}5M+NPYZ L G F9
 ( -	V$$T?L*IdO#/N4  !* 1 -u*3E*: '!%(Ie,<<(AR5)E:JN[`LabbG(,F9%- 'x0668 -174=h4G4J4Pb$X.q1 "(+A.)H2Ea2HH!Yx=PQR=SUcdlUmnoUpqqG(,F9%--4 *)||!%-=^!Tv  GKW]][_M` au##Iy9>BGMMRVDW Xu6$?F5M,{	%8+<<!)9DF6N $F9;tDF5Mi8 $F92d;F5M {ey0<<!>BF6N $F9;tDF5M	95 $F92d;F5M,{ex/!y2d;u {Fvg  %SV$$%:j   746$X.q17s0   +U   (VV 	V)V

VV,+V,__main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNUansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloakr   r   r   r	   r
   ansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.parser   copyr   r_   __name__r1       r^   <module>rl      sY    A @CJ$!
F5 5 4 A tn zF rk   