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(skip_serializing_if = "wkt::internal::is_default")]
48 #[serde_as(as = "serde_with::DisplayFromStr")]
49 pub request_size: i64,
50
51 #[serde(skip_serializing_if = "wkt::internal::is_default")]
54 pub status: i32,
55
56 #[serde(skip_serializing_if = "wkt::internal::is_default")]
59 #[serde_as(as = "serde_with::DisplayFromStr")]
60 pub response_size: i64,
61
62 #[serde(skip_serializing_if = "std::string::String::is_empty")]
66 pub user_agent: std::string::String,
67
68 #[serde(skip_serializing_if = "std::string::String::is_empty")]
72 pub remote_ip: std::string::String,
73
74 #[serde(skip_serializing_if = "std::string::String::is_empty")]
78 pub server_ip: std::string::String,
79
80 #[serde(skip_serializing_if = "std::string::String::is_empty")]
84 pub referer: std::string::String,
85
86 #[serde(skip_serializing_if = "std::option::Option::is_none")]
89 pub latency: std::option::Option<wkt::Duration>,
90
91 #[serde(skip_serializing_if = "wkt::internal::is_default")]
93 pub cache_lookup: bool,
94
95 #[serde(skip_serializing_if = "wkt::internal::is_default")]
98 pub cache_hit: bool,
99
100 #[serde(skip_serializing_if = "wkt::internal::is_default")]
104 pub cache_validated_with_origin_server: bool,
105
106 #[serde(skip_serializing_if = "wkt::internal::is_default")]
109 #[serde_as(as = "serde_with::DisplayFromStr")]
110 pub cache_fill_bytes: i64,
111
112 #[serde(skip_serializing_if = "std::string::String::is_empty")]
114 pub protocol: std::string::String,
115
116 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
117 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
118}
119
120impl HttpRequest {
121 pub fn new() -> Self {
122 std::default::Default::default()
123 }
124
125 pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
127 self.request_method = v.into();
128 self
129 }
130
131 pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
133 self.request_url = v.into();
134 self
135 }
136
137 pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
139 self.request_size = v.into();
140 self
141 }
142
143 pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
145 self.status = v.into();
146 self
147 }
148
149 pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
151 self.response_size = v.into();
152 self
153 }
154
155 pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
157 self.user_agent = v.into();
158 self
159 }
160
161 pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
163 self.remote_ip = v.into();
164 self
165 }
166
167 pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
169 self.server_ip = v.into();
170 self
171 }
172
173 pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
175 self.referer = v.into();
176 self
177 }
178
179 pub fn set_latency<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
181 mut self,
182 v: T,
183 ) -> Self {
184 self.latency = v.into();
185 self
186 }
187
188 pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
190 self.cache_lookup = v.into();
191 self
192 }
193
194 pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
196 self.cache_hit = v.into();
197 self
198 }
199
200 pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
202 mut self,
203 v: T,
204 ) -> Self {
205 self.cache_validated_with_origin_server = v.into();
206 self
207 }
208
209 pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
211 self.cache_fill_bytes = v.into();
212 self
213 }
214
215 pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
217 self.protocol = v.into();
218 self
219 }
220}
221
222impl wkt::message::Message for HttpRequest {
223 fn typename() -> &'static str {
224 "type.googleapis.com/google.logging.type.HttpRequest"
225 }
226}
227
228#[derive(Clone, Debug, PartialEq)]
260#[non_exhaustive]
261pub enum LogSeverity {
262 Default,
264 Debug,
266 Info,
268 Notice,
271 Warning,
273 Error,
275 Critical,
277 Alert,
279 Emergency,
281 UnknownValue(log_severity::UnknownValue),
286}
287
288#[doc(hidden)]
289pub mod log_severity {
290 #[allow(unused_imports)]
291 use super::*;
292 #[derive(Clone, Debug, PartialEq)]
293 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
294}
295
296impl LogSeverity {
297 pub fn value(&self) -> std::option::Option<i32> {
302 match self {
303 Self::Default => std::option::Option::Some(0),
304 Self::Debug => std::option::Option::Some(100),
305 Self::Info => std::option::Option::Some(200),
306 Self::Notice => std::option::Option::Some(300),
307 Self::Warning => std::option::Option::Some(400),
308 Self::Error => std::option::Option::Some(500),
309 Self::Critical => std::option::Option::Some(600),
310 Self::Alert => std::option::Option::Some(700),
311 Self::Emergency => std::option::Option::Some(800),
312 Self::UnknownValue(u) => u.0.value(),
313 }
314 }
315
316 pub fn name(&self) -> std::option::Option<&str> {
321 match self {
322 Self::Default => std::option::Option::Some("DEFAULT"),
323 Self::Debug => std::option::Option::Some("DEBUG"),
324 Self::Info => std::option::Option::Some("INFO"),
325 Self::Notice => std::option::Option::Some("NOTICE"),
326 Self::Warning => std::option::Option::Some("WARNING"),
327 Self::Error => std::option::Option::Some("ERROR"),
328 Self::Critical => std::option::Option::Some("CRITICAL"),
329 Self::Alert => std::option::Option::Some("ALERT"),
330 Self::Emergency => std::option::Option::Some("EMERGENCY"),
331 Self::UnknownValue(u) => u.0.name(),
332 }
333 }
334}
335
336impl std::default::Default for LogSeverity {
337 fn default() -> Self {
338 use std::convert::From;
339 Self::from(0)
340 }
341}
342
343impl std::fmt::Display for LogSeverity {
344 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
345 wkt::internal::display_enum(f, self.name(), self.value())
346 }
347}
348
349impl std::convert::From<i32> for LogSeverity {
350 fn from(value: i32) -> Self {
351 match value {
352 0 => Self::Default,
353 100 => Self::Debug,
354 200 => Self::Info,
355 300 => Self::Notice,
356 400 => Self::Warning,
357 500 => Self::Error,
358 600 => Self::Critical,
359 700 => Self::Alert,
360 800 => Self::Emergency,
361 _ => Self::UnknownValue(log_severity::UnknownValue(
362 wkt::internal::UnknownEnumValue::Integer(value),
363 )),
364 }
365 }
366}
367
368impl std::convert::From<&str> for LogSeverity {
369 fn from(value: &str) -> Self {
370 use std::string::ToString;
371 match value {
372 "DEFAULT" => Self::Default,
373 "DEBUG" => Self::Debug,
374 "INFO" => Self::Info,
375 "NOTICE" => Self::Notice,
376 "WARNING" => Self::Warning,
377 "ERROR" => Self::Error,
378 "CRITICAL" => Self::Critical,
379 "ALERT" => Self::Alert,
380 "EMERGENCY" => Self::Emergency,
381 _ => Self::UnknownValue(log_severity::UnknownValue(
382 wkt::internal::UnknownEnumValue::String(value.to_string()),
383 )),
384 }
385 }
386}
387
388impl serde::ser::Serialize for LogSeverity {
389 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
390 where
391 S: serde::Serializer,
392 {
393 match self {
394 Self::Default => serializer.serialize_i32(0),
395 Self::Debug => serializer.serialize_i32(100),
396 Self::Info => serializer.serialize_i32(200),
397 Self::Notice => serializer.serialize_i32(300),
398 Self::Warning => serializer.serialize_i32(400),
399 Self::Error => serializer.serialize_i32(500),
400 Self::Critical => serializer.serialize_i32(600),
401 Self::Alert => serializer.serialize_i32(700),
402 Self::Emergency => serializer.serialize_i32(800),
403 Self::UnknownValue(u) => u.0.serialize(serializer),
404 }
405 }
406}
407
408impl<'de> serde::de::Deserialize<'de> for LogSeverity {
409 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
410 where
411 D: serde::Deserializer<'de>,
412 {
413 deserializer.deserialize_any(wkt::internal::EnumVisitor::<LogSeverity>::new(
414 ".google.logging.type.LogSeverity",
415 ))
416 }
417}