Skip to content

Keycloak

The keycloak adapter provides integration with Keycloak for identity and access management, including token validation, user management, and role-based access control.

Ports

Abstract port interface defining the Keycloak adapter contract.

Keycloak port interfaces composed from per-concern mixins.

archipy.adapters.keycloak.ports.KeycloakGroupType module-attribute

KeycloakGroupType = dict[str, Any]

archipy.adapters.keycloak.ports.KeycloakOrganizationType module-attribute

KeycloakOrganizationType = dict[str, Any]

archipy.adapters.keycloak.ports.KeycloakResponseType module-attribute

KeycloakResponseType = dict[str, Any]

archipy.adapters.keycloak.ports.KeycloakRoleType module-attribute

KeycloakRoleType = dict[str, Any]

archipy.adapters.keycloak.ports.KeycloakTokenType module-attribute

KeycloakTokenType = dict[str, Any]

archipy.adapters.keycloak.ports.KeycloakUserType module-attribute

KeycloakUserType = dict[str, Any]

archipy.adapters.keycloak.ports.PublicKeyType module-attribute

PublicKeyType = Any

archipy.adapters.keycloak.ports.KeycloakPort

Bases: KeycloakAuthPort, KeycloakUsersPort, KeycloakRolesPort, KeycloakClientsPort, KeycloakRealmsPort, KeycloakOrganizationsPort, KeycloakGroupsPort, KeycloakAuthFlowsPort, KeycloakClientScopesPort, KeycloakAuthzPort, KeycloakUmaPort, KeycloakComponentsPort

Interface for Keycloak operations providing a standardized access pattern.

This interface defines the contract for Keycloak adapters, ensuring consistent implementation of Keycloak operations across different adapters. It covers essential functionality including authentication, user management, and role management.

Source code in archipy/adapters/keycloak/ports.py
class KeycloakPort(
    KeycloakAuthPort,
    KeycloakUsersPort,
    KeycloakRolesPort,
    KeycloakClientsPort,
    KeycloakRealmsPort,
    KeycloakOrganizationsPort,
    KeycloakGroupsPort,
    KeycloakAuthFlowsPort,
    KeycloakClientScopesPort,
    KeycloakAuthzPort,
    KeycloakUmaPort,
    KeycloakComponentsPort,
):
    """Interface for Keycloak operations providing a standardized access pattern.

    This interface defines the contract for Keycloak adapters, ensuring consistent
    implementation of Keycloak operations across different adapters. It covers essential
    functionality including authentication, user management, and role management.
    """

archipy.adapters.keycloak.ports.KeycloakPort.create_component abstractmethod

create_component(payload: dict[str, Any]) -> str

Create a Keycloak component.

Parameters:

Name Type Description Default
payload dict[str, Any]

Component representation.

required

Returns:

Type Description
str

Created component ID.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
def create_component(self, payload: dict[str, Any]) -> str:
    """Create a Keycloak component.

    Args:
        payload: Component representation.

    Returns:
        Created component ID.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_component abstractmethod

get_component(component_id: str) -> dict[str, Any]

Get a component by ID.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Component representation.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
def get_component(self, component_id: str) -> dict[str, Any]:
    """Get a component by ID.

    Args:
        component_id: Component identifier.

    Returns:
        Component representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_components abstractmethod

