Hsm.OperationalContextService.Client
1.0.0-alpha.6
See the version list below for details.
dotnet add package Hsm.OperationalContextService.Client --version 1.0.0-alpha.6
NuGet\Install-Package Hsm.OperationalContextService.Client -Version 1.0.0-alpha.6
<PackageReference Include="Hsm.OperationalContextService.Client" Version="1.0.0-alpha.6" />
<PackageVersion Include="Hsm.OperationalContextService.Client" Version="1.0.0-alpha.6" />
<PackageReference Include="Hsm.OperationalContextService.Client" />
paket add Hsm.OperationalContextService.Client --version 1.0.0-alpha.6
#r "nuget: Hsm.OperationalContextService.Client, 1.0.0-alpha.6"
#:package Hsm.OperationalContextService.Client@1.0.0-alpha.6
#addin nuget:?package=Hsm.OperationalContextService.Client&version=1.0.0-alpha.6&prerelease
#tool nuget:?package=Hsm.OperationalContextService.Client&version=1.0.0-alpha.6&prerelease
Hsm.OperationalContextService.Client
Interfaces:
- 'IOperationalContextClientApiV1'
ExampleUsage:
services
.AddGeneratedRestClient<IOperationalContextClientApiV1>(() => ServiceClientConfiguration)
Caching
Adds AddRecommendedMethods(). These can change over time and should be considered volatile. Does only cache. nothing about invalidation.
.AddCaching(
config => config.AddRecommendedMethods(),
sp => sp.GetRequiredService<IDistributedCache>())
Generic Client Documentation
Basic Usage
Example using the client IOperationalContextClientApiV1:
services
.AddGeneratedRestClient<IOperationalContextClientApiV1>(() => ServiceClientConfiguration)
.Register();
This registers the generated REST client with a configured base URL.
Full Example
services
.AddDistributedMemoryCache()
.AddGeneratedRestClient<IOperationalContextClientApiV1>(() => ServiceClientConfiguration)
.AddStandardHttpResilience()
.AddExceptionTransformation((_, exception) =>
exception switch
{
OperationalContextApiException<ErrorContainer> typedError
when typedError.Result.Error.Code == "NoOperationalContext"
=> new TestException("OperationalContext NotFound", exception),
_ => exception,
})
.AddCaching(
config => config.AddRecommendedMethods(),
sp => sp.GetRequiredService<IDistributedCache>())
.Register();
Features
Resilience
.AddStandardHttpResilience()
Adds default HTTP resilience (retries, timeouts, etc.). Optional overrides can be provided if needed.
Exception Transformation
.AddExceptionTransformation((method, exception) => ...)
Allows mapping API exceptions to domain-specific exceptions based on:
- called method
- returned error
Caching
Setup Caching Definitions
Caching is opt-in and method-based:
- Only methods returning Task<T> can be cached
- Each method maps to a CacheOptions (TTL, etc.)
- Re-registering a method overwrites previous configuration
Selection
- Add(...) → single method
- AddWhere(...) → bulk selection by predicate
- Remove(...) / RemoveWhere(...) → exclusions
⚠️ AddWhere(_ ⇒ true) will cache everything returning Task<T> (including POST-like calls)
Exceptions are never cached
.AddCaching(
config => config
.Add(client => client.GetSomethingAsync(id)) // cache specific method
.SetNewOptionsDefault(new CacheOptions(TimeSpan.FromHours(1))) // default TTL for all methods following
.AddWhere(m => m.Name.StartsWith("Get")) // cache multiple methods
.Remove(client => client.GetSomethingAsync(otherId)), // remove if needed
sp => sp.GetRequiredService<IDistributedCache>() // backing cache
)
Invalidation
If caching is added automatically adds ICacheInvalidator<IOperationalContextClientApiV1>
await cacheInvalidator.InvalidateAsync(
client => client.GetSomethingAsync(id),
cancellationToken);
Invalidates exactly one method call (method + arguments). the arguments have to match exactly for the cache to be invalidated (ingoring CancellationTokens)
Health Checks
If the client supports it, you can register a health check:
Only works for clients implementing the required health interface inside the Client, otherwise, this call will fail at compile time.
services.AddRestClientHealthCheck<IOperationalContextClientApiV1>();
Order of Operations
TIClient (resolved from DI)
└── ExceptionTransformationDecorator (Optional)
└── CacheDecorator (Optional)
└── TClient (generated REST client)
└── HttpClient
├── OAuth2 Token Handler (Optional)
└── Resilience Handler (retries, timeouts, etc.) (Optional)
Notes
- All features are optional and composable
- Order of builder calls does not matter (eg ExcepiontTransformation and Caching will not change their order of operations)
- Internally uses decorators to build the pipeline
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
- Newtonsoft.Json (>= 13.0.4)
-
.NETStandard 2.1
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.17 | 63 | 5/28/2026 |
| 1.0.0-alpha.16 | 40 | 5/28/2026 |
| 1.0.0-alpha.15 | 54 | 5/19/2026 |
| 1.0.0-alpha.14 | 101 | 5/18/2026 |
| 1.0.0-alpha.9 | 99 | 5/12/2026 |
| 1.0.0-alpha.8 | 61 | 5/11/2026 |
| 1.0.0-alpha.7 | 58 | 5/8/2026 |
| 1.0.0-alpha.6 | 52 | 5/8/2026 |
| 1.0.0-alpha.5 | 48 | 5/8/2026 |
| 1.0.0-alpha.4 | 58 | 5/8/2026 |
| 1.0.0-alpha.3 | 51 | 5/7/2026 |
| 1.0.0-alpha.2 | 50 | 5/7/2026 |
| 1.0.0-alpha.1 | 46 | 5/6/2026 |