couchbase_core/cbconfig/
mod.rs

1/*
2 *
3 *  * Copyright (c) 2025 Couchbase, Inc.
4 *  *
5 *  * Licensed under the Apache License, Version 2.0 (the "License");
6 *  * you may not use this file except in compliance with the License.
7 *  * You may obtain a copy of the License at
8 *  *
9 *  *    http://www.apache.org/licenses/LICENSE-2.0
10 *  *
11 *  * Unless required by applicable law or agreed to in writing, software
12 *  * distributed under the License is distributed on an "AS IS" BASIS,
13 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  * See the License for the specific language governing permissions and
15 *  * limitations under the License.
16 *
17 */
18
19pub mod parse;
20
21use std::collections::HashMap;
22
23use serde::Deserialize;
24
25#[derive(Deserialize, Debug, Clone)]
26pub struct VBucketServerMap {
27    #[serde(alias = "hashAlgorithm")]
28    pub hash_algorithm: String,
29    #[serde(alias = "numReplicas")]
30    pub num_replicas: usize,
31    #[serde(alias = "serverList")]
32    pub server_list: Vec<String>,
33    #[serde(alias = "vBucketMap")]
34    pub vbucket_map: Vec<Vec<i16>>,
35}
36
37#[derive(Deserialize, Debug, Clone)]
38pub struct ConfigDDocs {
39    #[serde(alias = "uri")]
40    pub uri: String,
41}
42
43#[derive(Deserialize, Debug, Default, Clone)]
44pub struct TerseExtNodePorts {
45    #[serde(alias = "kv")]
46    pub kv: Option<u16>,
47    #[serde(alias = "capi")]
48    pub capi: Option<u16>,
49    #[serde(alias = "mgmt")]
50    pub mgmt: Option<u16>,
51    #[serde(alias = "n1ql")]
52    pub n1ql: Option<u16>,
53    #[serde(alias = "fts")]
54    pub fts: Option<u16>,
55    #[serde(alias = "cbas")]
56    pub cbas: Option<u16>,
57    #[serde(alias = "eventingAdminPort")]
58    pub eventing: Option<u16>,
59    #[serde(alias = "indexHttp")]
60    pub gsi: Option<u16>,
61    #[serde(alias = "backupAPI")]
62    pub backup: Option<u16>,
63
64    #[serde(alias = "kvSSL")]
65    pub kv_ssl: Option<u16>,
66    #[serde(alias = "capiSSL")]
67    pub capi_ssl: Option<u16>,
68    #[serde(alias = "mgmtSSL")]
69    pub mgmt_ssl: Option<u16>,
70    #[serde(alias = "n1qlSSL")]
71    pub n1ql_ssl: Option<u16>,
72    #[serde(alias = "ftsSSL")]
73    pub fts_ssl: Option<u16>,
74    #[serde(alias = "cbasSSL")]
75    pub cbas_ssl: Option<u16>,
76    #[serde(alias = "eventingSSL")]
77    pub eventing_ssl: Option<u16>,
78    #[serde(alias = "indexHttps")]
79    pub gsi_ssl: Option<u16>,
80    #[serde(alias = "backupAPIHTTPS")]
81    pub backup_ssl: Option<u16>,
82}
83
84#[derive(Deserialize, Debug, Clone)]
85pub struct TerseExtNodeAltAddresses {
86    #[serde(alias = "ports")]
87    pub ports: TerseExtNodePorts,
88    #[serde(alias = "hostname")]
89    pub hostname: Option<String>,
90}
91
92#[derive(Deserialize, Debug, Clone)]
93pub struct TerseNodePorts {
94    #[serde(alias = "direct")]
95    pub direct: Option<u16>,
96    #[serde(alias = "proxy")]
97    pub proxy: Option<u16>,
98}
99
100#[derive(Deserialize, Debug, Clone)]
101pub struct TerseNodeConfig {
102    #[serde(alias = "couchbaseApiBase")]
103    pub couchbase_api_base: Option<String>,
104    #[serde(alias = "hostname")]
105    pub hostname: Option<String>,
106    #[serde(alias = "ports")]
107    pub ports: Option<TerseNodePorts>,
108}
109
110#[derive(Deserialize, Debug, Clone)]
111pub struct TerseNodeExtConfig {
112    #[serde(alias = "services")]
113    pub services: Option<TerseExtNodePorts>,
114    #[serde(alias = "thisNode")]
115    pub this_node: Option<bool>,
116    #[serde(alias = "hostname")]
117    pub hostname: Option<String>,
118    #[serde(alias = "alternateAddresses", default)]
119    pub alternate_addresses: HashMap<String, TerseExtNodeAltAddresses>,
120}
121
122#[derive(Deserialize, Debug, Clone)]
123pub struct TerseConfig {
124    #[serde(alias = "rev")]
125    pub rev: i64,
126    #[serde(alias = "revEpoch")]
127    pub rev_epoch: Option<i64>,
128    #[serde(alias = "name")]
129    pub name: Option<String>,
130    #[serde(alias = "nodeLocator")]
131    pub node_locator: Option<String>,
132    #[serde(alias = "uuid")]
133    pub uuid: Option<String>,
134    #[serde(alias = "uri")]
135    pub uri: Option<String>,
136    #[serde(alias = "streamingUri")]
137    pub streaming_uri: Option<String>,
138    #[serde(alias = "bucketCapabilitiesVer")]
139    pub bucket_capabilities_ver: Option<String>,
140    #[serde(alias = "bucketCapabilities")]
141    pub bucket_capabilities: Option<Vec<String>>,
142    #[serde(alias = "collectionsManifestUid")]
143    pub collections_manifest_uuid: Option<String>,
144    #[serde(alias = "ddocs")]
145    pub ddocs: Option<ConfigDDocs>,
146    #[serde(alias = "vBucketServerMap")]
147    pub vbucket_server_map: Option<VBucketServerMap>,
148    #[serde(alias = "nodes")]
149    pub nodes: Option<Vec<TerseNodeConfig>>,
150    #[serde(alias = "nodesExt")]
151    pub nodes_ext: Vec<TerseNodeExtConfig>,
152    #[serde(alias = "clusterCapabilitiesVer")]
153    pub cluster_capabilities_ver: Vec<i64>,
154    #[serde(alias = "clusterCapabilities")]
155    pub cluster_capabilities: HashMap<String, Vec<String>>,
156}
157
158#[derive(Deserialize, Debug, Clone)]
159#[non_exhaustive]
160pub struct CollectionManifestCollection {
161    #[serde(rename = "uid")]
162    pub uid: String,
163    #[serde(rename = "name")]
164    pub name: String,
165    #[serde(rename = "maxTTL", default)]
166    pub max_ttl: Option<i32>,
167    #[serde(rename = "history", default)]
168    pub history: Option<bool>,
169}
170
171#[derive(Deserialize, Debug, Clone)]
172#[non_exhaustive]
173pub struct CollectionManifestScope {
174    #[serde(rename = "uid")]
175    pub uid: String,
176    #[serde(rename = "name")]
177    pub name: String,
178    #[serde(rename = "collections", default)]
179    pub collections: Vec<CollectionManifestCollection>,
180}
181
182#[derive(Deserialize, Debug, Clone)]
183#[non_exhaustive]
184pub struct CollectionManifest {
185    #[serde(rename = "uid")]
186    pub uid: String,
187    #[serde(rename = "scopes", default)]
188    pub scopes: Vec<CollectionManifestScope>,
189}