1use compact_str::CompactString;
2use s2_common::{self, location::LocationName};
3use serde::{Deserialize, Serialize};
4
5#[rustfmt::skip]
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
8pub struct LocationInfo {
9 pub name: LocationName,
11 pub is_private: bool,
13 #[serde(default, skip_serializing_if = "Option::is_none")]
15 #[cfg_attr(feature = "utoipa", schema(value_type = Option<Vec<String>>))]
16 pub storage_classes: Option<Vec<CompactString>>,
17 #[serde(default, skip_serializing_if = "Option::is_none")]
19 #[cfg_attr(feature = "utoipa", schema(value_type = Option<String>))]
20 pub default_storage_class: Option<CompactString>,
21}
22
23impl From<s2_common::location::LocationInfo> for LocationInfo {
24 fn from(value: s2_common::location::LocationInfo) -> Self {
25 let s2_common::location::LocationInfo {
26 name,
27 is_private,
28 storage_classes,
29 default_storage_class,
30 } = value;
31
32 Self {
33 name,
34 is_private,
35 storage_classes: Some(storage_classes),
36 default_storage_class: Some(default_storage_class),
37 }
38 }
39}
40
41pub type GetDefaultLocationResponse = LocationInfo;
42
43pub type SetDefaultLocationRequest = LocationName;