google-cloud-logging-type 1.4.0

Google Cloud Client Libraries for Rust - Logging types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate bytes;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A common proto for logging HTTP requests. Only contains semantics
/// defined by the HTTP specification. Product-specific logging
/// information MUST be defined in a separate message.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct HttpRequest {
    /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
    pub request_method: std::string::String,

    /// The scheme (http, https), the host name, the path and the query
    /// portion of the URL that was requested.
    /// Example: ``http://example.com/some/info?color=red``.
    pub request_url: std::string::String,

    /// The size of the HTTP request message in bytes, including the request
    /// headers and the request body.
    pub request_size: i64,

    /// The response code indicating the status of response.
    /// Examples: 200, 404.
    pub status: i32,

    /// The size of the HTTP response message sent back to the client, in bytes,
    /// including the response headers and the response body.
    pub response_size: i64,

    /// The user agent sent by the client. Example:
    /// `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
    /// CLR 1.0.3705)"`.
    pub user_agent: std::string::String,

    /// The IP address (IPv4 or IPv6) of the client that issued the HTTP
    /// request. This field can include port information. Examples:
    /// `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`.
    pub remote_ip: std::string::String,

    /// The IP address (IPv4 or IPv6) of the origin server that the request was
    /// sent to. This field can include port information. Examples:
    /// `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`.
    pub server_ip: std::string::String,

    /// The referer URL of the request, as defined in
    /// [HTTP/1.1 Header Field
    /// Definitions](https://datatracker.ietf.org/doc/html/rfc2616#section-14.36).
    pub referer: std::string::String,

    /// The request processing latency on the server, from the time the request was
    /// received until the response was sent.
    pub latency: std::option::Option<wkt::Duration>,

    /// Whether or not a cache lookup was attempted.
    pub cache_lookup: bool,

    /// Whether or not an entity was served from cache
    /// (with or without validation).
    pub cache_hit: bool,

    /// Whether or not the response was validated with the origin server before
    /// being served from cache. This field is only meaningful if `cache_hit` is
    /// True.
    pub cache_validated_with_origin_server: bool,

    /// The number of HTTP response bytes inserted into cache. Set only when a
    /// cache fill was attempted.
    pub cache_fill_bytes: i64,

    /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
    pub protocol: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl HttpRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [request_method][crate::model::HttpRequest::request_method].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_request_method("example");
    /// ```
    pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_method = v.into();
        self
    }

    /// Sets the value of [request_url][crate::model::HttpRequest::request_url].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_request_url("example");
    /// ```
    pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_url = v.into();
        self
    }

    /// Sets the value of [request_size][crate::model::HttpRequest::request_size].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_request_size(42);
    /// ```
    pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.request_size = v.into();
        self
    }

    /// Sets the value of [status][crate::model::HttpRequest::status].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_status(42);
    /// ```
    pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.status = v.into();
        self
    }

    /// Sets the value of [response_size][crate::model::HttpRequest::response_size].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_response_size(42);
    /// ```
    pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.response_size = v.into();
        self
    }

    /// Sets the value of [user_agent][crate::model::HttpRequest::user_agent].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_user_agent("example");
    /// ```
    pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.user_agent = v.into();
        self
    }

    /// Sets the value of [remote_ip][crate::model::HttpRequest::remote_ip].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_remote_ip("example");
    /// ```
    pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.remote_ip = v.into();
        self
    }

    /// Sets the value of [server_ip][crate::model::HttpRequest::server_ip].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_server_ip("example");
    /// ```
    pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.server_ip = v.into();
        self
    }

    /// Sets the value of [referer][crate::model::HttpRequest::referer].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_referer("example");
    /// ```
    pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.referer = v.into();
        self
    }

    /// Sets the value of [latency][crate::model::HttpRequest::latency].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// use wkt::Duration;
    /// let x = HttpRequest::new().set_latency(Duration::default()/* use setters */);
    /// ```
    pub fn set_latency<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.latency = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [latency][crate::model::HttpRequest::latency].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// use wkt::Duration;
    /// let x = HttpRequest::new().set_or_clear_latency(Some(Duration::default()/* use setters */));
    /// let x = HttpRequest::new().set_or_clear_latency(None::<Duration>);
    /// ```
    pub fn set_or_clear_latency<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.latency = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cache_lookup][crate::model::HttpRequest::cache_lookup].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_cache_lookup(true);
    /// ```
    pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.cache_lookup = v.into();
        self
    }

    /// Sets the value of [cache_hit][crate::model::HttpRequest::cache_hit].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_cache_hit(true);
    /// ```
    pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.cache_hit = v.into();
        self
    }

    /// Sets the value of [cache_validated_with_origin_server][crate::model::HttpRequest::cache_validated_with_origin_server].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_cache_validated_with_origin_server(true);
    /// ```
    pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
        mut self,
        v: T,
    ) -> Self {
        self.cache_validated_with_origin_server = v.into();
        self
    }

    /// Sets the value of [cache_fill_bytes][crate::model::HttpRequest::cache_fill_bytes].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_cache_fill_bytes(42);
    /// ```
    pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.cache_fill_bytes = v.into();
        self
    }

    /// Sets the value of [protocol][crate::model::HttpRequest::protocol].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_logging_type::model::HttpRequest;
    /// let x = HttpRequest::new().set_protocol("example");
    /// ```
    pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.protocol = v.into();
        self
    }
}

