Skip to main content

firebase_admin_sdk/remote_config/
models.rs

1use std::collections::HashMap;
2
3/// Represents a Remote Config template.
4#[derive(Debug, serde::Serialize, serde::Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct RemoteConfig {
7    /// The list of named conditions.
8    #[serde(default)]
9    pub conditions: Vec<RemoteConfigCondition>,
10    /// The map of parameter keys to their optional default values and optional conditional values.
11    #[serde(default)]
12    pub parameters: HashMap<String, RemoteConfigParameter>,
13    /// The map of parameter group names to their parameter group instances.
14    #[serde(default)]
15    pub parameter_groups: HashMap<String, RemoteConfigParameterGroup>,
16    /// The ETag of the current template.
17    #[serde(skip)]
18    pub etag: String,
19    /// Version information for the template.
20    #[serde(default)]
21    pub version: Option<Version>,
22}
23
24/// A condition that can be used to target specific users.
25#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
26#[serde(rename_all = "camelCase")]
27pub struct RemoteConfigCondition {
28    /// The name of the condition.
29    pub name: String,
30    /// The logic expression for the condition.
31    pub expression: String,
32    /// The color associated with the condition (for the console).
33    pub tag_color: Option<String>,
34}
35
36/// A parameter in the Remote Config template.
37#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq)]
38#[serde(rename_all = "camelCase")]
39pub struct RemoteConfigParameter {
40    /// The value to set the parameter to, if no conditions are met.
41    pub default_value: Option<RemoteConfigParameterValue>,
42    /// A map of condition names to values.
43    #[serde(default)]
44    pub conditional_values: HashMap<String, RemoteConfigParameterValue>,
45    /// A description for the parameter.
46    pub description: Option<String>,
47}
48
49/// The value of a Remote Config parameter.
50#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq)]
51#[serde(rename_all = "camelCase")]
52#[serde(untagged)]
53pub enum RemoteConfigParameterValue {
54    /// A static string value.
55    Value {
56        /// The string value.
57        value: String,
58    },
59    /// Indicates that the in-app default value should be used.
60    UseInAppDefault {
61        /// Always true if present.
62        use_in_app_default: bool,
63    },
64}
65
66/// A group of parameters.
67#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq)]
68#[serde(rename_all = "camelCase")]
69pub struct RemoteConfigParameterGroup {
70    /// A description for the group.
71    pub description: Option<String>,
72    /// The parameters in the group.
73    pub parameters: HashMap<String, RemoteConfigParameter>,
74}
75
76/// Version information for a Remote Config template.
77#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
78#[serde(rename_all = "camelCase")]
79pub struct Version {
80    /// The version number.
81    pub version_number: String,
82    /// The time when this version was created.
83    pub update_time: String,
84    /// The user who created this version.
85    pub update_user: Option<User>,
86    /// A description of the version.
87    pub description: Option<String>,
88    /// The origin of the update (e.g. "CONSOLE").
89    pub update_origin: String,
90    /// The type of update (e.g. "INCREMENTAL_UPDATE").
91    pub update_type: String,
92}
93
94/// User information.
95#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
96#[serde(rename_all = "camelCase")]
97pub struct User {
98    /// The user's email.
99    pub email: String,
100    /// The user's name.
101    pub name: Option<String>,
102    /// The user's image URL.
103    pub image_url: Option<String>,
104}
105
106/// Options for listing versions.
107#[derive(Debug, Default, serde::Serialize)]
108#[serde(rename_all = "camelCase")]
109pub struct ListVersionsOptions {
110    /// The maximum number of versions to return.
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub page_size: Option<usize>,
113    /// The token for the next page of results.
114    #[serde(skip_serializing_if = "Option::is_none")]
115    pub page_token: Option<String>,
116}
117
118/// The result of listing versions.
119#[derive(Debug, serde::Deserialize)]
120#[serde(rename_all = "camelCase")]
121pub struct ListVersionsResult {
122    /// The list of versions.
123    pub versions: Vec<Version>,
124    /// The token for the next page of results.
125    #[serde(rename = "nextPageToken")]
126    pub next_page_token: Option<String>,
127}
128
129/// A request to rollback to a specific version.
130#[derive(Debug, serde::Serialize)]
131#[serde(rename_all = "camelCase")]
132pub(crate) struct RollbackRequest {
133    /// The version number to roll back to.
134    pub(crate) version_number: String,
135}