google_logging2_beta1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// View and manage your data across Google Cloud Platform services
17 CloudPlatform,
18
19 /// View your data across Google Cloud Platform services
20 CloudPlatformReadOnly,
21
22 /// Administrate log data for your projects
23 Admin,
24
25 /// View log data for your projects
26 Read,
27
28 /// Submit log data for your projects
29 Write,
30}
31
32impl AsRef<str> for Scope {
33 fn as_ref(&self) -> &str {
34 match *self {
35 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
36 Scope::CloudPlatformReadOnly => {
37 "https://www.googleapis.com/auth/cloud-platform.read-only"
38 }
39 Scope::Admin => "https://www.googleapis.com/auth/logging.admin",
40 Scope::Read => "https://www.googleapis.com/auth/logging.read",
41 Scope::Write => "https://www.googleapis.com/auth/logging.write",
42 }
43 }
44}
45
46#[allow(clippy::derivable_impls)]
47impl Default for Scope {
48 fn default() -> Scope {
49 Scope::Read
50 }
51}
52
53// ########
54// HUB ###
55// ######
56
57/// Central instance to access all Logging related resource activities
58///
59/// # Examples
60///
61/// Instantiate a new hub
62///
63/// ```test_harness,no_run
64/// extern crate hyper;
65/// extern crate hyper_rustls;
66/// extern crate google_logging2_beta1 as logging2_beta1;
67/// use logging2_beta1::api::LogMetric;
68/// use logging2_beta1::{Result, Error};
69/// # async fn dox() {
70/// use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
71///
72/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
73/// // `client_secret`, among other things.
74/// let secret: yup_oauth2::ApplicationSecret = Default::default();
75/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
76/// // unless you replace `None` with the desired Flow.
77/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
78/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
79/// // retrieve them from storage.
80/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
81/// .with_native_roots()
82/// .unwrap()
83/// .https_only()
84/// .enable_http2()
85/// .build();
86///
87/// let executor = hyper_util::rt::TokioExecutor::new();
88/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
89/// secret,
90/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
91/// yup_oauth2::client::CustomHyperClientBuilder::from(
92/// hyper_util::client::legacy::Client::builder(executor).build(connector),
93/// ),
94/// ).build().await.unwrap();
95///
96/// let client = hyper_util::client::legacy::Client::builder(
97/// hyper_util::rt::TokioExecutor::new()
98/// )
99/// .build(
100/// hyper_rustls::HttpsConnectorBuilder::new()
101/// .with_native_roots()
102/// .unwrap()
103/// .https_or_http()
104/// .enable_http2()
105/// .build()
106/// );
107/// let mut hub = Logging::new(client, auth);
108/// // As the method needs a request, you would usually fill it with the desired information
109/// // into the respective structure. Some of the parts shown here might not be applicable !
110/// // Values shown here are possibly random and not representative !
111/// let mut req = LogMetric::default();
112///
113/// // You can configure optional parameters by calling the respective setters at will, and
114/// // execute the final call using `doit()`.
115/// // Values shown here are possibly random and not representative !
116/// let result = hub.projects().metrics_create(req, "parent")
117/// .doit().await;
118///
119/// match result {
120/// Err(e) => match e {
121/// // The Error enum provides details about what exactly happened.
122/// // You can also just use its `Debug`, `Display` or `Error` traits
123/// Error::HttpError(_)
124/// |Error::Io(_)
125/// |Error::MissingAPIKey
126/// |Error::MissingToken(_)
127/// |Error::Cancelled
128/// |Error::UploadSizeLimitExceeded(_, _)
129/// |Error::Failure(_)
130/// |Error::BadRequest(_)
131/// |Error::FieldClash(_)
132/// |Error::JsonDecodeError(_, _) => println!("{}", e),
133/// },
134/// Ok(res) => println!("Success: {:?}", res),
135/// }
136/// # }
137/// ```
138#[derive(Clone)]
139pub struct Logging<C> {
140 pub client: common::Client<C>,
141 pub auth: Box<dyn common::GetToken>,
142 _user_agent: String,
143 _base_url: String,
144 _root_url: String,
145}
146
147impl<C> common::Hub for Logging<C> {}
148
149impl<'a, C> Logging<C> {
150 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Logging<C> {
151 Logging {
152 client,
153 auth: Box::new(auth),
154 _user_agent: "google-api-rust-client/7.0.0".to_string(),
155 _base_url: "https://logging.googleapis.com/".to_string(),
156 _root_url: "https://logging.googleapis.com/".to_string(),
157 }
158 }
159
160 pub fn entries(&'a self) -> EntryMethods<'a, C> {
161 EntryMethods { hub: self }
162 }
163 pub fn monitored_resource_descriptors(&'a self) -> MonitoredResourceDescriptorMethods<'a, C> {
164 MonitoredResourceDescriptorMethods { hub: self }
165 }
166 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
167 ProjectMethods { hub: self }
168 }
169
170 /// Set the user-agent header field to use in all requests to the server.
171 /// It defaults to `google-api-rust-client/7.0.0`.
172 ///
173 /// Returns the previously set user-agent.
174 pub fn user_agent(&mut self, agent_name: String) -> String {
175 std::mem::replace(&mut self._user_agent, agent_name)
176 }
177
178 /// Set the base url to use in all requests to the server.
179 /// It defaults to `https://logging.googleapis.com/`.
180 ///
181 /// Returns the previously set base url.
182 pub fn base_url(&mut self, new_base_url: String) -> String {
183 std::mem::replace(&mut self._base_url, new_base_url)
184 }
185
186 /// Set the root url to use in all requests to the server.
187 /// It defaults to `https://logging.googleapis.com/`.
188 ///
189 /// Returns the previously set root url.
190 pub fn root_url(&mut self, new_root_url: String) -> String {
191 std::mem::replace(&mut self._root_url, new_root_url)
192 }
193}
194
195// ############
196// SCHEMAS ###
197// ##########
198/// BucketOptions describes the bucket boundaries used to create a histogram for the distribution. The buckets can be in a linear sequence, an exponential sequence, or each bucket can be specified explicitly. BucketOptions does not include the number of values in each bucket.A bucket has an inclusive lower bound and exclusive upper bound for the values that are counted for that bucket. The upper bound of a bucket must be strictly greater than the lower bound. The sequence of N buckets for a distribution consists of an underflow bucket (number 0), zero or more finite buckets (number 1 through N - 2) and an overflow bucket (number N - 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the same as the upper bound of bucket i - 1. The buckets span the whole range of finite values: lower bound of the underflow bucket is -infinity and the upper bound of the overflow bucket is +infinity. The finite buckets are so-called because both bounds are finite.
199///
200/// This type is not used in any activity, and only used as *part* of another schema.
201///
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct BucketOptions {
206 /// The explicit buckets.
207 #[serde(rename = "explicitBuckets")]
208 pub explicit_buckets: Option<Explicit>,
209 /// The exponential buckets.
210 #[serde(rename = "exponentialBuckets")]
211 pub exponential_buckets: Option<Exponential>,
212 /// The linear bucket.
213 #[serde(rename = "linearBuckets")]
214 pub linear_buckets: Option<Linear>,
215}
216
217impl common::Part for BucketOptions {}
218
219/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance:
220/// service Foo {
221/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
222/// }
223/// The JSON representation for Empty is empty JSON object {}.
224///
225/// # Activities
226///
227/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
228/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
229///
230/// * [metrics delete projects](ProjectMetricDeleteCall) (response)
231/// * [sinks delete projects](ProjectSinkDeleteCall) (response)
232#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
233#[serde_with::serde_as]
234#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
235pub struct Empty {
236 _never_set: Option<bool>,
237}
238
239impl common::ResponseResult for Empty {}
240
241/// Specifies a set of buckets with arbitrary widths.There are size(bounds) + 1 (= N) buckets. Bucket i has the following boundaries:Upper bound (0 <= i < N-1): boundsi Lower bound (1 <= i < N); boundsi - 1The bounds field must contain at least one element. If bounds has only one element, then there are no finite buckets, and that single element is the common boundary of the overflow and underflow buckets.
242///
243/// This type is not used in any activity, and only used as *part* of another schema.
244///
245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
246#[serde_with::serde_as]
247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
248pub struct Explicit {
249 /// The values must be monotonically increasing.
250 pub bounds: Option<Vec<f64>>,
251}
252
253impl common::Part for Explicit {}
254
255/// Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket.There are num_finite_buckets + 2 (= N) buckets. Bucket i has the following boundaries:Upper bound (0 <= i < N-1): scale * (growth_factor ^ i). Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
256///
257/// This type is not used in any activity, and only used as *part* of another schema.
258///
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct Exponential {
263 /// Must be greater than 1.
264 #[serde(rename = "growthFactor")]
265 pub growth_factor: Option<f64>,
266 /// Must be greater than 0.
267 #[serde(rename = "numFiniteBuckets")]
268 pub num_finite_buckets: Option<i32>,
269 /// Must be greater than 0.
270 pub scale: Option<f64>,
271}
272
273impl common::Part for Exponential {}
274
275/// 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.
276///
277/// This type is not used in any activity, and only used as *part* of another schema.
278///
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct HttpRequest {
283 /// The number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted.
284 #[serde(rename = "cacheFillBytes")]
285 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
286 pub cache_fill_bytes: Option<i64>,
287 /// Whether or not an entity was served from cache (with or without validation).
288 #[serde(rename = "cacheHit")]
289 pub cache_hit: Option<bool>,
290 /// Whether or not a cache lookup was attempted.
291 #[serde(rename = "cacheLookup")]
292 pub cache_lookup: Option<bool>,
293 /// 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.
294 #[serde(rename = "cacheValidatedWithOriginServer")]
295 pub cache_validated_with_origin_server: Option<bool>,
296 /// The request processing latency on the server, from the time the request was received until the response was sent.
297 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
298 pub latency: Option<chrono::Duration>,
299 /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
300 pub protocol: Option<String>,
301 /// The referer URL of the request, as defined in HTTP/1.1 Header Field Definitions (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
302 pub referer: Option<String>,
303 /// The IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples: "192.168.1.1", "FE80::0202:B3FF:FE1E:8329".
304 #[serde(rename = "remoteIp")]
305 pub remote_ip: Option<String>,
306 /// The request method. Examples: "GET", "HEAD", "PUT", "POST".
307 #[serde(rename = "requestMethod")]
308 pub request_method: Option<String>,
309 /// The size of the HTTP request message in bytes, including the request headers and the request body.
310 #[serde(rename = "requestSize")]
311 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
312 pub request_size: Option<i64>,
313 /// 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".
314 #[serde(rename = "requestUrl")]
315 pub request_url: Option<String>,
316 /// The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.
317 #[serde(rename = "responseSize")]
318 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
319 pub response_size: Option<i64>,
320 /// The IP address (IPv4 or IPv6) of the origin server that the request was sent to.
321 #[serde(rename = "serverIp")]
322 pub server_ip: Option<String>,
323 /// The response code indicating the status of response. Examples: 200, 404.
324 pub status: Option<i32>,
325 /// The user agent sent by the client. Example: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
326 /// CLR 1.0.3705)".
327 #[serde(rename = "userAgent")]
328 pub user_agent: Option<String>,
329}
330
331impl common::Part for HttpRequest {}
332
333/// A description of a label.
334///
335/// This type is not used in any activity, and only used as *part* of another schema.
336///
337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
338#[serde_with::serde_as]
339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
340pub struct LabelDescriptor {
341 /// A human-readable description for the label.
342 pub description: Option<String>,
343 /// The label key.
344 pub key: Option<String>,
345 /// The type of data that can be assigned to the label.
346 #[serde(rename = "valueType")]
347 pub value_type: Option<String>,
348}
349
350impl common::Part for LabelDescriptor {}
351
352/// Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket.There are num_finite_buckets + 2 (= N) buckets. Bucket i has the following boundaries:Upper bound (0 <= i < N-1): offset + (width * i). Lower bound (1 <= i < N): offset + (width * (i - 1)).
353///
354/// This type is not used in any activity, and only used as *part* of another schema.
355///
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct Linear {
360 /// Must be greater than 0.
361 #[serde(rename = "numFiniteBuckets")]
362 pub num_finite_buckets: Option<i32>,
363 /// Lower bound of the first bucket.
364 pub offset: Option<f64>,
365 /// Must be greater than 0.
366 pub width: Option<f64>,
367}
368
369impl common::Part for Linear {}
370
371/// The parameters to ListLogEntries.
372///
373/// # Activities
374///
375/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
376/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
377///
378/// * [list entries](EntryListCall) (request)
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct ListLogEntriesRequest {
383 /// Optional. A filter that chooses which log entries to return. See Advanced Logs Filters. Only log entries that match the filter are returned. An empty filter matches all log entries in the resources listed in resource_names. Referencing a parent resource that is not listed in resource_names will cause the filter to return no results. The maximum length of the filter is 20000 characters.
384 pub filter: Option<String>,
385 /// Optional. How the results should be sorted. Presently, the only permitted values are "timestamp asc" (default) and "timestamp desc". The first option returns entries in order of increasing values of LogEntry.timestamp (oldest first), and the second option returns entries in order of decreasing timestamps (newest first). Entries with equal timestamps are returned in order of their insert_id values.
386 #[serde(rename = "orderBy")]
387 pub order_by: Option<String>,
388 /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. The presence of next_page_token in the response indicates that more results might be available.
389 #[serde(rename = "pageSize")]
390 pub page_size: Option<i32>,
391 /// Optional. If present, then retrieve the next batch of results from the preceding call to this method. page_token must be the value of next_page_token from the previous response. The values of other method parameters should be identical to those in the previous call.
392 #[serde(rename = "pageToken")]
393 pub page_token: Option<String>,
394 /// Deprecated. Use resource_names instead. One or more project identifiers or project numbers from which to retrieve log entries. Example: "my-project-1A".
395 #[serde(rename = "projectIds")]
396 pub project_ids: Option<Vec<String>>,
397 /// Required. Names of one or more parent resources from which to retrieve log entries:
398 /// "projects/[PROJECT_ID]"
399 /// "organizations/[ORGANIZATION_ID]"
400 /// "billingAccounts/[BILLING_ACCOUNT_ID]"
401 /// "folders/[FOLDER_ID]"
402 /// Projects listed in the project_ids field are added to this list.
403 #[serde(rename = "resourceNames")]
404 pub resource_names: Option<Vec<String>>,
405}
406
407impl common::RequestValue for ListLogEntriesRequest {}
408
409/// Result returned from ListLogEntries.
410///
411/// # Activities
412///
413/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
414/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
415///
416/// * [list entries](EntryListCall) (response)
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct ListLogEntriesResponse {
421 /// A list of log entries. If entries is empty, nextPageToken may still be returned, indicating that more entries may exist. See nextPageToken for more information.
422 pub entries: Option<Vec<LogEntry>>,
423 /// If there might be more results than those appearing in this response, then nextPageToken is included. To get the next set of results, call this method again using the value of nextPageToken as pageToken.If a value for next_page_token appears and the entries field is empty, it means that the search found no log entries so far but it did not have time to search all the possible log entries. Retry the method with this value for page_token to continue the search. Alternatively, consider speeding up the search by changing your filter to specify a single log name or resource type, or to narrow the time range of the search.
424 #[serde(rename = "nextPageToken")]
425 pub next_page_token: Option<String>,
426}
427
428impl common::ResponseResult for ListLogEntriesResponse {}
429
430/// Result returned from ListLogMetrics.
431///
432/// # Activities
433///
434/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
435/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
436///
437/// * [metrics list projects](ProjectMetricListCall) (response)
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct ListLogMetricsResponse {
442 /// A list of logs-based metrics.
443 pub metrics: Option<Vec<LogMetric>>,
444 /// If there might be more results than appear in this response, then nextPageToken is included. To get the next set of results, call this method again using the value of nextPageToken as pageToken.
445 #[serde(rename = "nextPageToken")]
446 pub next_page_token: Option<String>,
447}
448
449impl common::ResponseResult for ListLogMetricsResponse {}
450
451/// Result returned from ListMonitoredResourceDescriptors.
452///
453/// # Activities
454///
455/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
456/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
457///
458/// * [list monitored resource descriptors](MonitoredResourceDescriptorListCall) (response)
459#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
460#[serde_with::serde_as]
461#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
462pub struct ListMonitoredResourceDescriptorsResponse {
463 /// If there might be more results than those appearing in this response, then nextPageToken is included. To get the next set of results, call this method again using the value of nextPageToken as pageToken.
464 #[serde(rename = "nextPageToken")]
465 pub next_page_token: Option<String>,
466 /// A list of resource descriptors.
467 #[serde(rename = "resourceDescriptors")]
468 pub resource_descriptors: Option<Vec<MonitoredResourceDescriptor>>,
469}
470
471impl common::ResponseResult for ListMonitoredResourceDescriptorsResponse {}
472
473/// Result returned from ListSinks.
474///
475/// # Activities
476///
477/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
478/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
479///
480/// * [sinks list projects](ProjectSinkListCall) (response)
481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
482#[serde_with::serde_as]
483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
484pub struct ListSinksResponse {
485 /// If there might be more results than appear in this response, then nextPageToken is included. To get the next set of results, call the same method again using the value of nextPageToken as pageToken.
486 #[serde(rename = "nextPageToken")]
487 pub next_page_token: Option<String>,
488 /// A list of sinks.
489 pub sinks: Option<Vec<LogSink>>,
490}
491
492impl common::ResponseResult for ListSinksResponse {}
493
494/// An individual entry in a log.
495///
496/// This type is not used in any activity, and only used as *part* of another schema.
497///
498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
499#[serde_with::serde_as]
500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
501pub struct LogEntry {
502 /// Optional. Information about the HTTP request associated with this log entry, if applicable.
503 #[serde(rename = "httpRequest")]
504 pub http_request: Option<HttpRequest>,
505 /// Optional. A unique identifier for the log entry. If you provide a value, then Logging considers other log entries in the same project, with the same timestamp, and with the same insert_id to be duplicates which can be removed. If omitted in new log entries, then Logging assigns its own unique identifier. The insert_id is also used to order log entries that have the same timestamp value.
506 #[serde(rename = "insertId")]
507 pub insert_id: Option<String>,
508 /// The log entry payload, represented as a structure that is expressed as a JSON object.
509 #[serde(rename = "jsonPayload")]
510 pub json_payload: Option<HashMap<String, serde_json::Value>>,
511 /// Optional. A set of user-defined (key, value) data that provides additional information about the log entry.
512 pub labels: Option<HashMap<String, String>>,
513 /// Required. The resource name of the log to which this log entry belongs:
514 /// "projects/[PROJECT_ID]/logs/[LOG_ID]"
515 /// "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
516 /// "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
517 /// "folders/[FOLDER_ID]/logs/[LOG_ID]"
518 /// A project number may optionally be used in place of PROJECT_ID. The project number is translated to its corresponding PROJECT_ID internally and the log_name field will contain PROJECT_ID in queries and exports.[LOG_ID] must be URL-encoded within log_name. Example: "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity". [LOG_ID] must be less than 512 characters long and can only include the following characters: upper and lower case alphanumeric characters, forward-slash, underscore, hyphen, and period.For backward compatibility, if log_name begins with a forward-slash, such as /projects/..., then the log entry is ingested as usual but the forward-slash is removed. Listing the log entry will not show the leading slash and filtering for a log name with a leading slash will never return any results.
519 #[serde(rename = "logName")]
520 pub log_name: Option<String>,
521 /// Deprecated. Output only. Additional metadata about the monitored resource.Only k8s_container, k8s_pod, and k8s_node MonitoredResources have this field populated for GKE versions older than 1.12.6. For GKE versions 1.12.6 and above, the metadata field has been deprecated. The Kubernetes pod labels that used to be in metadata.userLabels will now be present in the labels field with a key prefix of k8s-pod/. The Stackdriver system labels that were present in the metadata.systemLabels field will no longer be available in the LogEntry.
522 pub metadata: Option<MonitoredResourceMetadata>,
523 /// Optional. Information about an operation associated with the log entry, if applicable.
524 pub operation: Option<LogEntryOperation>,
525 /// The log entry payload, represented as a protocol buffer. Some Google Cloud Platform services use this field for their log entry payloads.
526 #[serde(rename = "protoPayload")]
527 pub proto_payload: Option<HashMap<String, serde_json::Value>>,
528 /// Output only. The time the log entry was received by Logging.
529 #[serde(rename = "receiveTimestamp")]
530 pub receive_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
531 /// Required. The primary monitored resource associated with this log entry.Example: a log entry that reports a database error would be associated with the monitored resource designating the particular database that reported the error.
532 pub resource: Option<MonitoredResource>,
533 /// Optional. The severity of the log entry. The default value is LogSeverity.DEFAULT.
534 pub severity: Option<String>,
535 /// Optional. Source code location information associated with the log entry, if any.
536 #[serde(rename = "sourceLocation")]
537 pub source_location: Option<LogEntrySourceLocation>,
538 /// Optional. The span ID within the trace associated with the log entry.For Trace spans, this is the same format that the Trace API v2 uses: a 16-character hexadecimal encoding of an 8-byte array, such as <code>"000000000000004a"</code>.
539 #[serde(rename = "spanId")]
540 pub span_id: Option<String>,
541 /// The log entry payload, represented as a Unicode string (UTF-8).
542 #[serde(rename = "textPayload")]
543 pub text_payload: Option<String>,
544 /// Optional. The time the event described by the log entry occurred. This time is used to compute the log entry's age and to enforce the logs retention period. If this field is omitted in a new log entry, then Logging assigns it the current time. Timestamps have nanosecond accuracy, but trailing zeros in the fractional seconds might be omitted when the timestamp is displayed.Incoming log entries should have timestamps that are no more than the logs retention period in the past, and no more than 24 hours in the future. Log entries outside those time boundaries will not be available when calling entries.list, but those log entries can still be exported with LogSinks.
545 pub timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
546 /// Optional. Resource name of the trace associated with the log entry, if any. If it contains a relative resource name, the name is assumed to be relative to //tracing.googleapis.com. Example: projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824
547 pub trace: Option<String>,
548 /// Optional. The sampling decision of the trace associated with the log entry.True means that the trace resource name in the trace field was sampled for storage in a trace backend. False means that the trace was not sampled for storage when this log entry was written, or the sampling decision was unknown at the time. A non-sampled trace value is still useful as a request correlation identifier. The default is False.
549 #[serde(rename = "traceSampled")]
550 pub trace_sampled: Option<bool>,
551}
552
553impl common::Part for LogEntry {}
554
555/// Additional information about a potentially long-running operation with which a log entry is associated.
556///
557/// This type is not used in any activity, and only used as *part* of another schema.
558///
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct LogEntryOperation {
563 /// Optional. Set this to True if this is the first log entry in the operation.
564 pub first: Option<bool>,
565 /// Optional. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation.
566 pub id: Option<String>,
567 /// Optional. Set this to True if this is the last log entry in the operation.
568 pub last: Option<bool>,
569 /// Optional. An arbitrary producer identifier. The combination of id and producer must be globally unique. Examples for producer: "MyDivision.MyBigCompany.com", "github.com/MyProject/MyApplication".
570 pub producer: Option<String>,
571}
572
573impl common::Part for LogEntryOperation {}
574
575/// Additional information about the source code location that produced the log entry.
576///
577/// This type is not used in any activity, and only used as *part* of another schema.
578///
579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
580#[serde_with::serde_as]
581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
582pub struct LogEntrySourceLocation {
583 /// Optional. Source file name. Depending on the runtime environment, this might be a simple name or a fully-qualified name.
584 pub file: Option<String>,
585 /// Optional. Human-readable name of the function or method being invoked, with optional context such as the class or package name. This information may be used in contexts such as the logs viewer, where a file and line number are less meaningful. The format can vary by language. For example: qual.if.ied.Class.method (Java), dir/package.func (Go), function (Python).
586 pub function: Option<String>,
587 /// Optional. Line within the source file. 1-based; 0 indicates no line number available.
588 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
589 pub line: Option<i64>,
590}
591
592impl common::Part for LogEntrySourceLocation {}
593
594/// Describes a logs-based metric. The value of the metric is the number of log entries that match a logs filter in a given time interval.Logs-based metric can also be used to extract values from logs and create a a distribution of the values. The distribution records the statistics of the extracted values along with an optional histogram of the values as specified by the bucket options.
595///
596/// # Activities
597///
598/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
599/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
600///
601/// * [metrics create projects](ProjectMetricCreateCall) (request|response)
602/// * [metrics get projects](ProjectMetricGetCall) (response)
603/// * [metrics update projects](ProjectMetricUpdateCall) (request|response)
604#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
605#[serde_with::serde_as]
606#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
607pub struct LogMetric {
608 /// Optional. The bucket_options are required when the logs-based metric is using a DISTRIBUTION value type and it describes the bucket boundaries used to create a histogram of the extracted values.
609 #[serde(rename = "bucketOptions")]
610 pub bucket_options: Option<BucketOptions>,
611 /// Output only. The creation timestamp of the metric.This field may not be present for older metrics.
612 #[serde(rename = "createTime")]
613 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
614 /// Optional. A description of this metric, which is used in documentation. The maximum length of the description is 8000 characters.
615 pub description: Option<String>,
616 /// Required. An advanced logs filter which is used to match log entries. Example:
617 /// "resource.type=gae_app AND severity>=ERROR"
618 /// The maximum length of the filter is 20000 characters.
619 pub filter: Option<String>,
620 /// Optional. A map from a label key string to an extractor expression which is used to extract data from a log entry field and assign as the label value. Each label key specified in the LabelDescriptor must have an associated extractor expression in this map. The syntax of the extractor expression is the same as for the value_extractor field.The extracted value is converted to the type defined in the label descriptor. If the either the extraction or the type conversion fails, the label will have a default value. The default value for a string label is an empty string, for an integer label its 0, and for a boolean label its false.Note that there are upper bounds on the maximum number of labels and the number of active time series that are allowed in a project.
621 #[serde(rename = "labelExtractors")]
622 pub label_extractors: Option<HashMap<String, String>>,
623 /// Optional. The metric descriptor associated with the logs-based metric. If unspecified, it uses a default metric descriptor with a DELTA metric kind, INT64 value type, with no labels and a unit of "1". Such a metric counts the number of log entries matching the filter expression.The name, type, and description fields in the metric_descriptor are output only, and is constructed using the name and description field in the LogMetric.To create a logs-based metric that records a distribution of log values, a DELTA metric kind with a DISTRIBUTION value type must be used along with a value_extractor expression in the LogMetric.Each label in the metric descriptor must have a matching label name as the key and an extractor expression as the value in the label_extractors map.The metric_kind and value_type fields in the metric_descriptor cannot be updated once initially configured. New labels can be added in the metric_descriptor, but existing labels cannot be modified except for their description.
624 #[serde(rename = "metricDescriptor")]
625 pub metric_descriptor: Option<MetricDescriptor>,
626 /// Required. The client-assigned metric identifier. Examples: "error_count", "nginx/requests".Metric identifiers are limited to 100 characters and can include only the following characters: A-Z, a-z, 0-9, and the special characters _-.,+!*',()%/. The forward-slash character (/) denotes a hierarchy of name pieces, and it cannot be the first character of the name.The metric identifier in this field must not be URL-encoded (https://en.wikipedia.org/wiki/Percent-encoding). However, when the metric identifier appears as the [METRIC_ID] part of a metric_name API parameter, then the metric identifier must be URL-encoded. Example: "projects/my-project/metrics/nginx%2Frequests".
627 pub name: Option<String>,
628 /// Output only. The last update timestamp of the metric.This field may not be present for older metrics.
629 #[serde(rename = "updateTime")]
630 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
631 /// Optional. A value_extractor is required when using a distribution logs-based metric to extract the values to record from a log entry. Two functions are supported for value extraction: EXTRACT(field) or REGEXP_EXTRACT(field, regex). The argument are: 1. field: The name of the log entry field from which the value is to be extracted. 2. regex: A regular expression using the Google RE2 syntax (https://github.com/google/re2/wiki/Syntax) with a single capture group to extract data from the specified log entry field. The value of the field is converted to a string before applying the regex. It is an error to specify a regex that does not include exactly one capture group.The result of the extraction must be convertible to a double type, as the distribution always records double values. If either the extraction or the conversion to double fails, then those values are not recorded in the distribution.Example: REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")
632 #[serde(rename = "valueExtractor")]
633 pub value_extractor: Option<String>,
634 /// Deprecated. The API version that created or updated this metric. The v2 format is used by default and cannot be changed.
635 pub version: Option<String>,
636}
637
638impl common::RequestValue for LogMetric {}
639impl common::ResponseResult for LogMetric {}
640
641/// Describes a sink used to export log entries to one of the following destinations in any project: a Cloud Storage bucket, a BigQuery dataset, or a Cloud Pub/Sub topic. A logs filter controls which log entries are exported. The sink must be created within a project, organization, billing account, or folder.
642///
643/// # Activities
644///
645/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
646/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
647///
648/// * [sinks create projects](ProjectSinkCreateCall) (request|response)
649/// * [sinks get projects](ProjectSinkGetCall) (response)
650/// * [sinks update projects](ProjectSinkUpdateCall) (request|response)
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct LogSink {
655 /// Output only. The creation timestamp of the sink.This field may not be present for older sinks.
656 #[serde(rename = "createTime")]
657 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
658 /// Required. The export destination:
659 /// "storage.googleapis.com/[GCS_BUCKET]"
660 /// "bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]"
661 /// "pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_ID]"
662 /// The sink's writer_identity, set when the sink is created, must have permission to write to the destination or else the log entries are not exported. For more information, see Exporting Logs with Sinks.
663 pub destination: Option<String>,
664 /// Optional. An advanced logs filter. The only exported log entries are those that are in the resource owning the sink and that match the filter. For example:
665 /// logName="projects/[PROJECT_ID]/logs/[LOG_ID]" AND severity>=ERROR
666 ///
667 pub filter: Option<String>,
668 /// Optional. This field applies only to sinks owned by organizations and folders. If the field is false, the default, only the logs owned by the sink's parent resource are available for export. If the field is true, then logs from all the projects, folders, and billing accounts contained in the sink's parent resource are also available for export. Whether a particular log entry from the children is exported depends on the sink's filter expression. For example, if this field is true, then the filter resource.type=gce_instance would export all Compute Engine VM instance log entries from all projects in the sink's parent. To only export entries from certain child projects, filter on the project part of the log name:
669 /// logName:("projects/test-project1/" OR "projects/test-project2/") AND
670 /// resource.type=gce_instance
671 ///
672 #[serde(rename = "includeChildren")]
673 pub include_children: Option<bool>,
674 /// Required. The client-assigned sink identifier, unique within the project. Example: "my-syslog-errors-to-pubsub". Sink identifiers are limited to 100 characters and can include only the following characters: upper and lower-case alphanumeric characters, underscores, hyphens, and periods.
675 pub name: Option<String>,
676 /// Deprecated. The log entry format to use for this sink's exported log entries. The v2 format is used by default and cannot be changed.
677 #[serde(rename = "outputVersionFormat")]
678 pub output_version_format: Option<String>,
679 /// Output only. The last update timestamp of the sink.This field may not be present for older sinks.
680 #[serde(rename = "updateTime")]
681 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
682 /// Output only. An IAM identity—a service account or group—under which Logging writes the exported log entries to the sink's destination. This field is set by sinks.create and sinks.update based on the value of unique_writer_identity in those methods.Until you grant this identity write-access to the destination, log entry exports from this sink will fail. For more information, see Granting Access for a Resource. Consult the destination service's documentation to determine the appropriate IAM roles to assign to the identity.
683 #[serde(rename = "writerIdentity")]
684 pub writer_identity: Option<String>,
685}
686
687impl common::RequestValue for LogSink {}
688impl common::ResponseResult for LogSink {}
689
690/// Defines a metric type and its schema. Once a metric descriptor is created, deleting or altering it stops data collection and makes the metric type's existing data unusable.
691///
692/// This type is not used in any activity, and only used as *part* of another schema.
693///
694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
695#[serde_with::serde_as]
696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
697pub struct MetricDescriptor {
698 /// A detailed description of the metric, which can be used in documentation.
699 pub description: Option<String>,
700 /// A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count". This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota.
701 #[serde(rename = "displayName")]
702 pub display_name: Option<String>,
703 /// The set of labels that can be used to describe a specific instance of this metric type. For example, the appengine.googleapis.com/http/server/response_latencies metric type has a label for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed.
704 pub labels: Option<Vec<LabelDescriptor>>,
705 /// Optional. Metadata which can be used to guide usage of the metric.
706 pub metadata: Option<MetricDescriptorMetadata>,
707 /// Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metric_kind and value_type might not be supported.
708 #[serde(rename = "metricKind")]
709 pub metric_kind: Option<String>,
710 /// The resource name of the metric descriptor.
711 pub name: Option<String>,
712 /// The metric type, including its DNS name prefix. The type is not URL-encoded. All user-defined metric types have the DNS name custom.googleapis.com or external.googleapis.com. Metric types should use a natural hierarchical grouping. For example:
713 /// "custom.googleapis.com/invoice/paid/amount"
714 /// "external.googleapis.com/prometheus/up"
715 /// "appengine.googleapis.com/http/server/response_latencies"
716 ///
717 #[serde(rename = "type")]
718 pub type_: Option<String>,
719 /// The unit in which the metric value is reported. It is only applicable if the value_type is INT64, DOUBLE, or DISTRIBUTION. The supported units are a subset of The Unified Code for Units of Measure (http://unitsofmeasure.org/ucum.html) standard:Basic units (UNIT)
720 /// bit bit
721 /// By byte
722 /// s second
723 /// min minute
724 /// h hour
725 /// d dayPrefixes (PREFIX)
726 /// k kilo (10**3)
727 /// M mega (10**6)
728 /// G giga (10**9)
729 /// T tera (10**12)
730 /// P peta (10**15)
731 /// E exa (10**18)
732 /// Z zetta (10**21)
733 /// Y yotta (10**24)
734 /// m milli (10\*\*-3)
735 /// u micro (10\*\*-6)
736 /// n nano (10\*\*-9)
737 /// p pico (10\*\*-12)
738 /// f femto (10\*\*-15)
739 /// a atto (10\*\*-18)
740 /// z zepto (10\*\*-21)
741 /// y yocto (10\*\*-24)
742 /// Ki kibi (2**10)
743 /// Mi mebi (2**20)
744 /// Gi gibi (2**30)
745 /// Ti tebi (2**40)GrammarThe grammar also includes these connectors:
746 /// / division (as an infix operator, e.g. 1/s).
747 /// . multiplication (as an infix operator, e.g. GBy.d)The grammar for a unit is as follows:
748 /// Expression = Component { “.” Component } { “/” Component } ;
749 ///
750 /// Component = ( \[ PREFIX \] UNIT | “%” ) \[ Annotation \]
751 /// \| Annotation
752 /// \| “1”
753 /// ;
754 ///
755 /// Annotation = “{” NAME “}” ;
756 /// Notes:
757 /// Annotation is just a comment if it follows a UNIT and is equivalent to 1 if it is used alone. For examples, {requests}/s == 1/s, By{transmitted}/s == By/s.
758 /// NAME is a sequence of non-blank printable ASCII characters not containing ‘{’ or ‘}’.
759 /// 1 represents dimensionless value 1, such as in 1/s.
760 /// % represents dimensionless value 1/100, and annotates values giving a percentage.
761 pub unit: Option<String>,
762 /// Whether the measurement is an integer, a floating-point number, etc. Some combinations of metric_kind and value_type might not be supported.
763 #[serde(rename = "valueType")]
764 pub value_type: Option<String>,
765}
766
767impl common::Part for MetricDescriptor {}
768
769/// Additional annotations that can be used to guide the usage of a metric.
770///
771/// This type is not used in any activity, and only used as *part* of another schema.
772///
773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
774#[serde_with::serde_as]
775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
776pub struct MetricDescriptorMetadata {
777 /// The delay of data points caused by ingestion. Data points older than this age are guaranteed to be ingested and available to be read, excluding data loss due to errors.
778 #[serde(rename = "ingestDelay")]
779 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
780 pub ingest_delay: Option<chrono::Duration>,
781 /// The launch stage of the metric definition.
782 #[serde(rename = "launchStage")]
783 pub launch_stage: Option<String>,
784 /// The sampling period of metric data points. For metrics which are written periodically, consecutive data points are stored at this time interval, excluding data loss due to errors. Metrics with a higher granularity have a smaller sampling period.
785 #[serde(rename = "samplePeriod")]
786 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
787 pub sample_period: Option<chrono::Duration>,
788}
789
790impl common::Part for MetricDescriptorMetadata {}
791
792/// An object representing a resource that can be used for monitoring, logging, billing, or other purposes. Examples include virtual machine instances, databases, and storage devices such as disks. The type field identifies a MonitoredResourceDescriptor object that describes the resource’s schema. Information in the labels field identifies the actual resource and its attributes according to the schema. For example, a particular Compute Engine VM instance could be represented by the following object, because the MonitoredResourceDescriptor for “gce_instance” has labels “instance_id” and “zone”:
793/// { “type”: “gce_instance”,
794/// “labels”: { “instance_id”: “12345678901234”,
795/// “zone”: “us-central1-a” }}
796///
797/// This type is not used in any activity, and only used as *part* of another schema.
798#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
799#[serde_with::serde_as]
800#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
801pub struct MonitoredResource {
802 /// Required. Values for all of the labels listed in the associated monitored resource descriptor. For example, Compute Engine VM instances use the labels "project_id", "instance_id", and "zone".
803 pub labels: Option<HashMap<String, String>>,
804 /// Required. The monitored resource type. This field must match the type field of a MonitoredResourceDescriptor object. For example, the type of a Compute Engine VM instance is gce_instance.
805 #[serde(rename = "type")]
806 pub type_: Option<String>,
807}
808
809impl common::Part for MonitoredResource {}
810
811/// An object that describes the schema of a MonitoredResource object using a type name and a set of labels. For example, the monitored resource descriptor for Google Compute Engine VM instances has a type of “gce_instance” and specifies the use of the labels “instance_id” and “zone” to identify particular VM instances.Different APIs can support different monitored resource types. APIs generally provide a list method that returns the monitored resource descriptors used by the API.
812///
813/// # Activities
814///
815/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
816/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
817///
818/// * [list monitored resource descriptors](MonitoredResourceDescriptorListCall) (none)
819#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
820#[serde_with::serde_as]
821#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
822pub struct MonitoredResourceDescriptor {
823 /// Optional. A detailed description of the monitored resource type that might be used in documentation.
824 pub description: Option<String>,
825 /// Optional. A concise name for the monitored resource type that might be displayed in user interfaces. It should be a Title Cased Noun Phrase, without any article or other determiners. For example, "Google Cloud SQL Database".
826 #[serde(rename = "displayName")]
827 pub display_name: Option<String>,
828 /// Required. A set of labels used to describe instances of this monitored resource type. For example, an individual Google Cloud SQL database is identified by values for the labels "database_id" and "zone".
829 pub labels: Option<Vec<LabelDescriptor>>,
830 /// Optional. The resource name of the monitored resource descriptor: "projects/{project_id}/monitoredResourceDescriptors/{type}" where {type} is the value of the type field in this object and {project_id} is a project ID that provides API-specific context for accessing the type. APIs that do not use project information can use the resource name format "monitoredResourceDescriptors/{type}".
831 pub name: Option<String>,
832 /// Required. The monitored resource type. For example, the type "cloudsql_database" represents databases in Google Cloud SQL. The maximum length of this value is 256 characters.
833 #[serde(rename = "type")]
834 pub type_: Option<String>,
835}
836
837impl common::Resource for MonitoredResourceDescriptor {}
838
839/// Auxiliary metadata for a MonitoredResource object. MonitoredResource objects contain the minimum set of information to uniquely identify a monitored resource instance. There is some other useful auxiliary metadata. Monitoring and Logging use an ingestion pipeline to extract metadata for cloud resources of all types, and store the metadata in this message.
840///
841/// This type is not used in any activity, and only used as *part* of another schema.
842///
843#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
844#[serde_with::serde_as]
845#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
846pub struct MonitoredResourceMetadata {
847 /// Output only. Values for predefined system metadata labels. System labels are a kind of metadata extracted by Google, including "machine_image", "vpc", "subnet_id", "security_group", "name", etc. System label values can be only strings, Boolean values, or a list of strings. For example:
848 /// { "name": "my-test-instance",
849 /// "security_group": ["a", "b", "c"],
850 /// "spot_instance": false }
851 ///
852 #[serde(rename = "systemLabels")]
853 pub system_labels: Option<HashMap<String, serde_json::Value>>,
854 /// Output only. A map of user-defined metadata labels.
855 #[serde(rename = "userLabels")]
856 pub user_labels: Option<HashMap<String, String>>,
857}
858
859impl common::Part for MonitoredResourceMetadata {}
860
861/// The parameters to WriteLogEntries.
862///
863/// # Activities
864///
865/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
866/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
867///
868/// * [write entries](EntryWriteCall) (request)
869#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
870#[serde_with::serde_as]
871#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
872pub struct WriteLogEntriesRequest {
873 /// Optional. If true, the request should expect normal response, but the entries won't be persisted nor exported. Useful for checking whether the logging API endpoints are working properly before sending valuable data.
874 #[serde(rename = "dryRun")]
875 pub dry_run: Option<bool>,
876 /// Required. The log entries to send to Logging. The order of log entries in this list does not matter. Values supplied in this method's log_name, resource, and labels fields are copied into those log entries in this list that do not include values for their corresponding fields. For more information, see the LogEntry type.If the timestamp or insert_id fields are missing in log entries, then this method supplies the current time or a unique identifier, respectively. The supplied values are chosen so that, among the log entries that did not supply their own values, the entries earlier in the list will sort before the entries later in the list. See the entries.list method.Log entries with timestamps that are more than the logs retention period in the past or more than 24 hours in the future will not be available when calling entries.list. However, those log entries can still be exported with LogSinks.To improve throughput and to avoid exceeding the quota limit for calls to entries.write, you should try to include several log entries in this list, rather than calling this method for each individual log entry.
877 pub entries: Option<Vec<LogEntry>>,
878 /// Optional. Default labels that are added to the labels field of all log entries in entries. If a log entry already has a label with the same key as a label in this parameter, then the log entry's label is not changed. See LogEntry.
879 pub labels: Option<HashMap<String, String>>,
880 /// Optional. A default log resource name that is assigned to all log entries in entries that do not specify a value for log_name:
881 /// "projects/[PROJECT_ID]/logs/[LOG_ID]"
882 /// "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
883 /// "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
884 /// "folders/[FOLDER_ID]/logs/[LOG_ID]"
885 /// [LOG_ID] must be URL-encoded. For example:
886 /// "projects/my-project-id/logs/syslog"
887 /// "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"
888 /// The permission <code>logging.logEntries.create</code> is needed on each project, organization, billing account, or folder that is receiving new log entries, whether the resource is specified in <code>logName</code> or in an individual log entry.
889 #[serde(rename = "logName")]
890 pub log_name: Option<String>,
891 /// Optional. Whether valid entries should be written even if some other entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any entry is not written, then the response status is the error associated with one of the failed entries and the response includes error details keyed by the entries' zero-based index in the entries.write method.
892 #[serde(rename = "partialSuccess")]
893 pub partial_success: Option<bool>,
894 /// Optional. A default monitored resource object that is assigned to all log entries in entries that do not specify a value for resource. Example:
895 /// { “type”: “gce_instance”,
896 /// “labels”: {
897 /// “zone”: “us-central1-a”, “instance_id”: “00000000000000000000” }}
898 /// See LogEntry.
899 pub resource: Option<MonitoredResource>,
900}
901
902impl common::RequestValue for WriteLogEntriesRequest {}
903
904/// Result returned from WriteLogEntries. empty
905///
906/// # Activities
907///
908/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
909/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
910///
911/// * [write entries](EntryWriteCall) (response)
912#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
913#[serde_with::serde_as]
914#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
915pub struct WriteLogEntriesResponse {
916 _never_set: Option<bool>,
917}
918
919impl common::ResponseResult for WriteLogEntriesResponse {}
920
921// ###################
922// MethodBuilders ###
923// #################
924
925/// A builder providing access to all methods supported on *entry* resources.
926/// It is not used directly, but through the [`Logging`] hub.
927///
928/// # Example
929///
930/// Instantiate a resource builder
931///
932/// ```test_harness,no_run
933/// extern crate hyper;
934/// extern crate hyper_rustls;
935/// extern crate google_logging2_beta1 as logging2_beta1;
936///
937/// # async fn dox() {
938/// use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
939///
940/// let secret: yup_oauth2::ApplicationSecret = Default::default();
941/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
942/// .with_native_roots()
943/// .unwrap()
944/// .https_only()
945/// .enable_http2()
946/// .build();
947///
948/// let executor = hyper_util::rt::TokioExecutor::new();
949/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
950/// secret,
951/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
952/// yup_oauth2::client::CustomHyperClientBuilder::from(
953/// hyper_util::client::legacy::Client::builder(executor).build(connector),
954/// ),
955/// ).build().await.unwrap();
956///
957/// let client = hyper_util::client::legacy::Client::builder(
958/// hyper_util::rt::TokioExecutor::new()
959/// )
960/// .build(
961/// hyper_rustls::HttpsConnectorBuilder::new()
962/// .with_native_roots()
963/// .unwrap()
964/// .https_or_http()
965/// .enable_http2()
966/// .build()
967/// );
968/// let mut hub = Logging::new(client, auth);
969/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
970/// // like `list(...)` and `write(...)`
971/// // to build up your call.
972/// let rb = hub.entries();
973/// # }
974/// ```
975pub struct EntryMethods<'a, C>
976where
977 C: 'a,
978{
979 hub: &'a Logging<C>,
980}
981
982impl<'a, C> common::MethodsBuilder for EntryMethods<'a, C> {}
983
984impl<'a, C> EntryMethods<'a, C> {
985 /// Create a builder to help you perform the following task:
986 ///
987 /// Lists log entries. Use this method to retrieve log entries that originated from a project/folder/organization/billing account. For ways to export log entries, see Exporting Logs.
988 ///
989 /// # Arguments
990 ///
991 /// * `request` - No description provided.
992 pub fn list(&self, request: ListLogEntriesRequest) -> EntryListCall<'a, C> {
993 EntryListCall {
994 hub: self.hub,
995 _request: request,
996 _delegate: Default::default(),
997 _additional_params: Default::default(),
998 _scopes: Default::default(),
999 }
1000 }
1001
1002 /// Create a builder to help you perform the following task:
1003 ///
1004 /// Writes log entries to Logging. This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)
1005 ///
1006 /// # Arguments
1007 ///
1008 /// * `request` - No description provided.
1009 pub fn write(&self, request: WriteLogEntriesRequest) -> EntryWriteCall<'a, C> {
1010 EntryWriteCall {
1011 hub: self.hub,
1012 _request: request,
1013 _delegate: Default::default(),
1014 _additional_params: Default::default(),
1015 _scopes: Default::default(),
1016 }
1017 }
1018}
1019
1020/// A builder providing access to all methods supported on *monitoredResourceDescriptor* resources.
1021/// It is not used directly, but through the [`Logging`] hub.
1022///
1023/// # Example
1024///
1025/// Instantiate a resource builder
1026///
1027/// ```test_harness,no_run
1028/// extern crate hyper;
1029/// extern crate hyper_rustls;
1030/// extern crate google_logging2_beta1 as logging2_beta1;
1031///
1032/// # async fn dox() {
1033/// use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1034///
1035/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1036/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1037/// .with_native_roots()
1038/// .unwrap()
1039/// .https_only()
1040/// .enable_http2()
1041/// .build();
1042///
1043/// let executor = hyper_util::rt::TokioExecutor::new();
1044/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1045/// secret,
1046/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1047/// yup_oauth2::client::CustomHyperClientBuilder::from(
1048/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1049/// ),
1050/// ).build().await.unwrap();
1051///
1052/// let client = hyper_util::client::legacy::Client::builder(
1053/// hyper_util::rt::TokioExecutor::new()
1054/// )
1055/// .build(
1056/// hyper_rustls::HttpsConnectorBuilder::new()
1057/// .with_native_roots()
1058/// .unwrap()
1059/// .https_or_http()
1060/// .enable_http2()
1061/// .build()
1062/// );
1063/// let mut hub = Logging::new(client, auth);
1064/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1065/// // like `list(...)`
1066/// // to build up your call.
1067/// let rb = hub.monitored_resource_descriptors();
1068/// # }
1069/// ```
1070pub struct MonitoredResourceDescriptorMethods<'a, C>
1071where
1072 C: 'a,
1073{
1074 hub: &'a Logging<C>,
1075}
1076
1077impl<'a, C> common::MethodsBuilder for MonitoredResourceDescriptorMethods<'a, C> {}
1078
1079impl<'a, C> MonitoredResourceDescriptorMethods<'a, C> {
1080 /// Create a builder to help you perform the following task:
1081 ///
1082 /// Lists the descriptors for monitored resource types used by Logging.
1083 pub fn list(&self) -> MonitoredResourceDescriptorListCall<'a, C> {
1084 MonitoredResourceDescriptorListCall {
1085 hub: self.hub,
1086 _page_token: Default::default(),
1087 _page_size: Default::default(),
1088 _delegate: Default::default(),
1089 _additional_params: Default::default(),
1090 _scopes: Default::default(),
1091 }
1092 }
1093}
1094
1095/// A builder providing access to all methods supported on *project* resources.
1096/// It is not used directly, but through the [`Logging`] hub.
1097///
1098/// # Example
1099///
1100/// Instantiate a resource builder
1101///
1102/// ```test_harness,no_run
1103/// extern crate hyper;
1104/// extern crate hyper_rustls;
1105/// extern crate google_logging2_beta1 as logging2_beta1;
1106///
1107/// # async fn dox() {
1108/// use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1109///
1110/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1111/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1112/// .with_native_roots()
1113/// .unwrap()
1114/// .https_only()
1115/// .enable_http2()
1116/// .build();
1117///
1118/// let executor = hyper_util::rt::TokioExecutor::new();
1119/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1120/// secret,
1121/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1122/// yup_oauth2::client::CustomHyperClientBuilder::from(
1123/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1124/// ),
1125/// ).build().await.unwrap();
1126///
1127/// let client = hyper_util::client::legacy::Client::builder(
1128/// hyper_util::rt::TokioExecutor::new()
1129/// )
1130/// .build(
1131/// hyper_rustls::HttpsConnectorBuilder::new()
1132/// .with_native_roots()
1133/// .unwrap()
1134/// .https_or_http()
1135/// .enable_http2()
1136/// .build()
1137/// );
1138/// let mut hub = Logging::new(client, auth);
1139/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1140/// // like `metrics_create(...)`, `metrics_delete(...)`, `metrics_get(...)`, `metrics_list(...)`, `metrics_update(...)`, `sinks_create(...)`, `sinks_delete(...)`, `sinks_get(...)`, `sinks_list(...)` and `sinks_update(...)`
1141/// // to build up your call.
1142/// let rb = hub.projects();
1143/// # }
1144/// ```
1145pub struct ProjectMethods<'a, C>
1146where
1147 C: 'a,
1148{
1149 hub: &'a Logging<C>,
1150}
1151
1152impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1153
1154impl<'a, C> ProjectMethods<'a, C> {
1155 /// Create a builder to help you perform the following task:
1156 ///
1157 /// Creates a logs-based metric.
1158 ///
1159 /// # Arguments
1160 ///
1161 /// * `request` - No description provided.
1162 /// * `parent` - The resource name of the project in which to create the metric:
1163 /// "projects/[PROJECT_ID]"
1164 /// The new metric must be provided in the request.
1165 pub fn metrics_create(
1166 &self,
1167 request: LogMetric,
1168 parent: &str,
1169 ) -> ProjectMetricCreateCall<'a, C> {
1170 ProjectMetricCreateCall {
1171 hub: self.hub,
1172 _request: request,
1173 _parent: parent.to_string(),
1174 _delegate: Default::default(),
1175 _additional_params: Default::default(),
1176 _scopes: Default::default(),
1177 }
1178 }
1179
1180 /// Create a builder to help you perform the following task:
1181 ///
1182 /// Deletes a logs-based metric.
1183 ///
1184 /// # Arguments
1185 ///
1186 /// * `metricName` - The resource name of the metric to delete:
1187 /// "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
1188 ///
1189 pub fn metrics_delete(&self, metric_name: &str) -> ProjectMetricDeleteCall<'a, C> {
1190 ProjectMetricDeleteCall {
1191 hub: self.hub,
1192 _metric_name: metric_name.to_string(),
1193 _delegate: Default::default(),
1194 _additional_params: Default::default(),
1195 _scopes: Default::default(),
1196 }
1197 }
1198
1199 /// Create a builder to help you perform the following task:
1200 ///
1201 /// Gets a logs-based metric.
1202 ///
1203 /// # Arguments
1204 ///
1205 /// * `metricName` - The resource name of the desired metric:
1206 /// "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
1207 ///
1208 pub fn metrics_get(&self, metric_name: &str) -> ProjectMetricGetCall<'a, C> {
1209 ProjectMetricGetCall {
1210 hub: self.hub,
1211 _metric_name: metric_name.to_string(),
1212 _delegate: Default::default(),
1213 _additional_params: Default::default(),
1214 _scopes: Default::default(),
1215 }
1216 }
1217
1218 /// Create a builder to help you perform the following task:
1219 ///
1220 /// Lists logs-based metrics.
1221 ///
1222 /// # Arguments
1223 ///
1224 /// * `parent` - Required. The name of the project containing the metrics:
1225 /// "projects/[PROJECT_ID]"
1226 ///
1227 pub fn metrics_list(&self, parent: &str) -> ProjectMetricListCall<'a, C> {
1228 ProjectMetricListCall {
1229 hub: self.hub,
1230 _parent: parent.to_string(),
1231 _page_token: Default::default(),
1232 _page_size: Default::default(),
1233 _delegate: Default::default(),
1234 _additional_params: Default::default(),
1235 _scopes: Default::default(),
1236 }
1237 }
1238
1239 /// Create a builder to help you perform the following task:
1240 ///
1241 /// Creates or updates a logs-based metric.
1242 ///
1243 /// # Arguments
1244 ///
1245 /// * `request` - No description provided.
1246 /// * `metricName` - The resource name of the metric to update:
1247 /// "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
1248 /// The updated metric must be provided in the request and it's name field must be the same as [METRIC_ID] If the metric does not exist in [PROJECT_ID], then a new metric is created.
1249 pub fn metrics_update(
1250 &self,
1251 request: LogMetric,
1252 metric_name: &str,
1253 ) -> ProjectMetricUpdateCall<'a, C> {
1254 ProjectMetricUpdateCall {
1255 hub: self.hub,
1256 _request: request,
1257 _metric_name: metric_name.to_string(),
1258 _delegate: Default::default(),
1259 _additional_params: Default::default(),
1260 _scopes: Default::default(),
1261 }
1262 }
1263
1264 /// Create a builder to help you perform the following task:
1265 ///
1266 /// Creates a sink that exports specified log entries to a destination. The export of newly-ingested log entries begins immediately, unless the sink's writer_identity is not permitted to write to the destination. A sink can export log entries only from the resource owning the sink.
1267 ///
1268 /// # Arguments
1269 ///
1270 /// * `request` - No description provided.
1271 /// * `parent` - Required. The resource in which to create the sink:
1272 /// "projects/[PROJECT_ID]"
1273 /// "organizations/[ORGANIZATION_ID]"
1274 /// "billingAccounts/[BILLING_ACCOUNT_ID]"
1275 /// "folders/[FOLDER_ID]"
1276 /// Examples: "projects/my-logging-project", "organizations/123456789".
1277 pub fn sinks_create(&self, request: LogSink, parent: &str) -> ProjectSinkCreateCall<'a, C> {
1278 ProjectSinkCreateCall {
1279 hub: self.hub,
1280 _request: request,
1281 _parent: parent.to_string(),
1282 _unique_writer_identity: Default::default(),
1283 _delegate: Default::default(),
1284 _additional_params: Default::default(),
1285 _scopes: Default::default(),
1286 }
1287 }
1288
1289 /// Create a builder to help you perform the following task:
1290 ///
1291 /// Deletes a sink. If the sink has a unique writer_identity, then that service account is also deleted.
1292 ///
1293 /// # Arguments
1294 ///
1295 /// * `sinkName` - Required. The full resource name of the sink to delete, including the parent resource and the sink identifier:
1296 /// "projects/[PROJECT_ID]/sinks/[SINK_ID]"
1297 /// "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
1298 /// "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
1299 /// "folders/[FOLDER_ID]/sinks/[SINK_ID]"
1300 /// Example: "projects/my-project-id/sinks/my-sink-id".
1301 pub fn sinks_delete(&self, sink_name: &str) -> ProjectSinkDeleteCall<'a, C> {
1302 ProjectSinkDeleteCall {
1303 hub: self.hub,
1304 _sink_name: sink_name.to_string(),
1305 _delegate: Default::default(),
1306 _additional_params: Default::default(),
1307 _scopes: Default::default(),
1308 }
1309 }
1310
1311 /// Create a builder to help you perform the following task:
1312 ///
1313 /// Gets a sink.
1314 ///
1315 /// # Arguments
1316 ///
1317 /// * `sinkName` - Required. The resource name of the sink:
1318 /// "projects/[PROJECT_ID]/sinks/[SINK_ID]"
1319 /// "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
1320 /// "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
1321 /// "folders/[FOLDER_ID]/sinks/[SINK_ID]"
1322 /// Example: "projects/my-project-id/sinks/my-sink-id".
1323 pub fn sinks_get(&self, sink_name: &str) -> ProjectSinkGetCall<'a, C> {
1324 ProjectSinkGetCall {
1325 hub: self.hub,
1326 _sink_name: sink_name.to_string(),
1327 _delegate: Default::default(),
1328 _additional_params: Default::default(),
1329 _scopes: Default::default(),
1330 }
1331 }
1332
1333 /// Create a builder to help you perform the following task:
1334 ///
1335 /// Lists sinks.
1336 ///
1337 /// # Arguments
1338 ///
1339 /// * `parent` - Required. The parent resource whose sinks are to be listed:
1340 /// "projects/[PROJECT_ID]"
1341 /// "organizations/[ORGANIZATION_ID]"
1342 /// "billingAccounts/[BILLING_ACCOUNT_ID]"
1343 /// "folders/[FOLDER_ID]"
1344 ///
1345 pub fn sinks_list(&self, parent: &str) -> ProjectSinkListCall<'a, C> {
1346 ProjectSinkListCall {
1347 hub: self.hub,
1348 _parent: parent.to_string(),
1349 _page_token: Default::default(),
1350 _page_size: Default::default(),
1351 _delegate: Default::default(),
1352 _additional_params: Default::default(),
1353 _scopes: Default::default(),
1354 }
1355 }
1356
1357 /// Create a builder to help you perform the following task:
1358 ///
1359 /// Updates a sink. This method replaces the following fields in the existing sink with values from the new sink: destination, and filter.The updated sink might also have a new writer_identity; see the unique_writer_identity field.
1360 ///
1361 /// # Arguments
1362 ///
1363 /// * `request` - No description provided.
1364 /// * `sinkName` - Required. The full resource name of the sink to update, including the parent resource and the sink identifier:
1365 /// "projects/[PROJECT_ID]/sinks/[SINK_ID]"
1366 /// "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
1367 /// "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
1368 /// "folders/[FOLDER_ID]/sinks/[SINK_ID]"
1369 /// Example: "projects/my-project-id/sinks/my-sink-id".
1370 pub fn sinks_update(&self, request: LogSink, sink_name: &str) -> ProjectSinkUpdateCall<'a, C> {
1371 ProjectSinkUpdateCall {
1372 hub: self.hub,
1373 _request: request,
1374 _sink_name: sink_name.to_string(),
1375 _update_mask: Default::default(),
1376 _unique_writer_identity: Default::default(),
1377 _delegate: Default::default(),
1378 _additional_params: Default::default(),
1379 _scopes: Default::default(),
1380 }
1381 }
1382}
1383
1384// ###################
1385// CallBuilders ###
1386// #################
1387
1388/// Lists log entries. Use this method to retrieve log entries that originated from a project/folder/organization/billing account. For ways to export log entries, see Exporting Logs.
1389///
1390/// A builder for the *list* method supported by a *entry* resource.
1391/// It is not used directly, but through a [`EntryMethods`] instance.
1392///
1393/// # Example
1394///
1395/// Instantiate a resource method builder
1396///
1397/// ```test_harness,no_run
1398/// # extern crate hyper;
1399/// # extern crate hyper_rustls;
1400/// # extern crate google_logging2_beta1 as logging2_beta1;
1401/// use logging2_beta1::api::ListLogEntriesRequest;
1402/// # async fn dox() {
1403/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1404///
1405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1406/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1407/// # .with_native_roots()
1408/// # .unwrap()
1409/// # .https_only()
1410/// # .enable_http2()
1411/// # .build();
1412///
1413/// # let executor = hyper_util::rt::TokioExecutor::new();
1414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1415/// # secret,
1416/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1417/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1418/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1419/// # ),
1420/// # ).build().await.unwrap();
1421///
1422/// # let client = hyper_util::client::legacy::Client::builder(
1423/// # hyper_util::rt::TokioExecutor::new()
1424/// # )
1425/// # .build(
1426/// # hyper_rustls::HttpsConnectorBuilder::new()
1427/// # .with_native_roots()
1428/// # .unwrap()
1429/// # .https_or_http()
1430/// # .enable_http2()
1431/// # .build()
1432/// # );
1433/// # let mut hub = Logging::new(client, auth);
1434/// // As the method needs a request, you would usually fill it with the desired information
1435/// // into the respective structure. Some of the parts shown here might not be applicable !
1436/// // Values shown here are possibly random and not representative !
1437/// let mut req = ListLogEntriesRequest::default();
1438///
1439/// // You can configure optional parameters by calling the respective setters at will, and
1440/// // execute the final call using `doit()`.
1441/// // Values shown here are possibly random and not representative !
1442/// let result = hub.entries().list(req)
1443/// .doit().await;
1444/// # }
1445/// ```
1446pub struct EntryListCall<'a, C>
1447where
1448 C: 'a,
1449{
1450 hub: &'a Logging<C>,
1451 _request: ListLogEntriesRequest,
1452 _delegate: Option<&'a mut dyn common::Delegate>,
1453 _additional_params: HashMap<String, String>,
1454 _scopes: BTreeSet<String>,
1455}
1456
1457impl<'a, C> common::CallBuilder for EntryListCall<'a, C> {}
1458
1459impl<'a, C> EntryListCall<'a, C>
1460where
1461 C: common::Connector,
1462{
1463 /// Perform the operation you have build so far.
1464 pub async fn doit(mut self) -> common::Result<(common::Response, ListLogEntriesResponse)> {
1465 use std::borrow::Cow;
1466 use std::io::{Read, Seek};
1467
1468 use common::{url::Params, ToParts};
1469 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1470
1471 let mut dd = common::DefaultDelegate;
1472 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1473 dlg.begin(common::MethodInfo {
1474 id: "logging.entries.list",
1475 http_method: hyper::Method::POST,
1476 });
1477
1478 for &field in ["alt"].iter() {
1479 if self._additional_params.contains_key(field) {
1480 dlg.finished(false);
1481 return Err(common::Error::FieldClash(field));
1482 }
1483 }
1484
1485 let mut params = Params::with_capacity(3 + self._additional_params.len());
1486
1487 params.extend(self._additional_params.iter());
1488
1489 params.push("alt", "json");
1490 let mut url = self.hub._base_url.clone() + "v2beta1/entries:list";
1491 if self._scopes.is_empty() {
1492 self._scopes
1493 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
1494 }
1495
1496 let url = params.parse_with_url(&url);
1497
1498 let mut json_mime_type = mime::APPLICATION_JSON;
1499 let mut request_value_reader = {
1500 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1501 common::remove_json_null_values(&mut value);
1502 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1503 serde_json::to_writer(&mut dst, &value).unwrap();
1504 dst
1505 };
1506 let request_size = request_value_reader
1507 .seek(std::io::SeekFrom::End(0))
1508 .unwrap();
1509 request_value_reader
1510 .seek(std::io::SeekFrom::Start(0))
1511 .unwrap();
1512
1513 loop {
1514 let token = match self
1515 .hub
1516 .auth
1517 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1518 .await
1519 {
1520 Ok(token) => token,
1521 Err(e) => match dlg.token(e) {
1522 Ok(token) => token,
1523 Err(e) => {
1524 dlg.finished(false);
1525 return Err(common::Error::MissingToken(e));
1526 }
1527 },
1528 };
1529 request_value_reader
1530 .seek(std::io::SeekFrom::Start(0))
1531 .unwrap();
1532 let mut req_result = {
1533 let client = &self.hub.client;
1534 dlg.pre_request();
1535 let mut req_builder = hyper::Request::builder()
1536 .method(hyper::Method::POST)
1537 .uri(url.as_str())
1538 .header(USER_AGENT, self.hub._user_agent.clone());
1539
1540 if let Some(token) = token.as_ref() {
1541 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1542 }
1543
1544 let request = req_builder
1545 .header(CONTENT_TYPE, json_mime_type.to_string())
1546 .header(CONTENT_LENGTH, request_size as u64)
1547 .body(common::to_body(
1548 request_value_reader.get_ref().clone().into(),
1549 ));
1550
1551 client.request(request.unwrap()).await
1552 };
1553
1554 match req_result {
1555 Err(err) => {
1556 if let common::Retry::After(d) = dlg.http_error(&err) {
1557 sleep(d).await;
1558 continue;
1559 }
1560 dlg.finished(false);
1561 return Err(common::Error::HttpError(err));
1562 }
1563 Ok(res) => {
1564 let (mut parts, body) = res.into_parts();
1565 let mut body = common::Body::new(body);
1566 if !parts.status.is_success() {
1567 let bytes = common::to_bytes(body).await.unwrap_or_default();
1568 let error = serde_json::from_str(&common::to_string(&bytes));
1569 let response = common::to_response(parts, bytes.into());
1570
1571 if let common::Retry::After(d) =
1572 dlg.http_failure(&response, error.as_ref().ok())
1573 {
1574 sleep(d).await;
1575 continue;
1576 }
1577
1578 dlg.finished(false);
1579
1580 return Err(match error {
1581 Ok(value) => common::Error::BadRequest(value),
1582 _ => common::Error::Failure(response),
1583 });
1584 }
1585 let response = {
1586 let bytes = common::to_bytes(body).await.unwrap_or_default();
1587 let encoded = common::to_string(&bytes);
1588 match serde_json::from_str(&encoded) {
1589 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1590 Err(error) => {
1591 dlg.response_json_decode_error(&encoded, &error);
1592 return Err(common::Error::JsonDecodeError(
1593 encoded.to_string(),
1594 error,
1595 ));
1596 }
1597 }
1598 };
1599
1600 dlg.finished(true);
1601 return Ok(response);
1602 }
1603 }
1604 }
1605 }
1606
1607 ///
1608 /// Sets the *request* property to the given value.
1609 ///
1610 /// Even though the property as already been set when instantiating this call,
1611 /// we provide this method for API completeness.
1612 pub fn request(mut self, new_value: ListLogEntriesRequest) -> EntryListCall<'a, C> {
1613 self._request = new_value;
1614 self
1615 }
1616 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1617 /// while executing the actual API request.
1618 ///
1619 /// ````text
1620 /// It should be used to handle progress information, and to implement a certain level of resilience.
1621 /// ````
1622 ///
1623 /// Sets the *delegate* property to the given value.
1624 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EntryListCall<'a, C> {
1625 self._delegate = Some(new_value);
1626 self
1627 }
1628
1629 /// Set any additional parameter of the query string used in the request.
1630 /// It should be used to set parameters which are not yet available through their own
1631 /// setters.
1632 ///
1633 /// Please note that this method must not be used to set any of the known parameters
1634 /// which have their own setter method. If done anyway, the request will fail.
1635 ///
1636 /// # Additional Parameters
1637 ///
1638 /// * *$.xgafv* (query-string) - V1 error format.
1639 /// * *access_token* (query-string) - OAuth access token.
1640 /// * *alt* (query-string) - Data format for response.
1641 /// * *callback* (query-string) - JSONP
1642 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1643 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1644 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1645 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1646 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1647 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1648 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1649 pub fn param<T>(mut self, name: T, value: T) -> EntryListCall<'a, C>
1650 where
1651 T: AsRef<str>,
1652 {
1653 self._additional_params
1654 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1655 self
1656 }
1657
1658 /// Identifies the authorization scope for the method you are building.
1659 ///
1660 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1661 /// [`Scope::CloudPlatformReadOnly`].
1662 ///
1663 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1664 /// tokens for more than one scope.
1665 ///
1666 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1667 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1668 /// sufficient, a read-write scope will do as well.
1669 pub fn add_scope<St>(mut self, scope: St) -> EntryListCall<'a, C>
1670 where
1671 St: AsRef<str>,
1672 {
1673 self._scopes.insert(String::from(scope.as_ref()));
1674 self
1675 }
1676 /// Identifies the authorization scope(s) for the method you are building.
1677 ///
1678 /// See [`Self::add_scope()`] for details.
1679 pub fn add_scopes<I, St>(mut self, scopes: I) -> EntryListCall<'a, C>
1680 where
1681 I: IntoIterator<Item = St>,
1682 St: AsRef<str>,
1683 {
1684 self._scopes
1685 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1686 self
1687 }
1688
1689 /// Removes all scopes, and no default scope will be used either.
1690 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1691 /// for details).
1692 pub fn clear_scopes(mut self) -> EntryListCall<'a, C> {
1693 self._scopes.clear();
1694 self
1695 }
1696}
1697
1698/// Writes log entries to Logging. This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)
1699///
1700/// A builder for the *write* method supported by a *entry* resource.
1701/// It is not used directly, but through a [`EntryMethods`] instance.
1702///
1703/// # Example
1704///
1705/// Instantiate a resource method builder
1706///
1707/// ```test_harness,no_run
1708/// # extern crate hyper;
1709/// # extern crate hyper_rustls;
1710/// # extern crate google_logging2_beta1 as logging2_beta1;
1711/// use logging2_beta1::api::WriteLogEntriesRequest;
1712/// # async fn dox() {
1713/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1714///
1715/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1716/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1717/// # .with_native_roots()
1718/// # .unwrap()
1719/// # .https_only()
1720/// # .enable_http2()
1721/// # .build();
1722///
1723/// # let executor = hyper_util::rt::TokioExecutor::new();
1724/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1725/// # secret,
1726/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1727/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1728/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1729/// # ),
1730/// # ).build().await.unwrap();
1731///
1732/// # let client = hyper_util::client::legacy::Client::builder(
1733/// # hyper_util::rt::TokioExecutor::new()
1734/// # )
1735/// # .build(
1736/// # hyper_rustls::HttpsConnectorBuilder::new()
1737/// # .with_native_roots()
1738/// # .unwrap()
1739/// # .https_or_http()
1740/// # .enable_http2()
1741/// # .build()
1742/// # );
1743/// # let mut hub = Logging::new(client, auth);
1744/// // As the method needs a request, you would usually fill it with the desired information
1745/// // into the respective structure. Some of the parts shown here might not be applicable !
1746/// // Values shown here are possibly random and not representative !
1747/// let mut req = WriteLogEntriesRequest::default();
1748///
1749/// // You can configure optional parameters by calling the respective setters at will, and
1750/// // execute the final call using `doit()`.
1751/// // Values shown here are possibly random and not representative !
1752/// let result = hub.entries().write(req)
1753/// .doit().await;
1754/// # }
1755/// ```
1756pub struct EntryWriteCall<'a, C>
1757where
1758 C: 'a,
1759{
1760 hub: &'a Logging<C>,
1761 _request: WriteLogEntriesRequest,
1762 _delegate: Option<&'a mut dyn common::Delegate>,
1763 _additional_params: HashMap<String, String>,
1764 _scopes: BTreeSet<String>,
1765}
1766
1767impl<'a, C> common::CallBuilder for EntryWriteCall<'a, C> {}
1768
1769impl<'a, C> EntryWriteCall<'a, C>
1770where
1771 C: common::Connector,
1772{
1773 /// Perform the operation you have build so far.
1774 pub async fn doit(mut self) -> common::Result<(common::Response, WriteLogEntriesResponse)> {
1775 use std::borrow::Cow;
1776 use std::io::{Read, Seek};
1777
1778 use common::{url::Params, ToParts};
1779 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1780
1781 let mut dd = common::DefaultDelegate;
1782 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1783 dlg.begin(common::MethodInfo {
1784 id: "logging.entries.write",
1785 http_method: hyper::Method::POST,
1786 });
1787
1788 for &field in ["alt"].iter() {
1789 if self._additional_params.contains_key(field) {
1790 dlg.finished(false);
1791 return Err(common::Error::FieldClash(field));
1792 }
1793 }
1794
1795 let mut params = Params::with_capacity(3 + self._additional_params.len());
1796
1797 params.extend(self._additional_params.iter());
1798
1799 params.push("alt", "json");
1800 let mut url = self.hub._base_url.clone() + "v2beta1/entries:write";
1801 if self._scopes.is_empty() {
1802 self._scopes
1803 .insert(Scope::CloudPlatform.as_ref().to_string());
1804 }
1805
1806 let url = params.parse_with_url(&url);
1807
1808 let mut json_mime_type = mime::APPLICATION_JSON;
1809 let mut request_value_reader = {
1810 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1811 common::remove_json_null_values(&mut value);
1812 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1813 serde_json::to_writer(&mut dst, &value).unwrap();
1814 dst
1815 };
1816 let request_size = request_value_reader
1817 .seek(std::io::SeekFrom::End(0))
1818 .unwrap();
1819 request_value_reader
1820 .seek(std::io::SeekFrom::Start(0))
1821 .unwrap();
1822
1823 loop {
1824 let token = match self
1825 .hub
1826 .auth
1827 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1828 .await
1829 {
1830 Ok(token) => token,
1831 Err(e) => match dlg.token(e) {
1832 Ok(token) => token,
1833 Err(e) => {
1834 dlg.finished(false);
1835 return Err(common::Error::MissingToken(e));
1836 }
1837 },
1838 };
1839 request_value_reader
1840 .seek(std::io::SeekFrom::Start(0))
1841 .unwrap();
1842 let mut req_result = {
1843 let client = &self.hub.client;
1844 dlg.pre_request();
1845 let mut req_builder = hyper::Request::builder()
1846 .method(hyper::Method::POST)
1847 .uri(url.as_str())
1848 .header(USER_AGENT, self.hub._user_agent.clone());
1849
1850 if let Some(token) = token.as_ref() {
1851 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1852 }
1853
1854 let request = req_builder
1855 .header(CONTENT_TYPE, json_mime_type.to_string())
1856 .header(CONTENT_LENGTH, request_size as u64)
1857 .body(common::to_body(
1858 request_value_reader.get_ref().clone().into(),
1859 ));
1860
1861 client.request(request.unwrap()).await
1862 };
1863
1864 match req_result {
1865 Err(err) => {
1866 if let common::Retry::After(d) = dlg.http_error(&err) {
1867 sleep(d).await;
1868 continue;
1869 }
1870 dlg.finished(false);
1871 return Err(common::Error::HttpError(err));
1872 }
1873 Ok(res) => {
1874 let (mut parts, body) = res.into_parts();
1875 let mut body = common::Body::new(body);
1876 if !parts.status.is_success() {
1877 let bytes = common::to_bytes(body).await.unwrap_or_default();
1878 let error = serde_json::from_str(&common::to_string(&bytes));
1879 let response = common::to_response(parts, bytes.into());
1880
1881 if let common::Retry::After(d) =
1882 dlg.http_failure(&response, error.as_ref().ok())
1883 {
1884 sleep(d).await;
1885 continue;
1886 }
1887
1888 dlg.finished(false);
1889
1890 return Err(match error {
1891 Ok(value) => common::Error::BadRequest(value),
1892 _ => common::Error::Failure(response),
1893 });
1894 }
1895 let response = {
1896 let bytes = common::to_bytes(body).await.unwrap_or_default();
1897 let encoded = common::to_string(&bytes);
1898 match serde_json::from_str(&encoded) {
1899 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1900 Err(error) => {
1901 dlg.response_json_decode_error(&encoded, &error);
1902 return Err(common::Error::JsonDecodeError(
1903 encoded.to_string(),
1904 error,
1905 ));
1906 }
1907 }
1908 };
1909
1910 dlg.finished(true);
1911 return Ok(response);
1912 }
1913 }
1914 }
1915 }
1916
1917 ///
1918 /// Sets the *request* property to the given value.
1919 ///
1920 /// Even though the property as already been set when instantiating this call,
1921 /// we provide this method for API completeness.
1922 pub fn request(mut self, new_value: WriteLogEntriesRequest) -> EntryWriteCall<'a, C> {
1923 self._request = new_value;
1924 self
1925 }
1926 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1927 /// while executing the actual API request.
1928 ///
1929 /// ````text
1930 /// It should be used to handle progress information, and to implement a certain level of resilience.
1931 /// ````
1932 ///
1933 /// Sets the *delegate* property to the given value.
1934 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EntryWriteCall<'a, C> {
1935 self._delegate = Some(new_value);
1936 self
1937 }
1938
1939 /// Set any additional parameter of the query string used in the request.
1940 /// It should be used to set parameters which are not yet available through their own
1941 /// setters.
1942 ///
1943 /// Please note that this method must not be used to set any of the known parameters
1944 /// which have their own setter method. If done anyway, the request will fail.
1945 ///
1946 /// # Additional Parameters
1947 ///
1948 /// * *$.xgafv* (query-string) - V1 error format.
1949 /// * *access_token* (query-string) - OAuth access token.
1950 /// * *alt* (query-string) - Data format for response.
1951 /// * *callback* (query-string) - JSONP
1952 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1953 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1954 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1955 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1956 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1957 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1958 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1959 pub fn param<T>(mut self, name: T, value: T) -> EntryWriteCall<'a, C>
1960 where
1961 T: AsRef<str>,
1962 {
1963 self._additional_params
1964 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1965 self
1966 }
1967
1968 /// Identifies the authorization scope for the method you are building.
1969 ///
1970 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1971 /// [`Scope::CloudPlatform`].
1972 ///
1973 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1974 /// tokens for more than one scope.
1975 ///
1976 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1977 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1978 /// sufficient, a read-write scope will do as well.
1979 pub fn add_scope<St>(mut self, scope: St) -> EntryWriteCall<'a, C>
1980 where
1981 St: AsRef<str>,
1982 {
1983 self._scopes.insert(String::from(scope.as_ref()));
1984 self
1985 }
1986 /// Identifies the authorization scope(s) for the method you are building.
1987 ///
1988 /// See [`Self::add_scope()`] for details.
1989 pub fn add_scopes<I, St>(mut self, scopes: I) -> EntryWriteCall<'a, C>
1990 where
1991 I: IntoIterator<Item = St>,
1992 St: AsRef<str>,
1993 {
1994 self._scopes
1995 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1996 self
1997 }
1998
1999 /// Removes all scopes, and no default scope will be used either.
2000 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2001 /// for details).
2002 pub fn clear_scopes(mut self) -> EntryWriteCall<'a, C> {
2003 self._scopes.clear();
2004 self
2005 }
2006}
2007
2008/// Lists the descriptors for monitored resource types used by Logging.
2009///
2010/// A builder for the *list* method supported by a *monitoredResourceDescriptor* resource.
2011/// It is not used directly, but through a [`MonitoredResourceDescriptorMethods`] instance.
2012///
2013/// # Example
2014///
2015/// Instantiate a resource method builder
2016///
2017/// ```test_harness,no_run
2018/// # extern crate hyper;
2019/// # extern crate hyper_rustls;
2020/// # extern crate google_logging2_beta1 as logging2_beta1;
2021/// # async fn dox() {
2022/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2023///
2024/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2025/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2026/// # .with_native_roots()
2027/// # .unwrap()
2028/// # .https_only()
2029/// # .enable_http2()
2030/// # .build();
2031///
2032/// # let executor = hyper_util::rt::TokioExecutor::new();
2033/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2034/// # secret,
2035/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2036/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2037/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2038/// # ),
2039/// # ).build().await.unwrap();
2040///
2041/// # let client = hyper_util::client::legacy::Client::builder(
2042/// # hyper_util::rt::TokioExecutor::new()
2043/// # )
2044/// # .build(
2045/// # hyper_rustls::HttpsConnectorBuilder::new()
2046/// # .with_native_roots()
2047/// # .unwrap()
2048/// # .https_or_http()
2049/// # .enable_http2()
2050/// # .build()
2051/// # );
2052/// # let mut hub = Logging::new(client, auth);
2053/// // You can configure optional parameters by calling the respective setters at will, and
2054/// // execute the final call using `doit()`.
2055/// // Values shown here are possibly random and not representative !
2056/// let result = hub.monitored_resource_descriptors().list()
2057/// .page_token("ipsum")
2058/// .page_size(-28)
2059/// .doit().await;
2060/// # }
2061/// ```
2062pub struct MonitoredResourceDescriptorListCall<'a, C>
2063where
2064 C: 'a,
2065{
2066 hub: &'a Logging<C>,
2067 _page_token: Option<String>,
2068 _page_size: Option<i32>,
2069 _delegate: Option<&'a mut dyn common::Delegate>,
2070 _additional_params: HashMap<String, String>,
2071 _scopes: BTreeSet<String>,
2072}
2073
2074impl<'a, C> common::CallBuilder for MonitoredResourceDescriptorListCall<'a, C> {}
2075
2076impl<'a, C> MonitoredResourceDescriptorListCall<'a, C>
2077where
2078 C: common::Connector,
2079{
2080 /// Perform the operation you have build so far.
2081 pub async fn doit(
2082 mut self,
2083 ) -> common::Result<(common::Response, ListMonitoredResourceDescriptorsResponse)> {
2084 use std::borrow::Cow;
2085 use std::io::{Read, Seek};
2086
2087 use common::{url::Params, ToParts};
2088 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2089
2090 let mut dd = common::DefaultDelegate;
2091 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2092 dlg.begin(common::MethodInfo {
2093 id: "logging.monitoredResourceDescriptors.list",
2094 http_method: hyper::Method::GET,
2095 });
2096
2097 for &field in ["alt", "pageToken", "pageSize"].iter() {
2098 if self._additional_params.contains_key(field) {
2099 dlg.finished(false);
2100 return Err(common::Error::FieldClash(field));
2101 }
2102 }
2103
2104 let mut params = Params::with_capacity(4 + self._additional_params.len());
2105 if let Some(value) = self._page_token.as_ref() {
2106 params.push("pageToken", value);
2107 }
2108 if let Some(value) = self._page_size.as_ref() {
2109 params.push("pageSize", value.to_string());
2110 }
2111
2112 params.extend(self._additional_params.iter());
2113
2114 params.push("alt", "json");
2115 let mut url = self.hub._base_url.clone() + "v2beta1/monitoredResourceDescriptors";
2116 if self._scopes.is_empty() {
2117 self._scopes
2118 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
2119 }
2120
2121 let url = params.parse_with_url(&url);
2122
2123 loop {
2124 let token = match self
2125 .hub
2126 .auth
2127 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2128 .await
2129 {
2130 Ok(token) => token,
2131 Err(e) => match dlg.token(e) {
2132 Ok(token) => token,
2133 Err(e) => {
2134 dlg.finished(false);
2135 return Err(common::Error::MissingToken(e));
2136 }
2137 },
2138 };
2139 let mut req_result = {
2140 let client = &self.hub.client;
2141 dlg.pre_request();
2142 let mut req_builder = hyper::Request::builder()
2143 .method(hyper::Method::GET)
2144 .uri(url.as_str())
2145 .header(USER_AGENT, self.hub._user_agent.clone());
2146
2147 if let Some(token) = token.as_ref() {
2148 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2149 }
2150
2151 let request = req_builder
2152 .header(CONTENT_LENGTH, 0_u64)
2153 .body(common::to_body::<String>(None));
2154
2155 client.request(request.unwrap()).await
2156 };
2157
2158 match req_result {
2159 Err(err) => {
2160 if let common::Retry::After(d) = dlg.http_error(&err) {
2161 sleep(d).await;
2162 continue;
2163 }
2164 dlg.finished(false);
2165 return Err(common::Error::HttpError(err));
2166 }
2167 Ok(res) => {
2168 let (mut parts, body) = res.into_parts();
2169 let mut body = common::Body::new(body);
2170 if !parts.status.is_success() {
2171 let bytes = common::to_bytes(body).await.unwrap_or_default();
2172 let error = serde_json::from_str(&common::to_string(&bytes));
2173 let response = common::to_response(parts, bytes.into());
2174
2175 if let common::Retry::After(d) =
2176 dlg.http_failure(&response, error.as_ref().ok())
2177 {
2178 sleep(d).await;
2179 continue;
2180 }
2181
2182 dlg.finished(false);
2183
2184 return Err(match error {
2185 Ok(value) => common::Error::BadRequest(value),
2186 _ => common::Error::Failure(response),
2187 });
2188 }
2189 let response = {
2190 let bytes = common::to_bytes(body).await.unwrap_or_default();
2191 let encoded = common::to_string(&bytes);
2192 match serde_json::from_str(&encoded) {
2193 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2194 Err(error) => {
2195 dlg.response_json_decode_error(&encoded, &error);
2196 return Err(common::Error::JsonDecodeError(
2197 encoded.to_string(),
2198 error,
2199 ));
2200 }
2201 }
2202 };
2203
2204 dlg.finished(true);
2205 return Ok(response);
2206 }
2207 }
2208 }
2209 }
2210
2211 /// Optional. If present, then retrieve the next batch of results from the preceding call to this method. pageToken must be the value of nextPageToken from the previous response. The values of other method parameters should be identical to those in the previous call.
2212 ///
2213 /// Sets the *page token* query property to the given value.
2214 pub fn page_token(mut self, new_value: &str) -> MonitoredResourceDescriptorListCall<'a, C> {
2215 self._page_token = Some(new_value.to_string());
2216 self
2217 }
2218 /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. The presence of nextPageToken in the response indicates that more results might be available.
2219 ///
2220 /// Sets the *page size* query property to the given value.
2221 pub fn page_size(mut self, new_value: i32) -> MonitoredResourceDescriptorListCall<'a, C> {
2222 self._page_size = Some(new_value);
2223 self
2224 }
2225 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2226 /// while executing the actual API request.
2227 ///
2228 /// ````text
2229 /// It should be used to handle progress information, and to implement a certain level of resilience.
2230 /// ````
2231 ///
2232 /// Sets the *delegate* property to the given value.
2233 pub fn delegate(
2234 mut self,
2235 new_value: &'a mut dyn common::Delegate,
2236 ) -> MonitoredResourceDescriptorListCall<'a, C> {
2237 self._delegate = Some(new_value);
2238 self
2239 }
2240
2241 /// Set any additional parameter of the query string used in the request.
2242 /// It should be used to set parameters which are not yet available through their own
2243 /// setters.
2244 ///
2245 /// Please note that this method must not be used to set any of the known parameters
2246 /// which have their own setter method. If done anyway, the request will fail.
2247 ///
2248 /// # Additional Parameters
2249 ///
2250 /// * *$.xgafv* (query-string) - V1 error format.
2251 /// * *access_token* (query-string) - OAuth access token.
2252 /// * *alt* (query-string) - Data format for response.
2253 /// * *callback* (query-string) - JSONP
2254 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2255 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2256 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2257 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2258 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2259 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2260 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2261 pub fn param<T>(mut self, name: T, value: T) -> MonitoredResourceDescriptorListCall<'a, C>
2262 where
2263 T: AsRef<str>,
2264 {
2265 self._additional_params
2266 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2267 self
2268 }
2269
2270 /// Identifies the authorization scope for the method you are building.
2271 ///
2272 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2273 /// [`Scope::CloudPlatformReadOnly`].
2274 ///
2275 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2276 /// tokens for more than one scope.
2277 ///
2278 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2279 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2280 /// sufficient, a read-write scope will do as well.
2281 pub fn add_scope<St>(mut self, scope: St) -> MonitoredResourceDescriptorListCall<'a, C>
2282 where
2283 St: AsRef<str>,
2284 {
2285 self._scopes.insert(String::from(scope.as_ref()));
2286 self
2287 }
2288 /// Identifies the authorization scope(s) for the method you are building.
2289 ///
2290 /// See [`Self::add_scope()`] for details.
2291 pub fn add_scopes<I, St>(mut self, scopes: I) -> MonitoredResourceDescriptorListCall<'a, C>
2292 where
2293 I: IntoIterator<Item = St>,
2294 St: AsRef<str>,
2295 {
2296 self._scopes
2297 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2298 self
2299 }
2300
2301 /// Removes all scopes, and no default scope will be used either.
2302 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2303 /// for details).
2304 pub fn clear_scopes(mut self) -> MonitoredResourceDescriptorListCall<'a, C> {
2305 self._scopes.clear();
2306 self
2307 }
2308}
2309
2310/// Creates a logs-based metric.
2311///
2312/// A builder for the *metrics.create* method supported by a *project* resource.
2313/// It is not used directly, but through a [`ProjectMethods`] instance.
2314///
2315/// # Example
2316///
2317/// Instantiate a resource method builder
2318///
2319/// ```test_harness,no_run
2320/// # extern crate hyper;
2321/// # extern crate hyper_rustls;
2322/// # extern crate google_logging2_beta1 as logging2_beta1;
2323/// use logging2_beta1::api::LogMetric;
2324/// # async fn dox() {
2325/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2326///
2327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2328/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2329/// # .with_native_roots()
2330/// # .unwrap()
2331/// # .https_only()
2332/// # .enable_http2()
2333/// # .build();
2334///
2335/// # let executor = hyper_util::rt::TokioExecutor::new();
2336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2337/// # secret,
2338/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2339/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2340/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2341/// # ),
2342/// # ).build().await.unwrap();
2343///
2344/// # let client = hyper_util::client::legacy::Client::builder(
2345/// # hyper_util::rt::TokioExecutor::new()
2346/// # )
2347/// # .build(
2348/// # hyper_rustls::HttpsConnectorBuilder::new()
2349/// # .with_native_roots()
2350/// # .unwrap()
2351/// # .https_or_http()
2352/// # .enable_http2()
2353/// # .build()
2354/// # );
2355/// # let mut hub = Logging::new(client, auth);
2356/// // As the method needs a request, you would usually fill it with the desired information
2357/// // into the respective structure. Some of the parts shown here might not be applicable !
2358/// // Values shown here are possibly random and not representative !
2359/// let mut req = LogMetric::default();
2360///
2361/// // You can configure optional parameters by calling the respective setters at will, and
2362/// // execute the final call using `doit()`.
2363/// // Values shown here are possibly random and not representative !
2364/// let result = hub.projects().metrics_create(req, "parent")
2365/// .doit().await;
2366/// # }
2367/// ```
2368pub struct ProjectMetricCreateCall<'a, C>
2369where
2370 C: 'a,
2371{
2372 hub: &'a Logging<C>,
2373 _request: LogMetric,
2374 _parent: String,
2375 _delegate: Option<&'a mut dyn common::Delegate>,
2376 _additional_params: HashMap<String, String>,
2377 _scopes: BTreeSet<String>,
2378}
2379
2380impl<'a, C> common::CallBuilder for ProjectMetricCreateCall<'a, C> {}
2381
2382impl<'a, C> ProjectMetricCreateCall<'a, C>
2383where
2384 C: common::Connector,
2385{
2386 /// Perform the operation you have build so far.
2387 pub async fn doit(mut self) -> common::Result<(common::Response, LogMetric)> {
2388 use std::borrow::Cow;
2389 use std::io::{Read, Seek};
2390
2391 use common::{url::Params, ToParts};
2392 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2393
2394 let mut dd = common::DefaultDelegate;
2395 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2396 dlg.begin(common::MethodInfo {
2397 id: "logging.projects.metrics.create",
2398 http_method: hyper::Method::POST,
2399 });
2400
2401 for &field in ["alt", "parent"].iter() {
2402 if self._additional_params.contains_key(field) {
2403 dlg.finished(false);
2404 return Err(common::Error::FieldClash(field));
2405 }
2406 }
2407
2408 let mut params = Params::with_capacity(4 + self._additional_params.len());
2409 params.push("parent", self._parent);
2410
2411 params.extend(self._additional_params.iter());
2412
2413 params.push("alt", "json");
2414 let mut url = self.hub._base_url.clone() + "v2beta1/{+parent}/metrics";
2415 if self._scopes.is_empty() {
2416 self._scopes
2417 .insert(Scope::CloudPlatform.as_ref().to_string());
2418 }
2419
2420 #[allow(clippy::single_element_loop)]
2421 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2422 url = params.uri_replacement(url, param_name, find_this, true);
2423 }
2424 {
2425 let to_remove = ["parent"];
2426 params.remove_params(&to_remove);
2427 }
2428
2429 let url = params.parse_with_url(&url);
2430
2431 let mut json_mime_type = mime::APPLICATION_JSON;
2432 let mut request_value_reader = {
2433 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2434 common::remove_json_null_values(&mut value);
2435 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2436 serde_json::to_writer(&mut dst, &value).unwrap();
2437 dst
2438 };
2439 let request_size = request_value_reader
2440 .seek(std::io::SeekFrom::End(0))
2441 .unwrap();
2442 request_value_reader
2443 .seek(std::io::SeekFrom::Start(0))
2444 .unwrap();
2445
2446 loop {
2447 let token = match self
2448 .hub
2449 .auth
2450 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2451 .await
2452 {
2453 Ok(token) => token,
2454 Err(e) => match dlg.token(e) {
2455 Ok(token) => token,
2456 Err(e) => {
2457 dlg.finished(false);
2458 return Err(common::Error::MissingToken(e));
2459 }
2460 },
2461 };
2462 request_value_reader
2463 .seek(std::io::SeekFrom::Start(0))
2464 .unwrap();
2465 let mut req_result = {
2466 let client = &self.hub.client;
2467 dlg.pre_request();
2468 let mut req_builder = hyper::Request::builder()
2469 .method(hyper::Method::POST)
2470 .uri(url.as_str())
2471 .header(USER_AGENT, self.hub._user_agent.clone());
2472
2473 if let Some(token) = token.as_ref() {
2474 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2475 }
2476
2477 let request = req_builder
2478 .header(CONTENT_TYPE, json_mime_type.to_string())
2479 .header(CONTENT_LENGTH, request_size as u64)
2480 .body(common::to_body(
2481 request_value_reader.get_ref().clone().into(),
2482 ));
2483
2484 client.request(request.unwrap()).await
2485 };
2486
2487 match req_result {
2488 Err(err) => {
2489 if let common::Retry::After(d) = dlg.http_error(&err) {
2490 sleep(d).await;
2491 continue;
2492 }
2493 dlg.finished(false);
2494 return Err(common::Error::HttpError(err));
2495 }
2496 Ok(res) => {
2497 let (mut parts, body) = res.into_parts();
2498 let mut body = common::Body::new(body);
2499 if !parts.status.is_success() {
2500 let bytes = common::to_bytes(body).await.unwrap_or_default();
2501 let error = serde_json::from_str(&common::to_string(&bytes));
2502 let response = common::to_response(parts, bytes.into());
2503
2504 if let common::Retry::After(d) =
2505 dlg.http_failure(&response, error.as_ref().ok())
2506 {
2507 sleep(d).await;
2508 continue;
2509 }
2510
2511 dlg.finished(false);
2512
2513 return Err(match error {
2514 Ok(value) => common::Error::BadRequest(value),
2515 _ => common::Error::Failure(response),
2516 });
2517 }
2518 let response = {
2519 let bytes = common::to_bytes(body).await.unwrap_or_default();
2520 let encoded = common::to_string(&bytes);
2521 match serde_json::from_str(&encoded) {
2522 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2523 Err(error) => {
2524 dlg.response_json_decode_error(&encoded, &error);
2525 return Err(common::Error::JsonDecodeError(
2526 encoded.to_string(),
2527 error,
2528 ));
2529 }
2530 }
2531 };
2532
2533 dlg.finished(true);
2534 return Ok(response);
2535 }
2536 }
2537 }
2538 }
2539
2540 ///
2541 /// Sets the *request* property to the given value.
2542 ///
2543 /// Even though the property as already been set when instantiating this call,
2544 /// we provide this method for API completeness.
2545 pub fn request(mut self, new_value: LogMetric) -> ProjectMetricCreateCall<'a, C> {
2546 self._request = new_value;
2547 self
2548 }
2549 /// The resource name of the project in which to create the metric:
2550 /// "projects/[PROJECT_ID]"
2551 /// The new metric must be provided in the request.
2552 ///
2553 /// Sets the *parent* path property to the given value.
2554 ///
2555 /// Even though the property as already been set when instantiating this call,
2556 /// we provide this method for API completeness.
2557 pub fn parent(mut self, new_value: &str) -> ProjectMetricCreateCall<'a, C> {
2558 self._parent = new_value.to_string();
2559 self
2560 }
2561 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2562 /// while executing the actual API request.
2563 ///
2564 /// ````text
2565 /// It should be used to handle progress information, and to implement a certain level of resilience.
2566 /// ````
2567 ///
2568 /// Sets the *delegate* property to the given value.
2569 pub fn delegate(
2570 mut self,
2571 new_value: &'a mut dyn common::Delegate,
2572 ) -> ProjectMetricCreateCall<'a, C> {
2573 self._delegate = Some(new_value);
2574 self
2575 }
2576
2577 /// Set any additional parameter of the query string used in the request.
2578 /// It should be used to set parameters which are not yet available through their own
2579 /// setters.
2580 ///
2581 /// Please note that this method must not be used to set any of the known parameters
2582 /// which have their own setter method. If done anyway, the request will fail.
2583 ///
2584 /// # Additional Parameters
2585 ///
2586 /// * *$.xgafv* (query-string) - V1 error format.
2587 /// * *access_token* (query-string) - OAuth access token.
2588 /// * *alt* (query-string) - Data format for response.
2589 /// * *callback* (query-string) - JSONP
2590 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2591 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2592 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2593 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2594 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2595 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2596 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2597 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricCreateCall<'a, C>
2598 where
2599 T: AsRef<str>,
2600 {
2601 self._additional_params
2602 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2603 self
2604 }
2605
2606 /// Identifies the authorization scope for the method you are building.
2607 ///
2608 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2609 /// [`Scope::CloudPlatform`].
2610 ///
2611 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2612 /// tokens for more than one scope.
2613 ///
2614 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2615 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2616 /// sufficient, a read-write scope will do as well.
2617 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricCreateCall<'a, C>
2618 where
2619 St: AsRef<str>,
2620 {
2621 self._scopes.insert(String::from(scope.as_ref()));
2622 self
2623 }
2624 /// Identifies the authorization scope(s) for the method you are building.
2625 ///
2626 /// See [`Self::add_scope()`] for details.
2627 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricCreateCall<'a, C>
2628 where
2629 I: IntoIterator<Item = St>,
2630 St: AsRef<str>,
2631 {
2632 self._scopes
2633 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2634 self
2635 }
2636
2637 /// Removes all scopes, and no default scope will be used either.
2638 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2639 /// for details).
2640 pub fn clear_scopes(mut self) -> ProjectMetricCreateCall<'a, C> {
2641 self._scopes.clear();
2642 self
2643 }
2644}
2645
2646/// Deletes a logs-based metric.
2647///
2648/// A builder for the *metrics.delete* method supported by a *project* resource.
2649/// It is not used directly, but through a [`ProjectMethods`] instance.
2650///
2651/// # Example
2652///
2653/// Instantiate a resource method builder
2654///
2655/// ```test_harness,no_run
2656/// # extern crate hyper;
2657/// # extern crate hyper_rustls;
2658/// # extern crate google_logging2_beta1 as logging2_beta1;
2659/// # async fn dox() {
2660/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2661///
2662/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2663/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2664/// # .with_native_roots()
2665/// # .unwrap()
2666/// # .https_only()
2667/// # .enable_http2()
2668/// # .build();
2669///
2670/// # let executor = hyper_util::rt::TokioExecutor::new();
2671/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2672/// # secret,
2673/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2674/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2675/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2676/// # ),
2677/// # ).build().await.unwrap();
2678///
2679/// # let client = hyper_util::client::legacy::Client::builder(
2680/// # hyper_util::rt::TokioExecutor::new()
2681/// # )
2682/// # .build(
2683/// # hyper_rustls::HttpsConnectorBuilder::new()
2684/// # .with_native_roots()
2685/// # .unwrap()
2686/// # .https_or_http()
2687/// # .enable_http2()
2688/// # .build()
2689/// # );
2690/// # let mut hub = Logging::new(client, auth);
2691/// // You can configure optional parameters by calling the respective setters at will, and
2692/// // execute the final call using `doit()`.
2693/// // Values shown here are possibly random and not representative !
2694/// let result = hub.projects().metrics_delete("metricName")
2695/// .doit().await;
2696/// # }
2697/// ```
2698pub struct ProjectMetricDeleteCall<'a, C>
2699where
2700 C: 'a,
2701{
2702 hub: &'a Logging<C>,
2703 _metric_name: String,
2704 _delegate: Option<&'a mut dyn common::Delegate>,
2705 _additional_params: HashMap<String, String>,
2706 _scopes: BTreeSet<String>,
2707}
2708
2709impl<'a, C> common::CallBuilder for ProjectMetricDeleteCall<'a, C> {}
2710
2711impl<'a, C> ProjectMetricDeleteCall<'a, C>
2712where
2713 C: common::Connector,
2714{
2715 /// Perform the operation you have build so far.
2716 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2717 use std::borrow::Cow;
2718 use std::io::{Read, Seek};
2719
2720 use common::{url::Params, ToParts};
2721 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2722
2723 let mut dd = common::DefaultDelegate;
2724 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2725 dlg.begin(common::MethodInfo {
2726 id: "logging.projects.metrics.delete",
2727 http_method: hyper::Method::DELETE,
2728 });
2729
2730 for &field in ["alt", "metricName"].iter() {
2731 if self._additional_params.contains_key(field) {
2732 dlg.finished(false);
2733 return Err(common::Error::FieldClash(field));
2734 }
2735 }
2736
2737 let mut params = Params::with_capacity(3 + self._additional_params.len());
2738 params.push("metricName", self._metric_name);
2739
2740 params.extend(self._additional_params.iter());
2741
2742 params.push("alt", "json");
2743 let mut url = self.hub._base_url.clone() + "v2beta1/{+metricName}";
2744 if self._scopes.is_empty() {
2745 self._scopes
2746 .insert(Scope::CloudPlatform.as_ref().to_string());
2747 }
2748
2749 #[allow(clippy::single_element_loop)]
2750 for &(find_this, param_name) in [("{+metricName}", "metricName")].iter() {
2751 url = params.uri_replacement(url, param_name, find_this, true);
2752 }
2753 {
2754 let to_remove = ["metricName"];
2755 params.remove_params(&to_remove);
2756 }
2757
2758 let url = params.parse_with_url(&url);
2759
2760 loop {
2761 let token = match self
2762 .hub
2763 .auth
2764 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2765 .await
2766 {
2767 Ok(token) => token,
2768 Err(e) => match dlg.token(e) {
2769 Ok(token) => token,
2770 Err(e) => {
2771 dlg.finished(false);
2772 return Err(common::Error::MissingToken(e));
2773 }
2774 },
2775 };
2776 let mut req_result = {
2777 let client = &self.hub.client;
2778 dlg.pre_request();
2779 let mut req_builder = hyper::Request::builder()
2780 .method(hyper::Method::DELETE)
2781 .uri(url.as_str())
2782 .header(USER_AGENT, self.hub._user_agent.clone());
2783
2784 if let Some(token) = token.as_ref() {
2785 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2786 }
2787
2788 let request = req_builder
2789 .header(CONTENT_LENGTH, 0_u64)
2790 .body(common::to_body::<String>(None));
2791
2792 client.request(request.unwrap()).await
2793 };
2794
2795 match req_result {
2796 Err(err) => {
2797 if let common::Retry::After(d) = dlg.http_error(&err) {
2798 sleep(d).await;
2799 continue;
2800 }
2801 dlg.finished(false);
2802 return Err(common::Error::HttpError(err));
2803 }
2804 Ok(res) => {
2805 let (mut parts, body) = res.into_parts();
2806 let mut body = common::Body::new(body);
2807 if !parts.status.is_success() {
2808 let bytes = common::to_bytes(body).await.unwrap_or_default();
2809 let error = serde_json::from_str(&common::to_string(&bytes));
2810 let response = common::to_response(parts, bytes.into());
2811
2812 if let common::Retry::After(d) =
2813 dlg.http_failure(&response, error.as_ref().ok())
2814 {
2815 sleep(d).await;
2816 continue;
2817 }
2818
2819 dlg.finished(false);
2820
2821 return Err(match error {
2822 Ok(value) => common::Error::BadRequest(value),
2823 _ => common::Error::Failure(response),
2824 });
2825 }
2826 let response = {
2827 let bytes = common::to_bytes(body).await.unwrap_or_default();
2828 let encoded = common::to_string(&bytes);
2829 match serde_json::from_str(&encoded) {
2830 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2831 Err(error) => {
2832 dlg.response_json_decode_error(&encoded, &error);
2833 return Err(common::Error::JsonDecodeError(
2834 encoded.to_string(),
2835 error,
2836 ));
2837 }
2838 }
2839 };
2840
2841 dlg.finished(true);
2842 return Ok(response);
2843 }
2844 }
2845 }
2846 }
2847
2848 /// The resource name of the metric to delete:
2849 /// "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
2850 ///
2851 ///
2852 /// Sets the *metric name* path property to the given value.
2853 ///
2854 /// Even though the property as already been set when instantiating this call,
2855 /// we provide this method for API completeness.
2856 pub fn metric_name(mut self, new_value: &str) -> ProjectMetricDeleteCall<'a, C> {
2857 self._metric_name = new_value.to_string();
2858 self
2859 }
2860 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2861 /// while executing the actual API request.
2862 ///
2863 /// ````text
2864 /// It should be used to handle progress information, and to implement a certain level of resilience.
2865 /// ````
2866 ///
2867 /// Sets the *delegate* property to the given value.
2868 pub fn delegate(
2869 mut self,
2870 new_value: &'a mut dyn common::Delegate,
2871 ) -> ProjectMetricDeleteCall<'a, C> {
2872 self._delegate = Some(new_value);
2873 self
2874 }
2875
2876 /// Set any additional parameter of the query string used in the request.
2877 /// It should be used to set parameters which are not yet available through their own
2878 /// setters.
2879 ///
2880 /// Please note that this method must not be used to set any of the known parameters
2881 /// which have their own setter method. If done anyway, the request will fail.
2882 ///
2883 /// # Additional Parameters
2884 ///
2885 /// * *$.xgafv* (query-string) - V1 error format.
2886 /// * *access_token* (query-string) - OAuth access token.
2887 /// * *alt* (query-string) - Data format for response.
2888 /// * *callback* (query-string) - JSONP
2889 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2890 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2891 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2892 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2893 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2894 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2895 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2896 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricDeleteCall<'a, C>
2897 where
2898 T: AsRef<str>,
2899 {
2900 self._additional_params
2901 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2902 self
2903 }
2904
2905 /// Identifies the authorization scope for the method you are building.
2906 ///
2907 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2908 /// [`Scope::CloudPlatform`].
2909 ///
2910 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2911 /// tokens for more than one scope.
2912 ///
2913 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2914 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2915 /// sufficient, a read-write scope will do as well.
2916 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricDeleteCall<'a, C>
2917 where
2918 St: AsRef<str>,
2919 {
2920 self._scopes.insert(String::from(scope.as_ref()));
2921 self
2922 }
2923 /// Identifies the authorization scope(s) for the method you are building.
2924 ///
2925 /// See [`Self::add_scope()`] for details.
2926 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricDeleteCall<'a, C>
2927 where
2928 I: IntoIterator<Item = St>,
2929 St: AsRef<str>,
2930 {
2931 self._scopes
2932 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2933 self
2934 }
2935
2936 /// Removes all scopes, and no default scope will be used either.
2937 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2938 /// for details).
2939 pub fn clear_scopes(mut self) -> ProjectMetricDeleteCall<'a, C> {
2940 self._scopes.clear();
2941 self
2942 }
2943}
2944
2945/// Gets a logs-based metric.
2946///
2947/// A builder for the *metrics.get* method supported by a *project* resource.
2948/// It is not used directly, but through a [`ProjectMethods`] instance.
2949///
2950/// # Example
2951///
2952/// Instantiate a resource method builder
2953///
2954/// ```test_harness,no_run
2955/// # extern crate hyper;
2956/// # extern crate hyper_rustls;
2957/// # extern crate google_logging2_beta1 as logging2_beta1;
2958/// # async fn dox() {
2959/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2960///
2961/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2962/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2963/// # .with_native_roots()
2964/// # .unwrap()
2965/// # .https_only()
2966/// # .enable_http2()
2967/// # .build();
2968///
2969/// # let executor = hyper_util::rt::TokioExecutor::new();
2970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2971/// # secret,
2972/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2973/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2974/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2975/// # ),
2976/// # ).build().await.unwrap();
2977///
2978/// # let client = hyper_util::client::legacy::Client::builder(
2979/// # hyper_util::rt::TokioExecutor::new()
2980/// # )
2981/// # .build(
2982/// # hyper_rustls::HttpsConnectorBuilder::new()
2983/// # .with_native_roots()
2984/// # .unwrap()
2985/// # .https_or_http()
2986/// # .enable_http2()
2987/// # .build()
2988/// # );
2989/// # let mut hub = Logging::new(client, auth);
2990/// // You can configure optional parameters by calling the respective setters at will, and
2991/// // execute the final call using `doit()`.
2992/// // Values shown here are possibly random and not representative !
2993/// let result = hub.projects().metrics_get("metricName")
2994/// .doit().await;
2995/// # }
2996/// ```
2997pub struct ProjectMetricGetCall<'a, C>
2998where
2999 C: 'a,
3000{
3001 hub: &'a Logging<C>,
3002 _metric_name: String,
3003 _delegate: Option<&'a mut dyn common::Delegate>,
3004 _additional_params: HashMap<String, String>,
3005 _scopes: BTreeSet<String>,
3006}
3007
3008impl<'a, C> common::CallBuilder for ProjectMetricGetCall<'a, C> {}
3009
3010impl<'a, C> ProjectMetricGetCall<'a, C>
3011where
3012 C: common::Connector,
3013{
3014 /// Perform the operation you have build so far.
3015 pub async fn doit(mut self) -> common::Result<(common::Response, LogMetric)> {
3016 use std::borrow::Cow;
3017 use std::io::{Read, Seek};
3018
3019 use common::{url::Params, ToParts};
3020 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3021
3022 let mut dd = common::DefaultDelegate;
3023 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3024 dlg.begin(common::MethodInfo {
3025 id: "logging.projects.metrics.get",
3026 http_method: hyper::Method::GET,
3027 });
3028
3029 for &field in ["alt", "metricName"].iter() {
3030 if self._additional_params.contains_key(field) {
3031 dlg.finished(false);
3032 return Err(common::Error::FieldClash(field));
3033 }
3034 }
3035
3036 let mut params = Params::with_capacity(3 + self._additional_params.len());
3037 params.push("metricName", self._metric_name);
3038
3039 params.extend(self._additional_params.iter());
3040
3041 params.push("alt", "json");
3042 let mut url = self.hub._base_url.clone() + "v2beta1/{+metricName}";
3043 if self._scopes.is_empty() {
3044 self._scopes
3045 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
3046 }
3047
3048 #[allow(clippy::single_element_loop)]
3049 for &(find_this, param_name) in [("{+metricName}", "metricName")].iter() {
3050 url = params.uri_replacement(url, param_name, find_this, true);
3051 }
3052 {
3053 let to_remove = ["metricName"];
3054 params.remove_params(&to_remove);
3055 }
3056
3057 let url = params.parse_with_url(&url);
3058
3059 loop {
3060 let token = match self
3061 .hub
3062 .auth
3063 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3064 .await
3065 {
3066 Ok(token) => token,
3067 Err(e) => match dlg.token(e) {
3068 Ok(token) => token,
3069 Err(e) => {
3070 dlg.finished(false);
3071 return Err(common::Error::MissingToken(e));
3072 }
3073 },
3074 };
3075 let mut req_result = {
3076 let client = &self.hub.client;
3077 dlg.pre_request();
3078 let mut req_builder = hyper::Request::builder()
3079 .method(hyper::Method::GET)
3080 .uri(url.as_str())
3081 .header(USER_AGENT, self.hub._user_agent.clone());
3082
3083 if let Some(token) = token.as_ref() {
3084 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3085 }
3086
3087 let request = req_builder
3088 .header(CONTENT_LENGTH, 0_u64)
3089 .body(common::to_body::<String>(None));
3090
3091 client.request(request.unwrap()).await
3092 };
3093
3094 match req_result {
3095 Err(err) => {
3096 if let common::Retry::After(d) = dlg.http_error(&err) {
3097 sleep(d).await;
3098 continue;
3099 }
3100 dlg.finished(false);
3101 return Err(common::Error::HttpError(err));
3102 }
3103 Ok(res) => {
3104 let (mut parts, body) = res.into_parts();
3105 let mut body = common::Body::new(body);
3106 if !parts.status.is_success() {
3107 let bytes = common::to_bytes(body).await.unwrap_or_default();
3108 let error = serde_json::from_str(&common::to_string(&bytes));
3109 let response = common::to_response(parts, bytes.into());
3110
3111 if let common::Retry::After(d) =
3112 dlg.http_failure(&response, error.as_ref().ok())
3113 {
3114 sleep(d).await;
3115 continue;
3116 }
3117
3118 dlg.finished(false);
3119
3120 return Err(match error {
3121 Ok(value) => common::Error::BadRequest(value),
3122 _ => common::Error::Failure(response),
3123 });
3124 }
3125 let response = {
3126 let bytes = common::to_bytes(body).await.unwrap_or_default();
3127 let encoded = common::to_string(&bytes);
3128 match serde_json::from_str(&encoded) {
3129 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3130 Err(error) => {
3131 dlg.response_json_decode_error(&encoded, &error);
3132 return Err(common::Error::JsonDecodeError(
3133 encoded.to_string(),
3134 error,
3135 ));
3136 }
3137 }
3138 };
3139
3140 dlg.finished(true);
3141 return Ok(response);
3142 }
3143 }
3144 }
3145 }
3146
3147 /// The resource name of the desired metric:
3148 /// "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
3149 ///
3150 ///
3151 /// Sets the *metric name* path property to the given value.
3152 ///
3153 /// Even though the property as already been set when instantiating this call,
3154 /// we provide this method for API completeness.
3155 pub fn metric_name(mut self, new_value: &str) -> ProjectMetricGetCall<'a, C> {
3156 self._metric_name = new_value.to_string();
3157 self
3158 }
3159 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3160 /// while executing the actual API request.
3161 ///
3162 /// ````text
3163 /// It should be used to handle progress information, and to implement a certain level of resilience.
3164 /// ````
3165 ///
3166 /// Sets the *delegate* property to the given value.
3167 pub fn delegate(
3168 mut self,
3169 new_value: &'a mut dyn common::Delegate,
3170 ) -> ProjectMetricGetCall<'a, C> {
3171 self._delegate = Some(new_value);
3172 self
3173 }
3174
3175 /// Set any additional parameter of the query string used in the request.
3176 /// It should be used to set parameters which are not yet available through their own
3177 /// setters.
3178 ///
3179 /// Please note that this method must not be used to set any of the known parameters
3180 /// which have their own setter method. If done anyway, the request will fail.
3181 ///
3182 /// # Additional Parameters
3183 ///
3184 /// * *$.xgafv* (query-string) - V1 error format.
3185 /// * *access_token* (query-string) - OAuth access token.
3186 /// * *alt* (query-string) - Data format for response.
3187 /// * *callback* (query-string) - JSONP
3188 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3189 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3190 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3191 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3192 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3193 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3194 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3195 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricGetCall<'a, C>
3196 where
3197 T: AsRef<str>,
3198 {
3199 self._additional_params
3200 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3201 self
3202 }
3203
3204 /// Identifies the authorization scope for the method you are building.
3205 ///
3206 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3207 /// [`Scope::CloudPlatformReadOnly`].
3208 ///
3209 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3210 /// tokens for more than one scope.
3211 ///
3212 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3213 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3214 /// sufficient, a read-write scope will do as well.
3215 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricGetCall<'a, C>
3216 where
3217 St: AsRef<str>,
3218 {
3219 self._scopes.insert(String::from(scope.as_ref()));
3220 self
3221 }
3222 /// Identifies the authorization scope(s) for the method you are building.
3223 ///
3224 /// See [`Self::add_scope()`] for details.
3225 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricGetCall<'a, C>
3226 where
3227 I: IntoIterator<Item = St>,
3228 St: AsRef<str>,
3229 {
3230 self._scopes
3231 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3232 self
3233 }
3234
3235 /// Removes all scopes, and no default scope will be used either.
3236 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3237 /// for details).
3238 pub fn clear_scopes(mut self) -> ProjectMetricGetCall<'a, C> {
3239 self._scopes.clear();
3240 self
3241 }
3242}
3243
3244/// Lists logs-based metrics.
3245///
3246/// A builder for the *metrics.list* method supported by a *project* resource.
3247/// It is not used directly, but through a [`ProjectMethods`] instance.
3248///
3249/// # Example
3250///
3251/// Instantiate a resource method builder
3252///
3253/// ```test_harness,no_run
3254/// # extern crate hyper;
3255/// # extern crate hyper_rustls;
3256/// # extern crate google_logging2_beta1 as logging2_beta1;
3257/// # async fn dox() {
3258/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3259///
3260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3261/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3262/// # .with_native_roots()
3263/// # .unwrap()
3264/// # .https_only()
3265/// # .enable_http2()
3266/// # .build();
3267///
3268/// # let executor = hyper_util::rt::TokioExecutor::new();
3269/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3270/// # secret,
3271/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3272/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3273/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3274/// # ),
3275/// # ).build().await.unwrap();
3276///
3277/// # let client = hyper_util::client::legacy::Client::builder(
3278/// # hyper_util::rt::TokioExecutor::new()
3279/// # )
3280/// # .build(
3281/// # hyper_rustls::HttpsConnectorBuilder::new()
3282/// # .with_native_roots()
3283/// # .unwrap()
3284/// # .https_or_http()
3285/// # .enable_http2()
3286/// # .build()
3287/// # );
3288/// # let mut hub = Logging::new(client, auth);
3289/// // You can configure optional parameters by calling the respective setters at will, and
3290/// // execute the final call using `doit()`.
3291/// // Values shown here are possibly random and not representative !
3292/// let result = hub.projects().metrics_list("parent")
3293/// .page_token("takimata")
3294/// .page_size(-52)
3295/// .doit().await;
3296/// # }
3297/// ```
3298pub struct ProjectMetricListCall<'a, C>
3299where
3300 C: 'a,
3301{
3302 hub: &'a Logging<C>,
3303 _parent: String,
3304 _page_token: Option<String>,
3305 _page_size: Option<i32>,
3306 _delegate: Option<&'a mut dyn common::Delegate>,
3307 _additional_params: HashMap<String, String>,
3308 _scopes: BTreeSet<String>,
3309}
3310
3311impl<'a, C> common::CallBuilder for ProjectMetricListCall<'a, C> {}
3312
3313impl<'a, C> ProjectMetricListCall<'a, C>
3314where
3315 C: common::Connector,
3316{
3317 /// Perform the operation you have build so far.
3318 pub async fn doit(mut self) -> common::Result<(common::Response, ListLogMetricsResponse)> {
3319 use std::borrow::Cow;
3320 use std::io::{Read, Seek};
3321
3322 use common::{url::Params, ToParts};
3323 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3324
3325 let mut dd = common::DefaultDelegate;
3326 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3327 dlg.begin(common::MethodInfo {
3328 id: "logging.projects.metrics.list",
3329 http_method: hyper::Method::GET,
3330 });
3331
3332 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3333 if self._additional_params.contains_key(field) {
3334 dlg.finished(false);
3335 return Err(common::Error::FieldClash(field));
3336 }
3337 }
3338
3339 let mut params = Params::with_capacity(5 + self._additional_params.len());
3340 params.push("parent", self._parent);
3341 if let Some(value) = self._page_token.as_ref() {
3342 params.push("pageToken", value);
3343 }
3344 if let Some(value) = self._page_size.as_ref() {
3345 params.push("pageSize", value.to_string());
3346 }
3347
3348 params.extend(self._additional_params.iter());
3349
3350 params.push("alt", "json");
3351 let mut url = self.hub._base_url.clone() + "v2beta1/{+parent}/metrics";
3352 if self._scopes.is_empty() {
3353 self._scopes
3354 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
3355 }
3356
3357 #[allow(clippy::single_element_loop)]
3358 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3359 url = params.uri_replacement(url, param_name, find_this, true);
3360 }
3361 {
3362 let to_remove = ["parent"];
3363 params.remove_params(&to_remove);
3364 }
3365
3366 let url = params.parse_with_url(&url);
3367
3368 loop {
3369 let token = match self
3370 .hub
3371 .auth
3372 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3373 .await
3374 {
3375 Ok(token) => token,
3376 Err(e) => match dlg.token(e) {
3377 Ok(token) => token,
3378 Err(e) => {
3379 dlg.finished(false);
3380 return Err(common::Error::MissingToken(e));
3381 }
3382 },
3383 };
3384 let mut req_result = {
3385 let client = &self.hub.client;
3386 dlg.pre_request();
3387 let mut req_builder = hyper::Request::builder()
3388 .method(hyper::Method::GET)
3389 .uri(url.as_str())
3390 .header(USER_AGENT, self.hub._user_agent.clone());
3391
3392 if let Some(token) = token.as_ref() {
3393 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3394 }
3395
3396 let request = req_builder
3397 .header(CONTENT_LENGTH, 0_u64)
3398 .body(common::to_body::<String>(None));
3399
3400 client.request(request.unwrap()).await
3401 };
3402
3403 match req_result {
3404 Err(err) => {
3405 if let common::Retry::After(d) = dlg.http_error(&err) {
3406 sleep(d).await;
3407 continue;
3408 }
3409 dlg.finished(false);
3410 return Err(common::Error::HttpError(err));
3411 }
3412 Ok(res) => {
3413 let (mut parts, body) = res.into_parts();
3414 let mut body = common::Body::new(body);
3415 if !parts.status.is_success() {
3416 let bytes = common::to_bytes(body).await.unwrap_or_default();
3417 let error = serde_json::from_str(&common::to_string(&bytes));
3418 let response = common::to_response(parts, bytes.into());
3419
3420 if let common::Retry::After(d) =
3421 dlg.http_failure(&response, error.as_ref().ok())
3422 {
3423 sleep(d).await;
3424 continue;
3425 }
3426
3427 dlg.finished(false);
3428
3429 return Err(match error {
3430 Ok(value) => common::Error::BadRequest(value),
3431 _ => common::Error::Failure(response),
3432 });
3433 }
3434 let response = {
3435 let bytes = common::to_bytes(body).await.unwrap_or_default();
3436 let encoded = common::to_string(&bytes);
3437 match serde_json::from_str(&encoded) {
3438 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3439 Err(error) => {
3440 dlg.response_json_decode_error(&encoded, &error);
3441 return Err(common::Error::JsonDecodeError(
3442 encoded.to_string(),
3443 error,
3444 ));
3445 }
3446 }
3447 };
3448
3449 dlg.finished(true);
3450 return Ok(response);
3451 }
3452 }
3453 }
3454 }
3455
3456 /// Required. The name of the project containing the metrics:
3457 /// "projects/[PROJECT_ID]"
3458 ///
3459 ///
3460 /// Sets the *parent* path property to the given value.
3461 ///
3462 /// Even though the property as already been set when instantiating this call,
3463 /// we provide this method for API completeness.
3464 pub fn parent(mut self, new_value: &str) -> ProjectMetricListCall<'a, C> {
3465 self._parent = new_value.to_string();
3466 self
3467 }
3468 /// Optional. If present, then retrieve the next batch of results from the preceding call to this method. pageToken must be the value of nextPageToken from the previous response. The values of other method parameters should be identical to those in the previous call.
3469 ///
3470 /// Sets the *page token* query property to the given value.
3471 pub fn page_token(mut self, new_value: &str) -> ProjectMetricListCall<'a, C> {
3472 self._page_token = Some(new_value.to_string());
3473 self
3474 }
3475 /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. The presence of nextPageToken in the response indicates that more results might be available.
3476 ///
3477 /// Sets the *page size* query property to the given value.
3478 pub fn page_size(mut self, new_value: i32) -> ProjectMetricListCall<'a, C> {
3479 self._page_size = Some(new_value);
3480 self
3481 }
3482 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3483 /// while executing the actual API request.
3484 ///
3485 /// ````text
3486 /// It should be used to handle progress information, and to implement a certain level of resilience.
3487 /// ````
3488 ///
3489 /// Sets the *delegate* property to the given value.
3490 pub fn delegate(
3491 mut self,
3492 new_value: &'a mut dyn common::Delegate,
3493 ) -> ProjectMetricListCall<'a, C> {
3494 self._delegate = Some(new_value);
3495 self
3496 }
3497
3498 /// Set any additional parameter of the query string used in the request.
3499 /// It should be used to set parameters which are not yet available through their own
3500 /// setters.
3501 ///
3502 /// Please note that this method must not be used to set any of the known parameters
3503 /// which have their own setter method. If done anyway, the request will fail.
3504 ///
3505 /// # Additional Parameters
3506 ///
3507 /// * *$.xgafv* (query-string) - V1 error format.
3508 /// * *access_token* (query-string) - OAuth access token.
3509 /// * *alt* (query-string) - Data format for response.
3510 /// * *callback* (query-string) - JSONP
3511 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3512 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3513 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3514 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3515 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3516 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3517 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3518 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricListCall<'a, C>
3519 where
3520 T: AsRef<str>,
3521 {
3522 self._additional_params
3523 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3524 self
3525 }
3526
3527 /// Identifies the authorization scope for the method you are building.
3528 ///
3529 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3530 /// [`Scope::CloudPlatformReadOnly`].
3531 ///
3532 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3533 /// tokens for more than one scope.
3534 ///
3535 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3536 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3537 /// sufficient, a read-write scope will do as well.
3538 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricListCall<'a, C>
3539 where
3540 St: AsRef<str>,
3541 {
3542 self._scopes.insert(String::from(scope.as_ref()));
3543 self
3544 }
3545 /// Identifies the authorization scope(s) for the method you are building.
3546 ///
3547 /// See [`Self::add_scope()`] for details.
3548 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricListCall<'a, C>
3549 where
3550 I: IntoIterator<Item = St>,
3551 St: AsRef<str>,
3552 {
3553 self._scopes
3554 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3555 self
3556 }
3557
3558 /// Removes all scopes, and no default scope will be used either.
3559 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3560 /// for details).
3561 pub fn clear_scopes(mut self) -> ProjectMetricListCall<'a, C> {
3562 self._scopes.clear();
3563 self
3564 }
3565}
3566
3567/// Creates or updates a logs-based metric.
3568///
3569/// A builder for the *metrics.update* method supported by a *project* resource.
3570/// It is not used directly, but through a [`ProjectMethods`] instance.
3571///
3572/// # Example
3573///
3574/// Instantiate a resource method builder
3575///
3576/// ```test_harness,no_run
3577/// # extern crate hyper;
3578/// # extern crate hyper_rustls;
3579/// # extern crate google_logging2_beta1 as logging2_beta1;
3580/// use logging2_beta1::api::LogMetric;
3581/// # async fn dox() {
3582/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3583///
3584/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3585/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3586/// # .with_native_roots()
3587/// # .unwrap()
3588/// # .https_only()
3589/// # .enable_http2()
3590/// # .build();
3591///
3592/// # let executor = hyper_util::rt::TokioExecutor::new();
3593/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3594/// # secret,
3595/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3596/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3597/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3598/// # ),
3599/// # ).build().await.unwrap();
3600///
3601/// # let client = hyper_util::client::legacy::Client::builder(
3602/// # hyper_util::rt::TokioExecutor::new()
3603/// # )
3604/// # .build(
3605/// # hyper_rustls::HttpsConnectorBuilder::new()
3606/// # .with_native_roots()
3607/// # .unwrap()
3608/// # .https_or_http()
3609/// # .enable_http2()
3610/// # .build()
3611/// # );
3612/// # let mut hub = Logging::new(client, auth);
3613/// // As the method needs a request, you would usually fill it with the desired information
3614/// // into the respective structure. Some of the parts shown here might not be applicable !
3615/// // Values shown here are possibly random and not representative !
3616/// let mut req = LogMetric::default();
3617///
3618/// // You can configure optional parameters by calling the respective setters at will, and
3619/// // execute the final call using `doit()`.
3620/// // Values shown here are possibly random and not representative !
3621/// let result = hub.projects().metrics_update(req, "metricName")
3622/// .doit().await;
3623/// # }
3624/// ```
3625pub struct ProjectMetricUpdateCall<'a, C>
3626where
3627 C: 'a,
3628{
3629 hub: &'a Logging<C>,
3630 _request: LogMetric,
3631 _metric_name: String,
3632 _delegate: Option<&'a mut dyn common::Delegate>,
3633 _additional_params: HashMap<String, String>,
3634 _scopes: BTreeSet<String>,
3635}
3636
3637impl<'a, C> common::CallBuilder for ProjectMetricUpdateCall<'a, C> {}
3638
3639impl<'a, C> ProjectMetricUpdateCall<'a, C>
3640where
3641 C: common::Connector,
3642{
3643 /// Perform the operation you have build so far.
3644 pub async fn doit(mut self) -> common::Result<(common::Response, LogMetric)> {
3645 use std::borrow::Cow;
3646 use std::io::{Read, Seek};
3647
3648 use common::{url::Params, ToParts};
3649 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3650
3651 let mut dd = common::DefaultDelegate;
3652 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3653 dlg.begin(common::MethodInfo {
3654 id: "logging.projects.metrics.update",
3655 http_method: hyper::Method::PUT,
3656 });
3657
3658 for &field in ["alt", "metricName"].iter() {
3659 if self._additional_params.contains_key(field) {
3660 dlg.finished(false);
3661 return Err(common::Error::FieldClash(field));
3662 }
3663 }
3664
3665 let mut params = Params::with_capacity(4 + self._additional_params.len());
3666 params.push("metricName", self._metric_name);
3667
3668 params.extend(self._additional_params.iter());
3669
3670 params.push("alt", "json");
3671 let mut url = self.hub._base_url.clone() + "v2beta1/{+metricName}";
3672 if self._scopes.is_empty() {
3673 self._scopes
3674 .insert(Scope::CloudPlatform.as_ref().to_string());
3675 }
3676
3677 #[allow(clippy::single_element_loop)]
3678 for &(find_this, param_name) in [("{+metricName}", "metricName")].iter() {
3679 url = params.uri_replacement(url, param_name, find_this, true);
3680 }
3681 {
3682 let to_remove = ["metricName"];
3683 params.remove_params(&to_remove);
3684 }
3685
3686 let url = params.parse_with_url(&url);
3687
3688 let mut json_mime_type = mime::APPLICATION_JSON;
3689 let mut request_value_reader = {
3690 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3691 common::remove_json_null_values(&mut value);
3692 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3693 serde_json::to_writer(&mut dst, &value).unwrap();
3694 dst
3695 };
3696 let request_size = request_value_reader
3697 .seek(std::io::SeekFrom::End(0))
3698 .unwrap();
3699 request_value_reader
3700 .seek(std::io::SeekFrom::Start(0))
3701 .unwrap();
3702
3703 loop {
3704 let token = match self
3705 .hub
3706 .auth
3707 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3708 .await
3709 {
3710 Ok(token) => token,
3711 Err(e) => match dlg.token(e) {
3712 Ok(token) => token,
3713 Err(e) => {
3714 dlg.finished(false);
3715 return Err(common::Error::MissingToken(e));
3716 }
3717 },
3718 };
3719 request_value_reader
3720 .seek(std::io::SeekFrom::Start(0))
3721 .unwrap();
3722 let mut req_result = {
3723 let client = &self.hub.client;
3724 dlg.pre_request();
3725 let mut req_builder = hyper::Request::builder()
3726 .method(hyper::Method::PUT)
3727 .uri(url.as_str())
3728 .header(USER_AGENT, self.hub._user_agent.clone());
3729
3730 if let Some(token) = token.as_ref() {
3731 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3732 }
3733
3734 let request = req_builder
3735 .header(CONTENT_TYPE, json_mime_type.to_string())
3736 .header(CONTENT_LENGTH, request_size as u64)
3737 .body(common::to_body(
3738 request_value_reader.get_ref().clone().into(),
3739 ));
3740
3741 client.request(request.unwrap()).await
3742 };
3743
3744 match req_result {
3745 Err(err) => {
3746 if let common::Retry::After(d) = dlg.http_error(&err) {
3747 sleep(d).await;
3748 continue;
3749 }
3750 dlg.finished(false);
3751 return Err(common::Error::HttpError(err));
3752 }
3753 Ok(res) => {
3754 let (mut parts, body) = res.into_parts();
3755 let mut body = common::Body::new(body);
3756 if !parts.status.is_success() {
3757 let bytes = common::to_bytes(body).await.unwrap_or_default();
3758 let error = serde_json::from_str(&common::to_string(&bytes));
3759 let response = common::to_response(parts, bytes.into());
3760
3761 if let common::Retry::After(d) =
3762 dlg.http_failure(&response, error.as_ref().ok())
3763 {
3764 sleep(d).await;
3765 continue;
3766 }
3767
3768 dlg.finished(false);
3769
3770 return Err(match error {
3771 Ok(value) => common::Error::BadRequest(value),
3772 _ => common::Error::Failure(response),
3773 });
3774 }
3775 let response = {
3776 let bytes = common::to_bytes(body).await.unwrap_or_default();
3777 let encoded = common::to_string(&bytes);
3778 match serde_json::from_str(&encoded) {
3779 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3780 Err(error) => {
3781 dlg.response_json_decode_error(&encoded, &error);
3782 return Err(common::Error::JsonDecodeError(
3783 encoded.to_string(),
3784 error,
3785 ));
3786 }
3787 }
3788 };
3789
3790 dlg.finished(true);
3791 return Ok(response);
3792 }
3793 }
3794 }
3795 }
3796
3797 ///
3798 /// Sets the *request* property to the given value.
3799 ///
3800 /// Even though the property as already been set when instantiating this call,
3801 /// we provide this method for API completeness.
3802 pub fn request(mut self, new_value: LogMetric) -> ProjectMetricUpdateCall<'a, C> {
3803 self._request = new_value;
3804 self
3805 }
3806 /// The resource name of the metric to update:
3807 /// "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
3808 /// The updated metric must be provided in the request and it's name field must be the same as [METRIC_ID] If the metric does not exist in [PROJECT_ID], then a new metric is created.
3809 ///
3810 /// Sets the *metric name* path property to the given value.
3811 ///
3812 /// Even though the property as already been set when instantiating this call,
3813 /// we provide this method for API completeness.
3814 pub fn metric_name(mut self, new_value: &str) -> ProjectMetricUpdateCall<'a, C> {
3815 self._metric_name = new_value.to_string();
3816 self
3817 }
3818 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3819 /// while executing the actual API request.
3820 ///
3821 /// ````text
3822 /// It should be used to handle progress information, and to implement a certain level of resilience.
3823 /// ````
3824 ///
3825 /// Sets the *delegate* property to the given value.
3826 pub fn delegate(
3827 mut self,
3828 new_value: &'a mut dyn common::Delegate,
3829 ) -> ProjectMetricUpdateCall<'a, C> {
3830 self._delegate = Some(new_value);
3831 self
3832 }
3833
3834 /// Set any additional parameter of the query string used in the request.
3835 /// It should be used to set parameters which are not yet available through their own
3836 /// setters.
3837 ///
3838 /// Please note that this method must not be used to set any of the known parameters
3839 /// which have their own setter method. If done anyway, the request will fail.
3840 ///
3841 /// # Additional Parameters
3842 ///
3843 /// * *$.xgafv* (query-string) - V1 error format.
3844 /// * *access_token* (query-string) - OAuth access token.
3845 /// * *alt* (query-string) - Data format for response.
3846 /// * *callback* (query-string) - JSONP
3847 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3848 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3849 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3850 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3851 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3852 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3853 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3854 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricUpdateCall<'a, C>
3855 where
3856 T: AsRef<str>,
3857 {
3858 self._additional_params
3859 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3860 self
3861 }
3862
3863 /// Identifies the authorization scope for the method you are building.
3864 ///
3865 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3866 /// [`Scope::CloudPlatform`].
3867 ///
3868 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3869 /// tokens for more than one scope.
3870 ///
3871 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3872 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3873 /// sufficient, a read-write scope will do as well.
3874 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricUpdateCall<'a, C>
3875 where
3876 St: AsRef<str>,
3877 {
3878 self._scopes.insert(String::from(scope.as_ref()));
3879 self
3880 }
3881 /// Identifies the authorization scope(s) for the method you are building.
3882 ///
3883 /// See [`Self::add_scope()`] for details.
3884 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricUpdateCall<'a, C>
3885 where
3886 I: IntoIterator<Item = St>,
3887 St: AsRef<str>,
3888 {
3889 self._scopes
3890 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3891 self
3892 }
3893
3894 /// Removes all scopes, and no default scope will be used either.
3895 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3896 /// for details).
3897 pub fn clear_scopes(mut self) -> ProjectMetricUpdateCall<'a, C> {
3898 self._scopes.clear();
3899 self
3900 }
3901}
3902
3903/// Creates a sink that exports specified log entries to a destination. The export of newly-ingested log entries begins immediately, unless the sink's writer_identity is not permitted to write to the destination. A sink can export log entries only from the resource owning the sink.
3904///
3905/// A builder for the *sinks.create* method supported by a *project* resource.
3906/// It is not used directly, but through a [`ProjectMethods`] instance.
3907///
3908/// # Example
3909///
3910/// Instantiate a resource method builder
3911///
3912/// ```test_harness,no_run
3913/// # extern crate hyper;
3914/// # extern crate hyper_rustls;
3915/// # extern crate google_logging2_beta1 as logging2_beta1;
3916/// use logging2_beta1::api::LogSink;
3917/// # async fn dox() {
3918/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3919///
3920/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3921/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3922/// # .with_native_roots()
3923/// # .unwrap()
3924/// # .https_only()
3925/// # .enable_http2()
3926/// # .build();
3927///
3928/// # let executor = hyper_util::rt::TokioExecutor::new();
3929/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3930/// # secret,
3931/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3932/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3933/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3934/// # ),
3935/// # ).build().await.unwrap();
3936///
3937/// # let client = hyper_util::client::legacy::Client::builder(
3938/// # hyper_util::rt::TokioExecutor::new()
3939/// # )
3940/// # .build(
3941/// # hyper_rustls::HttpsConnectorBuilder::new()
3942/// # .with_native_roots()
3943/// # .unwrap()
3944/// # .https_or_http()
3945/// # .enable_http2()
3946/// # .build()
3947/// # );
3948/// # let mut hub = Logging::new(client, auth);
3949/// // As the method needs a request, you would usually fill it with the desired information
3950/// // into the respective structure. Some of the parts shown here might not be applicable !
3951/// // Values shown here are possibly random and not representative !
3952/// let mut req = LogSink::default();
3953///
3954/// // You can configure optional parameters by calling the respective setters at will, and
3955/// // execute the final call using `doit()`.
3956/// // Values shown here are possibly random and not representative !
3957/// let result = hub.projects().sinks_create(req, "parent")
3958/// .unique_writer_identity(true)
3959/// .doit().await;
3960/// # }
3961/// ```
3962pub struct ProjectSinkCreateCall<'a, C>
3963where
3964 C: 'a,
3965{
3966 hub: &'a Logging<C>,
3967 _request: LogSink,
3968 _parent: String,
3969 _unique_writer_identity: Option<bool>,
3970 _delegate: Option<&'a mut dyn common::Delegate>,
3971 _additional_params: HashMap<String, String>,
3972 _scopes: BTreeSet<String>,
3973}
3974
3975impl<'a, C> common::CallBuilder for ProjectSinkCreateCall<'a, C> {}
3976
3977impl<'a, C> ProjectSinkCreateCall<'a, C>
3978where
3979 C: common::Connector,
3980{
3981 /// Perform the operation you have build so far.
3982 pub async fn doit(mut self) -> common::Result<(common::Response, LogSink)> {
3983 use std::borrow::Cow;
3984 use std::io::{Read, Seek};
3985
3986 use common::{url::Params, ToParts};
3987 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3988
3989 let mut dd = common::DefaultDelegate;
3990 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3991 dlg.begin(common::MethodInfo {
3992 id: "logging.projects.sinks.create",
3993 http_method: hyper::Method::POST,
3994 });
3995
3996 for &field in ["alt", "parent", "uniqueWriterIdentity"].iter() {
3997 if self._additional_params.contains_key(field) {
3998 dlg.finished(false);
3999 return Err(common::Error::FieldClash(field));
4000 }
4001 }
4002
4003 let mut params = Params::with_capacity(5 + self._additional_params.len());
4004 params.push("parent", self._parent);
4005 if let Some(value) = self._unique_writer_identity.as_ref() {
4006 params.push("uniqueWriterIdentity", value.to_string());
4007 }
4008
4009 params.extend(self._additional_params.iter());
4010
4011 params.push("alt", "json");
4012 let mut url = self.hub._base_url.clone() + "v2beta1/{+parent}/sinks";
4013 if self._scopes.is_empty() {
4014 self._scopes
4015 .insert(Scope::CloudPlatform.as_ref().to_string());
4016 }
4017
4018 #[allow(clippy::single_element_loop)]
4019 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4020 url = params.uri_replacement(url, param_name, find_this, true);
4021 }
4022 {
4023 let to_remove = ["parent"];
4024 params.remove_params(&to_remove);
4025 }
4026
4027 let url = params.parse_with_url(&url);
4028
4029 let mut json_mime_type = mime::APPLICATION_JSON;
4030 let mut request_value_reader = {
4031 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4032 common::remove_json_null_values(&mut value);
4033 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4034 serde_json::to_writer(&mut dst, &value).unwrap();
4035 dst
4036 };
4037 let request_size = request_value_reader
4038 .seek(std::io::SeekFrom::End(0))
4039 .unwrap();
4040 request_value_reader
4041 .seek(std::io::SeekFrom::Start(0))
4042 .unwrap();
4043
4044 loop {
4045 let token = match self
4046 .hub
4047 .auth
4048 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4049 .await
4050 {
4051 Ok(token) => token,
4052 Err(e) => match dlg.token(e) {
4053 Ok(token) => token,
4054 Err(e) => {
4055 dlg.finished(false);
4056 return Err(common::Error::MissingToken(e));
4057 }
4058 },
4059 };
4060 request_value_reader
4061 .seek(std::io::SeekFrom::Start(0))
4062 .unwrap();
4063 let mut req_result = {
4064 let client = &self.hub.client;
4065 dlg.pre_request();
4066 let mut req_builder = hyper::Request::builder()
4067 .method(hyper::Method::POST)
4068 .uri(url.as_str())
4069 .header(USER_AGENT, self.hub._user_agent.clone());
4070
4071 if let Some(token) = token.as_ref() {
4072 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4073 }
4074
4075 let request = req_builder
4076 .header(CONTENT_TYPE, json_mime_type.to_string())
4077 .header(CONTENT_LENGTH, request_size as u64)
4078 .body(common::to_body(
4079 request_value_reader.get_ref().clone().into(),
4080 ));
4081
4082 client.request(request.unwrap()).await
4083 };
4084
4085 match req_result {
4086 Err(err) => {
4087 if let common::Retry::After(d) = dlg.http_error(&err) {
4088 sleep(d).await;
4089 continue;
4090 }
4091 dlg.finished(false);
4092 return Err(common::Error::HttpError(err));
4093 }
4094 Ok(res) => {
4095 let (mut parts, body) = res.into_parts();
4096 let mut body = common::Body::new(body);
4097 if !parts.status.is_success() {
4098 let bytes = common::to_bytes(body).await.unwrap_or_default();
4099 let error = serde_json::from_str(&common::to_string(&bytes));
4100 let response = common::to_response(parts, bytes.into());
4101
4102 if let common::Retry::After(d) =
4103 dlg.http_failure(&response, error.as_ref().ok())
4104 {
4105 sleep(d).await;
4106 continue;
4107 }
4108
4109 dlg.finished(false);
4110
4111 return Err(match error {
4112 Ok(value) => common::Error::BadRequest(value),
4113 _ => common::Error::Failure(response),
4114 });
4115 }
4116 let response = {
4117 let bytes = common::to_bytes(body).await.unwrap_or_default();
4118 let encoded = common::to_string(&bytes);
4119 match serde_json::from_str(&encoded) {
4120 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4121 Err(error) => {
4122 dlg.response_json_decode_error(&encoded, &error);
4123 return Err(common::Error::JsonDecodeError(
4124 encoded.to_string(),
4125 error,
4126 ));
4127 }
4128 }
4129 };
4130
4131 dlg.finished(true);
4132 return Ok(response);
4133 }
4134 }
4135 }
4136 }
4137
4138 ///
4139 /// Sets the *request* property to the given value.
4140 ///
4141 /// Even though the property as already been set when instantiating this call,
4142 /// we provide this method for API completeness.
4143 pub fn request(mut self, new_value: LogSink) -> ProjectSinkCreateCall<'a, C> {
4144 self._request = new_value;
4145 self
4146 }
4147 /// Required. The resource in which to create the sink:
4148 /// "projects/[PROJECT_ID]"
4149 /// "organizations/[ORGANIZATION_ID]"
4150 /// "billingAccounts/[BILLING_ACCOUNT_ID]"
4151 /// "folders/[FOLDER_ID]"
4152 /// Examples: "projects/my-logging-project", "organizations/123456789".
4153 ///
4154 /// Sets the *parent* path property to the given value.
4155 ///
4156 /// Even though the property as already been set when instantiating this call,
4157 /// we provide this method for API completeness.
4158 pub fn parent(mut self, new_value: &str) -> ProjectSinkCreateCall<'a, C> {
4159 self._parent = new_value.to_string();
4160 self
4161 }
4162 /// Optional. Determines the kind of IAM identity returned as writer_identity in the new sink. If this value is omitted or set to false, and if the sink's parent is a project, then the value returned as writer_identity is the same group or service account used by Logging before the addition of writer identities to this API. The sink's destination must be in the same project as the sink itself.If this field is set to true, or if the sink is owned by a non-project resource such as an organization, then the value of writer_identity will be a unique service account used only for exports from the new sink. For more information, see writer_identity in LogSink.
4163 ///
4164 /// Sets the *unique writer identity* query property to the given value.
4165 pub fn unique_writer_identity(mut self, new_value: bool) -> ProjectSinkCreateCall<'a, C> {
4166 self._unique_writer_identity = Some(new_value);
4167 self
4168 }
4169 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4170 /// while executing the actual API request.
4171 ///
4172 /// ````text
4173 /// It should be used to handle progress information, and to implement a certain level of resilience.
4174 /// ````
4175 ///
4176 /// Sets the *delegate* property to the given value.
4177 pub fn delegate(
4178 mut self,
4179 new_value: &'a mut dyn common::Delegate,
4180 ) -> ProjectSinkCreateCall<'a, C> {
4181 self._delegate = Some(new_value);
4182 self
4183 }
4184
4185 /// Set any additional parameter of the query string used in the request.
4186 /// It should be used to set parameters which are not yet available through their own
4187 /// setters.
4188 ///
4189 /// Please note that this method must not be used to set any of the known parameters
4190 /// which have their own setter method. If done anyway, the request will fail.
4191 ///
4192 /// # Additional Parameters
4193 ///
4194 /// * *$.xgafv* (query-string) - V1 error format.
4195 /// * *access_token* (query-string) - OAuth access token.
4196 /// * *alt* (query-string) - Data format for response.
4197 /// * *callback* (query-string) - JSONP
4198 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4199 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4200 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4201 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4202 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4203 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4204 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4205 pub fn param<T>(mut self, name: T, value: T) -> ProjectSinkCreateCall<'a, C>
4206 where
4207 T: AsRef<str>,
4208 {
4209 self._additional_params
4210 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4211 self
4212 }
4213
4214 /// Identifies the authorization scope for the method you are building.
4215 ///
4216 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4217 /// [`Scope::CloudPlatform`].
4218 ///
4219 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4220 /// tokens for more than one scope.
4221 ///
4222 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4223 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4224 /// sufficient, a read-write scope will do as well.
4225 pub fn add_scope<St>(mut self, scope: St) -> ProjectSinkCreateCall<'a, C>
4226 where
4227 St: AsRef<str>,
4228 {
4229 self._scopes.insert(String::from(scope.as_ref()));
4230 self
4231 }
4232 /// Identifies the authorization scope(s) for the method you are building.
4233 ///
4234 /// See [`Self::add_scope()`] for details.
4235 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSinkCreateCall<'a, C>
4236 where
4237 I: IntoIterator<Item = St>,
4238 St: AsRef<str>,
4239 {
4240 self._scopes
4241 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4242 self
4243 }
4244
4245 /// Removes all scopes, and no default scope will be used either.
4246 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4247 /// for details).
4248 pub fn clear_scopes(mut self) -> ProjectSinkCreateCall<'a, C> {
4249 self._scopes.clear();
4250 self
4251 }
4252}
4253
4254/// Deletes a sink. If the sink has a unique writer_identity, then that service account is also deleted.
4255///
4256/// A builder for the *sinks.delete* method supported by a *project* resource.
4257/// It is not used directly, but through a [`ProjectMethods`] instance.
4258///
4259/// # Example
4260///
4261/// Instantiate a resource method builder
4262///
4263/// ```test_harness,no_run
4264/// # extern crate hyper;
4265/// # extern crate hyper_rustls;
4266/// # extern crate google_logging2_beta1 as logging2_beta1;
4267/// # async fn dox() {
4268/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4269///
4270/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4271/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4272/// # .with_native_roots()
4273/// # .unwrap()
4274/// # .https_only()
4275/// # .enable_http2()
4276/// # .build();
4277///
4278/// # let executor = hyper_util::rt::TokioExecutor::new();
4279/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4280/// # secret,
4281/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4282/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4283/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4284/// # ),
4285/// # ).build().await.unwrap();
4286///
4287/// # let client = hyper_util::client::legacy::Client::builder(
4288/// # hyper_util::rt::TokioExecutor::new()
4289/// # )
4290/// # .build(
4291/// # hyper_rustls::HttpsConnectorBuilder::new()
4292/// # .with_native_roots()
4293/// # .unwrap()
4294/// # .https_or_http()
4295/// # .enable_http2()
4296/// # .build()
4297/// # );
4298/// # let mut hub = Logging::new(client, auth);
4299/// // You can configure optional parameters by calling the respective setters at will, and
4300/// // execute the final call using `doit()`.
4301/// // Values shown here are possibly random and not representative !
4302/// let result = hub.projects().sinks_delete("sinkName")
4303/// .doit().await;
4304/// # }
4305/// ```
4306pub struct ProjectSinkDeleteCall<'a, C>
4307where
4308 C: 'a,
4309{
4310 hub: &'a Logging<C>,
4311 _sink_name: String,
4312 _delegate: Option<&'a mut dyn common::Delegate>,
4313 _additional_params: HashMap<String, String>,
4314 _scopes: BTreeSet<String>,
4315}
4316
4317impl<'a, C> common::CallBuilder for ProjectSinkDeleteCall<'a, C> {}
4318
4319impl<'a, C> ProjectSinkDeleteCall<'a, C>
4320where
4321 C: common::Connector,
4322{
4323 /// Perform the operation you have build so far.
4324 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4325 use std::borrow::Cow;
4326 use std::io::{Read, Seek};
4327
4328 use common::{url::Params, ToParts};
4329 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4330
4331 let mut dd = common::DefaultDelegate;
4332 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4333 dlg.begin(common::MethodInfo {
4334 id: "logging.projects.sinks.delete",
4335 http_method: hyper::Method::DELETE,
4336 });
4337
4338 for &field in ["alt", "sinkName"].iter() {
4339 if self._additional_params.contains_key(field) {
4340 dlg.finished(false);
4341 return Err(common::Error::FieldClash(field));
4342 }
4343 }
4344
4345 let mut params = Params::with_capacity(3 + self._additional_params.len());
4346 params.push("sinkName", self._sink_name);
4347
4348 params.extend(self._additional_params.iter());
4349
4350 params.push("alt", "json");
4351 let mut url = self.hub._base_url.clone() + "v2beta1/{+sinkName}";
4352 if self._scopes.is_empty() {
4353 self._scopes
4354 .insert(Scope::CloudPlatform.as_ref().to_string());
4355 }
4356
4357 #[allow(clippy::single_element_loop)]
4358 for &(find_this, param_name) in [("{+sinkName}", "sinkName")].iter() {
4359 url = params.uri_replacement(url, param_name, find_this, true);
4360 }
4361 {
4362 let to_remove = ["sinkName"];
4363 params.remove_params(&to_remove);
4364 }
4365
4366 let url = params.parse_with_url(&url);
4367
4368 loop {
4369 let token = match self
4370 .hub
4371 .auth
4372 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4373 .await
4374 {
4375 Ok(token) => token,
4376 Err(e) => match dlg.token(e) {
4377 Ok(token) => token,
4378 Err(e) => {
4379 dlg.finished(false);
4380 return Err(common::Error::MissingToken(e));
4381 }
4382 },
4383 };
4384 let mut req_result = {
4385 let client = &self.hub.client;
4386 dlg.pre_request();
4387 let mut req_builder = hyper::Request::builder()
4388 .method(hyper::Method::DELETE)
4389 .uri(url.as_str())
4390 .header(USER_AGENT, self.hub._user_agent.clone());
4391
4392 if let Some(token) = token.as_ref() {
4393 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4394 }
4395
4396 let request = req_builder
4397 .header(CONTENT_LENGTH, 0_u64)
4398 .body(common::to_body::<String>(None));
4399
4400 client.request(request.unwrap()).await
4401 };
4402
4403 match req_result {
4404 Err(err) => {
4405 if let common::Retry::After(d) = dlg.http_error(&err) {
4406 sleep(d).await;
4407 continue;
4408 }
4409 dlg.finished(false);
4410 return Err(common::Error::HttpError(err));
4411 }
4412 Ok(res) => {
4413 let (mut parts, body) = res.into_parts();
4414 let mut body = common::Body::new(body);
4415 if !parts.status.is_success() {
4416 let bytes = common::to_bytes(body).await.unwrap_or_default();
4417 let error = serde_json::from_str(&common::to_string(&bytes));
4418 let response = common::to_response(parts, bytes.into());
4419
4420 if let common::Retry::After(d) =
4421 dlg.http_failure(&response, error.as_ref().ok())
4422 {
4423 sleep(d).await;
4424 continue;
4425 }
4426
4427 dlg.finished(false);
4428
4429 return Err(match error {
4430 Ok(value) => common::Error::BadRequest(value),
4431 _ => common::Error::Failure(response),
4432 });
4433 }
4434 let response = {
4435 let bytes = common::to_bytes(body).await.unwrap_or_default();
4436 let encoded = common::to_string(&bytes);
4437 match serde_json::from_str(&encoded) {
4438 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4439 Err(error) => {
4440 dlg.response_json_decode_error(&encoded, &error);
4441 return Err(common::Error::JsonDecodeError(
4442 encoded.to_string(),
4443 error,
4444 ));
4445 }
4446 }
4447 };
4448
4449 dlg.finished(true);
4450 return Ok(response);
4451 }
4452 }
4453 }
4454 }
4455
4456 /// Required. The full resource name of the sink to delete, including the parent resource and the sink identifier:
4457 /// "projects/[PROJECT_ID]/sinks/[SINK_ID]"
4458 /// "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
4459 /// "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
4460 /// "folders/[FOLDER_ID]/sinks/[SINK_ID]"
4461 /// Example: "projects/my-project-id/sinks/my-sink-id".
4462 ///
4463 /// Sets the *sink name* path property to the given value.
4464 ///
4465 /// Even though the property as already been set when instantiating this call,
4466 /// we provide this method for API completeness.
4467 pub fn sink_name(mut self, new_value: &str) -> ProjectSinkDeleteCall<'a, C> {
4468 self._sink_name = new_value.to_string();
4469 self
4470 }
4471 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4472 /// while executing the actual API request.
4473 ///
4474 /// ````text
4475 /// It should be used to handle progress information, and to implement a certain level of resilience.
4476 /// ````
4477 ///
4478 /// Sets the *delegate* property to the given value.
4479 pub fn delegate(
4480 mut self,
4481 new_value: &'a mut dyn common::Delegate,
4482 ) -> ProjectSinkDeleteCall<'a, C> {
4483 self._delegate = Some(new_value);
4484 self
4485 }
4486
4487 /// Set any additional parameter of the query string used in the request.
4488 /// It should be used to set parameters which are not yet available through their own
4489 /// setters.
4490 ///
4491 /// Please note that this method must not be used to set any of the known parameters
4492 /// which have their own setter method. If done anyway, the request will fail.
4493 ///
4494 /// # Additional Parameters
4495 ///
4496 /// * *$.xgafv* (query-string) - V1 error format.
4497 /// * *access_token* (query-string) - OAuth access token.
4498 /// * *alt* (query-string) - Data format for response.
4499 /// * *callback* (query-string) - JSONP
4500 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4501 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4502 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4503 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4504 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4505 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4506 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4507 pub fn param<T>(mut self, name: T, value: T) -> ProjectSinkDeleteCall<'a, C>
4508 where
4509 T: AsRef<str>,
4510 {
4511 self._additional_params
4512 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4513 self
4514 }
4515
4516 /// Identifies the authorization scope for the method you are building.
4517 ///
4518 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4519 /// [`Scope::CloudPlatform`].
4520 ///
4521 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4522 /// tokens for more than one scope.
4523 ///
4524 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4525 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4526 /// sufficient, a read-write scope will do as well.
4527 pub fn add_scope<St>(mut self, scope: St) -> ProjectSinkDeleteCall<'a, C>
4528 where
4529 St: AsRef<str>,
4530 {
4531 self._scopes.insert(String::from(scope.as_ref()));
4532 self
4533 }
4534 /// Identifies the authorization scope(s) for the method you are building.
4535 ///
4536 /// See [`Self::add_scope()`] for details.
4537 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSinkDeleteCall<'a, C>
4538 where
4539 I: IntoIterator<Item = St>,
4540 St: AsRef<str>,
4541 {
4542 self._scopes
4543 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4544 self
4545 }
4546
4547 /// Removes all scopes, and no default scope will be used either.
4548 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4549 /// for details).
4550 pub fn clear_scopes(mut self) -> ProjectSinkDeleteCall<'a, C> {
4551 self._scopes.clear();
4552 self
4553 }
4554}
4555
4556/// Gets a sink.
4557///
4558/// A builder for the *sinks.get* method supported by a *project* resource.
4559/// It is not used directly, but through a [`ProjectMethods`] instance.
4560///
4561/// # Example
4562///
4563/// Instantiate a resource method builder
4564///
4565/// ```test_harness,no_run
4566/// # extern crate hyper;
4567/// # extern crate hyper_rustls;
4568/// # extern crate google_logging2_beta1 as logging2_beta1;
4569/// # async fn dox() {
4570/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4571///
4572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4574/// # .with_native_roots()
4575/// # .unwrap()
4576/// # .https_only()
4577/// # .enable_http2()
4578/// # .build();
4579///
4580/// # let executor = hyper_util::rt::TokioExecutor::new();
4581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4582/// # secret,
4583/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4584/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4585/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4586/// # ),
4587/// # ).build().await.unwrap();
4588///
4589/// # let client = hyper_util::client::legacy::Client::builder(
4590/// # hyper_util::rt::TokioExecutor::new()
4591/// # )
4592/// # .build(
4593/// # hyper_rustls::HttpsConnectorBuilder::new()
4594/// # .with_native_roots()
4595/// # .unwrap()
4596/// # .https_or_http()
4597/// # .enable_http2()
4598/// # .build()
4599/// # );
4600/// # let mut hub = Logging::new(client, auth);
4601/// // You can configure optional parameters by calling the respective setters at will, and
4602/// // execute the final call using `doit()`.
4603/// // Values shown here are possibly random and not representative !
4604/// let result = hub.projects().sinks_get("sinkName")
4605/// .doit().await;
4606/// # }
4607/// ```
4608pub struct ProjectSinkGetCall<'a, C>
4609where
4610 C: 'a,
4611{
4612 hub: &'a Logging<C>,
4613 _sink_name: String,
4614 _delegate: Option<&'a mut dyn common::Delegate>,
4615 _additional_params: HashMap<String, String>,
4616 _scopes: BTreeSet<String>,
4617}
4618
4619impl<'a, C> common::CallBuilder for ProjectSinkGetCall<'a, C> {}
4620
4621impl<'a, C> ProjectSinkGetCall<'a, C>
4622where
4623 C: common::Connector,
4624{
4625 /// Perform the operation you have build so far.
4626 pub async fn doit(mut self) -> common::Result<(common::Response, LogSink)> {
4627 use std::borrow::Cow;
4628 use std::io::{Read, Seek};
4629
4630 use common::{url::Params, ToParts};
4631 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4632
4633 let mut dd = common::DefaultDelegate;
4634 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4635 dlg.begin(common::MethodInfo {
4636 id: "logging.projects.sinks.get",
4637 http_method: hyper::Method::GET,
4638 });
4639
4640 for &field in ["alt", "sinkName"].iter() {
4641 if self._additional_params.contains_key(field) {
4642 dlg.finished(false);
4643 return Err(common::Error::FieldClash(field));
4644 }
4645 }
4646
4647 let mut params = Params::with_capacity(3 + self._additional_params.len());
4648 params.push("sinkName", self._sink_name);
4649
4650 params.extend(self._additional_params.iter());
4651
4652 params.push("alt", "json");
4653 let mut url = self.hub._base_url.clone() + "v2beta1/{+sinkName}";
4654 if self._scopes.is_empty() {
4655 self._scopes
4656 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
4657 }
4658
4659 #[allow(clippy::single_element_loop)]
4660 for &(find_this, param_name) in [("{+sinkName}", "sinkName")].iter() {
4661 url = params.uri_replacement(url, param_name, find_this, true);
4662 }
4663 {
4664 let to_remove = ["sinkName"];
4665 params.remove_params(&to_remove);
4666 }
4667
4668 let url = params.parse_with_url(&url);
4669
4670 loop {
4671 let token = match self
4672 .hub
4673 .auth
4674 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4675 .await
4676 {
4677 Ok(token) => token,
4678 Err(e) => match dlg.token(e) {
4679 Ok(token) => token,
4680 Err(e) => {
4681 dlg.finished(false);
4682 return Err(common::Error::MissingToken(e));
4683 }
4684 },
4685 };
4686 let mut req_result = {
4687 let client = &self.hub.client;
4688 dlg.pre_request();
4689 let mut req_builder = hyper::Request::builder()
4690 .method(hyper::Method::GET)
4691 .uri(url.as_str())
4692 .header(USER_AGENT, self.hub._user_agent.clone());
4693
4694 if let Some(token) = token.as_ref() {
4695 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4696 }
4697
4698 let request = req_builder
4699 .header(CONTENT_LENGTH, 0_u64)
4700 .body(common::to_body::<String>(None));
4701
4702 client.request(request.unwrap()).await
4703 };
4704
4705 match req_result {
4706 Err(err) => {
4707 if let common::Retry::After(d) = dlg.http_error(&err) {
4708 sleep(d).await;
4709 continue;
4710 }
4711 dlg.finished(false);
4712 return Err(common::Error::HttpError(err));
4713 }
4714 Ok(res) => {
4715 let (mut parts, body) = res.into_parts();
4716 let mut body = common::Body::new(body);
4717 if !parts.status.is_success() {
4718 let bytes = common::to_bytes(body).await.unwrap_or_default();
4719 let error = serde_json::from_str(&common::to_string(&bytes));
4720 let response = common::to_response(parts, bytes.into());
4721
4722 if let common::Retry::After(d) =
4723 dlg.http_failure(&response, error.as_ref().ok())
4724 {
4725 sleep(d).await;
4726 continue;
4727 }
4728
4729 dlg.finished(false);
4730
4731 return Err(match error {
4732 Ok(value) => common::Error::BadRequest(value),
4733 _ => common::Error::Failure(response),
4734 });
4735 }
4736 let response = {
4737 let bytes = common::to_bytes(body).await.unwrap_or_default();
4738 let encoded = common::to_string(&bytes);
4739 match serde_json::from_str(&encoded) {
4740 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4741 Err(error) => {
4742 dlg.response_json_decode_error(&encoded, &error);
4743 return Err(common::Error::JsonDecodeError(
4744 encoded.to_string(),
4745 error,
4746 ));
4747 }
4748 }
4749 };
4750
4751 dlg.finished(true);
4752 return Ok(response);
4753 }
4754 }
4755 }
4756 }
4757
4758 /// Required. The resource name of the sink:
4759 /// "projects/[PROJECT_ID]/sinks/[SINK_ID]"
4760 /// "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
4761 /// "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
4762 /// "folders/[FOLDER_ID]/sinks/[SINK_ID]"
4763 /// Example: "projects/my-project-id/sinks/my-sink-id".
4764 ///
4765 /// Sets the *sink name* path property to the given value.
4766 ///
4767 /// Even though the property as already been set when instantiating this call,
4768 /// we provide this method for API completeness.
4769 pub fn sink_name(mut self, new_value: &str) -> ProjectSinkGetCall<'a, C> {
4770 self._sink_name = new_value.to_string();
4771 self
4772 }
4773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4774 /// while executing the actual API request.
4775 ///
4776 /// ````text
4777 /// It should be used to handle progress information, and to implement a certain level of resilience.
4778 /// ````
4779 ///
4780 /// Sets the *delegate* property to the given value.
4781 pub fn delegate(
4782 mut self,
4783 new_value: &'a mut dyn common::Delegate,
4784 ) -> ProjectSinkGetCall<'a, C> {
4785 self._delegate = Some(new_value);
4786 self
4787 }
4788
4789 /// Set any additional parameter of the query string used in the request.
4790 /// It should be used to set parameters which are not yet available through their own
4791 /// setters.
4792 ///
4793 /// Please note that this method must not be used to set any of the known parameters
4794 /// which have their own setter method. If done anyway, the request will fail.
4795 ///
4796 /// # Additional Parameters
4797 ///
4798 /// * *$.xgafv* (query-string) - V1 error format.
4799 /// * *access_token* (query-string) - OAuth access token.
4800 /// * *alt* (query-string) - Data format for response.
4801 /// * *callback* (query-string) - JSONP
4802 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4803 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4804 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4805 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4806 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4807 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4808 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4809 pub fn param<T>(mut self, name: T, value: T) -> ProjectSinkGetCall<'a, C>
4810 where
4811 T: AsRef<str>,
4812 {
4813 self._additional_params
4814 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4815 self
4816 }
4817
4818 /// Identifies the authorization scope for the method you are building.
4819 ///
4820 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4821 /// [`Scope::CloudPlatformReadOnly`].
4822 ///
4823 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4824 /// tokens for more than one scope.
4825 ///
4826 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4827 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4828 /// sufficient, a read-write scope will do as well.
4829 pub fn add_scope<St>(mut self, scope: St) -> ProjectSinkGetCall<'a, C>
4830 where
4831 St: AsRef<str>,
4832 {
4833 self._scopes.insert(String::from(scope.as_ref()));
4834 self
4835 }
4836 /// Identifies the authorization scope(s) for the method you are building.
4837 ///
4838 /// See [`Self::add_scope()`] for details.
4839 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSinkGetCall<'a, C>
4840 where
4841 I: IntoIterator<Item = St>,
4842 St: AsRef<str>,
4843 {
4844 self._scopes
4845 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4846 self
4847 }
4848
4849 /// Removes all scopes, and no default scope will be used either.
4850 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4851 /// for details).
4852 pub fn clear_scopes(mut self) -> ProjectSinkGetCall<'a, C> {
4853 self._scopes.clear();
4854 self
4855 }
4856}
4857
4858/// Lists sinks.
4859///
4860/// A builder for the *sinks.list* method supported by a *project* resource.
4861/// It is not used directly, but through a [`ProjectMethods`] instance.
4862///
4863/// # Example
4864///
4865/// Instantiate a resource method builder
4866///
4867/// ```test_harness,no_run
4868/// # extern crate hyper;
4869/// # extern crate hyper_rustls;
4870/// # extern crate google_logging2_beta1 as logging2_beta1;
4871/// # async fn dox() {
4872/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4873///
4874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4875/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4876/// # .with_native_roots()
4877/// # .unwrap()
4878/// # .https_only()
4879/// # .enable_http2()
4880/// # .build();
4881///
4882/// # let executor = hyper_util::rt::TokioExecutor::new();
4883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4884/// # secret,
4885/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4886/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4887/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4888/// # ),
4889/// # ).build().await.unwrap();
4890///
4891/// # let client = hyper_util::client::legacy::Client::builder(
4892/// # hyper_util::rt::TokioExecutor::new()
4893/// # )
4894/// # .build(
4895/// # hyper_rustls::HttpsConnectorBuilder::new()
4896/// # .with_native_roots()
4897/// # .unwrap()
4898/// # .https_or_http()
4899/// # .enable_http2()
4900/// # .build()
4901/// # );
4902/// # let mut hub = Logging::new(client, auth);
4903/// // You can configure optional parameters by calling the respective setters at will, and
4904/// // execute the final call using `doit()`.
4905/// // Values shown here are possibly random and not representative !
4906/// let result = hub.projects().sinks_list("parent")
4907/// .page_token("dolor")
4908/// .page_size(-17)
4909/// .doit().await;
4910/// # }
4911/// ```
4912pub struct ProjectSinkListCall<'a, C>
4913where
4914 C: 'a,
4915{
4916 hub: &'a Logging<C>,
4917 _parent: String,
4918 _page_token: Option<String>,
4919 _page_size: Option<i32>,
4920 _delegate: Option<&'a mut dyn common::Delegate>,
4921 _additional_params: HashMap<String, String>,
4922 _scopes: BTreeSet<String>,
4923}
4924
4925impl<'a, C> common::CallBuilder for ProjectSinkListCall<'a, C> {}
4926
4927impl<'a, C> ProjectSinkListCall<'a, C>
4928where
4929 C: common::Connector,
4930{
4931 /// Perform the operation you have build so far.
4932 pub async fn doit(mut self) -> common::Result<(common::Response, ListSinksResponse)> {
4933 use std::borrow::Cow;
4934 use std::io::{Read, Seek};
4935
4936 use common::{url::Params, ToParts};
4937 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4938
4939 let mut dd = common::DefaultDelegate;
4940 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4941 dlg.begin(common::MethodInfo {
4942 id: "logging.projects.sinks.list",
4943 http_method: hyper::Method::GET,
4944 });
4945
4946 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4947 if self._additional_params.contains_key(field) {
4948 dlg.finished(false);
4949 return Err(common::Error::FieldClash(field));
4950 }
4951 }
4952
4953 let mut params = Params::with_capacity(5 + self._additional_params.len());
4954 params.push("parent", self._parent);
4955 if let Some(value) = self._page_token.as_ref() {
4956 params.push("pageToken", value);
4957 }
4958 if let Some(value) = self._page_size.as_ref() {
4959 params.push("pageSize", value.to_string());
4960 }
4961
4962 params.extend(self._additional_params.iter());
4963
4964 params.push("alt", "json");
4965 let mut url = self.hub._base_url.clone() + "v2beta1/{+parent}/sinks";
4966 if self._scopes.is_empty() {
4967 self._scopes
4968 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
4969 }
4970
4971 #[allow(clippy::single_element_loop)]
4972 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4973 url = params.uri_replacement(url, param_name, find_this, true);
4974 }
4975 {
4976 let to_remove = ["parent"];
4977 params.remove_params(&to_remove);
4978 }
4979
4980 let url = params.parse_with_url(&url);
4981
4982 loop {
4983 let token = match self
4984 .hub
4985 .auth
4986 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4987 .await
4988 {
4989 Ok(token) => token,
4990 Err(e) => match dlg.token(e) {
4991 Ok(token) => token,
4992 Err(e) => {
4993 dlg.finished(false);
4994 return Err(common::Error::MissingToken(e));
4995 }
4996 },
4997 };
4998 let mut req_result = {
4999 let client = &self.hub.client;
5000 dlg.pre_request();
5001 let mut req_builder = hyper::Request::builder()
5002 .method(hyper::Method::GET)
5003 .uri(url.as_str())
5004 .header(USER_AGENT, self.hub._user_agent.clone());
5005
5006 if let Some(token) = token.as_ref() {
5007 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5008 }
5009
5010 let request = req_builder
5011 .header(CONTENT_LENGTH, 0_u64)
5012 .body(common::to_body::<String>(None));
5013
5014 client.request(request.unwrap()).await
5015 };
5016
5017 match req_result {
5018 Err(err) => {
5019 if let common::Retry::After(d) = dlg.http_error(&err) {
5020 sleep(d).await;
5021 continue;
5022 }
5023 dlg.finished(false);
5024 return Err(common::Error::HttpError(err));
5025 }
5026 Ok(res) => {
5027 let (mut parts, body) = res.into_parts();
5028 let mut body = common::Body::new(body);
5029 if !parts.status.is_success() {
5030 let bytes = common::to_bytes(body).await.unwrap_or_default();
5031 let error = serde_json::from_str(&common::to_string(&bytes));
5032 let response = common::to_response(parts, bytes.into());
5033
5034 if let common::Retry::After(d) =
5035 dlg.http_failure(&response, error.as_ref().ok())
5036 {
5037 sleep(d).await;
5038 continue;
5039 }
5040
5041 dlg.finished(false);
5042
5043 return Err(match error {
5044 Ok(value) => common::Error::BadRequest(value),
5045 _ => common::Error::Failure(response),
5046 });
5047 }
5048 let response = {
5049 let bytes = common::to_bytes(body).await.unwrap_or_default();
5050 let encoded = common::to_string(&bytes);
5051 match serde_json::from_str(&encoded) {
5052 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5053 Err(error) => {
5054 dlg.response_json_decode_error(&encoded, &error);
5055 return Err(common::Error::JsonDecodeError(
5056 encoded.to_string(),
5057 error,
5058 ));
5059 }
5060 }
5061 };
5062
5063 dlg.finished(true);
5064 return Ok(response);
5065 }
5066 }
5067 }
5068 }
5069
5070 /// Required. The parent resource whose sinks are to be listed:
5071 /// "projects/[PROJECT_ID]"
5072 /// "organizations/[ORGANIZATION_ID]"
5073 /// "billingAccounts/[BILLING_ACCOUNT_ID]"
5074 /// "folders/[FOLDER_ID]"
5075 ///
5076 ///
5077 /// Sets the *parent* path property to the given value.
5078 ///
5079 /// Even though the property as already been set when instantiating this call,
5080 /// we provide this method for API completeness.
5081 pub fn parent(mut self, new_value: &str) -> ProjectSinkListCall<'a, C> {
5082 self._parent = new_value.to_string();
5083 self
5084 }
5085 /// Optional. If present, then retrieve the next batch of results from the preceding call to this method. pageToken must be the value of nextPageToken from the previous response. The values of other method parameters should be identical to those in the previous call.
5086 ///
5087 /// Sets the *page token* query property to the given value.
5088 pub fn page_token(mut self, new_value: &str) -> ProjectSinkListCall<'a, C> {
5089 self._page_token = Some(new_value.to_string());
5090 self
5091 }
5092 /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. The presence of nextPageToken in the response indicates that more results might be available.
5093 ///
5094 /// Sets the *page size* query property to the given value.
5095 pub fn page_size(mut self, new_value: i32) -> ProjectSinkListCall<'a, C> {
5096 self._page_size = Some(new_value);
5097 self
5098 }
5099 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5100 /// while executing the actual API request.
5101 ///
5102 /// ````text
5103 /// It should be used to handle progress information, and to implement a certain level of resilience.
5104 /// ````
5105 ///
5106 /// Sets the *delegate* property to the given value.
5107 pub fn delegate(
5108 mut self,
5109 new_value: &'a mut dyn common::Delegate,
5110 ) -> ProjectSinkListCall<'a, C> {
5111 self._delegate = Some(new_value);
5112 self
5113 }
5114
5115 /// Set any additional parameter of the query string used in the request.
5116 /// It should be used to set parameters which are not yet available through their own
5117 /// setters.
5118 ///
5119 /// Please note that this method must not be used to set any of the known parameters
5120 /// which have their own setter method. If done anyway, the request will fail.
5121 ///
5122 /// # Additional Parameters
5123 ///
5124 /// * *$.xgafv* (query-string) - V1 error format.
5125 /// * *access_token* (query-string) - OAuth access token.
5126 /// * *alt* (query-string) - Data format for response.
5127 /// * *callback* (query-string) - JSONP
5128 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5129 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5130 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5131 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5132 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5133 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5134 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5135 pub fn param<T>(mut self, name: T, value: T) -> ProjectSinkListCall<'a, C>
5136 where
5137 T: AsRef<str>,
5138 {
5139 self._additional_params
5140 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5141 self
5142 }
5143
5144 /// Identifies the authorization scope for the method you are building.
5145 ///
5146 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5147 /// [`Scope::CloudPlatformReadOnly`].
5148 ///
5149 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5150 /// tokens for more than one scope.
5151 ///
5152 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5153 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5154 /// sufficient, a read-write scope will do as well.
5155 pub fn add_scope<St>(mut self, scope: St) -> ProjectSinkListCall<'a, C>
5156 where
5157 St: AsRef<str>,
5158 {
5159 self._scopes.insert(String::from(scope.as_ref()));
5160 self
5161 }
5162 /// Identifies the authorization scope(s) for the method you are building.
5163 ///
5164 /// See [`Self::add_scope()`] for details.
5165 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSinkListCall<'a, C>
5166 where
5167 I: IntoIterator<Item = St>,
5168 St: AsRef<str>,
5169 {
5170 self._scopes
5171 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5172 self
5173 }
5174
5175 /// Removes all scopes, and no default scope will be used either.
5176 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5177 /// for details).
5178 pub fn clear_scopes(mut self) -> ProjectSinkListCall<'a, C> {
5179 self._scopes.clear();
5180 self
5181 }
5182}
5183
5184/// Updates a sink. This method replaces the following fields in the existing sink with values from the new sink: destination, and filter.The updated sink might also have a new writer_identity; see the unique_writer_identity field.
5185///
5186/// A builder for the *sinks.update* method supported by a *project* resource.
5187/// It is not used directly, but through a [`ProjectMethods`] instance.
5188///
5189/// # Example
5190///
5191/// Instantiate a resource method builder
5192///
5193/// ```test_harness,no_run
5194/// # extern crate hyper;
5195/// # extern crate hyper_rustls;
5196/// # extern crate google_logging2_beta1 as logging2_beta1;
5197/// use logging2_beta1::api::LogSink;
5198/// # async fn dox() {
5199/// # use logging2_beta1::{Logging, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5200///
5201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5202/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5203/// # .with_native_roots()
5204/// # .unwrap()
5205/// # .https_only()
5206/// # .enable_http2()
5207/// # .build();
5208///
5209/// # let executor = hyper_util::rt::TokioExecutor::new();
5210/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5211/// # secret,
5212/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5213/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5214/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5215/// # ),
5216/// # ).build().await.unwrap();
5217///
5218/// # let client = hyper_util::client::legacy::Client::builder(
5219/// # hyper_util::rt::TokioExecutor::new()
5220/// # )
5221/// # .build(
5222/// # hyper_rustls::HttpsConnectorBuilder::new()
5223/// # .with_native_roots()
5224/// # .unwrap()
5225/// # .https_or_http()
5226/// # .enable_http2()
5227/// # .build()
5228/// # );
5229/// # let mut hub = Logging::new(client, auth);
5230/// // As the method needs a request, you would usually fill it with the desired information
5231/// // into the respective structure. Some of the parts shown here might not be applicable !
5232/// // Values shown here are possibly random and not representative !
5233/// let mut req = LogSink::default();
5234///
5235/// // You can configure optional parameters by calling the respective setters at will, and
5236/// // execute the final call using `doit()`.
5237/// // Values shown here are possibly random and not representative !
5238/// let result = hub.projects().sinks_update(req, "sinkName")
5239/// .update_mask(FieldMask::new::<&str>(&[]))
5240/// .unique_writer_identity(false)
5241/// .doit().await;
5242/// # }
5243/// ```
5244pub struct ProjectSinkUpdateCall<'a, C>
5245where
5246 C: 'a,
5247{
5248 hub: &'a Logging<C>,
5249 _request: LogSink,
5250 _sink_name: String,
5251 _update_mask: Option<common::FieldMask>,
5252 _unique_writer_identity: Option<bool>,
5253 _delegate: Option<&'a mut dyn common::Delegate>,
5254 _additional_params: HashMap<String, String>,
5255 _scopes: BTreeSet<String>,
5256}
5257
5258impl<'a, C> common::CallBuilder for ProjectSinkUpdateCall<'a, C> {}
5259
5260impl<'a, C> ProjectSinkUpdateCall<'a, C>
5261where
5262 C: common::Connector,
5263{
5264 /// Perform the operation you have build so far.
5265 pub async fn doit(mut self) -> common::Result<(common::Response, LogSink)> {
5266 use std::borrow::Cow;
5267 use std::io::{Read, Seek};
5268
5269 use common::{url::Params, ToParts};
5270 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5271
5272 let mut dd = common::DefaultDelegate;
5273 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5274 dlg.begin(common::MethodInfo {
5275 id: "logging.projects.sinks.update",
5276 http_method: hyper::Method::PUT,
5277 });
5278
5279 for &field in ["alt", "sinkName", "updateMask", "uniqueWriterIdentity"].iter() {
5280 if self._additional_params.contains_key(field) {
5281 dlg.finished(false);
5282 return Err(common::Error::FieldClash(field));
5283 }
5284 }
5285
5286 let mut params = Params::with_capacity(6 + self._additional_params.len());
5287 params.push("sinkName", self._sink_name);
5288 if let Some(value) = self._update_mask.as_ref() {
5289 params.push("updateMask", value.to_string());
5290 }
5291 if let Some(value) = self._unique_writer_identity.as_ref() {
5292 params.push("uniqueWriterIdentity", value.to_string());
5293 }
5294
5295 params.extend(self._additional_params.iter());
5296
5297 params.push("alt", "json");
5298 let mut url = self.hub._base_url.clone() + "v2beta1/{+sinkName}";
5299 if self._scopes.is_empty() {
5300 self._scopes
5301 .insert(Scope::CloudPlatform.as_ref().to_string());
5302 }
5303
5304 #[allow(clippy::single_element_loop)]
5305 for &(find_this, param_name) in [("{+sinkName}", "sinkName")].iter() {
5306 url = params.uri_replacement(url, param_name, find_this, true);
5307 }
5308 {
5309 let to_remove = ["sinkName"];
5310 params.remove_params(&to_remove);
5311 }
5312
5313 let url = params.parse_with_url(&url);
5314
5315 let mut json_mime_type = mime::APPLICATION_JSON;
5316 let mut request_value_reader = {
5317 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5318 common::remove_json_null_values(&mut value);
5319 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5320 serde_json::to_writer(&mut dst, &value).unwrap();
5321 dst
5322 };
5323 let request_size = request_value_reader
5324 .seek(std::io::SeekFrom::End(0))
5325 .unwrap();
5326 request_value_reader
5327 .seek(std::io::SeekFrom::Start(0))
5328 .unwrap();
5329
5330 loop {
5331 let token = match self
5332 .hub
5333 .auth
5334 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5335 .await
5336 {
5337 Ok(token) => token,
5338 Err(e) => match dlg.token(e) {
5339 Ok(token) => token,
5340 Err(e) => {
5341 dlg.finished(false);
5342 return Err(common::Error::MissingToken(e));
5343 }
5344 },
5345 };
5346 request_value_reader
5347 .seek(std::io::SeekFrom::Start(0))
5348 .unwrap();
5349 let mut req_result = {
5350 let client = &self.hub.client;
5351 dlg.pre_request();
5352 let mut req_builder = hyper::Request::builder()
5353 .method(hyper::Method::PUT)
5354 .uri(url.as_str())
5355 .header(USER_AGENT, self.hub._user_agent.clone());
5356
5357 if let Some(token) = token.as_ref() {
5358 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5359 }
5360
5361 let request = req_builder
5362 .header(CONTENT_TYPE, json_mime_type.to_string())
5363 .header(CONTENT_LENGTH, request_size as u64)
5364 .body(common::to_body(
5365 request_value_reader.get_ref().clone().into(),
5366 ));
5367
5368 client.request(request.unwrap()).await
5369 };
5370
5371 match req_result {
5372 Err(err) => {
5373 if let common::Retry::After(d) = dlg.http_error(&err) {
5374 sleep(d).await;
5375 continue;
5376 }
5377 dlg.finished(false);
5378 return Err(common::Error::HttpError(err));
5379 }
5380 Ok(res) => {
5381 let (mut parts, body) = res.into_parts();
5382 let mut body = common::Body::new(body);
5383 if !parts.status.is_success() {
5384 let bytes = common::to_bytes(body).await.unwrap_or_default();
5385 let error = serde_json::from_str(&common::to_string(&bytes));
5386 let response = common::to_response(parts, bytes.into());
5387
5388 if let common::Retry::After(d) =
5389 dlg.http_failure(&response, error.as_ref().ok())
5390 {
5391 sleep(d).await;
5392 continue;
5393 }
5394
5395 dlg.finished(false);
5396
5397 return Err(match error {
5398 Ok(value) => common::Error::BadRequest(value),
5399 _ => common::Error::Failure(response),
5400 });
5401 }
5402 let response = {
5403 let bytes = common::to_bytes(body).await.unwrap_or_default();
5404 let encoded = common::to_string(&bytes);
5405 match serde_json::from_str(&encoded) {
5406 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5407 Err(error) => {
5408 dlg.response_json_decode_error(&encoded, &error);
5409 return Err(common::Error::JsonDecodeError(
5410 encoded.to_string(),
5411 error,
5412 ));
5413 }
5414 }
5415 };
5416
5417 dlg.finished(true);
5418 return Ok(response);
5419 }
5420 }
5421 }
5422 }
5423
5424 ///
5425 /// Sets the *request* property to the given value.
5426 ///
5427 /// Even though the property as already been set when instantiating this call,
5428 /// we provide this method for API completeness.
5429 pub fn request(mut self, new_value: LogSink) -> ProjectSinkUpdateCall<'a, C> {
5430 self._request = new_value;
5431 self
5432 }
5433 /// Required. The full resource name of the sink to update, including the parent resource and the sink identifier:
5434 /// "projects/[PROJECT_ID]/sinks/[SINK_ID]"
5435 /// "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
5436 /// "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
5437 /// "folders/[FOLDER_ID]/sinks/[SINK_ID]"
5438 /// Example: "projects/my-project-id/sinks/my-sink-id".
5439 ///
5440 /// Sets the *sink name* path property to the given value.
5441 ///
5442 /// Even though the property as already been set when instantiating this call,
5443 /// we provide this method for API completeness.
5444 pub fn sink_name(mut self, new_value: &str) -> ProjectSinkUpdateCall<'a, C> {
5445 self._sink_name = new_value.to_string();
5446 self
5447 }
5448 /// Optional. Field mask that specifies the fields in sink that need an update. A sink field will be overwritten if, and only if, it is in the update mask. name and output only fields cannot be updated.An empty updateMask is temporarily treated as using the following mask for backwards compatibility purposes: destination,filter,includeChildren At some point in the future, behavior will be removed and specifying an empty updateMask will be an error.For a detailed FieldMask definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMaskExample: updateMask=filter.
5449 ///
5450 /// Sets the *update mask* query property to the given value.
5451 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectSinkUpdateCall<'a, C> {
5452 self._update_mask = Some(new_value);
5453 self
5454 }
5455 /// Optional. See sinks.create for a description of this field. When updating a sink, the effect of this field on the value of writer_identity in the updated sink depends on both the old and new values of this field:
5456 /// If the old and new values of this field are both false or both true, then there is no change to the sink's writer_identity.
5457 /// If the old value is false and the new value is true, then writer_identity is changed to a unique service account.
5458 /// It is an error if the old value is true and the new value is set to false or defaulted to false.
5459 ///
5460 /// Sets the *unique writer identity* query property to the given value.
5461 pub fn unique_writer_identity(mut self, new_value: bool) -> ProjectSinkUpdateCall<'a, C> {
5462 self._unique_writer_identity = Some(new_value);
5463 self
5464 }
5465 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5466 /// while executing the actual API request.
5467 ///
5468 /// ````text
5469 /// It should be used to handle progress information, and to implement a certain level of resilience.
5470 /// ````
5471 ///
5472 /// Sets the *delegate* property to the given value.
5473 pub fn delegate(
5474 mut self,
5475 new_value: &'a mut dyn common::Delegate,
5476 ) -> ProjectSinkUpdateCall<'a, C> {
5477 self._delegate = Some(new_value);
5478 self
5479 }
5480
5481 /// Set any additional parameter of the query string used in the request.
5482 /// It should be used to set parameters which are not yet available through their own
5483 /// setters.
5484 ///
5485 /// Please note that this method must not be used to set any of the known parameters
5486 /// which have their own setter method. If done anyway, the request will fail.
5487 ///
5488 /// # Additional Parameters
5489 ///
5490 /// * *$.xgafv* (query-string) - V1 error format.
5491 /// * *access_token* (query-string) - OAuth access token.
5492 /// * *alt* (query-string) - Data format for response.
5493 /// * *callback* (query-string) - JSONP
5494 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5495 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5496 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5497 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5498 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5499 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5500 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5501 pub fn param<T>(mut self, name: T, value: T) -> ProjectSinkUpdateCall<'a, C>
5502 where
5503 T: AsRef<str>,
5504 {
5505 self._additional_params
5506 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5507 self
5508 }
5509
5510 /// Identifies the authorization scope for the method you are building.
5511 ///
5512 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5513 /// [`Scope::CloudPlatform`].
5514 ///
5515 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5516 /// tokens for more than one scope.
5517 ///
5518 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5519 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5520 /// sufficient, a read-write scope will do as well.
5521 pub fn add_scope<St>(mut self, scope: St) -> ProjectSinkUpdateCall<'a, C>
5522 where
5523 St: AsRef<str>,
5524 {
5525 self._scopes.insert(String::from(scope.as_ref()));
5526 self
5527 }
5528 /// Identifies the authorization scope(s) for the method you are building.
5529 ///
5530 /// See [`Self::add_scope()`] for details.
5531 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSinkUpdateCall<'a, C>
5532 where
5533 I: IntoIterator<Item = St>,
5534 St: AsRef<str>,
5535 {
5536 self._scopes
5537 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5538 self
5539 }
5540
5541 /// Removes all scopes, and no default scope will be used either.
5542 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5543 /// for details).
5544 pub fn clear_scopes(mut self) -> ProjectSinkUpdateCall<'a, C> {
5545 self._scopes.clear();
5546 self
5547 }
5548}