Skip to main content

core_api/
storage_backend.rs

1//! Core/Plugin byte transport. Logical Folder policy remains in Core.
2use serde::{Deserialize, Serialize};
3pub const STORAGE_BACKEND_PROTOCOL_VERSION: &str = "storage.backend.v2";
4pub const STORAGE_BACKEND_DESCRIBE: &str = "/storage/backend/describe";
5pub const STORAGE_BACKEND_GRANT: &str = "/storage/backend/grant";
6pub const STORAGE_BACKEND_PREPARE_WRITE: &str = "/storage/backend/prepare-write";
7pub const STORAGE_GATEWAY_PREFIX: &str = "/storage/v1/";
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "lowercase")]
10pub enum StorageBackendPermission {
11    Read,
12    Write,
13    Stat,
14    Delete,
15}
16#[derive(Debug, Clone, Serialize, Deserialize)]
17#[serde(rename_all = "camelCase", deny_unknown_fields)]
18pub struct StorageBackendGrantRequest {
19    pub repository_id: String,
20    pub owner: String,
21    pub object_id: String,
22    pub permission: StorageBackendPermission,
23    pub local: bool,
24}
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(rename_all = "camelCase", deny_unknown_fields)]
27pub struct StorageBackendPrepareWriteRequest {
28    pub repository_id: String,
29    pub owner: String,
30    pub object: storage_api::backend::Blob,
31    pub local_import: bool,
32    pub local: bool,
33}
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub struct StorageBackendDescription {
37    pub protocol_version: String,
38    pub capacity: storage_api::backend::Capacity,
39}
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(tag = "status", rename_all = "camelCase")]
42pub enum StorageBackendReply<T> {
43    Ok { value: T },
44    Error { error: storage_api::StorageError },
45}
46#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct StorageBackendGrant {
49    pub repository_id: String,
50    pub url: String,
51    pub token: String,
52    pub host_identity: artifact_api::HostTlsIdentity,
53    pub expires_at_ms: u64,
54    pub local: Option<crate::StorageLocalEndpoint>,
55}
56
57/// Native gateway transport is local to the hosting process. Never return this descriptor to App callers.
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(rename_all = "camelCase", deny_unknown_fields)]
60pub struct StorageGatewayDescriptor {
61    pub url: String,
62    pub token: String,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(rename_all = "camelCase", deny_unknown_fields)]
67pub struct StorageGatewayRequest {
68    pub grant: String,
69    pub access_token: String,
70}