Theuth.Lineage.Client
1.0.0
dotnet add package Theuth.Lineage.Client --version 1.0.0
NuGet\Install-Package Theuth.Lineage.Client -Version 1.0.0
<PackageReference Include="Theuth.Lineage.Client" Version="1.0.0" />
paket add Theuth.Lineage.Client --version 1.0.0
#r "nuget: Theuth.Lineage.Client, 1.0.0"
// Install Theuth.Lineage.Client as a Cake Addin #addin nuget:?package=Theuth.Lineage.Client&version=1.0.0 // Install Theuth.Lineage.Client as a Cake Tool #tool nuget:?package=Theuth.Lineage.Client&version=1.0.0
Theuth Lineage Client
The client for connecting to Theuth Lineage APIs
Installation
You can install this package from NuGet:
PM> Install-Package Theuth.Lineage.Client
Setup
There are two primary methods for creating instance of the ILineageClient
: via Dependency Injection or directly.
Directly
This allows you to create a Theuth Lineage client directly without needing dependency injection:
using Theuth.Lineage.Client;
using Theuth.Lineage.Models.Composites;
var apiUrl = "https://lineage.example.com";
ILineageClient client = LineageClient.Create(baseUrl: apiUrl);
//Then you can use the client as you see fit:
const string DOCUMENT_DATA = @"# THIS IS A DOCUMENT
Howdy? How's it going?
This is a test document :)";
var create = new DocumentCreate("test_user", DOCUMENT_DATA, "Initial Commit");
var result = await client.Documents.Create(create);
This method actually isn't recommended for production instances, as it boxes the IHttpClientFactory
and will always create a new HttpClient
.
It is recommended you use the dependency injection route below, but this one works in a pinch.
Dependency Injection
This allows you to create a Lineage client and add it to your dependency injection services and inject it automagically. You can read more about Dependency Injection here.
using Microsoft.Extensions.DependencyInjection;
using Theuth.Lineage.Client;
IServiceCollection services; //Get or create this however you want
//Now you can add the Lineage client using one of the following (you should only use one):
//Specify the base URL directly:
services.AddLineageClient("https://lineage.example.com");
//Add a settings instance:
services.AddLineageClient(new LineageSettings
{
BaseUrl = "https://lineage.example.com"
});
//Add via configuration directly
IConfiguration config; //Get or create this however you want
services.AddLineageClient(config);
//You can also specify the section of the IConfiguration to get the settings from:
services.AddLineageClient(config, "SomeSection:Lineage");
//Add via auto-resolution of Configuration.
//This requires that you've already injected an instance of IConfiguration
services.AddLineageClient();
For instances that use IConfiguration
to determine the BaseUrl
the default configuration layout is:
{
"Theuth": {
"Lineage": {
"BaseUrl": "https://lineage.example.com"
}
}
}
You can change the default section key by setting the DiExtensions.DefaultConfigSection
to whatever your wrapping section is.
The default for this is Theuth:Lineage
.
Once you've injected the services you can access it like so:
using Theuth.Lineage.Client;
using Theuth.Lineage.Models.Composites;
public class MyService(ILineageClient _client)
{
public async Task CreateDocument(string value, string user = "test_user", string? message = null)
{
var create = new DocumentCreate(user, value, message);
var result = await _client.Documents.Create(create);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- CardboardBox.Http (>= 2.0.2)
- Theuth.Lineage.Models (>= 1.0.0)
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 | 78 | 11/30/2024 |