diff --git a/README.md b/README.md index 806750c..028f5b6 100644 --- a/README.md +++ b/README.md @@ -460,6 +460,12 @@ Note: Ids are sent as clientScopeId or clientId and mapperId everything else is | Get the events provider configuration Returns JSON object with events provider configuration | getEventsConfig | ✔️ | | Update the events provider Change the events provider and/or its configuration | updateEventsConfig | ✔️ | | Get user group by path | getGroupByPath | ✔️ | +| GET /{realm}/localization | getLocalizationLocales | ✔️ | +| POST /{realm}/localization/{locale} | updateLocalizationTexts | ✔️ | +| GET /{realm}/localization/{locale} | getLocalizationTexts | ✔️ | +| DELETE /{realm}/localization/{locale} | deleteLocalizationTexts | ✔️ | +| GET /{realm}/localization/{locale}/{key} | getLocalizationText | ✔️ | +| PUT /{realm}/localization/{locale}/{key} | saveLocalizationText | ✔️ | | Removes all user sessions. (Keycloak throws an exception when this one is called) | logoutAllUsers | ❌ | | Partial export of existing realm into a JSON file. | partialExportRealm | ✔️ | | Partial import from a JSON file to an existing realm. | partialImportRealm | ✔️ | diff --git a/src/Admin/Classes/FullTextLocation.php b/src/Admin/Classes/FullTextLocation.php new file mode 100644 index 0000000..cdeb004 --- /dev/null +++ b/src/Admin/Classes/FullTextLocation.php @@ -0,0 +1,62 @@ +contentType = $contentType; + } + + /** + * @param CommandInterface $command + * @param RequestInterface $request + * @param Parameter $param + * + * @return MessageInterface + */ + public function visit( + CommandInterface $command, + RequestInterface $request, + Parameter $param + ) { + $oldValue = $request->getBody()->getContents(); + + $value = $command[$param->getName()]; + $value = $param->filter($value); + + if ($oldValue !== '') { + $value = $oldValue.$vaule; + } + + if ($this->contentType && !$request->hasHeader('Content-Type')) { + $request = $request->withHeader('Content-Type', $this->contentType); + } + + return $request->withBody(Psr7\Utils::streamFor($value)); + } +} diff --git a/src/Admin/KeycloakClient.php b/src/Admin/KeycloakClient.php index c0c7054..9d513ff 100644 --- a/src/Admin/KeycloakClient.php +++ b/src/Admin/KeycloakClient.php @@ -10,6 +10,7 @@ use GuzzleHttp\Handler\CurlHandler; use GuzzleHttp\HandlerStack; use Keycloak\Admin\Classes\FullBodyLocation; +use Keycloak\Admin\Classes\FullTextLocation; use Keycloak\Admin\TokenStorages\RuntimeTokenStorage; /** @@ -193,6 +194,13 @@ * @method array getEventsConfig(array $args = array()) { @command Keycloak getEventsConfig } * @method array updateEventsConfig(array $args = array()) { @command Keycloak updateEventsConfig } * @method array getGroupByPath(array $args = array()) { @command Keycloak getGroupByPath } + * @method array getLocalizationLocales(array $args = array()) { @command Keycloak getLocalizationLocales } + * @method array getLocalizationTexts(array $args = array()) { @command Keycloak getLocalizationTexts } + * @method array updateLocalizationTexts(array $args = array()) { @command Keycloak updateLocalizationTexts } + * @method array deleteLocalizationTexts(array $args = array()) { @command Keycloak deleteLocalizationTexts } + * @method array getLocalizationText(array $args = array()) { @command Keycloak getLocalizationText } + * @method array saveLocalizationText(array $args = array()) { @command Keycloak saveLocalizationText } + * @method array deleteLocalizationText(array $args = array()) { @command Keycloak deleteLocalizationText } * @method array logoutAllUsers(array $args = array()) { @command Keycloak logoutAllUsers } * @method array partialExportRealm(array $args = array()) { @command Keycloak partialExportRealm } * @method array partialImportRealm(array $args = array()) { @command Keycloak partialImportRealm } @@ -339,7 +347,8 @@ public static function factory($config = array()) new Client($config), $description, new Serializer($description, [ - "fullBody" => new FullBodyLocation() + "fullBody" => new FullBodyLocation(), + "fullText" => new FullTextLocation(), ]), function ($response) { $responseBody = $response->getBody()->getContents(); diff --git a/src/Admin/Resources/keycloak-1_0.php b/src/Admin/Resources/keycloak-1_0.php index 1cc3034..67848ea 100644 --- a/src/Admin/Resources/keycloak-1_0.php +++ b/src/Admin/Resources/keycloak-1_0.php @@ -3652,6 +3652,175 @@ ) ), + 'getLocalizationLocales' => array( + 'uri' => 'admin/realms/{realm}/localization', + 'description' => 'Get localization locales for realm', + 'httpMethod' => 'GET', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + ) + ), + + 'getLocalizationTexts' => array( + 'uri' => 'admin/realms/{realm}/localization/{locale}', + 'description' => 'Get localization texts for a realm locale', + 'httpMethod' => 'GET', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'locale' => array( + 'location' => 'uri', + 'description' => 'The locale name', + 'type' => 'string', + 'required' => true, + ), + 'useRealmDefaultLocaleFallback' => array( + 'location' => 'query', + 'description' => 'Fallback to realm default locale', + 'type' => 'string', + 'required' => false, + ), + ) + ), + + 'updateLocalizationTexts' => array( + 'uri' => 'admin/realms/{realm}/localization/{locale}', + 'description' => 'Update localization texts for a realm locale', + 'httpMethod' => 'POST', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'locale' => array( + 'location' => 'uri', + 'description' => 'The locale name', + 'type' => 'string', + 'required' => true, + ), + 'localizationTexts' => array( + 'location' => 'fullBody', + 'description' => 'Map of text values for the locale', + 'required' => true + ), + ) + ), + + 'deleteLocalizationTexts' => array( + 'uri' => 'admin/realms/{realm}/localization/{locale}', + 'description' => 'Update localization texts for a realm locale', + 'httpMethod' => 'DELETE', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'locale' => array( + 'location' => 'uri', + 'description' => 'The locale name', + 'type' => 'string', + 'required' => true, + ), + ) + ), + + 'getLocalizationText' => array( + 'uri' => 'admin/realms/{realm}/localization/{locale}/{key}', + 'description' => 'Get a localization text for a realm locale', + 'httpMethod' => 'GET', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'locale' => array( + 'location' => 'uri', + 'description' => 'The locale name', + 'type' => 'string', + 'required' => true, + ), + 'key' => array( + 'location' => 'uri', + 'description' => 'The text key name', + 'type' => 'string', + 'required' => true, + ), + ) + ), + + 'saveLocalizationText' => array( + 'uri' => 'admin/realms/{realm}/localization/{locale}/{key}', + 'description' => 'Set a localization text for a realm locale', + 'httpMethod' => 'PUT', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'locale' => array( + 'location' => 'uri', + 'description' => 'The locale name', + 'type' => 'string', + 'required' => true, + ), + 'key' => array( + 'location' => 'uri', + 'description' => 'The text key name', + 'type' => 'string', + 'required' => true, + ), + 'text' => array( + 'location' => 'fullText', + 'description' => 'The text value', + 'type' => 'string', + 'required' => true, + ), + ) + ), + + 'deleteLocalizationText' => array( + 'uri' => 'admin/realms/{realm}/localization/{locale}/{key}', + 'description' => 'Delete a localization text for a realm locale', + 'httpMethod' => 'DELETE', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'locale' => array( + 'location' => 'uri', + 'description' => 'The locale name', + 'type' => 'string', + 'required' => true, + ), + 'key' => array( + 'location' => 'uri', + 'description' => 'The text key name', + 'type' => 'string', + 'required' => true, + ), + ) + ), + 'logoutAllUsers' => array( 'uri' => 'admin/realms/{realm}/logout-all', 'description' => 'Removes all user sessions.',