ForgejoApiClient 9.0.0-rev.2

This is a prerelease version of ForgejoApiClient.
dotnet add package ForgejoApiClient --version 9.0.0-rev.2                
NuGet\Install-Package ForgejoApiClient -Version 9.0.0-rev.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ForgejoApiClient" Version="9.0.0-rev.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ForgejoApiClient --version 9.0.0-rev.2                
#r "nuget: ForgejoApiClient, 9.0.0-rev.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ForgejoApiClient as a Cake Addin
#addin nuget:?package=ForgejoApiClient&version=9.0.0-rev.2&prerelease

// Install ForgejoApiClient as a Cake Tool
#tool nuget:?package=ForgejoApiClient&version=9.0.0-rev.2&prerelease                

ForgejoApiClient

NugetShield

This is Forgejo API client library for .NET. (unofficial)

This library is a relatively simple wrapping of the Forgejo API.
The client class ForgejoClient has properties grouped by API category as indicated in the Swagger documentation.
It should not be too difficult to find a correspondence to a method. However, in order to find the exact correspondence, the ForgejoEndpoint attribute is specified in the method.
The endpoints indicated by the attribute can be matched against the document.

Authentication supports only token authentication using HTTP headers.

Package and API version

Although the Forgejo API specification may change from version to version, this library targets only a single version.
If the version targeted by the library does not match the server version, there is a large possibility that it will not work properly.
The server and client versions must be combined correctly.

Package versions are in semantic versioning format, but are numbered according to the following arrangement.
The version number of this package always uses the pre-release versioning format.
The core version part represents the version of the target server.
The version (rev.XX) portion of the pre-release is used to indicate the version of the library, not as a pre-release.
Therefore, differences in pre-release version numbers are not necessarily trivial changes.

Examples

Some samples are shown below.

Create a repository in my namespace and add topics

using ForgejoApiClient;
using ForgejoApiClient.Api;

var apiBase = new Uri(@"http://<your-hosting-server>/api/v1");
var apiToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
using var client = new ForgejoClient(apiBase, apiToken);

var me = await client.User.GetMeAsync();
if (me.login == null) throw new Exception("unexpected");

var repoOptions = new CreateRepoOption(name: "repo-name", default_branch: "main", @private: true);
var repo = await client.Repository.CreateAsync(repoOptions);

await client.Repository.AddTopicAsync(me.login, "repo-name", topic: "sample");
await client.Repository.AddTopicAsync(me.login, "repo-name", topic: "test");

Create organizations and teams, add members

using var client = new ForgejoClient(apiBase, apiToken);

var org = await client.Organization.CreateAsync(new(username: "org-name"));
var team_units = new Dictionary<string, string> { ["repo.code"] = "write", };
var team = await client.Organization.CreateTeamAsync("org-name", new(name: "team-name", units_map: team_units));
await client.Organization.AddTeamMemberAsync(team.id!.Value, "user-name");

Save content response

using var client = new ForgejoClient(apiBase, apiToken);

using (var archiveDownload = await client.Repository.GetArchiveAsync("owner-name", "repo-name", "main.zip"))
using (var fileStream = File.OpenWrite(archiveDownload.Result.FileName ?? "main.zip"))
{
    await archiveDownload.Result.Stream.CopyToAsync(fileStream);
}

Create quota settings and assign users

using var client = new ForgejoClient(apiBase, apiToken);

var quotaGroup = await client.Admin.CreateQuotaGroupAsync(new(name: "package-quota"));
var quotaRule = await client.Admin.CreateQuotaRuleAsync(new(name: "limit-packages-500M", limit: 500 * 1024 * 1024, subjects: ["size:assets:packages:all"]));
await client.Admin.AddQuotaGroupRuleAsync("package-quota", "limit-packages-500M");

await client.Admin.AddQuotaGroupUserAsync("package-quota", "user-name");

Running the API in a different user context by sudo

using var adminClient = new ForgejoClient(apiBase, apiToken);

var userClient = adminClient.Sudo("user-name");
await userClient.Repository.WatchAsync("owner-name", "repo-name");
Product 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.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
9.0.0-rev.2 36 11/24/2024
8.0.0-rev.4 30 11/25/2024
7.0.5-rev.2 28 11/25/2024