OhrTech.Management
1.0.1
See the version list below for details.
dotnet add package OhrTech.Management --version 1.0.1
NuGet\Install-Package OhrTech.Management -Version 1.0.1
<PackageReference Include="OhrTech.Management" Version="1.0.1" />
<PackageVersion Include="OhrTech.Management" Version="1.0.1" />
<PackageReference Include="OhrTech.Management" />
paket add OhrTech.Management --version 1.0.1
#r "nuget: OhrTech.Management, 1.0.1"
#:package OhrTech.Management@1.0.1
#addin nuget:?package=OhrTech.Management&version=1.0.1
#tool nuget:?package=OhrTech.Management&version=1.0.1
OhrTech.Management
The .NET client for the OhrTech Management API: manage your organisation's devices from your own servers and tools. Device status and settings, fleets, messages and tasks, remote control (with a viewer you can embed in your web app) and remote ADB.
dotnet add package OhrTech.Management
netstandard2.0 and net10.0, with no reflection-based serialization, so it also works in .NET 10
file-based apps (dotnet run script.cs), trimmed and native AOT apps. This is the Management SDK, for servers and desktop tools. Apps
running on a managed device will use the Device SDK (device-sdk-*, coming later) to talk to the
OhrTech Agent instead.
Sign in
As a service account, for servers and automation. Create the account and its token in the portal under Service accounts, grant it only the permissions it needs (ViewDevices, EditSettings, SendMessages, RemoteControl, …), and limit it to the fleets or devices, networks and embed sites it works with.
using OhrTech.Management;
using var api = OhrManagementClient.ForServiceAccount(Environment.GetEnvironmentVariable("OHR_TOKEN")!);
As a person, for tools people run. They approve the sign-in in the portal with their usual login; the client refreshes their access token for you.
var session = await OhrUserSession.SignInAsync(p =>
Console.WriteLine($"Open {p.VerificationUri} and enter {p.UserCode}"));
using var api = OhrManagementClient.ForUser(session);
// Keep session.RefreshToken (a secret) to skip signing in next time:
// OhrUserSession.Resume(savedRefreshToken); save it again on session.TokensRefreshed.
As whoever is signed in to the ohr CLI, for quick scripts and development on your own
machine. It reads the CLI's saved login (ohr login) and never changes it:
using var api = OhrManagementClient.ForUser(OhrUserSession.FromOhrCli());
With IHttpClientFactory: add OhrServiceTokenHandler or OhrUserSessionHandler to your
HttpClient, set its BaseAddress to OhrManagementClient.DefaultBaseUrl, and use
new OhrManagementClient(httpClient).
Use it
Every API operation is a method (IOhrManagementClient), named after its operation id in the
reference.
foreach (var d in await api.ListDevicesAsync(online: true))
Console.WriteLine($"{d.DeviceId} {d.Serial} {d.FleetName} battery {d.BatteryLevel}%");
var device = await api.GetDeviceAsync(42);
await api.ShowMessageAsync(42, new ShowMessageRequest { Text = "Please plug me in" });
await api.UpdateDeviceSettingsAsync(42, new PolicyPatchDto
{
Settings = new() { ["display.brightness"] = new SettingPolicy { Mode = SettingMode.Locked, Value = 80 } }
});
Errors are OhrApiException<ProblemDetails> (or OhrApiException<HttpValidationProblemDetails>
for invalid settings): e.StatusCode, e.Result.Title, e.Result.Detail.
Remote control in your web app
var rc = await api.OpenRemoteControlSessionAsync(42, new OpenRemoteControlRequest
{
EmbedOrigins = new() { "https://support.example.com" }
});
// Hand rc.Embed.Url to your page (it is a credential until rc.Embed.ExpiresAt):
// <iframe src="{rc.Embed.Url}" allow="fullscreen; clipboard-read" style="width:100%;height:720px"></iframe>
The viewer reports its state to your page with postMessage and takes key, text, refresh,
focus and end commands back: see
Embed remote control.
Developing
src/OhrTech.Management/Generated/ is generated from openapi.json by ./generate.sh (NSwag, a
repo-local tool); don't edit it by hand. To pick up a new API version:
./generate.sh https://raw.githubusercontent.com/OhrTech/management-api/main/openapi.json
dotnet build -c Release
tests/no-reflection.cs checks the client with reflection-based JSON off:
dotnet run --no-cache tests/no-reflection.cs.
Releases: push a v* tag (such as v1.0.1) and GitHub Actions packs it with that version and
publishes it to nuget.org.
License
| 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 is compatible. 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 was computed. |
| .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
- System.Security.Cryptography.ProtectedData (>= 10.0.13)
- System.Text.Json (>= 10.0.0)
-
net10.0
- System.Security.Cryptography.ProtectedData (>= 10.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.