Repository: ansible-collections/community.general

Issue:
Add "docker-v2" Protocol Support to Keycloak Modules
### Summary

## Title: Add "docker-v2" Protocol Support to Keycloak Modules

### Description:

I am submitting a feature request for the `keycloak_client`, `keycloak_clientscope`, and `keycloak_clienttemplate` modules within the `community.general` collection. Currently, these modules do not accept the "docker-v2" protocol, which is a valid protocol supported by Keycloak. This limitation hinders the usability of the Ansible modules for configurations where the "docker-v2" protocol is needed.

### Current Behavior:

The current implementation of the `keycloak_client`, `keycloak_clientscope`, and `keycloak_clienttemplate` modules restricts the protocol choice to `['openid-connect', 'saml', 'wsfed']` due to the following definition in the modules' Python code:

```python
protocol=dict(type='str', choices=['openid-connect', 'saml', 'wsfed'])
```
As a result, attempts to use the "docker-v2" protocol with these modules lead to a failure, impacting users' ability to manage Keycloak clients that require this specific protocol.

### Expected Behavior:

The modules should support the "docker-v2" protocol, aligning with the protocols supported by Keycloak itself. Users should be able to specify "docker-v2" as a protocol option when using the `keycloak_client`, `keycloak_clientscope`, and `keycloak_clienttemplate` modules.

### Proposed Solution:

Update the `protocol` parameter definition in the affected modules to include "docker-v2" in the list of choices. This change will allow the modules to accept the "docker-v2" protocol and enable users to configure their Keycloak clients accordingly.

### Use Case:

The ability to set the "docker-v2" protocol is essential for users managing Keycloak configurations that involve Docker registry authentication and other scenarios where this protocol is necessary.

### Additional Context:

The "docker-v2" protocol is a valid option in Keycloak, and it can be set via the Keycloak API or Web UI. The absence of this option in the Ansible modules is a notable limitation for users who wish to manage their Keycloak setups through Ansible automation.




### Issue Type

Feature Idea

### Component Name

keycloak_client, keycloak_clientscope, keycloak_clienttemplate

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/keycloak_client.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/keycloak_client.py)
* [`plugins/modules/keycloak_clientscope.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/keycloak_clientscope.py)
* [`plugins/modules/keycloak_clienttemplate.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/keycloak_clienttemplate.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Gaetan2907 @eikef @mattock @ndclt
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/keycloak_client.py b/plugins/modules/keycloak_client.py
--- a/plugins/modules/keycloak_client.py
+++ b/plugins/modules/keycloak_client.py
@@ -248,8 +248,9 @@
         description:
             - Type of client.
             - At creation only, default value will be V(openid-connect) if O(protocol) is omitted.
+            - The V(docker-v2) value was added in community.general 8.6.0.
         type: str
-        choices: ['openid-connect', 'saml']
+        choices: ['openid-connect', 'saml', 'docker-v2']
 
     full_scope_allowed:
         description:
@@ -393,7 +394,7 @@
             protocol:
                 description:
                     - This specifies for which protocol this protocol mapper is active.
-                choices: ['openid-connect', 'saml']
+                choices: ['openid-connect', 'saml', 'docker-v2']
                 type: str
 
             protocolMapper:
@@ -724,6 +725,7 @@
 
 PROTOCOL_OPENID_CONNECT = 'openid-connect'
 PROTOCOL_SAML = 'saml'
+PROTOCOL_DOCKER_V2 = 'docker-v2'
 CLIENT_META_DATA = ['authorizationServicesEnabled']
 
 
@@ -785,7 +787,7 @@ def main():
         consentText=dict(type='str'),
         id=dict(type='str'),
         name=dict(type='str'),
-        protocol=dict(type='str', choices=[PROTOCOL_OPENID_CONNECT, PROTOCOL_SAML]),
+        protocol=dict(type='str', choices=[PROTOCOL_OPENID_CONNECT, PROTOCOL_SAML, PROTOCOL_DOCKER_V2]),
         protocolMapper=dict(type='str'),
         config=dict(type='dict'),
     )
@@ -819,7 +821,7 @@ def main():
         authorization_services_enabled=dict(type='bool', aliases=['authorizationServicesEnabled']),
         public_client=dict(type='bool', aliases=['publicClient']),
         frontchannel_logout=dict(type='bool', aliases=['frontchannelLogout']),
