Types¶
This module provides a typed schema of the Keycloak input and outputs.
There’s a few ways in which you can instantiate a dataclass including some not provided by the standard libarary:
Instantiate a dataclass with keyword arguments¶
from keycloak_admin_aio import RoleRepresentation
role_representation = RoleRepresentation(
name="role-name", description="role-description"
)
## or from a dict
role_representation = RoleRepresentation(
**{"name": "role-name", "description": "role-description"}
)
Instantiate a dataclass with the from_dict class method¶
The above works well if you have a flat data model. If you have a dataclass
which uses other dataclasses using **
with a dict will not work as
expected. If you have a nested data structure you should use the from_dict
function.
from keycloak_admin_aio import ClientMappingsRepresentation
client_mapping_representation = ClientMappingsRepresentation(
client="some-client", mappings=[RoleRepresentation(name="some-role")]
)
# can also be done like this
client_mapping_representation = ClientMappingsRepresentation.from_dict(
{"client": "some-client", "mappings": [{"name": "some-role"}]}
)
assert client_mapping_representation.mappings[0].name == "some-role"
Instantiate a list of dataclasses with the from_list class method¶
If you have a list of dictionaries you want to parse into a list of dataclasses
you use the from_list
method.
from keycloak_admin_aio import RoleRepresentation
roles = [{"name": "A"}, {"name": "B"}, {"name": "C"}]
roles = RoleRepresentation.from_list(roles)
- class keycloak_admin_aio.types.RoleRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#RoleRepresentation
- __init__(id=None, name=None, description=None, containerId=None, composites=None, composite=None, clientRole=None, attributes=None)¶
- Parameters:
id (str | None)
name (str | None)
description (str | None)
containerId (str | None)
composites (RoleRepresentationComposites | None)
composite (bool | None)
clientRole (bool | None)
attributes (dict[str, list[str]] | None)
- Return type:
None
- class keycloak_admin_aio.types.RoleRepresentationComposites¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#RoleRepresentation
- __init__(realm=None, client=None)¶
- Parameters:
realm (list[str] | None)
client (dict[str, list[str]] | None)
- Return type:
None
- class keycloak_admin_aio.types.ClientMappingsRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ClientMappingsRepresentation
- __init__(id=None, client=None, mappings=None)¶
- Parameters:
id (str | None)
client (str | None)
mappings (list[RoleRepresentation] | None)
- Return type:
None
- class keycloak_admin_aio.types.MappingsRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#MappingsRepresentation
- __init__(clientMappings=None, realmMappings=None)¶
- Parameters:
clientMappings (dict[str, ClientMappingsRepresentation] | None)
realmMappings (list[RoleRepresentation] | None)
- Return type:
None
- class keycloak_admin_aio.types.ProtocolMapperRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ProtocolMapperRepresentation
- __init__(id=None, name=None, protocol=None, protocolMapper=None)¶
- Parameters:
id (str | None)
name (str | None)
protocol (str | None)
protocolMapper (str | None)
- Return type:
None
- class keycloak_admin_aio.types.ClientScopeRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ClientScopeRepresentation
- __init__(id=None, name=None, description=None, protocol=None, protocolMappers=None, attributes=None)¶
- Parameters:
id (str | None)
name (str | None)
description (str | None)
protocol (str | None)
protocolMappers (list[ProtocolMapperRepresentation] | None)
attributes (dict[str, str] | None)
- Return type:
None
- class keycloak_admin_aio.types.FederatedIdentityRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#FederatedIdentityRepresentation
- __init__(userId=None, userName=None, identityProvider=None)¶
- Parameters:
userId (str | None)
userName (str | None)
identityProvider (str | None)
- Return type:
None
- class keycloak_admin_aio.types.CredentialRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#CredentialRepresentation
- __init__(id=None, createdDate=None, credentialData=None, priority=None, secretData=None, temporary=None, type=None, userLabel=None, value=None)¶
- Parameters:
id (str | None)
createdDate (int | None)
credentialData (str | None)
priority (int | None)
secretData (str | None)
temporary (bool | None)
type (str | None)
userLabel (str | None)
value (str | None)
- Return type:
None
- class keycloak_admin_aio.types.UserConsentRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#UserConsentRepresentation
- __init__(clientId=None, createdDate=None, grantedClientScopes=None, lastUpdatedDate=None)¶
- Parameters:
clientId (str | None)
createdDate (int | None)
grantedClientScopes (list[str] | None)
lastUpdatedDate (int | None)
- Return type:
None
- class keycloak_admin_aio.types.UserRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#UserRepresentation
- __init__(id=None, firstName=None, lastName=None, email=None, emailVerified=None, username=None, requiredActions=None, createdTimestamp=None, federationLink=None, federatedIdentities=None, enabled=None, disableableCredentialTypes=None, credentials=None, notBefore=None, access=None, attributes=None, clientConsents=None, totp=None, self=None, origin=None, realmRoles=None, groups=None, serviceAccountClientId=None, clientRoles=None)¶
- Parameters:
id (str | None)
firstName (str | None)
lastName (str | None)
email (str | None)
emailVerified (bool | None)
username (str | None)
requiredActions (list[str] | None)
createdTimestamp (int | None)
federationLink (str | None)
federatedIdentities (list[FederatedIdentityRepresentation] | None)
enabled (bool | None)
disableableCredentialTypes (list[str] | None)
credentials (list[CredentialRepresentation] | None)
notBefore (int | None)
access (dict[str, bool] | None)
attributes (dict[str, list[str]] | None)
clientConsents (list[UserConsentRepresentation] | None)
totp (bool | None)
self (str | None)
origin (str | None)
realmRoles (list[str] | None)
groups (list[str] | None)
serviceAccountClientId (str | None)
clientRoles (dict[str, Any] | None)
- Return type:
None
- class keycloak_admin_aio.types.GroupRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#GroupRepresentation
- __init__(id=None, name=None, realmRoles=None, path=None, subGroups=None, clientRoles=None, attributes=None, access=None)¶
- Parameters:
id (str | None)
name (str | None)
realmRoles (list[str] | None)
path (str | None)
subGroups (list[GroupRepresentation] | None)
clientRoles (dict[str, Any] | None)
attributes (dict[str, list[str]] | None)
access (dict[str, bool] | None)
- Return type:
None
- class keycloak_admin_aio.types.ScopeRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ScopeRepresentation
- __init__(id=None, name=None, displayName=None, iconUri=None, policies=None, resources=None)¶
- Parameters:
id (str | None)
name (str | None)
displayName (str | None)
iconUri (str | None)
policies (list[PolicyRepresentation] | None)
resources (list[ResourceRepresentation] | None)
- Return type:
None
- class keycloak_admin_aio.types.ResourceRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ResourceRepresentation
- __init__(id=None, name=None, displayName=None, icon_uri=None, attributes=None, ownerManagedAccess=None, scopes=None, type=None, uris=None)¶
- Parameters:
id (str | None)
name (str | None)
displayName (str | None)
icon_uri (str | None)
attributes (dict[str, str] | None)
ownerManagedAccess (bool | None)
scopes (list[ScopeRepresentation] | None)
type (str | None)
uris (list[str] | None)
- Return type:
None
- class keycloak_admin_aio.types.PolicyRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#PolicyRepresentation
- __init__(id=None, name=None, description=None, config=None, owner=None, logic=None, policies=None, resources=None, resourcesData=None, scopes=None, scopesData=None, type=None)¶
- Parameters:
id (str | None)
name (str | None)
description (str | None)
config (dict[str, str] | None)
owner (str | None)
logic (str | None)
policies (list[str] | None)
resources (list[str] | None)
resourcesData (list[ResourceRepresentation] | None)
scopes (list[str] | None)
scopesData (list[ScopeRepresentation] | None)
type (str | None)
- Return type:
None
- class keycloak_admin_aio.types.ResourceServerRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ResourceServerRepresentation
- __init__(id=None, name=None, allowRemoteResourceManagement=None, clientId=None, decisionStrategy=None, policyEnforcementMode=None, resources=None, scopes=None, policies=None)¶
- Parameters:
id (str | None)
name (str | None)
allowRemoteResourceManagement (bool | None)
clientId (str | None)
decisionStrategy (Literal['AFFIRMATIVE', 'UNANIMOUS', 'CONSENSUS'] | None)
policyEnforcementMode (Literal['ENFORCING', 'PERMISSIVE', 'DISABLED'] | None)
resources (list[ResourceRepresentation] | None)
scopes (list[ScopeRepresentation] | None)
policies (list[PolicyRepresentation] | None)
- Return type:
None
- class keycloak_admin_aio.types.ClientRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#ClientRepresentation
- __init__(id=None, name=None, access=None, adminUrl=None, alwaysDisplayInConsole=None, attributes=None, authenticationFlowBindingOverrides=None, authorizationServicesEnabled=None, authorizationSettings=None, baseUrl=None, bearerOnly=None, clientAuthenticatorType=None, clientId=None, consentRequired=None, defaultClientScopes=None, description=None, directAccessGrantsEnabled=None, enabled=None, frontchannelLogout=None, fullScopeAllowed=None, implicitFlowEnabled=None, nodeReRegistrationTimeout=None, notBefore=None, oauth2DeviceAuthorizationGrantEnabled=None, optionalClientScopes=None, origin=None, protocol=None, protocolMappers=None, publicClient=None, redirectUris=None, registeredNodes=None, registrationAccessToken=None, rootUrl=None, secret=None, serviceAccountsEnabled=None, standardFlowEnabled=None, surrogateAuthRequired=None, webOrigins=None)¶
- Parameters:
id (str | None)
name (str | None)
access (dict[str, bool] | None)
adminUrl (str | None)
alwaysDisplayInConsole (bool | None)
attributes (dict[str, str] | None)
authenticationFlowBindingOverrides (dict[str, str] | None)
authorizationServicesEnabled (bool | None)
authorizationSettings (ResourceServerRepresentation | None)
baseUrl (str | None)
bearerOnly (bool | None)
clientAuthenticatorType (str | None)
clientId (str | None)
consentRequired (bool | None)
defaultClientScopes (list[str] | None)
description (str | None)
directAccessGrantsEnabled (bool | None)
enabled (bool | None)
frontchannelLogout (bool | None)
fullScopeAllowed (bool | None)
implicitFlowEnabled (bool | None)
nodeReRegistrationTimeout (int | None)
notBefore (int | None)
oauth2DeviceAuthorizationGrantEnabled (bool | None)
optionalClientScopes (list[str] | None)
origin (str | None)
protocol (str | None)
protocolMappers (list[ProtocolMapperRepresentation] | None)
publicClient (bool | None)
redirectUris (list[str] | None)
registeredNodes (dict[str, str] | None)
registrationAccessToken (str | None)
rootUrl (str | None)
secret (str | None)
serviceAccountsEnabled (bool | None)
standardFlowEnabled (bool | None)
surrogateAuthRequired (bool | None)
webOrigins (list[str] | None)
- Return type:
None
- class keycloak_admin_aio.types.RequiredActionProviderRepresentation¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#RequiredActionProviderRepresentation
- __init__(alias=None, config=None, defaultAction=None, enabled=None, name=None, priority=None, providerId=None)¶
- Parameters:
alias (str | None)
config (dict[str, Any] | None)
defaultAction (bool | None)
enabled (bool | None)
name (str | None)
priority (int | None)
providerId (str | None)
- Return type:
None
- class keycloak_admin_aio.types.UserSession¶
This is no default Keycloak representation.
- __init__(clients=None, id=None, ipAddress=None, lastAccess=None, start=None, userId=None, username=None)¶
- Parameters:
clients (dict[str, str] | None)
id (str | None)
ipAddress (str | None)
lastAccess (int | None)
start (int | None)
userId (str | None)
username (str | None)
- Return type:
None