google_cloud_logging_type/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![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
27mod debug;
28mod deserialize;
29mod serialize;
30
31/// A common proto for logging HTTP requests. Only contains semantics
32/// defined by the HTTP specification. Product-specific logging
33/// information MUST be defined in a separate message.
34#[derive(Clone, Default, PartialEq)]
35#[non_exhaustive]
36pub struct HttpRequest {
37 /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
38 pub request_method: std::string::String,
39
40 /// The scheme (http, https), the host name, the path and the query
41 /// portion of the URL that was requested.
42 /// Example: ``http://example.com/some/info?color=red``.
43 pub request_url: std::string::String,
44
45 /// The size of the HTTP request message in bytes, including the request
46 /// headers and the request body.
47 pub request_size: i64,
48
49 /// The response code indicating the status of response.
50 /// Examples: 200, 404.
51 pub status: i32,
52
53 /// The size of the HTTP response message sent back to the client, in bytes,
54 /// including the response headers and the response body.
55 pub response_size: i64,
56
57 /// The user agent sent by the client. Example:
58 /// `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
59 /// CLR 1.0.3705)"`.
60 pub user_agent: std::string::String,
61
62 /// The IP address (IPv4 or IPv6) of the client that issued the HTTP
63 /// request. This field can include port information. Examples:
64 /// `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`.
65 pub remote_ip: std::string::String,
66
67 /// The IP address (IPv4 or IPv6) of the origin server that the request was
68 /// sent to. This field can include port information. Examples:
69 /// `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`.
70 pub server_ip: std::string::String,
71
72 /// The referer URL of the request, as defined in
73 /// [HTTP/1.1 Header Field
74 /// Definitions](https://datatracker.ietf.org/doc/html/rfc2616#section-14.36).
75 pub referer: std::string::String,
76
77 /// The request processing latency on the server, from the time the request was
78 /// received until the response was sent.
79 pub latency: std::option::Option<wkt::Duration>,
80
81 /// Whether or not a cache lookup was attempted.
82 pub cache_lookup: bool,
83
84 /// Whether or not an entity was served from cache
85 /// (with or without validation).
86 pub cache_hit: bool,
87
88 /// Whether or not the response was validated with the origin server before
89 /// being served from cache. This field is only meaningful if `cache_hit` is
90 /// True.
91 pub cache_validated_with_origin_server: bool,
92
93 /// The number of HTTP response bytes inserted into cache. Set only when a
94 /// cache fill was attempted.
95 pub cache_fill_bytes: i64,
96
97 /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
98 pub protocol: std::string::String,
99
100 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
101}
102
103impl HttpRequest {
104 pub fn new() -> Self {
105 std::default::Default::default()
106 }
107
108 /// Sets the value of [request_method][crate::model::HttpRequest::request_method].
109 ///
110 /// # Example
111 /// ```ignore,no_run
112 /// # use google_cloud_logging_type::model::HttpRequest;
113 /// let x = HttpRequest::new().set_request_method("example");
114 /// ```
115 pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
116 self.request_method = v.into();
117 self
118 }
119
120 /// Sets the value of [request_url][crate::model::HttpRequest::request_url].
121 ///
122 /// # Example
123 /// ```ignore,no_run
124 /// # use google_cloud_logging_type::model::HttpRequest;
125 /// let x = HttpRequest::new().set_request_url("example");
126 /// ```
127 pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
128 self.request_url = v.into();
129 self
130 }
131
132 /// Sets the value of [request_size][crate::model::HttpRequest::request_size].
133 ///
134 /// # Example
135 /// ```ignore,no_run
136 /// # use google_cloud_logging_type::model::HttpRequest;
137 /// let x = HttpRequest::new().set_request_size(42);
138 /// ```
139 pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
140 self.request_size = v.into();
141 self
142 }
143
144 /// Sets the value of [status][crate::model::HttpRequest::status].
145 ///
146 /// # Example
147 /// ```ignore,no_run
148 /// # use google_cloud_logging_type::model::HttpRequest;
149 /// let x = HttpRequest::new().set_status(42);
150 /// ```
151 pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
152 self.status = v.into();
153 self
154 }
155
156 /// Sets the value of [response_size][crate::model::HttpRequest::response_size].
157 ///
158 /// # Example
159 /// ```ignore,no_run
160 /// # use google_cloud_logging_type::model::HttpRequest;
161 /// let x = HttpRequest::new().set_response_size(42);
162 /// ```
163 pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
164 self.response_size = v.into();
165 self
166 }
167
168 /// Sets the value of [user_agent][crate::model::HttpRequest::user_agent].
169 ///
170 /// # Example
171 /// ```ignore,no_run
172 /// # use google_cloud_logging_type::model::HttpRequest;
173 /// let x = HttpRequest::new().set_user_agent("example");
174 /// ```
175 pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
176 self.user_agent = v.into();
177 self
178 }
179
180 /// Sets the value of [remote_ip][crate::model::HttpRequest::remote_ip].
181 ///
182 /// # Example
183 /// ```ignore,no_run
184 /// # use google_cloud_logging_type::model::HttpRequest;
185 /// let x = HttpRequest::new().set_remote_ip("example");
186 /// ```
187 pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
188 self.remote_ip = v.into();
189 self
190 }
191
192 /// Sets the value of [server_ip][crate::model::HttpRequest::server_ip].
193 ///
194 /// # Example
195 /// ```ignore,no_run
196 /// # use google_cloud_logging_type::model::HttpRequest;
197 /// let x = HttpRequest::new().set_server_ip("example");
198 /// ```
199 pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
200 self.server_ip = v.into();
201 self
202 }
203
204 /// Sets the value of [referer][crate::model::HttpRequest::referer].
205 ///
206 /// # Example
207 /// ```ignore,no_run
208 /// # use google_cloud_logging_type::model::HttpRequest;
209 /// let x = HttpRequest::new().set_referer("example");
210 /// ```
211 pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
212 self.referer = v.into();
213 self
214 }
215
216 /// Sets the value of [latency][crate::model::HttpRequest::latency].
217 ///
218 /// # Example
219 /// ```ignore,no_run
220 /// # use google_cloud_logging_type::model::HttpRequest;
221 /// use wkt::Duration;
222 /// let x = HttpRequest::new().set_latency(Duration::default()/* use setters */);
223 /// ```
224 pub fn set_latency<T>(mut self, v: T) -> Self
225 where
226 T: std::convert::Into<wkt::Duration>,
227 {
228 self.latency = std::option::Option::Some(v.into());
229 self
230 }
231
232 /// Sets or clears the value of [latency][crate::model::HttpRequest::latency].
233 ///
234 /// # Example
235 /// ```ignore,no_run
236 /// # use google_cloud_logging_type::model::HttpRequest;
237 /// use wkt::Duration;
238 /// let x = HttpRequest::new().set_or_clear_latency(Some(Duration::default()/* use setters */));
239 /// let x = HttpRequest::new().set_or_clear_latency(None::<Duration>);
240 /// ```
241 pub fn set_or_clear_latency<T>(mut self, v: std::option::Option<T>) -> Self
242 where
243 T: std::convert::Into<wkt::Duration>,
244 {
245 self.latency = v.map(|x| x.into());
246 self
247 }
248
249 /// Sets the value of [cache_lookup][crate::model::HttpRequest::cache_lookup].
250 ///
251 /// # Example
252 /// ```ignore,no_run
253 /// # use google_cloud_logging_type::model::HttpRequest;
254 /// let x = HttpRequest::new().set_cache_lookup(true);
255 /// ```
256 pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
257 self.cache_lookup = v.into();
258 self
259 }
260
261 /// Sets the value of [cache_hit][crate::model::HttpRequest::cache_hit].
262 ///
263 /// # Example
264 /// ```ignore,no_run
265 /// # use google_cloud_logging_type::model::HttpRequest;
266 /// let x = HttpRequest::new().set_cache_hit(true);
267 /// ```
268 pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
269 self.cache_hit = v.into();
270 self
271 }
272
273 /// Sets the value of [cache_validated_with_origin_server][crate::model::HttpRequest::cache_validated_with_origin_server].
274 ///
275 /// # Example
276 /// ```ignore,no_run
277 /// # use google_cloud_logging_type::model::HttpRequest;
278 /// let x = HttpRequest::new().set_cache_validated_with_origin_server(true);
279 /// ```
280 pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
281 mut self,
282 v: T,
283 ) -> Self {
284 self.cache_validated_with_origin_server = v.into();
285 self
286 }
287
288 /// Sets the value of [cache_fill_bytes][crate::model::HttpRequest::cache_fill_bytes].
289 ///
290 /// # Example
291 /// ```ignore,no_run
292 /// # use google_cloud_logging_type::model::HttpRequest;
293 /// let x = HttpRequest::new().set_cache_fill_bytes(42);
294 /// ```
295 pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
296 self.cache_fill_bytes = v.into();
297 self
298 }
299
300 /// Sets the value of [protocol][crate::model::HttpRequest::protocol].
301 ///
302 /// # Example
303 /// ```ignore,no_run
304 /// # use google_cloud_logging_type::model::HttpRequest;
305 /// let x = HttpRequest::new().set_protocol("example");
306 /// ```
307 pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
308 self.protocol = v.into();
309 self
310 }
311}
312
313impl wkt::message::Message for HttpRequest {
314 fn typename() -> &'static str {
315 "type.googleapis.com/google.logging.type.HttpRequest"
316 }
317}
318
319/// The severity of the event described in a log entry, expressed as one of the
320/// standard severity levels listed below. For your reference, the levels are
321/// assigned the listed numeric values. The effect of using numeric values other
322/// than those listed is undefined.
323///
324/// You can filter for log entries by severity. For example, the following
325/// filter expression will match log entries with severities `INFO`, `NOTICE`,
326/// and `WARNING`:
327///
328/// ```norust
329/// severity > DEBUG AND severity <= WARNING
330/// ```
331///
332/// If you are writing log entries, you should map other severity encodings to
333/// one of these standard levels. For example, you might map all of Java's FINE,
334/// FINER, and FINEST levels to `LogSeverity.DEBUG`. You can preserve the
335/// original severity level in the log entry payload if you wish.
336///
337/// # Working with unknown values
338///
339/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
340/// additional enum variants at any time. Adding new variants is not considered
341/// a breaking change. Applications should write their code in anticipation of:
342///
343/// - New values appearing in future releases of the client library, **and**
344/// - New values received dynamically, without application changes.
345///
346/// Please consult the [Working with enums] section in the user guide for some
347/// guidelines.
348///
349/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
350#[derive(Clone, Debug, PartialEq)]
351#[non_exhaustive]
352pub enum LogSeverity {
353 /// (0) The log entry has no assigned severity level.
354 Default,
355 /// (100) Debug or trace information.
356 Debug,
357 /// (200) Routine information, such as ongoing status or performance.
358 Info,
359 /// (300) Normal but significant events, such as start up, shut down, or
360 /// a configuration change.
361 Notice,
362 /// (400) Warning events might cause problems.
363 Warning,
364 /// (500) Error events are likely to cause problems.
365 Error,
366 /// (600) Critical events cause more severe problems or outages.
367 Critical,
368 /// (700) A person must take an action immediately.
369 Alert,
370 /// (800) One or more systems are unusable.
371 Emergency,
372 /// If set, the enum was initialized with an unknown value.
373 ///
374 /// Applications can examine the value using [LogSeverity::value] or
375 /// [LogSeverity::name].
376 UnknownValue(log_severity::UnknownValue),
377}
378
379#[doc(hidden)]
380pub mod log_severity {
381 #[allow(unused_imports)]
382 use super::*;
383 #[derive(Clone, Debug, PartialEq)]
384 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
385}
386
387impl LogSeverity {
388 /// Gets the enum value.
389 ///
390 /// Returns `None` if the enum contains an unknown value deserialized from
391 /// the string representation of enums.
392 pub fn value(&self) -> std::option::Option<i32> {
393 match self {
394 Self::Default => std::option::Option::Some(0),
395 Self::Debug => std::option::Option::Some(100),
396 Self::Info => std::option::Option::Some(200),
397 Self::Notice => std::option::Option::Some(300),
398 Self::Warning => std::option::Option::Some(400),
399 Self::Error => std::option::Option::Some(500),
400 Self::Critical => std::option::Option::Some(600),
401 Self::Alert => std::option::Option::Some(700),
402 Self::Emergency => std::option::Option::Some(800),
403 Self::UnknownValue(u) => u.0.value(),
404 }
405 }
406
407 /// Gets the enum value as a string.
408 ///
409 /// Returns `None` if the enum contains an unknown value deserialized from
410 /// the integer representation of enums.
411 pub fn name(&self) -> std::option::Option<&str> {
412 match self {
413 Self::Default => std::option::Option::Some("DEFAULT"),
414 Self::Debug => std::option::Option::Some("DEBUG"),
415 Self::Info => std::option::Option::Some("INFO"),
416 Self::Notice => std::option::Option::Some("NOTICE"),
417 Self::Warning => std::option::Option::Some("WARNING"),
418 Self::Error => std::option::Option::Some("ERROR"),
419 Self::Critical => std::option::Option::Some("CRITICAL"),
420 Self::Alert => std::option::Option::Some("ALERT"),
421 Self::Emergency => std::option::Option::Some("EMERGENCY"),
422 Self::UnknownValue(u) => u.0.name(),
423 }
424 }
425}
426
427impl std::default::Default for LogSeverity {
428 fn default() -> Self {
429 use std::convert::From;
430 Self::from(0)
431 }
432}
433
434impl std::fmt::Display for LogSeverity {
435 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
436 wkt::internal::display_enum(f, self.name(), self.value())
437 }
438}
439
440impl std::convert::From<i32> for LogSeverity {
441 fn from(value: i32) -> Self {
442 match value {
443 0 => Self::Default,
444 100 => Self::Debug,
445 200 => Self::Info,
446 300 => Self::Notice,
447 400 => Self::Warning,
448 500 => Self::Error,
449 600 => Self::Critical,
450 700 => Self::Alert,
451 800 => Self::Emergency,
452 _ => Self::UnknownValue(log_severity::UnknownValue(
453 wkt::internal::UnknownEnumValue::Integer(value),
454 )),
455 }
456 }
457}
458
459impl std::convert::From<&str> for LogSeverity {
460 fn from(value: &str) -> Self {
461 use std::string::ToString;
462 match value {
463 "DEFAULT" => Self::Default,
464 "DEBUG" => Self::Debug,
465 "INFO" => Self::Info,
466 "NOTICE" => Self::Notice,
467 "WARNING" => Self::Warning,
468 "ERROR" => Self::Error,
469 "CRITICAL" => Self::Critical,
470 "ALERT" => Self::Alert,
471 "EMERGENCY" => Self::Emergency,
472 _ => Self::UnknownValue(log_severity::UnknownValue(
473 wkt::internal::UnknownEnumValue::String(value.to_string()),
474 )),
475 }
476 }
477}
478
479impl serde::ser::Serialize for LogSeverity {
480 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
481 where
482 S: serde::Serializer,
483 {
484 match self {
485 Self::Default => serializer.serialize_i32(0),
486 Self::Debug => serializer.serialize_i32(100),
487 Self::Info => serializer.serialize_i32(200),
488 Self::Notice => serializer.serialize_i32(300),
489 Self::Warning => serializer.serialize_i32(400),
490 Self::Error => serializer.serialize_i32(500),
491 Self::Critical => serializer.serialize_i32(600),
492 Self::Alert => serializer.serialize_i32(700),
493 Self::Emergency => serializer.serialize_i32(800),
494 Self::UnknownValue(u) => u.0.serialize(serializer),
495 }
496 }
497}
498
499impl<'de> serde::de::Deserialize<'de> for LogSeverity {
500 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
501 where
502 D: serde::Deserializer<'de>,
503 {
504 deserializer.deserialize_any(wkt::internal::EnumVisitor::<LogSeverity>::new(
505 ".google.logging.type.LogSeverity",
506 ))
507 }
508}