-        protocol=dict(type='str', choices=[PROTOCOL_OPENID_CONNECT, PROTOCOL_SAML]),
+        protocol=dict(type='str', choices=[PROTOCOL_OPENID_CONNECT, PROTOCOL_SAML, PROTOCOL_DOCKER_V2]),
         attributes=dict(type='dict'),
         full_scope_allowed=dict(type='bool', aliases=['fullScopeAllowed']),
         node_re_registration_timeout=dict(type='int', aliases=['nodeReRegistrationTimeout']),
diff --git a/plugins/modules/keycloak_clientscope.py b/plugins/modules/keycloak_clientscope.py
--- a/plugins/modules/keycloak_clientscope.py
+++ b/plugins/modules/keycloak_clientscope.py
@@ -79,7 +79,8 @@
     protocol:
         description:
             - Type of client.
-        choices: ['openid-connect', 'saml', 'wsfed']
+            - The V(docker-v2) value was added in community.general 8.6.0.
+        choices: ['openid-connect', 'saml', 'wsfed', 'docker-v2']
         type: str
 
     protocol_mappers:
@@ -95,7 +96,7 @@
                 description:
                     - This specifies for which protocol this protocol mapper.
                     - is active.
-                choices: ['openid-connect', 'saml', 'wsfed']
+                choices: ['openid-connect', 'saml', 'wsfed', 'docker-v2']
                 type: str
 
             protocolMapper:
@@ -330,7 +331,7 @@ def main():
     protmapper_spec = dict(
         id=dict(type='str'),
         name=dict(type='str'),
-        protocol=dict(type='str', choices=['openid-connect', 'saml', 'wsfed']),
+        protocol=dict(type='str', choices=['openid-connect', 'saml', 'wsfed', 'docker-v2']),
         protocolMapper=dict(type='str'),
         config=dict(type='dict'),
     )
@@ -341,7 +342,7 @@ def main():
         id=dict(type='str'),
         name=dict(type='str'),
         description=dict(type='str'),
-        protocol=dict(type='str', choices=['openid-connect', 'saml', 'wsfed']),
+        protocol=dict(type='str', choices=['openid-connect', 'saml', 'wsfed', 'docker-v2']),
         attributes=dict(type='dict'),
         protocol_mappers=dict(type='list', elements='dict', options=protmapper_spec, aliases=['protocolMappers']),
     )
diff --git a/plugins/modules/keycloak_clienttemplate.py b/plugins/modules/keycloak_clienttemplate.py
--- a/plugins/modules/keycloak_clienttemplate.py
+++ b/plugins/modules/keycloak_clienttemplate.py
@@ -68,7 +68,8 @@
     protocol:
         description:
             - Type of client template.
-        choices: ['openid-connect', 'saml']
+            - The V(docker-v2) value was added in community.general 8.6.0.
+        choices: ['openid-connect', 'saml', 'docker-v2']
         type: str
 
     full_scope_allowed:
@@ -107,7 +108,7 @@
             protocol:
                 description:
                     - This specifies for which protocol this protocol mapper is active.
-                choices: ['openid-connect', 'saml']
+                choices: ['openid-connect', 'saml', 'docker-v2']
                 type: str
 
             protocolMapper:
@@ -292,7 +293,7 @@ def main():
         consentText=dict(type='str'),
         id=dict(type='str'),
         name=dict(type='str'),
-        protocol=dict(type='str', choices=['openid-connect', 'saml']),
+        protocol=dict(type='str', choices=['openid-connect', 'saml', 'docker-v2']),
         protocolMapper=dict(type='str'),
         config=dict(type='dict'),
     )
@@ -304,7 +305,7 @@ def main():
         id=dict(type='str'),
         name=dict(type='str'),
         description=dict(type='str'),
-        protocol=dict(type='str', choices=['openid-connect', 'saml']),
+        protocol=dict(type='str', choices=['openid-connect', 'saml', 'docker-v2']),
         attributes=dict(type='dict'),
         full_scope_allowed=dict(type='bool'),
         protocol_mappers=dict(type='list', elements='dict', options=protmapper_spec),


Test patch: