google_webrisk1/
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    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all WebRisk related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_webrisk1 as webrisk1;
49/// use webrisk1::api::GoogleLongrunningCancelOperationRequest;
50/// use webrisk1::{Result, Error};
51/// # async fn dox() {
52/// use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = WebRisk::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleLongrunningCancelOperationRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().operations_cancel(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct WebRisk<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for WebRisk<C> {}
130
131impl<'a, C> WebRisk<C> {
132    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> WebRisk<C> {
133        WebRisk {
134            client,
135            auth: Box::new(auth),
136            _user_agent: "google-api-rust-client/7.0.0".to_string(),
137            _base_url: "https://webrisk.googleapis.com/".to_string(),
138            _root_url: "https://webrisk.googleapis.com/".to_string(),
139        }
140    }
141
142    pub fn hashes(&'a self) -> HashMethods<'a, C> {
143        HashMethods { hub: self }
144    }
145    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
146        ProjectMethods { hub: self }
147    }
148    pub fn threat_lists(&'a self) -> ThreatListMethods<'a, C> {
149        ThreatListMethods { hub: self }
150    }
151    pub fn uris(&'a self) -> UriMethods<'a, C> {
152        UriMethods { hub: self }
153    }
154
155    /// Set the user-agent header field to use in all requests to the server.
156    /// It defaults to `google-api-rust-client/7.0.0`.
157    ///
158    /// Returns the previously set user-agent.
159    pub fn user_agent(&mut self, agent_name: String) -> String {
160        std::mem::replace(&mut self._user_agent, agent_name)
161    }
162
163    /// Set the base url to use in all requests to the server.
164    /// It defaults to `https://webrisk.googleapis.com/`.
165    ///
166    /// Returns the previously set base url.
167    pub fn base_url(&mut self, new_base_url: String) -> String {
168        std::mem::replace(&mut self._base_url, new_base_url)
169    }
170
171    /// Set the root url to use in all requests to the server.
172    /// It defaults to `https://webrisk.googleapis.com/`.
173    ///
174    /// Returns the previously set root url.
175    pub fn root_url(&mut self, new_root_url: String) -> String {
176        std::mem::replace(&mut self._root_url, new_root_url)
177    }
178}
179
180// ############
181// SCHEMAS ###
182// ##########
183/// There is no detailed description.
184///
185/// # Activities
186///
187/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
188/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
189///
190/// * [compute diff threat lists](ThreatListComputeDiffCall) (response)
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct GoogleCloudWebriskV1ComputeThreatListDiffResponse {
195    /// A set of entries to add to a local threat type's list.
196    pub additions: Option<GoogleCloudWebriskV1ThreatEntryAdditions>,
197    /// The expected SHA256 hash of the client state; that is, of the sorted list of all hashes present in the database after applying the provided diff. If the client state doesn't match the expected state, the client must discard this diff and retry later.
198    pub checksum: Option<GoogleCloudWebriskV1ComputeThreatListDiffResponseChecksum>,
199    /// The new opaque client version token. This should be retained by the client and passed into the next call of ComputeThreatListDiff as 'version_token'. A separate version token should be stored and used for each threatList.
200    #[serde(rename = "newVersionToken")]
201    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
202    pub new_version_token: Option<Vec<u8>>,
203    /// The soonest the client should wait before issuing any diff request. Querying sooner is unlikely to produce a meaningful diff. Waiting longer is acceptable considering the use case. If this field is not set clients may update as soon as they want.
204    #[serde(rename = "recommendedNextDiff")]
205    pub recommended_next_diff: Option<chrono::DateTime<chrono::offset::Utc>>,
206    /// A set of entries to remove from a local threat type's list. This field may be empty.
207    pub removals: Option<GoogleCloudWebriskV1ThreatEntryRemovals>,
208    /// The type of response. This may indicate that an action must be taken by the client when the response is received.
209    #[serde(rename = "responseType")]
210    pub response_type: Option<String>,
211}
212
213impl common::ResponseResult for GoogleCloudWebriskV1ComputeThreatListDiffResponse {}
214
215/// The expected state of a client's local database.
216///
217/// This type is not used in any activity, and only used as *part* of another schema.
218///
219#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
220#[serde_with::serde_as]
221#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
222pub struct GoogleCloudWebriskV1ComputeThreatListDiffResponseChecksum {
223    /// The SHA256 hash of the client state; that is, of the sorted list of all hashes present in the database.
224    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
225    pub sha256: Option<Vec<u8>>,
226}
227
228impl common::Part for GoogleCloudWebriskV1ComputeThreatListDiffResponseChecksum {}
229
230/// The uncompressed threat entries in hash format. Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 bytes, but some hashes are lengthened if they collide with the hash of a popular URI. Used for sending ThreatEntryAdditons to clients that do not support compression, or when sending non-4-byte hashes to clients that do support compression.
231///
232/// This type is not used in any activity, and only used as *part* of another schema.
233///
234#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
235#[serde_with::serde_as]
236#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
237pub struct GoogleCloudWebriskV1RawHashes {
238    /// The number of bytes for each prefix encoded below. This field can be anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). In practice this is almost always 4, except in exceptional circumstances.
239    #[serde(rename = "prefixSize")]
240    pub prefix_size: Option<i32>,
241    /// The hashes, in binary format, concatenated into one long string. Hashes are sorted in lexicographic order. For JSON API users, hashes are base64-encoded.
242    #[serde(rename = "rawHashes")]
243    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
244    pub raw_hashes: Option<Vec<u8>>,
245}
246
247impl common::Part for GoogleCloudWebriskV1RawHashes {}
248
249/// A set of raw indices to remove from a local list.
250///
251/// This type is not used in any activity, and only used as *part* of another schema.
252///
253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
254#[serde_with::serde_as]
255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
256pub struct GoogleCloudWebriskV1RawIndices {
257    /// The indices to remove from a lexicographically-sorted local list.
258    pub indices: Option<Vec<i32>>,
259}
260
261impl common::Part for GoogleCloudWebriskV1RawIndices {}
262
263/// The Rice-Golomb encoded data. Used for sending compressed 4-byte hashes or compressed removal indices.
264///
265/// This type is not used in any activity, and only used as *part* of another schema.
266///
267#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
268#[serde_with::serde_as]
269#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
270pub struct GoogleCloudWebriskV1RiceDeltaEncoding {
271    /// The encoded deltas that are encoded using the Golomb-Rice coder.
272    #[serde(rename = "encodedData")]
273    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
274    pub encoded_data: Option<Vec<u8>>,
275    /// The number of entries that are delta encoded in the encoded data. If only a single integer was encoded, this will be zero and the single value will be stored in `first_value`.
276    #[serde(rename = "entryCount")]
277    pub entry_count: Option<i32>,
278    /// The offset of the first entry in the encoded data, or, if only a single integer was encoded, that single integer's value. If the field is empty or missing, assume zero.
279    #[serde(rename = "firstValue")]
280    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
281    pub first_value: Option<i64>,
282    /// The Golomb-Rice parameter, which is a number between 2 and 28. This field is missing (that is, zero) if `num_entries` is zero.
283    #[serde(rename = "riceParameter")]
284    pub rice_parameter: Option<i32>,
285}
286
287impl common::Part for GoogleCloudWebriskV1RiceDeltaEncoding {}
288
289/// There is no detailed description.
290///
291/// # Activities
292///
293/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
294/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
295///
296/// * [search hashes](HashSearchCall) (response)
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct GoogleCloudWebriskV1SearchHashesResponse {
301    /// For requested entities that did not match the threat list, how long to cache the response until.
302    #[serde(rename = "negativeExpireTime")]
303    pub negative_expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
304    /// The full hashes that matched the requested prefixes. The hash will be populated in the key.
305    pub threats: Option<Vec<GoogleCloudWebriskV1SearchHashesResponseThreatHash>>,
306}
307
308impl common::ResponseResult for GoogleCloudWebriskV1SearchHashesResponse {}
309
310/// Contains threat information on a matching hash.
311///
312/// This type is not used in any activity, and only used as *part* of another schema.
313///
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct GoogleCloudWebriskV1SearchHashesResponseThreatHash {
318    /// The cache lifetime for the returned match. Clients must not cache this response past this timestamp to avoid false positives.
319    #[serde(rename = "expireTime")]
320    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
321    /// A 32 byte SHA256 hash. This field is in binary format. For JSON requests, hashes are base64-encoded.
322    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
323    pub hash: Option<Vec<u8>>,
324    /// The ThreatList this threat belongs to. This must contain at least one entry.
325    #[serde(rename = "threatTypes")]
326    pub threat_types: Option<Vec<String>>,
327}
328
329impl common::Part for GoogleCloudWebriskV1SearchHashesResponseThreatHash {}
330
331/// There is no detailed description.
332///
333/// # Activities
334///
335/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
336/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
337///
338/// * [search uris](UriSearchCall) (response)
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct GoogleCloudWebriskV1SearchUrisResponse {
343    /// The threat list matches. This might be empty if the URI is on no list.
344    pub threat: Option<GoogleCloudWebriskV1SearchUrisResponseThreatUri>,
345}
346
347impl common::ResponseResult for GoogleCloudWebriskV1SearchUrisResponse {}
348
349/// Contains threat information on a matching uri.
350///
351/// This type is not used in any activity, and only used as *part* of another schema.
352///
353#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
354#[serde_with::serde_as]
355#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
356pub struct GoogleCloudWebriskV1SearchUrisResponseThreatUri {
357    /// The cache lifetime for the returned match. Clients must not cache this response past this timestamp to avoid false positives.
358    #[serde(rename = "expireTime")]
359    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
360    /// The ThreatList this threat belongs to.
361    #[serde(rename = "threatTypes")]
362    pub threat_types: Option<Vec<String>>,
363}
364
365impl common::Part for GoogleCloudWebriskV1SearchUrisResponseThreatUri {}
366
367/// Wraps a URI that might be displaying malicious content.
368///
369/// # Activities
370///
371/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
372/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
373///
374/// * [submissions create projects](ProjectSubmissionCreateCall) (request|response)
375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
376#[serde_with::serde_as]
377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
378pub struct GoogleCloudWebriskV1Submission {
379    /// Required. The URI that is being reported for malicious content to be analyzed.
380    pub uri: Option<String>,
381}
382
383impl common::RequestValue for GoogleCloudWebriskV1Submission {}
384impl common::ResponseResult for GoogleCloudWebriskV1Submission {}
385
386/// Contains the set of entries to add to a local database. May contain a combination of compressed and raw data in a single response.
387///
388/// This type is not used in any activity, and only used as *part* of another schema.
389///
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct GoogleCloudWebriskV1ThreatEntryAdditions {
394    /// The raw SHA256-formatted entries. Repeated to allow returning sets of hashes with different prefix sizes.
395    #[serde(rename = "rawHashes")]
396    pub raw_hashes: Option<Vec<GoogleCloudWebriskV1RawHashes>>,
397    /// The encoded 4-byte prefixes of SHA256-formatted entries, using a Golomb-Rice encoding. The hashes are converted to uint32, sorted in ascending order, then delta encoded and stored as encoded_data.
398    #[serde(rename = "riceHashes")]
399    pub rice_hashes: Option<GoogleCloudWebriskV1RiceDeltaEncoding>,
400}
401
402impl common::Part for GoogleCloudWebriskV1ThreatEntryAdditions {}
403
404/// Contains the set of entries to remove from a local database.
405///
406/// This type is not used in any activity, and only used as *part* of another schema.
407///
408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
409#[serde_with::serde_as]
410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
411pub struct GoogleCloudWebriskV1ThreatEntryRemovals {
412    /// The raw removal indices for a local list.
413    #[serde(rename = "rawIndices")]
414    pub raw_indices: Option<GoogleCloudWebriskV1RawIndices>,
415    /// The encoded local, lexicographically-sorted list indices, using a Golomb-Rice encoding. Used for sending compressed removal indices. The removal indices (uint32) are sorted in ascending order, then delta encoded and stored as encoded_data.
416    #[serde(rename = "riceIndices")]
417    pub rice_indices: Option<GoogleCloudWebriskV1RiceDeltaEncoding>,
418}
419
420impl common::Part for GoogleCloudWebriskV1ThreatEntryRemovals {}
421
422/// The request message for Operations.CancelOperation.
423///
424/// # Activities
425///
426/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
427/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
428///
429/// * [operations cancel projects](ProjectOperationCancelCall) (request)
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct GoogleLongrunningCancelOperationRequest {
434    _never_set: Option<bool>,
435}
436
437impl common::RequestValue for GoogleLongrunningCancelOperationRequest {}
438
439/// The response message for Operations.ListOperations.
440///
441/// # Activities
442///
443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
445///
446/// * [operations list projects](ProjectOperationListCall) (response)
447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
448#[serde_with::serde_as]
449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
450pub struct GoogleLongrunningListOperationsResponse {
451    /// The standard List next-page token.
452    #[serde(rename = "nextPageToken")]
453    pub next_page_token: Option<String>,
454    /// A list of operations that matches the specified filter in the request.
455    pub operations: Option<Vec<GoogleLongrunningOperation>>,
456    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
457    pub unreachable: Option<Vec<String>>,
458}
459
460impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
461
462/// This resource represents a long-running operation that is the result of a network API call.
463///
464/// # Activities
465///
466/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
467/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
468///
469/// * [operations get projects](ProjectOperationGetCall) (response)
470#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
471#[serde_with::serde_as]
472#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
473pub struct GoogleLongrunningOperation {
474    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
475    pub done: Option<bool>,
476    /// The error result of the operation in case of failure or cancellation.
477    pub error: Option<GoogleRpcStatus>,
478    /// Contains a `SubmitUriMetadata` object.
479    pub metadata: Option<HashMap<String, serde_json::Value>>,
480    /// Matches the `/v1/{project-name}/operations/{operation-id}` pattern.
481    pub name: Option<String>,
482    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
483    pub response: Option<HashMap<String, serde_json::Value>>,
484}
485
486impl common::ResponseResult for GoogleLongrunningOperation {}
487
488/// 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: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
489///
490/// # Activities
491///
492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
494///
495/// * [operations cancel projects](ProjectOperationCancelCall) (response)
496/// * [operations delete projects](ProjectOperationDeleteCall) (response)
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct GoogleProtobufEmpty {
501    _never_set: Option<bool>,
502}
503
504impl common::ResponseResult for GoogleProtobufEmpty {}
505
506/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
507///
508/// This type is not used in any activity, and only used as *part* of another schema.
509///
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct GoogleRpcStatus {
514    /// The status code, which should be an enum value of google.rpc.Code.
515    pub code: Option<i32>,
516    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
517    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
518    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
519    pub message: Option<String>,
520}
521
522impl common::Part for GoogleRpcStatus {}
523
524// ###################
525// MethodBuilders ###
526// #################
527
528/// A builder providing access to all methods supported on *hash* resources.
529/// It is not used directly, but through the [`WebRisk`] hub.
530///
531/// # Example
532///
533/// Instantiate a resource builder
534///
535/// ```test_harness,no_run
536/// extern crate hyper;
537/// extern crate hyper_rustls;
538/// extern crate google_webrisk1 as webrisk1;
539///
540/// # async fn dox() {
541/// use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
542///
543/// let secret: yup_oauth2::ApplicationSecret = Default::default();
544/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
545///     .with_native_roots()
546///     .unwrap()
547///     .https_only()
548///     .enable_http2()
549///     .build();
550///
551/// let executor = hyper_util::rt::TokioExecutor::new();
552/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
553///     secret,
554///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
555///     yup_oauth2::client::CustomHyperClientBuilder::from(
556///         hyper_util::client::legacy::Client::builder(executor).build(connector),
557///     ),
558/// ).build().await.unwrap();
559///
560/// let client = hyper_util::client::legacy::Client::builder(
561///     hyper_util::rt::TokioExecutor::new()
562/// )
563/// .build(
564///     hyper_rustls::HttpsConnectorBuilder::new()
565///         .with_native_roots()
566///         .unwrap()
567///         .https_or_http()
568///         .enable_http2()
569///         .build()
570/// );
571/// let mut hub = WebRisk::new(client, auth);
572/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
573/// // like `search(...)`
574/// // to build up your call.
575/// let rb = hub.hashes();
576/// # }
577/// ```
578pub struct HashMethods<'a, C>
579where
580    C: 'a,
581{
582    hub: &'a WebRisk<C>,
583}
584
585impl<'a, C> common::MethodsBuilder for HashMethods<'a, C> {}
586
587impl<'a, C> HashMethods<'a, C> {
588    /// Create a builder to help you perform the following task:
589    ///
590    /// Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.
591    pub fn search(&self) -> HashSearchCall<'a, C> {
592        HashSearchCall {
593            hub: self.hub,
594            _threat_types: Default::default(),
595            _hash_prefix: Default::default(),
596            _delegate: Default::default(),
597            _additional_params: Default::default(),
598            _scopes: Default::default(),
599        }
600    }
601}
602
603/// A builder providing access to all methods supported on *project* resources.
604/// It is not used directly, but through the [`WebRisk`] hub.
605///
606/// # Example
607///
608/// Instantiate a resource builder
609///
610/// ```test_harness,no_run
611/// extern crate hyper;
612/// extern crate hyper_rustls;
613/// extern crate google_webrisk1 as webrisk1;
614///
615/// # async fn dox() {
616/// use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
617///
618/// let secret: yup_oauth2::ApplicationSecret = Default::default();
619/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
620///     .with_native_roots()
621///     .unwrap()
622///     .https_only()
623///     .enable_http2()
624///     .build();
625///
626/// let executor = hyper_util::rt::TokioExecutor::new();
627/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
628///     secret,
629///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
630///     yup_oauth2::client::CustomHyperClientBuilder::from(
631///         hyper_util::client::legacy::Client::builder(executor).build(connector),
632///     ),
633/// ).build().await.unwrap();
634///
635/// let client = hyper_util::client::legacy::Client::builder(
636///     hyper_util::rt::TokioExecutor::new()
637/// )
638/// .build(
639///     hyper_rustls::HttpsConnectorBuilder::new()
640///         .with_native_roots()
641///         .unwrap()
642///         .https_or_http()
643///         .enable_http2()
644///         .build()
645/// );
646/// let mut hub = WebRisk::new(client, auth);
647/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
648/// // like `operations_cancel(...)`, `operations_delete(...)`, `operations_get(...)`, `operations_list(...)` and `submissions_create(...)`
649/// // to build up your call.
650/// let rb = hub.projects();
651/// # }
652/// ```
653pub struct ProjectMethods<'a, C>
654where
655    C: 'a,
656{
657    hub: &'a WebRisk<C>,
658}
659
660impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
661
662impl<'a, C> ProjectMethods<'a, C> {
663    /// Create a builder to help you perform the following task:
664    ///
665    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
666    ///
667    /// # Arguments
668    ///
669    /// * `request` - No description provided.
670    /// * `name` - The name of the operation resource to be cancelled.
671    pub fn operations_cancel(
672        &self,
673        request: GoogleLongrunningCancelOperationRequest,
674        name: &str,
675    ) -> ProjectOperationCancelCall<'a, C> {
676        ProjectOperationCancelCall {
677            hub: self.hub,
678            _request: request,
679            _name: name.to_string(),
680            _delegate: Default::default(),
681            _additional_params: Default::default(),
682        }
683    }
684
685    /// Create a builder to help you perform the following task:
686    ///
687    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
688    ///
689    /// # Arguments
690    ///
691    /// * `name` - The name of the operation resource to be deleted.
692    pub fn operations_delete(&self, name: &str) -> ProjectOperationDeleteCall<'a, C> {
693        ProjectOperationDeleteCall {
694            hub: self.hub,
695            _name: name.to_string(),
696            _delegate: Default::default(),
697            _additional_params: Default::default(),
698        }
699    }
700
701    /// Create a builder to help you perform the following task:
702    ///
703    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
704    ///
705    /// # Arguments
706    ///
707    /// * `name` - The name of the operation resource.
708    pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
709        ProjectOperationGetCall {
710            hub: self.hub,
711            _name: name.to_string(),
712            _delegate: Default::default(),
713            _additional_params: Default::default(),
714            _scopes: Default::default(),
715        }
716    }
717
718    /// Create a builder to help you perform the following task:
719    ///
720    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
721    ///
722    /// # Arguments
723    ///
724    /// * `name` - The name of the operation's parent resource.
725    pub fn operations_list(&self, name: &str) -> ProjectOperationListCall<'a, C> {
726        ProjectOperationListCall {
727            hub: self.hub,
728            _name: name.to_string(),
729            _return_partial_success: Default::default(),
730            _page_token: Default::default(),
731            _page_size: Default::default(),
732            _filter: Default::default(),
733            _delegate: Default::default(),
734            _additional_params: Default::default(),
735        }
736    }
737
738    /// Create a builder to help you perform the following task:
739    ///
740    /// Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to the [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future. Only allowlisted projects can use this method during Early Access. Please reach out to Sales or your customer engineer to obtain access.
741    ///
742    /// # Arguments
743    ///
744    /// * `request` - No description provided.
745    /// * `parent` - Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}".
746    pub fn submissions_create(
747        &self,
748        request: GoogleCloudWebriskV1Submission,
749        parent: &str,
750    ) -> ProjectSubmissionCreateCall<'a, C> {
751        ProjectSubmissionCreateCall {
752            hub: self.hub,
753            _request: request,
754            _parent: parent.to_string(),
755            _delegate: Default::default(),
756            _additional_params: Default::default(),
757            _scopes: Default::default(),
758        }
759    }
760}
761
762/// A builder providing access to all methods supported on *threatList* resources.
763/// It is not used directly, but through the [`WebRisk`] hub.
764///
765/// # Example
766///
767/// Instantiate a resource builder
768///
769/// ```test_harness,no_run
770/// extern crate hyper;
771/// extern crate hyper_rustls;
772/// extern crate google_webrisk1 as webrisk1;
773///
774/// # async fn dox() {
775/// use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
776///
777/// let secret: yup_oauth2::ApplicationSecret = Default::default();
778/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
779///     .with_native_roots()
780///     .unwrap()
781///     .https_only()
782///     .enable_http2()
783///     .build();
784///
785/// let executor = hyper_util::rt::TokioExecutor::new();
786/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
787///     secret,
788///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
789///     yup_oauth2::client::CustomHyperClientBuilder::from(
790///         hyper_util::client::legacy::Client::builder(executor).build(connector),
791///     ),
792/// ).build().await.unwrap();
793///
794/// let client = hyper_util::client::legacy::Client::builder(
795///     hyper_util::rt::TokioExecutor::new()
796/// )
797/// .build(
798///     hyper_rustls::HttpsConnectorBuilder::new()
799///         .with_native_roots()
800///         .unwrap()
801///         .https_or_http()
802///         .enable_http2()
803///         .build()
804/// );
805/// let mut hub = WebRisk::new(client, auth);
806/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
807/// // like `compute_diff(...)`
808/// // to build up your call.
809/// let rb = hub.threat_lists();
810/// # }
811/// ```
812pub struct ThreatListMethods<'a, C>
813where
814    C: 'a,
815{
816    hub: &'a WebRisk<C>,
817}
818
819impl<'a, C> common::MethodsBuilder for ThreatListMethods<'a, C> {}
820
821impl<'a, C> ThreatListMethods<'a, C> {
822    /// Create a builder to help you perform the following task:
823    ///
824    /// Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once for each list.
825    pub fn compute_diff(&self) -> ThreatListComputeDiffCall<'a, C> {
826        ThreatListComputeDiffCall {
827            hub: self.hub,
828            _version_token: Default::default(),
829            _threat_type: Default::default(),
830            _constraints_supported_compressions: Default::default(),
831            _constraints_max_diff_entries: Default::default(),
832            _constraints_max_database_entries: Default::default(),
833            _delegate: Default::default(),
834            _additional_params: Default::default(),
835            _scopes: Default::default(),
836        }
837    }
838}
839
840/// A builder providing access to all methods supported on *uri* resources.
841/// It is not used directly, but through the [`WebRisk`] hub.
842///
843/// # Example
844///
845/// Instantiate a resource builder
846///
847/// ```test_harness,no_run
848/// extern crate hyper;
849/// extern crate hyper_rustls;
850/// extern crate google_webrisk1 as webrisk1;
851///
852/// # async fn dox() {
853/// use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
854///
855/// let secret: yup_oauth2::ApplicationSecret = Default::default();
856/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
857///     .with_native_roots()
858///     .unwrap()
859///     .https_only()
860///     .enable_http2()
861///     .build();
862///
863/// let executor = hyper_util::rt::TokioExecutor::new();
864/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
865///     secret,
866///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
867///     yup_oauth2::client::CustomHyperClientBuilder::from(
868///         hyper_util::client::legacy::Client::builder(executor).build(connector),
869///     ),
870/// ).build().await.unwrap();
871///
872/// let client = hyper_util::client::legacy::Client::builder(
873///     hyper_util::rt::TokioExecutor::new()
874/// )
875/// .build(
876///     hyper_rustls::HttpsConnectorBuilder::new()
877///         .with_native_roots()
878///         .unwrap()
879///         .https_or_http()
880///         .enable_http2()
881///         .build()
882/// );
883/// let mut hub = WebRisk::new(client, auth);
884/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
885/// // like `search(...)`
886/// // to build up your call.
887/// let rb = hub.uris();
888/// # }
889/// ```
890pub struct UriMethods<'a, C>
891where
892    C: 'a,
893{
894    hub: &'a WebRisk<C>,
895}
896
897impl<'a, C> common::MethodsBuilder for UriMethods<'a, C> {}
898
899impl<'a, C> UriMethods<'a, C> {
900    /// Create a builder to help you perform the following task:
901    ///
902    /// This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.
903    pub fn search(&self) -> UriSearchCall<'a, C> {
904        UriSearchCall {
905            hub: self.hub,
906            _uri: Default::default(),
907            _threat_types: Default::default(),
908            _delegate: Default::default(),
909            _additional_params: Default::default(),
910            _scopes: Default::default(),
911        }
912    }
913}
914
915// ###################
916// CallBuilders   ###
917// #################
918
919/// Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.
920///
921/// A builder for the *search* method supported by a *hash* resource.
922/// It is not used directly, but through a [`HashMethods`] instance.
923///
924/// # Example
925///
926/// Instantiate a resource method builder
927///
928/// ```test_harness,no_run
929/// # extern crate hyper;
930/// # extern crate hyper_rustls;
931/// # extern crate google_webrisk1 as webrisk1;
932/// # async fn dox() {
933/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
934///
935/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
936/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
937/// #     .with_native_roots()
938/// #     .unwrap()
939/// #     .https_only()
940/// #     .enable_http2()
941/// #     .build();
942///
943/// # let executor = hyper_util::rt::TokioExecutor::new();
944/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
945/// #     secret,
946/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
947/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
948/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
949/// #     ),
950/// # ).build().await.unwrap();
951///
952/// # let client = hyper_util::client::legacy::Client::builder(
953/// #     hyper_util::rt::TokioExecutor::new()
954/// # )
955/// # .build(
956/// #     hyper_rustls::HttpsConnectorBuilder::new()
957/// #         .with_native_roots()
958/// #         .unwrap()
959/// #         .https_or_http()
960/// #         .enable_http2()
961/// #         .build()
962/// # );
963/// # let mut hub = WebRisk::new(client, auth);
964/// // You can configure optional parameters by calling the respective setters at will, and
965/// // execute the final call using `doit()`.
966/// // Values shown here are possibly random and not representative !
967/// let result = hub.hashes().search()
968///              .add_threat_types("ipsum")
969///              .hash_prefix(vec![0, 1, 2, 3])
970///              .doit().await;
971/// # }
972/// ```
973pub struct HashSearchCall<'a, C>
974where
975    C: 'a,
976{
977    hub: &'a WebRisk<C>,
978    _threat_types: Vec<String>,
979    _hash_prefix: Option<Vec<u8>>,
980    _delegate: Option<&'a mut dyn common::Delegate>,
981    _additional_params: HashMap<String, String>,
982    _scopes: BTreeSet<String>,
983}
984
985impl<'a, C> common::CallBuilder for HashSearchCall<'a, C> {}
986
987impl<'a, C> HashSearchCall<'a, C>
988where
989    C: common::Connector,
990{
991    /// Perform the operation you have build so far.
992    pub async fn doit(
993        mut self,
994    ) -> common::Result<(common::Response, GoogleCloudWebriskV1SearchHashesResponse)> {
995        use std::borrow::Cow;
996        use std::io::{Read, Seek};
997
998        use common::{url::Params, ToParts};
999        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1000
1001        let mut dd = common::DefaultDelegate;
1002        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1003        dlg.begin(common::MethodInfo {
1004            id: "webrisk.hashes.search",
1005            http_method: hyper::Method::GET,
1006        });
1007
1008        for &field in ["alt", "threatTypes", "hashPrefix"].iter() {
1009            if self._additional_params.contains_key(field) {
1010                dlg.finished(false);
1011                return Err(common::Error::FieldClash(field));
1012            }
1013        }
1014
1015        let mut params = Params::with_capacity(4 + self._additional_params.len());
1016        if !self._threat_types.is_empty() {
1017            for f in self._threat_types.iter() {
1018                params.push("threatTypes", f);
1019            }
1020        }
1021        if let Some(value) = self._hash_prefix.as_ref() {
1022            params.push(
1023                "hashPrefix",
1024                common::serde::standard_base64::to_string(&value),
1025            );
1026        }
1027
1028        params.extend(self._additional_params.iter());
1029
1030        params.push("alt", "json");
1031        let mut url = self.hub._base_url.clone() + "v1/hashes:search";
1032        if self._scopes.is_empty() {
1033            self._scopes
1034                .insert(Scope::CloudPlatform.as_ref().to_string());
1035        }
1036
1037        let url = params.parse_with_url(&url);
1038
1039        loop {
1040            let token = match self
1041                .hub
1042                .auth
1043                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1044                .await
1045            {
1046                Ok(token) => token,
1047                Err(e) => match dlg.token(e) {
1048                    Ok(token) => token,
1049                    Err(e) => {
1050                        dlg.finished(false);
1051                        return Err(common::Error::MissingToken(e));
1052                    }
1053                },
1054            };
1055            let mut req_result = {
1056                let client = &self.hub.client;
1057                dlg.pre_request();
1058                let mut req_builder = hyper::Request::builder()
1059                    .method(hyper::Method::GET)
1060                    .uri(url.as_str())
1061                    .header(USER_AGENT, self.hub._user_agent.clone());
1062
1063                if let Some(token) = token.as_ref() {
1064                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1065                }
1066
1067                let request = req_builder
1068                    .header(CONTENT_LENGTH, 0_u64)
1069                    .body(common::to_body::<String>(None));
1070
1071                client.request(request.unwrap()).await
1072            };
1073
1074            match req_result {
1075                Err(err) => {
1076                    if let common::Retry::After(d) = dlg.http_error(&err) {
1077                        sleep(d).await;
1078                        continue;
1079                    }
1080                    dlg.finished(false);
1081                    return Err(common::Error::HttpError(err));
1082                }
1083                Ok(res) => {
1084                    let (mut parts, body) = res.into_parts();
1085                    let mut body = common::Body::new(body);
1086                    if !parts.status.is_success() {
1087                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1088                        let error = serde_json::from_str(&common::to_string(&bytes));
1089                        let response = common::to_response(parts, bytes.into());
1090
1091                        if let common::Retry::After(d) =
1092                            dlg.http_failure(&response, error.as_ref().ok())
1093                        {
1094                            sleep(d).await;
1095                            continue;
1096                        }
1097
1098                        dlg.finished(false);
1099
1100                        return Err(match error {
1101                            Ok(value) => common::Error::BadRequest(value),
1102                            _ => common::Error::Failure(response),
1103                        });
1104                    }
1105                    let response = {
1106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1107                        let encoded = common::to_string(&bytes);
1108                        match serde_json::from_str(&encoded) {
1109                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1110                            Err(error) => {
1111                                dlg.response_json_decode_error(&encoded, &error);
1112                                return Err(common::Error::JsonDecodeError(
1113                                    encoded.to_string(),
1114                                    error,
1115                                ));
1116                            }
1117                        }
1118                    };
1119
1120                    dlg.finished(true);
1121                    return Ok(response);
1122                }
1123            }
1124        }
1125    }
1126
1127    /// Required. The ThreatLists to search in. Multiple ThreatLists may be specified.
1128    ///
1129    /// Append the given value to the *threat types* query property.
1130    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
1131    pub fn add_threat_types(mut self, new_value: &str) -> HashSearchCall<'a, C> {
1132        self._threat_types.push(new_value.to_string());
1133        self
1134    }
1135    /// A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 hash. For JSON requests, this field is base64-encoded. Note that if this parameter is provided by a URI, it must be encoded using the web safe base64 variant (RFC 4648).
1136    ///
1137    /// Sets the *hash prefix* query property to the given value.
1138    pub fn hash_prefix(mut self, new_value: Vec<u8>) -> HashSearchCall<'a, C> {
1139        self._hash_prefix = Some(new_value);
1140        self
1141    }
1142    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1143    /// while executing the actual API request.
1144    ///
1145    /// ````text
1146    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1147    /// ````
1148    ///
1149    /// Sets the *delegate* property to the given value.
1150    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> HashSearchCall<'a, C> {
1151        self._delegate = Some(new_value);
1152        self
1153    }
1154
1155    /// Set any additional parameter of the query string used in the request.
1156    /// It should be used to set parameters which are not yet available through their own
1157    /// setters.
1158    ///
1159    /// Please note that this method must not be used to set any of the known parameters
1160    /// which have their own setter method. If done anyway, the request will fail.
1161    ///
1162    /// # Additional Parameters
1163    ///
1164    /// * *$.xgafv* (query-string) - V1 error format.
1165    /// * *access_token* (query-string) - OAuth access token.
1166    /// * *alt* (query-string) - Data format for response.
1167    /// * *callback* (query-string) - JSONP
1168    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1169    /// * *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.
1170    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1171    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1172    /// * *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.
1173    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1174    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1175    pub fn param<T>(mut self, name: T, value: T) -> HashSearchCall<'a, C>
1176    where
1177        T: AsRef<str>,
1178    {
1179        self._additional_params
1180            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1181        self
1182    }
1183
1184    /// Identifies the authorization scope for the method you are building.
1185    ///
1186    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1187    /// [`Scope::CloudPlatform`].
1188    ///
1189    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1190    /// tokens for more than one scope.
1191    ///
1192    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1193    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1194    /// sufficient, a read-write scope will do as well.
1195    pub fn add_scope<St>(mut self, scope: St) -> HashSearchCall<'a, C>
1196    where
1197        St: AsRef<str>,
1198    {
1199        self._scopes.insert(String::from(scope.as_ref()));
1200        self
1201    }
1202    /// Identifies the authorization scope(s) for the method you are building.
1203    ///
1204    /// See [`Self::add_scope()`] for details.
1205    pub fn add_scopes<I, St>(mut self, scopes: I) -> HashSearchCall<'a, C>
1206    where
1207        I: IntoIterator<Item = St>,
1208        St: AsRef<str>,
1209    {
1210        self._scopes
1211            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1212        self
1213    }
1214
1215    /// Removes all scopes, and no default scope will be used either.
1216    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1217    /// for details).
1218    pub fn clear_scopes(mut self) -> HashSearchCall<'a, C> {
1219        self._scopes.clear();
1220        self
1221    }
1222}
1223
1224/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
1225///
1226/// A builder for the *operations.cancel* method supported by a *project* resource.
1227/// It is not used directly, but through a [`ProjectMethods`] instance.
1228///
1229/// # Example
1230///
1231/// Instantiate a resource method builder
1232///
1233/// ```test_harness,no_run
1234/// # extern crate hyper;
1235/// # extern crate hyper_rustls;
1236/// # extern crate google_webrisk1 as webrisk1;
1237/// use webrisk1::api::GoogleLongrunningCancelOperationRequest;
1238/// # async fn dox() {
1239/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1240///
1241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1242/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1243/// #     .with_native_roots()
1244/// #     .unwrap()
1245/// #     .https_only()
1246/// #     .enable_http2()
1247/// #     .build();
1248///
1249/// # let executor = hyper_util::rt::TokioExecutor::new();
1250/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1251/// #     secret,
1252/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1253/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1254/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1255/// #     ),
1256/// # ).build().await.unwrap();
1257///
1258/// # let client = hyper_util::client::legacy::Client::builder(
1259/// #     hyper_util::rt::TokioExecutor::new()
1260/// # )
1261/// # .build(
1262/// #     hyper_rustls::HttpsConnectorBuilder::new()
1263/// #         .with_native_roots()
1264/// #         .unwrap()
1265/// #         .https_or_http()
1266/// #         .enable_http2()
1267/// #         .build()
1268/// # );
1269/// # let mut hub = WebRisk::new(client, auth);
1270/// // As the method needs a request, you would usually fill it with the desired information
1271/// // into the respective structure. Some of the parts shown here might not be applicable !
1272/// // Values shown here are possibly random and not representative !
1273/// let mut req = GoogleLongrunningCancelOperationRequest::default();
1274///
1275/// // You can configure optional parameters by calling the respective setters at will, and
1276/// // execute the final call using `doit()`.
1277/// // Values shown here are possibly random and not representative !
1278/// let result = hub.projects().operations_cancel(req, "name")
1279///              .doit().await;
1280/// # }
1281/// ```
1282pub struct ProjectOperationCancelCall<'a, C>
1283where
1284    C: 'a,
1285{
1286    hub: &'a WebRisk<C>,
1287    _request: GoogleLongrunningCancelOperationRequest,
1288    _name: String,
1289    _delegate: Option<&'a mut dyn common::Delegate>,
1290    _additional_params: HashMap<String, String>,
1291}
1292
1293impl<'a, C> common::CallBuilder for ProjectOperationCancelCall<'a, C> {}
1294
1295impl<'a, C> ProjectOperationCancelCall<'a, C>
1296where
1297    C: common::Connector,
1298{
1299    /// Perform the operation you have build so far.
1300    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
1301        use std::borrow::Cow;
1302        use std::io::{Read, Seek};
1303
1304        use common::{url::Params, ToParts};
1305        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1306
1307        let mut dd = common::DefaultDelegate;
1308        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1309        dlg.begin(common::MethodInfo {
1310            id: "webrisk.projects.operations.cancel",
1311            http_method: hyper::Method::POST,
1312        });
1313
1314        for &field in ["alt", "name"].iter() {
1315            if self._additional_params.contains_key(field) {
1316                dlg.finished(false);
1317                return Err(common::Error::FieldClash(field));
1318            }
1319        }
1320
1321        let mut params = Params::with_capacity(4 + self._additional_params.len());
1322        params.push("name", self._name);
1323
1324        params.extend(self._additional_params.iter());
1325
1326        params.push("alt", "json");
1327        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
1328
1329        match dlg.api_key() {
1330            Some(value) => params.push("key", value),
1331            None => {
1332                dlg.finished(false);
1333                return Err(common::Error::MissingAPIKey);
1334            }
1335        }
1336
1337        #[allow(clippy::single_element_loop)]
1338        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1339            url = params.uri_replacement(url, param_name, find_this, true);
1340        }
1341        {
1342            let to_remove = ["name"];
1343            params.remove_params(&to_remove);
1344        }
1345
1346        let url = params.parse_with_url(&url);
1347
1348        let mut json_mime_type = mime::APPLICATION_JSON;
1349        let mut request_value_reader = {
1350            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1351            common::remove_json_null_values(&mut value);
1352            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1353            serde_json::to_writer(&mut dst, &value).unwrap();
1354            dst
1355        };
1356        let request_size = request_value_reader
1357            .seek(std::io::SeekFrom::End(0))
1358            .unwrap();
1359        request_value_reader
1360            .seek(std::io::SeekFrom::Start(0))
1361            .unwrap();
1362
1363        loop {
1364            request_value_reader
1365                .seek(std::io::SeekFrom::Start(0))
1366                .unwrap();
1367            let mut req_result = {
1368                let client = &self.hub.client;
1369                dlg.pre_request();
1370                let mut req_builder = hyper::Request::builder()
1371                    .method(hyper::Method::POST)
1372                    .uri(url.as_str())
1373                    .header(USER_AGENT, self.hub._user_agent.clone());
1374
1375                let request = req_builder
1376                    .header(CONTENT_TYPE, json_mime_type.to_string())
1377                    .header(CONTENT_LENGTH, request_size as u64)
1378                    .body(common::to_body(
1379                        request_value_reader.get_ref().clone().into(),
1380                    ));
1381
1382                client.request(request.unwrap()).await
1383            };
1384
1385            match req_result {
1386                Err(err) => {
1387                    if let common::Retry::After(d) = dlg.http_error(&err) {
1388                        sleep(d).await;
1389                        continue;
1390                    }
1391                    dlg.finished(false);
1392                    return Err(common::Error::HttpError(err));
1393                }
1394                Ok(res) => {
1395                    let (mut parts, body) = res.into_parts();
1396                    let mut body = common::Body::new(body);
1397                    if !parts.status.is_success() {
1398                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1399                        let error = serde_json::from_str(&common::to_string(&bytes));
1400                        let response = common::to_response(parts, bytes.into());
1401
1402                        if let common::Retry::After(d) =
1403                            dlg.http_failure(&response, error.as_ref().ok())
1404                        {
1405                            sleep(d).await;
1406                            continue;
1407                        }
1408
1409                        dlg.finished(false);
1410
1411                        return Err(match error {
1412                            Ok(value) => common::Error::BadRequest(value),
1413                            _ => common::Error::Failure(response),
1414                        });
1415                    }
1416                    let response = {
1417                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1418                        let encoded = common::to_string(&bytes);
1419                        match serde_json::from_str(&encoded) {
1420                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1421                            Err(error) => {
1422                                dlg.response_json_decode_error(&encoded, &error);
1423                                return Err(common::Error::JsonDecodeError(
1424                                    encoded.to_string(),
1425                                    error,
1426                                ));
1427                            }
1428                        }
1429                    };
1430
1431                    dlg.finished(true);
1432                    return Ok(response);
1433                }
1434            }
1435        }
1436    }
1437
1438    ///
1439    /// Sets the *request* property to the given value.
1440    ///
1441    /// Even though the property as already been set when instantiating this call,
1442    /// we provide this method for API completeness.
1443    pub fn request(
1444        mut self,
1445        new_value: GoogleLongrunningCancelOperationRequest,
1446    ) -> ProjectOperationCancelCall<'a, C> {
1447        self._request = new_value;
1448        self
1449    }
1450    /// The name of the operation resource to be cancelled.
1451    ///
1452    /// Sets the *name* path property to the given value.
1453    ///
1454    /// Even though the property as already been set when instantiating this call,
1455    /// we provide this method for API completeness.
1456    pub fn name(mut self, new_value: &str) -> ProjectOperationCancelCall<'a, C> {
1457        self._name = new_value.to_string();
1458        self
1459    }
1460    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1461    /// while executing the actual API request.
1462    ///
1463    /// ````text
1464    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1465    /// ````
1466    ///
1467    /// Sets the *delegate* property to the given value.
1468    pub fn delegate(
1469        mut self,
1470        new_value: &'a mut dyn common::Delegate,
1471    ) -> ProjectOperationCancelCall<'a, C> {
1472        self._delegate = Some(new_value);
1473        self
1474    }
1475
1476    /// Set any additional parameter of the query string used in the request.
1477    /// It should be used to set parameters which are not yet available through their own
1478    /// setters.
1479    ///
1480    /// Please note that this method must not be used to set any of the known parameters
1481    /// which have their own setter method. If done anyway, the request will fail.
1482    ///
1483    /// # Additional Parameters
1484    ///
1485    /// * *$.xgafv* (query-string) - V1 error format.
1486    /// * *access_token* (query-string) - OAuth access token.
1487    /// * *alt* (query-string) - Data format for response.
1488    /// * *callback* (query-string) - JSONP
1489    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1490    /// * *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.
1491    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1492    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1493    /// * *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.
1494    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1495    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1496    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationCancelCall<'a, C>
1497    where
1498        T: AsRef<str>,
1499    {
1500        self._additional_params
1501            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1502        self
1503    }
1504}
1505
1506/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
1507///
1508/// A builder for the *operations.delete* method supported by a *project* resource.
1509/// It is not used directly, but through a [`ProjectMethods`] instance.
1510///
1511/// # Example
1512///
1513/// Instantiate a resource method builder
1514///
1515/// ```test_harness,no_run
1516/// # extern crate hyper;
1517/// # extern crate hyper_rustls;
1518/// # extern crate google_webrisk1 as webrisk1;
1519/// # async fn dox() {
1520/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1521///
1522/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1523/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1524/// #     .with_native_roots()
1525/// #     .unwrap()
1526/// #     .https_only()
1527/// #     .enable_http2()
1528/// #     .build();
1529///
1530/// # let executor = hyper_util::rt::TokioExecutor::new();
1531/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1532/// #     secret,
1533/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1534/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1535/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1536/// #     ),
1537/// # ).build().await.unwrap();
1538///
1539/// # let client = hyper_util::client::legacy::Client::builder(
1540/// #     hyper_util::rt::TokioExecutor::new()
1541/// # )
1542/// # .build(
1543/// #     hyper_rustls::HttpsConnectorBuilder::new()
1544/// #         .with_native_roots()
1545/// #         .unwrap()
1546/// #         .https_or_http()
1547/// #         .enable_http2()
1548/// #         .build()
1549/// # );
1550/// # let mut hub = WebRisk::new(client, auth);
1551/// // You can configure optional parameters by calling the respective setters at will, and
1552/// // execute the final call using `doit()`.
1553/// // Values shown here are possibly random and not representative !
1554/// let result = hub.projects().operations_delete("name")
1555///              .doit().await;
1556/// # }
1557/// ```
1558pub struct ProjectOperationDeleteCall<'a, C>
1559where
1560    C: 'a,
1561{
1562    hub: &'a WebRisk<C>,
1563    _name: String,
1564    _delegate: Option<&'a mut dyn common::Delegate>,
1565    _additional_params: HashMap<String, String>,
1566}
1567
1568impl<'a, C> common::CallBuilder for ProjectOperationDeleteCall<'a, C> {}
1569
1570impl<'a, C> ProjectOperationDeleteCall<'a, C>
1571where
1572    C: common::Connector,
1573{
1574    /// Perform the operation you have build so far.
1575    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
1576        use std::borrow::Cow;
1577        use std::io::{Read, Seek};
1578
1579        use common::{url::Params, ToParts};
1580        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1581
1582        let mut dd = common::DefaultDelegate;
1583        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1584        dlg.begin(common::MethodInfo {
1585            id: "webrisk.projects.operations.delete",
1586            http_method: hyper::Method::DELETE,
1587        });
1588
1589        for &field in ["alt", "name"].iter() {
1590            if self._additional_params.contains_key(field) {
1591                dlg.finished(false);
1592                return Err(common::Error::FieldClash(field));
1593            }
1594        }
1595
1596        let mut params = Params::with_capacity(3 + self._additional_params.len());
1597        params.push("name", self._name);
1598
1599        params.extend(self._additional_params.iter());
1600
1601        params.push("alt", "json");
1602        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1603
1604        match dlg.api_key() {
1605            Some(value) => params.push("key", value),
1606            None => {
1607                dlg.finished(false);
1608                return Err(common::Error::MissingAPIKey);
1609            }
1610        }
1611
1612        #[allow(clippy::single_element_loop)]
1613        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1614            url = params.uri_replacement(url, param_name, find_this, true);
1615        }
1616        {
1617            let to_remove = ["name"];
1618            params.remove_params(&to_remove);
1619        }
1620
1621        let url = params.parse_with_url(&url);
1622
1623        loop {
1624            let mut req_result = {
1625                let client = &self.hub.client;
1626                dlg.pre_request();
1627                let mut req_builder = hyper::Request::builder()
1628                    .method(hyper::Method::DELETE)
1629                    .uri(url.as_str())
1630                    .header(USER_AGENT, self.hub._user_agent.clone());
1631
1632                let request = req_builder
1633                    .header(CONTENT_LENGTH, 0_u64)
1634                    .body(common::to_body::<String>(None));
1635
1636                client.request(request.unwrap()).await
1637            };
1638
1639            match req_result {
1640                Err(err) => {
1641                    if let common::Retry::After(d) = dlg.http_error(&err) {
1642                        sleep(d).await;
1643                        continue;
1644                    }
1645                    dlg.finished(false);
1646                    return Err(common::Error::HttpError(err));
1647                }
1648                Ok(res) => {
1649                    let (mut parts, body) = res.into_parts();
1650                    let mut body = common::Body::new(body);
1651                    if !parts.status.is_success() {
1652                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1653                        let error = serde_json::from_str(&common::to_string(&bytes));
1654                        let response = common::to_response(parts, bytes.into());
1655
1656                        if let common::Retry::After(d) =
1657                            dlg.http_failure(&response, error.as_ref().ok())
1658                        {
1659                            sleep(d).await;
1660                            continue;
1661                        }
1662
1663                        dlg.finished(false);
1664
1665                        return Err(match error {
1666                            Ok(value) => common::Error::BadRequest(value),
1667                            _ => common::Error::Failure(response),
1668                        });
1669                    }
1670                    let response = {
1671                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1672                        let encoded = common::to_string(&bytes);
1673                        match serde_json::from_str(&encoded) {
1674                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1675                            Err(error) => {
1676                                dlg.response_json_decode_error(&encoded, &error);
1677                                return Err(common::Error::JsonDecodeError(
1678                                    encoded.to_string(),
1679                                    error,
1680                                ));
1681                            }
1682                        }
1683                    };
1684
1685                    dlg.finished(true);
1686                    return Ok(response);
1687                }
1688            }
1689        }
1690    }
1691
1692    /// The name of the operation resource to be deleted.
1693    ///
1694    /// Sets the *name* path property to the given value.
1695    ///
1696    /// Even though the property as already been set when instantiating this call,
1697    /// we provide this method for API completeness.
1698    pub fn name(mut self, new_value: &str) -> ProjectOperationDeleteCall<'a, C> {
1699        self._name = new_value.to_string();
1700        self
1701    }
1702    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1703    /// while executing the actual API request.
1704    ///
1705    /// ````text
1706    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1707    /// ````
1708    ///
1709    /// Sets the *delegate* property to the given value.
1710    pub fn delegate(
1711        mut self,
1712        new_value: &'a mut dyn common::Delegate,
1713    ) -> ProjectOperationDeleteCall<'a, C> {
1714        self._delegate = Some(new_value);
1715        self
1716    }
1717
1718    /// Set any additional parameter of the query string used in the request.
1719    /// It should be used to set parameters which are not yet available through their own
1720    /// setters.
1721    ///
1722    /// Please note that this method must not be used to set any of the known parameters
1723    /// which have their own setter method. If done anyway, the request will fail.
1724    ///
1725    /// # Additional Parameters
1726    ///
1727    /// * *$.xgafv* (query-string) - V1 error format.
1728    /// * *access_token* (query-string) - OAuth access token.
1729    /// * *alt* (query-string) - Data format for response.
1730    /// * *callback* (query-string) - JSONP
1731    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1732    /// * *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.
1733    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1734    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1735    /// * *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.
1736    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1737    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1738    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationDeleteCall<'a, C>
1739    where
1740        T: AsRef<str>,
1741    {
1742        self._additional_params
1743            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1744        self
1745    }
1746}
1747
1748/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1749///
1750/// A builder for the *operations.get* method supported by a *project* resource.
1751/// It is not used directly, but through a [`ProjectMethods`] instance.
1752///
1753/// # Example
1754///
1755/// Instantiate a resource method builder
1756///
1757/// ```test_harness,no_run
1758/// # extern crate hyper;
1759/// # extern crate hyper_rustls;
1760/// # extern crate google_webrisk1 as webrisk1;
1761/// # async fn dox() {
1762/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1763///
1764/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1765/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1766/// #     .with_native_roots()
1767/// #     .unwrap()
1768/// #     .https_only()
1769/// #     .enable_http2()
1770/// #     .build();
1771///
1772/// # let executor = hyper_util::rt::TokioExecutor::new();
1773/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1774/// #     secret,
1775/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1776/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1777/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1778/// #     ),
1779/// # ).build().await.unwrap();
1780///
1781/// # let client = hyper_util::client::legacy::Client::builder(
1782/// #     hyper_util::rt::TokioExecutor::new()
1783/// # )
1784/// # .build(
1785/// #     hyper_rustls::HttpsConnectorBuilder::new()
1786/// #         .with_native_roots()
1787/// #         .unwrap()
1788/// #         .https_or_http()
1789/// #         .enable_http2()
1790/// #         .build()
1791/// # );
1792/// # let mut hub = WebRisk::new(client, auth);
1793/// // You can configure optional parameters by calling the respective setters at will, and
1794/// // execute the final call using `doit()`.
1795/// // Values shown here are possibly random and not representative !
1796/// let result = hub.projects().operations_get("name")
1797///              .doit().await;
1798/// # }
1799/// ```
1800pub struct ProjectOperationGetCall<'a, C>
1801where
1802    C: 'a,
1803{
1804    hub: &'a WebRisk<C>,
1805    _name: String,
1806    _delegate: Option<&'a mut dyn common::Delegate>,
1807    _additional_params: HashMap<String, String>,
1808    _scopes: BTreeSet<String>,
1809}
1810
1811impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
1812
1813impl<'a, C> ProjectOperationGetCall<'a, C>
1814where
1815    C: common::Connector,
1816{
1817    /// Perform the operation you have build so far.
1818    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
1819        use std::borrow::Cow;
1820        use std::io::{Read, Seek};
1821
1822        use common::{url::Params, ToParts};
1823        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1824
1825        let mut dd = common::DefaultDelegate;
1826        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1827        dlg.begin(common::MethodInfo {
1828            id: "webrisk.projects.operations.get",
1829            http_method: hyper::Method::GET,
1830        });
1831
1832        for &field in ["alt", "name"].iter() {
1833            if self._additional_params.contains_key(field) {
1834                dlg.finished(false);
1835                return Err(common::Error::FieldClash(field));
1836            }
1837        }
1838
1839        let mut params = Params::with_capacity(3 + self._additional_params.len());
1840        params.push("name", self._name);
1841
1842        params.extend(self._additional_params.iter());
1843
1844        params.push("alt", "json");
1845        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1846        if self._scopes.is_empty() {
1847            self._scopes
1848                .insert(Scope::CloudPlatform.as_ref().to_string());
1849        }
1850
1851        #[allow(clippy::single_element_loop)]
1852        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1853            url = params.uri_replacement(url, param_name, find_this, true);
1854        }
1855        {
1856            let to_remove = ["name"];
1857            params.remove_params(&to_remove);
1858        }
1859
1860        let url = params.parse_with_url(&url);
1861
1862        loop {
1863            let token = match self
1864                .hub
1865                .auth
1866                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1867                .await
1868            {
1869                Ok(token) => token,
1870                Err(e) => match dlg.token(e) {
1871                    Ok(token) => token,
1872                    Err(e) => {
1873                        dlg.finished(false);
1874                        return Err(common::Error::MissingToken(e));
1875                    }
1876                },
1877            };
1878            let mut req_result = {
1879                let client = &self.hub.client;
1880                dlg.pre_request();
1881                let mut req_builder = hyper::Request::builder()
1882                    .method(hyper::Method::GET)
1883                    .uri(url.as_str())
1884                    .header(USER_AGENT, self.hub._user_agent.clone());
1885
1886                if let Some(token) = token.as_ref() {
1887                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1888                }
1889
1890                let request = req_builder
1891                    .header(CONTENT_LENGTH, 0_u64)
1892                    .body(common::to_body::<String>(None));
1893
1894                client.request(request.unwrap()).await
1895            };
1896
1897            match req_result {
1898                Err(err) => {
1899                    if let common::Retry::After(d) = dlg.http_error(&err) {
1900                        sleep(d).await;
1901                        continue;
1902                    }
1903                    dlg.finished(false);
1904                    return Err(common::Error::HttpError(err));
1905                }
1906                Ok(res) => {
1907                    let (mut parts, body) = res.into_parts();
1908                    let mut body = common::Body::new(body);
1909                    if !parts.status.is_success() {
1910                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1911                        let error = serde_json::from_str(&common::to_string(&bytes));
1912                        let response = common::to_response(parts, bytes.into());
1913
1914                        if let common::Retry::After(d) =
1915                            dlg.http_failure(&response, error.as_ref().ok())
1916                        {
1917                            sleep(d).await;
1918                            continue;
1919                        }
1920
1921                        dlg.finished(false);
1922
1923                        return Err(match error {
1924                            Ok(value) => common::Error::BadRequest(value),
1925                            _ => common::Error::Failure(response),
1926                        });
1927                    }
1928                    let response = {
1929                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1930                        let encoded = common::to_string(&bytes);
1931                        match serde_json::from_str(&encoded) {
1932                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1933                            Err(error) => {
1934                                dlg.response_json_decode_error(&encoded, &error);
1935                                return Err(common::Error::JsonDecodeError(
1936                                    encoded.to_string(),
1937                                    error,
1938                                ));
1939                            }
1940                        }
1941                    };
1942
1943                    dlg.finished(true);
1944                    return Ok(response);
1945                }
1946            }
1947        }
1948    }
1949
1950    /// The name of the operation resource.
1951    ///
1952    /// Sets the *name* path property to the given value.
1953    ///
1954    /// Even though the property as already been set when instantiating this call,
1955    /// we provide this method for API completeness.
1956    pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
1957        self._name = new_value.to_string();
1958        self
1959    }
1960    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1961    /// while executing the actual API request.
1962    ///
1963    /// ````text
1964    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1965    /// ````
1966    ///
1967    /// Sets the *delegate* property to the given value.
1968    pub fn delegate(
1969        mut self,
1970        new_value: &'a mut dyn common::Delegate,
1971    ) -> ProjectOperationGetCall<'a, C> {
1972        self._delegate = Some(new_value);
1973        self
1974    }
1975
1976    /// Set any additional parameter of the query string used in the request.
1977    /// It should be used to set parameters which are not yet available through their own
1978    /// setters.
1979    ///
1980    /// Please note that this method must not be used to set any of the known parameters
1981    /// which have their own setter method. If done anyway, the request will fail.
1982    ///
1983    /// # Additional Parameters
1984    ///
1985    /// * *$.xgafv* (query-string) - V1 error format.
1986    /// * *access_token* (query-string) - OAuth access token.
1987    /// * *alt* (query-string) - Data format for response.
1988    /// * *callback* (query-string) - JSONP
1989    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1990    /// * *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.
1991    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1992    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1993    /// * *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.
1994    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1995    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1996    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
1997    where
1998        T: AsRef<str>,
1999    {
2000        self._additional_params
2001            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2002        self
2003    }
2004
2005    /// Identifies the authorization scope for the method you are building.
2006    ///
2007    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2008    /// [`Scope::CloudPlatform`].
2009    ///
2010    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2011    /// tokens for more than one scope.
2012    ///
2013    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2014    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2015    /// sufficient, a read-write scope will do as well.
2016    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
2017    where
2018        St: AsRef<str>,
2019    {
2020        self._scopes.insert(String::from(scope.as_ref()));
2021        self
2022    }
2023    /// Identifies the authorization scope(s) for the method you are building.
2024    ///
2025    /// See [`Self::add_scope()`] for details.
2026    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
2027    where
2028        I: IntoIterator<Item = St>,
2029        St: AsRef<str>,
2030    {
2031        self._scopes
2032            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2033        self
2034    }
2035
2036    /// Removes all scopes, and no default scope will be used either.
2037    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2038    /// for details).
2039    pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
2040        self._scopes.clear();
2041        self
2042    }
2043}
2044
2045/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2046///
2047/// A builder for the *operations.list* method supported by a *project* resource.
2048/// It is not used directly, but through a [`ProjectMethods`] instance.
2049///
2050/// # Example
2051///
2052/// Instantiate a resource method builder
2053///
2054/// ```test_harness,no_run
2055/// # extern crate hyper;
2056/// # extern crate hyper_rustls;
2057/// # extern crate google_webrisk1 as webrisk1;
2058/// # async fn dox() {
2059/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2060///
2061/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2062/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2063/// #     .with_native_roots()
2064/// #     .unwrap()
2065/// #     .https_only()
2066/// #     .enable_http2()
2067/// #     .build();
2068///
2069/// # let executor = hyper_util::rt::TokioExecutor::new();
2070/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2071/// #     secret,
2072/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2073/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2074/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2075/// #     ),
2076/// # ).build().await.unwrap();
2077///
2078/// # let client = hyper_util::client::legacy::Client::builder(
2079/// #     hyper_util::rt::TokioExecutor::new()
2080/// # )
2081/// # .build(
2082/// #     hyper_rustls::HttpsConnectorBuilder::new()
2083/// #         .with_native_roots()
2084/// #         .unwrap()
2085/// #         .https_or_http()
2086/// #         .enable_http2()
2087/// #         .build()
2088/// # );
2089/// # let mut hub = WebRisk::new(client, auth);
2090/// // You can configure optional parameters by calling the respective setters at will, and
2091/// // execute the final call using `doit()`.
2092/// // Values shown here are possibly random and not representative !
2093/// let result = hub.projects().operations_list("name")
2094///              .return_partial_success(true)
2095///              .page_token("amet.")
2096///              .page_size(-20)
2097///              .filter("ipsum")
2098///              .doit().await;
2099/// # }
2100/// ```
2101pub struct ProjectOperationListCall<'a, C>
2102where
2103    C: 'a,
2104{
2105    hub: &'a WebRisk<C>,
2106    _name: String,
2107    _return_partial_success: Option<bool>,
2108    _page_token: Option<String>,
2109    _page_size: Option<i32>,
2110    _filter: Option<String>,
2111    _delegate: Option<&'a mut dyn common::Delegate>,
2112    _additional_params: HashMap<String, String>,
2113}
2114
2115impl<'a, C> common::CallBuilder for ProjectOperationListCall<'a, C> {}
2116
2117impl<'a, C> ProjectOperationListCall<'a, C>
2118where
2119    C: common::Connector,
2120{
2121    /// Perform the operation you have build so far.
2122    pub async fn doit(
2123        mut self,
2124    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
2125        use std::borrow::Cow;
2126        use std::io::{Read, Seek};
2127
2128        use common::{url::Params, ToParts};
2129        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2130
2131        let mut dd = common::DefaultDelegate;
2132        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2133        dlg.begin(common::MethodInfo {
2134            id: "webrisk.projects.operations.list",
2135            http_method: hyper::Method::GET,
2136        });
2137
2138        for &field in [
2139            "alt",
2140            "name",
2141            "returnPartialSuccess",
2142            "pageToken",
2143            "pageSize",
2144            "filter",
2145        ]
2146        .iter()
2147        {
2148            if self._additional_params.contains_key(field) {
2149                dlg.finished(false);
2150                return Err(common::Error::FieldClash(field));
2151            }
2152        }
2153
2154        let mut params = Params::with_capacity(7 + self._additional_params.len());
2155        params.push("name", self._name);
2156        if let Some(value) = self._return_partial_success.as_ref() {
2157            params.push("returnPartialSuccess", value.to_string());
2158        }
2159        if let Some(value) = self._page_token.as_ref() {
2160            params.push("pageToken", value);
2161        }
2162        if let Some(value) = self._page_size.as_ref() {
2163            params.push("pageSize", value.to_string());
2164        }
2165        if let Some(value) = self._filter.as_ref() {
2166            params.push("filter", value);
2167        }
2168
2169        params.extend(self._additional_params.iter());
2170
2171        params.push("alt", "json");
2172        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
2173
2174        match dlg.api_key() {
2175            Some(value) => params.push("key", value),
2176            None => {
2177                dlg.finished(false);
2178                return Err(common::Error::MissingAPIKey);
2179            }
2180        }
2181
2182        #[allow(clippy::single_element_loop)]
2183        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2184            url = params.uri_replacement(url, param_name, find_this, true);
2185        }
2186        {
2187            let to_remove = ["name"];
2188            params.remove_params(&to_remove);
2189        }
2190
2191        let url = params.parse_with_url(&url);
2192
2193        loop {
2194            let mut req_result = {
2195                let client = &self.hub.client;
2196                dlg.pre_request();
2197                let mut req_builder = hyper::Request::builder()
2198                    .method(hyper::Method::GET)
2199                    .uri(url.as_str())
2200                    .header(USER_AGENT, self.hub._user_agent.clone());
2201
2202                let request = req_builder
2203                    .header(CONTENT_LENGTH, 0_u64)
2204                    .body(common::to_body::<String>(None));
2205
2206                client.request(request.unwrap()).await
2207            };
2208
2209            match req_result {
2210                Err(err) => {
2211                    if let common::Retry::After(d) = dlg.http_error(&err) {
2212                        sleep(d).await;
2213                        continue;
2214                    }
2215                    dlg.finished(false);
2216                    return Err(common::Error::HttpError(err));
2217                }
2218                Ok(res) => {
2219                    let (mut parts, body) = res.into_parts();
2220                    let mut body = common::Body::new(body);
2221                    if !parts.status.is_success() {
2222                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2223                        let error = serde_json::from_str(&common::to_string(&bytes));
2224                        let response = common::to_response(parts, bytes.into());
2225
2226                        if let common::Retry::After(d) =
2227                            dlg.http_failure(&response, error.as_ref().ok())
2228                        {
2229                            sleep(d).await;
2230                            continue;
2231                        }
2232
2233                        dlg.finished(false);
2234
2235                        return Err(match error {
2236                            Ok(value) => common::Error::BadRequest(value),
2237                            _ => common::Error::Failure(response),
2238                        });
2239                    }
2240                    let response = {
2241                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2242                        let encoded = common::to_string(&bytes);
2243                        match serde_json::from_str(&encoded) {
2244                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2245                            Err(error) => {
2246                                dlg.response_json_decode_error(&encoded, &error);
2247                                return Err(common::Error::JsonDecodeError(
2248                                    encoded.to_string(),
2249                                    error,
2250                                ));
2251                            }
2252                        }
2253                    };
2254
2255                    dlg.finished(true);
2256                    return Ok(response);
2257                }
2258            }
2259        }
2260    }
2261
2262    /// The name of the operation's parent resource.
2263    ///
2264    /// Sets the *name* path property to the given value.
2265    ///
2266    /// Even though the property as already been set when instantiating this call,
2267    /// we provide this method for API completeness.
2268    pub fn name(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
2269        self._name = new_value.to_string();
2270        self
2271    }
2272    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
2273    ///
2274    /// Sets the *return partial success* query property to the given value.
2275    pub fn return_partial_success(mut self, new_value: bool) -> ProjectOperationListCall<'a, C> {
2276        self._return_partial_success = Some(new_value);
2277        self
2278    }
2279    /// The standard list page token.
2280    ///
2281    /// Sets the *page token* query property to the given value.
2282    pub fn page_token(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
2283        self._page_token = Some(new_value.to_string());
2284        self
2285    }
2286    /// The standard list page size.
2287    ///
2288    /// Sets the *page size* query property to the given value.
2289    pub fn page_size(mut self, new_value: i32) -> ProjectOperationListCall<'a, C> {
2290        self._page_size = Some(new_value);
2291        self
2292    }
2293    /// The standard list filter.
2294    ///
2295    /// Sets the *filter* query property to the given value.
2296    pub fn filter(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
2297        self._filter = Some(new_value.to_string());
2298        self
2299    }
2300    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2301    /// while executing the actual API request.
2302    ///
2303    /// ````text
2304    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2305    /// ````
2306    ///
2307    /// Sets the *delegate* property to the given value.
2308    pub fn delegate(
2309        mut self,
2310        new_value: &'a mut dyn common::Delegate,
2311    ) -> ProjectOperationListCall<'a, C> {
2312        self._delegate = Some(new_value);
2313        self
2314    }
2315
2316    /// Set any additional parameter of the query string used in the request.
2317    /// It should be used to set parameters which are not yet available through their own
2318    /// setters.
2319    ///
2320    /// Please note that this method must not be used to set any of the known parameters
2321    /// which have their own setter method. If done anyway, the request will fail.
2322    ///
2323    /// # Additional Parameters
2324    ///
2325    /// * *$.xgafv* (query-string) - V1 error format.
2326    /// * *access_token* (query-string) - OAuth access token.
2327    /// * *alt* (query-string) - Data format for response.
2328    /// * *callback* (query-string) - JSONP
2329    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2330    /// * *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.
2331    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2332    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2333    /// * *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.
2334    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2335    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2336    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationListCall<'a, C>
2337    where
2338        T: AsRef<str>,
2339    {
2340        self._additional_params
2341            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2342        self
2343    }
2344}
2345
2346/// Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to the [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future. Only allowlisted projects can use this method during Early Access. Please reach out to Sales or your customer engineer to obtain access.
2347///
2348/// A builder for the *submissions.create* method supported by a *project* resource.
2349/// It is not used directly, but through a [`ProjectMethods`] instance.
2350///
2351/// # Example
2352///
2353/// Instantiate a resource method builder
2354///
2355/// ```test_harness,no_run
2356/// # extern crate hyper;
2357/// # extern crate hyper_rustls;
2358/// # extern crate google_webrisk1 as webrisk1;
2359/// use webrisk1::api::GoogleCloudWebriskV1Submission;
2360/// # async fn dox() {
2361/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2362///
2363/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2364/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2365/// #     .with_native_roots()
2366/// #     .unwrap()
2367/// #     .https_only()
2368/// #     .enable_http2()
2369/// #     .build();
2370///
2371/// # let executor = hyper_util::rt::TokioExecutor::new();
2372/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2373/// #     secret,
2374/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2375/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2376/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2377/// #     ),
2378/// # ).build().await.unwrap();
2379///
2380/// # let client = hyper_util::client::legacy::Client::builder(
2381/// #     hyper_util::rt::TokioExecutor::new()
2382/// # )
2383/// # .build(
2384/// #     hyper_rustls::HttpsConnectorBuilder::new()
2385/// #         .with_native_roots()
2386/// #         .unwrap()
2387/// #         .https_or_http()
2388/// #         .enable_http2()
2389/// #         .build()
2390/// # );
2391/// # let mut hub = WebRisk::new(client, auth);
2392/// // As the method needs a request, you would usually fill it with the desired information
2393/// // into the respective structure. Some of the parts shown here might not be applicable !
2394/// // Values shown here are possibly random and not representative !
2395/// let mut req = GoogleCloudWebriskV1Submission::default();
2396///
2397/// // You can configure optional parameters by calling the respective setters at will, and
2398/// // execute the final call using `doit()`.
2399/// // Values shown here are possibly random and not representative !
2400/// let result = hub.projects().submissions_create(req, "parent")
2401///              .doit().await;
2402/// # }
2403/// ```
2404pub struct ProjectSubmissionCreateCall<'a, C>
2405where
2406    C: 'a,
2407{
2408    hub: &'a WebRisk<C>,
2409    _request: GoogleCloudWebriskV1Submission,
2410    _parent: String,
2411    _delegate: Option<&'a mut dyn common::Delegate>,
2412    _additional_params: HashMap<String, String>,
2413    _scopes: BTreeSet<String>,
2414}
2415
2416impl<'a, C> common::CallBuilder for ProjectSubmissionCreateCall<'a, C> {}
2417
2418impl<'a, C> ProjectSubmissionCreateCall<'a, C>
2419where
2420    C: common::Connector,
2421{
2422    /// Perform the operation you have build so far.
2423    pub async fn doit(
2424        mut self,
2425    ) -> common::Result<(common::Response, GoogleCloudWebriskV1Submission)> {
2426        use std::borrow::Cow;
2427        use std::io::{Read, Seek};
2428
2429        use common::{url::Params, ToParts};
2430        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2431
2432        let mut dd = common::DefaultDelegate;
2433        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2434        dlg.begin(common::MethodInfo {
2435            id: "webrisk.projects.submissions.create",
2436            http_method: hyper::Method::POST,
2437        });
2438
2439        for &field in ["alt", "parent"].iter() {
2440            if self._additional_params.contains_key(field) {
2441                dlg.finished(false);
2442                return Err(common::Error::FieldClash(field));
2443            }
2444        }
2445
2446        let mut params = Params::with_capacity(4 + self._additional_params.len());
2447        params.push("parent", self._parent);
2448
2449        params.extend(self._additional_params.iter());
2450
2451        params.push("alt", "json");
2452        let mut url = self.hub._base_url.clone() + "v1/{+parent}/submissions";
2453        if self._scopes.is_empty() {
2454            self._scopes
2455                .insert(Scope::CloudPlatform.as_ref().to_string());
2456        }
2457
2458        #[allow(clippy::single_element_loop)]
2459        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2460            url = params.uri_replacement(url, param_name, find_this, true);
2461        }
2462        {
2463            let to_remove = ["parent"];
2464            params.remove_params(&to_remove);
2465        }
2466
2467        let url = params.parse_with_url(&url);
2468
2469        let mut json_mime_type = mime::APPLICATION_JSON;
2470        let mut request_value_reader = {
2471            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2472            common::remove_json_null_values(&mut value);
2473            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2474            serde_json::to_writer(&mut dst, &value).unwrap();
2475            dst
2476        };
2477        let request_size = request_value_reader
2478            .seek(std::io::SeekFrom::End(0))
2479            .unwrap();
2480        request_value_reader
2481            .seek(std::io::SeekFrom::Start(0))
2482            .unwrap();
2483
2484        loop {
2485            let token = match self
2486                .hub
2487                .auth
2488                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2489                .await
2490            {
2491                Ok(token) => token,
2492                Err(e) => match dlg.token(e) {
2493                    Ok(token) => token,
2494                    Err(e) => {
2495                        dlg.finished(false);
2496                        return Err(common::Error::MissingToken(e));
2497                    }
2498                },
2499            };
2500            request_value_reader
2501                .seek(std::io::SeekFrom::Start(0))
2502                .unwrap();
2503            let mut req_result = {
2504                let client = &self.hub.client;
2505                dlg.pre_request();
2506                let mut req_builder = hyper::Request::builder()
2507                    .method(hyper::Method::POST)
2508                    .uri(url.as_str())
2509                    .header(USER_AGENT, self.hub._user_agent.clone());
2510
2511                if let Some(token) = token.as_ref() {
2512                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2513                }
2514
2515                let request = req_builder
2516                    .header(CONTENT_TYPE, json_mime_type.to_string())
2517                    .header(CONTENT_LENGTH, request_size as u64)
2518                    .body(common::to_body(
2519                        request_value_reader.get_ref().clone().into(),
2520                    ));
2521
2522                client.request(request.unwrap()).await
2523            };
2524
2525            match req_result {
2526                Err(err) => {
2527                    if let common::Retry::After(d) = dlg.http_error(&err) {
2528                        sleep(d).await;
2529                        continue;
2530                    }
2531                    dlg.finished(false);
2532                    return Err(common::Error::HttpError(err));
2533                }
2534                Ok(res) => {
2535                    let (mut parts, body) = res.into_parts();
2536                    let mut body = common::Body::new(body);
2537                    if !parts.status.is_success() {
2538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2539                        let error = serde_json::from_str(&common::to_string(&bytes));
2540                        let response = common::to_response(parts, bytes.into());
2541
2542                        if let common::Retry::After(d) =
2543                            dlg.http_failure(&response, error.as_ref().ok())
2544                        {
2545                            sleep(d).await;
2546                            continue;
2547                        }
2548
2549                        dlg.finished(false);
2550
2551                        return Err(match error {
2552                            Ok(value) => common::Error::BadRequest(value),
2553                            _ => common::Error::Failure(response),
2554                        });
2555                    }
2556                    let response = {
2557                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2558                        let encoded = common::to_string(&bytes);
2559                        match serde_json::from_str(&encoded) {
2560                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2561                            Err(error) => {
2562                                dlg.response_json_decode_error(&encoded, &error);
2563                                return Err(common::Error::JsonDecodeError(
2564                                    encoded.to_string(),
2565                                    error,
2566                                ));
2567                            }
2568                        }
2569                    };
2570
2571                    dlg.finished(true);
2572                    return Ok(response);
2573                }
2574            }
2575        }
2576    }
2577
2578    ///
2579    /// Sets the *request* property to the given value.
2580    ///
2581    /// Even though the property as already been set when instantiating this call,
2582    /// we provide this method for API completeness.
2583    pub fn request(
2584        mut self,
2585        new_value: GoogleCloudWebriskV1Submission,
2586    ) -> ProjectSubmissionCreateCall<'a, C> {
2587        self._request = new_value;
2588        self
2589    }
2590    /// Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}".
2591    ///
2592    /// Sets the *parent* path property to the given value.
2593    ///
2594    /// Even though the property as already been set when instantiating this call,
2595    /// we provide this method for API completeness.
2596    pub fn parent(mut self, new_value: &str) -> ProjectSubmissionCreateCall<'a, C> {
2597        self._parent = new_value.to_string();
2598        self
2599    }
2600    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2601    /// while executing the actual API request.
2602    ///
2603    /// ````text
2604    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2605    /// ````
2606    ///
2607    /// Sets the *delegate* property to the given value.
2608    pub fn delegate(
2609        mut self,
2610        new_value: &'a mut dyn common::Delegate,
2611    ) -> ProjectSubmissionCreateCall<'a, C> {
2612        self._delegate = Some(new_value);
2613        self
2614    }
2615
2616    /// Set any additional parameter of the query string used in the request.
2617    /// It should be used to set parameters which are not yet available through their own
2618    /// setters.
2619    ///
2620    /// Please note that this method must not be used to set any of the known parameters
2621    /// which have their own setter method. If done anyway, the request will fail.
2622    ///
2623    /// # Additional Parameters
2624    ///
2625    /// * *$.xgafv* (query-string) - V1 error format.
2626    /// * *access_token* (query-string) - OAuth access token.
2627    /// * *alt* (query-string) - Data format for response.
2628    /// * *callback* (query-string) - JSONP
2629    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2630    /// * *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.
2631    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2632    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2633    /// * *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.
2634    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2635    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2636    pub fn param<T>(mut self, name: T, value: T) -> ProjectSubmissionCreateCall<'a, C>
2637    where
2638        T: AsRef<str>,
2639    {
2640        self._additional_params
2641            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2642        self
2643    }
2644
2645    /// Identifies the authorization scope for the method you are building.
2646    ///
2647    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2648    /// [`Scope::CloudPlatform`].
2649    ///
2650    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2651    /// tokens for more than one scope.
2652    ///
2653    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2654    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2655    /// sufficient, a read-write scope will do as well.
2656    pub fn add_scope<St>(mut self, scope: St) -> ProjectSubmissionCreateCall<'a, C>
2657    where
2658        St: AsRef<str>,
2659    {
2660        self._scopes.insert(String::from(scope.as_ref()));
2661        self
2662    }
2663    /// Identifies the authorization scope(s) for the method you are building.
2664    ///
2665    /// See [`Self::add_scope()`] for details.
2666    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubmissionCreateCall<'a, C>
2667    where
2668        I: IntoIterator<Item = St>,
2669        St: AsRef<str>,
2670    {
2671        self._scopes
2672            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2673        self
2674    }
2675
2676    /// Removes all scopes, and no default scope will be used either.
2677    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2678    /// for details).
2679    pub fn clear_scopes(mut self) -> ProjectSubmissionCreateCall<'a, C> {
2680        self._scopes.clear();
2681        self
2682    }
2683}
2684
2685/// Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once for each list.
2686///
2687/// A builder for the *computeDiff* method supported by a *threatList* resource.
2688/// It is not used directly, but through a [`ThreatListMethods`] instance.
2689///
2690/// # Example
2691///
2692/// Instantiate a resource method builder
2693///
2694/// ```test_harness,no_run
2695/// # extern crate hyper;
2696/// # extern crate hyper_rustls;
2697/// # extern crate google_webrisk1 as webrisk1;
2698/// # async fn dox() {
2699/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2700///
2701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2702/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2703/// #     .with_native_roots()
2704/// #     .unwrap()
2705/// #     .https_only()
2706/// #     .enable_http2()
2707/// #     .build();
2708///
2709/// # let executor = hyper_util::rt::TokioExecutor::new();
2710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2711/// #     secret,
2712/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2713/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2714/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2715/// #     ),
2716/// # ).build().await.unwrap();
2717///
2718/// # let client = hyper_util::client::legacy::Client::builder(
2719/// #     hyper_util::rt::TokioExecutor::new()
2720/// # )
2721/// # .build(
2722/// #     hyper_rustls::HttpsConnectorBuilder::new()
2723/// #         .with_native_roots()
2724/// #         .unwrap()
2725/// #         .https_or_http()
2726/// #         .enable_http2()
2727/// #         .build()
2728/// # );
2729/// # let mut hub = WebRisk::new(client, auth);
2730/// // You can configure optional parameters by calling the respective setters at will, and
2731/// // execute the final call using `doit()`.
2732/// // Values shown here are possibly random and not representative !
2733/// let result = hub.threat_lists().compute_diff()
2734///              .version_token(vec![0, 1, 2, 3])
2735///              .threat_type("Lorem")
2736///              .add_constraints_supported_compressions("gubergren")
2737///              .constraints_max_diff_entries(-75)
2738///              .constraints_max_database_entries(-4)
2739///              .doit().await;
2740/// # }
2741/// ```
2742pub struct ThreatListComputeDiffCall<'a, C>
2743where
2744    C: 'a,
2745{
2746    hub: &'a WebRisk<C>,
2747    _version_token: Option<Vec<u8>>,
2748    _threat_type: Option<String>,
2749    _constraints_supported_compressions: Vec<String>,
2750    _constraints_max_diff_entries: Option<i32>,
2751    _constraints_max_database_entries: Option<i32>,
2752    _delegate: Option<&'a mut dyn common::Delegate>,
2753    _additional_params: HashMap<String, String>,
2754    _scopes: BTreeSet<String>,
2755}
2756
2757impl<'a, C> common::CallBuilder for ThreatListComputeDiffCall<'a, C> {}
2758
2759impl<'a, C> ThreatListComputeDiffCall<'a, C>
2760where
2761    C: common::Connector,
2762{
2763    /// Perform the operation you have build so far.
2764    pub async fn doit(
2765        mut self,
2766    ) -> common::Result<(
2767        common::Response,
2768        GoogleCloudWebriskV1ComputeThreatListDiffResponse,
2769    )> {
2770        use std::borrow::Cow;
2771        use std::io::{Read, Seek};
2772
2773        use common::{url::Params, ToParts};
2774        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2775
2776        let mut dd = common::DefaultDelegate;
2777        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2778        dlg.begin(common::MethodInfo {
2779            id: "webrisk.threatLists.computeDiff",
2780            http_method: hyper::Method::GET,
2781        });
2782
2783        for &field in [
2784            "alt",
2785            "versionToken",
2786            "threatType",
2787            "constraints.supportedCompressions",
2788            "constraints.maxDiffEntries",
2789            "constraints.maxDatabaseEntries",
2790        ]
2791        .iter()
2792        {
2793            if self._additional_params.contains_key(field) {
2794                dlg.finished(false);
2795                return Err(common::Error::FieldClash(field));
2796            }
2797        }
2798
2799        let mut params = Params::with_capacity(7 + self._additional_params.len());
2800        if let Some(value) = self._version_token.as_ref() {
2801            params.push(
2802                "versionToken",
2803                common::serde::standard_base64::to_string(&value),
2804            );
2805        }
2806        if let Some(value) = self._threat_type.as_ref() {
2807            params.push("threatType", value);
2808        }
2809        if !self._constraints_supported_compressions.is_empty() {
2810            for f in self._constraints_supported_compressions.iter() {
2811                params.push("constraints.supportedCompressions", f);
2812            }
2813        }
2814        if let Some(value) = self._constraints_max_diff_entries.as_ref() {
2815            params.push("constraints.maxDiffEntries", value.to_string());
2816        }
2817        if let Some(value) = self._constraints_max_database_entries.as_ref() {
2818            params.push("constraints.maxDatabaseEntries", value.to_string());
2819        }
2820
2821        params.extend(self._additional_params.iter());
2822
2823        params.push("alt", "json");
2824        let mut url = self.hub._base_url.clone() + "v1/threatLists:computeDiff";
2825        if self._scopes.is_empty() {
2826            self._scopes
2827                .insert(Scope::CloudPlatform.as_ref().to_string());
2828        }
2829
2830        let url = params.parse_with_url(&url);
2831
2832        loop {
2833            let token = match self
2834                .hub
2835                .auth
2836                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2837                .await
2838            {
2839                Ok(token) => token,
2840                Err(e) => match dlg.token(e) {
2841                    Ok(token) => token,
2842                    Err(e) => {
2843                        dlg.finished(false);
2844                        return Err(common::Error::MissingToken(e));
2845                    }
2846                },
2847            };
2848            let mut req_result = {
2849                let client = &self.hub.client;
2850                dlg.pre_request();
2851                let mut req_builder = hyper::Request::builder()
2852                    .method(hyper::Method::GET)
2853                    .uri(url.as_str())
2854                    .header(USER_AGENT, self.hub._user_agent.clone());
2855
2856                if let Some(token) = token.as_ref() {
2857                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2858                }
2859
2860                let request = req_builder
2861                    .header(CONTENT_LENGTH, 0_u64)
2862                    .body(common::to_body::<String>(None));
2863
2864                client.request(request.unwrap()).await
2865            };
2866
2867            match req_result {
2868                Err(err) => {
2869                    if let common::Retry::After(d) = dlg.http_error(&err) {
2870                        sleep(d).await;
2871                        continue;
2872                    }
2873                    dlg.finished(false);
2874                    return Err(common::Error::HttpError(err));
2875                }
2876                Ok(res) => {
2877                    let (mut parts, body) = res.into_parts();
2878                    let mut body = common::Body::new(body);
2879                    if !parts.status.is_success() {
2880                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2881                        let error = serde_json::from_str(&common::to_string(&bytes));
2882                        let response = common::to_response(parts, bytes.into());
2883
2884                        if let common::Retry::After(d) =
2885                            dlg.http_failure(&response, error.as_ref().ok())
2886                        {
2887                            sleep(d).await;
2888                            continue;
2889                        }
2890
2891                        dlg.finished(false);
2892
2893                        return Err(match error {
2894                            Ok(value) => common::Error::BadRequest(value),
2895                            _ => common::Error::Failure(response),
2896                        });
2897                    }
2898                    let response = {
2899                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2900                        let encoded = common::to_string(&bytes);
2901                        match serde_json::from_str(&encoded) {
2902                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2903                            Err(error) => {
2904                                dlg.response_json_decode_error(&encoded, &error);
2905                                return Err(common::Error::JsonDecodeError(
2906                                    encoded.to_string(),
2907                                    error,
2908                                ));
2909                            }
2910                        }
2911                    };
2912
2913                    dlg.finished(true);
2914                    return Ok(response);
2915                }
2916            }
2917        }
2918    }
2919
2920    /// The current version token of the client for the requested list (the client version that was received from the last successful diff). If the client does not have a version token (this is the first time calling ComputeThreatListDiff), this may be left empty and a full database snapshot will be returned.
2921    ///
2922    /// Sets the *version token* query property to the given value.
2923    pub fn version_token(mut self, new_value: Vec<u8>) -> ThreatListComputeDiffCall<'a, C> {
2924        self._version_token = Some(new_value);
2925        self
2926    }
2927    /// Required. The threat list to update. Only a single ThreatType should be specified per request. If you want to handle multiple ThreatTypes, you must make one request per ThreatType.
2928    ///
2929    /// Sets the *threat type* query property to the given value.
2930    pub fn threat_type(mut self, new_value: &str) -> ThreatListComputeDiffCall<'a, C> {
2931        self._threat_type = Some(new_value.to_string());
2932        self
2933    }
2934    /// The compression types supported by the client.
2935    ///
2936    /// Append the given value to the *constraints.supported compressions* query property.
2937    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
2938    pub fn add_constraints_supported_compressions(
2939        mut self,
2940        new_value: &str,
2941    ) -> ThreatListComputeDiffCall<'a, C> {
2942        self._constraints_supported_compressions
2943            .push(new_value.to_string());
2944        self
2945    }
2946    /// The maximum size in number of entries. The diff will not contain more entries than this value. This should be a power of 2 between 2**10 and 2**20. If zero, no diff size limit is set.
2947    ///
2948    /// Sets the *constraints.max diff entries* query property to the given value.
2949    pub fn constraints_max_diff_entries(
2950        mut self,
2951        new_value: i32,
2952    ) -> ThreatListComputeDiffCall<'a, C> {
2953        self._constraints_max_diff_entries = Some(new_value);
2954        self
2955    }
2956    /// Sets the maximum number of entries that the client is willing to have in the local database. This should be a power of 2 between 2**10 and 2**20. If zero, no database size limit is set.
2957    ///
2958    /// Sets the *constraints.max database entries* query property to the given value.
2959    pub fn constraints_max_database_entries(
2960        mut self,
2961        new_value: i32,
2962    ) -> ThreatListComputeDiffCall<'a, C> {
2963        self._constraints_max_database_entries = Some(new_value);
2964        self
2965    }
2966    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2967    /// while executing the actual API request.
2968    ///
2969    /// ````text
2970    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2971    /// ````
2972    ///
2973    /// Sets the *delegate* property to the given value.
2974    pub fn delegate(
2975        mut self,
2976        new_value: &'a mut dyn common::Delegate,
2977    ) -> ThreatListComputeDiffCall<'a, C> {
2978        self._delegate = Some(new_value);
2979        self
2980    }
2981
2982    /// Set any additional parameter of the query string used in the request.
2983    /// It should be used to set parameters which are not yet available through their own
2984    /// setters.
2985    ///
2986    /// Please note that this method must not be used to set any of the known parameters
2987    /// which have their own setter method. If done anyway, the request will fail.
2988    ///
2989    /// # Additional Parameters
2990    ///
2991    /// * *$.xgafv* (query-string) - V1 error format.
2992    /// * *access_token* (query-string) - OAuth access token.
2993    /// * *alt* (query-string) - Data format for response.
2994    /// * *callback* (query-string) - JSONP
2995    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2996    /// * *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.
2997    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2998    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2999    /// * *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.
3000    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3001    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3002    pub fn param<T>(mut self, name: T, value: T) -> ThreatListComputeDiffCall<'a, C>
3003    where
3004        T: AsRef<str>,
3005    {
3006        self._additional_params
3007            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3008        self
3009    }
3010
3011    /// Identifies the authorization scope for the method you are building.
3012    ///
3013    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3014    /// [`Scope::CloudPlatform`].
3015    ///
3016    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3017    /// tokens for more than one scope.
3018    ///
3019    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3020    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3021    /// sufficient, a read-write scope will do as well.
3022    pub fn add_scope<St>(mut self, scope: St) -> ThreatListComputeDiffCall<'a, C>
3023    where
3024        St: AsRef<str>,
3025    {
3026        self._scopes.insert(String::from(scope.as_ref()));
3027        self
3028    }
3029    /// Identifies the authorization scope(s) for the method you are building.
3030    ///
3031    /// See [`Self::add_scope()`] for details.
3032    pub fn add_scopes<I, St>(mut self, scopes: I) -> ThreatListComputeDiffCall<'a, C>
3033    where
3034        I: IntoIterator<Item = St>,
3035        St: AsRef<str>,
3036    {
3037        self._scopes
3038            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3039        self
3040    }
3041
3042    /// Removes all scopes, and no default scope will be used either.
3043    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3044    /// for details).
3045    pub fn clear_scopes(mut self) -> ThreatListComputeDiffCall<'a, C> {
3046        self._scopes.clear();
3047        self
3048    }
3049}
3050
3051/// This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.
3052///
3053/// A builder for the *search* method supported by a *uri* resource.
3054/// It is not used directly, but through a [`UriMethods`] instance.
3055///
3056/// # Example
3057///
3058/// Instantiate a resource method builder
3059///
3060/// ```test_harness,no_run
3061/// # extern crate hyper;
3062/// # extern crate hyper_rustls;
3063/// # extern crate google_webrisk1 as webrisk1;
3064/// # async fn dox() {
3065/// # use webrisk1::{WebRisk, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3066///
3067/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3068/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3069/// #     .with_native_roots()
3070/// #     .unwrap()
3071/// #     .https_only()
3072/// #     .enable_http2()
3073/// #     .build();
3074///
3075/// # let executor = hyper_util::rt::TokioExecutor::new();
3076/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3077/// #     secret,
3078/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3079/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3080/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3081/// #     ),
3082/// # ).build().await.unwrap();
3083///
3084/// # let client = hyper_util::client::legacy::Client::builder(
3085/// #     hyper_util::rt::TokioExecutor::new()
3086/// # )
3087/// # .build(
3088/// #     hyper_rustls::HttpsConnectorBuilder::new()
3089/// #         .with_native_roots()
3090/// #         .unwrap()
3091/// #         .https_or_http()
3092/// #         .enable_http2()
3093/// #         .build()
3094/// # );
3095/// # let mut hub = WebRisk::new(client, auth);
3096/// // You can configure optional parameters by calling the respective setters at will, and
3097/// // execute the final call using `doit()`.
3098/// // Values shown here are possibly random and not representative !
3099/// let result = hub.uris().search()
3100///              .uri("ea")
3101///              .add_threat_types("ipsum")
3102///              .doit().await;
3103/// # }
3104/// ```
3105pub struct UriSearchCall<'a, C>
3106where
3107    C: 'a,
3108{
3109    hub: &'a WebRisk<C>,
3110    _uri: Option<String>,
3111    _threat_types: Vec<String>,
3112    _delegate: Option<&'a mut dyn common::Delegate>,
3113    _additional_params: HashMap<String, String>,
3114    _scopes: BTreeSet<String>,
3115}
3116
3117impl<'a, C> common::CallBuilder for UriSearchCall<'a, C> {}
3118
3119impl<'a, C> UriSearchCall<'a, C>
3120where
3121    C: common::Connector,
3122{
3123    /// Perform the operation you have build so far.
3124    pub async fn doit(
3125        mut self,
3126    ) -> common::Result<(common::Response, GoogleCloudWebriskV1SearchUrisResponse)> {
3127        use std::borrow::Cow;
3128        use std::io::{Read, Seek};
3129
3130        use common::{url::Params, ToParts};
3131        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3132
3133        let mut dd = common::DefaultDelegate;
3134        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3135        dlg.begin(common::MethodInfo {
3136            id: "webrisk.uris.search",
3137            http_method: hyper::Method::GET,
3138        });
3139
3140        for &field in ["alt", "uri", "threatTypes"].iter() {
3141            if self._additional_params.contains_key(field) {
3142                dlg.finished(false);
3143                return Err(common::Error::FieldClash(field));
3144            }
3145        }
3146
3147        let mut params = Params::with_capacity(4 + self._additional_params.len());
3148        if let Some(value) = self._uri.as_ref() {
3149            params.push("uri", value);
3150        }
3151        if !self._threat_types.is_empty() {
3152            for f in self._threat_types.iter() {
3153                params.push("threatTypes", f);
3154            }
3155        }
3156
3157        params.extend(self._additional_params.iter());
3158
3159        params.push("alt", "json");
3160        let mut url = self.hub._base_url.clone() + "v1/uris:search";
3161        if self._scopes.is_empty() {
3162            self._scopes
3163                .insert(Scope::CloudPlatform.as_ref().to_string());
3164        }
3165
3166        let url = params.parse_with_url(&url);
3167
3168        loop {
3169            let token = match self
3170                .hub
3171                .auth
3172                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3173                .await
3174            {
3175                Ok(token) => token,
3176                Err(e) => match dlg.token(e) {
3177                    Ok(token) => token,
3178                    Err(e) => {
3179                        dlg.finished(false);
3180                        return Err(common::Error::MissingToken(e));
3181                    }
3182                },
3183            };
3184            let mut req_result = {
3185                let client = &self.hub.client;
3186                dlg.pre_request();
3187                let mut req_builder = hyper::Request::builder()
3188                    .method(hyper::Method::GET)
3189                    .uri(url.as_str())
3190                    .header(USER_AGENT, self.hub._user_agent.clone());
3191
3192                if let Some(token) = token.as_ref() {
3193                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3194                }
3195
3196                let request = req_builder
3197                    .header(CONTENT_LENGTH, 0_u64)
3198                    .body(common::to_body::<String>(None));
3199
3200                client.request(request.unwrap()).await
3201            };
3202
3203            match req_result {
3204                Err(err) => {
3205                    if let common::Retry::After(d) = dlg.http_error(&err) {
3206                        sleep(d).await;
3207                        continue;
3208                    }
3209                    dlg.finished(false);
3210                    return Err(common::Error::HttpError(err));
3211                }
3212                Ok(res) => {
3213                    let (mut parts, body) = res.into_parts();
3214                    let mut body = common::Body::new(body);
3215                    if !parts.status.is_success() {
3216                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3217                        let error = serde_json::from_str(&common::to_string(&bytes));
3218                        let response = common::to_response(parts, bytes.into());
3219
3220                        if let common::Retry::After(d) =
3221                            dlg.http_failure(&response, error.as_ref().ok())
3222                        {
3223                            sleep(d).await;
3224                            continue;
3225                        }
3226
3227                        dlg.finished(false);
3228
3229                        return Err(match error {
3230                            Ok(value) => common::Error::BadRequest(value),
3231                            _ => common::Error::Failure(response),
3232                        });
3233                    }
3234                    let response = {
3235                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3236                        let encoded = common::to_string(&bytes);
3237                        match serde_json::from_str(&encoded) {
3238                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3239                            Err(error) => {
3240                                dlg.response_json_decode_error(&encoded, &error);
3241                                return Err(common::Error::JsonDecodeError(
3242                                    encoded.to_string(),
3243                                    error,
3244                                ));
3245                            }
3246                        }
3247                    };
3248
3249                    dlg.finished(true);
3250                    return Ok(response);
3251                }
3252            }
3253        }
3254    }
3255
3256    /// Required. The URI to be checked for matches.
3257    ///
3258    /// Sets the *uri* query property to the given value.
3259    pub fn uri(mut self, new_value: &str) -> UriSearchCall<'a, C> {
3260        self._uri = Some(new_value.to_string());
3261        self
3262    }
3263    /// Required. The ThreatLists to search in. Multiple ThreatLists may be specified.
3264    ///
3265    /// Append the given value to the *threat types* query property.
3266    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3267    pub fn add_threat_types(mut self, new_value: &str) -> UriSearchCall<'a, C> {
3268        self._threat_types.push(new_value.to_string());
3269        self
3270    }
3271    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3272    /// while executing the actual API request.
3273    ///
3274    /// ````text
3275    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3276    /// ````
3277    ///
3278    /// Sets the *delegate* property to the given value.
3279    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UriSearchCall<'a, C> {
3280        self._delegate = Some(new_value);
3281        self
3282    }
3283
3284    /// Set any additional parameter of the query string used in the request.
3285    /// It should be used to set parameters which are not yet available through their own
3286    /// setters.
3287    ///
3288    /// Please note that this method must not be used to set any of the known parameters
3289    /// which have their own setter method. If done anyway, the request will fail.
3290    ///
3291    /// # Additional Parameters
3292    ///
3293    /// * *$.xgafv* (query-string) - V1 error format.
3294    /// * *access_token* (query-string) - OAuth access token.
3295    /// * *alt* (query-string) - Data format for response.
3296    /// * *callback* (query-string) - JSONP
3297    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3298    /// * *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.
3299    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3300    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3301    /// * *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.
3302    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3303    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3304    pub fn param<T>(mut self, name: T, value: T) -> UriSearchCall<'a, C>
3305    where
3306        T: AsRef<str>,
3307    {
3308        self._additional_params
3309            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3310        self
3311    }
3312
3313    /// Identifies the authorization scope for the method you are building.
3314    ///
3315    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3316    /// [`Scope::CloudPlatform`].
3317    ///
3318    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3319    /// tokens for more than one scope.
3320    ///
3321    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3322    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3323    /// sufficient, a read-write scope will do as well.
3324    pub fn add_scope<St>(mut self, scope: St) -> UriSearchCall<'a, C>
3325    where
3326        St: AsRef<str>,
3327    {
3328        self._scopes.insert(String::from(scope.as_ref()));
3329        self
3330    }
3331    /// Identifies the authorization scope(s) for the method you are building.
3332    ///
3333    /// See [`Self::add_scope()`] for details.
3334    pub fn add_scopes<I, St>(mut self, scopes: I) -> UriSearchCall<'a, C>
3335    where
3336        I: IntoIterator<Item = St>,
3337        St: AsRef<str>,
3338    {
3339        self._scopes
3340            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3341        self
3342    }
3343
3344    /// Removes all scopes, and no default scope will be used either.
3345    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3346    /// for details).
3347    pub fn clear_scopes(mut self) -> UriSearchCall<'a, C> {
3348        self._scopes.clear();
3349        self
3350    }
3351}