forked from votrongdao/FlowX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigCapabilities.cs
More file actions
50 lines (43 loc) · 1.66 KB
/
Copy pathConfigCapabilities.cs
File metadata and controls
50 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using FlowX;
namespace Crm;
/// <summary>
/// What a tenant has declared, of one kind.
/// </summary>
/// <remarks>
/// <para>
/// <strong><c>crm.admin</c>, because this is the administrator's view of the tenant.</strong> The
/// sentences it composes describe what refuses a write, who has to approve what, and where this
/// server sends. None of that is secret from an administrator and none of it is any of a
/// representative's business — and a setup screen that anybody could read is a map of the
/// controls for anybody who wants to work around them.
/// </para>
/// <para>
/// Idempotent, and it writes nothing.
/// </para>
/// </remarks>
[Capability("crm.config.list", Version = "1.0.0",
Authorization = Authorization.Permission, Permission = "crm.admin",
Idempotent = true)]
public sealed class ReadCrmConfig : ICapability<ReadConfig, ConfigList>
{
private readonly ConfigStore _config;
/// <summary>Creates the capability.</summary>
/// <param name="config">Lists the declarations.</param>
/// <exception cref="ArgumentNullException"><paramref name="config"/> is null.</exception>
public ReadCrmConfig(ConfigStore config)
{
ArgumentNullException.ThrowIfNull(config);
_config = config;
}
/// <inheritdoc />
public async ValueTask<Result<ConfigList>> ExecuteAsync(
ReadConfig input,
CapabilityContext ctx,
CancellationToken ct)
{
ArgumentNullException.ThrowIfNull(input);
ArgumentNullException.ThrowIfNull(ctx);
var items = await _config.ListAsync(ctx.TenantId, input, ct).ConfigureAwait(false);
return Result.Ok(new ConfigList(input.Kind, items));
}
}