google_cloud_logging_type/
model.rs1#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate bytes;
21extern crate serde;
22extern crate serde_json;
23extern crate serde_with;
24extern crate std;
25extern crate wkt;
26
27#[serde_with::serde_as]
31#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
32#[serde(default, rename_all = "camelCase")]
33#[non_exhaustive]
34pub struct HttpRequest {
35 #[serde(skip_serializing_if = "std::string::String::is_empty")]
37 pub request_method: std::string::String,
38
39 #[serde(skip_serializing_if = "std::string::String::is_empty")]
43 pub request_url: std::string::String,
44
45 #[serde_as(as = "serde_with::DisplayFromStr")]
48 pub request_size: i64,
49
50 pub status: i32,
53
54 #[serde_as(as = "serde_with::DisplayFromStr")]
57 pub response_size: i64,
58
59 #[serde(skip_serializing_if = "std::string::String::is_empty")]
63 pub user_agent: std::string::String,
64
65 #[serde(skip_serializing_if = "std::string::String::is_empty")]
69 pub remote_ip: std::string::String,
70
71 #[serde(skip_serializing_if = "std::string::String::is_empty")]
75 pub server_ip: std::string::String,
76
77 #[serde(skip_serializing_if = "std::string::String::is_empty")]
81 pub referer: std::string::String,
82
83 #[serde(skip_serializing_if = "std::option::Option::is_none")]
86 pub latency: std::option::Option<wkt::Duration>,
87
88 pub cache_lookup: bool,
90
91 pub cache_hit: bool,
94
95 pub cache_validated_with_origin_server: bool,
99
100 #[serde_as(as = "serde_with::DisplayFromStr")]
103 pub cache_fill_bytes: i64,
104
105 #[serde(skip_serializing_if = "std::string::String::is_empty")]
107 pub protocol: std::string::String,
108
109 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
110 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
111}
112
113impl HttpRequest {
114 pub fn new() -> Self {
115 std::default::Default::default()
116 }
117
118 pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
120 self.request_method = v.into();
121 self
122 }
123
124 pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
126 self.request_url = v.into();
127 self
128 }
129
130 pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
132 self.request_size = v.into();
133 self
134 }
135
136 pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
138 self.status = v.into();
139 self
140 }
141
142 pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
144 self.response_size = v.into();
145 self
146 }
147
148 pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
150 self.user_agent = v.into();
151 self
152 }
153
154 pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
156 self.remote_ip = v.into();
157 self
158 }
159
160 pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
162 self.server_ip = v.into();
163 self
164 }
165
166 pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
168 self.referer = v.into();
169 self
170 }
171
172 pub fn set_latency<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
174 mut self,
175 v: T,
176 ) -> Self {
177 self.latency = v.into();
178 self
179 }
180
181 pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
183 self.cache_lookup = v.into();
184 self
185 }
186
187 pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
189 self.cache_hit = v.into();
190 self
191 }
192
193 pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
195 mut self,
196 v: T,
197 ) -> Self {
198 self.cache_validated_with_origin_server = v.into();
199 self
200 }
201
202 pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
204 self.cache_fill_bytes = v.into();
205 self
206 }
207
208 pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
210 self.protocol = v.into();
211 self
212 }
213}
214
215impl wkt::message::Message for HttpRequest {
216 fn typename() -> &'static str {
217 "type.googleapis.com/google.logging.type.HttpRequest"
218 }
219}
220
221#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
239pub struct LogSeverity(i32);
240
241impl LogSeverity {
242 pub const DEFAULT: LogSeverity = LogSeverity::new(0);
244
245 pub const DEBUG: LogSeverity = LogSeverity::new(100);
247
248 pub const INFO: LogSeverity = LogSeverity::new(200);
250
251 pub const NOTICE: LogSeverity = LogSeverity::new(300);
254
255 pub const WARNING: LogSeverity = LogSeverity::new(400);
257
258 pub const ERROR: LogSeverity = LogSeverity::new(500);
260
261 pub const CRITICAL: LogSeverity = LogSeverity::new(600);
263
264 pub const ALERT: LogSeverity = LogSeverity::new(700);
266
267 pub const EMERGENCY: LogSeverity = LogSeverity::new(800);
269
270 pub(crate) const fn new(value: i32) -> Self {
272 Self(value)
273 }
274
275 pub fn value(&self) -> i32 {
277 self.0
278 }
279
280 pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> {
282 match self.0 {
283 0 => std::borrow::Cow::Borrowed("DEFAULT"),
284 100 => std::borrow::Cow::Borrowed("DEBUG"),
285 200 => std::borrow::Cow::Borrowed("INFO"),
286 300 => std::borrow::Cow::Borrowed("NOTICE"),
287 400 => std::borrow::Cow::Borrowed("WARNING"),
288 500 => std::borrow::Cow::Borrowed("ERROR"),
289 600 => std::borrow::Cow::Borrowed("CRITICAL"),
290 700 => std::borrow::Cow::Borrowed("ALERT"),
291 800 => std::borrow::Cow::Borrowed("EMERGENCY"),
292 _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)),
293 }
294 }
295
296 pub fn from_str_name(name: &str) -> std::option::Option<Self> {
298 match name {
299 "DEFAULT" => std::option::Option::Some(Self::DEFAULT),
300 "DEBUG" => std::option::Option::Some(Self::DEBUG),
301 "INFO" => std::option::Option::Some(Self::INFO),
302 "NOTICE" => std::option::Option::Some(Self::NOTICE),
303 "WARNING" => std::option::Option::Some(Self::WARNING),
304 "ERROR" => std::option::Option::Some(Self::ERROR),
305 "CRITICAL" => std::option::Option::Some(Self::CRITICAL),
306 "ALERT" => std::option::Option::Some(Self::ALERT),
307 "EMERGENCY" => std::option::Option::Some(Self::EMERGENCY),
308 _ => std::option::Option::None,
309 }
310 }
311}
312
313impl std::convert::From<i32> for LogSeverity {
314 fn from(value: i32) -> Self {
315 Self::new(value)
316 }
317}
318
319impl std::default::Default for LogSeverity {
320 fn default() -> Self {
321 Self::new(0)
322 }
323}