1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7pub enum ApiKeyScope {
8 #[serde(rename = "git:read")]
10 GitRead,
11 #[serde(rename = "git:write")]
13 GitWrite,
14 #[serde(rename = "repo:read")]
16 RepoRead,
17 #[serde(rename = "repo:create")]
19 RepoCreate,
20 #[serde(rename = "repo:delete")]
22 RepoDelete,
23 #[serde(rename = "admin")]
25 Admin,
26}
27
28#[derive(Debug, Clone, Serialize)]
30pub struct CreateApiKeyRequest {
31 pub name: String,
33 pub scopes: Vec<ApiKeyScope>,
35}
36
37#[derive(Debug, Clone, Deserialize)]
39pub struct ApiKeyCreated {
40 pub id: String,
42 pub key: String,
44 pub name: Option<String>,
46 pub scopes: Vec<ApiKeyScope>,
48 pub created_at: String,
50}
51
52#[derive(Debug, Clone, Deserialize)]
54pub struct ApiKey {
55 pub id: String,
57 pub name: Option<String>,
59 pub scopes: Vec<ApiKeyScope>,
61 pub last_used_at: Option<String>,
63 pub expires_at: Option<String>,
65 pub revoked_at: Option<String>,
67 pub created_at: String,
69}
70
71#[derive(Debug, Clone, Deserialize)]
73pub struct ListApiKeysResponse {
74 pub api_keys: Vec<ApiKey>,
76}