impl wkt::message::Message for HttpRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.logging.type.HttpRequest"
    }
}

/// The severity of the event described in a log entry, expressed as one of the
/// standard severity levels listed below.  For your reference, the levels are
/// assigned the listed numeric values. The effect of using numeric values other
/// than those listed is undefined.
///
/// You can filter for log entries by severity.  For example, the following
/// filter expression will match log entries with severities `INFO`, `NOTICE`,
/// and `WARNING`:
///
/// ```norust
/// severity > DEBUG AND severity <= WARNING
/// ```
///
/// If you are writing log entries, you should map other severity encodings to
/// one of these standard levels. For example, you might map all of Java's FINE,
/// FINER, and FINEST levels to `LogSeverity.DEBUG`. You can preserve the
/// original severity level in the log entry payload if you wish.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum LogSeverity {
    /// (0) The log entry has no assigned severity level.
    Default,
    /// (100) Debug or trace information.
    Debug,
    /// (200) Routine information, such as ongoing status or performance.
    Info,
    /// (300) Normal but significant events, such as start up, shut down, or
    /// a configuration change.
    Notice,
    /// (400) Warning events might cause problems.
    Warning,
    /// (500) Error events are likely to cause problems.
    Error,
    /// (600) Critical events cause more severe problems or outages.
    Critical,
    /// (700) A person must take an action immediately.
    Alert,
    /// (800) One or more systems are unusable.
    Emergency,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [LogSeverity::value] or
    /// [LogSeverity::name].
    UnknownValue(log_severity::UnknownValue),
}

#[doc(hidden)]
pub mod log_severity {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl LogSeverity {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Default => std::option::Option::Some(0),
            Self::Debug => std::option::Option::Some(100),
            Self::Info => std::option::Option::Some(200),
            Self::Notice => std::option::Option::Some(300),
            Self::Warning => std::option::Option::Some(400),
            Self::Error => std::option::Option::Some(500),
            Self::Critical => std::option::Option::Some(600),
            Self::Alert => std::option::Option::Some(700),
            Self::Emergency => std::option::Option::Some(800),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Default => std::option::Option::Some("DEFAULT"),
            Self::Debug => std::option::Option::Some("DEBUG"),
            Self::Info => std::option::Option::Some("INFO"),
            Self::Notice => std::option::Option::Some("NOTICE"),
            Self::Warning => std::option::Option::Some("WARNING"),
            Self::Error => std::option::Option::Some("ERROR"),
            Self::Critical => std::option::Option::Some("CRITICAL"),
            Self::Alert => std::option::Option::Some("ALERT"),
            Self::Emergency => std::option::Option::Some("EMERGENCY"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for LogSeverity {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for LogSeverity {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for LogSeverity {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Default,
            100 => Self::Debug,
            200 => Self::Info,
            300 => Self::Notice,
            400 => Self::Warning,
            500 => Self::Error,
            600 => Self::Critical,
            700 => Self::Alert,
            800 => Self::Emergency,
            _ => Self::UnknownValue(log_severity::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for LogSeverity {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "DEFAULT" => Self::Default,
            "DEBUG" => Self::Debug,
            "INFO" => Self::Info,
            "NOTICE" => Self::Notice,
            "WARNING" => Self::Warning,
            "ERROR" => Self::Error,
            "CRITICAL" => Self::Critical,
            "ALERT" => Self::Alert,
            "EMERGENCY" => Self::Emergency,
            _ => Self::UnknownValue(log_severity::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for LogSeverity {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Default => serializer.serialize_i32(0),
            Self::Debug => serializer.serialize_i32(100),
            Self::Info => serializer.serialize_i32(200),
            Self::Notice => serializer.serialize_i32(300),
            Self::Warning => serializer.serialize_i32(400),
            Self::Error => serializer.serialize_i32(500),
            Self::Critical => serializer.serialize_i32(600),
            Self::Alert => serializer.serialize_i32(700),
            Self::Emergency => serializer.serialize_i32(800),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for LogSeverity {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<LogSeverity>::new(
            ".google.logging.type.LogSeverity",
        ))
    }
}