Repository: ansible-collections/community.general

Issue:
keycloak_client module uses deprecated client templates instead of client scopes
### Summary

Since Keycloak 4.0, "Client Templates" has been renamed to "Client Scopes". The corresponding client representation in the API uses "defaultClientScopes" and "optionalClientScopes" as arrays.

Attempting to use "client_template" (as a list of Available Client Scopess" and "use_template_scope = true" has no affect on the client. "client_template" is looking for a string and even if using a valid client scope here, it does not get added to the client.

### Issue Type

Bug Report

### Component Name

keycloak_client

### Ansible Version

```console (paste below)
$ ansible --version
ansible 2.9.10
  config file = /Users/mf/git/lasp/wi/ansible/ansible.cfg
  configured module search path = ['/Users/mf/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/mf/venvs/ansible-2.9.10/lib/python3.7/site-packages/ansible
  executable location = /Users/mf/venvs/ansible-2.9.10/bin/ansible
  python version = 3.7.4 (default, Sep  7 2019, 18:31:37) [Clang 9.0.0 (clang-900.0.39.2)]
```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed

```


### OS / Environment

_No response_

### Steps to Reproduce

Set the variable {{client_template}} and {{use_template_scope}}.


### Expected Results

I expect the module to add Available Client Scopes in a list to the client.

### Actual Results

Client is created with Default Client Scopes only.


### Code of Conduct

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


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

If these files are inaccurate, 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/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @eikef @ndclt
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/identity/keycloak/keycloak_client.py b/plugins/modules/identity/keycloak/keycloak_client.py
--- a/plugins/modules/identity/keycloak/keycloak_client.py
+++ b/plugins/modules/identity/keycloak/keycloak_client.py
@@ -326,6 +326,24 @@
             - authenticationFlowBindingOverrides
         version_added: 3.4.0
 
+    default_client_scopes:
+        description:
+            - List of default client scopes.
+        aliases:
+            - defaultClientScopes
+        type: list
+        elements: str
+        version_added: 4.7.0
+
+    optional_client_scopes:
+        description:
+            - List of optional client scopes.
+        aliases:
+            - optionalClientScopes
+        type: list
+        elements: str
+        version_added: 4.7.0
+
     protocol_mappers:
         description:
             - a list of dicts defining protocol mappers for this client.
@@ -789,6 +807,8 @@ def main():
         authentication_flow_binding_overrides=dict(type='dict', aliases=['authenticationFlowBindingOverrides']),
         protocol_mappers=dict(type='list', elements='dict', options=protmapper_spec, aliases=['protocolMappers']),
         authorization_settings=dict(type='dict', aliases=['authorizationSettings']),
+        default_client_scopes=dict(type='list', elements='str', aliases=['defaultClientScopes']),
+        optional_client_scopes=dict(type='list', elements='str', aliases=['optionalClientScopes']),
     )
 
     argument_spec.update(meta_args)


Test patch: