oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1import Foundation
2
3public struct ProjectList: Codable, Sendable {
4 public var cursor: Int64? = nil
5 public var items: [ThinProject]?
6 public var connections: [ProjectConnection]?
7 public var canAdd: [ReachableProject]?
8 public var allowed: [String]?
9 public var home: String?
10}
11
12public struct ProjectConnection: Codable, Sendable, Identifiable, Equatable {
13 public var id: String
14 public var forge: String
15 public var title: String
16 public var state: String
17 public var canAdd: Bool
18}
19
20public struct ReachableProject: Codable, Sendable, Identifiable, Equatable {
21 public var repo: String
22 public var name: String
23 public var title: String
24 public var description: String
25 public var descriptionSource: String
26 public var forge: String
27 public var connectionId: String
28 public var id: String { repo }
29}
30
31extension EquipoClient {
32 public func setStar(_ id: String, _ starred: Bool) async throws -> ThinProject {
33 try await send(APIRequest("PUT", projectPath(id) + "/star", body: try EquipoJSON.encoder.encode(["starred": starred]), bearer: token))
34 }
35 public func addProject(_ repo: String) async throws -> ThinProject {
36 try await send(APIRequest("POST", "/projects", body: try EquipoJSON.encoder.encode(["repo": repo]), bearer: token))
37 }
38 public func forgetName(_ name: String, projectID: String) async throws {
39 let _: EmptyResponse = try await send(APIRequest("DELETE", projectPath(projectID) + "/names", body: try EquipoJSON.encoder.encode(["name": name]), bearer: token))
40 }
41 private func projectPath(_ id: String) -> String {
42 "/projects/" + (id.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed.subtracting(CharacterSet(charactersIn: "/?#"))) ?? "")
43 }
44}
45