-
Notifications
You must be signed in to change notification settings - Fork 2
DSI-8683: Public API - get service users no filter #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5cd9f59
eed8c9c
edc9d42
13c4f61
f678c22
f6cf096
7670d09
7fccc12
6ac4a8d
5ec6c8f
f31b1f8
92e3fd6
0da5da2
f22d9ed
5e8f6a2
60879a3
a10a147
35fcee6
77e1aa3
caa235b
ef7e600
bd00eec
3150f9d
e07f307
2f7bf37
46e4911
4e3909e
4f53ee3
a634820
a965c89
71e6415
663910c
33e0d54
bced67a
a551f11
0f75e2f
4042ef7
6e08c4f
043eb42
f7d8ea8
5b66d49
decbd7a
524aaab
e622079
4e6f36e
e1a74b2
f57d1cd
514380a
eae5e7a
d224f18
96391cc
47a048f
2329d42
6691911
598682c
b71cc82
ec5f8b0
37f252e
2bc4950
c54ef5e
af170b2
a64c210
7deffff
ce1c52d
c78d815
8e1fb9a
7b11fff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| namespace Dfe.SignIn.Base.Framework.Extensions; | ||
|
|
||
| /// <summary> | ||
| /// Extensions for DateTime to handle conversion to UTC, treating unspecified kinds as UTC by default. | ||
| /// </summary> | ||
| public static class DateTimeExtensions | ||
| { | ||
| /// <summary> | ||
| /// Returns the UTC equivalent of the given DateTime. If the input DateTime has an | ||
| /// unspecified kind, it will be treated as UTC. | ||
| /// </summary> | ||
| /// <param name="date">The DateTime to convert to UTC.</param> | ||
| /// <returns>The UTC equivalent of the given DateTime.</returns> | ||
| public static DateTime ToUtc(this DateTime date) | ||
| => date.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(date, DateTimeKind.Utc) : date.ToUniversalTime(); | ||
|
|
||
| /// <summary> | ||
| /// Returns the UTC equivalent of the given DateTime, or null if the input is null. | ||
| /// </summary> | ||
| /// <param name="date">The nullable DateTime to convert to UTC.</param> | ||
| /// <returns>The UTC equivalent of the given DateTime, or null if the input is null.</returns> | ||
| public static DateTime? ToUtc(this DateTime? date) | ||
| => date.HasValue ? ToUtc(date.Value) : null; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Dfe.SignIn.Core.Contracts.Applications; | ||
|
|
||
| /// <summary> | ||
| /// A model representing a role in DfE Sign-in. | ||
| /// </summary> | ||
| public sealed record ApplicationRole | ||
| { | ||
| /// <summary> | ||
| /// The unique value that identifies the role. | ||
| /// </summary> | ||
| public required Guid Id { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// The parent role. | ||
| /// </summary> | ||
| public ApplicationRole? Parent { get; init; } = null; | ||
|
|
||
| /// <summary> | ||
| /// The code of the role. | ||
| /// </summary> | ||
| public required string Code { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// The name of the role. | ||
| /// </summary> | ||
| public required string Name { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// The numeric identifier of the role. | ||
| /// </summary> | ||
| public required long NumericId { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// A value indicating the status of the role. | ||
| /// </summary> | ||
| [EnumDataType(typeof(ApplicationRoleStatus))] | ||
| public required ApplicationRoleStatus Status { get; init; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Represents the status of a role. | ||
| /// </summary> | ||
| public enum ApplicationRoleStatus | ||
| { | ||
| /// <summary> | ||
| /// Indicates that a role is inactive. | ||
| /// </summary> | ||
| Inactive = 0, | ||
|
|
||
| /// <summary> | ||
| /// Indicates that a role is active. | ||
| /// </summary> | ||
| Active = 1, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using Dfe.SignIn.Base.Framework; | ||
|
|
||
| namespace Dfe.SignIn.Core.Contracts.Applications; | ||
|
|
||
| /// <summary> | ||
| /// Request to get the roles that are associated with an application. | ||
| /// </summary> | ||
| [AssociatedResponse(typeof(GetApplicationRolesResponse))] | ||
| public sealed record GetApplicationRolesRequest | ||
| { | ||
| /// <summary> | ||
| /// The unique identifier of the application. | ||
| /// </summary> | ||
| public required Guid ApplicationId { get; init; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Response model for request <see cref="GetApplicationRolesRequest"/>. | ||
| /// </summary> | ||
| public sealed record GetApplicationRolesResponse | ||
| { | ||
| /// <summary> | ||
| /// An enumerable collection of application roles. | ||
| /// </summary> | ||
| public required IEnumerable<ApplicationRole> Roles { get; init; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| namespace Dfe.SignIn.Core.Contracts.Organisations; | ||
|
|
||
| /// <summary> | ||
| /// Represents an organisation role with an identifier and a display name. | ||
| /// </summary> | ||
| /// <param name="Id">The unique short identifier for the role.</param> | ||
| /// <param name="Name">The display name of the role.</param> | ||
| public sealed record OrganisationRole(short Id, string Name); | ||
|
|
||
| /// <summary> | ||
| /// Provides static references and lookup methods for well-known organisation roles. | ||
| /// </summary> | ||
| public static class OrganisationRoles | ||
| { | ||
| /// <summary> | ||
| /// The standard end user role (Id = 0, Name = "End user"). | ||
| /// </summary> | ||
| public static readonly OrganisationRole EndUser = new(0, "End user"); | ||
|
|
||
| /// <summary> | ||
| /// The approver role (Id = 10000, Name = "Approver"). | ||
| /// </summary> | ||
| public static readonly OrganisationRole Approver = new(10000, "Approver"); | ||
|
|
||
| /// <summary> | ||
| /// Internal lookup dictionary for roles by their short Id. | ||
| /// </summary> | ||
| private static readonly IReadOnlyDictionary<short, OrganisationRole> ById = | ||
|
Check warning on line 28 in src/Dfe.SignIn.Core.Contracts/Organisations/OrganisationRole.cs
|
||
| new Dictionary<short, OrganisationRole> { | ||
| [EndUser.Id] = EndUser, | ||
| [Approver.Id] = Approver | ||
| }; | ||
|
|
||
| /// <summary> | ||
| /// Gets a known <see cref="OrganisationRole"/> by its Id, or null if not found. | ||
| /// </summary> | ||
| /// <param name="roleId">The short Id of the role.</param> | ||
| /// <returns>The matching <see cref="OrganisationRole"/>, or null if not found.</returns> | ||
| public static OrganisationRole? FromId(short roleId) => ById.TryGetValue(roleId, out var role) ? role : null; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.