get_components(
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get components, optionally filtered by query.

Parameters:

Name Type Description Default
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

Matching component representations.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
def get_components(self, query: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Get components, optionally filtered by query.

    Args:
        query: Optional filter query parameters.

    Returns:
        Matching component representations.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_component abstractmethod

update_component(
    component_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required
payload dict[str, Any]

Updated component representation.

required

Returns:

Type Description
dict[str, Any]

Update response payload.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
def update_component(self, component_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a component.

    Args:
        component_id: Component identifier.
        payload: Updated component representation.

    Returns:
        Update response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_component abstractmethod

delete_component(component_id: str) -> dict[str, Any]

Delete a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
def delete_component(self, component_id: str) -> dict[str, Any]:
    """Delete a component.

    Args:
        component_id: Component identifier.

    Returns:
        Deletion response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.resource_set_create abstractmethod

resource_set_create(
    payload: dict[str, Any],
) -> dict[str, Any]

Create a UMA resource set.

Parameters:

Name Type Description Default
payload dict[str, Any]

Resource set representation.

required

Returns:

Type Description
dict[str, Any]

Created resource set representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def resource_set_create(self, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA resource set.

    Args:
        payload: Resource set representation.

    Returns:
        Created resource set representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.resource_set_read abstractmethod

resource_set_read(resource_id: str) -> dict[str, Any]

Read a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Resource set representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def resource_set_read(self, resource_id: str) -> dict[str, Any]:
    """Read a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Resource set representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.resource_set_update abstractmethod

resource_set_update(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required
payload dict[str, Any]

Updated resource set representation.

required

Returns:

Type Description
dict[str, Any]

Updated resource set representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def resource_set_update(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a UMA resource set.

    Args:
        resource_id: Resource set identifier.
        payload: Updated resource set representation.

    Returns:
        Updated resource set representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.resource_set_delete abstractmethod

resource_set_delete(resource_id: str) -> dict[str, Any]

Delete a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def resource_set_delete(self, resource_id: str) -> dict[str, Any]:
    """Delete a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Deletion response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.resource_set_list abstractmethod

resource_set_list() -> list[dict[str, Any]]

List all UMA resource sets.

Returns:

Type Description
list[dict[str, Any]]

List of resource set representations.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def resource_set_list(self) -> list[dict[str, Any]]:
    """List all UMA resource sets.

    Returns:
        List of resource set representations.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.resource_set_list_ids abstractmethod

resource_set_list_ids(
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

List UMA resource set IDs with optional filters.

Parameters:

Name Type Description Default
name str

Filter by resource name.

''
exact_name bool

Require exact name match when True.

False
uri str

Filter by resource URI.

''
owner str

Filter by owner.

''
resource_type str

Filter by resource type.

''
scope str

Filter by scope.

''
matchingUri bool

Match URI patterns when True.

False
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching resource set IDs / summaries.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def resource_set_list_ids(
    self,
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """List UMA resource set IDs with optional filters.

    Args:
        name: Filter by resource name.
        exact_name: Require exact name match when True.
        uri: Filter by resource URI.
        owner: Filter by owner.
        resource_type: Filter by resource type.
        scope: Filter by scope.
        matchingUri: Match URI patterns when True.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching resource set IDs / summaries.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.policy_resource_create abstractmethod

policy_resource_create(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Create a UMA policy for a resource.

Parameters:

Name Type Description Default
resource_id str

Resource identifier.

required
payload dict[str, Any]

Policy representation.

required

Returns:

Type Description
dict[str, Any]

Created policy representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def policy_resource_create(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA policy for a resource.

    Args:
        resource_id: Resource identifier.
        payload: Policy representation.

    Returns:
        Created policy representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.policy_update abstractmethod

policy_update(
    policy_id: str, payload: dict[str, Any]
) -> bytes

Update a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required
payload dict[str, Any]

Updated policy representation.

required

Returns:

Type Description
bytes

Raw update response bytes.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def policy_update(self, policy_id: str, payload: dict[str, Any]) -> bytes:
    """Update a UMA policy.

    Args:
        policy_id: Policy identifier.
        payload: Updated policy representation.

    Returns:
        Raw update response bytes.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.policy_delete abstractmethod

policy_delete(policy_id: str) -> dict[str, Any]

Delete a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def policy_delete(self, policy_id: str) -> dict[str, Any]:
    """Delete a UMA policy.

    Args:
        policy_id: Policy identifier.

    Returns:
        Deletion response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.policy_query abstractmethod

policy_query(
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

Query UMA policies.

Parameters:

Name Type Description Default
resource str

Filter by resource.

''
name str

Filter by policy name.

''
scope str

Filter by scope.

''
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching policy representations.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def policy_query(
    self,
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """Query UMA policies.

    Args:
        resource: Filter by resource.
        name: Filter by policy name.
        scope: Filter by scope.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching policy representations.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.permission_ticket_create abstractmethod

permission_ticket_create(
    permissions: Iterable[UMAPermission],
) -> dict[str, Any]

Create a UMA permission ticket.

Parameters:

Name Type Description Default
permissions Iterable[UMAPermission]

Permissions to include in the ticket.

required

Returns:

Type Description
dict[str, Any]

Permission ticket representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def permission_ticket_create(self, permissions: Iterable[UMAPermission]) -> dict[str, Any]:
    """Create a UMA permission ticket.

    Args:
        permissions: Permissions to include in the ticket.

    Returns:
        Permission ticket representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.permissions_check abstractmethod

permissions_check(
    token: str,
    permissions: Iterable[UMAPermission],
    **extra_payload: Any,
) -> bool

Check UMA permissions for a token.

Parameters:

Name Type Description Default
token str

Access token to evaluate.

required
permissions Iterable[UMAPermission]

Permissions to check.

required
**extra_payload Any

Extra fields forwarded to the UMA endpoint.

{}

Returns:

Type Description
bool

True when all requested permissions are granted.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
def permissions_check(self, token: str, permissions: Iterable[UMAPermission], **extra_payload: Any) -> bool:
    """Check UMA permissions for a token.

    Args:
        token: Access token to evaluate.
        permissions: Permissions to check.
        **extra_payload: Extra fields forwarded to the UMA endpoint.

    Returns:
        True when all requested permissions are granted.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_resource abstractmethod

create_client_authz_resource(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization resource for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_resource(self, client_id: str, payload: dict, skip_exists: bool = False) -> dict[str, Any]:
    """Create an authorization resource for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_resources abstractmethod

get_client_authz_resources(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization resources for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_resources(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization resources for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_resource abstractmethod

get_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Get a single authorization resource.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Get a single authorization resource."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_client_authz_resource abstractmethod

update_client_authz_resource(
    client_id: str, resource_id: str, payload: dict
) -> dict[str, Any]

Update an authorization resource.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def update_client_authz_resource(self, client_id: str, resource_id: str, payload: dict) -> dict[str, Any]:
    """Update an authorization resource."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_client_authz_resource abstractmethod

delete_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Delete an authorization resource.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def delete_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Delete an authorization resource."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_scopes abstractmethod

create_client_authz_scopes(
    client_id: str, payload: dict
) -> dict[str, Any]

Create authorization scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_scopes(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Create authorization scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_scopes abstractmethod

get_client_authz_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_role_based_policy abstractmethod

create_client_authz_role_based_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a role-based authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_role_based_policy(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a role-based authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_client_policy abstractmethod

create_client_authz_client_policy(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a client-based authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_client_policy(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a client-based authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_policy abstractmethod

create_client_authz_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_policy(self, client_id: str, payload: dict, skip_exists: bool = False) -> dict[str, Any]:
    """Create an authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_policies abstractmethod

get_client_authz_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization policies for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization policies for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_policy abstractmethod

get_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Get a single authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Get a single authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_client_authz_policy abstractmethod

delete_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Delete an authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def delete_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Delete an authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_resource_based_permission abstractmethod

create_client_authz_resource_based_permission(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a resource-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_resource_based_permission(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a resource-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_authz_scope_permission abstractmethod

create_client_authz_scope_permission(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a scope-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def create_client_authz_scope_permission(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a scope-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_permissions abstractmethod

get_client_authz_permissions(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization permissions for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_permissions(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization permissions for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_scope_permission abstractmethod

get_client_authz_scope_permission(
    client_id: str, scope_id: str
) -> dict[str, Any]

Get a scope-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_scope_permission(self, client_id: str, scope_id: str) -> dict[str, Any]:
    """Get a scope-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_client_authz_scope_permission abstractmethod

update_client_authz_scope_permission(
    payload: dict, client_id: str, scope_id: str
) -> bytes

Update a scope-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def update_client_authz_scope_permission(self, payload: dict, client_id: str, scope_id: str) -> bytes:
    """Update a scope-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_client_authz_resource_permission abstractmethod

update_client_authz_resource_permission(
    payload: dict, client_id: str, resource_id: str
) -> bytes

Update a resource-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def update_client_authz_resource_permission(self, payload: dict, client_id: str, resource_id: str) -> bytes:
    """Update a resource-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_permission_associated_policies abstractmethod

get_client_authz_permission_associated_policies(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get policies associated with a permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_permission_associated_policies(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get policies associated with a permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_settings abstractmethod

get_client_authz_settings(client_id: str) -> dict[str, Any]

Get authorization settings for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_settings(self, client_id: str) -> dict[str, Any]:
    """Get authorization settings for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_client_policies abstractmethod

get_client_authz_client_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get client policies for authorization.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_client_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get client policies for authorization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_policy_resources abstractmethod

get_client_authz_policy_resources(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get resources associated with a policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_policy_resources(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get resources associated with a policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_authz_policy_scopes abstractmethod

get_client_authz_policy_scopes(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get scopes associated with a policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def get_client_authz_policy_scopes(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get scopes associated with a policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.import_client_authz_config abstractmethod

import_client_authz_config(
    client_id: str, payload: dict
) -> dict[str, Any]

Import authorization configuration for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
def import_client_authz_config(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Import authorization configuration for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_scopes abstractmethod

get_client_scopes() -> list[dict[str, Any]]

Get all client scopes.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get all client scopes."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_scope abstractmethod

get_client_scope(client_scope_id: str) -> dict[str, Any]

Get a client scope by ID.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Get a client scope by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_scope_by_name abstractmethod

get_client_scope_by_name(
    client_scope_name: str,
) -> dict[str, Any] | None

Get a client scope by name.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_client_scope_by_name(self, client_scope_name: str) -> dict[str, Any] | None:
    """Get a client scope by name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_scope abstractmethod

create_client_scope(
    payload: dict, skip_exists: bool = False
) -> str

Create a new client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def create_client_scope(self, payload: dict, skip_exists: bool = False) -> str:
    """Create a new client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_client_scope abstractmethod

update_client_scope(
    client_scope_id: str, payload: dict
) -> dict[str, Any]

Update a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def update_client_scope(self, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Update a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_client_scope abstractmethod

delete_client_scope(client_scope_id: str) -> dict[str, Any]

Delete a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def delete_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Delete a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_mapper_to_client_scope abstractmethod

add_mapper_to_client_scope(
    client_scope_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def add_mapper_to_client_scope(self, client_scope_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_mappers_from_client_scope abstractmethod

get_mappers_from_client_scope(
    client_scope_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_mappers_from_client_scope(self, client_scope_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_mapper_in_client_scope abstractmethod

update_mapper_in_client_scope(
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]

Update a protocol mapper in a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def update_mapper_in_client_scope(
    self,
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Update a protocol mapper in a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_mapper_from_client_scope abstractmethod

delete_mapper_from_client_scope(
    client_scope_id: str, protocol_mapper_id: str
) -> dict[str, Any]

Delete a protocol mapper from a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def delete_mapper_from_client_scope(self, client_scope_id: str, protocol_mapper_id: str) -> dict[str, Any]:
    """Delete a protocol mapper from a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_mapper_to_client abstractmethod

add_mapper_to_client(
    client_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def add_mapper_to_client(self, client_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_mappers_from_client abstractmethod

get_mappers_from_client(
    client_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_mappers_from_client(self, client_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_client_mapper abstractmethod

update_client_mapper(
    client_id: str, mapper_id: str, payload: dict
) -> dict[str, Any]

Update a protocol mapper on a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def update_client_mapper(self, client_id: str, mapper_id: str, payload: dict) -> dict[str, Any]:
    """Update a protocol mapper on a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.remove_client_mapper abstractmethod

remove_client_mapper(
    client_id: str, client_mapper_id: str
) -> dict[str, Any]

Remove a protocol mapper from a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def remove_client_mapper(self, client_id: str, client_mapper_id: str) -> dict[str, Any]:
    """Remove a protocol mapper from a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_default_client_scopes abstractmethod

get_client_default_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get default client scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_client_default_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get default client scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_client_default_client_scope abstractmethod

add_client_default_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add a default client scope to a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def add_client_default_client_scope(self, client_id: str, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Add a default client scope to a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_client_default_client_scope abstractmethod

delete_client_default_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove a default client scope from a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def delete_client_default_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove a default client scope from a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_optional_client_scopes abstractmethod

get_client_optional_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get optional client scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_client_optional_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get optional client scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_client_optional_client_scope abstractmethod

add_client_optional_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add an optional client scope to a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def add_client_optional_client_scope(self, client_id: str, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Add an optional client scope to a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_client_optional_client_scope abstractmethod

delete_client_optional_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove an optional client scope from a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def delete_client_optional_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove an optional client scope from a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_default_default_client_scopes abstractmethod

get_default_default_client_scopes() -> list[dict[str, Any]]

Get realm default client scopes.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_default_default_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm default client scopes."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_default_default_client_scope abstractmethod

add_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def add_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_default_default_client_scope abstractmethod

delete_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def delete_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_default_optional_client_scopes abstractmethod

get_default_optional_client_scopes() -> list[
    dict[str, Any]
]

Get realm optional default client scopes.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def get_default_optional_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm optional default client scopes."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_default_optional_client_scope abstractmethod

add_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm optional default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def add_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm optional default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_default_optional_client_scope abstractmethod

delete_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm optional default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
def delete_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm optional default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_authentication_flow abstractmethod

create_authentication_flow(
    payload: dict, skip_exists: bool = False
) -> bytes

Create a new authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def create_authentication_flow(self, payload: dict, skip_exists: bool = False) -> bytes:
    """Create a new authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.copy_authentication_flow abstractmethod

copy_authentication_flow(
    payload: dict, flow_alias: str
) -> bytes

Copy an existing authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def copy_authentication_flow(self, payload: dict, flow_alias: str) -> bytes:
    """Copy an existing authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authentication_flows abstractmethod

get_authentication_flows() -> list[dict[str, Any]]

Get all authentication flows.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authentication_flows(
    self,
) -> list[dict[str, Any]]:
    """Get all authentication flows."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authentication_flow_for_id abstractmethod

get_authentication_flow_for_id(
    flow_id: str,
) -> dict[str, Any]

Get authentication flow by ID.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authentication_flow_for_id(self, flow_id: str) -> dict[str, Any]:
    """Get authentication flow by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_authentication_flow abstractmethod

delete_authentication_flow(flow_id: str) -> dict[str, Any]

Delete an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def delete_authentication_flow(self, flow_id: str) -> dict[str, Any]:
    """Delete an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authentication_flow_executions abstractmethod

get_authentication_flow_executions(
    flow_alias: str,
) -> list[dict[str, Any]]

Get executions for an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authentication_flow_executions(self, flow_alias: str) -> list[dict[str, Any]]:
    """Get executions for an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authentication_flow_execution abstractmethod

get_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Get a single authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Get a single authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_authentication_flow_execution abstractmethod

create_authentication_flow_execution(
    payload: dict, flow_alias: str
) -> bytes

Create an execution in an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def create_authentication_flow_execution(self, payload: dict, flow_alias: str) -> bytes:
    """Create an execution in an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_authentication_flow_executions abstractmethod

update_authentication_flow_executions(
    payload: dict, flow_alias: str
) -> dict[str, Any]

Update executions in an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def update_authentication_flow_executions(self, payload: dict, flow_alias: str) -> dict[str, Any]:
    """Update executions in an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_authentication_flow_subflow abstractmethod

create_authentication_flow_subflow(
    payload: dict,
    flow_alias: str,
    skip_exists: bool = False,
) -> bytes

Create a subflow in an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def create_authentication_flow_subflow(self, payload: dict, flow_alias: str, skip_exists: bool = False) -> bytes:
    """Create a subflow in an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_authentication_flow_execution abstractmethod

delete_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Delete an authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def delete_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Delete an authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.change_execution_priority abstractmethod

change_execution_priority(
    execution_id: str, diff: int
) -> None

Change priority of an authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def change_execution_priority(self, execution_id: str, diff: int) -> None:
    """Change priority of an authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_authentication_flow abstractmethod

update_authentication_flow(
    flow_id: str, payload: dict
) -> dict[str, Any]

Update an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def update_authentication_flow(self, flow_id: str, payload: dict) -> dict[str, Any]:
    """Update an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authenticator_providers abstractmethod

get_authenticator_providers() -> list[dict[str, Any]]

Get available authenticator providers.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authenticator_providers(
    self,
) -> list[dict[str, Any]]:
    """Get available authenticator providers."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authenticator_provider_config_description abstractmethod

get_authenticator_provider_config_description(
    provider_id: str,
) -> dict[str, Any]

Get config description for an authenticator provider.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authenticator_provider_config_description(self, provider_id: str) -> dict[str, Any]:
    """Get config description for an authenticator provider."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_authenticator_config abstractmethod

get_authenticator_config(config_id: str) -> dict[str, Any]

Get authenticator configuration by ID.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def get_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Get authenticator configuration by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_authenticator_config abstractmethod

update_authenticator_config(
    payload: dict, config_id: str
) -> dict[str, Any]

Update authenticator configuration.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def update_authenticator_config(self, payload: dict, config_id: str) -> dict[str, Any]:
    """Update authenticator configuration."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_authenticator_config abstractmethod

delete_authenticator_config(
    config_id: str,
) -> dict[str, Any]

Delete authenticator configuration.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def delete_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Delete authenticator configuration."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_execution_config abstractmethod

create_execution_config(
    execution_id: str, payload: dict
) -> bytes

Create configuration for an authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
def create_execution_config(self, execution_id: str, payload: dict) -> bytes:
    """Create configuration for an authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_group abstractmethod

create_group(
    payload: dict,
    parent: str | None = None,
    skip_exists: bool = False,
) -> str | None

Create a new group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
# Group Operations
@abstractmethod
def create_group(self, payload: dict, parent: str | None = None, skip_exists: bool = False) -> str | None:
    """Create a new group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_group abstractmethod

update_group(
    group_id: str, payload: dict
) -> dict[str, Any]

Update a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def update_group(self, group_id: str, payload: dict) -> dict[str, Any]:
    """Update a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_group abstractmethod

delete_group(group_id: str) -> dict[str, Any]

Delete a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def delete_group(self, group_id: str) -> dict[str, Any]:
    """Delete a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_group abstractmethod

get_group(
    group_id: str,
    full_hierarchy: bool = False,
    query: dict | None = None,
) -> dict[str, Any]

Get group representation by ID.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_group(self, group_id: str, full_hierarchy: bool = False, query: dict | None = None) -> dict[str, Any]:
    """Get group representation by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_group_by_path abstractmethod

get_group_by_path(path: str) -> dict[str, Any]

Get group representation by path.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_group_by_path(self, path: str) -> dict[str, Any]:
    """Get group representation by path."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_group_children abstractmethod

get_group_children(
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]

Get child groups of a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_group_children(
    self,
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]:
    """Get child groups of a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_groups abstractmethod

get_groups(
    query: dict | None = None, full_hierarchy: bool = False
) -> list[dict[str, Any]]

Get all groups, optionally filtered by query.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_groups(self, query: dict | None = None, full_hierarchy: bool = False) -> list[dict[str, Any]]:
    """Get all groups, optionally filtered by query."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_subgroups abstractmethod

get_subgroups(
    group: dict, path: str
) -> dict[str, Any] | None

Get subgroups for a group at the given path.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_subgroups(self, group: dict, path: str) -> dict[str, Any] | None:
    """Get subgroups for a group at the given path."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.groups_count abstractmethod

groups_count(query: dict | None = None) -> dict[str, Any]

Get the number of groups matching the query.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def groups_count(self, query: dict | None = None) -> dict[str, Any]:
    """Get the number of groups matching the query."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.group_user_add abstractmethod

group_user_add(
    user_id: str, group_id: str
) -> dict[str, Any]

Add a user to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def group_user_add(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Add a user to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.group_user_remove abstractmethod

group_user_remove(
    user_id: str, group_id: str
) -> dict[str, Any]

Remove a user from a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def group_user_remove(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Remove a user from a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.group_set_permissions abstractmethod

group_set_permissions(
    group_id: str, enabled: bool = True
) -> dict[str, Any]

Enable or disable fine-grained permissions for a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def group_set_permissions(self, group_id: str, enabled: bool = True) -> dict[str, Any]:
    """Enable or disable fine-grained permissions for a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_group_members abstractmethod

get_group_members(
    group_id: str, query: dict | None = None
) -> list[dict[str, Any]]

Get members of a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_group_members(self, group_id: str, query: dict | None = None) -> list[dict[str, Any]]:
    """Get members of a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_group_client_roles abstractmethod

get_group_client_roles(
    group_id: str, client_id: str
) -> list[dict[str, Any]]

Get client roles assigned to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_group_client_roles(self, group_id: str, client_id: str) -> list[dict[str, Any]]:
    """Get client roles assigned to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_group_realm_roles abstractmethod

get_group_realm_roles(
    group_id: str, brief_representation: bool = True
) -> list[dict[str, Any]]

Get realm roles assigned to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_group_realm_roles(self, group_id: str, brief_representation: bool = True) -> list[dict[str, Any]]:
    """Get realm roles assigned to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.assign_group_client_roles abstractmethod

assign_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Assign client roles to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def assign_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Assign client roles to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.assign_group_realm_roles abstractmethod

assign_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Assign realm roles to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def assign_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Assign realm roles to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_group_client_roles abstractmethod

delete_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Remove client roles from a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def delete_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Remove client roles from a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_group_realm_roles abstractmethod

delete_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Remove realm roles from a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def delete_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Remove realm roles from a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_composite_client_roles_of_group abstractmethod

get_composite_client_roles_of_group(
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get composite client roles of a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_composite_client_roles_of_group(
    self,
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get composite client roles of a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_role_groups abstractmethod

get_client_role_groups(
    client_id: str, role_name: str, query: Any
) -> list[dict[str, Any]]

Get groups that have a specific client role.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_client_role_groups(self, client_id: str, role_name: str, query: Any) -> list[dict[str, Any]]:
    """Get groups that have a specific client role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_realm_role_groups abstractmethod

get_realm_role_groups(
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get groups that have a specific realm role.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
def get_realm_role_groups(
    self,
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get groups that have a specific realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_organizations abstractmethod

get_organizations(
    query: dict[str, Any] | None = None,
) -> list[KeycloakOrganizationType]

Fetch all organizations. Returns list of OrganizationRepresentation, filtered by query.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def get_organizations(self, query: dict[str, Any] | None = None) -> list[KeycloakOrganizationType]:
    """Fetch all organizations. Returns list of OrganizationRepresentation, filtered by query."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_organization abstractmethod

get_organization(
    organization_id: str,
) -> KeycloakOrganizationType

Get representation of the organization by ID.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def get_organization(self, organization_id: str) -> KeycloakOrganizationType:
    """Get representation of the organization by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_organization abstractmethod

create_organization(
    name: str, alias: str, **kwargs: Any
) -> str | None

Create a new organization. Name and alias must be unique. Returns org_id.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def create_organization(self, name: str, alias: str, **kwargs: Any) -> str | None:
    """Create a new organization. Name and alias must be unique. Returns org_id."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_organization abstractmethod

update_organization(
    organization_id: str, **kwargs: Any
) -> dict[str, Any]

Update an existing organization. Kwargs are organization attributes (e.g. name, alias).

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def update_organization(self, organization_id: str, **kwargs: Any) -> dict[str, Any]:
    """Update an existing organization. Kwargs are organization attributes (e.g. name, alias)."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_organization abstractmethod

delete_organization(organization_id: str) -> dict[str, Any]

Delete an organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def delete_organization(self, organization_id: str) -> dict[str, Any]:
    """Delete an organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_organization_idps abstractmethod

get_organization_idps(
    organization_id: str,
) -> list[dict[str, Any]]

Get IDPs by organization id.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def get_organization_idps(self, organization_id: str) -> list[dict[str, Any]]:
    """Get IDPs by organization id."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_user_organizations abstractmethod

get_user_organizations(
    user_id: str,
) -> list[KeycloakOrganizationType]

Get organizations by user id. Returns list of organizations the user is member of.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def get_user_organizations(self, user_id: str) -> list[KeycloakOrganizationType]:
    """Get organizations by user id. Returns list of organizations the user is member of."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_organization_members abstractmethod

get_organization_members(
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get members by organization id, optionally filtered by query parameters.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def get_organization_members(
    self,
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]:
    """Get members by organization id, optionally filtered by query parameters."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_organization_members_count abstractmethod

get_organization_members_count(organization_id: str) -> int

Get the number of members in the organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def get_organization_members_count(self, organization_id: str) -> int:
    """Get the number of members in the organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.organization_user_add abstractmethod

organization_user_add(
    user_id: str, organization_id: str
) -> bytes

Add a user to an organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def organization_user_add(self, user_id: str, organization_id: str) -> bytes:
    """Add a user to an organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.organization_user_remove abstractmethod

organization_user_remove(
    user_id: str, organization_id: str
) -> dict[str, Any]

Remove a user from an organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
def organization_user_remove(self, user_id: str, organization_id: str) -> dict[str, Any]:
    """Remove a user from an organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_realm abstractmethod

create_realm(
    realm_name: str, skip_exists: bool = True, **kwargs: Any
) -> dict[str, Any] | None

Create a new Keycloak realm.

Source code in archipy/adapters/keycloak/port_mixins/realms.py
@abstractmethod
def create_realm(self, realm_name: str, skip_exists: bool = True, **kwargs: Any) -> dict[str, Any] | None:
    """Create a new Keycloak realm."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_realm abstractmethod

get_realm(realm_name: str) -> dict[str, Any] | None

Get realm details by realm name.

Source code in archipy/adapters/keycloak/port_mixins/realms.py
@abstractmethod
def get_realm(self, realm_name: str) -> dict[str, Any] | None:
    """Get realm details by realm name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_realm abstractmethod

update_realm(
    realm_name: str, **kwargs: Any
) -> dict[str, Any] | None

Update a realm.

Kwargs are RealmRepresentation top-level attributes (e.g. displayName, organizationsEnabled).

Source code in archipy/adapters/keycloak/port_mixins/realms.py
@abstractmethod
def update_realm(self, realm_name: str, **kwargs: Any) -> dict[str, Any] | None:
    """Update a realm.

    Kwargs are RealmRepresentation top-level attributes (e.g. displayName, organizationsEnabled).
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_id abstractmethod

get_client_id(client_name: str) -> str

Get client ID by client name.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
def get_client_id(self, client_name: str) -> str:
    """Get client ID by client name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_secret abstractmethod

get_client_secret(client_id: str) -> str

Get client secret.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
def get_client_secret(self, client_id: str) -> str:
    """Get client secret."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_service_account_id abstractmethod

get_service_account_id() -> str

Get service account user ID for the current client.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
def get_service_account_id(self) -> str:
    """Get service account user ID for the current client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client abstractmethod

create_client(
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None

Create a new client in the specified realm.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
def create_client(
    self,
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None:
    """Create a new client in the specified realm."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_user_roles abstractmethod

get_user_roles(user_id: str) -> list[KeycloakRoleType]

Get roles assigned to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def get_user_roles(self, user_id: str) -> list[KeycloakRoleType]:
    """Get roles assigned to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_roles_for_user abstractmethod

get_client_roles_for_user(
    user_id: str, client_id: str
) -> list[KeycloakRoleType]

Get client-specific roles assigned to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def get_client_roles_for_user(self, user_id: str, client_id: str) -> list[KeycloakRoleType]:
    """Get client-specific roles assigned to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.has_role abstractmethod

has_role(token: str, role_name: str) -> bool

Check if a user has a specific role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def has_role(self, token: str, role_name: str) -> bool:
    """Check if a user has a specific role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.has_any_of_roles abstractmethod

has_any_of_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has any of the specified roles.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def has_any_of_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has any of the specified roles."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.has_all_roles abstractmethod

has_all_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has all of the specified roles.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def has_all_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has all of the specified roles."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.assign_realm_role abstractmethod

assign_realm_role(user_id: str, role_name: str) -> None

Assign a realm role to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def assign_realm_role(self, user_id: str, role_name: str) -> None:
    """Assign a realm role to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.remove_realm_role abstractmethod

remove_realm_role(user_id: str, role_name: str) -> None

Remove a realm role from a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def remove_realm_role(self, user_id: str, role_name: str) -> None:
    """Remove a realm role from a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.assign_client_role abstractmethod

assign_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Assign a client-specific role to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def assign_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Assign a client-specific role to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.remove_client_role abstractmethod

remove_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Remove a client-specific role from a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def remove_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Remove a client-specific role from a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_realm_role abstractmethod

get_realm_role(role_name: str) -> dict[str, Any]

Get realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def get_realm_role(self, role_name: str) -> dict[str, Any]:
    """Get realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_realm_roles abstractmethod

get_realm_roles() -> list[dict[str, Any]]

Get all realm roles.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def get_realm_roles(self) -> list[dict[str, Any]]:
    """Get all realm roles."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_realm_role abstractmethod

create_realm_role(
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def create_realm_role(
    self,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_realm_role abstractmethod

delete_realm_role(role_name: str) -> None

Delete a realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def delete_realm_role(self, role_name: str) -> None:
    """Delete a realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_client_role abstractmethod

create_client_role(
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new client role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def create_client_role(
    self,
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new client role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_realm_roles_to_composite abstractmethod

add_realm_roles_to_composite(
    composite_role_name: str, child_role_names: list[str]
) -> None

Add realm roles to a composite role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def add_realm_roles_to_composite(self, composite_role_name: str, child_role_names: list[str]) -> None:
    """Add realm roles to a composite role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.add_client_roles_to_composite abstractmethod

add_client_roles_to_composite(
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None

Add client roles to a composite role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def add_client_roles_to_composite(
    self,
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None:
    """Add client roles to a composite role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_composite_realm_roles abstractmethod

get_composite_realm_roles(
    role_name: str,
) -> list[dict[str, Any]] | None

Get composite roles for a realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
def get_composite_realm_roles(self, role_name: str) -> list[dict[str, Any]] | None:
    """Get composite roles for a realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_user_by_id abstractmethod

get_user_by_id(user_id: str) -> KeycloakUserType | None

Get user details by user ID.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def get_user_by_id(self, user_id: str) -> KeycloakUserType | None:
    """Get user details by user ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_user_by_username abstractmethod

get_user_by_username(
    username: str,
) -> KeycloakUserType | None

Get user details by username.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def get_user_by_username(self, username: str) -> KeycloakUserType | None:
    """Get user details by username."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_user_by_email abstractmethod

get_user_by_email(email: str) -> KeycloakUserType | None

Get user details by email.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def get_user_by_email(self, email: str) -> KeycloakUserType | None:
    """Get user details by email."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.create_user abstractmethod

create_user(user_data: dict[str, Any]) -> str | None

Create a new user in Keycloak.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def create_user(self, user_data: dict[str, Any]) -> str | None:
    """Create a new user in Keycloak."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.update_user abstractmethod

update_user(
    user_id: str, user_data: dict[str, Any]
) -> None

Update user details.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def update_user(self, user_id: str, user_data: dict[str, Any]) -> None:
    """Update user details."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.reset_password abstractmethod

reset_password(
    user_id: str, password: str, temporary: bool = False
) -> None

Reset a user's password.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def reset_password(self, user_id: str, password: str, temporary: bool = False) -> None:
    """Reset a user's password."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.search_users abstractmethod

search_users(
    query: str, max_results: int = 100
) -> list[KeycloakUserType]

Search for users by username, email, or name.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def search_users(self, query: str, max_results: int = 100) -> list[KeycloakUserType]:
    """Search for users by username, email, or name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.clear_user_sessions abstractmethod

clear_user_sessions(user_id: str) -> None

Clear all sessions for a user.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def clear_user_sessions(self, user_id: str) -> None:
    """Clear all sessions for a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.delete_user abstractmethod

delete_user(user_id: str) -> None

Delete a user from Keycloak by their ID.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
def delete_user(self, user_id: str) -> None:
    """Delete a user from Keycloak by their ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_token abstractmethod

get_token(
    username: str, password: str
) -> KeycloakTokenType | None

Get a user token by username and password.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_token(self, username: str, password: str) -> KeycloakTokenType | None:
    """Get a user token by username and password."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.refresh_token abstractmethod

refresh_token(
    refresh_token: str,
) -> KeycloakTokenType | None

Refresh an existing token using a refresh token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def refresh_token(self, refresh_token: str) -> KeycloakTokenType | None:
    """Refresh an existing token using a refresh token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.validate_token abstractmethod

validate_token(token: str) -> bool

Validate if a token is still valid.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def validate_token(self, token: str) -> bool:
    """Validate if a token is still valid."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_userinfo abstractmethod

get_userinfo(token: str) -> KeycloakUserType | None

Get user information from a token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_userinfo(self, token: str) -> KeycloakUserType | None:
    """Get user information from a token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_token_info abstractmethod

get_token_info(token: str) -> dict[str, Any] | None

Decode token to get its claims.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_token_info(self, token: str) -> dict[str, Any] | None:
    """Decode token to get its claims."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.introspect_token abstractmethod

introspect_token(token: str) -> dict[str, Any] | None

Introspect token to get detailed information about it.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def introspect_token(self, token: str) -> dict[str, Any] | None:
    """Introspect token to get detailed information about it."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_client_credentials_token abstractmethod

get_client_credentials_token() -> KeycloakTokenType | None

Get token using client credentials.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_client_credentials_token(self) -> KeycloakTokenType | None:
    """Get token using client credentials."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.logout abstractmethod

logout(refresh_token: str) -> None

Logout user by invalidating their refresh token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def logout(self, refresh_token: str) -> None:
    """Logout user by invalidating their refresh token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_public_key abstractmethod

get_public_key() -> PublicKeyType

Get the public key used to verify tokens.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_public_key(self) -> PublicKeyType:
    """Get the public key used to verify tokens."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_well_known_config abstractmethod

get_well_known_config() -> dict[str, Any]

Get the well-known OpenID configuration.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_well_known_config(self) -> dict[str, Any]:
    """Get the well-known OpenID configuration."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_certs abstractmethod

get_certs() -> dict[str, Any]

Get the JWT verification certificates.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_certs(self) -> dict[str, Any]:
    """Get the JWT verification certificates."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.get_token_from_code abstractmethod

get_token_from_code(
    code: str, redirect_uri: str
) -> KeycloakTokenType | None

Exchange authorization code for token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def get_token_from_code(self, code: str, redirect_uri: str) -> KeycloakTokenType | None:
    """Exchange authorization code for token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.check_permissions abstractmethod

check_permissions(
    token: str, resource: str, scope: str
) -> bool

Check if a user has permission to access a resource with the specified scope.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def check_permissions(self, token: str, resource: str, scope: str) -> bool:
    """Check if a user has permission to access a resource with the specified scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.KeycloakPort.check_permissions_batch abstractmethod

check_permissions_batch(
    token: str, permissions: tuple[tuple[str, str], ...]
) -> frozenset[tuple[str, str]]

Return the subset of (resource, scope) pairs the token is authorized for in one UMA call.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
def check_permissions_batch(
    self,
    token: str,
    permissions: tuple[tuple[str, str], ...],
) -> frozenset[tuple[str, str]]:
    """Return the subset of (resource, scope) pairs the token is authorized for in one UMA call."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort

Bases: AsyncKeycloakAuthPort, AsyncKeycloakUsersPort, AsyncKeycloakRolesPort, AsyncKeycloakClientsPort, AsyncKeycloakRealmsPort, AsyncKeycloakOrganizationsPort, AsyncKeycloakGroupsPort, AsyncKeycloakAuthFlowsPort, AsyncKeycloakClientScopesPort, AsyncKeycloakAuthzPort, AsyncKeycloakUmaPort, AsyncKeycloakComponentsPort

Asynchronous interface for Keycloak operations providing a standardized access pattern.

This interface defines the contract for async Keycloak adapters, ensuring consistent implementation of Keycloak operations across different adapters. It covers essential functionality including authentication, user management, and role management.

Source code in archipy/adapters/keycloak/ports.py
class AsyncKeycloakPort(
    AsyncKeycloakAuthPort,
    AsyncKeycloakUsersPort,
    AsyncKeycloakRolesPort,
    AsyncKeycloakClientsPort,
    AsyncKeycloakRealmsPort,
    AsyncKeycloakOrganizationsPort,
    AsyncKeycloakGroupsPort,
    AsyncKeycloakAuthFlowsPort,
    AsyncKeycloakClientScopesPort,
    AsyncKeycloakAuthzPort,
    AsyncKeycloakUmaPort,
    AsyncKeycloakComponentsPort,
):
    """Asynchronous interface for Keycloak operations providing a standardized access pattern.

    This interface defines the contract for async Keycloak adapters, ensuring consistent
    implementation of Keycloak operations across different adapters. It covers essential
    functionality including authentication, user management, and role management.
    """

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_component abstractmethod async

create_component(payload: dict[str, Any]) -> str

Create a Keycloak component.

Parameters:

Name Type Description Default
payload dict[str, Any]

Component representation.

required

Returns:

Type Description
str

Created component ID.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
async def create_component(self, payload: dict[str, Any]) -> str:
    """Create a Keycloak component.

    Args:
        payload: Component representation.

    Returns:
        Created component ID.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_component abstractmethod async

get_component(component_id: str) -> dict[str, Any]

Get a component by ID.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Component representation.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
async def get_component(self, component_id: str) -> dict[str, Any]:
    """Get a component by ID.

    Args:
        component_id: Component identifier.

    Returns:
        Component representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_components abstractmethod async

get_components(
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get components, optionally filtered by query.

Parameters:

Name Type Description Default
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

Matching component representations.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
async def get_components(self, query: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Get components, optionally filtered by query.

    Args:
        query: Optional filter query parameters.

    Returns:
        Matching component representations.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_component abstractmethod async

update_component(
    component_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required
payload dict[str, Any]

Updated component representation.

required

Returns:

Type Description
dict[str, Any]

Update response payload.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
async def update_component(self, component_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a component.

    Args:
        component_id: Component identifier.
        payload: Updated component representation.

    Returns:
        Update response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_component abstractmethod async

delete_component(component_id: str) -> dict[str, Any]

Delete a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/port_mixins/components.py
@abstractmethod
async def delete_component(self, component_id: str) -> dict[str, Any]:
    """Delete a component.

    Args:
        component_id: Component identifier.

    Returns:
        Deletion response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.resource_set_create abstractmethod async

resource_set_create(
    payload: dict[str, Any],
) -> dict[str, Any]

Create a UMA resource set.

Parameters:

Name Type Description Default
payload dict[str, Any]

Resource set representation.

required

Returns:

Type Description
dict[str, Any]

Created resource set representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def resource_set_create(self, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA resource set.

    Args:
        payload: Resource set representation.

    Returns:
        Created resource set representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.resource_set_read abstractmethod async

resource_set_read(resource_id: str) -> dict[str, Any]

Read a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Resource set representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def resource_set_read(self, resource_id: str) -> dict[str, Any]:
    """Read a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Resource set representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.resource_set_update abstractmethod async

resource_set_update(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required
payload dict[str, Any]

Updated resource set representation.

required

Returns:

Type Description
dict[str, Any]

Updated resource set representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def resource_set_update(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a UMA resource set.

    Args:
        resource_id: Resource set identifier.
        payload: Updated resource set representation.

    Returns:
        Updated resource set representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.resource_set_delete abstractmethod async

resource_set_delete(resource_id: str) -> dict[str, Any]

Delete a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def resource_set_delete(self, resource_id: str) -> dict[str, Any]:
    """Delete a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Deletion response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.resource_set_list abstractmethod async

resource_set_list() -> list[dict[str, Any]]

List all UMA resource sets.

Returns:

Type Description
list[dict[str, Any]]

List of resource set representations.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def resource_set_list(self) -> list[dict[str, Any]]:
    """List all UMA resource sets.

    Returns:
        List of resource set representations.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.resource_set_list_ids abstractmethod async

resource_set_list_ids(
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

List UMA resource set IDs with optional filters.

Parameters:

Name Type Description Default
name str

Filter by resource name.

''
exact_name bool

Require exact name match when True.

False
uri str

Filter by resource URI.

''
owner str

Filter by owner.

''
resource_type str

Filter by resource type.

''
scope str

Filter by scope.

''
matchingUri bool

Match URI patterns when True.

False
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching resource set IDs / summaries.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def resource_set_list_ids(
    self,
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """List UMA resource set IDs with optional filters.

    Args:
        name: Filter by resource name.
        exact_name: Require exact name match when True.
        uri: Filter by resource URI.
        owner: Filter by owner.
        resource_type: Filter by resource type.
        scope: Filter by scope.
        matchingUri: Match URI patterns when True.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching resource set IDs / summaries.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.policy_resource_create abstractmethod async

policy_resource_create(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Create a UMA policy for a resource.

Parameters:

Name Type Description Default
resource_id str

Resource identifier.

required
payload dict[str, Any]

Policy representation.

required

Returns:

Type Description
dict[str, Any]

Created policy representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def policy_resource_create(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA policy for a resource.

    Args:
        resource_id: Resource identifier.
        payload: Policy representation.

    Returns:
        Created policy representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.policy_update abstractmethod async

policy_update(
    policy_id: str, payload: dict[str, Any]
) -> bytes

Update a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required
payload dict[str, Any]

Updated policy representation.

required

Returns:

Type Description
bytes

Raw update response bytes.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def policy_update(self, policy_id: str, payload: dict[str, Any]) -> bytes:
    """Update a UMA policy.

    Args:
        policy_id: Policy identifier.
        payload: Updated policy representation.

    Returns:
        Raw update response bytes.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.policy_delete abstractmethod async

policy_delete(policy_id: str) -> dict[str, Any]

Delete a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def policy_delete(self, policy_id: str) -> dict[str, Any]:
    """Delete a UMA policy.

    Args:
        policy_id: Policy identifier.

    Returns:
        Deletion response payload.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.policy_query abstractmethod async

policy_query(
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

Query UMA policies.

Parameters:

Name Type Description Default
resource str

Filter by resource.

''
name str

Filter by policy name.

''
scope str

Filter by scope.

''
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching policy representations.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def policy_query(
    self,
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """Query UMA policies.

    Args:
        resource: Filter by resource.
        name: Filter by policy name.
        scope: Filter by scope.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching policy representations.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.permission_ticket_create abstractmethod async

permission_ticket_create(
    permissions: Iterable[UMAPermission],
) -> dict[str, Any]

Create a UMA permission ticket.

Parameters:

Name Type Description Default
permissions Iterable[UMAPermission]

Permissions to include in the ticket.

required

Returns:

Type Description
dict[str, Any]

Permission ticket representation.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def permission_ticket_create(self, permissions: Iterable[UMAPermission]) -> dict[str, Any]:
    """Create a UMA permission ticket.

    Args:
        permissions: Permissions to include in the ticket.

    Returns:
        Permission ticket representation.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.permissions_check abstractmethod async

permissions_check(
    token: str,
    permissions: Iterable[UMAPermission],
    **extra_payload: Any,
) -> bool

Check UMA permissions for a token.

Parameters:

Name Type Description Default
token str

Access token to evaluate.

required
permissions Iterable[UMAPermission]

Permissions to check.

required
**extra_payload Any

Extra fields forwarded to the UMA endpoint.

{}

Returns:

Type Description
bool

True when all requested permissions are granted.

Source code in archipy/adapters/keycloak/port_mixins/uma.py
@abstractmethod
async def permissions_check(self, token: str, permissions: Iterable[UMAPermission], **extra_payload: Any) -> bool:
    """Check UMA permissions for a token.

    Args:
        token: Access token to evaluate.
        permissions: Permissions to check.
        **extra_payload: Extra fields forwarded to the UMA endpoint.

    Returns:
        True when all requested permissions are granted.
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_resource abstractmethod async

create_client_authz_resource(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization resource for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_resource(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create an authorization resource for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_resources abstractmethod async

get_client_authz_resources(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization resources for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_resources(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization resources for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_resource abstractmethod async

get_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Get a single authorization resource.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Get a single authorization resource."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_client_authz_resource abstractmethod async

update_client_authz_resource(
    client_id: str, resource_id: str, payload: dict
) -> dict[str, Any]

Update an authorization resource.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def update_client_authz_resource(self, client_id: str, resource_id: str, payload: dict) -> dict[str, Any]:
    """Update an authorization resource."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_client_authz_resource abstractmethod async

delete_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Delete an authorization resource.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def delete_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Delete an authorization resource."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_scopes abstractmethod async

create_client_authz_scopes(
    client_id: str, payload: dict
) -> dict[str, Any]

Create authorization scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_scopes(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Create authorization scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_scopes abstractmethod async

get_client_authz_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_role_based_policy abstractmethod async

create_client_authz_role_based_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a role-based authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_role_based_policy(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a role-based authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_client_policy abstractmethod async

create_client_authz_client_policy(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a client-based authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_client_policy(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a client-based authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_policy abstractmethod async

create_client_authz_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_policy(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create an authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_policies abstractmethod async

get_client_authz_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization policies for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization policies for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_policy abstractmethod async

get_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Get a single authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Get a single authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_client_authz_policy abstractmethod async

delete_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Delete an authorization policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def delete_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Delete an authorization policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_resource_based_permission abstractmethod async

create_client_authz_resource_based_permission(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a resource-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_resource_based_permission(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a resource-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_authz_scope_permission abstractmethod async

create_client_authz_scope_permission(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a scope-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def create_client_authz_scope_permission(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a scope-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_permissions abstractmethod async

get_client_authz_permissions(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization permissions for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_permissions(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization permissions for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_scope_permission abstractmethod async

get_client_authz_scope_permission(
    client_id: str, scope_id: str
) -> dict[str, Any]

Get a scope-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_scope_permission(self, client_id: str, scope_id: str) -> dict[str, Any]:
    """Get a scope-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_client_authz_scope_permission abstractmethod async

update_client_authz_scope_permission(
    payload: dict, client_id: str, scope_id: str
) -> bytes

Update a scope-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def update_client_authz_scope_permission(self, payload: dict, client_id: str, scope_id: str) -> bytes:
    """Update a scope-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_client_authz_resource_permission abstractmethod async

update_client_authz_resource_permission(
    payload: dict, client_id: str, resource_id: str
) -> bytes

Update a resource-based permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def update_client_authz_resource_permission(self, payload: dict, client_id: str, resource_id: str) -> bytes:
    """Update a resource-based permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_permission_associated_policies abstractmethod async

get_client_authz_permission_associated_policies(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get policies associated with a permission.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_permission_associated_policies(
    self,
    client_id: str,
    policy_id: str,
) -> list[dict[str, Any]]:
    """Get policies associated with a permission."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_settings abstractmethod async

get_client_authz_settings(client_id: str) -> dict[str, Any]

Get authorization settings for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_settings(self, client_id: str) -> dict[str, Any]:
    """Get authorization settings for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_client_policies abstractmethod async

get_client_authz_client_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get client policies for authorization.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_client_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get client policies for authorization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_policy_resources abstractmethod async

get_client_authz_policy_resources(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get resources associated with a policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_policy_resources(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get resources associated with a policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_authz_policy_scopes abstractmethod async

get_client_authz_policy_scopes(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get scopes associated with a policy.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def get_client_authz_policy_scopes(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get scopes associated with a policy."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.import_client_authz_config abstractmethod async

import_client_authz_config(
    client_id: str, payload: dict
) -> dict[str, Any]

Import authorization configuration for a client.

Source code in archipy/adapters/keycloak/port_mixins/authz.py
@abstractmethod
async def import_client_authz_config(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Import authorization configuration for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_scopes abstractmethod async

get_client_scopes() -> list[dict[str, Any]]

Get all client scopes.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get all client scopes."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_scope abstractmethod async

get_client_scope(client_scope_id: str) -> dict[str, Any]

Get a client scope by ID.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Get a client scope by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_scope_by_name abstractmethod async

get_client_scope_by_name(
    client_scope_name: str,
) -> dict[str, Any] | None

Get a client scope by name.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_client_scope_by_name(self, client_scope_name: str) -> dict[str, Any] | None:
    """Get a client scope by name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_scope abstractmethod async

create_client_scope(
    payload: dict, skip_exists: bool = False
) -> str

Create a new client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def create_client_scope(self, payload: dict, skip_exists: bool = False) -> str:
    """Create a new client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_client_scope abstractmethod async

update_client_scope(
    client_scope_id: str, payload: dict
) -> dict[str, Any]

Update a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def update_client_scope(self, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Update a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_client_scope abstractmethod async

delete_client_scope(client_scope_id: str) -> dict[str, Any]

Delete a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def delete_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Delete a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_mapper_to_client_scope abstractmethod async

add_mapper_to_client_scope(
    client_scope_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def add_mapper_to_client_scope(self, client_scope_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_mappers_from_client_scope abstractmethod async

get_mappers_from_client_scope(
    client_scope_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_mappers_from_client_scope(self, client_scope_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_mapper_in_client_scope abstractmethod async

update_mapper_in_client_scope(
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]

Update a protocol mapper in a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def update_mapper_in_client_scope(
    self,
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Update a protocol mapper in a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_mapper_from_client_scope abstractmethod async

delete_mapper_from_client_scope(
    client_scope_id: str, protocol_mapper_id: str
) -> dict[str, Any]

Delete a protocol mapper from a client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def delete_mapper_from_client_scope(self, client_scope_id: str, protocol_mapper_id: str) -> dict[str, Any]:
    """Delete a protocol mapper from a client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_mapper_to_client abstractmethod async

add_mapper_to_client(
    client_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def add_mapper_to_client(self, client_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_mappers_from_client abstractmethod async

get_mappers_from_client(
    client_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_mappers_from_client(self, client_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_client_mapper abstractmethod async

update_client_mapper(
    client_id: str, mapper_id: str, payload: dict
) -> dict[str, Any]

Update a protocol mapper on a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def update_client_mapper(self, client_id: str, mapper_id: str, payload: dict) -> dict[str, Any]:
    """Update a protocol mapper on a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.remove_client_mapper abstractmethod async

remove_client_mapper(
    client_id: str, client_mapper_id: str
) -> dict[str, Any]

Remove a protocol mapper from a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def remove_client_mapper(self, client_id: str, client_mapper_id: str) -> dict[str, Any]:
    """Remove a protocol mapper from a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_default_client_scopes abstractmethod async

get_client_default_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get default client scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_client_default_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get default client scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_client_default_client_scope abstractmethod async

add_client_default_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add a default client scope to a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def add_client_default_client_scope(
    self,
    client_id: str,
    client_scope_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Add a default client scope to a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_client_default_client_scope abstractmethod async

delete_client_default_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove a default client scope from a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def delete_client_default_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove a default client scope from a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_optional_client_scopes abstractmethod async

get_client_optional_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get optional client scopes for a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_client_optional_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get optional client scopes for a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_client_optional_client_scope abstractmethod async

add_client_optional_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add an optional client scope to a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def add_client_optional_client_scope(
    self,
    client_id: str,
    client_scope_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Add an optional client scope to a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_client_optional_client_scope abstractmethod async

delete_client_optional_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove an optional client scope from a client.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def delete_client_optional_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove an optional client scope from a client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_default_default_client_scopes abstractmethod async

get_default_default_client_scopes() -> list[dict[str, Any]]

Get realm default client scopes.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_default_default_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm default client scopes."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_default_default_client_scope abstractmethod async

add_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def add_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_default_default_client_scope abstractmethod async

delete_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def delete_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_default_optional_client_scopes abstractmethod async

get_default_optional_client_scopes() -> list[
    dict[str, Any]
]

Get realm optional default client scopes.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def get_default_optional_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm optional default client scopes."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_default_optional_client_scope abstractmethod async

add_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm optional default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def add_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm optional default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_default_optional_client_scope abstractmethod async

delete_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm optional default client scope.

Source code in archipy/adapters/keycloak/port_mixins/client_scopes.py
@abstractmethod
async def delete_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm optional default client scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_authentication_flow abstractmethod async

create_authentication_flow(
    payload: dict, skip_exists: bool = False
) -> bytes

Create a new authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def create_authentication_flow(self, payload: dict, skip_exists: bool = False) -> bytes:
    """Create a new authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.copy_authentication_flow abstractmethod async

copy_authentication_flow(
    payload: dict, flow_alias: str
) -> bytes

Copy an existing authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def copy_authentication_flow(self, payload: dict, flow_alias: str) -> bytes:
    """Copy an existing authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authentication_flows abstractmethod async

get_authentication_flows() -> list[dict[str, Any]]

Get all authentication flows.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authentication_flows(
    self,
) -> list[dict[str, Any]]:
    """Get all authentication flows."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authentication_flow_for_id abstractmethod async

get_authentication_flow_for_id(
    flow_id: str,
) -> dict[str, Any]

Get authentication flow by ID.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authentication_flow_for_id(self, flow_id: str) -> dict[str, Any]:
    """Get authentication flow by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_authentication_flow abstractmethod async

delete_authentication_flow(flow_id: str) -> dict[str, Any]

Delete an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def delete_authentication_flow(self, flow_id: str) -> dict[str, Any]:
    """Delete an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authentication_flow_executions abstractmethod async

get_authentication_flow_executions(
    flow_alias: str,
) -> list[dict[str, Any]]

Get executions for an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authentication_flow_executions(self, flow_alias: str) -> list[dict[str, Any]]:
    """Get executions for an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authentication_flow_execution abstractmethod async

get_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Get a single authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Get a single authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_authentication_flow_execution abstractmethod async

create_authentication_flow_execution(
    payload: dict, flow_alias: str
) -> bytes

Create an execution in an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def create_authentication_flow_execution(self, payload: dict, flow_alias: str) -> bytes:
    """Create an execution in an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_authentication_flow_executions abstractmethod async

update_authentication_flow_executions(
    payload: dict, flow_alias: str
) -> dict[str, Any]

Update executions in an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def update_authentication_flow_executions(self, payload: dict, flow_alias: str) -> dict[str, Any]:
    """Update executions in an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_authentication_flow_subflow abstractmethod async

create_authentication_flow_subflow(
    payload: dict,
    flow_alias: str,
    skip_exists: bool = False,
) -> bytes

Create a subflow in an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def create_authentication_flow_subflow(
    self,
    payload: dict,
    flow_alias: str,
    skip_exists: bool = False,
) -> bytes:
    """Create a subflow in an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_authentication_flow_execution abstractmethod async

delete_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Delete an authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def delete_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Delete an authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.change_execution_priority abstractmethod async

change_execution_priority(
    execution_id: str, diff: int
) -> None

Change priority of an authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def change_execution_priority(self, execution_id: str, diff: int) -> None:
    """Change priority of an authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_authentication_flow abstractmethod async

update_authentication_flow(
    flow_id: str, payload: dict
) -> dict[str, Any]

Update an authentication flow.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def update_authentication_flow(self, flow_id: str, payload: dict) -> dict[str, Any]:
    """Update an authentication flow."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authenticator_providers abstractmethod async

get_authenticator_providers() -> list[dict[str, Any]]

Get available authenticator providers.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authenticator_providers(
    self,
) -> list[dict[str, Any]]:
    """Get available authenticator providers."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authenticator_provider_config_description abstractmethod async

get_authenticator_provider_config_description(
    provider_id: str,
) -> dict[str, Any]

Get config description for an authenticator provider.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authenticator_provider_config_description(self, provider_id: str) -> dict[str, Any]:
    """Get config description for an authenticator provider."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_authenticator_config abstractmethod async

get_authenticator_config(config_id: str) -> dict[str, Any]

Get authenticator configuration by ID.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def get_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Get authenticator configuration by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_authenticator_config abstractmethod async

update_authenticator_config(
    payload: dict, config_id: str
) -> dict[str, Any]

Update authenticator configuration.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def update_authenticator_config(self, payload: dict, config_id: str) -> dict[str, Any]:
    """Update authenticator configuration."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_authenticator_config abstractmethod async

delete_authenticator_config(
    config_id: str,
) -> dict[str, Any]

Delete authenticator configuration.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def delete_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Delete authenticator configuration."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_execution_config abstractmethod async

create_execution_config(
    execution_id: str, payload: dict
) -> bytes

Create configuration for an authentication flow execution.

Source code in archipy/adapters/keycloak/port_mixins/auth_flows.py
@abstractmethod
async def create_execution_config(self, execution_id: str, payload: dict) -> bytes:
    """Create configuration for an authentication flow execution."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_group abstractmethod async

create_group(
    payload: dict,
    parent: str | None = None,
    skip_exists: bool = False,
) -> str | None

Create a new group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
# Group Operations
@abstractmethod
async def create_group(self, payload: dict, parent: str | None = None, skip_exists: bool = False) -> str | None:
    """Create a new group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_group abstractmethod async

update_group(
    group_id: str, payload: dict
) -> dict[str, Any]

Update a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def update_group(self, group_id: str, payload: dict) -> dict[str, Any]:
    """Update a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_group abstractmethod async

delete_group(group_id: str) -> dict[str, Any]

Delete a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def delete_group(self, group_id: str) -> dict[str, Any]:
    """Delete a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_group abstractmethod async

get_group(
    group_id: str,
    full_hierarchy: bool = False,
    query: dict | None = None,
) -> dict[str, Any]

Get group representation by ID.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_group(self, group_id: str, full_hierarchy: bool = False, query: dict | None = None) -> dict[str, Any]:
    """Get group representation by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_group_by_path abstractmethod async

get_group_by_path(path: str) -> dict[str, Any]

Get group representation by path.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_group_by_path(self, path: str) -> dict[str, Any]:
    """Get group representation by path."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_group_children abstractmethod async

get_group_children(
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]

Get child groups of a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_group_children(
    self,
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]:
    """Get child groups of a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_groups abstractmethod async

get_groups(
    query: dict | None = None, full_hierarchy: bool = False
) -> list[dict[str, Any]]

Get all groups, optionally filtered by query.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_groups(self, query: dict | None = None, full_hierarchy: bool = False) -> list[dict[str, Any]]:
    """Get all groups, optionally filtered by query."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_subgroups abstractmethod async

get_subgroups(
    group: dict, path: str
) -> dict[str, Any] | None

Get subgroups for a group at the given path.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_subgroups(self, group: dict, path: str) -> dict[str, Any] | None:
    """Get subgroups for a group at the given path."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.groups_count abstractmethod async

groups_count(query: dict | None = None) -> dict[str, Any]

Get the number of groups matching the query.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def groups_count(self, query: dict | None = None) -> dict[str, Any]:
    """Get the number of groups matching the query."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.group_user_add abstractmethod async

group_user_add(
    user_id: str, group_id: str
) -> dict[str, Any]

Add a user to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def group_user_add(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Add a user to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.group_user_remove abstractmethod async

group_user_remove(
    user_id: str, group_id: str
) -> dict[str, Any]

Remove a user from a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def group_user_remove(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Remove a user from a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.group_set_permissions abstractmethod async

group_set_permissions(
    group_id: str, enabled: bool = True
) -> dict[str, Any]

Enable or disable fine-grained permissions for a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def group_set_permissions(self, group_id: str, enabled: bool = True) -> dict[str, Any]:
    """Enable or disable fine-grained permissions for a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_group_members abstractmethod async

get_group_members(
    group_id: str, query: dict | None = None
) -> list[dict[str, Any]]

Get members of a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_group_members(self, group_id: str, query: dict | None = None) -> list[dict[str, Any]]:
    """Get members of a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_group_client_roles abstractmethod async

get_group_client_roles(
    group_id: str, client_id: str
) -> list[dict[str, Any]]

Get client roles assigned to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_group_client_roles(self, group_id: str, client_id: str) -> list[dict[str, Any]]:
    """Get client roles assigned to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_group_realm_roles abstractmethod async

get_group_realm_roles(
    group_id: str, brief_representation: bool = True
) -> list[dict[str, Any]]

Get realm roles assigned to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_group_realm_roles(self, group_id: str, brief_representation: bool = True) -> list[dict[str, Any]]:
    """Get realm roles assigned to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.assign_group_client_roles abstractmethod async

assign_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Assign client roles to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def assign_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Assign client roles to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.assign_group_realm_roles abstractmethod async

assign_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Assign realm roles to a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def assign_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Assign realm roles to a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_group_client_roles abstractmethod async

delete_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Remove client roles from a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def delete_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Remove client roles from a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_group_realm_roles abstractmethod async

delete_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Remove realm roles from a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def delete_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Remove realm roles from a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_composite_client_roles_of_group abstractmethod async

get_composite_client_roles_of_group(
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get composite client roles of a group.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_composite_client_roles_of_group(
    self,
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get composite client roles of a group."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_role_groups abstractmethod async

get_client_role_groups(
    client_id: str, role_name: str, query: Any
) -> list[dict[str, Any]]

Get groups that have a specific client role.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_client_role_groups(self, client_id: str, role_name: str, query: Any) -> list[dict[str, Any]]:
    """Get groups that have a specific client role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_realm_role_groups abstractmethod async

get_realm_role_groups(
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get groups that have a specific realm role.

Source code in archipy/adapters/keycloak/port_mixins/groups.py
@abstractmethod
async def get_realm_role_groups(
    self,
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get groups that have a specific realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_organizations abstractmethod async

get_organizations(
    query: dict[str, Any] | None = None,
) -> list[KeycloakOrganizationType]

Fetch all organizations. Returns list of OrganizationRepresentation, filtered by query.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def get_organizations(self, query: dict[str, Any] | None = None) -> list[KeycloakOrganizationType]:
    """Fetch all organizations. Returns list of OrganizationRepresentation, filtered by query."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_organization abstractmethod async

get_organization(
    organization_id: str,
) -> KeycloakOrganizationType

Get representation of the organization by ID.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def get_organization(self, organization_id: str) -> KeycloakOrganizationType:
    """Get representation of the organization by ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_organization abstractmethod async

create_organization(
    name: str, alias: str, **kwargs: Any
) -> str | None

Create a new organization. Name and alias must be unique. Returns org_id.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def create_organization(self, name: str, alias: str, **kwargs: Any) -> str | None:
    """Create a new organization. Name and alias must be unique. Returns org_id."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_organization abstractmethod async

update_organization(
    organization_id: str, **kwargs: Any
) -> dict[str, Any]

Update an existing organization. Kwargs are organization attributes (e.g. name, alias).

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def update_organization(self, organization_id: str, **kwargs: Any) -> dict[str, Any]:
    """Update an existing organization. Kwargs are organization attributes (e.g. name, alias)."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_organization abstractmethod async

delete_organization(organization_id: str) -> dict[str, Any]

Delete an organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def delete_organization(self, organization_id: str) -> dict[str, Any]:
    """Delete an organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_organization_idps abstractmethod async

get_organization_idps(
    organization_id: str,
) -> list[dict[str, Any]]

Get IDPs by organization id.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def get_organization_idps(self, organization_id: str) -> list[dict[str, Any]]:
    """Get IDPs by organization id."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_user_organizations abstractmethod async

get_user_organizations(
    user_id: str,
) -> list[KeycloakOrganizationType]

Get organizations by user id. Returns list of organizations the user is member of.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def get_user_organizations(self, user_id: str) -> list[KeycloakOrganizationType]:
    """Get organizations by user id. Returns list of organizations the user is member of."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_organization_members abstractmethod async

get_organization_members(
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get members by organization id, optionally filtered by query parameters.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def get_organization_members(
    self,
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]:
    """Get members by organization id, optionally filtered by query parameters."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_organization_members_count abstractmethod async

get_organization_members_count(organization_id: str) -> int

Get the number of members in the organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def get_organization_members_count(self, organization_id: str) -> int:
    """Get the number of members in the organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.organization_user_add abstractmethod async

organization_user_add(
    user_id: str, organization_id: str
) -> bytes

Add a user to an organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def organization_user_add(self, user_id: str, organization_id: str) -> bytes:
    """Add a user to an organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.organization_user_remove abstractmethod async

organization_user_remove(
    user_id: str, organization_id: str
) -> dict[str, Any]

Remove a user from an organization.

Source code in archipy/adapters/keycloak/port_mixins/organizations.py
@abstractmethod
async def organization_user_remove(self, user_id: str, organization_id: str) -> dict[str, Any]:
    """Remove a user from an organization."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_realm abstractmethod async

create_realm(
    realm_name: str, skip_exists: bool = True, **kwargs: Any
) -> dict[str, Any] | None

Create a new Keycloak realm.

Source code in archipy/adapters/keycloak/port_mixins/realms.py
@abstractmethod
async def create_realm(self, realm_name: str, skip_exists: bool = True, **kwargs: Any) -> dict[str, Any] | None:
    """Create a new Keycloak realm."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_realm abstractmethod async

get_realm(realm_name: str) -> dict[str, Any] | None

Get realm details by realm name.

Source code in archipy/adapters/keycloak/port_mixins/realms.py
@abstractmethod
async def get_realm(self, realm_name: str) -> dict[str, Any] | None:
    """Get realm details by realm name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_realm abstractmethod async

update_realm(
    realm_name: str, **kwargs: Any
) -> dict[str, Any] | None

Update a realm.

Kwargs are RealmRepresentation top-level attributes (e.g. displayName, organizationsEnabled).

Source code in archipy/adapters/keycloak/port_mixins/realms.py
@abstractmethod
async def update_realm(self, realm_name: str, **kwargs: Any) -> dict[str, Any] | None:
    """Update a realm.

    Kwargs are RealmRepresentation top-level attributes (e.g. displayName, organizationsEnabled).
    """
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_id abstractmethod async

get_client_id(client_name: str) -> str

Get client ID by client name.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
async def get_client_id(self, client_name: str) -> str:
    """Get client ID by client name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_secret abstractmethod async

get_client_secret(client_id: str) -> str

Get client secret.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
async def get_client_secret(self, client_id: str) -> str:
    """Get client secret."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_service_account_id abstractmethod async

get_service_account_id() -> str

Get service account user ID for the current client.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
async def get_service_account_id(self) -> str:
    """Get service account user ID for the current client."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client abstractmethod async

create_client(
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None

Create a new client in the specified realm.

Source code in archipy/adapters/keycloak/port_mixins/clients.py
@abstractmethod
async def create_client(
    self,
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None:
    """Create a new client in the specified realm."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_user_roles abstractmethod async

get_user_roles(user_id: str) -> list[KeycloakRoleType]

Get roles assigned to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def get_user_roles(self, user_id: str) -> list[KeycloakRoleType]:
    """Get roles assigned to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_roles_for_user abstractmethod async

get_client_roles_for_user(
    user_id: str, client_id: str
) -> list[KeycloakRoleType]

Get client-specific roles assigned to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def get_client_roles_for_user(self, user_id: str, client_id: str) -> list[KeycloakRoleType]:
    """Get client-specific roles assigned to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.has_role abstractmethod async

has_role(token: str, role_name: str) -> bool

Check if a user has a specific role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def has_role(self, token: str, role_name: str) -> bool:
    """Check if a user has a specific role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.has_any_of_roles abstractmethod async

has_any_of_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has any of the specified roles.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def has_any_of_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has any of the specified roles."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.has_all_roles abstractmethod async

has_all_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has all of the specified roles.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def has_all_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has all of the specified roles."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.assign_realm_role abstractmethod async

assign_realm_role(user_id: str, role_name: str) -> None

Assign a realm role to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def assign_realm_role(self, user_id: str, role_name: str) -> None:
    """Assign a realm role to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.remove_realm_role abstractmethod async

remove_realm_role(user_id: str, role_name: str) -> None

Remove a realm role from a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def remove_realm_role(self, user_id: str, role_name: str) -> None:
    """Remove a realm role from a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.assign_client_role abstractmethod async

assign_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Assign a client-specific role to a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def assign_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Assign a client-specific role to a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.remove_client_role abstractmethod async

remove_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Remove a client-specific role from a user.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def remove_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Remove a client-specific role from a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_realm_role abstractmethod async

get_realm_role(role_name: str) -> dict[str, Any]

Get realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def get_realm_role(self, role_name: str) -> dict[str, Any]:
    """Get realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_realm_roles abstractmethod async

get_realm_roles() -> list[dict[str, Any]]

Get all realm roles.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def get_realm_roles(self) -> list[dict[str, Any]]:
    """Get all realm roles."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_realm_role abstractmethod async

create_realm_role(
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def create_realm_role(
    self,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_realm_role abstractmethod async

delete_realm_role(role_name: str) -> None

Delete a realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def delete_realm_role(self, role_name: str) -> None:
    """Delete a realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_client_role abstractmethod async

create_client_role(
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new client role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def create_client_role(
    self,
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new client role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_realm_roles_to_composite abstractmethod async

add_realm_roles_to_composite(
    composite_role_name: str, child_role_names: list[str]
) -> None

Add realm roles to a composite role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def add_realm_roles_to_composite(self, composite_role_name: str, child_role_names: list[str]) -> None:
    """Add realm roles to a composite role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.add_client_roles_to_composite abstractmethod async

add_client_roles_to_composite(
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None

Add client roles to a composite role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def add_client_roles_to_composite(
    self,
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None:
    """Add client roles to a composite role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_composite_realm_roles abstractmethod async

get_composite_realm_roles(
    role_name: str,
) -> list[dict[str, Any]] | None

Get composite roles for a realm role.

Source code in archipy/adapters/keycloak/port_mixins/roles.py
@abstractmethod
async def get_composite_realm_roles(self, role_name: str) -> list[dict[str, Any]] | None:
    """Get composite roles for a realm role."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_user_by_id abstractmethod async

get_user_by_id(user_id: str) -> KeycloakUserType | None

Get user details by user ID.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def get_user_by_id(self, user_id: str) -> KeycloakUserType | None:
    """Get user details by user ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_user_by_username abstractmethod async

get_user_by_username(
    username: str,
) -> KeycloakUserType | None

Get user details by username.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def get_user_by_username(self, username: str) -> KeycloakUserType | None:
    """Get user details by username."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_user_by_email abstractmethod async

get_user_by_email(email: str) -> KeycloakUserType | None

Get user details by email.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def get_user_by_email(self, email: str) -> KeycloakUserType | None:
    """Get user details by email."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.create_user abstractmethod async

create_user(user_data: dict[str, Any]) -> str | None

Create a new user in Keycloak.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def create_user(self, user_data: dict[str, Any]) -> str | None:
    """Create a new user in Keycloak."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.update_user abstractmethod async

update_user(
    user_id: str, user_data: dict[str, Any]
) -> None

Update user details.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def update_user(self, user_id: str, user_data: dict[str, Any]) -> None:
    """Update user details."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.reset_password abstractmethod async

reset_password(
    user_id: str, password: str, temporary: bool = False
) -> None

Reset a user's password.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def reset_password(self, user_id: str, password: str, temporary: bool = False) -> None:
    """Reset a user's password."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.search_users abstractmethod async

search_users(
    query: str, max_results: int = 100
) -> list[KeycloakUserType]

Search for users by username, email, or name.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def search_users(self, query: str, max_results: int = 100) -> list[KeycloakUserType]:
    """Search for users by username, email, or name."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.clear_user_sessions abstractmethod async

clear_user_sessions(user_id: str) -> None

Clear all sessions for a user.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def clear_user_sessions(self, user_id: str) -> None:
    """Clear all sessions for a user."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.delete_user abstractmethod async

delete_user(user_id: str) -> None

Delete a user from Keycloak by their ID.

Source code in archipy/adapters/keycloak/port_mixins/users.py
@abstractmethod
async def delete_user(self, user_id: str) -> None:
    """Delete a user from Keycloak by their ID."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_token abstractmethod async

get_token(
    username: str, password: str
) -> KeycloakTokenType | None

Get a user token by username and password.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_token(self, username: str, password: str) -> KeycloakTokenType | None:
    """Get a user token by username and password."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.refresh_token abstractmethod async

refresh_token(
    refresh_token: str,
) -> KeycloakTokenType | None

Refresh an existing token using a refresh token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def refresh_token(self, refresh_token: str) -> KeycloakTokenType | None:
    """Refresh an existing token using a refresh token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.validate_token abstractmethod async

validate_token(token: str) -> bool

Validate if a token is still valid.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def validate_token(self, token: str) -> bool:
    """Validate if a token is still valid."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_userinfo abstractmethod async

get_userinfo(token: str) -> KeycloakUserType | None

Get user information from a token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_userinfo(self, token: str) -> KeycloakUserType | None:
    """Get user information from a token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_token_info abstractmethod async

get_token_info(token: str) -> dict[str, Any] | None

Decode token to get its claims.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_token_info(self, token: str) -> dict[str, Any] | None:
    """Decode token to get its claims."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.introspect_token abstractmethod async

introspect_token(token: str) -> dict[str, Any] | None

Introspect token to get detailed information about it.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def introspect_token(self, token: str) -> dict[str, Any] | None:
    """Introspect token to get detailed information about it."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_client_credentials_token abstractmethod async

get_client_credentials_token() -> KeycloakTokenType | None

Get token using client credentials.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_client_credentials_token(self) -> KeycloakTokenType | None:
    """Get token using client credentials."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.logout abstractmethod async

logout(refresh_token: str) -> None

Logout user by invalidating their refresh token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def logout(self, refresh_token: str) -> None:
    """Logout user by invalidating their refresh token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_public_key abstractmethod async

get_public_key() -> PublicKeyType

Get the public key used to verify tokens.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_public_key(self) -> PublicKeyType:
    """Get the public key used to verify tokens."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_well_known_config abstractmethod async

get_well_known_config() -> dict[str, Any]

Get the well-known OpenID configuration.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_well_known_config(self) -> dict[str, Any]:
    """Get the well-known OpenID configuration."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_certs abstractmethod async

get_certs() -> dict[str, Any]

Get the JWT verification certificates.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_certs(self) -> dict[str, Any]:
    """Get the JWT verification certificates."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.get_token_from_code abstractmethod async

get_token_from_code(
    code: str, redirect_uri: str
) -> KeycloakTokenType | None

Exchange authorization code for token.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def get_token_from_code(self, code: str, redirect_uri: str) -> KeycloakTokenType | None:
    """Exchange authorization code for token."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.check_permissions abstractmethod async

check_permissions(
    token: str, resource: str, scope: str
) -> bool

Check if a user has permission to access a resource with the specified scope.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def check_permissions(self, token: str, resource: str, scope: str) -> bool:
    """Check if a user has permission to access a resource with the specified scope."""
    raise NotImplementedError

archipy.adapters.keycloak.ports.AsyncKeycloakPort.check_permissions_batch abstractmethod async

check_permissions_batch(
    token: str, permissions: tuple[tuple[str, str], ...]
) -> frozenset[tuple[str, str]]

Return the subset of (resource, scope) pairs the token is authorized for in one UMA call.

Source code in archipy/adapters/keycloak/port_mixins/auth.py
@abstractmethod
async def check_permissions_batch(
    self,
    token: str,
    permissions: tuple[tuple[str, str], ...],
) -> frozenset[tuple[str, str]]:
    """Return the subset of (resource, scope) pairs the token is authorized for in one UMA call."""
    raise NotImplementedError

options: show_root_toc_entry: false heading_level: 3

Adapters

Concrete Keycloak adapter wrapping the Keycloak REST API for authentication and authorization operations.

Keycloak adapters composed from per-concern mixins.

archipy.adapters.keycloak.adapters.KeycloakAdapter

Bases: KeycloakConnectionMixin, KeycloakAuthMixin, KeycloakUsersMixin, KeycloakRolesMixin, KeycloakClientsMixin, KeycloakRealmsMixin, KeycloakOrganizationsMixin, KeycloakGroupsMixin, KeycloakAuthFlowsMixin, KeycloakClientScopesMixin, KeycloakAuthzMixin, KeycloakUmaMixin, KeycloakComponentsMixin, KeycloakPort

Concrete implementation of the KeycloakPort interface using python-keycloak library.

This implementation includes TTL caching for appropriate operations to improve performance while ensuring cache entries expire after a configured time to prevent stale data.

Source code in archipy/adapters/keycloak/adapters.py
class KeycloakAdapter(
    KeycloakConnectionMixin,
    KeycloakAuthMixin,
    KeycloakUsersMixin,
    KeycloakRolesMixin,
    KeycloakClientsMixin,
    KeycloakRealmsMixin,
    KeycloakOrganizationsMixin,
    KeycloakGroupsMixin,
    KeycloakAuthFlowsMixin,
    KeycloakClientScopesMixin,
    KeycloakAuthzMixin,
    KeycloakUmaMixin,
    KeycloakComponentsMixin,
    KeycloakPort,
):
    """Concrete implementation of the KeycloakPort interface using python-keycloak library.

    This implementation includes TTL caching for appropriate operations to improve performance
    while ensuring cache entries expire after a configured time to prevent stale data.
    """

archipy.adapters.keycloak.adapters.KeycloakAdapter.configs instance-attribute

configs: KeycloakConfig = (
    BaseConfig.global_config().KEYCLOAK
    if keycloak_configs is None
    else keycloak_configs
)

archipy.adapters.keycloak.adapters.KeycloakAdapter.admin_adapter property

admin_adapter: KeycloakAdmin

Get the admin adapter, refreshing it if necessary.

Returns:

Type Description
KeycloakAdmin

KeycloakAdmin instance

Raises:

Type Description
UnauthenticatedError

If admin client is not available due to authentication issues

UnavailableError

If Keycloak service is unavailable

archipy.adapters.keycloak.adapters.KeycloakAdapter.uma_adapter property

uma_adapter: KeycloakUMA

Get the UMA adapter, creating it on first access.

Returns:

Type Description
KeycloakUMA

KeycloakUMA instance

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_component

create_component(payload: dict[str, Any]) -> str

Create a Keycloak component.

Parameters:

Name Type Description Default
payload dict[str, Any]

Component representation.

required

Returns:

Type Description
str

Created component ID.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
def create_component(self, payload: dict[str, Any]) -> str:
    """Create a Keycloak component.

    Args:
        payload: Component representation.

    Returns:
        Created component ID.
    """
    return self._call_keycloak(
        "create_component",
        lambda: self.admin_adapter.create_component(payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_component

get_component(component_id: str) -> dict[str, Any]

Get a component by ID.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Component representation.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
def get_component(self, component_id: str) -> dict[str, Any]:
    """Get a component by ID.

    Args:
        component_id: Component identifier.

    Returns:
        Component representation.
    """
    return self._call_keycloak(
        "get_component",
        lambda: self.admin_adapter.get_component(component_id=component_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_components

get_components(
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get components, optionally filtered by query.

Parameters:

Name Type Description Default
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

Matching component representations.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
def get_components(self, query: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Get components, optionally filtered by query.

    Args:
        query: Optional filter query parameters.

    Returns:
        Matching component representations.
    """
    return self._call_keycloak(
        "get_components",
        lambda: self.admin_adapter.get_components(query=query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_component

update_component(
    component_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required
payload dict[str, Any]

Updated component representation.

required

Returns:

Type Description
dict[str, Any]

Update response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
def update_component(self, component_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a component.

    Args:
        component_id: Component identifier.
        payload: Updated component representation.

    Returns:
        Update response payload.
    """
    return self._call_keycloak(
        "update_component",
        lambda: self.admin_adapter.update_component(component_id=component_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_component

delete_component(component_id: str) -> dict[str, Any]

Delete a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
def delete_component(self, component_id: str) -> dict[str, Any]:
    """Delete a component.

    Args:
        component_id: Component identifier.

    Returns:
        Deletion response payload.
    """
    return self._call_keycloak(
        "delete_component",
        lambda: self.admin_adapter.delete_component(component_id=component_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.resource_set_create

resource_set_create(
    payload: dict[str, Any],
) -> dict[str, Any]

Create a UMA resource set.

Parameters:

Name Type Description Default
payload dict[str, Any]

Resource set representation.

required

Returns:

Type Description
dict[str, Any]

Created resource set representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def resource_set_create(self, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA resource set.

    Args:
        payload: Resource set representation.

    Returns:
        Created resource set representation.
    """
    return self._call_keycloak(
        "resource_set_create",
        lambda: self.uma_adapter.resource_set_create(payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.resource_set_read

resource_set_read(resource_id: str) -> dict[str, Any]

Read a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Resource set representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def resource_set_read(self, resource_id: str) -> dict[str, Any]:
    """Read a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Resource set representation.
    """
    return self._call_keycloak(
        "resource_set_read",
        lambda: self.uma_adapter.resource_set_read(resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.resource_set_update

resource_set_update(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required
payload dict[str, Any]

Updated resource set representation.

required

Returns:

Type Description
dict[str, Any]

Updated resource set representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def resource_set_update(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a UMA resource set.

    Args:
        resource_id: Resource set identifier.
        payload: Updated resource set representation.

    Returns:
        Updated resource set representation.
    """
    return self._call_keycloak(
        "resource_set_update",
        lambda: self.uma_adapter.resource_set_update(resource_id=resource_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.resource_set_delete

resource_set_delete(resource_id: str) -> dict[str, Any]

Delete a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def resource_set_delete(self, resource_id: str) -> dict[str, Any]:
    """Delete a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Deletion response payload.
    """
    return self._call_keycloak(
        "resource_set_delete",
        lambda: self.uma_adapter.resource_set_delete(resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.resource_set_list

resource_set_list() -> list[dict[str, Any]]

List all UMA resource sets.

Returns:

Type Description
list[dict[str, Any]]

List of resource set representations.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def resource_set_list(self) -> list[dict[str, Any]]:
    """List all UMA resource sets.

    Returns:
        List of resource set representations.
    """
    return self._call_keycloak(
        "resource_set_list",
        lambda: list(self.uma_adapter.resource_set_list()),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.resource_set_list_ids

resource_set_list_ids(
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

List UMA resource set IDs with optional filters.

Parameters:

Name Type Description Default
name str

Filter by resource name.

''
exact_name bool

Require exact name match when True.

False
uri str

Filter by resource URI.

''
owner str

Filter by owner.

''
resource_type str

Filter by resource type.

''
scope str

Filter by scope.

''
matchingUri bool

Match URI patterns when True.

False
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching resource set IDs / summaries.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def resource_set_list_ids(
    self,
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """List UMA resource set IDs with optional filters.

    Args:
        name: Filter by resource name.
        exact_name: Require exact name match when True.
        uri: Filter by resource URI.
        owner: Filter by owner.
        resource_type: Filter by resource type.
        scope: Filter by scope.
        matchingUri: Match URI patterns when True.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching resource set IDs / summaries.
    """
    return self._call_keycloak(
        "resource_set_list_ids",
        lambda: self.uma_adapter.resource_set_list_ids(
            name=name,
            exact_name=exact_name,
            uri=uri,
            owner=owner,
            resource_type=resource_type,
            scope=scope,
            matchingUri=matchingUri,
            first=first,
            maximum=maximum,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.policy_resource_create

policy_resource_create(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Create a UMA policy for a resource.

Parameters:

Name Type Description Default
resource_id str

Resource identifier.

required
payload dict[str, Any]

Policy representation.

required

Returns:

Type Description
dict[str, Any]

Created policy representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def policy_resource_create(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA policy for a resource.

    Args:
        resource_id: Resource identifier.
        payload: Policy representation.

    Returns:
        Created policy representation.
    """
    return self._call_keycloak(
        "policy_resource_create",
        lambda: self.uma_adapter.policy_resource_create(resource_id=resource_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.policy_update

policy_update(
    policy_id: str, payload: dict[str, Any]
) -> bytes

Update a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required
payload dict[str, Any]

Updated policy representation.

required

Returns:

Type Description
bytes

Raw update response bytes.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def policy_update(self, policy_id: str, payload: dict[str, Any]) -> bytes:
    """Update a UMA policy.

    Args:
        policy_id: Policy identifier.
        payload: Updated policy representation.

    Returns:
        Raw update response bytes.
    """
    return self._call_keycloak(
        "policy_update",
        lambda: self.uma_adapter.policy_update(policy_id=policy_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.policy_delete

policy_delete(policy_id: str) -> dict[str, Any]

Delete a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def policy_delete(self, policy_id: str) -> dict[str, Any]:
    """Delete a UMA policy.

    Args:
        policy_id: Policy identifier.

    Returns:
        Deletion response payload.
    """
    return self._call_keycloak(
        "policy_delete",
        lambda: self.uma_adapter.policy_delete(policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.policy_query

policy_query(
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

Query UMA policies.

Parameters:

Name Type Description Default
resource str

Filter by resource.

''
name str

Filter by policy name.

''
scope str

Filter by scope.

''
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching policy representations.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def policy_query(
    self,
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """Query UMA policies.

    Args:
        resource: Filter by resource.
        name: Filter by policy name.
        scope: Filter by scope.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching policy representations.
    """
    return self._call_keycloak(
        "policy_query",
        lambda: self.uma_adapter.policy_query(
            resource=resource,
            name=name,
            scope=scope,
            first=first,
            maximum=maximum,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.permission_ticket_create

permission_ticket_create(
    permissions: Iterable[UMAPermission],
) -> dict[str, Any]

Create a UMA permission ticket.

Parameters:

Name Type Description Default
permissions Iterable[UMAPermission]

Permissions to include in the ticket.

required

Returns:

Type Description
dict[str, Any]

Permission ticket representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def permission_ticket_create(self, permissions: Iterable[UMAPermission]) -> dict[str, Any]:
    """Create a UMA permission ticket.

    Args:
        permissions: Permissions to include in the ticket.

    Returns:
        Permission ticket representation.
    """
    return self._call_keycloak(
        "permission_ticket_create",
        lambda: self.uma_adapter.permission_ticket_create(permissions=permissions),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.permissions_check

permissions_check(
    token: str,
    permissions: Iterable[UMAPermission],
    **extra_payload: Any,
) -> bool

Check UMA permissions for a token.

Parameters:

Name Type Description Default
token str

Access token to evaluate.

required
permissions Iterable[UMAPermission]

Permissions to check.

required
**extra_payload Any

Extra fields forwarded to the UMA endpoint.

{}

Returns:

Type Description
bool

True when all requested permissions are granted.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
def permissions_check(self, token: str, permissions: Iterable[UMAPermission], **extra_payload: Any) -> bool:
    """Check UMA permissions for a token.

    Args:
        token: Access token to evaluate.
        permissions: Permissions to check.
        **extra_payload: Extra fields forwarded to the UMA endpoint.

    Returns:
        True when all requested permissions are granted.
    """
    return self._call_keycloak(
        "permissions_check",
        lambda: self.uma_adapter.permissions_check(token=token, permissions=permissions, **extra_payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_resource

create_client_authz_resource(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization resource for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_resource(self, client_id: str, payload: dict, skip_exists: bool = False) -> dict[str, Any]:
    """Create an authorization resource for a client."""
    return self._call_keycloak(
        "create_client_authz_resource",
        lambda: self.admin_adapter.create_client_authz_resource(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_resources

get_client_authz_resources(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization resources for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_resources(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization resources for a client."""
    return self._call_keycloak(
        "get_client_authz_resources",
        lambda: self.admin_adapter.get_client_authz_resources(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_resource

get_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Get a single authorization resource.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Get a single authorization resource."""
    return self._call_keycloak(
        "get_client_authz_resource",
        lambda: self.admin_adapter.get_client_authz_resource(client_id=client_id, resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_client_authz_resource

update_client_authz_resource(
    client_id: str, resource_id: str, payload: dict
) -> dict[str, Any]

Update an authorization resource.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def update_client_authz_resource(self, client_id: str, resource_id: str, payload: dict) -> dict[str, Any]:
    """Update an authorization resource."""
    return self._call_keycloak(
        "update_client_authz_resource",
        lambda: self.admin_adapter.update_client_authz_resource(
            client_id=client_id,
            resource_id=resource_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_client_authz_resource

delete_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Delete an authorization resource.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def delete_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Delete an authorization resource."""
    return self._call_keycloak(
        "delete_client_authz_resource",
        lambda: self.admin_adapter.delete_client_authz_resource(client_id=client_id, resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_scopes

create_client_authz_scopes(
    client_id: str, payload: dict
) -> dict[str, Any]

Create authorization scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_scopes(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Create authorization scopes for a client."""
    return self._call_keycloak(
        "create_client_authz_scopes",
        lambda: self.admin_adapter.create_client_authz_scopes(client_id=client_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_scopes

get_client_authz_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization scopes for a client."""
    return self._call_keycloak(
        "get_client_authz_scopes",
        lambda: self.admin_adapter.get_client_authz_scopes(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_role_based_policy

create_client_authz_role_based_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a role-based authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_role_based_policy(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a role-based authorization policy."""
    return self._call_keycloak(
        "create_client_authz_role_based_policy",
        lambda: self.admin_adapter.create_client_authz_role_based_policy(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_client_policy

create_client_authz_client_policy(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a client-based authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_client_policy(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a client-based authorization policy."""
    return self._call_keycloak(
        "create_client_authz_client_policy",
        lambda: self.admin_adapter.create_client_authz_client_policy(payload=payload, client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_policy

create_client_authz_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_policy(self, client_id: str, payload: dict, skip_exists: bool = False) -> dict[str, Any]:
    """Create an authorization policy."""
    return self._call_keycloak(
        "create_client_authz_policy",
        lambda: self.admin_adapter.create_client_authz_policy(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_policies

get_client_authz_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization policies for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization policies for a client."""
    return self._call_keycloak(
        "get_client_authz_policies",
        lambda: self.admin_adapter.get_client_authz_policies(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_policy

get_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Get a single authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Get a single authorization policy."""
    return self._call_keycloak(
        "get_client_authz_policy",
        lambda: self.admin_adapter.get_client_authz_policy(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_client_authz_policy

delete_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Delete an authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def delete_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Delete an authorization policy."""
    return self._call_keycloak(
        "delete_client_authz_policy",
        lambda: self.admin_adapter.delete_client_authz_policy(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_resource_based_permission

create_client_authz_resource_based_permission(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a resource-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_resource_based_permission(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a resource-based permission."""
    return self._call_keycloak(
        "create_client_authz_resource_based_permission",
        lambda: self.admin_adapter.create_client_authz_resource_based_permission(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_authz_scope_permission

create_client_authz_scope_permission(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a scope-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def create_client_authz_scope_permission(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a scope-based permission."""
    return self._call_keycloak(
        "create_client_authz_scope_permission",
        lambda: self.admin_adapter.create_client_authz_scope_permission(payload=payload, client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_permissions

get_client_authz_permissions(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization permissions for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_permissions(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization permissions for a client."""
    return self._call_keycloak(
        "get_client_authz_permissions",
        lambda: self.admin_adapter.get_client_authz_permissions(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_scope_permission

get_client_authz_scope_permission(
    client_id: str, scope_id: str
) -> dict[str, Any]

Get a scope-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_scope_permission(self, client_id: str, scope_id: str) -> dict[str, Any]:
    """Get a scope-based permission."""
    return self._call_keycloak(
        "get_client_authz_scope_permission",
        lambda: self.admin_adapter.get_client_authz_scope_permission(client_id=client_id, scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_client_authz_scope_permission

update_client_authz_scope_permission(
    payload: dict, client_id: str, scope_id: str
) -> bytes

Update a scope-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def update_client_authz_scope_permission(self, payload: dict, client_id: str, scope_id: str) -> bytes:
    """Update a scope-based permission."""
    return self._call_keycloak(
        "update_client_authz_scope_permission",
        lambda: self.admin_adapter.update_client_authz_scope_permission(
            payload=payload,
            client_id=client_id,
            scope_id=scope_id,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_client_authz_resource_permission

update_client_authz_resource_permission(
    payload: dict, client_id: str, resource_id: str
) -> bytes

Update a resource-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def update_client_authz_resource_permission(self, payload: dict, client_id: str, resource_id: str) -> bytes:
    """Update a resource-based permission."""
    return self._call_keycloak(
        "update_client_authz_resource_permission",
        lambda: self.admin_adapter.update_client_authz_resource_permission(
            payload=payload,
            client_id=client_id,
            resource_id=resource_id,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_permission_associated_policies

get_client_authz_permission_associated_policies(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get policies associated with a permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_permission_associated_policies(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get policies associated with a permission."""
    return self._call_keycloak(
        "get_client_authz_permission_associated_policies",
        lambda: self.admin_adapter.get_client_authz_permission_associated_policies(
            client_id=client_id,
            policy_id=policy_id,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_settings

get_client_authz_settings(client_id: str) -> dict[str, Any]

Get authorization settings for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_settings(self, client_id: str) -> dict[str, Any]:
    """Get authorization settings for a client."""
    return self._call_keycloak(
        "get_client_authz_settings",
        lambda: self.admin_adapter.get_client_authz_settings(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_client_policies

get_client_authz_client_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get client policies for authorization.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_client_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get client policies for authorization."""
    return self._call_keycloak(
        "get_client_authz_client_policies",
        lambda: self.admin_adapter.get_client_authz_client_policies(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_policy_resources

get_client_authz_policy_resources(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get resources associated with a policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_policy_resources(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get resources associated with a policy."""
    return self._call_keycloak(
        "get_client_authz_policy_resources",
        lambda: self.admin_adapter.get_client_authz_policy_resources(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_authz_policy_scopes

get_client_authz_policy_scopes(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get scopes associated with a policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def get_client_authz_policy_scopes(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get scopes associated with a policy."""
    return self._call_keycloak(
        "get_client_authz_policy_scopes",
        lambda: self.admin_adapter.get_client_authz_policy_scopes(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.import_client_authz_config

import_client_authz_config(
    client_id: str, payload: dict
) -> dict[str, Any]

Import authorization configuration for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
def import_client_authz_config(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Import authorization configuration for a client."""
    return self._call_keycloak(
        "import_client_authz_config",
        lambda: self.admin_adapter.import_client_authz_config(client_id=client_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_scopes

get_client_scopes() -> list[dict[str, Any]]

Get all client scopes.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get all client scopes."""
    return self._call_keycloak(
        "get_client_scopes",
        self.admin_adapter.get_client_scopes,
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_scope

get_client_scope(client_scope_id: str) -> dict[str, Any]

Get a client scope by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Get a client scope by ID."""
    return self._call_keycloak(
        "get_client_scope",
        lambda: self.admin_adapter.get_client_scope(client_scope_id=client_scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_scope_by_name

get_client_scope_by_name(
    client_scope_name: str,
) -> dict[str, Any] | None

Get a client scope by name.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_client_scope_by_name(self, client_scope_name: str) -> dict[str, Any] | None:
    """Get a client scope by name."""
    return self._call_keycloak(
        "get_client_scope_by_name",
        lambda: self.admin_adapter.get_client_scope_by_name(client_scope_name=client_scope_name),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_scope

create_client_scope(
    payload: dict, skip_exists: bool = False
) -> str

Create a new client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def create_client_scope(self, payload: dict, skip_exists: bool = False) -> str:
    """Create a new client scope."""
    return self._call_keycloak(
        "create_client_scope",
        lambda: self.admin_adapter.create_client_scope(payload=payload, skip_exists=skip_exists),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_client_scope

update_client_scope(
    client_scope_id: str, payload: dict
) -> dict[str, Any]

Update a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def update_client_scope(self, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Update a client scope."""
    return self._call_keycloak(
        "update_client_scope",
        lambda: self.admin_adapter.update_client_scope(client_scope_id=client_scope_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_client_scope

delete_client_scope(client_scope_id: str) -> dict[str, Any]

Delete a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def delete_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Delete a client scope."""
    return self._call_keycloak(
        "delete_client_scope",
        lambda: self.admin_adapter.delete_client_scope(client_scope_id=client_scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_mapper_to_client_scope

add_mapper_to_client_scope(
    client_scope_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def add_mapper_to_client_scope(self, client_scope_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client scope."""
    return self._call_keycloak(
        "add_mapper_to_client_scope",
        lambda: self.admin_adapter.add_mapper_to_client_scope(client_scope_id=client_scope_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_mappers_from_client_scope

get_mappers_from_client_scope(
    client_scope_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_mappers_from_client_scope(self, client_scope_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client scope."""
    return self._call_keycloak(
        "get_mappers_from_client_scope",
        lambda: self.admin_adapter.get_mappers_from_client_scope(client_scope_id=client_scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_mapper_in_client_scope

update_mapper_in_client_scope(
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]

Update a protocol mapper in a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def update_mapper_in_client_scope(
    self,
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Update a protocol mapper in a client scope."""
    return self._call_keycloak(
        "update_mapper_in_client_scope",
        lambda: self.admin_adapter.update_mapper_in_client_scope(
            client_scope_id=client_scope_id,
            protocol_mapper_id=protocol_mapper_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_mapper_from_client_scope

delete_mapper_from_client_scope(
    client_scope_id: str, protocol_mapper_id: str
) -> dict[str, Any]

Delete a protocol mapper from a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def delete_mapper_from_client_scope(self, client_scope_id: str, protocol_mapper_id: str) -> dict[str, Any]:
    """Delete a protocol mapper from a client scope."""
    return self._call_keycloak(
        "delete_mapper_from_client_scope",
        lambda: self.admin_adapter.delete_mapper_from_client_scope(
            client_scope_id=client_scope_id,
            protocol_mapper_id=protocol_mapper_id,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_mapper_to_client

add_mapper_to_client(
    client_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def add_mapper_to_client(self, client_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client."""
    return self._call_keycloak(
        "add_mapper_to_client",
        lambda: self.admin_adapter.add_mapper_to_client(client_id=client_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_mappers_from_client

get_mappers_from_client(
    client_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_mappers_from_client(self, client_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client."""
    return self._call_keycloak(
        "get_mappers_from_client",
        lambda: self.admin_adapter.get_mappers_from_client(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_client_mapper

update_client_mapper(
    client_id: str, mapper_id: str, payload: dict
) -> dict[str, Any]

Update a protocol mapper on a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def update_client_mapper(self, client_id: str, mapper_id: str, payload: dict) -> dict[str, Any]:
    """Update a protocol mapper on a client."""
    return self._call_keycloak(
        "update_client_mapper",
        lambda: self.admin_adapter.update_client_mapper(client_id=client_id, mapper_id=mapper_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.remove_client_mapper

remove_client_mapper(
    client_id: str, client_mapper_id: str
) -> dict[str, Any]

Remove a protocol mapper from a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def remove_client_mapper(self, client_id: str, client_mapper_id: str) -> dict[str, Any]:
    """Remove a protocol mapper from a client."""
    return self._call_keycloak(
        "remove_client_mapper",
        lambda: self.admin_adapter.remove_client_mapper(client_id=client_id, client_mapper_id=client_mapper_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_default_client_scopes

get_client_default_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get default client scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_client_default_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get default client scopes for a client."""
    return self._call_keycloak(
        "get_client_default_client_scopes",
        lambda: self.admin_adapter.get_client_default_client_scopes(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_client_default_client_scope

add_client_default_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add a default client scope to a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def add_client_default_client_scope(self, client_id: str, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Add a default client scope to a client."""
    return self._call_keycloak(
        "add_client_default_client_scope",
        lambda: self.admin_adapter.add_client_default_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_client_default_client_scope

delete_client_default_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove a default client scope from a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def delete_client_default_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove a default client scope from a client."""
    return self._call_keycloak(
        "delete_client_default_client_scope",
        lambda: self.admin_adapter.delete_client_default_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_optional_client_scopes

get_client_optional_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get optional client scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_client_optional_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get optional client scopes for a client."""
    return self._call_keycloak(
        "get_client_optional_client_scopes",
        lambda: self.admin_adapter.get_client_optional_client_scopes(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_client_optional_client_scope

add_client_optional_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add an optional client scope to a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def add_client_optional_client_scope(self, client_id: str, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Add an optional client scope to a client."""
    return self._call_keycloak(
        "add_client_optional_client_scope",
        lambda: self.admin_adapter.add_client_optional_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_client_optional_client_scope

delete_client_optional_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove an optional client scope from a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def delete_client_optional_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove an optional client scope from a client."""
    return self._call_keycloak(
        "delete_client_optional_client_scope",
        lambda: self.admin_adapter.delete_client_optional_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_default_default_client_scopes

get_default_default_client_scopes() -> list[dict[str, Any]]

Get realm default client scopes.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_default_default_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm default client scopes."""
    return self._call_keycloak(
        "get_default_default_client_scopes",
        self.admin_adapter.get_default_default_client_scopes,
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_default_default_client_scope

add_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def add_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm default client scope."""
    return self._call_keycloak(
        "add_default_default_client_scope",
        lambda: self.admin_adapter.add_default_default_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_default_default_client_scope

delete_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def delete_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm default client scope."""
    return self._call_keycloak(
        "delete_default_default_client_scope",
        lambda: self.admin_adapter.delete_default_default_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_default_optional_client_scopes

get_default_optional_client_scopes() -> list[
    dict[str, Any]
]

Get realm optional default client scopes.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def get_default_optional_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm optional default client scopes."""
    return self._call_keycloak(
        "get_default_optional_client_scopes",
        self.admin_adapter.get_default_optional_client_scopes,
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_default_optional_client_scope

add_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm optional default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def add_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm optional default client scope."""
    return self._call_keycloak(
        "add_default_optional_client_scope",
        lambda: self.admin_adapter.add_default_optional_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_default_optional_client_scope

delete_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm optional default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
def delete_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm optional default client scope."""
    return self._call_keycloak(
        "delete_default_optional_client_scope",
        lambda: self.admin_adapter.delete_default_optional_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_authentication_flow

create_authentication_flow(
    payload: dict, skip_exists: bool = False
) -> bytes

Create a new authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def create_authentication_flow(self, payload: dict, skip_exists: bool = False) -> bytes:
    """Create a new authentication flow."""
    return self._call_keycloak(
        "create_authentication_flow",
        lambda: self.admin_adapter.create_authentication_flow(payload=payload, skip_exists=skip_exists),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.copy_authentication_flow

copy_authentication_flow(
    payload: dict, flow_alias: str
) -> bytes

Copy an existing authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def copy_authentication_flow(self, payload: dict, flow_alias: str) -> bytes:
    """Copy an existing authentication flow."""
    return self._call_keycloak(
        "copy_authentication_flow",
        lambda: self.admin_adapter.copy_authentication_flow(payload=payload, flow_alias=flow_alias),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authentication_flows

get_authentication_flows() -> list[dict[str, Any]]

Get all authentication flows.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authentication_flows(
    self,
) -> list[dict[str, Any]]:
    """Get all authentication flows."""
    return self._call_keycloak(
        "get_authentication_flows",
        self.admin_adapter.get_authentication_flows,
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authentication_flow_for_id

get_authentication_flow_for_id(
    flow_id: str,
) -> dict[str, Any]

Get authentication flow by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authentication_flow_for_id(self, flow_id: str) -> dict[str, Any]:
    """Get authentication flow by ID."""
    return self._call_keycloak(
        "get_authentication_flow_for_id",
        lambda: self.admin_adapter.get_authentication_flow_for_id(flow_id=flow_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_authentication_flow

delete_authentication_flow(flow_id: str) -> dict[str, Any]

Delete an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def delete_authentication_flow(self, flow_id: str) -> dict[str, Any]:
    """Delete an authentication flow."""
    return self._call_keycloak(
        "delete_authentication_flow",
        lambda: self.admin_adapter.delete_authentication_flow(flow_id=flow_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authentication_flow_executions

get_authentication_flow_executions(
    flow_alias: str,
) -> list[dict[str, Any]]

Get executions for an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authentication_flow_executions(self, flow_alias: str) -> list[dict[str, Any]]:
    """Get executions for an authentication flow."""
    return self._call_keycloak(
        "get_authentication_flow_executions",
        lambda: self.admin_adapter.get_authentication_flow_executions(flow_alias=flow_alias),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authentication_flow_execution

get_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Get a single authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Get a single authentication flow execution."""
    return self._call_keycloak(
        "get_authentication_flow_execution",
        lambda: self.admin_adapter.get_authentication_flow_execution(execution_id=execution_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_authentication_flow_execution

create_authentication_flow_execution(
    payload: dict, flow_alias: str
) -> bytes

Create an execution in an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def create_authentication_flow_execution(self, payload: dict, flow_alias: str) -> bytes:
    """Create an execution in an authentication flow."""
    return self._call_keycloak(
        "create_authentication_flow_execution",
        lambda: self.admin_adapter.create_authentication_flow_execution(payload=payload, flow_alias=flow_alias),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_authentication_flow_executions

update_authentication_flow_executions(
    payload: dict, flow_alias: str
) -> dict[str, Any]

Update executions in an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def update_authentication_flow_executions(self, payload: dict, flow_alias: str) -> dict[str, Any]:
    """Update executions in an authentication flow."""
    return self._call_keycloak(
        "update_authentication_flow_executions",
        lambda: self.admin_adapter.update_authentication_flow_executions(payload=payload, flow_alias=flow_alias),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_authentication_flow_subflow

create_authentication_flow_subflow(
    payload: dict,
    flow_alias: str,
    skip_exists: bool = False,
) -> bytes

Create a subflow in an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def create_authentication_flow_subflow(self, payload: dict, flow_alias: str, skip_exists: bool = False) -> bytes:
    """Create a subflow in an authentication flow."""
    return self._call_keycloak(
        "create_authentication_flow_subflow",
        lambda: self.admin_adapter.create_authentication_flow_subflow(
            payload=payload,
            flow_alias=flow_alias,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_authentication_flow_execution

delete_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Delete an authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def delete_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Delete an authentication flow execution."""
    return self._call_keycloak(
        "delete_authentication_flow_execution",
        lambda: self.admin_adapter.delete_authentication_flow_execution(execution_id=execution_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.change_execution_priority

change_execution_priority(
    execution_id: str, diff: int
) -> None

Change priority of an authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def change_execution_priority(self, execution_id: str, diff: int) -> None:
    """Change priority of an authentication flow execution."""
    return self._call_keycloak(
        "change_execution_priority",
        lambda: self.admin_adapter.change_execution_priority(execution_id=execution_id, diff=diff),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_authentication_flow

update_authentication_flow(
    flow_id: str, payload: dict
) -> dict[str, Any]

Update an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def update_authentication_flow(self, flow_id: str, payload: dict) -> dict[str, Any]:
    """Update an authentication flow."""
    return self._call_keycloak(
        "update_authentication_flow",
        lambda: self.admin_adapter.update_authentication_flow(flow_id=flow_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authenticator_providers

get_authenticator_providers() -> list[dict[str, Any]]

Get available authenticator providers.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authenticator_providers(
    self,
) -> list[dict[str, Any]]:
    """Get available authenticator providers."""
    return self._call_keycloak(
        "get_authenticator_providers",
        self.admin_adapter.get_authenticator_providers,
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authenticator_provider_config_description

get_authenticator_provider_config_description(
    provider_id: str,
) -> dict[str, Any]

Get config description for an authenticator provider.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authenticator_provider_config_description(self, provider_id: str) -> dict[str, Any]:
    """Get config description for an authenticator provider."""
    return self._call_keycloak(
        "get_authenticator_provider_config_description",
        lambda: self.admin_adapter.get_authenticator_provider_config_description(provider_id=provider_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_authenticator_config

get_authenticator_config(config_id: str) -> dict[str, Any]

Get authenticator configuration by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def get_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Get authenticator configuration by ID."""
    return self._call_keycloak(
        "get_authenticator_config",
        lambda: self.admin_adapter.get_authenticator_config(config_id=config_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_authenticator_config

update_authenticator_config(
    payload: dict, config_id: str
) -> dict[str, Any]

Update authenticator configuration.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def update_authenticator_config(self, payload: dict, config_id: str) -> dict[str, Any]:
    """Update authenticator configuration."""
    return self._call_keycloak(
        "update_authenticator_config",
        lambda: self.admin_adapter.update_authenticator_config(payload=payload, config_id=config_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_authenticator_config

delete_authenticator_config(
    config_id: str,
) -> dict[str, Any]

Delete authenticator configuration.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def delete_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Delete authenticator configuration."""
    return self._call_keycloak(
        "delete_authenticator_config",
        lambda: self.admin_adapter.delete_authenticator_config(config_id=config_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_execution_config

create_execution_config(
    execution_id: str, payload: dict
) -> bytes

Create configuration for an authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
def create_execution_config(self, execution_id: str, payload: dict) -> bytes:
    """Create configuration for an authentication flow execution."""
    return self._call_keycloak(
        "create_execution_config",
        lambda: self.admin_adapter.create_execution_config(execution_id=execution_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_group

create_group(
    payload: dict,
    parent: str | None = None,
    skip_exists: bool = False,
) -> str | None

Create a new group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def create_group(self, payload: dict, parent: str | None = None, skip_exists: bool = False) -> str | None:
    """Create a new group."""
    return self._call_keycloak(
        "create_group",
        lambda: self.admin_adapter.create_group(payload=payload, parent=parent, skip_exists=skip_exists),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_group

update_group(
    group_id: str, payload: dict
) -> dict[str, Any]

Update a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def update_group(self, group_id: str, payload: dict) -> dict[str, Any]:
    """Update a group."""
    return self._call_keycloak(
        "update_group",
        lambda: self.admin_adapter.update_group(group_id=group_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_group

delete_group(group_id: str) -> dict[str, Any]

Delete a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def delete_group(self, group_id: str) -> dict[str, Any]:
    """Delete a group."""
    return self._call_keycloak(
        "delete_group",
        lambda: self.admin_adapter.delete_group(group_id=group_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_group

get_group(
    group_id: str,
    full_hierarchy: bool = False,
    query: dict | None = None,
) -> dict[str, Any]

Get group representation by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_group(self, group_id: str, full_hierarchy: bool = False, query: dict | None = None) -> dict[str, Any]:
    """Get group representation by ID."""
    return self._call_keycloak(
        "get_group",
        lambda: self.admin_adapter.get_group(group_id=group_id, full_hierarchy=full_hierarchy, query=query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_group_by_path

get_group_by_path(path: str) -> dict[str, Any]

Get group representation by path.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_group_by_path(self, path: str) -> dict[str, Any]:
    """Get group representation by path."""
    return self._call_keycloak(
        "get_group_by_path",
        lambda: self.admin_adapter.get_group_by_path(path=path),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_group_children

get_group_children(
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]

Get child groups of a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_group_children(
    self,
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]:
    """Get child groups of a group."""
    return self._call_keycloak(
        "get_group_children",
        lambda: self.admin_adapter.get_group_children(
            group_id=group_id,
            query=query,
            full_hierarchy=full_hierarchy,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_groups

get_groups(
    query: dict | None = None, full_hierarchy: bool = False
) -> list[dict[str, Any]]

Get all groups, optionally filtered by query.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_groups(self, query: dict | None = None, full_hierarchy: bool = False) -> list[dict[str, Any]]:
    """Get all groups, optionally filtered by query."""
    return self._call_keycloak(
        "get_groups",
        lambda: self.admin_adapter.get_groups(query=query, full_hierarchy=full_hierarchy),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_subgroups

get_subgroups(
    group: dict, path: str
) -> dict[str, Any] | None

Get subgroups for a group at the given path.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_subgroups(self, group: dict, path: str) -> dict[str, Any] | None:
    """Get subgroups for a group at the given path."""
    return self._call_keycloak(
        "get_subgroups",
        lambda: self.admin_adapter.get_subgroups(group=group, path=path),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.groups_count

groups_count(query: dict | None = None) -> dict[str, Any]

Get the number of groups matching the query.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def groups_count(self, query: dict | None = None) -> dict[str, Any]:
    """Get the number of groups matching the query."""
    return self._call_keycloak(
        "groups_count",
        lambda: self.admin_adapter.groups_count(query=query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.group_user_add

group_user_add(
    user_id: str, group_id: str
) -> dict[str, Any]

Add a user to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def group_user_add(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Add a user to a group."""
    return self._call_keycloak(
        "group_user_add",
        lambda: self.admin_adapter.group_user_add(user_id=user_id, group_id=group_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.group_user_remove

group_user_remove(
    user_id: str, group_id: str
) -> dict[str, Any]

Remove a user from a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def group_user_remove(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Remove a user from a group."""
    return self._call_keycloak(
        "group_user_remove",
        lambda: self.admin_adapter.group_user_remove(user_id=user_id, group_id=group_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.group_set_permissions

group_set_permissions(
    group_id: str, enabled: bool = True
) -> dict[str, Any]

Enable or disable fine-grained permissions for a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def group_set_permissions(self, group_id: str, enabled: bool = True) -> dict[str, Any]:
    """Enable or disable fine-grained permissions for a group."""
    return self._call_keycloak(
        "group_set_permissions",
        lambda: self.admin_adapter.group_set_permissions(group_id=group_id, enabled=enabled),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_group_members

get_group_members(
    group_id: str, query: dict | None = None
) -> list[dict[str, Any]]

Get members of a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_group_members(self, group_id: str, query: dict | None = None) -> list[dict[str, Any]]:
    """Get members of a group."""
    return self._call_keycloak(
        "get_group_members",
        lambda: self.admin_adapter.get_group_members(group_id=group_id, query=query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_group_client_roles

get_group_client_roles(
    group_id: str, client_id: str
) -> list[dict[str, Any]]

Get client roles assigned to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_group_client_roles(self, group_id: str, client_id: str) -> list[dict[str, Any]]:
    """Get client roles assigned to a group."""
    return self._call_keycloak(
        "get_group_client_roles",
        lambda: self.admin_adapter.get_group_client_roles(group_id=group_id, client_id=client_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_group_realm_roles

get_group_realm_roles(
    group_id: str, brief_representation: bool = True
) -> list[dict[str, Any]]

Get realm roles assigned to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_group_realm_roles(self, group_id: str, brief_representation: bool = True) -> list[dict[str, Any]]:
    """Get realm roles assigned to a group."""
    return self._call_keycloak(
        "get_group_realm_roles",
        lambda: self.admin_adapter.get_group_realm_roles(
            group_id=group_id,
            brief_representation=brief_representation,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.assign_group_client_roles

assign_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Assign client roles to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def assign_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Assign client roles to a group."""
    return self._call_keycloak(
        "assign_group_client_roles",
        lambda: self.admin_adapter.assign_group_client_roles(group_id=group_id, client_id=client_id, roles=roles),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.assign_group_realm_roles

assign_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Assign realm roles to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def assign_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Assign realm roles to a group."""
    return self._call_keycloak(
        "assign_group_realm_roles",
        lambda: self.admin_adapter.assign_group_realm_roles(group_id=group_id, roles=roles),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_group_client_roles

delete_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Remove client roles from a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def delete_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Remove client roles from a group."""
    return self._call_keycloak(
        "delete_group_client_roles",
        lambda: self.admin_adapter.delete_group_client_roles(group_id=group_id, client_id=client_id, roles=roles),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_group_realm_roles

delete_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Remove realm roles from a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def delete_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Remove realm roles from a group."""
    return self._call_keycloak(
        "delete_group_realm_roles",
        lambda: self.admin_adapter.delete_group_realm_roles(group_id=group_id, roles=roles),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_composite_client_roles_of_group

get_composite_client_roles_of_group(
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get composite client roles of a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_composite_client_roles_of_group(
    self,
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get composite client roles of a group."""
    return self._call_keycloak(
        "get_composite_client_roles_of_group",
        lambda: self.admin_adapter.get_composite_client_roles_of_group(
            client_id=client_id,
            group_id=group_id,
            brief_representation=brief_representation,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_role_groups

get_client_role_groups(
    client_id: str, role_name: str, query: Any
) -> list[dict[str, Any]]

Get groups that have a specific client role.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_client_role_groups(self, client_id: str, role_name: str, query: Any) -> list[dict[str, Any]]:
    """Get groups that have a specific client role."""
    return self._call_keycloak(
        "get_client_role_groups",
        lambda: self.admin_adapter.get_client_role_groups(client_id=client_id, role_name=role_name, **query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_realm_role_groups

get_realm_role_groups(
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get groups that have a specific realm role.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
def get_realm_role_groups(
    self,
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get groups that have a specific realm role."""
    return self._call_keycloak(
        "get_realm_role_groups",
        lambda: self.admin_adapter.get_realm_role_groups(
            role_name=role_name,
            query=query,
            brief_representation=brief_representation,
        ),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_organizations

get_organizations(
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Fetch all organizations, optionally filtered by query parameters.

Parameters:

Name Type Description Default
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

List of organization representations.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def get_organizations(self, query: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Fetch all organizations, optionally filtered by query parameters.

    Args:
        query: Optional filter query parameters.

    Returns:
        List of organization representations.
    """
    return self._call_keycloak(
        "get_organizations",
        lambda: self.admin_adapter.get_organizations(query=query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_organization

get_organization(organization_id: str) -> dict[str, Any]

Get representation of the organization by ID.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
dict[str, Any]

Organization representation.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def get_organization(self, organization_id: str) -> dict[str, Any]:
    """Get representation of the organization by ID.

    Args:
        organization_id: Organization identifier.

    Returns:
        Organization representation.
    """
    return self._call_keycloak(
        "get_organization",
        lambda: self.admin_adapter.get_organization(organization_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_organization

create_organization(
    name: str, alias: str, **kwargs: Any
) -> str | None

Create a new organization. Name and alias must be unique.

Parameters:

Name Type Description Default
name str

Organization name.

required
alias str

Organization alias.

required
**kwargs Any

Additional organization attributes (snake_case mapped to camelCase).

{}

Returns:

Type Description
str | None

Created organization ID, or None.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def create_organization(self, name: str, alias: str, **kwargs: Any) -> str | None:
    """Create a new organization. Name and alias must be unique.

    Args:
        name: Organization name.
        alias: Organization alias.
        **kwargs: Additional organization attributes (snake_case mapped to camelCase).

    Returns:
        Created organization ID, or None.
    """
    payload = _organization_payload(name, alias, kwargs)
    return self._call_keycloak(
        "create_organization",
        lambda: self.admin_adapter.create_organization(payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_organization

update_organization(
    organization_id: str, **kwargs: Any
) -> dict[str, Any]

Update an existing organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required
**kwargs Any

Organization attributes to update (snake_case mapped to camelCase).

{}

Returns:

Type Description
dict[str, Any]

Update response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def update_organization(self, organization_id: str, **kwargs: Any) -> dict[str, Any]:
    """Update an existing organization.

    Args:
        organization_id: Organization identifier.
        **kwargs: Organization attributes to update (snake_case mapped to camelCase).

    Returns:
        Update response payload.
    """
    payload = _organization_update_payload(kwargs)
    return self._call_keycloak(
        "update_organization",
        lambda: self.admin_adapter.update_organization(organization_id=organization_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_organization

delete_organization(organization_id: str) -> dict[str, Any]

Delete an organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def delete_organization(self, organization_id: str) -> dict[str, Any]:
    """Delete an organization.

    Args:
        organization_id: Organization identifier.

    Returns:
        Deletion response payload.
    """
    return self._call_keycloak(
        "delete_organization",
        lambda: self.admin_adapter.delete_organization(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_organization_idps

get_organization_idps(
    organization_id: str,
) -> list[dict[str, Any]]

Get identity providers linked to an organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
list[dict[str, Any]]

List of identity provider representations.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def get_organization_idps(self, organization_id: str) -> list[dict[str, Any]]:
    """Get identity providers linked to an organization.

    Args:
        organization_id: Organization identifier.

    Returns:
        List of identity provider representations.
    """
    return self._call_keycloak(
        "get_organization_idps",
        lambda: self.admin_adapter.get_organization_idps(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_user_organizations

get_user_organizations(
    user_id: str,
) -> list[dict[str, Any]]

Get organizations by user id.

Parameters:

Name Type Description Default
user_id str

User identifier.

required

Returns:

Type Description
list[dict[str, Any]]

Organizations the user belongs to.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def get_user_organizations(self, user_id: str) -> list[dict[str, Any]]:
    """Get organizations by user id.

    Args:
        user_id: User identifier.

    Returns:
        Organizations the user belongs to.
    """
    return self._call_keycloak(
        "get_user_organizations",
        lambda: self.admin_adapter.get_user_organizations(user_id=user_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_organization_members

get_organization_members(
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get members by organization id, optionally filtered by query parameters.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

Member representations.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def get_organization_members(
    self,
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]:
    """Get members by organization id, optionally filtered by query parameters.

    Args:
        organization_id: Organization identifier.
        query: Optional filter query parameters.

    Returns:
        Member representations.
    """
    return self._call_keycloak(
        "get_organization_members",
        lambda: self.admin_adapter.get_organization_members(organization_id=organization_id, query=query),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_organization_members_count

get_organization_members_count(organization_id: str) -> int

Get the number of members in the organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
int

Member count.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def get_organization_members_count(self, organization_id: str) -> int:
    """Get the number of members in the organization.

    Args:
        organization_id: Organization identifier.

    Returns:
        Member count.
    """
    return self._call_keycloak(
        "get_organization_members_count",
        lambda: self.admin_adapter.get_organization_members_count(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.organization_user_add

organization_user_add(
    user_id: str, organization_id: str
) -> bytes

Add a user to an organization.

Parameters:

Name Type Description Default
user_id str

User identifier.

required
organization_id str

Organization identifier.

required

Returns:

Type Description
bytes

Raw response bytes.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def organization_user_add(self, user_id: str, organization_id: str) -> bytes:
    """Add a user to an organization.

    Args:
        user_id: User identifier.
        organization_id: Organization identifier.

    Returns:
        Raw response bytes.
    """
    return self._call_keycloak(
        "organization_user_add",
        lambda: self.admin_adapter.organization_user_add(user_id=user_id, organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.organization_user_remove

organization_user_remove(
    user_id: str, organization_id: str
) -> dict[str, Any]

Remove a user from an organization.

Parameters:

Name Type Description Default
user_id str

User identifier.

required
organization_id str

Organization identifier.

required

Returns:

Type Description
dict[str, Any]

Removal response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
def organization_user_remove(self, user_id: str, organization_id: str) -> dict[str, Any]:
    """Remove a user from an organization.

    Args:
        user_id: User identifier.
        organization_id: Organization identifier.

    Returns:
        Removal response payload.
    """
    return self._call_keycloak(
        "organization_user_remove",
        lambda: self.admin_adapter.organization_user_remove(user_id=user_id, organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_realm

create_realm(
    realm_name: str, skip_exists: bool = True, **kwargs: Any
) -> dict[str, Any] | None

Create a Keycloak realm with minimum required fields and optional additional config.

Parameters:

Name Type Description Default
realm_name str

The realm identifier (required)

required
skip_exists bool

Skip creation if realm already exists

True
kwargs Any

Additional optional configurations for the realm

{}

Returns:

Type Description
dict[str, Any] | None

Realm details

Source code in archipy/adapters/keycloak/adapter_mixins/realms.py
def create_realm(self, realm_name: str, skip_exists: bool = True, **kwargs: Any) -> dict[str, Any] | None:
    """Create a Keycloak realm with minimum required fields and optional additional config.

    Args:
        realm_name: The realm identifier (required)
        skip_exists: Skip creation if realm already exists
        kwargs: Additional optional configurations for the realm

    Returns:
        Realm details
    """
    payload = {
        "realm": realm_name,
        "enabled": kwargs.get("enabled", True),
        "displayName": kwargs.get("display_name", realm_name),
    }

    # Add any additional parameters from kwargs
    for key, value in kwargs.items():
        # Skip display_name as it's already handled
        if key == "display_name":
            continue

        # Convert Python snake_case to Keycloak camelCase
        camel_key = StringUtils.snake_to_camel_case(key)
        payload[camel_key] = value

    try:
        self.admin_adapter.create_realm(payload=payload, skip_exists=skip_exists)
    except KeycloakError as e:
        logger.debug("Failed to create realm: %s", e)

        # Handle realm already exists with skip_exists option
        if skip_exists:
            error_message = self._extract_error_message(e).lower()
            if "already exists" in error_message and "realm" in error_message:
                return {"realm": realm_name, "status": "already_exists", "config": payload}

        # Use the mixin to handle realm-specific errors
        self._handle_realm_exception(e, "create_realm", realm_name)
    else:
        return {"realm": realm_name, "status": "created", "config": payload}

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_realm

get_realm(realm_name: str) -> dict[str, Any] | None

Get realm details by realm name.

Parameters:

Name Type Description Default
realm_name str

Name of the realm

required

Returns:

Type Description
dict[str, Any] | None

Realm details

Source code in archipy/adapters/keycloak/adapter_mixins/realms.py
def get_realm(self, realm_name: str) -> dict[str, Any] | None:
    """Get realm details by realm name.

    Args:
        realm_name: Name of the realm

    Returns:
        Realm details
    """
    try:
        return self.admin_adapter.get_realm(realm_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_realm")

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_realm

update_realm(
    realm_name: str, **kwargs: Any
) -> dict[str, Any] | None

Update a realm. Kwargs are RealmRepresentation.

Parameters:

Name Type Description Default
realm_name str

Realm name (not the realm id).

required
**kwargs Any

RealmRepresentation attributes to update (e.g. displayName).

{}

Returns:

Type Description
dict[str, Any] | None

Response from Keycloak, or None on error (handled via exception).

Source code in archipy/adapters/keycloak/adapter_mixins/realms.py
def update_realm(self, realm_name: str, **kwargs: Any) -> dict[str, Any] | None:
    """Update a realm. Kwargs are RealmRepresentation.

    Args:
        realm_name: Realm name (not the realm id).
        **kwargs: RealmRepresentation attributes to update (e.g. displayName).

    Returns:
        Response from Keycloak, or None on error (handled via exception).
    """
    try:
        return self.admin_adapter.update_realm(realm_name, dict(kwargs))
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "update_realm")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_id

get_client_id(client_name: str) -> str | None

Get client ID by client name.

Parameters:

Name Type Description Default
client_name str

Name of the client

required

Returns:

Type Description
str | None

Client ID

Raises:

Type Description
ValueError

If client not found

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
@ttl_cache_decorator(ttl_seconds=3600, maxsize=50)  # Cache for 1 hour
def get_client_id(self, client_name: str) -> str | None:
    """Get client ID by client name.

    Args:
        client_name: Name of the client

    Returns:
        Client ID

    Raises:
        ValueError: If client not found
    """
    try:
        return self.admin_adapter.get_client_id(client_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_client_id")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_secret

get_client_secret(client_id: str) -> str | None

Get client secret.

Parameters:

Name Type Description Default
client_id str

Client ID

required

Returns:

Type Description
str | None

Client secret

Raises:

Type Description
ValueError

If getting secret fails

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
@ttl_cache_decorator(ttl_seconds=3600, maxsize=50)  # Cache for 1 hour
def get_client_secret(self, client_id: str) -> str | None:
    """Get client secret.

    Args:
        client_id: Client ID

    Returns:
        Client secret

    Raises:
        ValueError: If getting secret fails
    """
    try:
        client = self.admin_adapter.get_client(client_id)
        return client.get("secret", "")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_client_secret")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_service_account_id

get_service_account_id() -> str | None

Get service account user ID for the current client.

Returns:

Type Description
str | None

Service account user ID

Raises:

Type Description
ValueError

If getting service account fails

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
@ttl_cache_decorator(ttl_seconds=3600, maxsize=1)  # Cache for 1 hour
def get_service_account_id(self) -> str | None:
    """Get service account user ID for the current client.

    Returns:
        Service account user ID

    Raises:
        ValueError: If getting service account fails
    """
    try:
        client_id = self.get_client_id(self.configs.CLIENT_ID)
        return self.admin_adapter.get_client_service_account_user(str(client_id)).get("id")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_service_account_id")

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client

create_client(
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None

Create a Keycloak client with minimum required fields and optional additional config.

Parameters:

Name Type Description Default
client_id str

The client identifier (required)

required
realm str | None

Target realm name (uses the current realm in KeycloakAdmin if not specified)

None
skip_exists bool

Skip creation if client already exists

True
kwargs Any

Additional optional configurations for the client

{}

Returns:

Type Description
dict[str, Any] | None

Client details

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
def create_client(
    self,
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None:
    """Create a Keycloak client with minimum required fields and optional additional config.

    Args:
        client_id: The client identifier (required)
        realm: Target realm name (uses the current realm in KeycloakAdmin if not specified)
        skip_exists: Skip creation if client already exists
        kwargs: Additional optional configurations for the client

    Returns:
        Client details
    """
    original_realm = self.admin_adapter.connection.realm_name

    try:
        # Set the target realm if provided
        if realm and realm != original_realm:
            self.admin_adapter.connection.realm_name = realm

        public_client = kwargs.get("public_client", False)

        # Prepare the minimal client payload
        payload = {
            "clientId": client_id,
            "enabled": kwargs.get("enabled", True),
            "protocol": kwargs.get("protocol", "openid-connect"),
            "name": kwargs.get("name", client_id),
            "publicClient": public_client,
        }

        # Enable service accounts for confidential clients by default
        if not public_client:
            payload["serviceAccountsEnabled"] = kwargs.get("service_account_enabled", True)
            payload["clientAuthenticatorType"] = "client-secret"

        for key, value in kwargs.items():
            if key in ["enabled", "protocol", "name", "public_client", "service_account_enabled"]:
                continue

            # Convert snake_case to camelCase
            camel_key = StringUtils.snake_to_camel_case(key)
            payload[camel_key] = value

        internal_client_id = None
        try:
            internal_client_id = self.admin_adapter.create_client(payload, skip_exists=skip_exists)
        except KeycloakError as e:
            logger.debug("Failed to create client: %s", e)

            # Handle client already exists with skip_exists option
            if skip_exists:
                error_message = self._extract_error_message(e).lower()
                if "already exists" in error_message and "client" in error_message:
                    return {
                        "client_id": client_id,
                        "status": "already_exists",
                        "realm": self.admin_adapter.connection.realm_name,
                    }

            # Use the mixin to handle client-specific errors
            client_data = {"clientId": client_id, "name": kwargs.get("name", client_id)}
            self._handle_client_exception(e, "create_client", client_data)

        return {
            "client_id": client_id,
            "internal_client_id": internal_client_id,
            "realm": self.admin_adapter.connection.realm_name,
            "status": "created",
        }

    finally:
        # Always restore the original realm
        if realm and realm != original_realm:
            self.admin_adapter.connection.realm_name = original_realm

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_user_roles

get_user_roles(
    user_id: str,
) -> list[KeycloakRoleType] | None

Get roles assigned to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required

Returns:

Type Description
list[KeycloakRoleType] | None

List of roles

Raises:

Type Description
ValueError

If getting roles fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=100)  # Cache for 5 minutes
def get_user_roles(self, user_id: str) -> list[KeycloakRoleType] | None:
    """Get roles assigned to a user.

    Args:
        user_id: User's ID

    Returns:
        List of roles

    Raises:
        ValueError: If getting roles fails
    """
    try:
        return self.admin_adapter.get_realm_roles_of_user(user_id)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_roles")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_roles_for_user

get_client_roles_for_user(
    user_id: str, client_id: str
) -> list[KeycloakRoleType]

Get client-specific roles assigned to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
client_id str

Client ID

required

Returns:

Type Description
list[KeycloakRoleType]

List of client-specific roles

Raises:

Type Description
ValueError

If getting roles fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=100)  # Cache for 5 minutes
def get_client_roles_for_user(self, user_id: str, client_id: str) -> list[KeycloakRoleType]:
    """Get client-specific roles assigned to a user.

    Args:
        user_id: User's ID
        client_id: Client ID

    Returns:
        List of client-specific roles

    Raises:
        ValueError: If getting roles fails
    """
    try:
        return self.admin_adapter.get_client_roles_of_user(user_id, client_id)
    except KeycloakError as e:
        raise InternalError() from e

archipy.adapters.keycloak.adapters.KeycloakAdapter.has_role

has_role(token: str, role_name: str) -> bool

Check if a user has a specific role.

Parameters:

Name Type Description Default
token str

Access token

required
role_name str

Role name to check

required

Returns:

Type Description
bool

True if user has the role, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def has_role(self, token: str, role_name: str) -> bool:
    """Check if a user has a specific role.

    Args:
        token: Access token
        role_name: Role name to check

    Returns:
        True if user has the role, False otherwise
    """
    # Not caching this result as token validation is time-sensitive
    try:
        user_info = self.get_userinfo(token)
        if not user_info:
            return False

        # Check realm roles
        realm_access = user_info.get("realm_access", {})
        roles = realm_access.get("roles", [])
        if role_name in roles:
            return True

        # Check client roles
        resource_access = user_info.get("resource_access", {})
        client_roles = resource_access.get(self.configs.CLIENT_ID, {}).get("roles", [])
        if role_name in client_roles:
            return True

    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Role check failed: %s", e)
        return False
    else:
        return False

archipy.adapters.keycloak.adapters.KeycloakAdapter.has_any_of_roles

has_any_of_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has any of the specified roles.

Parameters:

Name Type Description Default
token str

Access token

required
role_names frozenset[str]

Set of role names to check

required

Returns:

Type Description
bool

True if user has any of the roles, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def has_any_of_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has any of the specified roles.

    Args:
        token: Access token
        role_names: Set of role names to check

    Returns:
        True if user has any of the roles, False otherwise
    """
    try:
        user_info = self.get_userinfo(token)
        if not user_info:
            return False

        # Check realm roles first
        realm_access = user_info.get("realm_access", {})
        realm_roles = set(realm_access.get("roles", []))
        if role_names.intersection(realm_roles):
            return True

        # Check roles for the configured client
        resource_access = user_info.get("resource_access", {})
        client_roles = set(resource_access.get(self.configs.CLIENT_ID, {}).get("roles", []))
        if role_names.intersection(client_roles):
            return True

    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Role check failed: %s", e)
        return False
    else:
        return False

archipy.adapters.keycloak.adapters.KeycloakAdapter.has_all_roles

has_all_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has all the specified roles.

Parameters:

Name Type Description Default
token str

Access token

required
role_names frozenset[str]

Set of role names to check

required

Returns:

Type Description
bool

True if user has all the roles, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def has_all_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has all the specified roles.

    Args:
        token: Access token
        role_names: Set of role names to check

    Returns:
        True if user has all the roles, False otherwise
    """
    try:
        user_info = self.get_userinfo(token)
        if not user_info:
            return False

        # Get all user roles
        all_roles = set()

        # Add realm roles
        realm_access = user_info.get("realm_access", {})
        all_roles.update(realm_access.get("roles", []))

        # Add client roles
        resource_access = user_info.get("resource_access", {})
        client_roles = resource_access.get(self.configs.CLIENT_ID, {}).get("roles", [])
        all_roles.update(client_roles)

        # Check if all required roles are present
        return role_names.issubset(all_roles)

    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("All roles check failed: %s", e)
        return False

archipy.adapters.keycloak.adapters.KeycloakAdapter.assign_realm_role

assign_realm_role(user_id: str, role_name: str) -> None

Assign a realm role to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
role_name str

Role name to assign

required

Raises:

Type Description
ValueError

If role assignment fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def assign_realm_role(self, user_id: str, role_name: str) -> None:
    """Assign a realm role to a user.

    Args:
        user_id: User's ID
        role_name: Role name to assign

    Raises:
        ValueError: If role assignment fails
    """
    # This is a write operation, no caching needed
    try:
        # Get role representation
        role = self.admin_adapter.get_realm_role(role_name)
        # Assign role to user
        self.admin_adapter.assign_realm_roles(user_id, [role])

        # Clear role-related caches
        if hasattr(self.get_user_roles, "clear_cache"):
            self.get_user_roles.clear_cache()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "assign_realm_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.remove_realm_role

remove_realm_role(user_id: str, role_name: str) -> None

Remove a realm role from a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
role_name str

Role name to remove

required

Raises:

Type Description
ValueError

If role removal fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def remove_realm_role(self, user_id: str, role_name: str) -> None:
    """Remove a realm role from a user.

    Args:
        user_id: User's ID
        role_name: Role name to remove

    Raises:
        ValueError: If role removal fails
    """
    # This is a write operation, no caching needed
    try:
        # Get role representation
        role = self.admin_adapter.get_realm_role(role_name)
        # Remove role from user
        self.admin_adapter.delete_realm_roles_of_user(user_id, [role])

        # Clear role-related caches
        if hasattr(self.get_user_roles, "clear_cache"):
            self.get_user_roles.clear_cache()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "remove_realm_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.assign_client_role

assign_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Assign a client-specific role to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
client_id str

Client ID

required
role_name str

Role name to assign

required

Raises:

Type Description
ValueError

If role assignment fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def assign_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Assign a client-specific role to a user.

    Args:
        user_id: User's ID
        client_id: Client ID
        role_name: Role name to assign

    Raises:
        ValueError: If role assignment fails
    """
    # This is a write operation, no caching needed
    try:
        # Get client
        client = self.admin_adapter.get_client_id(client_id)
        if client is None:
            raise InternalError(error_code="KEYCLOAK_CLIENT_ID_NONE")
        # Get role representation
        # Keycloak admin adapter methods accept these types at runtime
        role = self.admin_adapter.get_client_role(client, role_name)
        # Assign role to user
        self.admin_adapter.assign_client_role(user_id, client, [role])

        # Clear role-related caches
        if hasattr(self.get_client_roles_for_user, "clear_cache"):
            self.get_client_roles_for_user.clear_cache()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "assign_client_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.remove_client_role

remove_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Remove a client-specific role from a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
client_id str

Client ID

required
role_name str

Role name to remove

required

Raises:

Type Description
ValueError

If role removal fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def remove_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Remove a client-specific role from a user.

    Args:
        user_id: User's ID
        client_id: Client ID
        role_name: Role name to remove

    Raises:
        ValueError: If role removal fails
    """
    try:
        client = self.admin_adapter.get_client_id(client_id)
        if client is None:
            raise InternalError(error_code="KEYCLOAK_CLIENT_ID_NONE")
        # Keycloak admin adapter methods accept these types at runtime
        role = self.admin_adapter.get_client_role(client, role_name)
        self.admin_adapter.delete_client_roles_of_user(user_id, client, [role])

        if hasattr(self.get_client_roles_for_user, "clear_cache"):
            self.get_client_roles_for_user.clear_cache()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "remove_client_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_realm_role

get_realm_role(role_name: str) -> dict | None

Get realm role.

Parameters:

Name Type Description Default
role_name str

Role name

required

Returns: A realm role

Raises:

Type Description
ValueError

If getting role fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=1)  # Cache for 5 minutes
def get_realm_role(self, role_name: str) -> dict | None:
    """Get realm role.

    Args:
        role_name: Role name
    Returns:
        A realm role

    Raises:
        ValueError: If getting role fails
    """
    try:
        return self.admin_adapter.get_realm_role(role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_realm_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_realm_roles

get_realm_roles() -> list[dict[str, Any]] | None

Get all realm roles.

Returns:

Type Description
list[dict[str, Any]] | None

List of realm roles

Raises:

Type Description
ValueError

If getting roles fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=1)  # Cache for 5 minutes
def get_realm_roles(self) -> list[dict[str, Any]] | None:
    """Get all realm roles.

    Returns:
        List of realm roles

    Raises:
        ValueError: If getting roles fails
    """
    try:
        return self.admin_adapter.get_realm_roles()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_realm_roles")

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_realm_role

create_realm_role(
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new realm role.

Parameters:

Name Type Description Default
role_name str

Role name

required
description str | None

Optional role description

None
skip_exists bool

Skip creation if realm role already exists

True

Returns:

Type Description
dict[str, Any] | None

Created role details

Raises:

Type Description
ValueError

If role creation fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def create_realm_role(
    self,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new realm role.

    Args:
        role_name: Role name
        description: Optional role description
        skip_exists: Skip creation if realm role already exists

    Returns:
        Created role details

    Raises:
        ValueError: If role creation fails
    """
    # This is a write operation, no caching needed
    try:
        role_data = {"name": role_name}
        if description:
            role_data["description"] = description

        self.admin_adapter.create_realm_role(role_data, skip_exists=skip_exists)

        # Clear realm roles cache
        if hasattr(self.get_realm_roles, "clear_cache"):
            self.get_realm_roles.clear_cache()

        return self.admin_adapter.get_realm_role(role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "create_realm_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_realm_role

delete_realm_role(role_name: str) -> None

Delete a realm role.

Parameters:

Name Type Description Default
role_name str

Role name to delete

required

Raises:

Type Description
ValueError

If role deletion fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def delete_realm_role(self, role_name: str) -> None:
    """Delete a realm role.

    Args:
        role_name: Role name to delete

    Raises:
        ValueError: If role deletion fails
    """
    # This is a write operation, no caching needed
    try:
        self.admin_adapter.delete_realm_role(role_name)

        # Clear realm roles cache
        if hasattr(self.get_realm_roles, "clear_cache"):
            self.get_realm_roles.clear_cache()

        # We also need to clear user role caches since they might contain this role
        if hasattr(self.get_user_roles, "clear_cache"):
            self.get_user_roles.clear_cache()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "delete_realm_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_client_role

create_client_role(
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new client role.

Parameters:

Name Type Description Default
client_id str

Client ID or client name

required
role_name str

Role name

required
description str | None

Optional role description

None
skip_exists bool

Skip creation if client role already exists

True

Returns:

Type Description
dict[str, Any] | None

Created role details

Raises:

Type Description
ValueError

If role creation fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def create_client_role(
    self,
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new client role.

    Args:
        client_id: Client ID or client name
        role_name: Role name
        description: Optional role description
        skip_exists: Skip creation if client role already exists

    Returns:
        Created role details

    Raises:
        ValueError: If role creation fails
    """
    # This is a write operation, no caching needed
    try:
        resolved_client_id = self.admin_adapter.get_client_id(client_id)
        if resolved_client_id is None:
            raise NotFoundError(
                resource_type="keycloak_client",
                additional_data={"client_id": client_id},
            )

        # Prepare role data
        role_data = {"name": role_name}
        if description:
            role_data["description"] = description

        # Create client role
        self.admin_adapter.create_client_role(resolved_client_id, role_data, skip_exists=skip_exists)

        # Clear related caches if they exist
        if hasattr(self.get_client_roles_for_user, "clear_cache"):
            self.get_client_roles_for_user.clear_cache()

        # Return created role
        return self.admin_adapter.get_client_role(resolved_client_id, role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "create_client_role")

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_realm_roles_to_composite

add_realm_roles_to_composite(
    composite_role_name: str, child_role_names: list[str]
) -> None

Add realm roles to a composite role.

Parameters:

Name Type Description Default
composite_role_name str

Name of the composite realm role

required
child_role_names list[str]

List of child role names to add

required
Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def add_realm_roles_to_composite(self, composite_role_name: str, child_role_names: list[str]) -> None:
    """Add realm roles to a composite role.

    Args:
        composite_role_name: Name of the composite realm role
        child_role_names: List of child role names to add
    """
    try:
        child_roles = []
        for role_name in child_role_names:
            try:
                role = self.admin_adapter.get_realm_role(role_name)
                child_roles.append(role)
            except KeycloakGetError as e:
                if e.response_code == HTTP_NOT_FOUND:
                    logger.warning("Child role not found: %s", role_name)
                    continue
                raise

        if child_roles:
            self.admin_adapter.add_composite_realm_roles_to_role(role_name=composite_role_name, roles=child_roles)
            logger.info("Added %s realm roles to composite role: %s", len(child_roles), composite_role_name)

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "add_realm_roles_to_composite")

archipy.adapters.keycloak.adapters.KeycloakAdapter.add_client_roles_to_composite

add_client_roles_to_composite(
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None

Add client roles to a composite role.

Parameters:

Name Type Description Default
composite_role_name str

Name of the composite client role

required
client_id str

Client ID or client name

required
child_role_names list[str]

List of child role names to add

required
Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def add_client_roles_to_composite(
    self,
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None:
    """Add client roles to a composite role.

    Args:
        composite_role_name: Name of the composite client role
        client_id: Client ID or client name
        child_role_names: List of child role names to add
    """
    try:
        internal_client_id = self.admin_adapter.get_client_id(client_id)
        if internal_client_id is None:
            raise InternalError(error_code="KEYCLOAK_CLIENT_ID_NONE")

        child_roles = []
        for role_name in child_role_names:
            try:
                # Keycloak admin adapter methods accept these types at runtime
                role = self.admin_adapter.get_client_role(internal_client_id, role_name)
                child_roles.append(role)
            except KeycloakGetError as e:
                if e.response_code == HTTP_NOT_FOUND:
                    logger.warning("Client role not found: %s", role_name)
                    continue
                raise

        if child_roles:
            if internal_client_id is None:
                raise NotFoundError(resource_type="keycloak_client")
            resolved_client_id: str = internal_client_id
            self.admin_adapter.add_composite_client_roles_to_role(
                role_name=composite_role_name,
                client_role_id=resolved_client_id,
                roles=child_roles,
            )
            logger.info("Added %s client roles to composite role: %s", len(child_roles), composite_role_name)

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "add_client_roles_to_composite")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_composite_realm_roles

get_composite_realm_roles(
    role_name: str,
) -> list[dict[str, Any]] | None

Get composite roles for a realm role.

Parameters:

Name Type Description Default
role_name str

Name of the role

required

Returns:

Type Description
list[dict[str, Any]] | None

List of composite roles

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
def get_composite_realm_roles(self, role_name: str) -> list[dict[str, Any]] | None:
    """Get composite roles for a realm role.

    Args:
        role_name: Name of the role

    Returns:
        List of composite roles
    """
    try:
        return self.admin_adapter.get_composite_realm_roles_of_role(role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_composite_realm_roles")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_user_by_id

get_user_by_id(user_id: str) -> KeycloakUserType | None

Get user details by user ID.

Parameters:

Name Type Description Default
user_id str

User's ID

required

Returns:

Type Description
KeycloakUserType | None

User details or None if not found

Raises:

Type Description
ValueError

If getting user fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=100)  # Cache for 5 minutes
def get_user_by_id(self, user_id: str) -> KeycloakUserType | None:
    """Get user details by user ID.

    Args:
        user_id: User's ID

    Returns:
        User details or None if not found

    Raises:
        ValueError: If getting user fails
    """
    try:
        return self.admin_adapter.get_user(user_id)
    except KeycloakGetError as e:
        if e.response_code == HTTP_NOT_FOUND:
            return None
        self._handle_keycloak_exception(e, "get_user_by_id")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_by_id")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_user_by_username

get_user_by_username(
    username: str,
) -> KeycloakUserType | None

Get user details by username.

Parameters:

Name Type Description Default
username str

User's username

required

Returns:

Type Description
KeycloakUserType | None

User details or None if not found

Raises:

Type Description
ValueError

If query fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=100)  # Cache for 5 minutes
def get_user_by_username(self, username: str) -> KeycloakUserType | None:
    """Get user details by username.

    Args:
        username: User's username

    Returns:
        User details or None if not found

    Raises:
        ValueError: If query fails
    """
    try:
        users = self.admin_adapter.get_users({"username": username})
        return users[0] if users else None
    except KeycloakError as e:
        raise InternalError() from e

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_user_by_email

get_user_by_email(email: str) -> KeycloakUserType | None

Get user details by email.

Parameters:

Name Type Description Default
email str

User's email

required

Returns:

Type Description
KeycloakUserType | None

User details or None if not found

Raises:

Type Description
ValueError

If query fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@ttl_cache_decorator(ttl_seconds=300, maxsize=100)  # Cache for 5 minutes
def get_user_by_email(self, email: str) -> KeycloakUserType | None:
    """Get user details by email.

    Args:
        email: User's email

    Returns:
        User details or None if not found

    Raises:
        ValueError: If query fails
    """
    try:
        users = self.admin_adapter.get_users({"email": email})
        return users[0] if users else None
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_by_email")

archipy.adapters.keycloak.adapters.KeycloakAdapter.create_user

create_user(user_data: dict[str, Any]) -> str | None

Create a new user in Keycloak.

Parameters:

Name Type Description Default
user_data dict[str, Any]

User data including username, email, etc.

required

Returns:

Type Description
str | None

ID of the created user

Raises:

Type Description
ValueError

If creating user fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
def create_user(self, user_data: dict[str, Any]) -> str | None:
    """Create a new user in Keycloak.

    Args:
        user_data: User data including username, email, etc.

    Returns:
        ID of the created user

    Raises:
        ValueError: If creating user fails
    """
    # This is a write operation, no caching needed
    try:
        user_id = self.admin_adapter.create_user(user_data)

        # Clear related caches
        self.clear_all_caches()

    except KeycloakError as e:
        self._handle_user_exception(e, "create_user", user_data)
    else:
        return user_id

archipy.adapters.keycloak.adapters.KeycloakAdapter.update_user

update_user(
    user_id: str, user_data: dict[str, Any]
) -> None

Update user details.

Parameters:

Name Type Description Default
user_id str

User's ID

required
user_data dict[str, Any]

User data to update

required

Raises:

Type Description
ValueError

If updating user fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
def update_user(self, user_id: str, user_data: dict[str, Any]) -> None:
    """Update user details.

    Args:
        user_id: User's ID
        user_data: User data to update

    Raises:
        ValueError: If updating user fails
    """
    # This is a write operation, no caching needed
    try:
        self.admin_adapter.update_user(user_id, user_data)

        # Clear user-related caches
        self.clear_all_caches()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "update_user")

archipy.adapters.keycloak.adapters.KeycloakAdapter.reset_password

reset_password(
    user_id: str, password: str, temporary: bool = False
) -> None

Reset a user's password.

Parameters:

Name Type Description Default
user_id str

User's ID

required
password str

New password

required
temporary bool

Whether the password is temporary and should be changed on next login

False

Raises:

Type Description
ValueError

If password reset fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
def reset_password(self, user_id: str, password: str, temporary: bool = False) -> None:
    """Reset a user's password.

    Args:
        user_id: User's ID
        password: New password
        temporary: Whether the password is temporary and should be changed on next login

    Raises:
        ValueError: If password reset fails
    """
    # This is a write operation, no caching needed
    try:
        self.admin_adapter.set_user_password(user_id, password, temporary)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "reset_password")

archipy.adapters.keycloak.adapters.KeycloakAdapter.search_users

search_users(
    query: str, max_results: int = 100
) -> list[KeycloakUserType] | None

Search for users by username, email, or name.

Parameters:

Name Type Description Default
query str

Search query

required
max_results int

Maximum number of results to return

100

Returns:

Type Description
list[KeycloakUserType] | None

List of matching users

Raises:

Type Description
ValueError

If search fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@ttl_cache_decorator(ttl_seconds=30, maxsize=50)  # Cache for 30 seconds with limited entries
def search_users(self, query: str, max_results: int = 100) -> list[KeycloakUserType] | None:
    """Search for users by username, email, or name.

    Args:
        query: Search query
        max_results: Maximum number of results to return

    Returns:
        List of matching users

    Raises:
        ValueError: If search fails
    """
    try:
        # Try searching by different fields
        users = []

        # Search by username
        users.extend(self.admin_adapter.get_users({"username": query, "max": max_results}))

        # Search by email if no results or incomplete results
        if len(users) < max_results:
            remaining = max_results - len(users)
            email_users = self.admin_adapter.get_users({"email": query, "max": remaining})
            # Filter out duplicates
            user_ids = {user["id"] for user in users}
            users.extend([user for user in email_users if user["id"] not in user_ids])

        # Search by firstName if no results or incomplete results
        if len(users) < max_results:
            remaining = max_results - len(users)
            first_name_users = self.admin_adapter.get_users({"firstName": query, "max": remaining})
            # Filter out duplicates
            user_ids = {user["id"] for user in users}
            users.extend([user for user in first_name_users if user["id"] not in user_ids])

        # Search by lastName if no results or incomplete results
        if len(users) < max_results:
            remaining = max_results - len(users)
            last_name_users = self.admin_adapter.get_users({"lastName": query, "max": remaining})
            # Filter out duplicates
            user_ids = {user["id"] for user in users}
            users.extend([user for user in last_name_users if user["id"] not in user_ids])

        return users[:max_results]
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "search_users")

archipy.adapters.keycloak.adapters.KeycloakAdapter.clear_user_sessions

clear_user_sessions(user_id: str) -> None

Clear all sessions for a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required

Raises:

Type Description
ValueError

If clearing sessions fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
def clear_user_sessions(self, user_id: str) -> None:
    """Clear all sessions for a user.

    Args:
        user_id: User's ID

    Raises:
        ValueError: If clearing sessions fails
    """
    try:
        self.admin_adapter.user_logout(user_id)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "clear_user_sessions")

archipy.adapters.keycloak.adapters.KeycloakAdapter.delete_user

delete_user(user_id: str) -> None

Delete a user from Keycloak by their ID.

Parameters:

Name Type Description Default
user_id str

The ID of the user to delete

required

Raises:

Type Description
ValueError

If the deletion fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
def delete_user(self, user_id: str) -> None:
    """Delete a user from Keycloak by their ID.

    Args:
        user_id: The ID of the user to delete

    Raises:
        ValueError: If the deletion fails
    """
    try:
        self.admin_adapter.delete_user(user_id=user_id)

        if hasattr(self.get_user_by_username, "clear_cache"):
            self.get_user_by_username.clear_cache()

        logger.info("Successfully deleted user with ID %s", user_id)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "delete_user")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_token

get_token(
    username: str, password: str
) -> KeycloakTokenType | None

Get a user token by username and password using the Resource Owner Password Credentials Grant.

Warning

This method uses the direct password grant flow, which is less secure and not recommended for user login in production environments. Instead, prefer the web-based OAuth 2.0 Authorization Code Flow (use get_token_from_code) for secure authentication. Use this method only for testing, administrative tasks, or specific service accounts where direct credential use is acceptable and properly secured.

Parameters:

Name Type Description Default
username str

User's username

required
password str

User's password

required

Returns:

Type Description
KeycloakTokenType | None

Token response containing access_token, refresh_token, etc.

Raises:

Type Description
InvalidCredentialsError

If username or password is invalid

ServiceUnavailableError

If Keycloak service is unavailable

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def get_token(self, username: str, password: str) -> KeycloakTokenType | None:
    """Get a user token by username and password using the Resource Owner Password Credentials Grant.

    Warning:
        This method uses the direct password grant flow, which is less secure and not recommended
        for user login in production environments. Instead, prefer the web-based OAuth 2.0
        Authorization Code Flow (use `get_token_from_code`) for secure authentication.
        Use this method only for testing, administrative tasks, or specific service accounts
        where direct credential use is acceptable and properly secured.

    Args:
        username: User's username
        password: User's password

    Returns:
        Token response containing access_token, refresh_token, etc.

    Raises:
        InvalidCredentialsError: If username or password is invalid
        ServiceUnavailableError: If Keycloak service is unavailable
    """
    try:
        return self._openid_adapter.token(grant_type="password", username=username, password=password)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_token")

archipy.adapters.keycloak.adapters.KeycloakAdapter.refresh_token

refresh_token(
    refresh_token: str,
) -> KeycloakTokenType | None

Refresh an existing token using a refresh token.

Parameters:

Name Type Description Default
refresh_token str

Refresh token string

required

Returns:

Type Description
KeycloakTokenType | None

New token response containing access_token, refresh_token, etc.

Raises:

Type Description
InvalidTokenError

If refresh token is invalid or expired

ServiceUnavailableError

If Keycloak service is unavailable

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def refresh_token(self, refresh_token: str) -> KeycloakTokenType | None:
    """Refresh an existing token using a refresh token.

    Args:
        refresh_token: Refresh token string

    Returns:
        New token response containing access_token, refresh_token, etc.

    Raises:
        InvalidTokenError: If refresh token is invalid or expired
        ServiceUnavailableError: If Keycloak service is unavailable
    """
    try:
        return self._openid_adapter.refresh_token(refresh_token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "refresh_token")

archipy.adapters.keycloak.adapters.KeycloakAdapter.validate_token

validate_token(token: str) -> bool

Validate if a token is still valid.

Parameters:

Name Type Description Default
token str

Access token to validate

required

Returns:

Type Description
bool

True if token is valid, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def validate_token(self, token: str) -> bool:
    """Validate if a token is still valid.

    Args:
        token: Access token to validate

    Returns:
        True if token is valid, False otherwise
    """
    # Not caching validation results as tokens are time-sensitive
    try:
        # Let the underlying adapter handle key selection to align with expected types
        self._openid_adapter.decode_token(token)
    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Token validation failed: %s", e)
        return False
    else:
        return True

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_userinfo

get_userinfo(token: str) -> KeycloakUserType | None

Get user information from a token via the UserInfo endpoint.

The UserInfo endpoint validates the token server-side, so no local validation is needed here.

Parameters:

Name Type Description Default
token str

Access token

required

Returns:

Type Description
KeycloakUserType | None

User information

Raises:

Type Description
ValueError

If getting user info fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def get_userinfo(self, token: str) -> KeycloakUserType | None:
    """Get user information from a token via the UserInfo endpoint.

    The UserInfo endpoint validates the token server-side, so no local
    validation is needed here.

    Args:
        token: Access token

    Returns:
        User information

    Raises:
        ValueError: If getting user info fails
    """
    try:
        # _get_userinfo_cached returns KeycloakUserType (dict[str, Any])
        # The ttl_cache_decorator loses type info, but runtime behavior is correct
        # Access underlying function for proper typing
        cached_func = self._get_userinfo_cached
        underlying_func = getattr(cached_func, "__wrapped__", None)
        if underlying_func is not None:
            # Call underlying function directly for type checking
            result: KeycloakUserType = underlying_func(self, token)
        else:
            # Fallback to cached version if __wrapped__ not available
            result_raw = cached_func(token)
            if not isinstance(result_raw, dict):
                return None
            # Type assertion: result_raw is a dict, which matches KeycloakUserType
            # Convert to proper type by creating a new dict with explicit typing
            result: KeycloakUserType = {str(k): v for k, v in result_raw.items()}
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_userinfo")
        return None
    else:
        return result

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_token_info

get_token_info(token: str) -> dict[str, Any] | None

Decode token to get its claims.

Parameters:

Name Type Description Default
token str

Access token

required

Returns:

Type Description
dict[str, Any] | None

Dictionary of token claims

Raises:

Type Description
ValueError

If token decoding fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def get_token_info(self, token: str) -> dict[str, Any] | None:
    """Decode token to get its claims.

    Args:
        token: Access token

    Returns:
        Dictionary of token claims

    Raises:
        ValueError: If token decoding fails
    """
    try:
        # Let the underlying adapter handle key selection to align with expected types
        return self._openid_adapter.decode_token(token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_token_info")

archipy.adapters.keycloak.adapters.KeycloakAdapter.introspect_token

introspect_token(token: str) -> dict[str, Any] | None

Introspect token to get detailed information about it.

Parameters:

Name Type Description Default
token str

Access token

required

Returns:

Type Description
dict[str, Any] | None

Token introspection details

Raises:

Type Description
ValueError

If token introspection fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def introspect_token(self, token: str) -> dict[str, Any] | None:
    """Introspect token to get detailed information about it.

    Args:
        token: Access token

    Returns:
        Token introspection details

    Raises:
        ValueError: If token introspection fails
    """
    try:
        return self._openid_adapter.introspect(token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "introspect_token")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_client_credentials_token

get_client_credentials_token() -> KeycloakTokenType | None

Get token using client credentials.

Returns:

Type Description
KeycloakTokenType | None

Token response

Raises:

Type Description
ValueError

If token acquisition fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def get_client_credentials_token(self) -> KeycloakTokenType | None:
    """Get token using client credentials.

    Returns:
        Token response

    Raises:
        ValueError: If token acquisition fails
    """
    # Tokens are time-sensitive, don't cache
    try:
        return self._openid_adapter.token(grant_type="client_credentials")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_client_credentials_token")

archipy.adapters.keycloak.adapters.KeycloakAdapter.logout

logout(refresh_token: str) -> None

Logout user by invalidating their refresh token.

Parameters:

Name Type Description Default
refresh_token str

Refresh token to invalidate

required

Raises:

Type Description
ValueError

If logout fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def logout(self, refresh_token: str) -> None:
    """Logout user by invalidating their refresh token.

    Args:
        refresh_token: Refresh token to invalidate

    Raises:
        ValueError: If logout fails
    """
    try:
        self._openid_adapter.logout(refresh_token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "logout")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_public_key

get_public_key() -> PublicKeyType

Get the public key used to verify tokens.

Returns:

Type Description
PublicKeyType

JWK key object used to verify signatures

Raises:

Type Description
ServiceUnavailableError

If Keycloak service is unavailable

InternalError

If there's an internal error processing the public key

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@ttl_cache_decorator(ttl_seconds=3600, maxsize=1)  # Cache for 1 hour, public key rarely changes
def get_public_key(self) -> PublicKeyType:
    """Get the public key used to verify tokens.

    Returns:
        JWK key object used to verify signatures

    Raises:
        ServiceUnavailableError: If Keycloak service is unavailable
        InternalError: If there's an internal error processing the public key
    """
    try:
        keys_info = self._openid_adapter.public_key()
        key = f"-----BEGIN PUBLIC KEY-----\n{keys_info}\n-----END PUBLIC KEY-----"
        return jwk.JWK.from_pem(key.encode("utf-8"))
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_public_key")
    except Exception as e:  # soft-fail authz/role checks; JWT/Keycloak libs
        raise InternalError(additional_data={"operation": "get_public_key", "error": str(e)}) from e

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_well_known_config

get_well_known_config() -> dict[str, Any] | None

Get the well-known OpenID configuration.

Returns:

Type Description
dict[str, Any] | None

OIDC configuration

Raises:

Type Description
ValueError

If getting configuration fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@ttl_cache_decorator(ttl_seconds=3600, maxsize=1)  # Cache for 1 hour
def get_well_known_config(self) -> dict[str, Any] | None:
    """Get the well-known OpenID configuration.

    Returns:
        OIDC configuration

    Raises:
        ValueError: If getting configuration fails
    """
    try:
        return self._openid_adapter.well_known()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_well_known_config")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_certs

get_certs() -> dict[str, Any] | None

Get the JWT verification certificates.

Returns:

Type Description
dict[str, Any] | None

Certificate information

Raises:

Type Description
ValueError

If getting certificates fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@ttl_cache_decorator(ttl_seconds=3600, maxsize=1)  # Cache for 1 hour
def get_certs(self) -> dict[str, Any] | None:
    """Get the JWT verification certificates.

    Returns:
        Certificate information

    Raises:
        ValueError: If getting certificates fails
    """
    try:
        return self._openid_adapter.certs()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_certs")

archipy.adapters.keycloak.adapters.KeycloakAdapter.get_token_from_code

get_token_from_code(
    code: str, redirect_uri: str
) -> KeycloakTokenType | None

Exchange authorization code for token.

Parameters:

Name Type Description Default
code str

Authorization code

required
redirect_uri str

Redirect URI used in authorization request

required

Returns:

Type Description
KeycloakTokenType | None

Token response

Raises:

Type Description
ValueError

If token exchange fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def get_token_from_code(self, code: str, redirect_uri: str) -> KeycloakTokenType | None:
    """Exchange authorization code for token.

    Args:
        code: Authorization code
        redirect_uri: Redirect URI used in authorization request

    Returns:
        Token response

    Raises:
        ValueError: If token exchange fails
    """
    # Authorization codes can only be used once, don't cache
    try:
        return self._openid_adapter.token(grant_type="authorization_code", code=code, redirect_uri=redirect_uri)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_token_from_code")

archipy.adapters.keycloak.adapters.KeycloakAdapter.check_permissions

check_permissions(
    token: str, resource: str, scope: str
) -> bool

Check if a user has permission to access a resource with the specified scope.

Prefer :meth:check_permissions_batch when checking multiple pairs per request.

Parameters:

Name Type Description Default
token str

Access token

required
resource str

Resource name

required
scope str

Permission scope

required

Returns:

Type Description
bool

True if permission granted, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
def check_permissions(self, token: str, resource: str, scope: str) -> bool:
    """Check if a user has permission to access a resource with the specified scope.

    Prefer :meth:`check_permissions_batch` when checking multiple pairs per request.

    Args:
        token: Access token
        resource: Resource name
        scope: Permission scope

    Returns:
        True if permission granted, False otherwise
    """
    try:
        # Use UMA permissions endpoint to check specific resource and scope
        permissions = self._openid_adapter.uma_permissions(token, permissions=f"{resource}#{scope}")

        # Check if the response indicates permission is granted
        if not permissions or not isinstance(permissions, list):
            logger.debug("No permissions returned or invalid response format")
            return False

        # Look for the specific permission in the response
        for perm in permissions:
            if perm.get("rsname") == resource and scope in perm.get("scopes", []):
                return True

    except KeycloakError as e:
        logger.debug("Permission check failed with Keycloak error: %s", e)
        return False
    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Permission check failed with unexpected error: %s", e)
        return False
    else:
        return False

archipy.adapters.keycloak.adapters.KeycloakAdapter.check_permissions_batch

check_permissions_batch(
    token: str, permissions: tuple[tuple[str, str], ...]
) -> frozenset[tuple[str, str]]

Return the subset of (resource, scope) pairs the token is authorized for in one UMA call.

Prefer this over :meth:check_permissions when multiple pairs must be checked per request.

Parameters:

Name Type Description Default
token str

Access token

required
permissions tuple[tuple[str, str], ...]

Tuple of (resource, scope) pairs to check

required

Returns:

Type Description
frozenset[tuple[str, str]]

Subset of permissions that are granted

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@ttl_cache_decorator(ttl_seconds=30, maxsize=200)
def check_permissions_batch(
    self,
    token: str,
    permissions: tuple[tuple[str, str], ...],
) -> frozenset[tuple[str, str]]:
    """Return the subset of (resource, scope) pairs the token is authorized for in one UMA call.

    Prefer this over :meth:`check_permissions` when multiple pairs must be checked per request.

    Args:
        token: Access token
        permissions: Tuple of (resource, scope) pairs to check

    Returns:
        Subset of ``permissions`` that are granted
    """
    if not permissions:
        return frozenset()
    perm_strs = [f"{resource}#{scope}" for resource, scope in permissions]
    try:
        results = self._openid_adapter.uma_permissions(token, permissions=perm_strs)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "check_permissions_batch")
    if not results or not isinstance(results, list):
        return frozenset()
    granted: set[tuple[str, str]] = set()
    requested = set(permissions)
    for perm in results:
        rsname = perm.get("rsname")
        for scope in perm.get("scopes", []) or []:
            pair = (rsname, scope)
            if pair in requested:
                granted.add(pair)
    return frozenset(granted)

archipy.adapters.keycloak.adapters.KeycloakAdapter.clear_all_caches

clear_all_caches() -> None

Clear all cached values.

Source code in archipy/adapters/keycloak/adapter_mixins/connection.py
def clear_all_caches(self) -> None:
    """Clear all cached values."""
    for attr_name in dir(self):
        attr = getattr(self, attr_name)
        if hasattr(attr, "clear_cache"):
            attr.clear_cache()

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter

Bases: AsyncKeycloakConnectionMixin, AsyncKeycloakAuthMixin, AsyncKeycloakUsersMixin, AsyncKeycloakRolesMixin, AsyncKeycloakClientsMixin, AsyncKeycloakRealmsMixin, AsyncKeycloakOrganizationsMixin, AsyncKeycloakGroupsMixin, AsyncKeycloakAuthFlowsMixin, AsyncKeycloakClientScopesMixin, AsyncKeycloakAuthzMixin, AsyncKeycloakUmaMixin, AsyncKeycloakComponentsMixin, AsyncKeycloakPort

Async concrete implementation of the AsyncKeycloakPort interface using python-keycloak library.

This implementation includes TTL caching for appropriate operations to improve performance while ensuring cache entries expire after a configured time to prevent stale data.

Source code in archipy/adapters/keycloak/adapters.py
class AsyncKeycloakAdapter(
    AsyncKeycloakConnectionMixin,
    AsyncKeycloakAuthMixin,
    AsyncKeycloakUsersMixin,
    AsyncKeycloakRolesMixin,
    AsyncKeycloakClientsMixin,
    AsyncKeycloakRealmsMixin,
    AsyncKeycloakOrganizationsMixin,
    AsyncKeycloakGroupsMixin,
    AsyncKeycloakAuthFlowsMixin,
    AsyncKeycloakClientScopesMixin,
    AsyncKeycloakAuthzMixin,
    AsyncKeycloakUmaMixin,
    AsyncKeycloakComponentsMixin,
    AsyncKeycloakPort,
):
    """Async concrete implementation of the AsyncKeycloakPort interface using python-keycloak library.

    This implementation includes TTL caching for appropriate operations to improve performance
    while ensuring cache entries expire after a configured time to prevent stale data.
    """

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.configs instance-attribute

configs: KeycloakConfig = (
    BaseConfig.global_config().KEYCLOAK
    if keycloak_configs is None
    else keycloak_configs
)

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.openid_adapter instance-attribute

openid_adapter = self._get_openid_client(self.configs)

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.admin_adapter property

admin_adapter: KeycloakAdmin

Get the admin adapter, refreshing it if necessary.

Returns:

Type Description
KeycloakAdmin

KeycloakAdmin instance

Raises:

Type Description
UnauthenticatedError

If admin client is not available due to authentication issues

UnavailableError

If Keycloak service is unavailable

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.uma_adapter property

uma_adapter: KeycloakUMA

Get the UMA adapter, creating it on first access.

Returns:

Type Description
KeycloakUMA

KeycloakUMA instance

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_component async

create_component(payload: dict[str, Any]) -> str

Create a Keycloak component.

Parameters:

Name Type Description Default
payload dict[str, Any]

Component representation.

required

Returns:

Type Description
str

Created component ID.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
async def create_component(self, payload: dict[str, Any]) -> str:
    """Create a Keycloak component.

    Args:
        payload: Component representation.

    Returns:
        Created component ID.
    """
    return await self._async_call_keycloak(
        "create_component",
        lambda: self.admin_adapter.a_create_component(payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_component async

get_component(component_id: str) -> dict[str, Any]

Get a component by ID.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Component representation.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
async def get_component(self, component_id: str) -> dict[str, Any]:
    """Get a component by ID.

    Args:
        component_id: Component identifier.

    Returns:
        Component representation.
    """
    return await self._async_call_keycloak(
        "get_component",
        lambda: self.admin_adapter.a_get_component(component_id=component_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_components async

get_components(
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get components, optionally filtered by query.

Parameters:

Name Type Description Default
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

Matching component representations.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
async def get_components(self, query: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Get components, optionally filtered by query.

    Args:
        query: Optional filter query parameters.

    Returns:
        Matching component representations.
    """
    return await self._async_call_keycloak(
        "get_components",
        lambda: self.admin_adapter.a_get_components(query=query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_component async

update_component(
    component_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required
payload dict[str, Any]

Updated component representation.

required

Returns:

Type Description
dict[str, Any]

Update response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
async def update_component(self, component_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a component.

    Args:
        component_id: Component identifier.
        payload: Updated component representation.

    Returns:
        Update response payload.
    """
    return await self._async_call_keycloak(
        "update_component",
        lambda: self.admin_adapter.a_update_component(component_id=component_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_component async

delete_component(component_id: str) -> dict[str, Any]

Delete a component.

Parameters:

Name Type Description Default
component_id str

Component identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/components.py
async def delete_component(self, component_id: str) -> dict[str, Any]:
    """Delete a component.

    Args:
        component_id: Component identifier.

    Returns:
        Deletion response payload.
    """
    return await self._async_call_keycloak(
        "delete_component",
        lambda: self.admin_adapter.a_delete_component(component_id=component_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.resource_set_create async

resource_set_create(
    payload: dict[str, Any],
) -> dict[str, Any]

Create a UMA resource set.

Parameters:

Name Type Description Default
payload dict[str, Any]

Resource set representation.

required

Returns:

Type Description
dict[str, Any]

Created resource set representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def resource_set_create(self, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA resource set.

    Args:
        payload: Resource set representation.

    Returns:
        Created resource set representation.
    """
    return await self._async_call_keycloak(
        "resource_set_create",
        lambda: self.uma_adapter.a_resource_set_create(payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.resource_set_read async

resource_set_read(resource_id: str) -> dict[str, Any]

Read a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Resource set representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def resource_set_read(self, resource_id: str) -> dict[str, Any]:
    """Read a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Resource set representation.
    """
    return await self._async_call_keycloak(
        "resource_set_read",
        lambda: self.uma_adapter.a_resource_set_read(resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.resource_set_update async

resource_set_update(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Update a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required
payload dict[str, Any]

Updated resource set representation.

required

Returns:

Type Description
dict[str, Any]

Updated resource set representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def resource_set_update(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Update a UMA resource set.

    Args:
        resource_id: Resource set identifier.
        payload: Updated resource set representation.

    Returns:
        Updated resource set representation.
    """
    return await self._async_call_keycloak(
        "resource_set_update",
        lambda: self.uma_adapter.a_resource_set_update(resource_id=resource_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.resource_set_delete async

resource_set_delete(resource_id: str) -> dict[str, Any]

Delete a UMA resource set.

Parameters:

Name Type Description Default
resource_id str

Resource set identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def resource_set_delete(self, resource_id: str) -> dict[str, Any]:
    """Delete a UMA resource set.

    Args:
        resource_id: Resource set identifier.

    Returns:
        Deletion response payload.
    """
    return await self._async_call_keycloak(
        "resource_set_delete",
        lambda: self.uma_adapter.a_resource_set_delete(resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.resource_set_list async

resource_set_list() -> list[dict[str, Any]]

List all UMA resource sets.

Returns:

Type Description
list[dict[str, Any]]

List of resource set representations.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def resource_set_list(self) -> list[dict[str, Any]]:
    """List all UMA resource sets.

    Returns:
        List of resource set representations.
    """

    async def _list() -> list[dict[str, Any]]:
        return [item async for item in self.uma_adapter.a_resource_set_list()]

    return await self._async_call_keycloak("resource_set_list", _list)

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.resource_set_list_ids async

resource_set_list_ids(
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

List UMA resource set IDs with optional filters.

Parameters:

Name Type Description Default
name str

Filter by resource name.

''
exact_name bool

Require exact name match when True.

False
uri str

Filter by resource URI.

''
owner str

Filter by owner.

''
resource_type str

Filter by resource type.

''
scope str

Filter by scope.

''
matchingUri bool

Match URI patterns when True.

False
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching resource set IDs / summaries.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def resource_set_list_ids(
    self,
    name: str = "",
    exact_name: bool = False,
    uri: str = "",
    owner: str = "",
    resource_type: str = "",
    scope: str = "",
    matchingUri: bool = False,
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """List UMA resource set IDs with optional filters.

    Args:
        name: Filter by resource name.
        exact_name: Require exact name match when True.
        uri: Filter by resource URI.
        owner: Filter by owner.
        resource_type: Filter by resource type.
        scope: Filter by scope.
        matchingUri: Match URI patterns when True.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching resource set IDs / summaries.
    """
    return await self._async_call_keycloak(
        "resource_set_list_ids",
        lambda: self.uma_adapter.a_resource_set_list_ids(
            name=name,
            exact_name=exact_name,
            uri=uri,
            owner=owner,
            resource_type=resource_type,
            scope=scope,
            matchingUri=matchingUri,
            first=first,
            maximum=maximum,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.policy_resource_create async

policy_resource_create(
    resource_id: str, payload: dict[str, Any]
) -> dict[str, Any]

Create a UMA policy for a resource.

Parameters:

Name Type Description Default
resource_id str

Resource identifier.

required
payload dict[str, Any]

Policy representation.

required

Returns:

Type Description
dict[str, Any]

Created policy representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def policy_resource_create(self, resource_id: str, payload: dict[str, Any]) -> dict[str, Any]:
    """Create a UMA policy for a resource.

    Args:
        resource_id: Resource identifier.
        payload: Policy representation.

    Returns:
        Created policy representation.
    """
    return await self._async_call_keycloak(
        "policy_resource_create",
        lambda: self.uma_adapter.a_policy_resource_create(resource_id=resource_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.policy_update async

policy_update(
    policy_id: str, payload: dict[str, Any]
) -> bytes

Update a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required
payload dict[str, Any]

Updated policy representation.

required

Returns:

Type Description
bytes

Raw update response bytes.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def policy_update(self, policy_id: str, payload: dict[str, Any]) -> bytes:
    """Update a UMA policy.

    Args:
        policy_id: Policy identifier.
        payload: Updated policy representation.

    Returns:
        Raw update response bytes.
    """
    return await self._async_call_keycloak(
        "policy_update",
        lambda: self.uma_adapter.a_policy_update(policy_id=policy_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.policy_delete async

policy_delete(policy_id: str) -> dict[str, Any]

Delete a UMA policy.

Parameters:

Name Type Description Default
policy_id str

Policy identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def policy_delete(self, policy_id: str) -> dict[str, Any]:
    """Delete a UMA policy.

    Args:
        policy_id: Policy identifier.

    Returns:
        Deletion response payload.
    """
    return await self._async_call_keycloak(
        "policy_delete",
        lambda: self.uma_adapter.a_policy_delete(policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.policy_query async

policy_query(
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]

Query UMA policies.

Parameters:

Name Type Description Default
resource str

Filter by resource.

''
name str

Filter by policy name.

''
scope str

Filter by scope.

''
first int

Pagination offset.

0
maximum int

Max results (-1 for unlimited).

-1

Returns:

Type Description
list[dict[str, Any]]

Matching policy representations.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def policy_query(
    self,
    resource: str = "",
    name: str = "",
    scope: str = "",
    first: int = 0,
    maximum: int = -1,
) -> list[dict[str, Any]]:
    """Query UMA policies.

    Args:
        resource: Filter by resource.
        name: Filter by policy name.
        scope: Filter by scope.
        first: Pagination offset.
        maximum: Max results (-1 for unlimited).

    Returns:
        Matching policy representations.
    """
    return await self._async_call_keycloak(
        "policy_query",
        lambda: self.uma_adapter.a_policy_query(
            resource=resource,
            name=name,
            scope=scope,
            first=first,
            maximum=maximum,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.permission_ticket_create async

permission_ticket_create(
    permissions: Iterable[UMAPermission],
) -> dict[str, Any]

Create a UMA permission ticket.

Parameters:

Name Type Description Default
permissions Iterable[UMAPermission]

Permissions to include in the ticket.

required

Returns:

Type Description
dict[str, Any]

Permission ticket representation.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def permission_ticket_create(self, permissions: Iterable[UMAPermission]) -> dict[str, Any]:
    """Create a UMA permission ticket.

    Args:
        permissions: Permissions to include in the ticket.

    Returns:
        Permission ticket representation.
    """
    return await self._async_call_keycloak(
        "permission_ticket_create",
        lambda: self.uma_adapter.a_permission_ticket_create(permissions=permissions),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.permissions_check async

permissions_check(
    token: str,
    permissions: Iterable[UMAPermission],
    **extra_payload: Any,
) -> bool

Check UMA permissions for a token.

Parameters:

Name Type Description Default
token str

Access token to evaluate.

required
permissions Iterable[UMAPermission]

Permissions to check.

required
**extra_payload Any

Extra fields forwarded to the UMA endpoint.

{}

Returns:

Type Description
bool

True when all requested permissions are granted.

Source code in archipy/adapters/keycloak/adapter_mixins/uma.py
async def permissions_check(self, token: str, permissions: Iterable[UMAPermission], **extra_payload: Any) -> bool:
    """Check UMA permissions for a token.

    Args:
        token: Access token to evaluate.
        permissions: Permissions to check.
        **extra_payload: Extra fields forwarded to the UMA endpoint.

    Returns:
        True when all requested permissions are granted.
    """
    return await self._async_call_keycloak(
        "permissions_check",
        lambda: self.uma_adapter.a_permissions_check(token=token, permissions=permissions, **extra_payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_resource async

create_client_authz_resource(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization resource for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_resource(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create an authorization resource for a client."""
    return await self._async_call_keycloak(
        "create_client_authz_resource",
        lambda: self.admin_adapter.a_create_client_authz_resource(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_resources async

get_client_authz_resources(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization resources for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_resources(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization resources for a client."""
    return await self._async_call_keycloak(
        "get_client_authz_resources",
        lambda: self.admin_adapter.a_get_client_authz_resources(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_resource async

get_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Get a single authorization resource.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Get a single authorization resource."""
    return await self._async_call_keycloak(
        "get_client_authz_resource",
        lambda: self.admin_adapter.a_get_client_authz_resource(client_id=client_id, resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_client_authz_resource async

update_client_authz_resource(
    client_id: str, resource_id: str, payload: dict
) -> dict[str, Any]

Update an authorization resource.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def update_client_authz_resource(self, client_id: str, resource_id: str, payload: dict) -> dict[str, Any]:
    """Update an authorization resource."""
    return await self._async_call_keycloak(
        "update_client_authz_resource",
        lambda: self.admin_adapter.a_update_client_authz_resource(
            client_id=client_id,
            resource_id=resource_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_client_authz_resource async

delete_client_authz_resource(
    client_id: str, resource_id: str
) -> dict[str, Any]

Delete an authorization resource.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def delete_client_authz_resource(self, client_id: str, resource_id: str) -> dict[str, Any]:
    """Delete an authorization resource."""
    return await self._async_call_keycloak(
        "delete_client_authz_resource",
        lambda: self.admin_adapter.a_delete_client_authz_resource(client_id=client_id, resource_id=resource_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_scopes async

create_client_authz_scopes(
    client_id: str, payload: dict
) -> dict[str, Any]

Create authorization scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_scopes(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Create authorization scopes for a client."""
    return await self._async_call_keycloak(
        "create_client_authz_scopes",
        lambda: self.admin_adapter.a_create_client_authz_scopes(client_id=client_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_scopes async

get_client_authz_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization scopes for a client."""
    return await self._async_call_keycloak(
        "get_client_authz_scopes",
        lambda: self.admin_adapter.a_get_client_authz_scopes(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_role_based_policy async

create_client_authz_role_based_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a role-based authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_role_based_policy(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a role-based authorization policy."""
    return await self._async_call_keycloak(
        "create_client_authz_role_based_policy",
        lambda: self.admin_adapter.a_create_client_authz_role_based_policy(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_client_policy async

create_client_authz_client_policy(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a client-based authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_client_policy(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a client-based authorization policy."""
    return await self._async_call_keycloak(
        "create_client_authz_client_policy",
        lambda: self.admin_adapter.a_create_client_authz_client_policy(payload=payload, client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_policy async

create_client_authz_policy(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create an authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_policy(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create an authorization policy."""
    return await self._async_call_keycloak(
        "create_client_authz_policy",
        lambda: self.admin_adapter.a_create_client_authz_policy(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_policies async

get_client_authz_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization policies for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization policies for a client."""
    return await self._async_call_keycloak(
        "get_client_authz_policies",
        lambda: self.admin_adapter.a_get_client_authz_policies(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_policy async

get_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Get a single authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Get a single authorization policy."""
    return await self._async_call_keycloak(
        "get_client_authz_policy",
        lambda: self.admin_adapter.a_get_client_authz_policy(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_client_authz_policy async

delete_client_authz_policy(
    client_id: str, policy_id: str
) -> dict[str, Any]

Delete an authorization policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def delete_client_authz_policy(self, client_id: str, policy_id: str) -> dict[str, Any]:
    """Delete an authorization policy."""
    return await self._async_call_keycloak(
        "delete_client_authz_policy",
        lambda: self.admin_adapter.a_delete_client_authz_policy(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_resource_based_permission async

create_client_authz_resource_based_permission(
    client_id: str, payload: dict, skip_exists: bool = False
) -> dict[str, Any]

Create a resource-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_resource_based_permission(
    self,
    client_id: str,
    payload: dict,
    skip_exists: bool = False,
) -> dict[str, Any]:
    """Create a resource-based permission."""
    return await self._async_call_keycloak(
        "create_client_authz_resource_based_permission",
        lambda: self.admin_adapter.a_create_client_authz_resource_based_permission(
            client_id=client_id,
            payload=payload,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_authz_scope_permission async

create_client_authz_scope_permission(
    payload: dict, client_id: str
) -> dict[str, Any]

Create a scope-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def create_client_authz_scope_permission(self, payload: dict, client_id: str) -> dict[str, Any]:
    """Create a scope-based permission."""
    return await self._async_call_keycloak(
        "create_client_authz_scope_permission",
        lambda: self.admin_adapter.a_create_client_authz_scope_permission(payload=payload, client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_permissions async

get_client_authz_permissions(
    client_id: str,
) -> list[dict[str, Any]]

Get authorization permissions for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_permissions(self, client_id: str) -> list[dict[str, Any]]:
    """Get authorization permissions for a client."""
    return await self._async_call_keycloak(
        "get_client_authz_permissions",
        lambda: self.admin_adapter.a_get_client_authz_permissions(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_scope_permission async

get_client_authz_scope_permission(
    client_id: str, scope_id: str
) -> dict[str, Any]

Get a scope-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_scope_permission(self, client_id: str, scope_id: str) -> dict[str, Any]:
    """Get a scope-based permission."""
    return await self._async_call_keycloak(
        "get_client_authz_scope_permission",
        lambda: self.admin_adapter.a_get_client_authz_scope_permission(client_id=client_id, scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_client_authz_scope_permission async

update_client_authz_scope_permission(
    payload: dict, client_id: str, scope_id: str
) -> bytes

Update a scope-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def update_client_authz_scope_permission(self, payload: dict, client_id: str, scope_id: str) -> bytes:
    """Update a scope-based permission."""
    return await self._async_call_keycloak(
        "update_client_authz_scope_permission",
        lambda: self.admin_adapter.a_update_client_authz_scope_permission(
            payload=payload,
            client_id=client_id,
            scope_id=scope_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_client_authz_resource_permission async

update_client_authz_resource_permission(
    payload: dict, client_id: str, resource_id: str
) -> bytes

Update a resource-based permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def update_client_authz_resource_permission(self, payload: dict, client_id: str, resource_id: str) -> bytes:
    """Update a resource-based permission."""
    return await self._async_call_keycloak(
        "update_client_authz_resource_permission",
        lambda: self.admin_adapter.a_update_client_authz_resource_permission(
            payload=payload,
            client_id=client_id,
            resource_id=resource_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_permission_associated_policies async

get_client_authz_permission_associated_policies(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get policies associated with a permission.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_permission_associated_policies(
    self,
    client_id: str,
    policy_id: str,
) -> list[dict[str, Any]]:
    """Get policies associated with a permission."""
    return await self._async_call_keycloak(
        "get_client_authz_permission_associated_policies",
        lambda: self.admin_adapter.a_get_client_authz_permission_associated_policies(
            client_id=client_id,
            policy_id=policy_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_settings async

get_client_authz_settings(client_id: str) -> dict[str, Any]

Get authorization settings for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_settings(self, client_id: str) -> dict[str, Any]:
    """Get authorization settings for a client."""
    return await self._async_call_keycloak(
        "get_client_authz_settings",
        lambda: self.admin_adapter.a_get_client_authz_settings(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_client_policies async

get_client_authz_client_policies(
    client_id: str,
) -> list[dict[str, Any]]

Get client policies for authorization.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_client_policies(self, client_id: str) -> list[dict[str, Any]]:
    """Get client policies for authorization."""
    return await self._async_call_keycloak(
        "get_client_authz_client_policies",
        lambda: self.admin_adapter.a_get_client_authz_client_policies(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_policy_resources async

get_client_authz_policy_resources(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get resources associated with a policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_policy_resources(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get resources associated with a policy."""
    return await self._async_call_keycloak(
        "get_client_authz_policy_resources",
        lambda: self.admin_adapter.a_get_client_authz_policy_resources(
            client_id=client_id,
            policy_id=policy_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_authz_policy_scopes async

get_client_authz_policy_scopes(
    client_id: str, policy_id: str
) -> list[dict[str, Any]]

Get scopes associated with a policy.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def get_client_authz_policy_scopes(self, client_id: str, policy_id: str) -> list[dict[str, Any]]:
    """Get scopes associated with a policy."""
    return await self._async_call_keycloak(
        "get_client_authz_policy_scopes",
        lambda: self.admin_adapter.a_get_client_authz_policy_scopes(client_id=client_id, policy_id=policy_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.import_client_authz_config async

import_client_authz_config(
    client_id: str, payload: dict
) -> dict[str, Any]

Import authorization configuration for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/authz.py
async def import_client_authz_config(self, client_id: str, payload: dict) -> dict[str, Any]:
    """Import authorization configuration for a client."""
    return await self._async_call_keycloak(
        "import_client_authz_config",
        lambda: self.admin_adapter.a_import_client_authz_config(client_id=client_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_scopes async

get_client_scopes() -> list[dict[str, Any]]

Get all client scopes.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get all client scopes."""
    return await self._async_call_keycloak(
        "get_client_scopes",
        self.admin_adapter.a_get_client_scopes,
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_scope async

get_client_scope(client_scope_id: str) -> dict[str, Any]

Get a client scope by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Get a client scope by ID."""
    return await self._async_call_keycloak(
        "get_client_scope",
        lambda: self.admin_adapter.a_get_client_scope(client_scope_id=client_scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_scope_by_name async

get_client_scope_by_name(
    client_scope_name: str,
) -> dict[str, Any] | None

Get a client scope by name.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_client_scope_by_name(self, client_scope_name: str) -> dict[str, Any] | None:
    """Get a client scope by name."""
    return await self._async_call_keycloak(
        "get_client_scope_by_name",
        lambda: self.admin_adapter.a_get_client_scope_by_name(client_scope_name=client_scope_name),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_scope async

create_client_scope(
    payload: dict, skip_exists: bool = False
) -> str

Create a new client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def create_client_scope(self, payload: dict, skip_exists: bool = False) -> str:
    """Create a new client scope."""
    return await self._async_call_keycloak(
        "create_client_scope",
        lambda: self.admin_adapter.a_create_client_scope(payload=payload, skip_exists=skip_exists),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_client_scope async

update_client_scope(
    client_scope_id: str, payload: dict
) -> dict[str, Any]

Update a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def update_client_scope(self, client_scope_id: str, payload: dict) -> dict[str, Any]:
    """Update a client scope."""
    return await self._async_call_keycloak(
        "update_client_scope",
        lambda: self.admin_adapter.a_update_client_scope(client_scope_id=client_scope_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_client_scope async

delete_client_scope(client_scope_id: str) -> dict[str, Any]

Delete a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def delete_client_scope(self, client_scope_id: str) -> dict[str, Any]:
    """Delete a client scope."""
    return await self._async_call_keycloak(
        "delete_client_scope",
        lambda: self.admin_adapter.a_delete_client_scope(client_scope_id=client_scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_mapper_to_client_scope async

add_mapper_to_client_scope(
    client_scope_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def add_mapper_to_client_scope(self, client_scope_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client scope."""
    return await self._async_call_keycloak(
        "add_mapper_to_client_scope",
        lambda: self.admin_adapter.a_add_mapper_to_client_scope(
            client_scope_id=client_scope_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_mappers_from_client_scope async

get_mappers_from_client_scope(
    client_scope_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_mappers_from_client_scope(self, client_scope_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client scope."""
    return await self._async_call_keycloak(
        "get_mappers_from_client_scope",
        lambda: self.admin_adapter.a_get_mappers_from_client_scope(client_scope_id=client_scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_mapper_in_client_scope async

update_mapper_in_client_scope(
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]

Update a protocol mapper in a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def update_mapper_in_client_scope(
    self,
    client_scope_id: str,
    protocol_mapper_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Update a protocol mapper in a client scope."""
    return await self._async_call_keycloak(
        "update_mapper_in_client_scope",
        lambda: self.admin_adapter.a_update_mapper_in_client_scope(
            client_scope_id=client_scope_id,
            protocol_mapper_id=protocol_mapper_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_mapper_from_client_scope async

delete_mapper_from_client_scope(
    client_scope_id: str, protocol_mapper_id: str
) -> dict[str, Any]

Delete a protocol mapper from a client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def delete_mapper_from_client_scope(self, client_scope_id: str, protocol_mapper_id: str) -> dict[str, Any]:
    """Delete a protocol mapper from a client scope."""
    return await self._async_call_keycloak(
        "delete_mapper_from_client_scope",
        lambda: self.admin_adapter.a_delete_mapper_from_client_scope(
            client_scope_id=client_scope_id,
            protocol_mapper_id=protocol_mapper_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_mapper_to_client async

add_mapper_to_client(
    client_id: str, payload: dict
) -> bytes

Add a protocol mapper to a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def add_mapper_to_client(self, client_id: str, payload: dict) -> bytes:
    """Add a protocol mapper to a client."""
    return await self._async_call_keycloak(
        "add_mapper_to_client",
        lambda: self.admin_adapter.a_add_mapper_to_client(client_id=client_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_mappers_from_client async

get_mappers_from_client(
    client_id: str,
) -> list[dict[str, Any]]

Get protocol mappers for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_mappers_from_client(self, client_id: str) -> list[dict[str, Any]]:
    """Get protocol mappers for a client."""
    return await self._async_call_keycloak(
        "get_mappers_from_client",
        lambda: self.admin_adapter.a_get_mappers_from_client(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_client_mapper async

update_client_mapper(
    client_id: str, mapper_id: str, payload: dict
) -> dict[str, Any]

Update a protocol mapper on a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def update_client_mapper(self, client_id: str, mapper_id: str, payload: dict) -> dict[str, Any]:
    """Update a protocol mapper on a client."""
    return await self._async_call_keycloak(
        "update_client_mapper",
        lambda: self.admin_adapter.a_update_client_mapper(
            client_id=client_id,
            mapper_id=mapper_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.remove_client_mapper async

remove_client_mapper(
    client_id: str, client_mapper_id: str
) -> dict[str, Any]

Remove a protocol mapper from a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def remove_client_mapper(self, client_id: str, client_mapper_id: str) -> dict[str, Any]:
    """Remove a protocol mapper from a client."""
    return await self._async_call_keycloak(
        "remove_client_mapper",
        lambda: self.admin_adapter.a_remove_client_mapper(
            client_id=client_id,
            client_mapper_id=client_mapper_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_default_client_scopes async

get_client_default_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get default client scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_client_default_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get default client scopes for a client."""
    return await self._async_call_keycloak(
        "get_client_default_client_scopes",
        lambda: self.admin_adapter.a_get_client_default_client_scopes(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_client_default_client_scope async

add_client_default_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add a default client scope to a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def add_client_default_client_scope(
    self,
    client_id: str,
    client_scope_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Add a default client scope to a client."""
    return await self._async_call_keycloak(
        "add_client_default_client_scope",
        lambda: self.admin_adapter.a_add_client_default_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_client_default_client_scope async

delete_client_default_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove a default client scope from a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def delete_client_default_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove a default client scope from a client."""
    return await self._async_call_keycloak(
        "delete_client_default_client_scope",
        lambda: self.admin_adapter.a_delete_client_default_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_optional_client_scopes async

get_client_optional_client_scopes(
    client_id: str,
) -> list[dict[str, Any]]

Get optional client scopes for a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_client_optional_client_scopes(self, client_id: str) -> list[dict[str, Any]]:
    """Get optional client scopes for a client."""
    return await self._async_call_keycloak(
        "get_client_optional_client_scopes",
        lambda: self.admin_adapter.a_get_client_optional_client_scopes(client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_client_optional_client_scope async

add_client_optional_client_scope(
    client_id: str, client_scope_id: str, payload: dict
) -> dict[str, Any]

Add an optional client scope to a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def add_client_optional_client_scope(
    self,
    client_id: str,
    client_scope_id: str,
    payload: dict,
) -> dict[str, Any]:
    """Add an optional client scope to a client."""
    return await self._async_call_keycloak(
        "add_client_optional_client_scope",
        lambda: self.admin_adapter.a_add_client_optional_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
            payload=payload,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_client_optional_client_scope async

delete_client_optional_client_scope(
    client_id: str, client_scope_id: str
) -> dict[str, Any]

Remove an optional client scope from a client.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def delete_client_optional_client_scope(self, client_id: str, client_scope_id: str) -> dict[str, Any]:
    """Remove an optional client scope from a client."""
    return await self._async_call_keycloak(
        "delete_client_optional_client_scope",
        lambda: self.admin_adapter.a_delete_client_optional_client_scope(
            client_id=client_id,
            client_scope_id=client_scope_id,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_default_default_client_scopes async

get_default_default_client_scopes() -> list[dict[str, Any]]

Get realm default client scopes.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_default_default_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm default client scopes."""
    return await self._async_call_keycloak(
        "get_default_default_client_scopes",
        self.admin_adapter.a_get_default_default_client_scopes,
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_default_default_client_scope async

add_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def add_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm default client scope."""
    return await self._async_call_keycloak(
        "add_default_default_client_scope",
        lambda: self.admin_adapter.a_add_default_default_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_default_default_client_scope async

delete_default_default_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def delete_default_default_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm default client scope."""
    return await self._async_call_keycloak(
        "delete_default_default_client_scope",
        lambda: self.admin_adapter.a_delete_default_default_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_default_optional_client_scopes async

get_default_optional_client_scopes() -> list[
    dict[str, Any]
]

Get realm optional default client scopes.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def get_default_optional_client_scopes(
    self,
) -> list[dict[str, Any]]:
    """Get realm optional default client scopes."""
    return await self._async_call_keycloak(
        "get_default_optional_client_scopes",
        self.admin_adapter.a_get_default_optional_client_scopes,
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_default_optional_client_scope async

add_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Add a realm optional default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def add_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Add a realm optional default client scope."""
    return await self._async_call_keycloak(
        "add_default_optional_client_scope",
        lambda: self.admin_adapter.a_add_default_optional_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_default_optional_client_scope async

delete_default_optional_client_scope(
    scope_id: str,
) -> dict[str, Any]

Remove a realm optional default client scope.

Source code in archipy/adapters/keycloak/adapter_mixins/client_scopes.py
async def delete_default_optional_client_scope(self, scope_id: str) -> dict[str, Any]:
    """Remove a realm optional default client scope."""
    return await self._async_call_keycloak(
        "delete_default_optional_client_scope",
        lambda: self.admin_adapter.a_delete_default_optional_client_scope(scope_id=scope_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_authentication_flow async

create_authentication_flow(
    payload: dict, skip_exists: bool = False
) -> bytes

Create a new authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def create_authentication_flow(self, payload: dict, skip_exists: bool = False) -> bytes:
    """Create a new authentication flow."""
    return await self._async_call_keycloak(
        "create_authentication_flow",
        lambda: self.admin_adapter.a_create_authentication_flow(payload=payload, skip_exists=skip_exists),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.copy_authentication_flow async

copy_authentication_flow(
    payload: dict, flow_alias: str
) -> bytes

Copy an existing authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def copy_authentication_flow(self, payload: dict, flow_alias: str) -> bytes:
    """Copy an existing authentication flow."""
    return await self._async_call_keycloak(
        "copy_authentication_flow",
        lambda: self.admin_adapter.a_copy_authentication_flow(payload=payload, flow_alias=flow_alias),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authentication_flows async

get_authentication_flows() -> list[dict[str, Any]]

Get all authentication flows.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authentication_flows(
    self,
) -> list[dict[str, Any]]:
    """Get all authentication flows."""
    return await self._async_call_keycloak(
        "get_authentication_flows",
        self.admin_adapter.a_get_authentication_flows,
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authentication_flow_for_id async

get_authentication_flow_for_id(
    flow_id: str,
) -> dict[str, Any]

Get authentication flow by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authentication_flow_for_id(self, flow_id: str) -> dict[str, Any]:
    """Get authentication flow by ID."""
    return await self._async_call_keycloak(
        "get_authentication_flow_for_id",
        lambda: self.admin_adapter.a_get_authentication_flow_for_id(flow_id=flow_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_authentication_flow async

delete_authentication_flow(flow_id: str) -> dict[str, Any]

Delete an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def delete_authentication_flow(self, flow_id: str) -> dict[str, Any]:
    """Delete an authentication flow."""
    return await self._async_call_keycloak(
        "delete_authentication_flow",
        lambda: self.admin_adapter.a_delete_authentication_flow(flow_id=flow_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authentication_flow_executions async

get_authentication_flow_executions(
    flow_alias: str,
) -> list[dict[str, Any]]

Get executions for an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authentication_flow_executions(self, flow_alias: str) -> list[dict[str, Any]]:
    """Get executions for an authentication flow."""
    return await self._async_call_keycloak(
        "get_authentication_flow_executions",
        lambda: self.admin_adapter.a_get_authentication_flow_executions(flow_alias=flow_alias),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authentication_flow_execution async

get_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Get a single authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Get a single authentication flow execution."""
    return await self._async_call_keycloak(
        "get_authentication_flow_execution",
        lambda: self.admin_adapter.a_get_authentication_flow_execution(execution_id=execution_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_authentication_flow_execution async

create_authentication_flow_execution(
    payload: dict, flow_alias: str
) -> bytes

Create an execution in an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def create_authentication_flow_execution(self, payload: dict, flow_alias: str) -> bytes:
    """Create an execution in an authentication flow."""
    return await self._async_call_keycloak(
        "create_authentication_flow_execution",
        lambda: self.admin_adapter.a_create_authentication_flow_execution(
            payload=payload,
            flow_alias=flow_alias,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_authentication_flow_executions async

update_authentication_flow_executions(
    payload: dict, flow_alias: str
) -> dict[str, Any]

Update executions in an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def update_authentication_flow_executions(self, payload: dict, flow_alias: str) -> dict[str, Any]:
    """Update executions in an authentication flow."""
    return await self._async_call_keycloak(
        "update_authentication_flow_executions",
        lambda: self.admin_adapter.a_update_authentication_flow_executions(
            payload=payload,
            flow_alias=flow_alias,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_authentication_flow_subflow async

create_authentication_flow_subflow(
    payload: dict,
    flow_alias: str,
    skip_exists: bool = False,
) -> bytes

Create a subflow in an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def create_authentication_flow_subflow(
    self,
    payload: dict,
    flow_alias: str,
    skip_exists: bool = False,
) -> bytes:
    """Create a subflow in an authentication flow."""
    return await self._async_call_keycloak(
        "create_authentication_flow_subflow",
        lambda: self.admin_adapter.a_create_authentication_flow_subflow(
            payload=payload,
            flow_alias=flow_alias,
            skip_exists=skip_exists,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_authentication_flow_execution async

delete_authentication_flow_execution(
    execution_id: str,
) -> dict[str, Any]

Delete an authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def delete_authentication_flow_execution(self, execution_id: str) -> dict[str, Any]:
    """Delete an authentication flow execution."""
    return await self._async_call_keycloak(
        "delete_authentication_flow_execution",
        lambda: self.admin_adapter.a_delete_authentication_flow_execution(execution_id=execution_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.change_execution_priority async

change_execution_priority(
    execution_id: str, diff: int
) -> None

Change priority of an authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def change_execution_priority(self, execution_id: str, diff: int) -> None:
    """Change priority of an authentication flow execution."""
    return await self._async_call_keycloak(
        "change_execution_priority",
        lambda: self.admin_adapter.a_change_execution_priority(execution_id=execution_id, diff=diff),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_authentication_flow async

update_authentication_flow(
    flow_id: str, payload: dict
) -> dict[str, Any]

Update an authentication flow.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def update_authentication_flow(self, flow_id: str, payload: dict) -> dict[str, Any]:
    """Update an authentication flow."""
    return await self._async_call_keycloak(
        "update_authentication_flow",
        lambda: self.admin_adapter.a_update_authentication_flow(flow_id=flow_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authenticator_providers async

get_authenticator_providers() -> list[dict[str, Any]]

Get available authenticator providers.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authenticator_providers(
    self,
) -> list[dict[str, Any]]:
    """Get available authenticator providers."""
    return await self._async_call_keycloak(
        "get_authenticator_providers",
        self.admin_adapter.a_get_authenticator_providers,
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authenticator_provider_config_description async

get_authenticator_provider_config_description(
    provider_id: str,
) -> dict[str, Any]

Get config description for an authenticator provider.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authenticator_provider_config_description(self, provider_id: str) -> dict[str, Any]:
    """Get config description for an authenticator provider."""
    return await self._async_call_keycloak(
        "get_authenticator_provider_config_description",
        lambda: self.admin_adapter.a_get_authenticator_provider_config_description(provider_id=provider_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_authenticator_config async

get_authenticator_config(config_id: str) -> dict[str, Any]

Get authenticator configuration by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def get_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Get authenticator configuration by ID."""
    return await self._async_call_keycloak(
        "get_authenticator_config",
        lambda: self.admin_adapter.a_get_authenticator_config(config_id=config_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_authenticator_config async

update_authenticator_config(
    payload: dict, config_id: str
) -> dict[str, Any]

Update authenticator configuration.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def update_authenticator_config(self, payload: dict, config_id: str) -> dict[str, Any]:
    """Update authenticator configuration."""
    return await self._async_call_keycloak(
        "update_authenticator_config",
        lambda: self.admin_adapter.a_update_authenticator_config(payload=payload, config_id=config_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_authenticator_config async

delete_authenticator_config(
    config_id: str,
) -> dict[str, Any]

Delete authenticator configuration.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def delete_authenticator_config(self, config_id: str) -> dict[str, Any]:
    """Delete authenticator configuration."""
    return await self._async_call_keycloak(
        "delete_authenticator_config",
        lambda: self.admin_adapter.a_delete_authenticator_config(config_id=config_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_execution_config async

create_execution_config(
    execution_id: str, payload: dict
) -> bytes

Create configuration for an authentication flow execution.

Source code in archipy/adapters/keycloak/adapter_mixins/auth_flows.py
async def create_execution_config(self, execution_id: str, payload: dict) -> bytes:
    """Create configuration for an authentication flow execution."""
    return await self._async_call_keycloak(
        "create_execution_config",
        lambda: self.admin_adapter.a_create_execution_config(execution_id=execution_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_group async

create_group(
    payload: dict,
    parent: str | None = None,
    skip_exists: bool = False,
) -> str | None

Create a new group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def create_group(self, payload: dict, parent: str | None = None, skip_exists: bool = False) -> str | None:
    """Create a new group."""
    return await self._async_call_keycloak(
        "create_group",
        lambda: self.admin_adapter.a_create_group(payload=payload, parent=parent, skip_exists=skip_exists),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_group async

update_group(
    group_id: str, payload: dict
) -> dict[str, Any]

Update a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def update_group(self, group_id: str, payload: dict) -> dict[str, Any]:
    """Update a group."""
    return await self._async_call_keycloak(
        "update_group",
        lambda: self.admin_adapter.a_update_group(group_id=group_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_group async

delete_group(group_id: str) -> dict[str, Any]

Delete a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def delete_group(self, group_id: str) -> dict[str, Any]:
    """Delete a group."""
    return await self._async_call_keycloak(
        "delete_group",
        lambda: self.admin_adapter.a_delete_group(group_id=group_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_group async

get_group(
    group_id: str,
    full_hierarchy: bool = False,
    query: dict | None = None,
) -> dict[str, Any]

Get group representation by ID.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_group(self, group_id: str, full_hierarchy: bool = False, query: dict | None = None) -> dict[str, Any]:
    """Get group representation by ID."""
    return await self._async_call_keycloak(
        "get_group",
        lambda: self.admin_adapter.a_get_group(group_id=group_id, full_hierarchy=full_hierarchy, query=query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_group_by_path async

get_group_by_path(path: str) -> dict[str, Any]

Get group representation by path.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_group_by_path(self, path: str) -> dict[str, Any]:
    """Get group representation by path."""
    return await self._async_call_keycloak(
        "get_group_by_path",
        lambda: self.admin_adapter.a_get_group_by_path(path=path),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_group_children async

get_group_children(
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]

Get child groups of a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_group_children(
    self,
    group_id: str,
    query: dict | None = None,
    full_hierarchy: bool = False,
) -> list[dict[str, Any]]:
    """Get child groups of a group."""
    return await self._async_call_keycloak(
        "get_group_children",
        lambda: self.admin_adapter.a_get_group_children(
            group_id=group_id,
            query=query,
            full_hierarchy=full_hierarchy,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_groups async

get_groups(
    query: dict | None = None, full_hierarchy: bool = False
) -> list[dict[str, Any]]

Get all groups, optionally filtered by query.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_groups(self, query: dict | None = None, full_hierarchy: bool = False) -> list[dict[str, Any]]:
    """Get all groups, optionally filtered by query."""
    return await self._async_call_keycloak(
        "get_groups",
        lambda: self.admin_adapter.a_get_groups(query=query, full_hierarchy=full_hierarchy),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_subgroups async

get_subgroups(
    group: dict, path: str
) -> dict[str, Any] | None

Get subgroups for a group at the given path.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_subgroups(self, group: dict, path: str) -> dict[str, Any] | None:
    """Get subgroups for a group at the given path."""
    return await self._async_call_keycloak(
        "get_subgroups",
        lambda: self.admin_adapter.a_get_subgroups(group=group, path=path),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.groups_count async

groups_count(query: dict | None = None) -> dict[str, Any]

Get the number of groups matching the query.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def groups_count(self, query: dict | None = None) -> dict[str, Any]:
    """Get the number of groups matching the query."""
    return await self._async_call_keycloak(
        "groups_count",
        lambda: self.admin_adapter.a_groups_count(query=query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.group_user_add async

group_user_add(
    user_id: str, group_id: str
) -> dict[str, Any]

Add a user to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def group_user_add(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Add a user to a group."""
    return await self._async_call_keycloak(
        "group_user_add",
        lambda: self.admin_adapter.a_group_user_add(user_id=user_id, group_id=group_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.group_user_remove async

group_user_remove(
    user_id: str, group_id: str
) -> dict[str, Any]

Remove a user from a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def group_user_remove(self, user_id: str, group_id: str) -> dict[str, Any]:
    """Remove a user from a group."""
    return await self._async_call_keycloak(
        "group_user_remove",
        lambda: self.admin_adapter.a_group_user_remove(user_id=user_id, group_id=group_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.group_set_permissions async

group_set_permissions(
    group_id: str, enabled: bool = True
) -> dict[str, Any]

Enable or disable fine-grained permissions for a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def group_set_permissions(self, group_id: str, enabled: bool = True) -> dict[str, Any]:
    """Enable or disable fine-grained permissions for a group."""
    return await self._async_call_keycloak(
        "group_set_permissions",
        lambda: self.admin_adapter.a_group_set_permissions(group_id=group_id, enabled=enabled),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_group_members async

get_group_members(
    group_id: str, query: dict | None = None
) -> list[dict[str, Any]]

Get members of a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_group_members(self, group_id: str, query: dict | None = None) -> list[dict[str, Any]]:
    """Get members of a group."""
    return await self._async_call_keycloak(
        "get_group_members",
        lambda: self.admin_adapter.a_get_group_members(group_id=group_id, query=query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_group_client_roles async

get_group_client_roles(
    group_id: str, client_id: str
) -> list[dict[str, Any]]

Get client roles assigned to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_group_client_roles(self, group_id: str, client_id: str) -> list[dict[str, Any]]:
    """Get client roles assigned to a group."""
    return await self._async_call_keycloak(
        "get_group_client_roles",
        lambda: self.admin_adapter.a_get_group_client_roles(group_id=group_id, client_id=client_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_group_realm_roles async

get_group_realm_roles(
    group_id: str, brief_representation: bool = True
) -> list[dict[str, Any]]

Get realm roles assigned to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_group_realm_roles(self, group_id: str, brief_representation: bool = True) -> list[dict[str, Any]]:
    """Get realm roles assigned to a group."""
    return await self._async_call_keycloak(
        "get_group_realm_roles",
        lambda: self.admin_adapter.a_get_group_realm_roles(
            group_id=group_id,
            brief_representation=brief_representation,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.assign_group_client_roles async

assign_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Assign client roles to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def assign_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Assign client roles to a group."""
    return await self._async_call_keycloak(
        "assign_group_client_roles",
        lambda: self.admin_adapter.a_assign_group_client_roles(
            group_id=group_id,
            client_id=client_id,
            roles=roles,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.assign_group_realm_roles async

assign_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Assign realm roles to a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def assign_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Assign realm roles to a group."""
    return await self._async_call_keycloak(
        "assign_group_realm_roles",
        lambda: self.admin_adapter.a_assign_group_realm_roles(group_id=group_id, roles=roles),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_group_client_roles async

delete_group_client_roles(
    group_id: str, client_id: str, roles: str | list
) -> dict[str, Any]

Remove client roles from a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def delete_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> dict[str, Any]:
    """Remove client roles from a group."""
    return await self._async_call_keycloak(
        "delete_group_client_roles",
        lambda: self.admin_adapter.a_delete_group_client_roles(
            group_id=group_id,
            client_id=client_id,
            roles=roles,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_group_realm_roles async

delete_group_realm_roles(
    group_id: str, roles: str | list
) -> dict[str, Any]

Remove realm roles from a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def delete_group_realm_roles(self, group_id: str, roles: str | list) -> dict[str, Any]:
    """Remove realm roles from a group."""
    return await self._async_call_keycloak(
        "delete_group_realm_roles",
        lambda: self.admin_adapter.a_delete_group_realm_roles(group_id=group_id, roles=roles),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_composite_client_roles_of_group async

get_composite_client_roles_of_group(
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get composite client roles of a group.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_composite_client_roles_of_group(
    self,
    client_id: str,
    group_id: str,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get composite client roles of a group."""
    return await self._async_call_keycloak(
        "get_composite_client_roles_of_group",
        lambda: self.admin_adapter.a_get_composite_client_roles_of_group(
            client_id=client_id,
            group_id=group_id,
            brief_representation=brief_representation,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_role_groups async

get_client_role_groups(
    client_id: str, role_name: str, query: Any
) -> list[dict[str, Any]]

Get groups that have a specific client role.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_client_role_groups(self, client_id: str, role_name: str, query: Any) -> list[dict[str, Any]]:
    """Get groups that have a specific client role."""
    return await self._async_call_keycloak(
        "get_client_role_groups",
        lambda: self.admin_adapter.a_get_client_role_groups(client_id=client_id, role_name=role_name, **query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_realm_role_groups async

get_realm_role_groups(
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]

Get groups that have a specific realm role.

Source code in archipy/adapters/keycloak/adapter_mixins/groups.py
async def get_realm_role_groups(
    self,
    role_name: str,
    query: dict | None = None,
    brief_representation: bool = True,
) -> list[dict[str, Any]]:
    """Get groups that have a specific realm role."""
    return await self._async_call_keycloak(
        "get_realm_role_groups",
        lambda: self.admin_adapter.a_get_realm_role_groups(
            role_name=role_name,
            query=query,
            brief_representation=brief_representation,
        ),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_organizations async

get_organizations(
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Fetch all organizations, optionally filtered by query parameters.

Parameters:

Name Type Description Default
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

List of organization representations.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def get_organizations(self, query: dict[str, Any] | None = None) -> list[dict[str, Any]]:
    """Fetch all organizations, optionally filtered by query parameters.

    Args:
        query: Optional filter query parameters.

    Returns:
        List of organization representations.
    """
    return await self._async_call_keycloak(
        "get_organizations",
        lambda: self.admin_adapter.a_get_organizations(query=query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_organization async

get_organization(organization_id: str) -> dict[str, Any]

Get representation of the organization by ID.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
dict[str, Any]

Organization representation.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def get_organization(self, organization_id: str) -> dict[str, Any]:
    """Get representation of the organization by ID.

    Args:
        organization_id: Organization identifier.

    Returns:
        Organization representation.
    """
    return await self._async_call_keycloak(
        "get_organization",
        lambda: self.admin_adapter.a_get_organization(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_organization async

create_organization(
    name: str, alias: str, **kwargs: Any
) -> str | None

Create a new organization. Name and alias must be unique.

Parameters:

Name Type Description Default
name str

Organization name.

required
alias str

Organization alias.

required
**kwargs Any

Additional organization attributes (snake_case mapped to camelCase).

{}

Returns:

Type Description
str | None

Created organization ID, or None.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def create_organization(self, name: str, alias: str, **kwargs: Any) -> str | None:
    """Create a new organization. Name and alias must be unique.

    Args:
        name: Organization name.
        alias: Organization alias.
        **kwargs: Additional organization attributes (snake_case mapped to camelCase).

    Returns:
        Created organization ID, or None.
    """
    payload = _organization_payload(name, alias, kwargs)
    return await self._async_call_keycloak(
        "create_organization",
        lambda: self.admin_adapter.a_create_organization(payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_organization async

update_organization(
    organization_id: str, **kwargs: Any
) -> dict[str, Any]

Update an existing organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required
**kwargs Any

Organization attributes to update (snake_case mapped to camelCase).

{}

Returns:

Type Description
dict[str, Any]

Update response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def update_organization(self, organization_id: str, **kwargs: Any) -> dict[str, Any]:
    """Update an existing organization.

    Args:
        organization_id: Organization identifier.
        **kwargs: Organization attributes to update (snake_case mapped to camelCase).

    Returns:
        Update response payload.
    """
    payload = _organization_update_payload(kwargs)
    return await self._async_call_keycloak(
        "update_organization",
        lambda: self.admin_adapter.a_update_organization(organization_id=organization_id, payload=payload),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_organization async

delete_organization(organization_id: str) -> dict[str, Any]

Delete an organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
dict[str, Any]

Deletion response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def delete_organization(self, organization_id: str) -> dict[str, Any]:
    """Delete an organization.

    Args:
        organization_id: Organization identifier.

    Returns:
        Deletion response payload.
    """
    return await self._async_call_keycloak(
        "delete_organization",
        lambda: self.admin_adapter.a_delete_organization(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_organization_idps async

get_organization_idps(
    organization_id: str,
) -> list[dict[str, Any]]

Get identity providers linked to an organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
list[dict[str, Any]]

List of identity provider representations.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def get_organization_idps(self, organization_id: str) -> list[dict[str, Any]]:
    """Get identity providers linked to an organization.

    Args:
        organization_id: Organization identifier.

    Returns:
        List of identity provider representations.
    """
    return await self._async_call_keycloak(
        "get_organization_idps",
        lambda: self.admin_adapter.a_get_organization_idps(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_user_organizations async

get_user_organizations(
    user_id: str,
) -> list[dict[str, Any]]

Get organizations by user id.

Parameters:

Name Type Description Default
user_id str

User identifier.

required

Returns:

Type Description
list[dict[str, Any]]

Organizations the user belongs to.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def get_user_organizations(self, user_id: str) -> list[dict[str, Any]]:
    """Get organizations by user id.

    Args:
        user_id: User identifier.

    Returns:
        Organizations the user belongs to.
    """
    return await self._async_call_keycloak(
        "get_user_organizations",
        lambda: self.admin_adapter.a_get_user_organizations(user_id=user_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_organization_members async

get_organization_members(
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]

Get members by organization id, optionally filtered by query parameters.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required
query dict[str, Any] | None

Optional filter query parameters.

None

Returns:

Type Description
list[dict[str, Any]]

Member representations.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def get_organization_members(
    self,
    organization_id: str,
    query: dict[str, Any] | None = None,
) -> list[dict[str, Any]]:
    """Get members by organization id, optionally filtered by query parameters.

    Args:
        organization_id: Organization identifier.
        query: Optional filter query parameters.

    Returns:
        Member representations.
    """
    return await self._async_call_keycloak(
        "get_organization_members",
        lambda: self.admin_adapter.a_get_organization_members(organization_id=organization_id, query=query),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_organization_members_count async

get_organization_members_count(organization_id: str) -> int

Get the number of members in the organization.

Parameters:

Name Type Description Default
organization_id str

Organization identifier.

required

Returns:

Type Description
int

Member count.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def get_organization_members_count(self, organization_id: str) -> int:
    """Get the number of members in the organization.

    Args:
        organization_id: Organization identifier.

    Returns:
        Member count.
    """
    return await self._async_call_keycloak(
        "get_organization_members_count",
        lambda: self.admin_adapter.a_get_organization_members_count(organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.organization_user_add async

organization_user_add(
    user_id: str, organization_id: str
) -> bytes

Add a user to an organization.

Parameters:

Name Type Description Default
user_id str

User identifier.

required
organization_id str

Organization identifier.

required

Returns:

Type Description
bytes

Raw response bytes.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def organization_user_add(self, user_id: str, organization_id: str) -> bytes:
    """Add a user to an organization.

    Args:
        user_id: User identifier.
        organization_id: Organization identifier.

    Returns:
        Raw response bytes.
    """
    return await self._async_call_keycloak(
        "organization_user_add",
        lambda: self.admin_adapter.a_organization_user_add(user_id=user_id, organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.organization_user_remove async

organization_user_remove(
    user_id: str, organization_id: str
) -> dict[str, Any]

Remove a user from an organization.

Parameters:

Name Type Description Default
user_id str

User identifier.

required
organization_id str

Organization identifier.

required

Returns:

Type Description
dict[str, Any]

Removal response payload.

Source code in archipy/adapters/keycloak/adapter_mixins/organizations.py
async def organization_user_remove(self, user_id: str, organization_id: str) -> dict[str, Any]:
    """Remove a user from an organization.

    Args:
        user_id: User identifier.
        organization_id: Organization identifier.

    Returns:
        Removal response payload.
    """
    return await self._async_call_keycloak(
        "organization_user_remove",
        lambda: self.admin_adapter.a_organization_user_remove(user_id=user_id, organization_id=organization_id),
    )

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_realm async

create_realm(
    realm_name: str, skip_exists: bool = True, **kwargs: Any
) -> dict[str, Any] | None

Create a Keycloak realm with minimum required fields and optional additional config.

Parameters:

Name Type Description Default
realm_name str

The realm identifier (required)

required
skip_exists bool

Skip creation if realm already exists

True
kwargs Any

Additional optional configurations for the realm

{}

Returns:

Type Description
dict[str, Any] | None

Dictionary with realm information and status

Raises:

Type Description
InternalError

If realm creation fails

Source code in archipy/adapters/keycloak/adapter_mixins/realms.py
async def create_realm(self, realm_name: str, skip_exists: bool = True, **kwargs: Any) -> dict[str, Any] | None:
    """Create a Keycloak realm with minimum required fields and optional additional config.

    Args:
        realm_name: The realm identifier (required)
        skip_exists: Skip creation if realm already exists
        kwargs: Additional optional configurations for the realm

    Returns:
        Dictionary with realm information and status

    Raises:
        InternalError: If realm creation fails
    """
    payload = {
        "realm": realm_name,
        "enabled": kwargs.get("enabled", True),
        "displayName": kwargs.get("display_name", realm_name),
    }

    # Add any additional parameters from kwargs
    for key, value in kwargs.items():
        # Skip display_name as it's already handled
        if key == "display_name":
            continue

        # Convert Python snake_case to Keycloak camelCase
        camel_key = StringUtils.snake_to_camel_case(key)
        payload[camel_key] = value

    try:
        await self.admin_adapter.a_create_realm(payload=payload, skip_exists=skip_exists)
    except KeycloakError as e:
        logger.debug("Failed to create realm: %s", e)

        # Handle realm already exists with skip_exists option
        if skip_exists:
            error_message = self._extract_error_message(e).lower()
            if "already exists" in error_message and "realm" in error_message:
                return {"realm": realm_name, "status": "already_exists", "config": payload}

        # Use the mixin to handle realm-specific errors
        self._handle_realm_exception(e, "create_realm", realm_name)
    else:
        return {"realm": realm_name, "status": "created", "config": payload}

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_realm async

get_realm(realm_name: str) -> dict[str, Any] | None

Get realm details by realm name.

Parameters:

Name Type Description Default
realm_name str

Name of the realm

required

Returns:

Type Description
dict[str, Any] | None

Realm details

Raises:

Type Description
InternalError

If getting realm fails

Source code in archipy/adapters/keycloak/adapter_mixins/realms.py
async def get_realm(self, realm_name: str) -> dict[str, Any] | None:
    """Get realm details by realm name.

    Args:
        realm_name: Name of the realm

    Returns:
        Realm details

    Raises:
        InternalError: If getting realm fails
    """
    try:
        return await self.admin_adapter.a_get_realm(realm_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_realm")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_realm async

update_realm(
    realm_name: str, **kwargs: Any
) -> dict[str, Any] | None

Update a realm. Kwargs are RealmRepresentation top-level attributes (e.g. displayName, organizationsEnabled).

Parameters:

Name Type Description Default
realm_name str

Realm name (not the realm id).

required
**kwargs Any

RealmRepresentation attributes to update (e.g. displayName, organizationsEnabled).

{}

Returns:

Type Description
dict[str, Any] | None

Response from Keycloak, or None on error (handled via exception).

Source code in archipy/adapters/keycloak/adapter_mixins/realms.py
async def update_realm(self, realm_name: str, **kwargs: Any) -> dict[str, Any] | None:
    """Update a realm. Kwargs are RealmRepresentation top-level attributes (e.g. displayName, organizationsEnabled).

    Args:
        realm_name: Realm name (not the realm id).
        **kwargs: RealmRepresentation attributes to update (e.g. displayName, organizationsEnabled).

    Returns:
        Response from Keycloak, or None on error (handled via exception).
    """
    try:
        return await self.admin_adapter.a_update_realm(realm_name, dict(kwargs))
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "update_realm")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_id async

get_client_id(client_name: str) -> str | None

Get client ID by client name.

Parameters:

Name Type Description Default
client_name str

Name of the client

required

Returns:

Type Description
str | None

Client ID

Raises:

Type Description
ValueError

If client not found

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
@alru_cache(ttl=3600, maxsize=50)  # Cache for 1 hour
async def get_client_id(self, client_name: str) -> str | None:
    """Get client ID by client name.

    Args:
        client_name: Name of the client

    Returns:
        Client ID

    Raises:
        ValueError: If client not found
    """
    try:
        return await self.admin_adapter.a_get_client_id(client_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_client_id")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_secret async

get_client_secret(client_id: str) -> str | None

Get client secret.

Parameters:

Name Type Description Default
client_id str

Client ID

required

Returns:

Type Description
str | None

Client secret

Raises:

Type Description
ValueError

If getting secret fails

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
@alru_cache(ttl=3600, maxsize=50)  # Cache for 1 hour
async def get_client_secret(self, client_id: str) -> str | None:
    """Get client secret.

    Args:
        client_id: Client ID

    Returns:
        Client secret

    Raises:
        ValueError: If getting secret fails
    """
    try:
        client = await self.admin_adapter.a_get_client(client_id)
        return client.get("secret", "")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_client_secret")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_service_account_id async

get_service_account_id() -> str | None

Get service account user ID for the current client.

Returns:

Type Description
str | None

Service account user ID

Raises:

Type Description
ValueError

If getting service account fails

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
@alru_cache(ttl=3600, maxsize=1)  # Cache for 1 hour
async def get_service_account_id(self) -> str | None:
    """Get service account user ID for the current client.

    Returns:
        Service account user ID

    Raises:
        ValueError: If getting service account fails
    """
    try:
        client_id = await self.get_client_id(self.configs.CLIENT_ID)
        if client_id is None:
            return None
        service_account = await self.admin_adapter.a_get_client_service_account_user(client_id)
        return service_account.get("id")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_service_account_id")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client async

create_client(
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None

Create a Keycloak client with minimum required fields and optional additional config.

Parameters:

Name Type Description Default
client_id str

The client identifier (required)

required
realm str | None

Target realm name (uses the current realm in KeycloakAdmin if not specified)

None
skip_exists bool

Skip creation if client already exists

True
kwargs Any

Additional optional configurations for the client

{}

Returns:

Type Description
dict[str, Any] | None

Dictionary with client information

Raises:

Type Description
InternalError

If client creation fails

Source code in archipy/adapters/keycloak/adapter_mixins/clients.py
async def create_client(
    self,
    client_id: str,
    realm: str | None = None,
    skip_exists: bool = True,
    **kwargs: Any,
) -> dict[str, Any] | None:
    """Create a Keycloak client with minimum required fields and optional additional config.

    Args:
        client_id: The client identifier (required)
        realm: Target realm name (uses the current realm in KeycloakAdmin if not specified)
        skip_exists: Skip creation if client already exists
        kwargs: Additional optional configurations for the client

    Returns:
        Dictionary with client information

    Raises:
        InternalError: If client creation fails
    """
    original_realm = self.admin_adapter.connection.realm_name

    try:
        # Set the target realm if provided
        if realm and realm != original_realm:
            self.admin_adapter.connection.realm_name = realm

        public_client = kwargs.get("public_client", False)

        # Prepare the minimal client payload
        payload = {
            "clientId": client_id,
            "enabled": kwargs.get("enabled", True),
            "protocol": kwargs.get("protocol", "openid-connect"),
            "name": kwargs.get("name", client_id),
            "publicClient": public_client,
        }

        # Enable service accounts for confidential clients by default
        if not public_client:
            payload["serviceAccountsEnabled"] = kwargs.get("service_account_enabled", True)
            payload["clientAuthenticatorType"] = "client-secret"

        for key, value in kwargs.items():
            if key in ["enabled", "protocol", "name", "public_client", "service_account_enabled"]:
                continue

            # Convert snake_case to camelCase
            camel_key = StringUtils.snake_to_camel_case(key)
            payload[camel_key] = value

        internal_client_id = None
        try:
            internal_client_id = await self.admin_adapter.a_create_client(payload, skip_exists=skip_exists)
        except KeycloakError as e:
            logger.debug("Failed to create client: %s", e)

            # Handle client already exists with skip_exists option
            if skip_exists:
                error_message = self._extract_error_message(e).lower()
                if "already exists" in error_message and "client" in error_message:
                    return {
                        "client_id": client_id,
                        "status": "already_exists",
                        "realm": self.admin_adapter.connection.realm_name,
                    }

            # Use the mixin to handle client-specific errors
            client_data = {"clientId": client_id, "name": kwargs.get("name", client_id)}
            self._handle_client_exception(e, "create_client", client_data)

        return {
            "client_id": client_id,
            "internal_client_id": internal_client_id,
            "realm": self.admin_adapter.connection.realm_name,
            "status": "created",
        }

    finally:
        # Always restore the original realm
        if realm and realm != original_realm:
            self.admin_adapter.connection.realm_name = original_realm

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_user_roles async

get_user_roles(
    user_id: str,
) -> list[KeycloakRoleType] | None

Get roles assigned to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required

Returns:

Type Description
list[KeycloakRoleType] | None

List of roles

Raises:

Type Description
ValueError

If getting roles fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@alru_cache(ttl=300, maxsize=100)  # Cache for 5 minutes
async def get_user_roles(self, user_id: str) -> list[KeycloakRoleType] | None:
    """Get roles assigned to a user.

    Args:
        user_id: User's ID

    Returns:
        List of roles

    Raises:
        ValueError: If getting roles fails
    """
    try:
        return await self.admin_adapter.a_get_realm_roles_of_user(user_id)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_roles")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_roles_for_user async

get_client_roles_for_user(
    user_id: str, client_id: str
) -> list[KeycloakRoleType]

Get client-specific roles assigned to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
client_id str

Client ID

required

Returns:

Type Description
list[KeycloakRoleType]

List of client-specific roles

Raises:

Type Description
ValueError

If getting roles fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@alru_cache(ttl=300, maxsize=100)  # Cache for 5 minutes
async def get_client_roles_for_user(self, user_id: str, client_id: str) -> list[KeycloakRoleType]:
    """Get client-specific roles assigned to a user.

    Args:
        user_id: User's ID
        client_id: Client ID

    Returns:
        List of client-specific roles

    Raises:
        ValueError: If getting roles fails
    """
    try:
        return await self.admin_adapter.a_get_client_roles_of_user(user_id, client_id)
    except KeycloakError as e:
        raise InternalError() from e

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.has_role async

has_role(token: str, role_name: str) -> bool

Check if a user has a specific role.

Parameters:

Name Type Description Default
token str

Access token

required
role_name str

Role name to check

required

Returns:

Type Description
bool

True if user has the role, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def has_role(self, token: str, role_name: str) -> bool:
    """Check if a user has a specific role.

    Args:
        token: Access token
        role_name: Role name to check

    Returns:
        True if user has the role, False otherwise
    """
    # Not caching this result as token validation is time-sensitive
    try:
        user_info = await self.get_userinfo(token)
        if not user_info:
            return False

        # Check realm roles
        realm_access = user_info.get("realm_access", {})
        roles = realm_access.get("roles", [])
        if role_name in roles:
            return True

        # Check roles for the configured client
        resource_access = user_info.get("resource_access", {})
        client_roles = resource_access.get(self.configs.CLIENT_ID, {}).get("roles", [])
        if role_name in client_roles:
            return True

    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Role check failed: %s", e)
        return False
    else:
        return False

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.has_any_of_roles async

has_any_of_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has any of the specified roles.

Parameters:

Name Type Description Default
token str

Access token

required
role_names frozenset[str]

Set of role names to check

required

Returns:

Type Description
bool

True if user has any of the roles, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def has_any_of_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has any of the specified roles.

    Args:
        token: Access token
        role_names: Set of role names to check

    Returns:
        True if user has any of the roles, False otherwise
    """
    try:
        user_info = await self.get_userinfo(token)
        if not user_info:
            return False

        # Check realm roles first
        realm_access = user_info.get("realm_access", {})
        realm_roles = set(realm_access.get("roles", []))
        if role_names.intersection(realm_roles):
            return True

        # Check roles for the configured client
        resource_access = user_info.get("resource_access", {})
        client_roles = set(resource_access.get(self.configs.CLIENT_ID, {}).get("roles", []))
        if role_names.intersection(client_roles):
            return True

    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Role check failed: %s", e)
        return False
    else:
        return False

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.has_all_roles async

has_all_roles(
    token: str, role_names: frozenset[str]
) -> bool

Check if a user has all the specified roles.

Parameters:

Name Type Description Default
token str

Access token

required
role_names frozenset[str]

Set of role names to check

required

Returns:

Type Description
bool

True if user has all the roles, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def has_all_roles(self, token: str, role_names: frozenset[str]) -> bool:
    """Check if a user has all the specified roles.

    Args:
        token: Access token
        role_names: Set of role names to check

    Returns:
        True if user has all the roles, False otherwise
    """
    try:
        user_info = await self.get_userinfo(token)
        if not user_info:
            return False

        # Get all user roles
        all_roles = set()

        # Add realm roles
        realm_access = user_info.get("realm_access", {})
        all_roles.update(realm_access.get("roles", []))

        # Add roles from the configured client
        resource_access = user_info.get("resource_access", {})
        client_roles = resource_access.get(self.configs.CLIENT_ID, {}).get("roles", [])
        all_roles.update(client_roles)

        # Check if all required roles are present
        return role_names.issubset(all_roles)

    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("All roles check failed: %s", e)
        return False

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.assign_realm_role async

assign_realm_role(user_id: str, role_name: str) -> None

Assign a realm role to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
role_name str

Role name to assign

required

Raises:

Type Description
ValueError

If role assignment fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def assign_realm_role(self, user_id: str, role_name: str) -> None:
    """Assign a realm role to a user.

    Args:
        user_id: User's ID
        role_name: Role name to assign

    Raises:
        ValueError: If role assignment fails
    """
    # This is a write operation, no caching needed
    try:
        # Get role representation
        role = await self.admin_adapter.a_get_realm_role(role_name)
        # Assign role to user
        await self.admin_adapter.a_assign_realm_roles(user_id, [role])

        # Clear role-related caches
        if hasattr(self.get_user_roles, "cache_clear"):
            self.get_user_roles.cache_clear()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "assign_realm_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.remove_realm_role async

remove_realm_role(user_id: str, role_name: str) -> None

Remove a realm role from a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
role_name str

Role name to remove

required

Raises:

Type Description
ValueError

If role removal fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def remove_realm_role(self, user_id: str, role_name: str) -> None:
    """Remove a realm role from a user.

    Args:
        user_id: User's ID
        role_name: Role name to remove

    Raises:
        ValueError: If role removal fails
    """
    # This is a write operation, no caching needed
    try:
        # Get role representation
        role = await self.admin_adapter.a_get_realm_role(role_name)
        # Remove role from user
        await self.admin_adapter.a_delete_realm_roles_of_user(user_id, [role])

        # Clear role-related caches
        if hasattr(self.get_user_roles, "cache_clear"):
            self.get_user_roles.cache_clear()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "remove_realm_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.assign_client_role async

assign_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Assign a client-specific role to a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
client_id str

Client ID

required
role_name str

Role name to assign

required

Raises:

Type Description
ValueError

If role assignment fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def assign_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Assign a client-specific role to a user.

    Args:
        user_id: User's ID
        client_id: Client ID
        role_name: Role name to assign

    Raises:
        ValueError: If role assignment fails
    """
    # This is a write operation, no caching needed
    try:
        # Get client
        client = await self.admin_adapter.a_get_client_id(client_id)
        if client is None:
            raise InternalError(error_code="KEYCLOAK_CLIENT_ID_NONE")
        # Get role representation
        # Keycloak admin adapter methods accept these types at runtime
        role = await self.admin_adapter.a_get_client_role(client, role_name)
        # Assign role to user
        await self.admin_adapter.a_assign_client_role(user_id, client, [role])

        # Clear role-related caches
        if hasattr(self.get_client_roles_for_user, "cache_clear"):
            self.get_client_roles_for_user.cache_clear()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "assign_client_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.remove_client_role async

remove_client_role(
    user_id: str, client_id: str, role_name: str
) -> None

Remove a client-specific role from a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required
client_id str

Client ID

required
role_name str

Role name to remove

required

Raises:

Type Description
ValueError

If role removal fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def remove_client_role(self, user_id: str, client_id: str, role_name: str) -> None:
    """Remove a client-specific role from a user.

    Args:
        user_id: User's ID
        client_id: Client ID
        role_name: Role name to remove

    Raises:
        ValueError: If role removal fails
    """
    try:
        client = await self.admin_adapter.a_get_client_id(client_id)
        if client is None:
            raise InternalError(error_code="KEYCLOAK_CLIENT_ID_NONE")
        # Keycloak admin adapter methods accept these types at runtime
        role = await self.admin_adapter.a_get_client_role(client, role_name)
        await self.admin_adapter.a_delete_client_roles_of_user(user_id, client, [role])

        if hasattr(self.get_client_roles_for_user, "cache_clear"):
            self.get_client_roles_for_user.cache_clear()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "remove_client_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_realm_role async

get_realm_role(role_name: str) -> dict | None

Get realm role.

Parameters:

Name Type Description Default
role_name str

Role name

required

Returns: A realm role

Raises:

Type Description
ValueError

If getting role fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@alru_cache(ttl=300, maxsize=1)  # Cache for 5 minutes
async def get_realm_role(self, role_name: str) -> dict | None:
    """Get realm role.

    Args:
        role_name: Role name
    Returns:
        A realm role

    Raises:
        ValueError: If getting role fails
    """
    try:
        return await self.admin_adapter.a_get_realm_role(role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_realm_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_realm_roles async

get_realm_roles() -> list[dict[str, Any]] | None

Get all realm roles.

Returns:

Type Description
list[dict[str, Any]] | None

List of realm roles

Raises:

Type Description
ValueError

If getting roles fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
@alru_cache(ttl=300, maxsize=1)  # Cache for 5 minutes
async def get_realm_roles(self) -> list[dict[str, Any]] | None:
    """Get all realm roles.

    Returns:
        List of realm roles

    Raises:
        ValueError: If getting roles fails
    """
    try:
        return await self.admin_adapter.a_get_realm_roles()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_realm_roles")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_realm_role async

create_realm_role(
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new realm role.

Parameters:

Name Type Description Default
role_name str

Role name

required
description str | None

Optional role description

None
skip_exists bool

Skip creation if role already exists

True

Returns:

Type Description
dict[str, Any] | None

Created role details

Raises:

Type Description
ValueError

If role creation fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def create_realm_role(
    self,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new realm role.

    Args:
        role_name: Role name
        description: Optional role description
        skip_exists: Skip creation if role already exists

    Returns:
        Created role details

    Raises:
        ValueError: If role creation fails
    """
    # This is a write operation, no caching needed
    try:
        role_data = {"name": role_name}
        if description:
            role_data["description"] = description

        await self.admin_adapter.a_create_realm_role(role_data, skip_exists=skip_exists)

        # Clear realm roles cache
        if hasattr(self.get_realm_roles, "cache_clear"):
            self.get_realm_roles.cache_clear()

        return await self.admin_adapter.a_get_realm_role(role_name)

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "create_realm_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_realm_role async

delete_realm_role(role_name: str) -> None

Delete a realm role.

Parameters:

Name Type Description Default
role_name str

Role name to delete

required

Raises:

Type Description
ValueError

If role deletion fails

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def delete_realm_role(self, role_name: str) -> None:
    """Delete a realm role.

    Args:
        role_name: Role name to delete

    Raises:
        ValueError: If role deletion fails
    """
    # This is a write operation, no caching needed
    try:
        await self.admin_adapter.a_delete_realm_role(role_name)

        # Clear realm roles cache
        if hasattr(self.get_realm_roles, "cache_clear"):
            self.get_realm_roles.cache_clear()

        # We also need to clear user role caches since they might contain this role
        if hasattr(self.get_user_roles, "cache_clear"):
            self.get_user_roles.cache_clear()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "delete_realm_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_client_role async

create_client_role(
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None

Create a new client role.

Parameters:

Name Type Description Default
client_id str

Client ID or client name

required
role_name str

Role name

required
skip_exists bool

Skip creation if role already exists

True
description str | None

Optional role description

None

Returns:

Type Description
dict[str, Any] | None

Created role details

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def create_client_role(
    self,
    client_id: str,
    role_name: str,
    description: str | None = None,
    skip_exists: bool = True,
) -> dict[str, Any] | None:
    """Create a new client role.

    Args:
        client_id: Client ID or client name
        role_name: Role name
        skip_exists: Skip creation if role already exists
        description: Optional role description

    Returns:
        Created role details
    """
    # This is a write operation, no caching needed
    try:
        resolved_client_id = await self.admin_adapter.a_get_client_id(client_id)
        if resolved_client_id is None:
            raise NotFoundError(
                resource_type="keycloak_client",
                additional_data={"client_id": client_id},
            )

        # Prepare role data
        role_data = {"name": role_name}
        if description:
            role_data["description"] = description

        # Create client role
        await self.admin_adapter.a_create_client_role(resolved_client_id, role_data, skip_exists=skip_exists)

        # Clear related caches if they exist
        if hasattr(self.get_client_roles_for_user, "cache_clear"):
            self.get_client_roles_for_user.cache_clear()

        # Return created role
        return await self.admin_adapter.a_get_client_role(resolved_client_id, role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "create_client_role")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_realm_roles_to_composite async

add_realm_roles_to_composite(
    composite_role_name: str, child_role_names: list[str]
) -> None

Add realm roles to a composite role.

Parameters:

Name Type Description Default
composite_role_name str

Name of the composite role

required
child_role_names list[str]

List of child role names to add

required
Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def add_realm_roles_to_composite(self, composite_role_name: str, child_role_names: list[str]) -> None:
    """Add realm roles to a composite role.

    Args:
        composite_role_name: Name of the composite role
        child_role_names: List of child role names to add
    """
    try:
        child_roles = []
        for role_name in child_role_names:
            try:
                role = await self.admin_adapter.a_get_realm_role(role_name)
                child_roles.append(role)
            except KeycloakGetError as e:
                if e.response_code == HTTP_NOT_FOUND:
                    logger.warning("Child role not found: %s", role_name)
                    continue
                raise

        if child_roles:
            await self.admin_adapter.a_add_composite_realm_roles_to_role(
                role_name=composite_role_name,
                roles=child_roles,
            )
            logger.info("Added %s realm roles to composite role: %s", len(child_roles), composite_role_name)

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "add_realm_roles_to_composite")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.add_client_roles_to_composite async

add_client_roles_to_composite(
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None

Add client roles to a composite role.

Parameters:

Name Type Description Default
composite_role_name str

Name of the composite role

required
client_id str

Client ID or client name

required
child_role_names list[str]

List of child role names to add

required
Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def add_client_roles_to_composite(
    self,
    composite_role_name: str,
    client_id: str,
    child_role_names: list[str],
) -> None:
    """Add client roles to a composite role.

    Args:
        composite_role_name: Name of the composite role
        client_id: Client ID or client name
        child_role_names: List of child role names to add
    """
    try:
        internal_client_id = await self.admin_adapter.a_get_client_id(client_id)
        if internal_client_id is None:
            raise InternalError(error_code="KEYCLOAK_CLIENT_ID_NONE")

        child_roles = []
        for role_name in child_role_names:
            try:
                # Keycloak admin adapter methods accept these types at runtime
                role = await self.admin_adapter.a_get_client_role(internal_client_id, role_name)
                child_roles.append(role)
            except KeycloakGetError as e:
                if e.response_code == HTTP_NOT_FOUND:
                    logger.warning("Client role not found: %s", role_name)
                    continue
                raise

        if child_roles:
            if internal_client_id is None:
                raise NotFoundError(resource_type="keycloak_client")
            resolved_client_id: str = internal_client_id
            await self.admin_adapter.a_add_composite_client_roles_to_role(
                role_name=composite_role_name,
                client_role_id=resolved_client_id,
                roles=child_roles,
            )
            logger.info("Added %s client roles to composite role: %s", len(child_roles), composite_role_name)

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "add_client_roles_to_composite")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_composite_realm_roles async

get_composite_realm_roles(
    role_name: str,
) -> list[dict[str, Any]] | None

Get composite roles for a realm role.

Parameters:

Name Type Description Default
role_name str

Name of the role

required

Returns:

Type Description
list[dict[str, Any]] | None

List of composite roles

Source code in archipy/adapters/keycloak/adapter_mixins/roles.py
async def get_composite_realm_roles(self, role_name: str) -> list[dict[str, Any]] | None:
    """Get composite roles for a realm role.

    Args:
        role_name: Name of the role

    Returns:
        List of composite roles
    """
    try:
        return await self.admin_adapter.a_get_composite_realm_roles_of_role(role_name)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_composite_realm_roles")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_user_by_id async

get_user_by_id(user_id: str) -> KeycloakUserType | None

Get user details by user ID.

Parameters:

Name Type Description Default
user_id str

User's ID

required

Returns:

Type Description
KeycloakUserType | None

User details or None if not found

Raises:

Type Description
ValueError

If getting user fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@alru_cache(ttl=300, maxsize=100)  # Cache for 5 minutes
async def get_user_by_id(self, user_id: str) -> KeycloakUserType | None:
    """Get user details by user ID.

    Args:
        user_id: User's ID

    Returns:
        User details or None if not found

    Raises:
        ValueError: If getting user fails
    """
    try:
        return await self.admin_adapter.a_get_user(user_id)
    except KeycloakGetError as e:
        if e.response_code == HTTP_NOT_FOUND:
            return None
        raise InternalError() from e
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_by_id")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_user_by_username async

get_user_by_username(
    username: str,
) -> KeycloakUserType | None

Get user details by username.

Parameters:

Name Type Description Default
username str

User's username

required

Returns:

Type Description
KeycloakUserType | None

User details or None if not found

Raises:

Type Description
ValueError

If query fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@alru_cache(ttl=300, maxsize=100)  # Cache for 5 minutes
async def get_user_by_username(self, username: str) -> KeycloakUserType | None:
    """Get user details by username.

    Args:
        username: User's username

    Returns:
        User details or None if not found

    Raises:
        ValueError: If query fails
    """
    try:
        users = await self.admin_adapter.a_get_users({"username": username})
        return users[0] if users else None
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_by_username")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_user_by_email async

get_user_by_email(email: str) -> KeycloakUserType | None

Get user details by email.

Parameters:

Name Type Description Default
email str

User's email

required

Returns:

Type Description
KeycloakUserType | None

User details or None if not found

Raises:

Type Description
ValueError

If query fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@alru_cache(ttl=300, maxsize=100)  # Cache for 5 minutes
async def get_user_by_email(self, email: str) -> KeycloakUserType | None:
    """Get user details by email.

    Args:
        email: User's email

    Returns:
        User details or None if not found

    Raises:
        ValueError: If query fails
    """
    try:
        users = await self.admin_adapter.a_get_users({"email": email})
        return users[0] if users else None
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_user_by_email")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.create_user async

create_user(user_data: dict[str, Any]) -> str | None

Create a new user in Keycloak.

Parameters:

Name Type Description Default
user_data dict[str, Any]

User data including username, email, etc.

required

Returns:

Type Description
str | None

ID of the created user

Raises:

Type Description
ValueError

If creating user fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
async def create_user(self, user_data: dict[str, Any]) -> str | None:
    """Create a new user in Keycloak.

    Args:
        user_data: User data including username, email, etc.

    Returns:
        ID of the created user

    Raises:
        ValueError: If creating user fails
    """
    # This is a write operation, no caching needed
    try:
        user_id = await self.admin_adapter.a_create_user(user_data)

        # Clear related caches
        self.clear_all_caches()
    except KeycloakError as e:
        self._handle_user_exception(e, "create_user", user_data)
    else:
        return user_id

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.update_user async

update_user(
    user_id: str, user_data: dict[str, Any]
) -> None

Update user details.

Parameters:

Name Type Description Default
user_id str

User's ID

required
user_data dict[str, Any]

User data to update

required

Raises:

Type Description
ValueError

If updating user fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
async def update_user(self, user_id: str, user_data: dict[str, Any]) -> None:
    """Update user details.

    Args:
        user_id: User's ID
        user_data: User data to update

    Raises:
        ValueError: If updating user fails
    """
    # This is a write operation, no caching needed
    try:
        await self.admin_adapter.a_update_user(user_id, user_data)

        # Clear user-related caches
        self.clear_all_caches()

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "update_user")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.reset_password async

reset_password(
    user_id: str, password: str, temporary: bool = False
) -> None

Reset a user's password.

Parameters:

Name Type Description Default
user_id str

User's ID

required
password str

New password

required
temporary bool

Whether the password is temporary and should be changed on next login

False

Raises:

Type Description
ValueError

If password reset fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
async def reset_password(self, user_id: str, password: str, temporary: bool = False) -> None:
    """Reset a user's password.

    Args:
        user_id: User's ID
        password: New password
        temporary: Whether the password is temporary and should be changed on next login

    Raises:
        ValueError: If password reset fails
    """
    # This is a write operation, no caching needed
    try:
        await self.admin_adapter.a_set_user_password(user_id, password, temporary)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "reset_password")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.search_users async

search_users(
    query: str, max_results: int = 100
) -> list[KeycloakUserType] | None

Search for users by username, email, or name.

Parameters:

Name Type Description Default
query str

Search query

required
max_results int

Maximum number of results to return

100

Returns:

Type Description
list[KeycloakUserType] | None

List of matching users

Raises:

Type Description
ValueError

If search fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
@alru_cache(ttl=30, maxsize=50)  # Cache for 30 seconds with limited entries
async def search_users(self, query: str, max_results: int = 100) -> list[KeycloakUserType] | None:
    """Search for users by username, email, or name.

    Args:
        query: Search query
        max_results: Maximum number of results to return

    Returns:
        List of matching users

    Raises:
        ValueError: If search fails
    """
    try:
        # Try searching by different fields
        users = []

        # Search by username
        users.extend(await self.admin_adapter.a_get_users({"username": query, "max": max_results}))

        # Search by email if no results or incomplete results
        if len(users) < max_results:
            remaining = max_results - len(users)
            email_users = await self.admin_adapter.a_get_users({"email": query, "max": remaining})
            # Filter out duplicates
            user_ids = {user["id"] for user in users}
            users.extend([user for user in email_users if user["id"] not in user_ids])

        # Search by firstName if no results or incomplete results
        if len(users) < max_results:
            remaining = max_results - len(users)
            first_name_users = await self.admin_adapter.a_get_users({"firstName": query, "max": remaining})
            # Filter out duplicates
            user_ids = {user["id"] for user in users}
            users.extend([user for user in first_name_users if user["id"] not in user_ids])

        # Search by lastName if no results or incomplete results
        if len(users) < max_results:
            remaining = max_results - len(users)
            last_name_users = await self.admin_adapter.a_get_users({"lastName": query, "max": remaining})
            # Filter out duplicates
            user_ids = {user["id"] for user in users}
            users.extend([user for user in last_name_users if user["id"] not in user_ids])

        return users[:max_results]
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "search_users")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.clear_user_sessions async

clear_user_sessions(user_id: str) -> None

Clear all sessions for a user.

Parameters:

Name Type Description Default
user_id str

User's ID

required

Raises:

Type Description
ValueError

If clearing sessions fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
async def clear_user_sessions(self, user_id: str) -> None:
    """Clear all sessions for a user.

    Args:
        user_id: User's ID

    Raises:
        ValueError: If clearing sessions fails
    """
    try:
        await self.admin_adapter.a_user_logout(user_id)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "clear_user_sessions")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.delete_user async

delete_user(user_id: str) -> None

Delete a user from Keycloak by their ID.

Parameters:

Name Type Description Default
user_id str

The ID of the user to delete

required

Raises:

Type Description
ValueError

If the deletion fails

Source code in archipy/adapters/keycloak/adapter_mixins/users.py
async def delete_user(self, user_id: str) -> None:
    """Delete a user from Keycloak by their ID.

    Args:
        user_id: The ID of the user to delete

    Raises:
        ValueError: If the deletion fails
    """
    try:
        await self.admin_adapter.a_delete_user(user_id=user_id)

        if hasattr(self.get_user_by_username, "cache_clear"):
            self.get_user_by_username.cache_clear()

        logger.info("Successfully deleted user with ID %s", user_id)

    except KeycloakError as e:
        self._handle_keycloak_exception(e, "delete_user")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_token async

get_token(
    username: str, password: str
) -> KeycloakTokenType | None

Get a user token by username and password using the Resource Owner Password Credentials Grant.

Warning

This method uses the direct password grant flow, which is less secure and not recommended for user login in production environments. Instead, prefer the web-based OAuth 2.0 Authorization Code Flow (use get_token_from_code) for secure authentication. Use this method only for testing, administrative tasks, or specific service accounts where direct credential use is acceptable and properly secured.

Parameters:

Name Type Description Default
username str

User's username

required
password str

User's password

required

Returns:

Type Description
KeycloakTokenType | None

Token response containing access_token, refresh_token, etc.

Raises:

Type Description
InvalidCredentialsError

If username or password is invalid

ServiceUnavailableError

If Keycloak service is unavailable

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def get_token(self, username: str, password: str) -> KeycloakTokenType | None:
    """Get a user token by username and password using the Resource Owner Password Credentials Grant.

    Warning:
        This method uses the direct password grant flow, which is less secure and not recommended
        for user login in production environments. Instead, prefer the web-based OAuth 2.0
        Authorization Code Flow (use `get_token_from_code`) for secure authentication.
        Use this method only for testing, administrative tasks, or specific service accounts
        where direct credential use is acceptable and properly secured.

    Args:
        username: User's username
        password: User's password

    Returns:
        Token response containing access_token, refresh_token, etc.

    Raises:
        InvalidCredentialsError: If username or password is invalid
        ServiceUnavailableError: If Keycloak service is unavailable
    """
    try:
        return await self.openid_adapter.a_token(grant_type="password", username=username, password=password)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_token")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.refresh_token async

refresh_token(
    refresh_token: str,
) -> KeycloakTokenType | None

Refresh an existing token using a refresh token.

Parameters:

Name Type Description Default
refresh_token str

Refresh token string

required

Returns:

Type Description
KeycloakTokenType | None

New token response containing access_token, refresh_token, etc.

Raises:

Type Description
InvalidTokenError

If refresh token is invalid or expired

ServiceUnavailableError

If Keycloak service is unavailable

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def refresh_token(self, refresh_token: str) -> KeycloakTokenType | None:
    """Refresh an existing token using a refresh token.

    Args:
        refresh_token: Refresh token string

    Returns:
        New token response containing access_token, refresh_token, etc.

    Raises:
        InvalidTokenError: If refresh token is invalid or expired
        ServiceUnavailableError: If Keycloak service is unavailable
    """
    try:
        return await self.openid_adapter.a_refresh_token(refresh_token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "refresh_token")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.validate_token async

validate_token(token: str) -> bool

Validate if a token is still valid.

Parameters:

Name Type Description Default
token str

Access token to validate

required

Returns:

Type Description
bool

True if token is valid, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def validate_token(self, token: str) -> bool:
    """Validate if a token is still valid.

    Args:
        token: Access token to validate

    Returns:
        True if token is valid, False otherwise
    """
    # Not caching validation results as tokens are time-sensitive
    try:
        await self.openid_adapter.a_decode_token(
            token,
            key=await self.get_public_key(),
        )
    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Token validation failed: %s", e)
        return False
    else:
        return True

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_userinfo async

get_userinfo(token: str) -> KeycloakUserType | None

Get user information from a token via the UserInfo endpoint.

The UserInfo endpoint validates the token server-side, so no local validation is needed here.

Parameters:

Name Type Description Default
token str

Access token

required

Returns:

Type Description
KeycloakUserType | None

User information

Raises:

Type Description
ValueError

If getting user info fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def get_userinfo(self, token: str) -> KeycloakUserType | None:
    """Get user information from a token via the UserInfo endpoint.

    The UserInfo endpoint validates the token server-side, so no local
    validation is needed here.

    Args:
        token: Access token

    Returns:
        User information

    Raises:
        ValueError: If getting user info fails
    """
    try:
        return await self._get_userinfo_cached(token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_userinfo")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_token_info async

get_token_info(token: str) -> dict[str, Any] | None

Decode token to get its claims.

Parameters:

Name Type Description Default
token str

Access token

required

Returns:

Type Description
dict[str, Any] | None

Dictionary of token claims

Raises:

Type Description
ValueError

If token decoding fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def get_token_info(self, token: str) -> dict[str, Any] | None:
    """Decode token to get its claims.

    Args:
        token: Access token

    Returns:
        Dictionary of token claims

    Raises:
        ValueError: If token decoding fails
    """
    try:
        return await self.openid_adapter.a_decode_token(
            token,
            key=await self.get_public_key(),
        )
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_token_info")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.introspect_token async

introspect_token(token: str) -> dict[str, Any] | None

Introspect token to get detailed information about it.

Parameters:

Name Type Description Default
token str

Access token

required

Returns:

Type Description
dict[str, Any] | None

Token introspection details

Raises:

Type Description
ValueError

If token introspection fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def introspect_token(self, token: str) -> dict[str, Any] | None:
    """Introspect token to get detailed information about it.

    Args:
        token: Access token

    Returns:
        Token introspection details

    Raises:
        ValueError: If token introspection fails
    """
    try:
        return await self.openid_adapter.a_introspect(token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "introspect_token")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_client_credentials_token async

get_client_credentials_token() -> KeycloakTokenType | None

Get token using client credentials.

Returns:

Type Description
KeycloakTokenType | None

Token response

Raises:

Type Description
ValueError

If token acquisition fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def get_client_credentials_token(self) -> KeycloakTokenType | None:
    """Get token using client credentials.

    Returns:
        Token response

    Raises:
        ValueError: If token acquisition fails
    """
    # Tokens are time-sensitive, don't cache
    try:
        return await self.openid_adapter.a_token(grant_type="client_credentials")
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_client_credentials_token")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.logout async

logout(refresh_token: str) -> None

Logout user by invalidating their refresh token.

Parameters:

Name Type Description Default
refresh_token str

Refresh token to invalidate

required

Raises:

Type Description
ValueError

If logout fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def logout(self, refresh_token: str) -> None:
    """Logout user by invalidating their refresh token.

    Args:
        refresh_token: Refresh token to invalidate

    Raises:
        ValueError: If logout fails
    """
    try:
        await self.openid_adapter.a_logout(refresh_token)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "logout")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_public_key async

get_public_key() -> PublicKeyType

Get the public key used to verify tokens.

Returns:

Type Description
PublicKeyType

JWK key object used to verify signatures

Raises:

Type Description
ServiceUnavailableError

If Keycloak service is unavailable

InternalError

If there's an internal error processing the public key

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@alru_cache(ttl=3600, maxsize=1)  # Cache for 1 hour, public key rarely changes
async def get_public_key(self) -> PublicKeyType:
    """Get the public key used to verify tokens.

    Returns:
        JWK key object used to verify signatures

    Raises:
        ServiceUnavailableError: If Keycloak service is unavailable
        InternalError: If there's an internal error processing the public key
    """
    try:
        keys_info = await self.openid_adapter.a_public_key()
        key = f"-----BEGIN PUBLIC KEY-----\n{keys_info}\n-----END PUBLIC KEY-----"
        return jwk.JWK.from_pem(key.encode("utf-8"))
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_public_key")
    except Exception as e:  # soft-fail authz/role checks; JWT/Keycloak libs
        raise InternalError(additional_data={"operation": "get_public_key", "error": str(e)}) from e

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_well_known_config async

get_well_known_config() -> dict[str, Any] | None

Get the well-known OpenID configuration.

Returns:

Type Description
dict[str, Any] | None

OIDC configuration

Raises:

Type Description
ValueError

If getting configuration fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@alru_cache(ttl=3600, maxsize=1)  # Cache for 1 hour
async def get_well_known_config(self) -> dict[str, Any] | None:
    """Get the well-known OpenID configuration.

    Returns:
        OIDC configuration

    Raises:
        ValueError: If getting configuration fails
    """
    try:
        return await self.openid_adapter.a_well_known()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_well_known_config")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_certs async

get_certs() -> dict[str, Any] | None

Get the JWT verification certificates.

Returns:

Type Description
dict[str, Any] | None

Certificate information

Raises:

Type Description
ValueError

If getting certificates fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@alru_cache(ttl=3600, maxsize=1)  # Cache for 1 hour
async def get_certs(self) -> dict[str, Any] | None:
    """Get the JWT verification certificates.

    Returns:
        Certificate information

    Raises:
        ValueError: If getting certificates fails
    """
    try:
        return await self.openid_adapter.a_certs()
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_certs")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.get_token_from_code async

get_token_from_code(
    code: str, redirect_uri: str
) -> KeycloakTokenType | None

Exchange authorization code for token.

Parameters:

Name Type Description Default
code str

Authorization code

required
redirect_uri str

Redirect URI used in authorization request

required

Returns:

Type Description
KeycloakTokenType | None

Token response

Raises:

Type Description
ValueError

If token exchange fails

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def get_token_from_code(self, code: str, redirect_uri: str) -> KeycloakTokenType | None:
    """Exchange authorization code for token.

    Args:
        code: Authorization code
        redirect_uri: Redirect URI used in authorization request

    Returns:
        Token response

    Raises:
        ValueError: If token exchange fails
    """
    # Authorization codes can only be used once, don't cache
    try:
        return await self.openid_adapter.a_token(
            grant_type="authorization_code",
            code=code,
            redirect_uri=redirect_uri,
        )
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "get_token_from_code")

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.check_permissions async

check_permissions(
    token: str, resource: str, scope: str
) -> bool

Check if a user has permission to access a resource with the specified scope.

Prefer :meth:check_permissions_batch when checking multiple pairs per request.

Parameters:

Name Type Description Default
token str

Access token

required
resource str

Resource name

required
scope str

Permission scope

required

Returns:

Type Description
bool

True if permission granted, False otherwise

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
async def check_permissions(self, token: str, resource: str, scope: str) -> bool:
    """Check if a user has permission to access a resource with the specified scope.

    Prefer :meth:`check_permissions_batch` when checking multiple pairs per request.

    Args:
        token: Access token
        resource: Resource name
        scope: Permission scope

    Returns:
        True if permission granted, False otherwise
    """
    try:
        # Use UMA permissions endpoint to check specific resource and scope
        permissions = await self.openid_adapter.a_uma_permissions(token, permissions=f"{resource}#{scope}")

        # Check if the response indicates permission is granted
        if not permissions or not isinstance(permissions, list):
            logger.debug("No permissions returned or invalid response format")
            return False

        # Look for the specific permission in the response
        for perm in permissions:
            if perm.get("rsname") == resource and scope in perm.get("scopes", []):
                return True

    except KeycloakError as e:
        logger.debug("Permission check failed with Keycloak error: %s", e)
        return False
    except Exception as e:  # noqa: BLE001  # soft-fail authz/role checks; JWT/Keycloak libs
        logger.debug("Permission check failed with unexpected error: %s", e)
        return False
    else:
        return False

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.check_permissions_batch async

check_permissions_batch(
    token: str, permissions: tuple[tuple[str, str], ...]
) -> frozenset[tuple[str, str]]

Return the subset of (resource, scope) pairs the token is authorized for in one UMA call.

Prefer this over :meth:check_permissions when multiple pairs must be checked per request.

Parameters:

Name Type Description Default
token str

Access token

required
permissions tuple[tuple[str, str], ...]

Tuple of (resource, scope) pairs to check

required

Returns:

Type Description
frozenset[tuple[str, str]]

Subset of permissions that are granted

Source code in archipy/adapters/keycloak/adapter_mixins/auth.py
@alru_cache(ttl=30, maxsize=200)
async def check_permissions_batch(
    self,
    token: str,
    permissions: tuple[tuple[str, str], ...],
) -> frozenset[tuple[str, str]]:
    """Return the subset of (resource, scope) pairs the token is authorized for in one UMA call.

    Prefer this over :meth:`check_permissions` when multiple pairs must be checked per request.

    Args:
        token: Access token
        permissions: Tuple of (resource, scope) pairs to check

    Returns:
        Subset of ``permissions`` that are granted
    """
    if not permissions:
        return frozenset()
    perm_strs = [f"{resource}#{scope}" for resource, scope in permissions]
    try:
        results = await self.openid_adapter.a_uma_permissions(token, permissions=perm_strs)
    except KeycloakError as e:
        self._handle_keycloak_exception(e, "check_permissions_batch")
    if not results or not isinstance(results, list):
        return frozenset()
    granted: set[tuple[str, str]] = set()
    requested = set(permissions)
    for perm in results:
        rsname = perm.get("rsname")
        for scope in perm.get("scopes", []) or []:
            pair = (rsname, scope)
            if pair in requested:
                granted.add(pair)
    return frozenset(granted)

archipy.adapters.keycloak.adapters.AsyncKeycloakAdapter.clear_all_caches

clear_all_caches() -> None

Clear all cached values.

Source code in archipy/adapters/keycloak/adapter_mixins/connection.py
def clear_all_caches(self) -> None:
    """Clear all cached values."""
    for attr_name in dir(self):
        attr = getattr(self, attr_name)
        if hasattr(attr, "cache_clear"):
            attr.cache_clear()

options: show_root_toc_entry: false heading_level: 3