@ -1523,14 +1523,37 @@ class KeycloakAdmin:
data_raw , KeycloakPostError , expected_codes = [ 201 ] , skip_exists = skip_exists
data_raw , KeycloakPostError , expected_codes = [ 201 ] , skip_exists = skip_exists
)
)
def delete_client_authz_resource ( self , client_id : str , resource_id : str ) :
""" Delete a client resource.
: param client_id : id in ClientRepresentation
https : / / www . keycloak . org / docs - api / 18.0 / rest - api / index . html #_clientrepresentation
: type client_id : str
: param resource_id : id in ResourceRepresentation
https : / / www . keycloak . org / docs - api / 18.0 / rest - api / index . html #_resourcerepresentation
: type resource_id : str
: return : Keycloak server response
: rtype : bytes
"""
params_path = {
" realm-name " : self . connection . realm_name ,
" id " : client_id ,
" resource-id " : resource_id ,
}
data_raw = self . connection . raw_delete (
urls_patterns . URL_ADMIN_CLIENT_AUTHZ_RESOURCE . format ( * * params_path )
)
return raise_error_from_response ( data_raw , KeycloakDeleteError , expected_codes = [ 204 ] )
def get_client_authz_resources ( self , client_id ) :
def get_client_authz_resources ( self , client_id ) :
""" Get resources from client.
""" Get resources from client.
: param client_id : id in ClientRepresentation
: param client_id : id in ClientRepresentation
https : / / www . keycloak . org / docs - api / 18.0 / rest - api / index . html #_clientrepresentation
https : / / www . keycloak . org / docs - api / 18.0 / rest - api / index . html #_clientrepresentation
: type client_id : str
: type client_id : str
: return : Keycloak server response
: rtype : dict
: return : Keycloak server response ( ResourceRepresentation )
: rtype : lis t
"""
"""
params_path = { " realm-name " : self . connection . realm_name , " id " : client_id }
params_path = { " realm-name " : self . connection . realm_name , " id " : client_id }
data_raw = self . connection . raw_get (
data_raw = self . connection . raw_get (
@ -1538,6 +1561,29 @@ class KeycloakAdmin:
)
)
return raise_error_from_response ( data_raw , KeycloakGetError )
return raise_error_from_response ( data_raw , KeycloakGetError )
def get_client_authz_resource ( self , client_id : str , resource_id : str ) :
""" Get a client resource.
: param client_id : id in ClientRepresentation
https : / / www . keycloak . org / docs - api / 18.0 / rest - api / index . html #_clientrepresentation
: type client_id : str
: param resource_id : id in ResourceRepresentation
https : / / www . keycloak . org / docs - api / 18.0 / rest - api / index . html #_resourcerepresentation
: type resource_id : str
: return : Keycloak server response ( ResourceRepresentation )
: rtype : dict
"""
params_path = {
" realm-name " : self . connection . realm_name ,
" id " : client_id ,
" resource-id " : resource_id ,
}
data_raw = self . connection . raw_get (
urls_patterns . URL_ADMIN_CLIENT_AUTHZ_RESOURCE . format ( * * params_path )
)
return raise_error_from_response ( data_raw , KeycloakGetError , expected_codes = [ 200 ] )
def create_client_authz_role_based_policy ( self , client_id , payload , skip_exists = False ) :
def create_client_authz_role_based_policy ( self , client_id , payload , skip_exists = False ) :
""" Create role-based policy of client.
""" Create role-based policy of client.