/*
* Copyright (c) 2021-2026 ahriman team.
*
* This file is part of ahriman
* (see https://github.com/arcan1s/ahriman).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import { BaseClient } from "api/client/BaseClient";
import type { AURPackage } from "models/AURPackage";
import type { PackageActionRequest } from "models/PackageActionRequest";
import type { PGPKey } from "models/PGPKey";
import type { PGPKeyRequest } from "models/PGPKeyRequest";
import type { RepositoryId } from "models/RepositoryId";
export class ServiceMixin extends BaseClient {
async servicePackageAdd(repo: RepositoryId, data: PackageActionRequest): Promise {
return this.request("/api/v1/service/add", { method: "POST", query: repo.toQuery(), json: data });
}
async servicePackagePatchRemove(base: string, key: string): Promise {
return this.request(`/api/v1/packages/${encodeURIComponent(base)}/patches/${encodeURIComponent(key)}`, {
method: "DELETE",
});
}
async servicePackageRemove(repo: RepositoryId, packages: string[]): Promise {
return this.request("/api/v1/service/remove", {
method: "POST",
query: repo.toQuery(),
json: { packages },
});
}
async servicePackageRequest(repo: RepositoryId, data: PackageActionRequest): Promise {
return this.request("/api/v1/service/request", {
method: "POST",
query: repo.toQuery(),
json: data,
});
}
async servicePackageSearch(query: string): Promise {
return this.request("/api/v1/service/search", { query: { for: query } });
}
async servicePackageUpdate(repo: RepositoryId, data: PackageActionRequest): Promise {
return this.request("/api/v1/service/update", {
method: "POST",
query: repo.toQuery(),
json: data,
});
}
async servicePGPFetch(key: string, server: string): Promise {
return this.request("/api/v1/service/pgp", { query: { key, server } });
}
async servicePGPImport(data: PGPKeyRequest): Promise {
return this.request("/api/v1/service/pgp", { method: "POST", json: data });
}
async serviceRebuild(repo: RepositoryId, packages: string[]): Promise {
return this.request("/api/v1/service/rebuild", {
method: "POST",
query: repo.toQuery(),
json: { packages },
});
}
}