update_policy
const url = 'https://example.com/api/v1/admin/policies/1';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"allowed_types":["example"],"behavior":{"storage_native_media_metadata_enabled":true,"storage_native_media_metadata_extensions":["example"],"storage_native_thumbnail_enabled":true,"storage_native_thumbnail_extensions":["example"]},"chunk_size":1,"connector_config":{"connector_id":"example","format_version":1,"schema_version":1,"values":{"additionalProperty":true}},"credential":{"mode":"none"},"is_default":true,"max_file_size":1,"name":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use std::str::FromStr;use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://example.com/api/v1/admin/policies/1";
let payload = json!({ "allowed_types": ("example"), "behavior": json!({ "storage_native_media_metadata_enabled": true, "storage_native_media_metadata_extensions": ("example"), "storage_native_thumbnail_enabled": true, "storage_native_thumbnail_extensions": ("example") }), "chunk_size": 1, "connector_config": json!({ "connector_id": "example", "format_version": 1, "schema_version": 1, "values": json!({"additionalProperty": true}) }), "credential": json!({"mode": "none"}), "is_default": true, "max_file_size": 1, "name": "example" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.request(reqwest::Method::from_str("PATCH").unwrap(), url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request PATCH \ --url https://example.com/api/v1/admin/policies/1 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "allowed_types": [ "example" ], "behavior": { "storage_native_media_metadata_enabled": true, "storage_native_media_metadata_extensions": [ "example" ], "storage_native_thumbnail_enabled": true, "storage_native_thumbnail_extensions": [ "example" ] }, "chunk_size": 1, "connector_config": { "connector_id": "example", "format_version": 1, "schema_version": 1, "values": { "additionalProperty": true } }, "credential": { "mode": "none" }, "is_default": true, "max_file_size": 1, "name": "example" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Policy ID
Request Bodyrequired
Section titled “Request Bodyrequired”Patch a storage policy.
object
Core-owned, per-policy storage-native processing preferences.
These switches only add provider-native candidates ahead of the global media-processing registry. Disabling them does not disable thumbnail or metadata processing for files on the policy; it makes those files continue through the ordinary global processor chain. Extension vectors are retained as dormant configuration while their corresponding switch is off.
object
Prefer the storage provider’s native media-metadata implementation for
matching files. false leaves the global metadata processors enabled.
File extensions eligible for provider-native media metadata. An empty list matches no files even when enabled. Retained as dormant configuration while the corresponding switch is false.
Prefer the storage provider’s native thumbnail implementation for
matching files. false leaves the global thumbnail processors enabled.
File extensions eligible for provider-native thumbnails. An empty list
matches no files even when enabled. Retained as dormant configuration
while storage_native_thumbnail_enabled is false.
Persisted configuration for exactly one connector.
A storage policy currently has one active connector, so a map of historical namespaces would only create ambiguous ownership. If the connector is temporarily unavailable, this entire envelope is preserved byte-for-byte.
object
Stable connector/plugin identifier.
Built-in connectors use reverse-DNS-style identifiers such as
asterdrive.storage.local. Dynamically loaded plugins use the same type and
registry path, so core code never needs a built-in connector enum.
Responses
Section titled “Responses”Policy updated
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
object
Core-owned, per-policy storage-native processing preferences.
These switches only add provider-native candidates ahead of the global media-processing registry. Disabling them does not disable thumbnail or metadata processing for files on the policy; it makes those files continue through the ordinary global processor chain. Extension vectors are retained as dormant configuration while their corresponding switch is off.
object
Prefer the storage provider’s native media-metadata implementation for
matching files. false leaves the global metadata processors enabled.
File extensions eligible for provider-native media metadata. An empty list matches no files even when enabled. Retained as dormant configuration while the corresponding switch is false.
Prefer the storage provider’s native thumbnail implementation for
matching files. false leaves the global thumbnail processors enabled.
File extensions eligible for provider-native thumbnails. An empty list
matches no files even when enabled. Retained as dormant configuration
while storage_native_thumbnail_enabled is false.
Persisted configuration for exactly one connector.
A storage policy currently has one active connector, so a map of historical namespaces would only create ambiguous ownership. If the connector is temporarily unavailable, this entire envelope is preserved byte-for-byte.
object
Stable connector/plugin identifier.
Built-in connectors use reverse-DNS-style identifiers such as
asterdrive.storage.local. Dynamically loaded plugins use the same type and
registry path, so core code never needs a built-in connector enum.
Example
{ "code": "success"}Unauthorized
Forbidden
Policy not found