|
|
@ -42,7 +42,7 @@ from .urls_patterns import URL_ADMIN_SERVER_INFO, URL_ADMIN_CLIENT_AUTHZ_RESOURC |
|
|
|
URL_ADMIN_GROUP_MEMBERS, URL_ADMIN_USER_STORAGE, URL_ADMIN_GROUP_PERMISSIONS, URL_ADMIN_IDPS, \ |
|
|
|
URL_ADMIN_USER_CLIENT_ROLES_AVAILABLE, URL_ADMIN_USERS, URL_ADMIN_CLIENT_SCOPES, \ |
|
|
|
URL_ADMIN_CLIENT_SCOPES_ADD_MAPPER, URL_ADMIN_CLIENT_SCOPE, URL_ADMIN_CLIENT_SECRETS, \ |
|
|
|
URL_ADMIN_USER_REALM_ROLES |
|
|
|
URL_ADMIN_USER_REALM_ROLES, URL_ADMIN_COMPONENTS, URL_ADMIN_COMPONENT |
|
|
|
|
|
|
|
|
|
|
|
class KeycloakAdmin: |
|
|
@ -1174,6 +1174,78 @@ class KeycloakAdmin: |
|
|
|
data_raw = self.raw_get(URL_ADMIN_CLIENT_SECRETS.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
def get_components(self, query=None): |
|
|
|
""" |
|
|
|
Return a list of components, filtered according to query parameters |
|
|
|
|
|
|
|
ComponentRepresentation |
|
|
|
https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_componentrepresentation |
|
|
|
|
|
|
|
:param query: Query parameters (optional) |
|
|
|
:return: components list |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name} |
|
|
|
return self.__fetch_all(URL_ADMIN_COMPONENTS.format(**params_path), query) |
|
|
|
|
|
|
|
def create_component(self, payload): |
|
|
|
""" |
|
|
|
Create a new component. |
|
|
|
|
|
|
|
ComponentRepresentation |
|
|
|
https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_componentrepresentation |
|
|
|
|
|
|
|
:param payload: ComponentRepresentation |
|
|
|
|
|
|
|
:return: UserRepresentation |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name} |
|
|
|
|
|
|
|
data_raw = self.raw_post(URL_ADMIN_COMPONENTS.format(**params_path), |
|
|
|
data=json.dumps(payload)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError, expected_code=201, skip_exists=skip_exists) |
|
|
|
|
|
|
|
def get_component(self, component_id): |
|
|
|
""" |
|
|
|
Get representation of the component |
|
|
|
|
|
|
|
:param component_id: Component id |
|
|
|
|
|
|
|
ComponentRepresentation |
|
|
|
https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_componentrepresentation |
|
|
|
|
|
|
|
:return: ComponentRepresentation |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name, "id": component_id} |
|
|
|
data_raw = self.raw_get(URL_ADMIN_COMPONENT.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
def update_component(self, component_id, payload): |
|
|
|
""" |
|
|
|
Update the component |
|
|
|
|
|
|
|
:param component_id: Component id |
|
|
|
:param payload: ComponentRepresentation |
|
|
|
https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_componentrepresentation |
|
|
|
|
|
|
|
:return: Http response |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name, "id": component_id} |
|
|
|
data_raw = self.raw_put(URL_ADMIN_COMPONENT.format(**params_path), |
|
|
|
data=json.dumps(payload)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError, expected_code=204) |
|
|
|
|
|
|
|
def delete_component(self, component_id): |
|
|
|
""" |
|
|
|
Delete the component |
|
|
|
|
|
|
|
:param component_id: Component id |
|
|
|
|
|
|
|
:return: Http response |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name, "id": component_id} |
|
|
|
data_raw = self.raw_delete(URL_ADMIN_COMPONENT.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError, expected_code=204) |
|
|
|
|
|
|
|
|
|
|
|
def raw_get(self, *args, **kwargs): |
|
|
|
""" |
|
|
|