Endpoint for getting localization/effective message bundles (#24845)

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
agagancarczyk 2023-11-20 17:59:10 +00:00 committed by GitHub
parent a45934a762
commit 8115ebf2e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 2 deletions

View file

@ -0,0 +1,6 @@
export default interface EffectiveMessageBundleRepresentation {
theme?: string;
themeType?: string;
locale?: string;
source?: boolean;
}

View file

@ -1,17 +1,34 @@
import Resource from "./resource.js";
import type { ServerInfoRepresentation } from "../defs/serverInfoRepesentation.js";
import type KeycloakAdminClient from "../index.js";
import type EffectiveMessageBundleRepresentation from "../defs/effectiveMessageBundleRepresentation.js";
export class ServerInfo extends Resource {
constructor(client: KeycloakAdminClient) {
super(client, {
path: "/admin/serverinfo",
path: "/",
getBaseUrl: () => client.baseUrl,
});
}
public find = this.makeRequest<{}, ServerInfoRepresentation>({
method: "GET",
path: "/",
path: "/admin/serverinfo",
});
public findEffectiveMessageBundles = this.makeRequest<
{
realm: string;
theme?: string;
themeType?: string;
locale?: string;
source?: boolean;
},
EffectiveMessageBundleRepresentation[]
>({
method: "GET",
path: "/resources/{realm}/{themeType}/{locale}",
urlParamKeys: ["realm", "themeType", "locale"],
queryParamKeys: ["theme", "source"],
});
}

View file

@ -17,4 +17,15 @@ describe("Server Info", () => {
const serverInfo = await client.serverInfo.find();
expect(serverInfo).to.be.ok;
});
it("list effective message bundles of a realm", async () => {
const messageBundles = await client.serverInfo.findEffectiveMessageBundles({
realm: "master",
themeType: "admin",
locale: "en",
});
expect(messageBundles).to.be.ok;
expect(messageBundles.length).to.be.greaterThan(0);
});
});