-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
feat: new endpoint to get a specific user's groups
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Keycloak.AuthServices.Sdk.Admin; | ||
|
||
using System.Threading.Tasks; | ||
using Constants; | ||
using Models; | ||
using Refit; | ||
using Requests.Groups; | ||
|
||
/// <summary> | ||
/// Group management | ||
/// </summary> | ||
[Headers("Accept: application/json")] | ||
public interface IKeycloakGroupClient | ||
{ | ||
|
||
/// <summary> | ||
/// Get a stream of groups on the realm. | ||
/// </summary> | ||
/// <param name="realm">Realm name.</param> | ||
/// <param name="parameters">Optional query parameters.</param> | ||
/// <returns>A stream of groups, filtered according to query parameters.</returns> | ||
[Get(KeycloakClientApiConstants.GetGroups)] | ||
Task<IEnumerable<Group>> GetGroups(string realm, [Query] GetGroupRequestParameters? parameters = default); | ||
|
||
/// <summary> | ||
/// Get representation of a group. | ||
/// </summary> | ||
/// <param name="realm">Realm name.</param> | ||
/// <param name="groupId">group ID.</param> | ||
/// <returns>The group representation.</returns> | ||
[Get(KeycloakClientApiConstants.GetGroup)] | ||
Task<Group> GetGroup(string realm, [AliasAs("id")] string groupId); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma warning disable CS1591, CS8618 | ||
namespace Keycloak.AuthServices.Sdk.Admin.Models; | ||
|
||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Group representation. | ||
/// </summary> | ||
public class Group | ||
{ | ||
public string Id { get; init; } = default!; | ||
public string? Name { get; init; } | ||
public string? Path { get; init; } | ||
public Dictionary<string, string>? ClientRoles { get; init; } | ||
public string[]? RealmRoles { get; init; } | ||
public Group[]? SubGroups { get; init; } | ||
public Dictionary<string, string[]>? Attributes { get; init; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
namespace Keycloak.AuthServices.Sdk.Admin.Requests.Groups; | ||
|
||
using Keycloak.AuthServices.Sdk.Admin.Models; | ||
using Refit; | ||
|
||
/// <summary> | ||
/// Optional request parameters for the <see cref="IKeycloakGoupClient.GetGroups"/> endpoint. | ||
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 7 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
|
||
/// It can be called in three different ways. | ||
/// <list type="number"> | ||
/// <item> | ||
/// <description> | ||
/// Don’t specify any criteria. A stream of all groups within that realm will be returned (limited by pagination). | ||
/// </description> | ||
/// </item> | ||
/// <item> | ||
/// <description> | ||
/// If <see cref="Search"/> is specified, other criteria such as <see cref="LastName"/> | ||
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 17 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
|
||
/// will be ignored even though you may set them. The <see cref="Search"/> string will be matched against | ||
/// the <see cref="User.FirstName"/>, <see cref="User.LastName"/>, <see cref="User.Username"/> | ||
/// and the <see cref="User.Email"/> of a <see cref="User"/>. | ||
/// </description> | ||
/// </item> | ||
/// <item> | ||
/// <description> | ||
/// If <see cref="Search"/> is unspecified but any of <see cref="LastName"/>, <see cref="FirstName"/>, | ||
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 25 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
|
||
/// <see cref="Email"/> or <see cref="Username"/> are specified, then those criteria are matched against | ||
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-macOS-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
Check warning on line 26 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
|
||
/// their respective fields on a <see cref="User"/> entity. Combined with a logical <c>AND</c>. | ||
/// </description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
public class GetGroupRequestParameters | ||
{ | ||
/// <summary> | ||
/// Defines whether brief representations are returned. Default is false. | ||
/// </summary> | ||
[AliasAs("briefRepresentation")] | ||
public bool? BriefRepresentation { get; init; } | ||
|
||
/// <summary> | ||
/// Defines whether the params <see cref="LastName"/>, <see cref="FirstName"/>, | ||
Check warning on line 41 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 41 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 41 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 41 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
Check warning on line 41 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-windows-latest
|
||
/// <see cref="Email"/> and <see cref="Username"/> must match exactly | ||
Check warning on line 42 in src/Keycloak.AuthServices.Sdk/Admin/Requests/Groups/GetGroupRequestParameters.cs GitHub Actions / Build-ubuntu-latest
|
||
/// </summary> | ||
[AliasAs("exact")] | ||
public bool? Exact { get; init; } | ||
|
||
/// <summary> | ||
/// Pagination offset. | ||
/// </summary> | ||
[AliasAs("first")] | ||
public int? First { get; init; } | ||
|
||
/// <summary> | ||
/// Maximum results size. Default is 100. | ||
/// </summary> | ||
[AliasAs("max")] | ||
public int? Max { get; init; } | ||
|
||
/// <summary> | ||
/// A query to search for custom attributes, in the format "<c>key1:value2 key2:value2</c>". | ||
/// </summary> | ||
[AliasAs("q")] | ||
public string? Query { get; init; } | ||
|
||
/// <summary> | ||
/// Search for a string contained in <see cref="Username"/>, <see cref="FirstName"/>, | ||
/// <see cref="LastName"/> or <see cref="Email"/>. | ||
/// </summary> | ||
[AliasAs("search")] | ||
public string? Search { get; init; } | ||
} |