/* * 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 type { Client } from "api/client/Client"; 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 ServiceClient { protected client: Client; constructor(client: Client) { this.client = client; } async servicePackageAdd(repository: RepositoryId, data: PackageActionRequest): Promise { return this.client.request("/api/v1/service/add", { method: "POST", query: repository.toQuery(), json: data }); } async servicePackagePatchRemove(packageBase: string, key: string): Promise { return this.client.request(`/api/v1/packages/${encodeURIComponent(packageBase)}/patches/${encodeURIComponent(key)}`, { method: "DELETE", }); } async servicePackageRemove(repository: RepositoryId, packages: string[]): Promise { return this.client.request("/api/v1/service/remove", { method: "POST", query: repository.toQuery(), json: { packages }, }); } async servicePackageRequest(repository: RepositoryId, data: PackageActionRequest): Promise { return this.client.request("/api/v1/service/request", { method: "POST", query: repository.toQuery(), json: data, }); } async servicePackageSearch(query: string): Promise { return this.client.request("/api/v1/service/search", { query: { for: query } }); } async servicePackageUpdate(repository: RepositoryId, data: PackageActionRequest): Promise { return this.client.request("/api/v1/service/update", { method: "POST", query: repository.toQuery(), json: data, }); } async servicePGPFetch(key: string, server: string): Promise { return this.client.request("/api/v1/service/pgp", { query: { key, server } }); } async servicePGPImport(data: PGPKeyRequest): Promise { return this.client.request("/api/v1/service/pgp", { method: "POST", json: data }); } async serviceRebuild(repository: RepositoryId, packages: string[]): Promise { return this.client.request("/api/v1/service/rebuild", { method: "POST", query: repository.toQuery(), json: { packages }, }); } }