.NET client library for the traQ API.
The source code is generated from the OpenAPI Spec for the traQ API by Microsoft Kiota.
An extension method for the IServiceCollection type can be used.
In the sample code below, an instance of the TraqApiClient class configured by environment variables (TRAQ_BASE_ADDRESS and TRAQ_ACCESS_TOKEN) is added to the service collection.
var host = Host.CreateDefaultApplication(args)
.ConfigureServices((ctx, services) =>
{
services.AddTraqApiClient(options =>
{
var conf = ctx.Configuration;
options.BaseAddress = conf["TRAQ_BASE_ADDRESS"];
options.BearerAuthToken = conf["TRAQ_ACCESS_TOKEN"];
});
})
.Build();
host.Run();You can also separate configurator from the AddTraqApiClient method by using parameterless method.
In the following code, the added TraqApiClient automatically use configured TraqApiClientOptions.
var host = Host.CreateDefaultApplication(args)
.ConfigureServices((ctx, services) =>
{
services.Configure<TraqApiClientOptions>(ctx.Configuration);
services.AddTraqApiClient();
})
.Build();
host.Run();The TraqApiClientOptions class is used to configure the TraqApiClient instance.
You must fill the BaseAddress property to access the traQ API.
You can also set the BearerAuthToken, CookieAuthToken, and AuthMethodPreference properties to configure authentication.
The CreateFromOptions method in the TraqApiClientHelper class is useful to create a new instance of the TraqApiClient class with specified options.
TraqApiClientOptions options = new()
{
BaseAddress = "Base address of the traQ API",
BearerAuthToken = "Bearer authentication token"
}
var client = TraqApiClientHelper.CreateFromOptions(options);The TraqApiClient class implements Microsoft.Kiota.Abstractions.BaseRequestBuilder so that you can manually manage methods to access the traQ API.
For more information, please check Kiota Official Documentation.
Docker and Task are required for source generation.
To generate API client for certain version of traQ, set it to the TRAQ_TAG_NAME variable and run task gen or task generate-client.
The following command generates API client for traQ v3.27.0.
TRAQ_TAG_NAME="v3.27.0" task gen