google_dns2/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 /// View your data across Google Cloud services and see the email address of your Google Account
20 CloudPlatformReadOnly,
21
22 /// View your DNS records hosted by Google Cloud DNS
23 NdevClouddnReadonly,
24
25 /// View and manage your DNS records hosted by Google Cloud DNS
26 NdevClouddnReadwrite,
27}
28
29impl AsRef<str> for Scope {
30 fn as_ref(&self) -> &str {
31 match *self {
32 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
33 Scope::CloudPlatformReadOnly => {
34 "https://www.googleapis.com/auth/cloud-platform.read-only"
35 }
36 Scope::NdevClouddnReadonly => "https://www.googleapis.com/auth/ndev.clouddns.readonly",
37 Scope::NdevClouddnReadwrite => {
38 "https://www.googleapis.com/auth/ndev.clouddns.readwrite"
39 }
40 }
41 }
42}
43
44#[allow(clippy::derivable_impls)]
45impl Default for Scope {
46 fn default() -> Scope {
47 Scope::NdevClouddnReadonly
48 }
49}
50
51// ########
52// HUB ###
53// ######
54
55/// Central instance to access all Dns related resource activities
56///
57/// # Examples
58///
59/// Instantiate a new hub
60///
61/// ```test_harness,no_run
62/// extern crate hyper;
63/// extern crate hyper_rustls;
64/// extern crate google_dns2 as dns2;
65/// use dns2::{Result, Error};
66/// # async fn dox() {
67/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
68///
69/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
70/// // `client_secret`, among other things.
71/// let secret: yup_oauth2::ApplicationSecret = Default::default();
72/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
73/// // unless you replace `None` with the desired Flow.
74/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
75/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
76/// // retrieve them from storage.
77/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
78/// .with_native_roots()
79/// .unwrap()
80/// .https_only()
81/// .enable_http2()
82/// .build();
83///
84/// let executor = hyper_util::rt::TokioExecutor::new();
85/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
86/// secret,
87/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
88/// yup_oauth2::client::CustomHyperClientBuilder::from(
89/// hyper_util::client::legacy::Client::builder(executor).build(connector),
90/// ),
91/// ).build().await.unwrap();
92///
93/// let client = hyper_util::client::legacy::Client::builder(
94/// hyper_util::rt::TokioExecutor::new()
95/// )
96/// .build(
97/// hyper_rustls::HttpsConnectorBuilder::new()
98/// .with_native_roots()
99/// .unwrap()
100/// .https_or_http()
101/// .enable_http2()
102/// .build()
103/// );
104/// let mut hub = Dns::new(client, auth);
105/// // You can configure optional parameters by calling the respective setters at will, and
106/// // execute the final call using `doit()`.
107/// // Values shown here are possibly random and not representative !
108/// let result = hub.managed_zones().list("project", "location")
109/// .page_token("ipsum")
110/// .max_results(-62)
111/// .dns_name("Lorem")
112/// .doit().await;
113///
114/// match result {
115/// Err(e) => match e {
116/// // The Error enum provides details about what exactly happened.
117/// // You can also just use its `Debug`, `Display` or `Error` traits
118/// Error::HttpError(_)
119/// |Error::Io(_)
120/// |Error::MissingAPIKey
121/// |Error::MissingToken(_)
122/// |Error::Cancelled
123/// |Error::UploadSizeLimitExceeded(_, _)
124/// |Error::Failure(_)
125/// |Error::BadRequest(_)
126/// |Error::FieldClash(_)
127/// |Error::JsonDecodeError(_, _) => println!("{}", e),
128/// },
129/// Ok(res) => println!("Success: {:?}", res),
130/// }
131/// # }
132/// ```
133#[derive(Clone)]
134pub struct Dns<C> {
135 pub client: common::Client<C>,
136 pub auth: Box<dyn common::GetToken>,
137 _user_agent: String,
138 _base_url: String,
139 _root_url: String,
140}
141
142impl<C> common::Hub for Dns<C> {}
143
144impl<'a, C> Dns<C> {
145 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Dns<C> {
146 Dns {
147 client,
148 auth: Box::new(auth),
149 _user_agent: "google-api-rust-client/7.0.0".to_string(),
150 _base_url: "https://dns.googleapis.com/".to_string(),
151 _root_url: "https://dns.googleapis.com/".to_string(),
152 }
153 }
154
155 pub fn changes(&'a self) -> ChangeMethods<'a, C> {
156 ChangeMethods { hub: self }
157 }
158 pub fn dns_keys(&'a self) -> DnsKeyMethods<'a, C> {
159 DnsKeyMethods { hub: self }
160 }
161 pub fn managed_zone_operations(&'a self) -> ManagedZoneOperationMethods<'a, C> {
162 ManagedZoneOperationMethods { hub: self }
163 }
164 pub fn managed_zones(&'a self) -> ManagedZoneMethods<'a, C> {
165 ManagedZoneMethods { hub: self }
166 }
167 pub fn policies(&'a self) -> PolicyMethods<'a, C> {
168 PolicyMethods { hub: self }
169 }
170 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
171 ProjectMethods { hub: self }
172 }
173 pub fn resource_record_sets(&'a self) -> ResourceRecordSetMethods<'a, C> {
174 ResourceRecordSetMethods { hub: self }
175 }
176 pub fn response_policies(&'a self) -> ResponsePolicyMethods<'a, C> {
177 ResponsePolicyMethods { hub: self }
178 }
179 pub fn response_policy_rules(&'a self) -> ResponsePolicyRuleMethods<'a, C> {
180 ResponsePolicyRuleMethods { hub: self }
181 }
182
183 /// Set the user-agent header field to use in all requests to the server.
184 /// It defaults to `google-api-rust-client/7.0.0`.
185 ///
186 /// Returns the previously set user-agent.
187 pub fn user_agent(&mut self, agent_name: String) -> String {
188 std::mem::replace(&mut self._user_agent, agent_name)
189 }
190
191 /// Set the base url to use in all requests to the server.
192 /// It defaults to `https://dns.googleapis.com/`.
193 ///
194 /// Returns the previously set base url.
195 pub fn base_url(&mut self, new_base_url: String) -> String {
196 std::mem::replace(&mut self._base_url, new_base_url)
197 }
198
199 /// Set the root url to use in all requests to the server.
200 /// It defaults to `https://dns.googleapis.com/`.
201 ///
202 /// Returns the previously set root url.
203 pub fn root_url(&mut self, new_root_url: String) -> String {
204 std::mem::replace(&mut self._root_url, new_root_url)
205 }
206}
207
208// ############
209// SCHEMAS ###
210// ##########
211/// A Change represents a set of `ResourceRecordSet` additions and deletions applied atomically to a ManagedZone. ResourceRecordSets within a ManagedZone are modified by creating a new Change element in the Changes collection. In turn the Changes collection also records the past modifications to the `ResourceRecordSets` in a `ManagedZone`. The current state of the `ManagedZone` is the sum effect of applying all `Change` elements in the `Changes` collection in sequence.
212///
213/// # Activities
214///
215/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
216/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
217///
218/// * [create changes](ChangeCreateCall) (request|response)
219/// * [get changes](ChangeGetCall) (response)
220/// * [list changes](ChangeListCall) (none)
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct Change {
225 /// Which ResourceRecordSets to add?
226 pub additions: Option<Vec<ResourceRecordSet>>,
227 /// Which ResourceRecordSets to remove? Must match existing data exactly.
228 pub deletions: Option<Vec<ResourceRecordSet>>,
229 /// Unique identifier for the resource; defined by the server (output only).
230 pub id: Option<String>,
231 /// If the DNS queries for the zone will be served.
232 #[serde(rename = "isServing")]
233 pub is_serving: Option<bool>,
234 /// no description provided
235 pub kind: Option<String>,
236 /// The time that this operation was started by the server (output only). This is in RFC3339 text format.
237 #[serde(rename = "startTime")]
238 pub start_time: Option<String>,
239 /// Status of the operation (output only). A status of "done" means that the request to update the authoritative servers has been sent, but the servers might not be updated yet.
240 pub status: Option<String>,
241}
242
243impl common::RequestValue for Change {}
244impl common::Resource for Change {}
245impl common::ResponseResult for Change {}
246
247/// The response to a request to enumerate Changes to a ResourceRecordSets collection.
248///
249/// # Activities
250///
251/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
252/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
253///
254/// * [list changes](ChangeListCall) (response)
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct ChangesListResponse {
259 /// The requested changes.
260 pub changes: Option<Vec<Change>>,
261 /// Type of resource.
262 pub kind: Option<String>,
263 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
264 #[serde(rename = "nextPageToken")]
265 pub next_page_token: Option<String>,
266}
267
268impl common::ResponseResult for ChangesListResponse {}
269
270/// A DNSSEC key pair.
271///
272/// # Activities
273///
274/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
275/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
276///
277/// * [get dns keys](DnsKeyGetCall) (response)
278/// * [list dns keys](DnsKeyListCall) (none)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct DnsKey {
283 /// String mnemonic specifying the DNSSEC algorithm of this key. Immutable after creation time.
284 pub algorithm: Option<String>,
285 /// The time that this resource was created in the control plane. This is in RFC3339 text format. Output only.
286 #[serde(rename = "creationTime")]
287 pub creation_time: Option<String>,
288 /// A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the resource's function.
289 pub description: Option<String>,
290 /// Cryptographic hashes of the DNSKEY resource record associated with this DnsKey. These digests are needed to construct a DS record that points at this DNS key. Output only.
291 pub digests: Option<Vec<DnsKeyDigest>>,
292 /// Unique identifier for the resource; defined by the server (output only).
293 pub id: Option<String>,
294 /// Active keys are used to sign subsequent changes to the ManagedZone. Inactive keys are still present as DNSKEY Resource Records for the use of resolvers validating existing signatures.
295 #[serde(rename = "isActive")]
296 pub is_active: Option<bool>,
297 /// Length of the key in bits. Specified at creation time, and then immutable.
298 #[serde(rename = "keyLength")]
299 pub key_length: Option<u32>,
300 /// The key tag is a non-cryptographic hash of the a DNSKEY resource record associated with this DnsKey. The key tag can be used to identify a DNSKEY more quickly (but it is not a unique identifier). In particular, the key tag is used in a parent zone's DS record to point at the DNSKEY in this child ManagedZone. The key tag is a number in the range [0, 65535] and the algorithm to calculate it is specified in RFC4034 Appendix B. Output only.
301 #[serde(rename = "keyTag")]
302 pub key_tag: Option<i32>,
303 /// no description provided
304 pub kind: Option<String>,
305 /// Base64 encoded public half of this key. Output only.
306 #[serde(rename = "publicKey")]
307 pub public_key: Option<String>,
308 /// One of "KEY_SIGNING" or "ZONE_SIGNING". Keys of type KEY_SIGNING have the Secure Entry Point flag set and, when active, are used to sign only resource record sets of type DNSKEY. Otherwise, the Secure Entry Point flag is cleared, and this key is used to sign only resource record sets of other types. Immutable after creation time.
309 #[serde(rename = "type")]
310 pub type_: Option<String>,
311}
312
313impl common::Resource for DnsKey {}
314impl common::ResponseResult for DnsKey {}
315
316/// There is no detailed description.
317///
318/// This type is not used in any activity, and only used as *part* of another schema.
319///
320#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
321#[serde_with::serde_as]
322#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
323pub struct DnsKeyDigest {
324 /// The base-16 encoded bytes of this digest. Suitable for use in a DS resource record.
325 pub digest: Option<String>,
326 /// Specifies the algorithm used to calculate this digest.
327 #[serde(rename = "type")]
328 pub type_: Option<String>,
329}
330
331impl common::Part for DnsKeyDigest {}
332
333/// Parameters for DnsKey key generation. Used for generating initial keys for a new ManagedZone and as default when adding a new DnsKey.
334///
335/// This type is not used in any activity, and only used as *part* of another schema.
336///
337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
338#[serde_with::serde_as]
339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
340pub struct DnsKeySpec {
341 /// String mnemonic specifying the DNSSEC algorithm of this key.
342 pub algorithm: Option<String>,
343 /// Length of the keys in bits.
344 #[serde(rename = "keyLength")]
345 pub key_length: Option<u32>,
346 /// Specifies whether this is a key signing key (KSK) or a zone signing key (ZSK). Key signing keys have the Secure Entry Point flag set and, when active, are only used to sign resource record sets of type DNSKEY. Zone signing keys do not have the Secure Entry Point flag set and are used to sign all other types of resource record sets.
347 #[serde(rename = "keyType")]
348 pub key_type: Option<String>,
349 /// no description provided
350 pub kind: Option<String>,
351}
352
353impl common::Part for DnsKeySpec {}
354
355/// The response to a request to enumerate DnsKeys in a ManagedZone.
356///
357/// # Activities
358///
359/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
360/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
361///
362/// * [list dns keys](DnsKeyListCall) (response)
363#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
364#[serde_with::serde_as]
365#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
366pub struct DnsKeysListResponse {
367 /// The requested resources.
368 #[serde(rename = "dnsKeys")]
369 pub dns_keys: Option<Vec<DnsKey>>,
370 /// Type of resource.
371 pub kind: Option<String>,
372 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
373 #[serde(rename = "nextPageToken")]
374 pub next_page_token: Option<String>,
375}
376
377impl common::ResponseResult for DnsKeysListResponse {}
378
379/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct Expr {
387 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
388 pub description: Option<String>,
389 /// Textual representation of an expression in Common Expression Language syntax.
390 pub expression: Option<String>,
391 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
392 pub location: Option<String>,
393 /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
394 pub title: Option<String>,
395}
396
397impl common::Part for Expr {}
398
399/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
400///
401/// This type is not used in any activity, and only used as *part* of another schema.
402///
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct GoogleIamV1AuditConfig {
407 /// The configuration for logging of each type of permission.
408 #[serde(rename = "auditLogConfigs")]
409 pub audit_log_configs: Option<Vec<GoogleIamV1AuditLogConfig>>,
410 /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
411 pub service: Option<String>,
412}
413
414impl common::Part for GoogleIamV1AuditConfig {}
415
416/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
417///
418/// This type is not used in any activity, and only used as *part* of another schema.
419///
420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
421#[serde_with::serde_as]
422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
423pub struct GoogleIamV1AuditLogConfig {
424 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
425 #[serde(rename = "exemptedMembers")]
426 pub exempted_members: Option<Vec<String>>,
427 /// The log type that this config enables.
428 #[serde(rename = "logType")]
429 pub log_type: Option<String>,
430}
431
432impl common::Part for GoogleIamV1AuditLogConfig {}
433
434/// Associates `members`, or principals, with a `role`.
435///
436/// This type is not used in any activity, and only used as *part* of another schema.
437///
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct GoogleIamV1Binding {
442 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
443 pub condition: Option<Expr>,
444 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
445 pub members: Option<Vec<String>>,
446 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
447 pub role: Option<String>,
448}
449
450impl common::Part for GoogleIamV1Binding {}
451
452/// Request message for `GetIamPolicy` method.
453///
454/// # Activities
455///
456/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
457/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
458///
459/// * [get iam policy managed zones](ManagedZoneGetIamPolicyCall) (request)
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct GoogleIamV1GetIamPolicyRequest {
464 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
465 pub options: Option<GoogleIamV1GetPolicyOptions>,
466}
467
468impl common::RequestValue for GoogleIamV1GetIamPolicyRequest {}
469
470/// Encapsulates settings provided to GetIamPolicy.
471///
472/// This type is not used in any activity, and only used as *part* of another schema.
473///
474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
475#[serde_with::serde_as]
476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
477pub struct GoogleIamV1GetPolicyOptions {
478 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
479 #[serde(rename = "requestedPolicyVersion")]
480 pub requested_policy_version: Option<i32>,
481}
482
483impl common::Part for GoogleIamV1GetPolicyOptions {}
484
485/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
486///
487/// # Activities
488///
489/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
490/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
491///
492/// * [get iam policy managed zones](ManagedZoneGetIamPolicyCall) (response)
493/// * [set iam policy managed zones](ManagedZoneSetIamPolicyCall) (response)
494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
495#[serde_with::serde_as]
496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
497pub struct GoogleIamV1Policy {
498 /// Specifies cloud audit logging configuration for this policy.
499 #[serde(rename = "auditConfigs")]
500 pub audit_configs: Option<Vec<GoogleIamV1AuditConfig>>,
501 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
502 pub bindings: Option<Vec<GoogleIamV1Binding>>,
503 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
504 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
505 pub etag: Option<Vec<u8>>,
506 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
507 pub version: Option<i32>,
508}
509
510impl common::ResponseResult for GoogleIamV1Policy {}
511
512/// Request message for `SetIamPolicy` method.
513///
514/// # Activities
515///
516/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
517/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
518///
519/// * [set iam policy managed zones](ManagedZoneSetIamPolicyCall) (request)
520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
521#[serde_with::serde_as]
522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
523pub struct GoogleIamV1SetIamPolicyRequest {
524 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
525 pub policy: Option<GoogleIamV1Policy>,
526 /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
527 #[serde(rename = "updateMask")]
528 pub update_mask: Option<common::FieldMask>,
529}
530
531impl common::RequestValue for GoogleIamV1SetIamPolicyRequest {}
532
533/// Request message for `TestIamPermissions` method.
534///
535/// # Activities
536///
537/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
538/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
539///
540/// * [test iam permissions managed zones](ManagedZoneTestIamPermissionCall) (request)
541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
542#[serde_with::serde_as]
543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
544pub struct GoogleIamV1TestIamPermissionsRequest {
545 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
546 pub permissions: Option<Vec<String>>,
547}
548
549impl common::RequestValue for GoogleIamV1TestIamPermissionsRequest {}
550
551/// Response message for `TestIamPermissions` method.
552///
553/// # Activities
554///
555/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
556/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
557///
558/// * [test iam permissions managed zones](ManagedZoneTestIamPermissionCall) (response)
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct GoogleIamV1TestIamPermissionsResponse {
563 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
564 pub permissions: Option<Vec<String>>,
565}
566
567impl common::ResponseResult for GoogleIamV1TestIamPermissionsResponse {}
568
569/// A zone is a subtree of the DNS namespace under one administrative responsibility. A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service.
570///
571/// # Activities
572///
573/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
574/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
575///
576/// * [create managed zones](ManagedZoneCreateCall) (request|response)
577/// * [delete managed zones](ManagedZoneDeleteCall) (none)
578/// * [get managed zones](ManagedZoneGetCall) (response)
579/// * [get iam policy managed zones](ManagedZoneGetIamPolicyCall) (none)
580/// * [list managed zones](ManagedZoneListCall) (none)
581/// * [patch managed zones](ManagedZonePatchCall) (request)
582/// * [set iam policy managed zones](ManagedZoneSetIamPolicyCall) (none)
583/// * [test iam permissions managed zones](ManagedZoneTestIamPermissionCall) (none)
584/// * [update managed zones](ManagedZoneUpdateCall) (request)
585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
586#[serde_with::serde_as]
587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
588pub struct ManagedZone {
589 /// no description provided
590 #[serde(rename = "cloudLoggingConfig")]
591 pub cloud_logging_config: Option<ManagedZoneCloudLoggingConfig>,
592 /// The time that this resource was created on the server. This is in RFC3339 text format. Output only.
593 #[serde(rename = "creationTime")]
594 pub creation_time: Option<String>,
595 /// A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the managed zone's function.
596 pub description: Option<String>,
597 /// The DNS name of this managed zone, for instance "example.com.".
598 #[serde(rename = "dnsName")]
599 pub dns_name: Option<String>,
600 /// DNSSEC configuration.
601 #[serde(rename = "dnssecConfig")]
602 pub dnssec_config: Option<ManagedZoneDnsSecConfig>,
603 /// The presence for this field indicates that outbound forwarding is enabled for this zone. The value of this field contains the set of destinations to forward to.
604 #[serde(rename = "forwardingConfig")]
605 pub forwarding_config: Option<ManagedZoneForwardingConfig>,
606 /// Unique identifier for the resource; defined by the server (output only)
607 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
608 pub id: Option<u64>,
609 /// no description provided
610 pub kind: Option<String>,
611 /// User labels.
612 pub labels: Option<HashMap<String, String>>,
613 /// User assigned name for this resource. Must be unique within the project. The name must be 1-63 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes.
614 pub name: Option<String>,
615 /// Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is a set of DNS name servers that all host the same ManagedZones. Most users leave this field unset. If you need to use this field, contact your account team.
616 #[serde(rename = "nameServerSet")]
617 pub name_server_set: Option<String>,
618 /// Delegate your managed_zone to these virtual name servers; defined by the server (output only)
619 #[serde(rename = "nameServers")]
620 pub name_servers: Option<Vec<String>>,
621 /// The presence of this field indicates that DNS Peering is enabled for this zone. The value of this field contains the network to peer with.
622 #[serde(rename = "peeringConfig")]
623 pub peering_config: Option<ManagedZonePeeringConfig>,
624 /// For privately visible zones, the set of Virtual Private Cloud resources that the zone is visible from.
625 #[serde(rename = "privateVisibilityConfig")]
626 pub private_visibility_config: Option<ManagedZonePrivateVisibilityConfig>,
627 /// The presence of this field indicates that this is a managed reverse lookup zone and Cloud DNS resolves reverse lookup queries using automatically configured records for VPC resources. This only applies to networks listed under private_visibility_config.
628 #[serde(rename = "reverseLookupConfig")]
629 pub reverse_lookup_config: Option<ManagedZoneReverseLookupConfig>,
630 /// This field links to the associated service directory namespace. Do not set this field for public zones or forwarding zones.
631 #[serde(rename = "serviceDirectoryConfig")]
632 pub service_directory_config: Option<ManagedZoneServiceDirectoryConfig>,
633 /// The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
634 pub visibility: Option<String>,
635}
636
637impl common::RequestValue for ManagedZone {}
638impl common::Resource for ManagedZone {}
639impl common::ResponseResult for ManagedZone {}
640
641/// Cloud Logging configurations for publicly visible zones.
642///
643/// This type is not used in any activity, and only used as *part* of another schema.
644///
645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
646#[serde_with::serde_as]
647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
648pub struct ManagedZoneCloudLoggingConfig {
649 /// If set, enable query logging for this ManagedZone. False by default, making logging opt-in.
650 #[serde(rename = "enableLogging")]
651 pub enable_logging: Option<bool>,
652 /// no description provided
653 pub kind: Option<String>,
654}
655
656impl common::Part for ManagedZoneCloudLoggingConfig {}
657
658/// There is no detailed description.
659///
660/// This type is not used in any activity, and only used as *part* of another schema.
661///
662#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
663#[serde_with::serde_as]
664#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
665pub struct ManagedZoneDnsSecConfig {
666 /// Specifies parameters for generating initial DnsKeys for this ManagedZone. Can only be changed while the state is OFF.
667 #[serde(rename = "defaultKeySpecs")]
668 pub default_key_specs: Option<Vec<DnsKeySpec>>,
669 /// no description provided
670 pub kind: Option<String>,
671 /// Specifies the mechanism for authenticated denial-of-existence responses. Can only be changed while the state is OFF.
672 #[serde(rename = "nonExistence")]
673 pub non_existence: Option<String>,
674 /// Specifies whether DNSSEC is enabled, and what mode it is in.
675 pub state: Option<String>,
676}
677
678impl common::Part for ManagedZoneDnsSecConfig {}
679
680/// There is no detailed description.
681///
682/// This type is not used in any activity, and only used as *part* of another schema.
683///
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct ManagedZoneForwardingConfig {
688 /// no description provided
689 pub kind: Option<String>,
690 /// List of target name servers to forward to. Cloud DNS selects the best available name server if more than one target is given.
691 #[serde(rename = "targetNameServers")]
692 pub target_name_servers: Option<Vec<ManagedZoneForwardingConfigNameServerTarget>>,
693}
694
695impl common::Part for ManagedZoneForwardingConfig {}
696
697/// There is no detailed description.
698///
699/// This type is not used in any activity, and only used as *part* of another schema.
700///
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct ManagedZoneForwardingConfigNameServerTarget {
705 /// Fully qualified domain name for the forwarding target.
706 #[serde(rename = "domainName")]
707 pub domain_name: Option<String>,
708 /// Forwarding path for this NameServerTarget. If unset or set to DEFAULT, Cloud DNS makes forwarding decisions based on IP address ranges; that is, RFC1918 addresses go to the VPC network, non-RFC1918 addresses go to the internet. When set to PRIVATE, Cloud DNS always sends queries through the VPC network for this target.
709 #[serde(rename = "forwardingPath")]
710 pub forwarding_path: Option<String>,
711 /// IPv4 address of a target name server.
712 #[serde(rename = "ipv4Address")]
713 pub ipv4_address: Option<String>,
714 /// IPv6 address of a target name server. Does not accept both fields (ipv4 & ipv6) being populated. Public preview as of November 2022.
715 #[serde(rename = "ipv6Address")]
716 pub ipv6_address: Option<String>,
717 /// no description provided
718 pub kind: Option<String>,
719}
720
721impl common::Part for ManagedZoneForwardingConfigNameServerTarget {}
722
723/// There is no detailed description.
724///
725/// # Activities
726///
727/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
728/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
729///
730/// * [list managed zone operations](ManagedZoneOperationListCall) (response)
731#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
732#[serde_with::serde_as]
733#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
734pub struct ManagedZoneOperationsListResponse {
735 /// no description provided
736 pub kind: Option<String>,
737 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
738 #[serde(rename = "nextPageToken")]
739 pub next_page_token: Option<String>,
740 /// The operation resources.
741 pub operations: Option<Vec<Operation>>,
742}
743
744impl common::ResponseResult for ManagedZoneOperationsListResponse {}
745
746/// There is no detailed description.
747///
748/// This type is not used in any activity, and only used as *part* of another schema.
749///
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct ManagedZonePeeringConfig {
754 /// no description provided
755 pub kind: Option<String>,
756 /// The network with which to peer.
757 #[serde(rename = "targetNetwork")]
758 pub target_network: Option<ManagedZonePeeringConfigTargetNetwork>,
759}
760
761impl common::Part for ManagedZonePeeringConfig {}
762
763/// There is no detailed description.
764///
765/// This type is not used in any activity, and only used as *part* of another schema.
766///
767#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
768#[serde_with::serde_as]
769#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
770pub struct ManagedZonePeeringConfigTargetNetwork {
771 /// The time at which the zone was deactivated, in RFC 3339 date-time format. An empty string indicates that the peering connection is active. The producer network can deactivate a zone. The zone is automatically deactivated if the producer network that the zone targeted is deleted. Output only.
772 #[serde(rename = "deactivateTime")]
773 pub deactivate_time: Option<String>,
774 /// no description provided
775 pub kind: Option<String>,
776 /// The fully qualified URL of the VPC network to forward queries to. This should be formatted like `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`
777 #[serde(rename = "networkUrl")]
778 pub network_url: Option<String>,
779}
780
781impl common::Part for ManagedZonePeeringConfigTargetNetwork {}
782
783/// There is no detailed description.
784///
785/// This type is not used in any activity, and only used as *part* of another schema.
786///
787#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
788#[serde_with::serde_as]
789#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
790pub struct ManagedZonePrivateVisibilityConfig {
791 /// The list of Google Kubernetes Engine clusters that can see this zone.
792 #[serde(rename = "gkeClusters")]
793 pub gke_clusters: Option<Vec<ManagedZonePrivateVisibilityConfigGKECluster>>,
794 /// no description provided
795 pub kind: Option<String>,
796 /// The list of VPC networks that can see this zone.
797 pub networks: Option<Vec<ManagedZonePrivateVisibilityConfigNetwork>>,
798}
799
800impl common::Part for ManagedZonePrivateVisibilityConfig {}
801
802/// There is no detailed description.
803///
804/// This type is not used in any activity, and only used as *part* of another schema.
805///
806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
807#[serde_with::serde_as]
808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
809pub struct ManagedZonePrivateVisibilityConfigGKECluster {
810 /// The resource name of the cluster to bind this ManagedZone to. This should be specified in the format like: projects/*/locations/*/clusters/*. This is referenced from GKE projects.locations.clusters.get API: https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/get
811 #[serde(rename = "gkeClusterName")]
812 pub gke_cluster_name: Option<String>,
813 /// no description provided
814 pub kind: Option<String>,
815}
816
817impl common::Part for ManagedZonePrivateVisibilityConfigGKECluster {}
818
819/// There is no detailed description.
820///
821/// This type is not used in any activity, and only used as *part* of another schema.
822///
823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
824#[serde_with::serde_as]
825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
826pub struct ManagedZonePrivateVisibilityConfigNetwork {
827 /// no description provided
828 pub kind: Option<String>,
829 /// The fully qualified URL of the VPC network to bind to. Format this URL like `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`
830 #[serde(rename = "networkUrl")]
831 pub network_url: Option<String>,
832}
833
834impl common::Part for ManagedZonePrivateVisibilityConfigNetwork {}
835
836/// There is no detailed description.
837///
838/// This type is not used in any activity, and only used as *part* of another schema.
839///
840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
841#[serde_with::serde_as]
842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
843pub struct ManagedZoneReverseLookupConfig {
844 /// no description provided
845 pub kind: Option<String>,
846}
847
848impl common::Part for ManagedZoneReverseLookupConfig {}
849
850/// Contains information about Service Directory-backed zones.
851///
852/// This type is not used in any activity, and only used as *part* of another schema.
853///
854#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
855#[serde_with::serde_as]
856#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
857pub struct ManagedZoneServiceDirectoryConfig {
858 /// no description provided
859 pub kind: Option<String>,
860 /// Contains information about the namespace associated with the zone.
861 pub namespace: Option<ManagedZoneServiceDirectoryConfigNamespace>,
862}
863
864impl common::Part for ManagedZoneServiceDirectoryConfig {}
865
866/// There is no detailed description.
867///
868/// This type is not used in any activity, and only used as *part* of another schema.
869///
870#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
871#[serde_with::serde_as]
872#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
873pub struct ManagedZoneServiceDirectoryConfigNamespace {
874 /// The time that the namespace backing this zone was deleted; an empty string if it still exists. This is in RFC3339 text format. Output only.
875 #[serde(rename = "deletionTime")]
876 pub deletion_time: Option<String>,
877 /// no description provided
878 pub kind: Option<String>,
879 /// The fully qualified URL of the namespace associated with the zone. Format must be `https://servicedirectory.googleapis.com/v1/projects/{project}/locations/{location}/namespaces/{namespace}`
880 #[serde(rename = "namespaceUrl")]
881 pub namespace_url: Option<String>,
882}
883
884impl common::Part for ManagedZoneServiceDirectoryConfigNamespace {}
885
886/// There is no detailed description.
887///
888/// # Activities
889///
890/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
891/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
892///
893/// * [list managed zones](ManagedZoneListCall) (response)
894#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
895#[serde_with::serde_as]
896#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
897pub struct ManagedZonesListResponse {
898 /// Type of resource.
899 pub kind: Option<String>,
900 /// The managed zone resources.
901 #[serde(rename = "managedZones")]
902 pub managed_zones: Option<Vec<ManagedZone>>,
903 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
904 #[serde(rename = "nextPageToken")]
905 pub next_page_token: Option<String>,
906}
907
908impl common::ResponseResult for ManagedZonesListResponse {}
909
910/// An operation represents a successful mutation performed on a Cloud DNS resource. Operations provide: - An audit log of server resource mutations. - A way to recover/retry API calls in the case where the response is never received by the caller. Use the caller specified client_operation_id.
911///
912/// # Activities
913///
914/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
915/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
916///
917/// * [get managed zone operations](ManagedZoneOperationGetCall) (response)
918/// * [patch managed zones](ManagedZonePatchCall) (response)
919/// * [update managed zones](ManagedZoneUpdateCall) (response)
920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
921#[serde_with::serde_as]
922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
923pub struct Operation {
924 /// Only populated if the operation targeted a DnsKey (output only).
925 #[serde(rename = "dnsKeyContext")]
926 pub dns_key_context: Option<OperationDnsKeyContext>,
927 /// Unique identifier for the resource. This is the client_operation_id if the client specified it when the mutation was initiated, otherwise, it is generated by the server. The name must be 1-63 characters long and match the regular expression [-a-z0-9]? (output only)
928 pub id: Option<String>,
929 /// no description provided
930 pub kind: Option<String>,
931 /// The time that this operation was started by the server. This is in RFC3339 text format (output only).
932 #[serde(rename = "startTime")]
933 pub start_time: Option<String>,
934 /// Status of the operation. Can be one of the following: "PENDING" or "DONE" (output only). A status of "DONE" means that the request to update the authoritative servers has been sent, but the servers might not be updated yet.
935 pub status: Option<String>,
936 /// Type of the operation. Operations include insert, update, and delete (output only).
937 #[serde(rename = "type")]
938 pub type_: Option<String>,
939 /// User who requested the operation, for example: user@example.com. cloud-dns-system for operations automatically done by the system. (output only)
940 pub user: Option<String>,
941 /// Only populated if the operation targeted a ManagedZone (output only).
942 #[serde(rename = "zoneContext")]
943 pub zone_context: Option<OperationManagedZoneContext>,
944}
945
946impl common::ResponseResult for Operation {}
947
948/// There is no detailed description.
949///
950/// This type is not used in any activity, and only used as *part* of another schema.
951///
952#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
953#[serde_with::serde_as]
954#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
955pub struct OperationDnsKeyContext {
956 /// The post-operation DnsKey resource.
957 #[serde(rename = "newValue")]
958 pub new_value: Option<DnsKey>,
959 /// The pre-operation DnsKey resource.
960 #[serde(rename = "oldValue")]
961 pub old_value: Option<DnsKey>,
962}
963
964impl common::Part for OperationDnsKeyContext {}
965
966/// There is no detailed description.
967///
968/// This type is not used in any activity, and only used as *part* of another schema.
969///
970#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
971#[serde_with::serde_as]
972#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
973pub struct OperationManagedZoneContext {
974 /// The post-operation ManagedZone resource.
975 #[serde(rename = "newValue")]
976 pub new_value: Option<ManagedZone>,
977 /// The pre-operation ManagedZone resource.
978 #[serde(rename = "oldValue")]
979 pub old_value: Option<ManagedZone>,
980}
981
982impl common::Part for OperationManagedZoneContext {}
983
984/// There is no detailed description.
985///
986/// # Activities
987///
988/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
989/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
990///
991/// * [list policies](PolicyListCall) (response)
992#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
993#[serde_with::serde_as]
994#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
995pub struct PoliciesListResponse {
996 /// Type of resource.
997 pub kind: Option<String>,
998 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
999 #[serde(rename = "nextPageToken")]
1000 pub next_page_token: Option<String>,
1001 /// The policy resources.
1002 pub policies: Option<Vec<Policy>>,
1003}
1004
1005impl common::ResponseResult for PoliciesListResponse {}
1006
1007/// There is no detailed description.
1008///
1009/// # Activities
1010///
1011/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1012/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1013///
1014/// * [patch policies](PolicyPatchCall) (response)
1015#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1016#[serde_with::serde_as]
1017#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1018pub struct PoliciesPatchResponse {
1019 /// no description provided
1020 pub policy: Option<Policy>,
1021}
1022
1023impl common::ResponseResult for PoliciesPatchResponse {}
1024
1025/// There is no detailed description.
1026///
1027/// # Activities
1028///
1029/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1030/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1031///
1032/// * [update policies](PolicyUpdateCall) (response)
1033#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1034#[serde_with::serde_as]
1035#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1036pub struct PoliciesUpdateResponse {
1037 /// no description provided
1038 pub policy: Option<Policy>,
1039}
1040
1041impl common::ResponseResult for PoliciesUpdateResponse {}
1042
1043/// A policy is a collection of DNS rules applied to one or more Virtual Private Cloud resources.
1044///
1045/// # Activities
1046///
1047/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1048/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1049///
1050/// * [create policies](PolicyCreateCall) (request|response)
1051/// * [get policies](PolicyGetCall) (response)
1052/// * [patch policies](PolicyPatchCall) (request)
1053/// * [update policies](PolicyUpdateCall) (request)
1054#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1055#[serde_with::serde_as]
1056#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1057pub struct Policy {
1058 /// Sets an alternative name server for the associated networks. When specified, all DNS queries are forwarded to a name server that you choose. Names such as .internal are not available when an alternative name server is specified.
1059 #[serde(rename = "alternativeNameServerConfig")]
1060 pub alternative_name_server_config: Option<PolicyAlternativeNameServerConfig>,
1061 /// A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the policy's function.
1062 pub description: Option<String>,
1063 /// Configurations related to DNS64 for this policy.
1064 #[serde(rename = "dns64Config")]
1065 pub dns64_config: Option<PolicyDns64Config>,
1066 /// Allows networks bound to this policy to receive DNS queries sent by VMs or applications over VPN connections. When enabled, a virtual IP address is allocated from each of the subnetworks that are bound to this policy.
1067 #[serde(rename = "enableInboundForwarding")]
1068 pub enable_inbound_forwarding: Option<bool>,
1069 /// Controls whether logging is enabled for the networks bound to this policy. Defaults to no logging if not set.
1070 #[serde(rename = "enableLogging")]
1071 pub enable_logging: Option<bool>,
1072 /// Unique identifier for the resource; defined by the server (output only).
1073 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1074 pub id: Option<u64>,
1075 /// no description provided
1076 pub kind: Option<String>,
1077 /// User-assigned name for this policy.
1078 pub name: Option<String>,
1079 /// List of network names specifying networks to which this policy is applied.
1080 pub networks: Option<Vec<PolicyNetwork>>,
1081}
1082
1083impl common::RequestValue for Policy {}
1084impl common::ResponseResult for Policy {}
1085
1086/// There is no detailed description.
1087///
1088/// This type is not used in any activity, and only used as *part* of another schema.
1089///
1090#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1091#[serde_with::serde_as]
1092#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1093pub struct PolicyAlternativeNameServerConfig {
1094 /// no description provided
1095 pub kind: Option<String>,
1096 /// Sets an alternative name server for the associated networks. When specified, all DNS queries are forwarded to a name server that you choose. Names such as .internal are not available when an alternative name server is specified.
1097 #[serde(rename = "targetNameServers")]
1098 pub target_name_servers: Option<Vec<PolicyAlternativeNameServerConfigTargetNameServer>>,
1099}
1100
1101impl common::Part for PolicyAlternativeNameServerConfig {}
1102
1103/// There is no detailed description.
1104///
1105/// This type is not used in any activity, and only used as *part* of another schema.
1106///
1107#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1108#[serde_with::serde_as]
1109#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1110pub struct PolicyAlternativeNameServerConfigTargetNameServer {
1111 /// Forwarding path for this TargetNameServer. If unset or set to DEFAULT, Cloud DNS makes forwarding decisions based on address ranges; that is, RFC1918 addresses go to the VPC network, non-RFC1918 addresses go to the internet. When set to PRIVATE, Cloud DNS always sends queries through the VPC network for this target.
1112 #[serde(rename = "forwardingPath")]
1113 pub forwarding_path: Option<String>,
1114 /// IPv4 address to forward queries to.
1115 #[serde(rename = "ipv4Address")]
1116 pub ipv4_address: Option<String>,
1117 /// IPv6 address to forward to. Does not accept both fields (ipv4 & ipv6) being populated. Public preview as of November 2022.
1118 #[serde(rename = "ipv6Address")]
1119 pub ipv6_address: Option<String>,
1120 /// no description provided
1121 pub kind: Option<String>,
1122}
1123
1124impl common::Part for PolicyAlternativeNameServerConfigTargetNameServer {}
1125
1126/// DNS64 policies
1127///
1128/// This type is not used in any activity, and only used as *part* of another schema.
1129///
1130#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1131#[serde_with::serde_as]
1132#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1133pub struct PolicyDns64Config {
1134 /// no description provided
1135 pub kind: Option<String>,
1136 /// The scope to which DNS64 config will be applied to.
1137 pub scope: Option<PolicyDns64ConfigScope>,
1138}
1139
1140impl common::Part for PolicyDns64Config {}
1141
1142/// There is no detailed description.
1143///
1144/// This type is not used in any activity, and only used as *part* of another schema.
1145///
1146#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1147#[serde_with::serde_as]
1148#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1149pub struct PolicyDns64ConfigScope {
1150 /// Controls whether DNS64 is enabled globally for all networks bound to the policy.
1151 #[serde(rename = "allQueries")]
1152 pub all_queries: Option<bool>,
1153 /// no description provided
1154 pub kind: Option<String>,
1155}
1156
1157impl common::Part for PolicyDns64ConfigScope {}
1158
1159/// There is no detailed description.
1160///
1161/// This type is not used in any activity, and only used as *part* of another schema.
1162///
1163#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1164#[serde_with::serde_as]
1165#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1166pub struct PolicyNetwork {
1167 /// no description provided
1168 pub kind: Option<String>,
1169 /// The fully qualified URL of the VPC network to bind to. This should be formatted like https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}
1170 #[serde(rename = "networkUrl")]
1171 pub network_url: Option<String>,
1172}
1173
1174impl common::Part for PolicyNetwork {}
1175
1176/// A project resource. The project is a top level container for resources including Cloud DNS ManagedZones. Projects can be created only in the APIs console.
1177///
1178/// # Activities
1179///
1180/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1181/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1182///
1183/// * [get projects](ProjectGetCall) (response)
1184#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1185#[serde_with::serde_as]
1186#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1187pub struct Project {
1188 /// User assigned unique identifier for the resource (output only).
1189 pub id: Option<String>,
1190 /// no description provided
1191 pub kind: Option<String>,
1192 /// Unique numeric identifier for the resource; defined by the server (output only).
1193 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1194 pub number: Option<u64>,
1195 /// Quotas assigned to this project (output only).
1196 pub quota: Option<Quota>,
1197}
1198
1199impl common::Resource for Project {}
1200impl common::ResponseResult for Project {}
1201
1202/// Limits associated with a Project.
1203///
1204/// This type is not used in any activity, and only used as *part* of another schema.
1205///
1206#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1207#[serde_with::serde_as]
1208#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1209pub struct Quota {
1210 /// Maximum allowed number of DnsKeys per ManagedZone.
1211 #[serde(rename = "dnsKeysPerManagedZone")]
1212 pub dns_keys_per_managed_zone: Option<i32>,
1213 /// Maximum allowed number of GKE clusters to which a privately scoped zone can be attached.
1214 #[serde(rename = "gkeClustersPerManagedZone")]
1215 pub gke_clusters_per_managed_zone: Option<i32>,
1216 /// Maximum allowed number of GKE clusters per policy.
1217 #[serde(rename = "gkeClustersPerPolicy")]
1218 pub gke_clusters_per_policy: Option<i32>,
1219 /// Maximum allowed number of GKE clusters per response policy.
1220 #[serde(rename = "gkeClustersPerResponsePolicy")]
1221 pub gke_clusters_per_response_policy: Option<i32>,
1222 /// no description provided
1223 #[serde(rename = "internetHealthChecksPerManagedZone")]
1224 pub internet_health_checks_per_managed_zone: Option<i32>,
1225 /// Maximum allowed number of items per routing policy.
1226 #[serde(rename = "itemsPerRoutingPolicy")]
1227 pub items_per_routing_policy: Option<i32>,
1228 /// no description provided
1229 pub kind: Option<String>,
1230 /// Maximum allowed number of managed zones in the project.
1231 #[serde(rename = "managedZones")]
1232 pub managed_zones: Option<i32>,
1233 /// Maximum allowed number of managed zones which can be attached to a GKE cluster.
1234 #[serde(rename = "managedZonesPerGkeCluster")]
1235 pub managed_zones_per_gke_cluster: Option<i32>,
1236 /// Maximum allowed number of managed zones which can be attached to a network.
1237 #[serde(rename = "managedZonesPerNetwork")]
1238 pub managed_zones_per_network: Option<i32>,
1239 /// Maximum number of nameservers per delegation, meant to prevent abuse
1240 #[serde(rename = "nameserversPerDelegation")]
1241 pub nameservers_per_delegation: Option<i32>,
1242 /// Maximum allowed number of networks to which a privately scoped zone can be attached.
1243 #[serde(rename = "networksPerManagedZone")]
1244 pub networks_per_managed_zone: Option<i32>,
1245 /// Maximum allowed number of networks per policy.
1246 #[serde(rename = "networksPerPolicy")]
1247 pub networks_per_policy: Option<i32>,
1248 /// Maximum allowed number of networks per response policy.
1249 #[serde(rename = "networksPerResponsePolicy")]
1250 pub networks_per_response_policy: Option<i32>,
1251 /// Maximum allowed number of consumer peering zones per target network owned by this producer project
1252 #[serde(rename = "peeringZonesPerTargetNetwork")]
1253 pub peering_zones_per_target_network: Option<i32>,
1254 /// Maximum allowed number of policies per project.
1255 pub policies: Option<i32>,
1256 /// Maximum allowed number of ResourceRecords per ResourceRecordSet.
1257 #[serde(rename = "resourceRecordsPerRrset")]
1258 pub resource_records_per_rrset: Option<i32>,
1259 /// Maximum allowed number of response policies per project.
1260 #[serde(rename = "responsePolicies")]
1261 pub response_policies: Option<i32>,
1262 /// Maximum allowed number of rules per response policy.
1263 #[serde(rename = "responsePolicyRulesPerResponsePolicy")]
1264 pub response_policy_rules_per_response_policy: Option<i32>,
1265 /// Maximum allowed number of ResourceRecordSets to add per ChangesCreateRequest.
1266 #[serde(rename = "rrsetAdditionsPerChange")]
1267 pub rrset_additions_per_change: Option<i32>,
1268 /// Maximum allowed number of ResourceRecordSets to delete per ChangesCreateRequest.
1269 #[serde(rename = "rrsetDeletionsPerChange")]
1270 pub rrset_deletions_per_change: Option<i32>,
1271 /// Maximum allowed number of ResourceRecordSets per zone in the project.
1272 #[serde(rename = "rrsetsPerManagedZone")]
1273 pub rrsets_per_managed_zone: Option<i32>,
1274 /// Maximum allowed number of target name servers per managed forwarding zone.
1275 #[serde(rename = "targetNameServersPerManagedZone")]
1276 pub target_name_servers_per_managed_zone: Option<i32>,
1277 /// Maximum allowed number of alternative target name servers per policy.
1278 #[serde(rename = "targetNameServersPerPolicy")]
1279 pub target_name_servers_per_policy: Option<i32>,
1280 /// Maximum allowed size for total rrdata in one ChangesCreateRequest in bytes.
1281 #[serde(rename = "totalRrdataSizePerChange")]
1282 pub total_rrdata_size_per_change: Option<i32>,
1283 /// DNSSEC algorithm and key length types that can be used for DnsKeys.
1284 #[serde(rename = "whitelistedKeySpecs")]
1285 pub whitelisted_key_specs: Option<Vec<DnsKeySpec>>,
1286}
1287
1288impl common::Part for Quota {}
1289
1290/// A RRSetRoutingPolicy represents ResourceRecordSet data that is returned dynamically with the response varying based on configured properties such as geolocation or by weighted random selection.
1291///
1292/// This type is not used in any activity, and only used as *part* of another schema.
1293///
1294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1295#[serde_with::serde_as]
1296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1297pub struct RRSetRoutingPolicy {
1298 /// no description provided
1299 pub geo: Option<RRSetRoutingPolicyGeoPolicy>,
1300 /// The fully qualified URL of the HealthCheck to use for this RRSetRoutingPolicy. Format this URL like `https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{healthCheck}`. https://cloud.google.com/compute/docs/reference/rest/v1/healthChecks
1301 #[serde(rename = "healthCheck")]
1302 pub health_check: Option<String>,
1303 /// no description provided
1304 pub kind: Option<String>,
1305 /// no description provided
1306 #[serde(rename = "primaryBackup")]
1307 pub primary_backup: Option<RRSetRoutingPolicyPrimaryBackupPolicy>,
1308 /// no description provided
1309 pub wrr: Option<RRSetRoutingPolicyWrrPolicy>,
1310}
1311
1312impl common::Part for RRSetRoutingPolicy {}
1313
1314/// Configures a `RRSetRoutingPolicy` that routes based on the geo location of the querying user.
1315///
1316/// This type is not used in any activity, and only used as *part* of another schema.
1317///
1318#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1319#[serde_with::serde_as]
1320#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1321pub struct RRSetRoutingPolicyGeoPolicy {
1322 /// Without fencing, if health check fails for all configured items in the current geo bucket, we failover to the next nearest geo bucket. With fencing, if health checking is enabled, as long as some targets in the current geo bucket are healthy, we return only the healthy targets. However, if all targets are unhealthy, we don't failover to the next nearest bucket; instead, we return all the items in the current bucket even when all targets are unhealthy.
1323 #[serde(rename = "enableFencing")]
1324 pub enable_fencing: Option<bool>,
1325 /// The primary geo routing configuration. If there are multiple items with the same location, an error is returned instead.
1326 pub items: Option<Vec<RRSetRoutingPolicyGeoPolicyGeoPolicyItem>>,
1327 /// no description provided
1328 pub kind: Option<String>,
1329}
1330
1331impl common::Part for RRSetRoutingPolicyGeoPolicy {}
1332
1333/// ResourceRecordSet data for one geo location.
1334///
1335/// This type is not used in any activity, and only used as *part* of another schema.
1336///
1337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1338#[serde_with::serde_as]
1339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1340pub struct RRSetRoutingPolicyGeoPolicyGeoPolicyItem {
1341 /// For A and AAAA types only. Endpoints to return in the query result only if they are healthy. These can be specified along with `rrdata` within this item.
1342 #[serde(rename = "healthCheckedTargets")]
1343 pub health_checked_targets: Option<RRSetRoutingPolicyHealthCheckTargets>,
1344 /// no description provided
1345 pub kind: Option<String>,
1346 /// The geo-location granularity is a GCP region. This location string should correspond to a GCP region. e.g. "us-east1", "southamerica-east1", "asia-east1", etc.
1347 pub location: Option<String>,
1348 /// no description provided
1349 pub rrdatas: Option<Vec<String>>,
1350 /// DNSSEC generated signatures for all the `rrdata` within this item. When using health-checked targets for DNSSEC-enabled zones, you can only use at most one health-checked IP address per item.
1351 #[serde(rename = "signatureRrdatas")]
1352 pub signature_rrdatas: Option<Vec<String>>,
1353}
1354
1355impl common::Part for RRSetRoutingPolicyGeoPolicyGeoPolicyItem {}
1356
1357/// HealthCheckTargets describes endpoints to health-check when responding to Routing Policy queries. Only the healthy endpoints will be included in the response. Set either `internal_load_balancer` or `external_endpoints`. Do not set both.
1358///
1359/// This type is not used in any activity, and only used as *part* of another schema.
1360///
1361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1362#[serde_with::serde_as]
1363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1364pub struct RRSetRoutingPolicyHealthCheckTargets {
1365 /// The Internet IP addresses to be health checked. The format matches the format of ResourceRecordSet.rrdata as defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1)
1366 #[serde(rename = "externalEndpoints")]
1367 pub external_endpoints: Option<Vec<String>>,
1368 /// Configuration for internal load balancers to be health checked.
1369 #[serde(rename = "internalLoadBalancers")]
1370 pub internal_load_balancers: Option<Vec<RRSetRoutingPolicyLoadBalancerTarget>>,
1371}
1372
1373impl common::Part for RRSetRoutingPolicyHealthCheckTargets {}
1374
1375/// The configuration for an individual load balancer to health check.
1376///
1377/// This type is not used in any activity, and only used as *part* of another schema.
1378///
1379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1380#[serde_with::serde_as]
1381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1382pub struct RRSetRoutingPolicyLoadBalancerTarget {
1383 /// The frontend IP address of the load balancer to health check.
1384 #[serde(rename = "ipAddress")]
1385 pub ip_address: Option<String>,
1386 /// The protocol of the load balancer to health check.
1387 #[serde(rename = "ipProtocol")]
1388 pub ip_protocol: Option<String>,
1389 /// no description provided
1390 pub kind: Option<String>,
1391 /// The type of load balancer specified by this target. This value must match the configuration of the load balancer located at the LoadBalancerTarget's IP address, port, and region. Use the following: - *regionalL4ilb*: for a regional internal passthrough Network Load Balancer. - *regionalL7ilb*: for a regional internal Application Load Balancer. - *globalL7ilb*: for a global internal Application Load Balancer.
1392 #[serde(rename = "loadBalancerType")]
1393 pub load_balancer_type: Option<String>,
1394 /// The fully qualified URL of the network that the load balancer is attached to. This should be formatted like `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`.
1395 #[serde(rename = "networkUrl")]
1396 pub network_url: Option<String>,
1397 /// The configured port of the load balancer.
1398 pub port: Option<String>,
1399 /// The project ID in which the load balancer is located.
1400 pub project: Option<String>,
1401 /// The region in which the load balancer is located.
1402 pub region: Option<String>,
1403}
1404
1405impl common::Part for RRSetRoutingPolicyLoadBalancerTarget {}
1406
1407/// Configures a RRSetRoutingPolicy such that all queries are responded with the primary_targets if they are healthy. And if all of them are unhealthy, then we fallback to a geo localized policy.
1408///
1409/// This type is not used in any activity, and only used as *part* of another schema.
1410///
1411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1412#[serde_with::serde_as]
1413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1414pub struct RRSetRoutingPolicyPrimaryBackupPolicy {
1415 /// Backup targets provide a regional failover policy for the otherwise global primary targets. If serving state is set to `BACKUP`, this policy essentially becomes a geo routing policy.
1416 #[serde(rename = "backupGeoTargets")]
1417 pub backup_geo_targets: Option<RRSetRoutingPolicyGeoPolicy>,
1418 /// no description provided
1419 pub kind: Option<String>,
1420 /// Endpoints that are health checked before making the routing decision. Unhealthy endpoints are omitted from the results. If all endpoints are unhealthy, we serve a response based on the `backup_geo_targets`.
1421 #[serde(rename = "primaryTargets")]
1422 pub primary_targets: Option<RRSetRoutingPolicyHealthCheckTargets>,
1423 /// When serving state is `PRIMARY`, this field provides the option of sending a small percentage of the traffic to the backup targets.
1424 #[serde(rename = "trickleTraffic")]
1425 pub trickle_traffic: Option<f64>,
1426}
1427
1428impl common::Part for RRSetRoutingPolicyPrimaryBackupPolicy {}
1429
1430/// Configures a RRSetRoutingPolicy that routes in a weighted round robin fashion.
1431///
1432/// This type is not used in any activity, and only used as *part* of another schema.
1433///
1434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1435#[serde_with::serde_as]
1436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1437pub struct RRSetRoutingPolicyWrrPolicy {
1438 /// no description provided
1439 pub items: Option<Vec<RRSetRoutingPolicyWrrPolicyWrrPolicyItem>>,
1440 /// no description provided
1441 pub kind: Option<String>,
1442}
1443
1444impl common::Part for RRSetRoutingPolicyWrrPolicy {}
1445
1446/// A routing block which contains the routing information for one WRR item.
1447///
1448/// This type is not used in any activity, and only used as *part* of another schema.
1449///
1450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1451#[serde_with::serde_as]
1452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1453pub struct RRSetRoutingPolicyWrrPolicyWrrPolicyItem {
1454 /// Endpoints that are health checked before making the routing decision. The unhealthy endpoints are omitted from the result. If all endpoints within a bucket are unhealthy, we choose a different bucket (sampled with respect to its weight) for responding. If DNSSEC is enabled for this zone, only one of `rrdata` or `health_checked_targets` can be set.
1455 #[serde(rename = "healthCheckedTargets")]
1456 pub health_checked_targets: Option<RRSetRoutingPolicyHealthCheckTargets>,
1457 /// no description provided
1458 pub kind: Option<String>,
1459 /// no description provided
1460 pub rrdatas: Option<Vec<String>>,
1461 /// DNSSEC generated signatures for all the `rrdata` within this item. When using health-checked targets for DNSSEC-enabled zones, you can only use at most one health-checked IP address per item.
1462 #[serde(rename = "signatureRrdatas")]
1463 pub signature_rrdatas: Option<Vec<String>>,
1464 /// The weight corresponding to this `WrrPolicyItem` object. When multiple `WrrPolicyItem` objects are configured, the probability of returning an `WrrPolicyItem` object's data is proportional to its weight relative to the sum of weights configured for all items. This weight must be non-negative.
1465 pub weight: Option<f64>,
1466}
1467
1468impl common::Part for RRSetRoutingPolicyWrrPolicyWrrPolicyItem {}
1469
1470/// A unit of data that is returned by the DNS servers.
1471///
1472/// # Activities
1473///
1474/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1475/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1476///
1477/// * [create resource record sets](ResourceRecordSetCreateCall) (request|response)
1478/// * [delete resource record sets](ResourceRecordSetDeleteCall) (none)
1479/// * [get resource record sets](ResourceRecordSetGetCall) (response)
1480/// * [list resource record sets](ResourceRecordSetListCall) (none)
1481/// * [patch resource record sets](ResourceRecordSetPatchCall) (request|response)
1482#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1483#[serde_with::serde_as]
1484#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1485pub struct ResourceRecordSet {
1486 /// no description provided
1487 pub kind: Option<String>,
1488 /// For example, www.example.com.
1489 pub name: Option<String>,
1490 /// Configures dynamic query responses based on either the geo location of the querying user or a weighted round robin based routing policy. A valid `ResourceRecordSet` contains only `rrdata` (for static resolution) or a `routing_policy` (for dynamic resolution).
1491 #[serde(rename = "routingPolicy")]
1492 pub routing_policy: Option<RRSetRoutingPolicy>,
1493 /// As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) -- see examples.
1494 pub rrdatas: Option<Vec<String>>,
1495 /// As defined in RFC 4034 (section 3.2).
1496 #[serde(rename = "signatureRrdatas")]
1497 pub signature_rrdatas: Option<Vec<String>>,
1498 /// Number of seconds that this `ResourceRecordSet` can be cached by resolvers.
1499 pub ttl: Option<i32>,
1500 /// The identifier of a supported record type. See the list of Supported DNS record types.
1501 #[serde(rename = "type")]
1502 pub type_: Option<String>,
1503}
1504
1505impl common::RequestValue for ResourceRecordSet {}
1506impl common::Resource for ResourceRecordSet {}
1507impl common::ResponseResult for ResourceRecordSet {}
1508
1509/// There is no detailed description.
1510///
1511/// # Activities
1512///
1513/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1514/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1515///
1516/// * [list resource record sets](ResourceRecordSetListCall) (response)
1517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1518#[serde_with::serde_as]
1519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1520pub struct ResourceRecordSetsListResponse {
1521 /// Type of resource.
1522 pub kind: Option<String>,
1523 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
1524 #[serde(rename = "nextPageToken")]
1525 pub next_page_token: Option<String>,
1526 /// The resource record set resources.
1527 pub rrsets: Option<Vec<ResourceRecordSet>>,
1528}
1529
1530impl common::ResponseResult for ResourceRecordSetsListResponse {}
1531
1532/// There is no detailed description.
1533///
1534/// # Activities
1535///
1536/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1537/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1538///
1539/// * [list response policies](ResponsePolicyListCall) (response)
1540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1541#[serde_with::serde_as]
1542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1543pub struct ResponsePoliciesListResponse {
1544 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
1545 #[serde(rename = "nextPageToken")]
1546 pub next_page_token: Option<String>,
1547 /// The Response Policy resources.
1548 #[serde(rename = "responsePolicies")]
1549 pub response_policies: Option<Vec<ResponsePolicy>>,
1550}
1551
1552impl common::ResponseResult for ResponsePoliciesListResponse {}
1553
1554/// There is no detailed description.
1555///
1556/// # Activities
1557///
1558/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1559/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1560///
1561/// * [patch response policies](ResponsePolicyPatchCall) (response)
1562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1563#[serde_with::serde_as]
1564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1565pub struct ResponsePoliciesPatchResponse {
1566 /// no description provided
1567 #[serde(rename = "responsePolicy")]
1568 pub response_policy: Option<ResponsePolicy>,
1569}
1570
1571impl common::ResponseResult for ResponsePoliciesPatchResponse {}
1572
1573/// There is no detailed description.
1574///
1575/// # Activities
1576///
1577/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1578/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1579///
1580/// * [update response policies](ResponsePolicyUpdateCall) (response)
1581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1582#[serde_with::serde_as]
1583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1584pub struct ResponsePoliciesUpdateResponse {
1585 /// no description provided
1586 #[serde(rename = "responsePolicy")]
1587 pub response_policy: Option<ResponsePolicy>,
1588}
1589
1590impl common::ResponseResult for ResponsePoliciesUpdateResponse {}
1591
1592/// A Response Policy is a collection of selectors that apply to queries made against one or more Virtual Private Cloud networks.
1593///
1594/// # Activities
1595///
1596/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1597/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1598///
1599/// * [create response policies](ResponsePolicyCreateCall) (request|response)
1600/// * [get response policies](ResponsePolicyGetCall) (response)
1601/// * [patch response policies](ResponsePolicyPatchCall) (request)
1602/// * [update response policies](ResponsePolicyUpdateCall) (request)
1603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1604#[serde_with::serde_as]
1605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1606pub struct ResponsePolicy {
1607 /// User-provided description for this Response Policy.
1608 pub description: Option<String>,
1609 /// The list of Google Kubernetes Engine clusters to which this response policy is applied.
1610 #[serde(rename = "gkeClusters")]
1611 pub gke_clusters: Option<Vec<ResponsePolicyGKECluster>>,
1612 /// Unique identifier for the resource; defined by the server (output only).
1613 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1614 pub id: Option<i64>,
1615 /// no description provided
1616 pub kind: Option<String>,
1617 /// User labels.
1618 pub labels: Option<HashMap<String, String>>,
1619 /// List of network names specifying networks to which this policy is applied.
1620 pub networks: Option<Vec<ResponsePolicyNetwork>>,
1621 /// User assigned name for this Response Policy.
1622 #[serde(rename = "responsePolicyName")]
1623 pub response_policy_name: Option<String>,
1624}
1625
1626impl common::RequestValue for ResponsePolicy {}
1627impl common::ResponseResult for ResponsePolicy {}
1628
1629/// There is no detailed description.
1630///
1631/// This type is not used in any activity, and only used as *part* of another schema.
1632///
1633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1634#[serde_with::serde_as]
1635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1636pub struct ResponsePolicyGKECluster {
1637 /// The resource name of the cluster to bind this response policy to. This should be specified in the format like: projects/*/locations/*/clusters/*. This is referenced from GKE projects.locations.clusters.get API: https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/get
1638 #[serde(rename = "gkeClusterName")]
1639 pub gke_cluster_name: Option<String>,
1640 /// no description provided
1641 pub kind: Option<String>,
1642}
1643
1644impl common::Part for ResponsePolicyGKECluster {}
1645
1646/// There is no detailed description.
1647///
1648/// This type is not used in any activity, and only used as *part* of another schema.
1649///
1650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1651#[serde_with::serde_as]
1652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1653pub struct ResponsePolicyNetwork {
1654 /// no description provided
1655 pub kind: Option<String>,
1656 /// The fully qualified URL of the VPC network to bind to. This should be formatted like `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`
1657 #[serde(rename = "networkUrl")]
1658 pub network_url: Option<String>,
1659}
1660
1661impl common::Part for ResponsePolicyNetwork {}
1662
1663/// A Response Policy Rule is a selector that applies its behavior to queries that match the selector. Selectors are DNS names, which may be wildcards or exact matches. Each DNS query subject to a Response Policy matches at most one ResponsePolicyRule, as identified by the dns_name field with the longest matching suffix.
1664///
1665/// # Activities
1666///
1667/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1668/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1669///
1670/// * [create response policy rules](ResponsePolicyRuleCreateCall) (request|response)
1671/// * [delete response policy rules](ResponsePolicyRuleDeleteCall) (none)
1672/// * [get response policy rules](ResponsePolicyRuleGetCall) (response)
1673/// * [list response policy rules](ResponsePolicyRuleListCall) (none)
1674/// * [patch response policy rules](ResponsePolicyRulePatchCall) (request)
1675/// * [update response policy rules](ResponsePolicyRuleUpdateCall) (request)
1676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1677#[serde_with::serde_as]
1678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1679pub struct ResponsePolicyRule {
1680 /// Answer this query with a behavior rather than DNS data.
1681 pub behavior: Option<String>,
1682 /// The DNS name (wildcard or exact) to apply this rule to. Must be unique within the Response Policy Rule.
1683 #[serde(rename = "dnsName")]
1684 pub dns_name: Option<String>,
1685 /// no description provided
1686 pub kind: Option<String>,
1687 /// Answer this query directly with DNS data. These ResourceRecordSets override any other DNS behavior for the matched name; in particular they override private zones, the public internet, and GCP internal DNS. No SOA nor NS types are allowed.
1688 #[serde(rename = "localData")]
1689 pub local_data: Option<ResponsePolicyRuleLocalData>,
1690 /// An identifier for this rule. Must be unique with the ResponsePolicy.
1691 #[serde(rename = "ruleName")]
1692 pub rule_name: Option<String>,
1693}
1694
1695impl common::RequestValue for ResponsePolicyRule {}
1696impl common::Resource for ResponsePolicyRule {}
1697impl common::ResponseResult for ResponsePolicyRule {}
1698
1699/// There is no detailed description.
1700///
1701/// This type is not used in any activity, and only used as *part* of another schema.
1702///
1703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1704#[serde_with::serde_as]
1705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1706pub struct ResponsePolicyRuleLocalData {
1707 /// All resource record sets for this selector, one per resource record type. The name must match the dns_name.
1708 #[serde(rename = "localDatas")]
1709 pub local_datas: Option<Vec<ResourceRecordSet>>,
1710}
1711
1712impl common::Part for ResponsePolicyRuleLocalData {}
1713
1714/// There is no detailed description.
1715///
1716/// # Activities
1717///
1718/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1719/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1720///
1721/// * [list response policy rules](ResponsePolicyRuleListCall) (response)
1722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1723#[serde_with::serde_as]
1724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1725pub struct ResponsePolicyRulesListResponse {
1726 /// This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size.
1727 #[serde(rename = "nextPageToken")]
1728 pub next_page_token: Option<String>,
1729 /// The Response Policy Rule resources.
1730 #[serde(rename = "responsePolicyRules")]
1731 pub response_policy_rules: Option<Vec<ResponsePolicyRule>>,
1732}
1733
1734impl common::ResponseResult for ResponsePolicyRulesListResponse {}
1735
1736/// There is no detailed description.
1737///
1738/// # Activities
1739///
1740/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1741/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1742///
1743/// * [patch response policy rules](ResponsePolicyRulePatchCall) (response)
1744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1745#[serde_with::serde_as]
1746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1747pub struct ResponsePolicyRulesPatchResponse {
1748 /// no description provided
1749 #[serde(rename = "responsePolicyRule")]
1750 pub response_policy_rule: Option<ResponsePolicyRule>,
1751}
1752
1753impl common::ResponseResult for ResponsePolicyRulesPatchResponse {}
1754
1755/// There is no detailed description.
1756///
1757/// # Activities
1758///
1759/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1760/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1761///
1762/// * [update response policy rules](ResponsePolicyRuleUpdateCall) (response)
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct ResponsePolicyRulesUpdateResponse {
1767 /// no description provided
1768 #[serde(rename = "responsePolicyRule")]
1769 pub response_policy_rule: Option<ResponsePolicyRule>,
1770}
1771
1772impl common::ResponseResult for ResponsePolicyRulesUpdateResponse {}
1773
1774// ###################
1775// MethodBuilders ###
1776// #################
1777
1778/// A builder providing access to all methods supported on *change* resources.
1779/// It is not used directly, but through the [`Dns`] hub.
1780///
1781/// # Example
1782///
1783/// Instantiate a resource builder
1784///
1785/// ```test_harness,no_run
1786/// extern crate hyper;
1787/// extern crate hyper_rustls;
1788/// extern crate google_dns2 as dns2;
1789///
1790/// # async fn dox() {
1791/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1792///
1793/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1794/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1795/// .with_native_roots()
1796/// .unwrap()
1797/// .https_only()
1798/// .enable_http2()
1799/// .build();
1800///
1801/// let executor = hyper_util::rt::TokioExecutor::new();
1802/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1803/// secret,
1804/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1805/// yup_oauth2::client::CustomHyperClientBuilder::from(
1806/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1807/// ),
1808/// ).build().await.unwrap();
1809///
1810/// let client = hyper_util::client::legacy::Client::builder(
1811/// hyper_util::rt::TokioExecutor::new()
1812/// )
1813/// .build(
1814/// hyper_rustls::HttpsConnectorBuilder::new()
1815/// .with_native_roots()
1816/// .unwrap()
1817/// .https_or_http()
1818/// .enable_http2()
1819/// .build()
1820/// );
1821/// let mut hub = Dns::new(client, auth);
1822/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1823/// // like `create(...)`, `get(...)` and `list(...)`
1824/// // to build up your call.
1825/// let rb = hub.changes();
1826/// # }
1827/// ```
1828pub struct ChangeMethods<'a, C>
1829where
1830 C: 'a,
1831{
1832 hub: &'a Dns<C>,
1833}
1834
1835impl<'a, C> common::MethodsBuilder for ChangeMethods<'a, C> {}
1836
1837impl<'a, C> ChangeMethods<'a, C> {
1838 /// Create a builder to help you perform the following task:
1839 ///
1840 /// Atomically updates the ResourceRecordSet collection.
1841 ///
1842 /// # Arguments
1843 ///
1844 /// * `request` - No description provided.
1845 /// * `project` - Identifies the project addressed by this request.
1846 /// * `location` - No description provided.
1847 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1848 pub fn create(
1849 &self,
1850 request: Change,
1851 project: &str,
1852 location: &str,
1853 managed_zone: &str,
1854 ) -> ChangeCreateCall<'a, C> {
1855 ChangeCreateCall {
1856 hub: self.hub,
1857 _request: request,
1858 _project: project.to_string(),
1859 _location: location.to_string(),
1860 _managed_zone: managed_zone.to_string(),
1861 _client_operation_id: Default::default(),
1862 _delegate: Default::default(),
1863 _additional_params: Default::default(),
1864 _scopes: Default::default(),
1865 }
1866 }
1867
1868 /// Create a builder to help you perform the following task:
1869 ///
1870 /// Fetches the representation of an existing Change.
1871 ///
1872 /// # Arguments
1873 ///
1874 /// * `project` - Identifies the project addressed by this request.
1875 /// * `location` - No description provided.
1876 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1877 /// * `changeId` - The identifier of the requested change, from a previous ResourceRecordSetsChangeResponse.
1878 pub fn get(
1879 &self,
1880 project: &str,
1881 location: &str,
1882 managed_zone: &str,
1883 change_id: &str,
1884 ) -> ChangeGetCall<'a, C> {
1885 ChangeGetCall {
1886 hub: self.hub,
1887 _project: project.to_string(),
1888 _location: location.to_string(),
1889 _managed_zone: managed_zone.to_string(),
1890 _change_id: change_id.to_string(),
1891 _client_operation_id: Default::default(),
1892 _delegate: Default::default(),
1893 _additional_params: Default::default(),
1894 _scopes: Default::default(),
1895 }
1896 }
1897
1898 /// Create a builder to help you perform the following task:
1899 ///
1900 /// Enumerates Changes to a ResourceRecordSet collection.
1901 ///
1902 /// # Arguments
1903 ///
1904 /// * `project` - Identifies the project addressed by this request.
1905 /// * `location` - No description provided.
1906 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1907 pub fn list(&self, project: &str, location: &str, managed_zone: &str) -> ChangeListCall<'a, C> {
1908 ChangeListCall {
1909 hub: self.hub,
1910 _project: project.to_string(),
1911 _location: location.to_string(),
1912 _managed_zone: managed_zone.to_string(),
1913 _sort_order: Default::default(),
1914 _sort_by: Default::default(),
1915 _page_token: Default::default(),
1916 _max_results: Default::default(),
1917 _delegate: Default::default(),
1918 _additional_params: Default::default(),
1919 _scopes: Default::default(),
1920 }
1921 }
1922}
1923
1924/// A builder providing access to all methods supported on *dnsKey* resources.
1925/// It is not used directly, but through the [`Dns`] hub.
1926///
1927/// # Example
1928///
1929/// Instantiate a resource builder
1930///
1931/// ```test_harness,no_run
1932/// extern crate hyper;
1933/// extern crate hyper_rustls;
1934/// extern crate google_dns2 as dns2;
1935///
1936/// # async fn dox() {
1937/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1938///
1939/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1940/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1941/// .with_native_roots()
1942/// .unwrap()
1943/// .https_only()
1944/// .enable_http2()
1945/// .build();
1946///
1947/// let executor = hyper_util::rt::TokioExecutor::new();
1948/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1949/// secret,
1950/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1951/// yup_oauth2::client::CustomHyperClientBuilder::from(
1952/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1953/// ),
1954/// ).build().await.unwrap();
1955///
1956/// let client = hyper_util::client::legacy::Client::builder(
1957/// hyper_util::rt::TokioExecutor::new()
1958/// )
1959/// .build(
1960/// hyper_rustls::HttpsConnectorBuilder::new()
1961/// .with_native_roots()
1962/// .unwrap()
1963/// .https_or_http()
1964/// .enable_http2()
1965/// .build()
1966/// );
1967/// let mut hub = Dns::new(client, auth);
1968/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1969/// // like `get(...)` and `list(...)`
1970/// // to build up your call.
1971/// let rb = hub.dns_keys();
1972/// # }
1973/// ```
1974pub struct DnsKeyMethods<'a, C>
1975where
1976 C: 'a,
1977{
1978 hub: &'a Dns<C>,
1979}
1980
1981impl<'a, C> common::MethodsBuilder for DnsKeyMethods<'a, C> {}
1982
1983impl<'a, C> DnsKeyMethods<'a, C> {
1984 /// Create a builder to help you perform the following task:
1985 ///
1986 /// Fetches the representation of an existing DnsKey.
1987 ///
1988 /// # Arguments
1989 ///
1990 /// * `project` - Identifies the project addressed by this request.
1991 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
1992 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1993 /// * `dnsKeyId` - The identifier of the requested DnsKey.
1994 pub fn get(
1995 &self,
1996 project: &str,
1997 location: &str,
1998 managed_zone: &str,
1999 dns_key_id: &str,
2000 ) -> DnsKeyGetCall<'a, C> {
2001 DnsKeyGetCall {
2002 hub: self.hub,
2003 _project: project.to_string(),
2004 _location: location.to_string(),
2005 _managed_zone: managed_zone.to_string(),
2006 _dns_key_id: dns_key_id.to_string(),
2007 _digest_type: Default::default(),
2008 _client_operation_id: Default::default(),
2009 _delegate: Default::default(),
2010 _additional_params: Default::default(),
2011 _scopes: Default::default(),
2012 }
2013 }
2014
2015 /// Create a builder to help you perform the following task:
2016 ///
2017 /// Enumerates DnsKeys to a ResourceRecordSet collection.
2018 ///
2019 /// # Arguments
2020 ///
2021 /// * `project` - Identifies the project addressed by this request.
2022 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2023 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2024 pub fn list(&self, project: &str, location: &str, managed_zone: &str) -> DnsKeyListCall<'a, C> {
2025 DnsKeyListCall {
2026 hub: self.hub,
2027 _project: project.to_string(),
2028 _location: location.to_string(),
2029 _managed_zone: managed_zone.to_string(),
2030 _page_token: Default::default(),
2031 _max_results: Default::default(),
2032 _digest_type: Default::default(),
2033 _delegate: Default::default(),
2034 _additional_params: Default::default(),
2035 _scopes: Default::default(),
2036 }
2037 }
2038}
2039
2040/// A builder providing access to all methods supported on *managedZoneOperation* resources.
2041/// It is not used directly, but through the [`Dns`] hub.
2042///
2043/// # Example
2044///
2045/// Instantiate a resource builder
2046///
2047/// ```test_harness,no_run
2048/// extern crate hyper;
2049/// extern crate hyper_rustls;
2050/// extern crate google_dns2 as dns2;
2051///
2052/// # async fn dox() {
2053/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2054///
2055/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2056/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2057/// .with_native_roots()
2058/// .unwrap()
2059/// .https_only()
2060/// .enable_http2()
2061/// .build();
2062///
2063/// let executor = hyper_util::rt::TokioExecutor::new();
2064/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2065/// secret,
2066/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2067/// yup_oauth2::client::CustomHyperClientBuilder::from(
2068/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2069/// ),
2070/// ).build().await.unwrap();
2071///
2072/// let client = hyper_util::client::legacy::Client::builder(
2073/// hyper_util::rt::TokioExecutor::new()
2074/// )
2075/// .build(
2076/// hyper_rustls::HttpsConnectorBuilder::new()
2077/// .with_native_roots()
2078/// .unwrap()
2079/// .https_or_http()
2080/// .enable_http2()
2081/// .build()
2082/// );
2083/// let mut hub = Dns::new(client, auth);
2084/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2085/// // like `get(...)` and `list(...)`
2086/// // to build up your call.
2087/// let rb = hub.managed_zone_operations();
2088/// # }
2089/// ```
2090pub struct ManagedZoneOperationMethods<'a, C>
2091where
2092 C: 'a,
2093{
2094 hub: &'a Dns<C>,
2095}
2096
2097impl<'a, C> common::MethodsBuilder for ManagedZoneOperationMethods<'a, C> {}
2098
2099impl<'a, C> ManagedZoneOperationMethods<'a, C> {
2100 /// Create a builder to help you perform the following task:
2101 ///
2102 /// Fetches the representation of an existing Operation.
2103 ///
2104 /// # Arguments
2105 ///
2106 /// * `project` - Identifies the project addressed by this request.
2107 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2108 /// * `managedZone` - Identifies the managed zone addressed by this request.
2109 /// * `operation` - Identifies the operation addressed by this request (ID of the operation).
2110 pub fn get(
2111 &self,
2112 project: &str,
2113 location: &str,
2114 managed_zone: &str,
2115 operation: &str,
2116 ) -> ManagedZoneOperationGetCall<'a, C> {
2117 ManagedZoneOperationGetCall {
2118 hub: self.hub,
2119 _project: project.to_string(),
2120 _location: location.to_string(),
2121 _managed_zone: managed_zone.to_string(),
2122 _operation: operation.to_string(),
2123 _client_operation_id: Default::default(),
2124 _delegate: Default::default(),
2125 _additional_params: Default::default(),
2126 _scopes: Default::default(),
2127 }
2128 }
2129
2130 /// Create a builder to help you perform the following task:
2131 ///
2132 /// Enumerates Operations for the given ManagedZone.
2133 ///
2134 /// # Arguments
2135 ///
2136 /// * `project` - Identifies the project addressed by this request.
2137 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2138 /// * `managedZone` - Identifies the managed zone addressed by this request.
2139 pub fn list(
2140 &self,
2141 project: &str,
2142 location: &str,
2143 managed_zone: &str,
2144 ) -> ManagedZoneOperationListCall<'a, C> {
2145 ManagedZoneOperationListCall {
2146 hub: self.hub,
2147 _project: project.to_string(),
2148 _location: location.to_string(),
2149 _managed_zone: managed_zone.to_string(),
2150 _sort_by: Default::default(),
2151 _page_token: Default::default(),
2152 _max_results: Default::default(),
2153 _delegate: Default::default(),
2154 _additional_params: Default::default(),
2155 _scopes: Default::default(),
2156 }
2157 }
2158}
2159
2160/// A builder providing access to all methods supported on *managedZone* resources.
2161/// It is not used directly, but through the [`Dns`] hub.
2162///
2163/// # Example
2164///
2165/// Instantiate a resource builder
2166///
2167/// ```test_harness,no_run
2168/// extern crate hyper;
2169/// extern crate hyper_rustls;
2170/// extern crate google_dns2 as dns2;
2171///
2172/// # async fn dox() {
2173/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2174///
2175/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2176/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2177/// .with_native_roots()
2178/// .unwrap()
2179/// .https_only()
2180/// .enable_http2()
2181/// .build();
2182///
2183/// let executor = hyper_util::rt::TokioExecutor::new();
2184/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2185/// secret,
2186/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2187/// yup_oauth2::client::CustomHyperClientBuilder::from(
2188/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2189/// ),
2190/// ).build().await.unwrap();
2191///
2192/// let client = hyper_util::client::legacy::Client::builder(
2193/// hyper_util::rt::TokioExecutor::new()
2194/// )
2195/// .build(
2196/// hyper_rustls::HttpsConnectorBuilder::new()
2197/// .with_native_roots()
2198/// .unwrap()
2199/// .https_or_http()
2200/// .enable_http2()
2201/// .build()
2202/// );
2203/// let mut hub = Dns::new(client, auth);
2204/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2205/// // like `create(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `patch(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)` and `update(...)`
2206/// // to build up your call.
2207/// let rb = hub.managed_zones();
2208/// # }
2209/// ```
2210pub struct ManagedZoneMethods<'a, C>
2211where
2212 C: 'a,
2213{
2214 hub: &'a Dns<C>,
2215}
2216
2217impl<'a, C> common::MethodsBuilder for ManagedZoneMethods<'a, C> {}
2218
2219impl<'a, C> ManagedZoneMethods<'a, C> {
2220 /// Create a builder to help you perform the following task:
2221 ///
2222 /// Creates a new ManagedZone.
2223 ///
2224 /// # Arguments
2225 ///
2226 /// * `request` - No description provided.
2227 /// * `project` - Identifies the project addressed by this request.
2228 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2229 pub fn create(
2230 &self,
2231 request: ManagedZone,
2232 project: &str,
2233 location: &str,
2234 ) -> ManagedZoneCreateCall<'a, C> {
2235 ManagedZoneCreateCall {
2236 hub: self.hub,
2237 _request: request,
2238 _project: project.to_string(),
2239 _location: location.to_string(),
2240 _client_operation_id: Default::default(),
2241 _delegate: Default::default(),
2242 _additional_params: Default::default(),
2243 _scopes: Default::default(),
2244 }
2245 }
2246
2247 /// Create a builder to help you perform the following task:
2248 ///
2249 /// Deletes a previously created ManagedZone.
2250 ///
2251 /// # Arguments
2252 ///
2253 /// * `project` - Identifies the project addressed by this request.
2254 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2255 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2256 pub fn delete(
2257 &self,
2258 project: &str,
2259 location: &str,
2260 managed_zone: &str,
2261 ) -> ManagedZoneDeleteCall<'a, C> {
2262 ManagedZoneDeleteCall {
2263 hub: self.hub,
2264 _project: project.to_string(),
2265 _location: location.to_string(),
2266 _managed_zone: managed_zone.to_string(),
2267 _client_operation_id: Default::default(),
2268 _delegate: Default::default(),
2269 _additional_params: Default::default(),
2270 _scopes: Default::default(),
2271 }
2272 }
2273
2274 /// Create a builder to help you perform the following task:
2275 ///
2276 /// Fetches the representation of an existing ManagedZone.
2277 ///
2278 /// # Arguments
2279 ///
2280 /// * `project` - Identifies the project addressed by this request.
2281 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2282 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2283 pub fn get(
2284 &self,
2285 project: &str,
2286 location: &str,
2287 managed_zone: &str,
2288 ) -> ManagedZoneGetCall<'a, C> {
2289 ManagedZoneGetCall {
2290 hub: self.hub,
2291 _project: project.to_string(),
2292 _location: location.to_string(),
2293 _managed_zone: managed_zone.to_string(),
2294 _client_operation_id: Default::default(),
2295 _delegate: Default::default(),
2296 _additional_params: Default::default(),
2297 _scopes: Default::default(),
2298 }
2299 }
2300
2301 /// Create a builder to help you perform the following task:
2302 ///
2303 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2304 ///
2305 /// # Arguments
2306 ///
2307 /// * `request` - No description provided.
2308 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2309 pub fn get_iam_policy(
2310 &self,
2311 request: GoogleIamV1GetIamPolicyRequest,
2312 resource: &str,
2313 ) -> ManagedZoneGetIamPolicyCall<'a, C> {
2314 ManagedZoneGetIamPolicyCall {
2315 hub: self.hub,
2316 _request: request,
2317 _resource: resource.to_string(),
2318 _delegate: Default::default(),
2319 _additional_params: Default::default(),
2320 _scopes: Default::default(),
2321 }
2322 }
2323
2324 /// Create a builder to help you perform the following task:
2325 ///
2326 /// Enumerates ManagedZones that have been created but not yet deleted.
2327 ///
2328 /// # Arguments
2329 ///
2330 /// * `project` - Identifies the project addressed by this request.
2331 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2332 pub fn list(&self, project: &str, location: &str) -> ManagedZoneListCall<'a, C> {
2333 ManagedZoneListCall {
2334 hub: self.hub,
2335 _project: project.to_string(),
2336 _location: location.to_string(),
2337 _page_token: Default::default(),
2338 _max_results: Default::default(),
2339 _dns_name: Default::default(),
2340 _delegate: Default::default(),
2341 _additional_params: Default::default(),
2342 _scopes: Default::default(),
2343 }
2344 }
2345
2346 /// Create a builder to help you perform the following task:
2347 ///
2348 /// Applies a partial update to an existing ManagedZone.
2349 ///
2350 /// # Arguments
2351 ///
2352 /// * `request` - No description provided.
2353 /// * `project` - Identifies the project addressed by this request.
2354 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2355 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2356 pub fn patch(
2357 &self,
2358 request: ManagedZone,
2359 project: &str,
2360 location: &str,
2361 managed_zone: &str,
2362 ) -> ManagedZonePatchCall<'a, C> {
2363 ManagedZonePatchCall {
2364 hub: self.hub,
2365 _request: request,
2366 _project: project.to_string(),
2367 _location: location.to_string(),
2368 _managed_zone: managed_zone.to_string(),
2369 _client_operation_id: Default::default(),
2370 _delegate: Default::default(),
2371 _additional_params: Default::default(),
2372 _scopes: Default::default(),
2373 }
2374 }
2375
2376 /// Create a builder to help you perform the following task:
2377 ///
2378 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2379 ///
2380 /// # Arguments
2381 ///
2382 /// * `request` - No description provided.
2383 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2384 pub fn set_iam_policy(
2385 &self,
2386 request: GoogleIamV1SetIamPolicyRequest,
2387 resource: &str,
2388 ) -> ManagedZoneSetIamPolicyCall<'a, C> {
2389 ManagedZoneSetIamPolicyCall {
2390 hub: self.hub,
2391 _request: request,
2392 _resource: resource.to_string(),
2393 _delegate: Default::default(),
2394 _additional_params: Default::default(),
2395 _scopes: Default::default(),
2396 }
2397 }
2398
2399 /// Create a builder to help you perform the following task:
2400 ///
2401 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this returns an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2402 ///
2403 /// # Arguments
2404 ///
2405 /// * `request` - No description provided.
2406 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2407 pub fn test_iam_permissions(
2408 &self,
2409 request: GoogleIamV1TestIamPermissionsRequest,
2410 resource: &str,
2411 ) -> ManagedZoneTestIamPermissionCall<'a, C> {
2412 ManagedZoneTestIamPermissionCall {
2413 hub: self.hub,
2414 _request: request,
2415 _resource: resource.to_string(),
2416 _delegate: Default::default(),
2417 _additional_params: Default::default(),
2418 _scopes: Default::default(),
2419 }
2420 }
2421
2422 /// Create a builder to help you perform the following task:
2423 ///
2424 /// Updates an existing ManagedZone.
2425 ///
2426 /// # Arguments
2427 ///
2428 /// * `request` - No description provided.
2429 /// * `project` - Identifies the project addressed by this request.
2430 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2431 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2432 pub fn update(
2433 &self,
2434 request: ManagedZone,
2435 project: &str,
2436 location: &str,
2437 managed_zone: &str,
2438 ) -> ManagedZoneUpdateCall<'a, C> {
2439 ManagedZoneUpdateCall {
2440 hub: self.hub,
2441 _request: request,
2442 _project: project.to_string(),
2443 _location: location.to_string(),
2444 _managed_zone: managed_zone.to_string(),
2445 _client_operation_id: Default::default(),
2446 _delegate: Default::default(),
2447 _additional_params: Default::default(),
2448 _scopes: Default::default(),
2449 }
2450 }
2451}
2452
2453/// A builder providing access to all methods supported on *policy* resources.
2454/// It is not used directly, but through the [`Dns`] hub.
2455///
2456/// # Example
2457///
2458/// Instantiate a resource builder
2459///
2460/// ```test_harness,no_run
2461/// extern crate hyper;
2462/// extern crate hyper_rustls;
2463/// extern crate google_dns2 as dns2;
2464///
2465/// # async fn dox() {
2466/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2467///
2468/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2469/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2470/// .with_native_roots()
2471/// .unwrap()
2472/// .https_only()
2473/// .enable_http2()
2474/// .build();
2475///
2476/// let executor = hyper_util::rt::TokioExecutor::new();
2477/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2478/// secret,
2479/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2480/// yup_oauth2::client::CustomHyperClientBuilder::from(
2481/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2482/// ),
2483/// ).build().await.unwrap();
2484///
2485/// let client = hyper_util::client::legacy::Client::builder(
2486/// hyper_util::rt::TokioExecutor::new()
2487/// )
2488/// .build(
2489/// hyper_rustls::HttpsConnectorBuilder::new()
2490/// .with_native_roots()
2491/// .unwrap()
2492/// .https_or_http()
2493/// .enable_http2()
2494/// .build()
2495/// );
2496/// let mut hub = Dns::new(client, auth);
2497/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2498/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
2499/// // to build up your call.
2500/// let rb = hub.policies();
2501/// # }
2502/// ```
2503pub struct PolicyMethods<'a, C>
2504where
2505 C: 'a,
2506{
2507 hub: &'a Dns<C>,
2508}
2509
2510impl<'a, C> common::MethodsBuilder for PolicyMethods<'a, C> {}
2511
2512impl<'a, C> PolicyMethods<'a, C> {
2513 /// Create a builder to help you perform the following task:
2514 ///
2515 /// Creates a new policy.
2516 ///
2517 /// # Arguments
2518 ///
2519 /// * `request` - No description provided.
2520 /// * `project` - Identifies the project addressed by this request.
2521 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2522 pub fn create(
2523 &self,
2524 request: Policy,
2525 project: &str,
2526 location: &str,
2527 ) -> PolicyCreateCall<'a, C> {
2528 PolicyCreateCall {
2529 hub: self.hub,
2530 _request: request,
2531 _project: project.to_string(),
2532 _location: location.to_string(),
2533 _client_operation_id: Default::default(),
2534 _delegate: Default::default(),
2535 _additional_params: Default::default(),
2536 _scopes: Default::default(),
2537 }
2538 }
2539
2540 /// Create a builder to help you perform the following task:
2541 ///
2542 /// Deletes a previously created policy. Fails if the policy is still being referenced by a network.
2543 ///
2544 /// # Arguments
2545 ///
2546 /// * `project` - Identifies the project addressed by this request.
2547 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2548 /// * `policy` - User given friendly name of the policy addressed by this request.
2549 pub fn delete(&self, project: &str, location: &str, policy: &str) -> PolicyDeleteCall<'a, C> {
2550 PolicyDeleteCall {
2551 hub: self.hub,
2552 _project: project.to_string(),
2553 _location: location.to_string(),
2554 _policy: policy.to_string(),
2555 _client_operation_id: Default::default(),
2556 _delegate: Default::default(),
2557 _additional_params: Default::default(),
2558 _scopes: Default::default(),
2559 }
2560 }
2561
2562 /// Create a builder to help you perform the following task:
2563 ///
2564 /// Fetches the representation of an existing policy.
2565 ///
2566 /// # Arguments
2567 ///
2568 /// * `project` - Identifies the project addressed by this request.
2569 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2570 /// * `policy` - User given friendly name of the policy addressed by this request.
2571 pub fn get(&self, project: &str, location: &str, policy: &str) -> PolicyGetCall<'a, C> {
2572 PolicyGetCall {
2573 hub: self.hub,
2574 _project: project.to_string(),
2575 _location: location.to_string(),
2576 _policy: policy.to_string(),
2577 _client_operation_id: Default::default(),
2578 _delegate: Default::default(),
2579 _additional_params: Default::default(),
2580 _scopes: Default::default(),
2581 }
2582 }
2583
2584 /// Create a builder to help you perform the following task:
2585 ///
2586 /// Enumerates all policies associated with a project.
2587 ///
2588 /// # Arguments
2589 ///
2590 /// * `project` - Identifies the project addressed by this request.
2591 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2592 pub fn list(&self, project: &str, location: &str) -> PolicyListCall<'a, C> {
2593 PolicyListCall {
2594 hub: self.hub,
2595 _project: project.to_string(),
2596 _location: location.to_string(),
2597 _page_token: Default::default(),
2598 _max_results: Default::default(),
2599 _delegate: Default::default(),
2600 _additional_params: Default::default(),
2601 _scopes: Default::default(),
2602 }
2603 }
2604
2605 /// Create a builder to help you perform the following task:
2606 ///
2607 /// Applies a partial update to an existing policy.
2608 ///
2609 /// # Arguments
2610 ///
2611 /// * `request` - No description provided.
2612 /// * `project` - Identifies the project addressed by this request.
2613 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2614 /// * `policy` - User given friendly name of the policy addressed by this request.
2615 pub fn patch(
2616 &self,
2617 request: Policy,
2618 project: &str,
2619 location: &str,
2620 policy: &str,
2621 ) -> PolicyPatchCall<'a, C> {
2622 PolicyPatchCall {
2623 hub: self.hub,
2624 _request: request,
2625 _project: project.to_string(),
2626 _location: location.to_string(),
2627 _policy: policy.to_string(),
2628 _client_operation_id: Default::default(),
2629 _delegate: Default::default(),
2630 _additional_params: Default::default(),
2631 _scopes: Default::default(),
2632 }
2633 }
2634
2635 /// Create a builder to help you perform the following task:
2636 ///
2637 /// Updates an existing policy.
2638 ///
2639 /// # Arguments
2640 ///
2641 /// * `request` - No description provided.
2642 /// * `project` - Identifies the project addressed by this request.
2643 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2644 /// * `policy` - User given friendly name of the policy addressed by this request.
2645 pub fn update(
2646 &self,
2647 request: Policy,
2648 project: &str,
2649 location: &str,
2650 policy: &str,
2651 ) -> PolicyUpdateCall<'a, C> {
2652 PolicyUpdateCall {
2653 hub: self.hub,
2654 _request: request,
2655 _project: project.to_string(),
2656 _location: location.to_string(),
2657 _policy: policy.to_string(),
2658 _client_operation_id: Default::default(),
2659 _delegate: Default::default(),
2660 _additional_params: Default::default(),
2661 _scopes: Default::default(),
2662 }
2663 }
2664}
2665
2666/// A builder providing access to all methods supported on *project* resources.
2667/// It is not used directly, but through the [`Dns`] hub.
2668///
2669/// # Example
2670///
2671/// Instantiate a resource builder
2672///
2673/// ```test_harness,no_run
2674/// extern crate hyper;
2675/// extern crate hyper_rustls;
2676/// extern crate google_dns2 as dns2;
2677///
2678/// # async fn dox() {
2679/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2680///
2681/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2682/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2683/// .with_native_roots()
2684/// .unwrap()
2685/// .https_only()
2686/// .enable_http2()
2687/// .build();
2688///
2689/// let executor = hyper_util::rt::TokioExecutor::new();
2690/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2691/// secret,
2692/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2693/// yup_oauth2::client::CustomHyperClientBuilder::from(
2694/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2695/// ),
2696/// ).build().await.unwrap();
2697///
2698/// let client = hyper_util::client::legacy::Client::builder(
2699/// hyper_util::rt::TokioExecutor::new()
2700/// )
2701/// .build(
2702/// hyper_rustls::HttpsConnectorBuilder::new()
2703/// .with_native_roots()
2704/// .unwrap()
2705/// .https_or_http()
2706/// .enable_http2()
2707/// .build()
2708/// );
2709/// let mut hub = Dns::new(client, auth);
2710/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2711/// // like `get(...)`
2712/// // to build up your call.
2713/// let rb = hub.projects();
2714/// # }
2715/// ```
2716pub struct ProjectMethods<'a, C>
2717where
2718 C: 'a,
2719{
2720 hub: &'a Dns<C>,
2721}
2722
2723impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2724
2725impl<'a, C> ProjectMethods<'a, C> {
2726 /// Create a builder to help you perform the following task:
2727 ///
2728 /// Fetches the representation of an existing Project.
2729 ///
2730 /// # Arguments
2731 ///
2732 /// * `project` - Identifies the project addressed by this request.
2733 /// * `location` - No description provided.
2734 pub fn get(&self, project: &str, location: &str) -> ProjectGetCall<'a, C> {
2735 ProjectGetCall {
2736 hub: self.hub,
2737 _project: project.to_string(),
2738 _location: location.to_string(),
2739 _client_operation_id: Default::default(),
2740 _delegate: Default::default(),
2741 _additional_params: Default::default(),
2742 _scopes: Default::default(),
2743 }
2744 }
2745}
2746
2747/// A builder providing access to all methods supported on *resourceRecordSet* resources.
2748/// It is not used directly, but through the [`Dns`] hub.
2749///
2750/// # Example
2751///
2752/// Instantiate a resource builder
2753///
2754/// ```test_harness,no_run
2755/// extern crate hyper;
2756/// extern crate hyper_rustls;
2757/// extern crate google_dns2 as dns2;
2758///
2759/// # async fn dox() {
2760/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2761///
2762/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2763/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2764/// .with_native_roots()
2765/// .unwrap()
2766/// .https_only()
2767/// .enable_http2()
2768/// .build();
2769///
2770/// let executor = hyper_util::rt::TokioExecutor::new();
2771/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2772/// secret,
2773/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2774/// yup_oauth2::client::CustomHyperClientBuilder::from(
2775/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2776/// ),
2777/// ).build().await.unwrap();
2778///
2779/// let client = hyper_util::client::legacy::Client::builder(
2780/// hyper_util::rt::TokioExecutor::new()
2781/// )
2782/// .build(
2783/// hyper_rustls::HttpsConnectorBuilder::new()
2784/// .with_native_roots()
2785/// .unwrap()
2786/// .https_or_http()
2787/// .enable_http2()
2788/// .build()
2789/// );
2790/// let mut hub = Dns::new(client, auth);
2791/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2792/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `patch(...)`
2793/// // to build up your call.
2794/// let rb = hub.resource_record_sets();
2795/// # }
2796/// ```
2797pub struct ResourceRecordSetMethods<'a, C>
2798where
2799 C: 'a,
2800{
2801 hub: &'a Dns<C>,
2802}
2803
2804impl<'a, C> common::MethodsBuilder for ResourceRecordSetMethods<'a, C> {}
2805
2806impl<'a, C> ResourceRecordSetMethods<'a, C> {
2807 /// Create a builder to help you perform the following task:
2808 ///
2809 /// Creates a new ResourceRecordSet.
2810 ///
2811 /// # Arguments
2812 ///
2813 /// * `request` - No description provided.
2814 /// * `project` - Identifies the project addressed by this request.
2815 /// * `location` - Specifies the location of the resource. This information is used for routing and is part of the resource name.
2816 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2817 pub fn create(
2818 &self,
2819 request: ResourceRecordSet,
2820 project: &str,
2821 location: &str,
2822 managed_zone: &str,
2823 ) -> ResourceRecordSetCreateCall<'a, C> {
2824 ResourceRecordSetCreateCall {
2825 hub: self.hub,
2826 _request: request,
2827 _project: project.to_string(),
2828 _location: location.to_string(),
2829 _managed_zone: managed_zone.to_string(),
2830 _client_operation_id: Default::default(),
2831 _delegate: Default::default(),
2832 _additional_params: Default::default(),
2833 _scopes: Default::default(),
2834 }
2835 }
2836
2837 /// Create a builder to help you perform the following task:
2838 ///
2839 /// Deletes a previously created ResourceRecordSet.
2840 ///
2841 /// # Arguments
2842 ///
2843 /// * `project` - Identifies the project addressed by this request.
2844 /// * `location` - Specifies the location of the resource. This information is used for routing and is part of the resource name.
2845 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2846 /// * `name` - Fully qualified domain name.
2847 /// * `type` - RRSet type.
2848 pub fn delete(
2849 &self,
2850 project: &str,
2851 location: &str,
2852 managed_zone: &str,
2853 name: &str,
2854 type_: &str,
2855 ) -> ResourceRecordSetDeleteCall<'a, C> {
2856 ResourceRecordSetDeleteCall {
2857 hub: self.hub,
2858 _project: project.to_string(),
2859 _location: location.to_string(),
2860 _managed_zone: managed_zone.to_string(),
2861 _name: name.to_string(),
2862 _type_: type_.to_string(),
2863 _client_operation_id: Default::default(),
2864 _delegate: Default::default(),
2865 _additional_params: Default::default(),
2866 _scopes: Default::default(),
2867 }
2868 }
2869
2870 /// Create a builder to help you perform the following task:
2871 ///
2872 /// Fetches the representation of an existing ResourceRecordSet.
2873 ///
2874 /// # Arguments
2875 ///
2876 /// * `project` - Identifies the project addressed by this request.
2877 /// * `location` - Specifies the location of the resource. This information is used for routing and is part of the resource name.
2878 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2879 /// * `name` - Fully qualified domain name.
2880 /// * `type` - RRSet type.
2881 pub fn get(
2882 &self,
2883 project: &str,
2884 location: &str,
2885 managed_zone: &str,
2886 name: &str,
2887 type_: &str,
2888 ) -> ResourceRecordSetGetCall<'a, C> {
2889 ResourceRecordSetGetCall {
2890 hub: self.hub,
2891 _project: project.to_string(),
2892 _location: location.to_string(),
2893 _managed_zone: managed_zone.to_string(),
2894 _name: name.to_string(),
2895 _type_: type_.to_string(),
2896 _client_operation_id: Default::default(),
2897 _delegate: Default::default(),
2898 _additional_params: Default::default(),
2899 _scopes: Default::default(),
2900 }
2901 }
2902
2903 /// Create a builder to help you perform the following task:
2904 ///
2905 /// Enumerates ResourceRecordSets that you have created but not yet deleted.
2906 ///
2907 /// # Arguments
2908 ///
2909 /// * `project` - Identifies the project addressed by this request.
2910 /// * `location` - Specifies the location of the resource. This information is used for routing and is part of the resource name.
2911 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2912 pub fn list(
2913 &self,
2914 project: &str,
2915 location: &str,
2916 managed_zone: &str,
2917 ) -> ResourceRecordSetListCall<'a, C> {
2918 ResourceRecordSetListCall {
2919 hub: self.hub,
2920 _project: project.to_string(),
2921 _location: location.to_string(),
2922 _managed_zone: managed_zone.to_string(),
2923 _type_: Default::default(),
2924 _page_token: Default::default(),
2925 _name: Default::default(),
2926 _max_results: Default::default(),
2927 _delegate: Default::default(),
2928 _additional_params: Default::default(),
2929 _scopes: Default::default(),
2930 }
2931 }
2932
2933 /// Create a builder to help you perform the following task:
2934 ///
2935 /// Applies a partial update to an existing ResourceRecordSet.
2936 ///
2937 /// # Arguments
2938 ///
2939 /// * `request` - No description provided.
2940 /// * `project` - Identifies the project addressed by this request.
2941 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
2942 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2943 /// * `name` - Fully qualified domain name.
2944 /// * `type` - RRSet type.
2945 pub fn patch(
2946 &self,
2947 request: ResourceRecordSet,
2948 project: &str,
2949 location: &str,
2950 managed_zone: &str,
2951 name: &str,
2952 type_: &str,
2953 ) -> ResourceRecordSetPatchCall<'a, C> {
2954 ResourceRecordSetPatchCall {
2955 hub: self.hub,
2956 _request: request,
2957 _project: project.to_string(),
2958 _location: location.to_string(),
2959 _managed_zone: managed_zone.to_string(),
2960 _name: name.to_string(),
2961 _type_: type_.to_string(),
2962 _client_operation_id: Default::default(),
2963 _delegate: Default::default(),
2964 _additional_params: Default::default(),
2965 _scopes: Default::default(),
2966 }
2967 }
2968}
2969
2970/// A builder providing access to all methods supported on *responsePolicy* resources.
2971/// It is not used directly, but through the [`Dns`] hub.
2972///
2973/// # Example
2974///
2975/// Instantiate a resource builder
2976///
2977/// ```test_harness,no_run
2978/// extern crate hyper;
2979/// extern crate hyper_rustls;
2980/// extern crate google_dns2 as dns2;
2981///
2982/// # async fn dox() {
2983/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2984///
2985/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2986/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2987/// .with_native_roots()
2988/// .unwrap()
2989/// .https_only()
2990/// .enable_http2()
2991/// .build();
2992///
2993/// let executor = hyper_util::rt::TokioExecutor::new();
2994/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2995/// secret,
2996/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2997/// yup_oauth2::client::CustomHyperClientBuilder::from(
2998/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2999/// ),
3000/// ).build().await.unwrap();
3001///
3002/// let client = hyper_util::client::legacy::Client::builder(
3003/// hyper_util::rt::TokioExecutor::new()
3004/// )
3005/// .build(
3006/// hyper_rustls::HttpsConnectorBuilder::new()
3007/// .with_native_roots()
3008/// .unwrap()
3009/// .https_or_http()
3010/// .enable_http2()
3011/// .build()
3012/// );
3013/// let mut hub = Dns::new(client, auth);
3014/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3015/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
3016/// // to build up your call.
3017/// let rb = hub.response_policies();
3018/// # }
3019/// ```
3020pub struct ResponsePolicyMethods<'a, C>
3021where
3022 C: 'a,
3023{
3024 hub: &'a Dns<C>,
3025}
3026
3027impl<'a, C> common::MethodsBuilder for ResponsePolicyMethods<'a, C> {}
3028
3029impl<'a, C> ResponsePolicyMethods<'a, C> {
3030 /// Create a builder to help you perform the following task:
3031 ///
3032 /// Creates a new Response Policy
3033 ///
3034 /// # Arguments
3035 ///
3036 /// * `request` - No description provided.
3037 /// * `project` - Identifies the project addressed by this request.
3038 /// * `location` - Specifies the location of the resource, only applicable in the v APIs. This information will be used for routing and will be part of the resource name.
3039 pub fn create(
3040 &self,
3041 request: ResponsePolicy,
3042 project: &str,
3043 location: &str,
3044 ) -> ResponsePolicyCreateCall<'a, C> {
3045 ResponsePolicyCreateCall {
3046 hub: self.hub,
3047 _request: request,
3048 _project: project.to_string(),
3049 _location: location.to_string(),
3050 _client_operation_id: Default::default(),
3051 _delegate: Default::default(),
3052 _additional_params: Default::default(),
3053 _scopes: Default::default(),
3054 }
3055 }
3056
3057 /// Create a builder to help you perform the following task:
3058 ///
3059 /// Deletes a previously created Response Policy. Fails if the response policy is non-empty or still being referenced by a network.
3060 ///
3061 /// # Arguments
3062 ///
3063 /// * `project` - Identifies the project addressed by this request.
3064 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3065 /// * `responsePolicy` - User assigned name of the Response Policy addressed by this request.
3066 pub fn delete(
3067 &self,
3068 project: &str,
3069 location: &str,
3070 response_policy: &str,
3071 ) -> ResponsePolicyDeleteCall<'a, C> {
3072 ResponsePolicyDeleteCall {
3073 hub: self.hub,
3074 _project: project.to_string(),
3075 _location: location.to_string(),
3076 _response_policy: response_policy.to_string(),
3077 _client_operation_id: Default::default(),
3078 _delegate: Default::default(),
3079 _additional_params: Default::default(),
3080 _scopes: Default::default(),
3081 }
3082 }
3083
3084 /// Create a builder to help you perform the following task:
3085 ///
3086 /// Fetches the representation of an existing Response Policy.
3087 ///
3088 /// # Arguments
3089 ///
3090 /// * `project` - Identifies the project addressed by this request.
3091 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3092 /// * `responsePolicy` - User assigned name of the Response Policy addressed by this request.
3093 pub fn get(
3094 &self,
3095 project: &str,
3096 location: &str,
3097 response_policy: &str,
3098 ) -> ResponsePolicyGetCall<'a, C> {
3099 ResponsePolicyGetCall {
3100 hub: self.hub,
3101 _project: project.to_string(),
3102 _location: location.to_string(),
3103 _response_policy: response_policy.to_string(),
3104 _client_operation_id: Default::default(),
3105 _delegate: Default::default(),
3106 _additional_params: Default::default(),
3107 _scopes: Default::default(),
3108 }
3109 }
3110
3111 /// Create a builder to help you perform the following task:
3112 ///
3113 /// Enumerates all Response Policies associated with a project.
3114 ///
3115 /// # Arguments
3116 ///
3117 /// * `project` - Identifies the project addressed by this request.
3118 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3119 pub fn list(&self, project: &str, location: &str) -> ResponsePolicyListCall<'a, C> {
3120 ResponsePolicyListCall {
3121 hub: self.hub,
3122 _project: project.to_string(),
3123 _location: location.to_string(),
3124 _page_token: Default::default(),
3125 _max_results: Default::default(),
3126 _delegate: Default::default(),
3127 _additional_params: Default::default(),
3128 _scopes: Default::default(),
3129 }
3130 }
3131
3132 /// Create a builder to help you perform the following task:
3133 ///
3134 /// Applies a partial update to an existing Response Policy.
3135 ///
3136 /// # Arguments
3137 ///
3138 /// * `request` - No description provided.
3139 /// * `project` - Identifies the project addressed by this request.
3140 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3141 /// * `responsePolicy` - User assigned name of the response policy addressed by this request.
3142 pub fn patch(
3143 &self,
3144 request: ResponsePolicy,
3145 project: &str,
3146 location: &str,
3147 response_policy: &str,
3148 ) -> ResponsePolicyPatchCall<'a, C> {
3149 ResponsePolicyPatchCall {
3150 hub: self.hub,
3151 _request: request,
3152 _project: project.to_string(),
3153 _location: location.to_string(),
3154 _response_policy: response_policy.to_string(),
3155 _client_operation_id: Default::default(),
3156 _delegate: Default::default(),
3157 _additional_params: Default::default(),
3158 _scopes: Default::default(),
3159 }
3160 }
3161
3162 /// Create a builder to help you perform the following task:
3163 ///
3164 /// Updates an existing Response Policy.
3165 ///
3166 /// # Arguments
3167 ///
3168 /// * `request` - No description provided.
3169 /// * `project` - Identifies the project addressed by this request.
3170 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3171 /// * `responsePolicy` - User assigned name of the Response Policy addressed by this request.
3172 pub fn update(
3173 &self,
3174 request: ResponsePolicy,
3175 project: &str,
3176 location: &str,
3177 response_policy: &str,
3178 ) -> ResponsePolicyUpdateCall<'a, C> {
3179 ResponsePolicyUpdateCall {
3180 hub: self.hub,
3181 _request: request,
3182 _project: project.to_string(),
3183 _location: location.to_string(),
3184 _response_policy: response_policy.to_string(),
3185 _client_operation_id: Default::default(),
3186 _delegate: Default::default(),
3187 _additional_params: Default::default(),
3188 _scopes: Default::default(),
3189 }
3190 }
3191}
3192
3193/// A builder providing access to all methods supported on *responsePolicyRule* resources.
3194/// It is not used directly, but through the [`Dns`] hub.
3195///
3196/// # Example
3197///
3198/// Instantiate a resource builder
3199///
3200/// ```test_harness,no_run
3201/// extern crate hyper;
3202/// extern crate hyper_rustls;
3203/// extern crate google_dns2 as dns2;
3204///
3205/// # async fn dox() {
3206/// use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3207///
3208/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3209/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3210/// .with_native_roots()
3211/// .unwrap()
3212/// .https_only()
3213/// .enable_http2()
3214/// .build();
3215///
3216/// let executor = hyper_util::rt::TokioExecutor::new();
3217/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3218/// secret,
3219/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3220/// yup_oauth2::client::CustomHyperClientBuilder::from(
3221/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3222/// ),
3223/// ).build().await.unwrap();
3224///
3225/// let client = hyper_util::client::legacy::Client::builder(
3226/// hyper_util::rt::TokioExecutor::new()
3227/// )
3228/// .build(
3229/// hyper_rustls::HttpsConnectorBuilder::new()
3230/// .with_native_roots()
3231/// .unwrap()
3232/// .https_or_http()
3233/// .enable_http2()
3234/// .build()
3235/// );
3236/// let mut hub = Dns::new(client, auth);
3237/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3238/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
3239/// // to build up your call.
3240/// let rb = hub.response_policy_rules();
3241/// # }
3242/// ```
3243pub struct ResponsePolicyRuleMethods<'a, C>
3244where
3245 C: 'a,
3246{
3247 hub: &'a Dns<C>,
3248}
3249
3250impl<'a, C> common::MethodsBuilder for ResponsePolicyRuleMethods<'a, C> {}
3251
3252impl<'a, C> ResponsePolicyRuleMethods<'a, C> {
3253 /// Create a builder to help you perform the following task:
3254 ///
3255 /// Creates a new Response Policy Rule.
3256 ///
3257 /// # Arguments
3258 ///
3259 /// * `request` - No description provided.
3260 /// * `project` - Identifies the project addressed by this request.
3261 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3262 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3263 pub fn create(
3264 &self,
3265 request: ResponsePolicyRule,
3266 project: &str,
3267 location: &str,
3268 response_policy: &str,
3269 ) -> ResponsePolicyRuleCreateCall<'a, C> {
3270 ResponsePolicyRuleCreateCall {
3271 hub: self.hub,
3272 _request: request,
3273 _project: project.to_string(),
3274 _location: location.to_string(),
3275 _response_policy: response_policy.to_string(),
3276 _client_operation_id: Default::default(),
3277 _delegate: Default::default(),
3278 _additional_params: Default::default(),
3279 _scopes: Default::default(),
3280 }
3281 }
3282
3283 /// Create a builder to help you perform the following task:
3284 ///
3285 /// Deletes a previously created Response Policy Rule.
3286 ///
3287 /// # Arguments
3288 ///
3289 /// * `project` - Identifies the project addressed by this request.
3290 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3291 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3292 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3293 pub fn delete(
3294 &self,
3295 project: &str,
3296 location: &str,
3297 response_policy: &str,
3298 response_policy_rule: &str,
3299 ) -> ResponsePolicyRuleDeleteCall<'a, C> {
3300 ResponsePolicyRuleDeleteCall {
3301 hub: self.hub,
3302 _project: project.to_string(),
3303 _location: location.to_string(),
3304 _response_policy: response_policy.to_string(),
3305 _response_policy_rule: response_policy_rule.to_string(),
3306 _client_operation_id: Default::default(),
3307 _delegate: Default::default(),
3308 _additional_params: Default::default(),
3309 _scopes: Default::default(),
3310 }
3311 }
3312
3313 /// Create a builder to help you perform the following task:
3314 ///
3315 /// Fetches the representation of an existing Response Policy Rule.
3316 ///
3317 /// # Arguments
3318 ///
3319 /// * `project` - Identifies the project addressed by this request.
3320 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3321 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3322 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3323 pub fn get(
3324 &self,
3325 project: &str,
3326 location: &str,
3327 response_policy: &str,
3328 response_policy_rule: &str,
3329 ) -> ResponsePolicyRuleGetCall<'a, C> {
3330 ResponsePolicyRuleGetCall {
3331 hub: self.hub,
3332 _project: project.to_string(),
3333 _location: location.to_string(),
3334 _response_policy: response_policy.to_string(),
3335 _response_policy_rule: response_policy_rule.to_string(),
3336 _client_operation_id: Default::default(),
3337 _delegate: Default::default(),
3338 _additional_params: Default::default(),
3339 _scopes: Default::default(),
3340 }
3341 }
3342
3343 /// Create a builder to help you perform the following task:
3344 ///
3345 /// Enumerates all Response Policy Rules associated with a project.
3346 ///
3347 /// # Arguments
3348 ///
3349 /// * `project` - Identifies the project addressed by this request.
3350 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3351 /// * `responsePolicy` - User assigned name of the Response Policy to list.
3352 pub fn list(
3353 &self,
3354 project: &str,
3355 location: &str,
3356 response_policy: &str,
3357 ) -> ResponsePolicyRuleListCall<'a, C> {
3358 ResponsePolicyRuleListCall {
3359 hub: self.hub,
3360 _project: project.to_string(),
3361 _location: location.to_string(),
3362 _response_policy: response_policy.to_string(),
3363 _page_token: Default::default(),
3364 _max_results: Default::default(),
3365 _delegate: Default::default(),
3366 _additional_params: Default::default(),
3367 _scopes: Default::default(),
3368 }
3369 }
3370
3371 /// Create a builder to help you perform the following task:
3372 ///
3373 /// Applies a partial update to an existing Response Policy Rule.
3374 ///
3375 /// # Arguments
3376 ///
3377 /// * `request` - No description provided.
3378 /// * `project` - Identifies the project addressed by this request.
3379 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3380 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3381 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3382 pub fn patch(
3383 &self,
3384 request: ResponsePolicyRule,
3385 project: &str,
3386 location: &str,
3387 response_policy: &str,
3388 response_policy_rule: &str,
3389 ) -> ResponsePolicyRulePatchCall<'a, C> {
3390 ResponsePolicyRulePatchCall {
3391 hub: self.hub,
3392 _request: request,
3393 _project: project.to_string(),
3394 _location: location.to_string(),
3395 _response_policy: response_policy.to_string(),
3396 _response_policy_rule: response_policy_rule.to_string(),
3397 _client_operation_id: Default::default(),
3398 _delegate: Default::default(),
3399 _additional_params: Default::default(),
3400 _scopes: Default::default(),
3401 }
3402 }
3403
3404 /// Create a builder to help you perform the following task:
3405 ///
3406 /// Updates an existing Response Policy Rule.
3407 ///
3408 /// # Arguments
3409 ///
3410 /// * `request` - No description provided.
3411 /// * `project` - Identifies the project addressed by this request.
3412 /// * `location` - Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
3413 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3414 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3415 pub fn update(
3416 &self,
3417 request: ResponsePolicyRule,
3418 project: &str,
3419 location: &str,
3420 response_policy: &str,
3421 response_policy_rule: &str,
3422 ) -> ResponsePolicyRuleUpdateCall<'a, C> {
3423 ResponsePolicyRuleUpdateCall {
3424 hub: self.hub,
3425 _request: request,
3426 _project: project.to_string(),
3427 _location: location.to_string(),
3428 _response_policy: response_policy.to_string(),
3429 _response_policy_rule: response_policy_rule.to_string(),
3430 _client_operation_id: Default::default(),
3431 _delegate: Default::default(),
3432 _additional_params: Default::default(),
3433 _scopes: Default::default(),
3434 }
3435 }
3436}
3437
3438// ###################
3439// CallBuilders ###
3440// #################
3441
3442/// Atomically updates the ResourceRecordSet collection.
3443///
3444/// A builder for the *create* method supported by a *change* resource.
3445/// It is not used directly, but through a [`ChangeMethods`] instance.
3446///
3447/// # Example
3448///
3449/// Instantiate a resource method builder
3450///
3451/// ```test_harness,no_run
3452/// # extern crate hyper;
3453/// # extern crate hyper_rustls;
3454/// # extern crate google_dns2 as dns2;
3455/// use dns2::api::Change;
3456/// # async fn dox() {
3457/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3458///
3459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3460/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3461/// # .with_native_roots()
3462/// # .unwrap()
3463/// # .https_only()
3464/// # .enable_http2()
3465/// # .build();
3466///
3467/// # let executor = hyper_util::rt::TokioExecutor::new();
3468/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3469/// # secret,
3470/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3471/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3472/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3473/// # ),
3474/// # ).build().await.unwrap();
3475///
3476/// # let client = hyper_util::client::legacy::Client::builder(
3477/// # hyper_util::rt::TokioExecutor::new()
3478/// # )
3479/// # .build(
3480/// # hyper_rustls::HttpsConnectorBuilder::new()
3481/// # .with_native_roots()
3482/// # .unwrap()
3483/// # .https_or_http()
3484/// # .enable_http2()
3485/// # .build()
3486/// # );
3487/// # let mut hub = Dns::new(client, auth);
3488/// // As the method needs a request, you would usually fill it with the desired information
3489/// // into the respective structure. Some of the parts shown here might not be applicable !
3490/// // Values shown here are possibly random and not representative !
3491/// let mut req = Change::default();
3492///
3493/// // You can configure optional parameters by calling the respective setters at will, and
3494/// // execute the final call using `doit()`.
3495/// // Values shown here are possibly random and not representative !
3496/// let result = hub.changes().create(req, "project", "location", "managedZone")
3497/// .client_operation_id("ea")
3498/// .doit().await;
3499/// # }
3500/// ```
3501pub struct ChangeCreateCall<'a, C>
3502where
3503 C: 'a,
3504{
3505 hub: &'a Dns<C>,
3506 _request: Change,
3507 _project: String,
3508 _location: String,
3509 _managed_zone: String,
3510 _client_operation_id: Option<String>,
3511 _delegate: Option<&'a mut dyn common::Delegate>,
3512 _additional_params: HashMap<String, String>,
3513 _scopes: BTreeSet<String>,
3514}
3515
3516impl<'a, C> common::CallBuilder for ChangeCreateCall<'a, C> {}
3517
3518impl<'a, C> ChangeCreateCall<'a, C>
3519where
3520 C: common::Connector,
3521{
3522 /// Perform the operation you have build so far.
3523 pub async fn doit(mut self) -> common::Result<(common::Response, Change)> {
3524 use std::borrow::Cow;
3525 use std::io::{Read, Seek};
3526
3527 use common::{url::Params, ToParts};
3528 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3529
3530 let mut dd = common::DefaultDelegate;
3531 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3532 dlg.begin(common::MethodInfo {
3533 id: "dns.changes.create",
3534 http_method: hyper::Method::POST,
3535 });
3536
3537 for &field in [
3538 "alt",
3539 "project",
3540 "location",
3541 "managedZone",
3542 "clientOperationId",
3543 ]
3544 .iter()
3545 {
3546 if self._additional_params.contains_key(field) {
3547 dlg.finished(false);
3548 return Err(common::Error::FieldClash(field));
3549 }
3550 }
3551
3552 let mut params = Params::with_capacity(7 + self._additional_params.len());
3553 params.push("project", self._project);
3554 params.push("location", self._location);
3555 params.push("managedZone", self._managed_zone);
3556 if let Some(value) = self._client_operation_id.as_ref() {
3557 params.push("clientOperationId", value);
3558 }
3559
3560 params.extend(self._additional_params.iter());
3561
3562 params.push("alt", "json");
3563 let mut url = self.hub._base_url.clone()
3564 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/changes";
3565 if self._scopes.is_empty() {
3566 self._scopes
3567 .insert(Scope::CloudPlatform.as_ref().to_string());
3568 }
3569
3570 #[allow(clippy::single_element_loop)]
3571 for &(find_this, param_name) in [
3572 ("{project}", "project"),
3573 ("{location}", "location"),
3574 ("{managedZone}", "managedZone"),
3575 ]
3576 .iter()
3577 {
3578 url = params.uri_replacement(url, param_name, find_this, false);
3579 }
3580 {
3581 let to_remove = ["managedZone", "location", "project"];
3582 params.remove_params(&to_remove);
3583 }
3584
3585 let url = params.parse_with_url(&url);
3586
3587 let mut json_mime_type = mime::APPLICATION_JSON;
3588 let mut request_value_reader = {
3589 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3590 common::remove_json_null_values(&mut value);
3591 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3592 serde_json::to_writer(&mut dst, &value).unwrap();
3593 dst
3594 };
3595 let request_size = request_value_reader
3596 .seek(std::io::SeekFrom::End(0))
3597 .unwrap();
3598 request_value_reader
3599 .seek(std::io::SeekFrom::Start(0))
3600 .unwrap();
3601
3602 loop {
3603 let token = match self
3604 .hub
3605 .auth
3606 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3607 .await
3608 {
3609 Ok(token) => token,
3610 Err(e) => match dlg.token(e) {
3611 Ok(token) => token,
3612 Err(e) => {
3613 dlg.finished(false);
3614 return Err(common::Error::MissingToken(e));
3615 }
3616 },
3617 };
3618 request_value_reader
3619 .seek(std::io::SeekFrom::Start(0))
3620 .unwrap();
3621 let mut req_result = {
3622 let client = &self.hub.client;
3623 dlg.pre_request();
3624 let mut req_builder = hyper::Request::builder()
3625 .method(hyper::Method::POST)
3626 .uri(url.as_str())
3627 .header(USER_AGENT, self.hub._user_agent.clone());
3628
3629 if let Some(token) = token.as_ref() {
3630 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3631 }
3632
3633 let request = req_builder
3634 .header(CONTENT_TYPE, json_mime_type.to_string())
3635 .header(CONTENT_LENGTH, request_size as u64)
3636 .body(common::to_body(
3637 request_value_reader.get_ref().clone().into(),
3638 ));
3639
3640 client.request(request.unwrap()).await
3641 };
3642
3643 match req_result {
3644 Err(err) => {
3645 if let common::Retry::After(d) = dlg.http_error(&err) {
3646 sleep(d).await;
3647 continue;
3648 }
3649 dlg.finished(false);
3650 return Err(common::Error::HttpError(err));
3651 }
3652 Ok(res) => {
3653 let (mut parts, body) = res.into_parts();
3654 let mut body = common::Body::new(body);
3655 if !parts.status.is_success() {
3656 let bytes = common::to_bytes(body).await.unwrap_or_default();
3657 let error = serde_json::from_str(&common::to_string(&bytes));
3658 let response = common::to_response(parts, bytes.into());
3659
3660 if let common::Retry::After(d) =
3661 dlg.http_failure(&response, error.as_ref().ok())
3662 {
3663 sleep(d).await;
3664 continue;
3665 }
3666
3667 dlg.finished(false);
3668
3669 return Err(match error {
3670 Ok(value) => common::Error::BadRequest(value),
3671 _ => common::Error::Failure(response),
3672 });
3673 }
3674 let response = {
3675 let bytes = common::to_bytes(body).await.unwrap_or_default();
3676 let encoded = common::to_string(&bytes);
3677 match serde_json::from_str(&encoded) {
3678 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3679 Err(error) => {
3680 dlg.response_json_decode_error(&encoded, &error);
3681 return Err(common::Error::JsonDecodeError(
3682 encoded.to_string(),
3683 error,
3684 ));
3685 }
3686 }
3687 };
3688
3689 dlg.finished(true);
3690 return Ok(response);
3691 }
3692 }
3693 }
3694 }
3695
3696 ///
3697 /// Sets the *request* property to the given value.
3698 ///
3699 /// Even though the property as already been set when instantiating this call,
3700 /// we provide this method for API completeness.
3701 pub fn request(mut self, new_value: Change) -> ChangeCreateCall<'a, C> {
3702 self._request = new_value;
3703 self
3704 }
3705 /// Identifies the project addressed by this request.
3706 ///
3707 /// Sets the *project* path property to the given value.
3708 ///
3709 /// Even though the property as already been set when instantiating this call,
3710 /// we provide this method for API completeness.
3711 pub fn project(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3712 self._project = new_value.to_string();
3713 self
3714 }
3715 ///
3716 /// Sets the *location* path property to the given value.
3717 ///
3718 /// Even though the property as already been set when instantiating this call,
3719 /// we provide this method for API completeness.
3720 pub fn location(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3721 self._location = new_value.to_string();
3722 self
3723 }
3724 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
3725 ///
3726 /// Sets the *managed zone* path property to the given value.
3727 ///
3728 /// Even though the property as already been set when instantiating this call,
3729 /// we provide this method for API completeness.
3730 pub fn managed_zone(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3731 self._managed_zone = new_value.to_string();
3732 self
3733 }
3734 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
3735 ///
3736 /// Sets the *client operation id* query property to the given value.
3737 pub fn client_operation_id(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3738 self._client_operation_id = Some(new_value.to_string());
3739 self
3740 }
3741 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3742 /// while executing the actual API request.
3743 ///
3744 /// ````text
3745 /// It should be used to handle progress information, and to implement a certain level of resilience.
3746 /// ````
3747 ///
3748 /// Sets the *delegate* property to the given value.
3749 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeCreateCall<'a, C> {
3750 self._delegate = Some(new_value);
3751 self
3752 }
3753
3754 /// Set any additional parameter of the query string used in the request.
3755 /// It should be used to set parameters which are not yet available through their own
3756 /// setters.
3757 ///
3758 /// Please note that this method must not be used to set any of the known parameters
3759 /// which have their own setter method. If done anyway, the request will fail.
3760 ///
3761 /// # Additional Parameters
3762 ///
3763 /// * *$.xgafv* (query-string) - V1 error format.
3764 /// * *access_token* (query-string) - OAuth access token.
3765 /// * *alt* (query-string) - Data format for response.
3766 /// * *callback* (query-string) - JSONP
3767 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3768 /// * *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.
3769 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3770 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3771 /// * *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.
3772 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3773 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3774 pub fn param<T>(mut self, name: T, value: T) -> ChangeCreateCall<'a, C>
3775 where
3776 T: AsRef<str>,
3777 {
3778 self._additional_params
3779 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3780 self
3781 }
3782
3783 /// Identifies the authorization scope for the method you are building.
3784 ///
3785 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3786 /// [`Scope::CloudPlatform`].
3787 ///
3788 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3789 /// tokens for more than one scope.
3790 ///
3791 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3792 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3793 /// sufficient, a read-write scope will do as well.
3794 pub fn add_scope<St>(mut self, scope: St) -> ChangeCreateCall<'a, C>
3795 where
3796 St: AsRef<str>,
3797 {
3798 self._scopes.insert(String::from(scope.as_ref()));
3799 self
3800 }
3801 /// Identifies the authorization scope(s) for the method you are building.
3802 ///
3803 /// See [`Self::add_scope()`] for details.
3804 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeCreateCall<'a, C>
3805 where
3806 I: IntoIterator<Item = St>,
3807 St: AsRef<str>,
3808 {
3809 self._scopes
3810 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3811 self
3812 }
3813
3814 /// Removes all scopes, and no default scope will be used either.
3815 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3816 /// for details).
3817 pub fn clear_scopes(mut self) -> ChangeCreateCall<'a, C> {
3818 self._scopes.clear();
3819 self
3820 }
3821}
3822
3823/// Fetches the representation of an existing Change.
3824///
3825/// A builder for the *get* method supported by a *change* resource.
3826/// It is not used directly, but through a [`ChangeMethods`] instance.
3827///
3828/// # Example
3829///
3830/// Instantiate a resource method builder
3831///
3832/// ```test_harness,no_run
3833/// # extern crate hyper;
3834/// # extern crate hyper_rustls;
3835/// # extern crate google_dns2 as dns2;
3836/// # async fn dox() {
3837/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3838///
3839/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3840/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3841/// # .with_native_roots()
3842/// # .unwrap()
3843/// # .https_only()
3844/// # .enable_http2()
3845/// # .build();
3846///
3847/// # let executor = hyper_util::rt::TokioExecutor::new();
3848/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3849/// # secret,
3850/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3851/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3852/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3853/// # ),
3854/// # ).build().await.unwrap();
3855///
3856/// # let client = hyper_util::client::legacy::Client::builder(
3857/// # hyper_util::rt::TokioExecutor::new()
3858/// # )
3859/// # .build(
3860/// # hyper_rustls::HttpsConnectorBuilder::new()
3861/// # .with_native_roots()
3862/// # .unwrap()
3863/// # .https_or_http()
3864/// # .enable_http2()
3865/// # .build()
3866/// # );
3867/// # let mut hub = Dns::new(client, auth);
3868/// // You can configure optional parameters by calling the respective setters at will, and
3869/// // execute the final call using `doit()`.
3870/// // Values shown here are possibly random and not representative !
3871/// let result = hub.changes().get("project", "location", "managedZone", "changeId")
3872/// .client_operation_id("ipsum")
3873/// .doit().await;
3874/// # }
3875/// ```
3876pub struct ChangeGetCall<'a, C>
3877where
3878 C: 'a,
3879{
3880 hub: &'a Dns<C>,
3881 _project: String,
3882 _location: String,
3883 _managed_zone: String,
3884 _change_id: String,
3885 _client_operation_id: Option<String>,
3886 _delegate: Option<&'a mut dyn common::Delegate>,
3887 _additional_params: HashMap<String, String>,
3888 _scopes: BTreeSet<String>,
3889}
3890
3891impl<'a, C> common::CallBuilder for ChangeGetCall<'a, C> {}
3892
3893impl<'a, C> ChangeGetCall<'a, C>
3894where
3895 C: common::Connector,
3896{
3897 /// Perform the operation you have build so far.
3898 pub async fn doit(mut self) -> common::Result<(common::Response, Change)> {
3899 use std::borrow::Cow;
3900 use std::io::{Read, Seek};
3901
3902 use common::{url::Params, ToParts};
3903 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3904
3905 let mut dd = common::DefaultDelegate;
3906 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3907 dlg.begin(common::MethodInfo {
3908 id: "dns.changes.get",
3909 http_method: hyper::Method::GET,
3910 });
3911
3912 for &field in [
3913 "alt",
3914 "project",
3915 "location",
3916 "managedZone",
3917 "changeId",
3918 "clientOperationId",
3919 ]
3920 .iter()
3921 {
3922 if self._additional_params.contains_key(field) {
3923 dlg.finished(false);
3924 return Err(common::Error::FieldClash(field));
3925 }
3926 }
3927
3928 let mut params = Params::with_capacity(7 + self._additional_params.len());
3929 params.push("project", self._project);
3930 params.push("location", self._location);
3931 params.push("managedZone", self._managed_zone);
3932 params.push("changeId", self._change_id);
3933 if let Some(value) = self._client_operation_id.as_ref() {
3934 params.push("clientOperationId", value);
3935 }
3936
3937 params.extend(self._additional_params.iter());
3938
3939 params.push("alt", "json");
3940 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/changes/{changeId}";
3941 if self._scopes.is_empty() {
3942 self._scopes
3943 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
3944 }
3945
3946 #[allow(clippy::single_element_loop)]
3947 for &(find_this, param_name) in [
3948 ("{project}", "project"),
3949 ("{location}", "location"),
3950 ("{managedZone}", "managedZone"),
3951 ("{changeId}", "changeId"),
3952 ]
3953 .iter()
3954 {
3955 url = params.uri_replacement(url, param_name, find_this, false);
3956 }
3957 {
3958 let to_remove = ["changeId", "managedZone", "location", "project"];
3959 params.remove_params(&to_remove);
3960 }
3961
3962 let url = params.parse_with_url(&url);
3963
3964 loop {
3965 let token = match self
3966 .hub
3967 .auth
3968 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3969 .await
3970 {
3971 Ok(token) => token,
3972 Err(e) => match dlg.token(e) {
3973 Ok(token) => token,
3974 Err(e) => {
3975 dlg.finished(false);
3976 return Err(common::Error::MissingToken(e));
3977 }
3978 },
3979 };
3980 let mut req_result = {
3981 let client = &self.hub.client;
3982 dlg.pre_request();
3983 let mut req_builder = hyper::Request::builder()
3984 .method(hyper::Method::GET)
3985 .uri(url.as_str())
3986 .header(USER_AGENT, self.hub._user_agent.clone());
3987
3988 if let Some(token) = token.as_ref() {
3989 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3990 }
3991
3992 let request = req_builder
3993 .header(CONTENT_LENGTH, 0_u64)
3994 .body(common::to_body::<String>(None));
3995
3996 client.request(request.unwrap()).await
3997 };
3998
3999 match req_result {
4000 Err(err) => {
4001 if let common::Retry::After(d) = dlg.http_error(&err) {
4002 sleep(d).await;
4003 continue;
4004 }
4005 dlg.finished(false);
4006 return Err(common::Error::HttpError(err));
4007 }
4008 Ok(res) => {
4009 let (mut parts, body) = res.into_parts();
4010 let mut body = common::Body::new(body);
4011 if !parts.status.is_success() {
4012 let bytes = common::to_bytes(body).await.unwrap_or_default();
4013 let error = serde_json::from_str(&common::to_string(&bytes));
4014 let response = common::to_response(parts, bytes.into());
4015
4016 if let common::Retry::After(d) =
4017 dlg.http_failure(&response, error.as_ref().ok())
4018 {
4019 sleep(d).await;
4020 continue;
4021 }
4022
4023 dlg.finished(false);
4024
4025 return Err(match error {
4026 Ok(value) => common::Error::BadRequest(value),
4027 _ => common::Error::Failure(response),
4028 });
4029 }
4030 let response = {
4031 let bytes = common::to_bytes(body).await.unwrap_or_default();
4032 let encoded = common::to_string(&bytes);
4033 match serde_json::from_str(&encoded) {
4034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4035 Err(error) => {
4036 dlg.response_json_decode_error(&encoded, &error);
4037 return Err(common::Error::JsonDecodeError(
4038 encoded.to_string(),
4039 error,
4040 ));
4041 }
4042 }
4043 };
4044
4045 dlg.finished(true);
4046 return Ok(response);
4047 }
4048 }
4049 }
4050 }
4051
4052 /// Identifies the project addressed by this request.
4053 ///
4054 /// Sets the *project* path property to the given value.
4055 ///
4056 /// Even though the property as already been set when instantiating this call,
4057 /// we provide this method for API completeness.
4058 pub fn project(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
4059 self._project = new_value.to_string();
4060 self
4061 }
4062 ///
4063 /// Sets the *location* path property to the given value.
4064 ///
4065 /// Even though the property as already been set when instantiating this call,
4066 /// we provide this method for API completeness.
4067 pub fn location(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
4068 self._location = new_value.to_string();
4069 self
4070 }
4071 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
4072 ///
4073 /// Sets the *managed zone* path property to the given value.
4074 ///
4075 /// Even though the property as already been set when instantiating this call,
4076 /// we provide this method for API completeness.
4077 pub fn managed_zone(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
4078 self._managed_zone = new_value.to_string();
4079 self
4080 }
4081 /// The identifier of the requested change, from a previous ResourceRecordSetsChangeResponse.
4082 ///
4083 /// Sets the *change id* path property to the given value.
4084 ///
4085 /// Even though the property as already been set when instantiating this call,
4086 /// we provide this method for API completeness.
4087 pub fn change_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
4088 self._change_id = new_value.to_string();
4089 self
4090 }
4091 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
4092 ///
4093 /// Sets the *client operation id* query property to the given value.
4094 pub fn client_operation_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
4095 self._client_operation_id = Some(new_value.to_string());
4096 self
4097 }
4098 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4099 /// while executing the actual API request.
4100 ///
4101 /// ````text
4102 /// It should be used to handle progress information, and to implement a certain level of resilience.
4103 /// ````
4104 ///
4105 /// Sets the *delegate* property to the given value.
4106 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeGetCall<'a, C> {
4107 self._delegate = Some(new_value);
4108 self
4109 }
4110
4111 /// Set any additional parameter of the query string used in the request.
4112 /// It should be used to set parameters which are not yet available through their own
4113 /// setters.
4114 ///
4115 /// Please note that this method must not be used to set any of the known parameters
4116 /// which have their own setter method. If done anyway, the request will fail.
4117 ///
4118 /// # Additional Parameters
4119 ///
4120 /// * *$.xgafv* (query-string) - V1 error format.
4121 /// * *access_token* (query-string) - OAuth access token.
4122 /// * *alt* (query-string) - Data format for response.
4123 /// * *callback* (query-string) - JSONP
4124 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4125 /// * *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.
4126 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4127 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4128 /// * *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.
4129 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4130 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4131 pub fn param<T>(mut self, name: T, value: T) -> ChangeGetCall<'a, C>
4132 where
4133 T: AsRef<str>,
4134 {
4135 self._additional_params
4136 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4137 self
4138 }
4139
4140 /// Identifies the authorization scope for the method you are building.
4141 ///
4142 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4143 /// [`Scope::NdevClouddnReadonly`].
4144 ///
4145 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4146 /// tokens for more than one scope.
4147 ///
4148 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4149 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4150 /// sufficient, a read-write scope will do as well.
4151 pub fn add_scope<St>(mut self, scope: St) -> ChangeGetCall<'a, C>
4152 where
4153 St: AsRef<str>,
4154 {
4155 self._scopes.insert(String::from(scope.as_ref()));
4156 self
4157 }
4158 /// Identifies the authorization scope(s) for the method you are building.
4159 ///
4160 /// See [`Self::add_scope()`] for details.
4161 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeGetCall<'a, C>
4162 where
4163 I: IntoIterator<Item = St>,
4164 St: AsRef<str>,
4165 {
4166 self._scopes
4167 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4168 self
4169 }
4170
4171 /// Removes all scopes, and no default scope will be used either.
4172 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4173 /// for details).
4174 pub fn clear_scopes(mut self) -> ChangeGetCall<'a, C> {
4175 self._scopes.clear();
4176 self
4177 }
4178}
4179
4180/// Enumerates Changes to a ResourceRecordSet collection.
4181///
4182/// A builder for the *list* method supported by a *change* resource.
4183/// It is not used directly, but through a [`ChangeMethods`] instance.
4184///
4185/// # Example
4186///
4187/// Instantiate a resource method builder
4188///
4189/// ```test_harness,no_run
4190/// # extern crate hyper;
4191/// # extern crate hyper_rustls;
4192/// # extern crate google_dns2 as dns2;
4193/// # async fn dox() {
4194/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4195///
4196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4197/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4198/// # .with_native_roots()
4199/// # .unwrap()
4200/// # .https_only()
4201/// # .enable_http2()
4202/// # .build();
4203///
4204/// # let executor = hyper_util::rt::TokioExecutor::new();
4205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4206/// # secret,
4207/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4208/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4209/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4210/// # ),
4211/// # ).build().await.unwrap();
4212///
4213/// # let client = hyper_util::client::legacy::Client::builder(
4214/// # hyper_util::rt::TokioExecutor::new()
4215/// # )
4216/// # .build(
4217/// # hyper_rustls::HttpsConnectorBuilder::new()
4218/// # .with_native_roots()
4219/// # .unwrap()
4220/// # .https_or_http()
4221/// # .enable_http2()
4222/// # .build()
4223/// # );
4224/// # let mut hub = Dns::new(client, auth);
4225/// // You can configure optional parameters by calling the respective setters at will, and
4226/// // execute the final call using `doit()`.
4227/// // Values shown here are possibly random and not representative !
4228/// let result = hub.changes().list("project", "location", "managedZone")
4229/// .sort_order("rebum.")
4230/// .sort_by("est")
4231/// .page_token("ipsum")
4232/// .max_results(-50)
4233/// .doit().await;
4234/// # }
4235/// ```
4236pub struct ChangeListCall<'a, C>
4237where
4238 C: 'a,
4239{
4240 hub: &'a Dns<C>,
4241 _project: String,
4242 _location: String,
4243 _managed_zone: String,
4244 _sort_order: Option<String>,
4245 _sort_by: Option<String>,
4246 _page_token: Option<String>,
4247 _max_results: Option<i32>,
4248 _delegate: Option<&'a mut dyn common::Delegate>,
4249 _additional_params: HashMap<String, String>,
4250 _scopes: BTreeSet<String>,
4251}
4252
4253impl<'a, C> common::CallBuilder for ChangeListCall<'a, C> {}
4254
4255impl<'a, C> ChangeListCall<'a, C>
4256where
4257 C: common::Connector,
4258{
4259 /// Perform the operation you have build so far.
4260 pub async fn doit(mut self) -> common::Result<(common::Response, ChangesListResponse)> {
4261 use std::borrow::Cow;
4262 use std::io::{Read, Seek};
4263
4264 use common::{url::Params, ToParts};
4265 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4266
4267 let mut dd = common::DefaultDelegate;
4268 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4269 dlg.begin(common::MethodInfo {
4270 id: "dns.changes.list",
4271 http_method: hyper::Method::GET,
4272 });
4273
4274 for &field in [
4275 "alt",
4276 "project",
4277 "location",
4278 "managedZone",
4279 "sortOrder",
4280 "sortBy",
4281 "pageToken",
4282 "maxResults",
4283 ]
4284 .iter()
4285 {
4286 if self._additional_params.contains_key(field) {
4287 dlg.finished(false);
4288 return Err(common::Error::FieldClash(field));
4289 }
4290 }
4291
4292 let mut params = Params::with_capacity(9 + self._additional_params.len());
4293 params.push("project", self._project);
4294 params.push("location", self._location);
4295 params.push("managedZone", self._managed_zone);
4296 if let Some(value) = self._sort_order.as_ref() {
4297 params.push("sortOrder", value);
4298 }
4299 if let Some(value) = self._sort_by.as_ref() {
4300 params.push("sortBy", value);
4301 }
4302 if let Some(value) = self._page_token.as_ref() {
4303 params.push("pageToken", value);
4304 }
4305 if let Some(value) = self._max_results.as_ref() {
4306 params.push("maxResults", value.to_string());
4307 }
4308
4309 params.extend(self._additional_params.iter());
4310
4311 params.push("alt", "json");
4312 let mut url = self.hub._base_url.clone()
4313 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/changes";
4314 if self._scopes.is_empty() {
4315 self._scopes
4316 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
4317 }
4318
4319 #[allow(clippy::single_element_loop)]
4320 for &(find_this, param_name) in [
4321 ("{project}", "project"),
4322 ("{location}", "location"),
4323 ("{managedZone}", "managedZone"),
4324 ]
4325 .iter()
4326 {
4327 url = params.uri_replacement(url, param_name, find_this, false);
4328 }
4329 {
4330 let to_remove = ["managedZone", "location", "project"];
4331 params.remove_params(&to_remove);
4332 }
4333
4334 let url = params.parse_with_url(&url);
4335
4336 loop {
4337 let token = match self
4338 .hub
4339 .auth
4340 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4341 .await
4342 {
4343 Ok(token) => token,
4344 Err(e) => match dlg.token(e) {
4345 Ok(token) => token,
4346 Err(e) => {
4347 dlg.finished(false);
4348 return Err(common::Error::MissingToken(e));
4349 }
4350 },
4351 };
4352 let mut req_result = {
4353 let client = &self.hub.client;
4354 dlg.pre_request();
4355 let mut req_builder = hyper::Request::builder()
4356 .method(hyper::Method::GET)
4357 .uri(url.as_str())
4358 .header(USER_AGENT, self.hub._user_agent.clone());
4359
4360 if let Some(token) = token.as_ref() {
4361 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4362 }
4363
4364 let request = req_builder
4365 .header(CONTENT_LENGTH, 0_u64)
4366 .body(common::to_body::<String>(None));
4367
4368 client.request(request.unwrap()).await
4369 };
4370
4371 match req_result {
4372 Err(err) => {
4373 if let common::Retry::After(d) = dlg.http_error(&err) {
4374 sleep(d).await;
4375 continue;
4376 }
4377 dlg.finished(false);
4378 return Err(common::Error::HttpError(err));
4379 }
4380 Ok(res) => {
4381 let (mut parts, body) = res.into_parts();
4382 let mut body = common::Body::new(body);
4383 if !parts.status.is_success() {
4384 let bytes = common::to_bytes(body).await.unwrap_or_default();
4385 let error = serde_json::from_str(&common::to_string(&bytes));
4386 let response = common::to_response(parts, bytes.into());
4387
4388 if let common::Retry::After(d) =
4389 dlg.http_failure(&response, error.as_ref().ok())
4390 {
4391 sleep(d).await;
4392 continue;
4393 }
4394
4395 dlg.finished(false);
4396
4397 return Err(match error {
4398 Ok(value) => common::Error::BadRequest(value),
4399 _ => common::Error::Failure(response),
4400 });
4401 }
4402 let response = {
4403 let bytes = common::to_bytes(body).await.unwrap_or_default();
4404 let encoded = common::to_string(&bytes);
4405 match serde_json::from_str(&encoded) {
4406 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4407 Err(error) => {
4408 dlg.response_json_decode_error(&encoded, &error);
4409 return Err(common::Error::JsonDecodeError(
4410 encoded.to_string(),
4411 error,
4412 ));
4413 }
4414 }
4415 };
4416
4417 dlg.finished(true);
4418 return Ok(response);
4419 }
4420 }
4421 }
4422 }
4423
4424 /// Identifies the project addressed by this request.
4425 ///
4426 /// Sets the *project* path property to the given value.
4427 ///
4428 /// Even though the property as already been set when instantiating this call,
4429 /// we provide this method for API completeness.
4430 pub fn project(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4431 self._project = new_value.to_string();
4432 self
4433 }
4434 ///
4435 /// Sets the *location* path property to the given value.
4436 ///
4437 /// Even though the property as already been set when instantiating this call,
4438 /// we provide this method for API completeness.
4439 pub fn location(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4440 self._location = new_value.to_string();
4441 self
4442 }
4443 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
4444 ///
4445 /// Sets the *managed zone* path property to the given value.
4446 ///
4447 /// Even though the property as already been set when instantiating this call,
4448 /// we provide this method for API completeness.
4449 pub fn managed_zone(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4450 self._managed_zone = new_value.to_string();
4451 self
4452 }
4453 /// Sorting order direction: 'ascending' or 'descending'.
4454 ///
4455 /// Sets the *sort order* query property to the given value.
4456 pub fn sort_order(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4457 self._sort_order = Some(new_value.to_string());
4458 self
4459 }
4460 /// Sorting criterion. The only supported value is change sequence.
4461 ///
4462 /// Sets the *sort by* query property to the given value.
4463 pub fn sort_by(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4464 self._sort_by = Some(new_value.to_string());
4465 self
4466 }
4467 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
4468 ///
4469 /// Sets the *page token* query property to the given value.
4470 pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4471 self._page_token = Some(new_value.to_string());
4472 self
4473 }
4474 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
4475 ///
4476 /// Sets the *max results* query property to the given value.
4477 pub fn max_results(mut self, new_value: i32) -> ChangeListCall<'a, C> {
4478 self._max_results = Some(new_value);
4479 self
4480 }
4481 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4482 /// while executing the actual API request.
4483 ///
4484 /// ````text
4485 /// It should be used to handle progress information, and to implement a certain level of resilience.
4486 /// ````
4487 ///
4488 /// Sets the *delegate* property to the given value.
4489 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeListCall<'a, C> {
4490 self._delegate = Some(new_value);
4491 self
4492 }
4493
4494 /// Set any additional parameter of the query string used in the request.
4495 /// It should be used to set parameters which are not yet available through their own
4496 /// setters.
4497 ///
4498 /// Please note that this method must not be used to set any of the known parameters
4499 /// which have their own setter method. If done anyway, the request will fail.
4500 ///
4501 /// # Additional Parameters
4502 ///
4503 /// * *$.xgafv* (query-string) - V1 error format.
4504 /// * *access_token* (query-string) - OAuth access token.
4505 /// * *alt* (query-string) - Data format for response.
4506 /// * *callback* (query-string) - JSONP
4507 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4508 /// * *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.
4509 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4510 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4511 /// * *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.
4512 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4513 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4514 pub fn param<T>(mut self, name: T, value: T) -> ChangeListCall<'a, C>
4515 where
4516 T: AsRef<str>,
4517 {
4518 self._additional_params
4519 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4520 self
4521 }
4522
4523 /// Identifies the authorization scope for the method you are building.
4524 ///
4525 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4526 /// [`Scope::NdevClouddnReadonly`].
4527 ///
4528 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4529 /// tokens for more than one scope.
4530 ///
4531 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4532 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4533 /// sufficient, a read-write scope will do as well.
4534 pub fn add_scope<St>(mut self, scope: St) -> ChangeListCall<'a, C>
4535 where
4536 St: AsRef<str>,
4537 {
4538 self._scopes.insert(String::from(scope.as_ref()));
4539 self
4540 }
4541 /// Identifies the authorization scope(s) for the method you are building.
4542 ///
4543 /// See [`Self::add_scope()`] for details.
4544 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeListCall<'a, C>
4545 where
4546 I: IntoIterator<Item = St>,
4547 St: AsRef<str>,
4548 {
4549 self._scopes
4550 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4551 self
4552 }
4553
4554 /// Removes all scopes, and no default scope will be used either.
4555 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4556 /// for details).
4557 pub fn clear_scopes(mut self) -> ChangeListCall<'a, C> {
4558 self._scopes.clear();
4559 self
4560 }
4561}
4562
4563/// Fetches the representation of an existing DnsKey.
4564///
4565/// A builder for the *get* method supported by a *dnsKey* resource.
4566/// It is not used directly, but through a [`DnsKeyMethods`] instance.
4567///
4568/// # Example
4569///
4570/// Instantiate a resource method builder
4571///
4572/// ```test_harness,no_run
4573/// # extern crate hyper;
4574/// # extern crate hyper_rustls;
4575/// # extern crate google_dns2 as dns2;
4576/// # async fn dox() {
4577/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4578///
4579/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4580/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4581/// # .with_native_roots()
4582/// # .unwrap()
4583/// # .https_only()
4584/// # .enable_http2()
4585/// # .build();
4586///
4587/// # let executor = hyper_util::rt::TokioExecutor::new();
4588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4589/// # secret,
4590/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4591/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4592/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4593/// # ),
4594/// # ).build().await.unwrap();
4595///
4596/// # let client = hyper_util::client::legacy::Client::builder(
4597/// # hyper_util::rt::TokioExecutor::new()
4598/// # )
4599/// # .build(
4600/// # hyper_rustls::HttpsConnectorBuilder::new()
4601/// # .with_native_roots()
4602/// # .unwrap()
4603/// # .https_or_http()
4604/// # .enable_http2()
4605/// # .build()
4606/// # );
4607/// # let mut hub = Dns::new(client, auth);
4608/// // You can configure optional parameters by calling the respective setters at will, and
4609/// // execute the final call using `doit()`.
4610/// // Values shown here are possibly random and not representative !
4611/// let result = hub.dns_keys().get("project", "location", "managedZone", "dnsKeyId")
4612/// .digest_type("Lorem")
4613/// .client_operation_id("eos")
4614/// .doit().await;
4615/// # }
4616/// ```
4617pub struct DnsKeyGetCall<'a, C>
4618where
4619 C: 'a,
4620{
4621 hub: &'a Dns<C>,
4622 _project: String,
4623 _location: String,
4624 _managed_zone: String,
4625 _dns_key_id: String,
4626 _digest_type: Option<String>,
4627 _client_operation_id: Option<String>,
4628 _delegate: Option<&'a mut dyn common::Delegate>,
4629 _additional_params: HashMap<String, String>,
4630 _scopes: BTreeSet<String>,
4631}
4632
4633impl<'a, C> common::CallBuilder for DnsKeyGetCall<'a, C> {}
4634
4635impl<'a, C> DnsKeyGetCall<'a, C>
4636where
4637 C: common::Connector,
4638{
4639 /// Perform the operation you have build so far.
4640 pub async fn doit(mut self) -> common::Result<(common::Response, DnsKey)> {
4641 use std::borrow::Cow;
4642 use std::io::{Read, Seek};
4643
4644 use common::{url::Params, ToParts};
4645 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4646
4647 let mut dd = common::DefaultDelegate;
4648 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4649 dlg.begin(common::MethodInfo {
4650 id: "dns.dnsKeys.get",
4651 http_method: hyper::Method::GET,
4652 });
4653
4654 for &field in [
4655 "alt",
4656 "project",
4657 "location",
4658 "managedZone",
4659 "dnsKeyId",
4660 "digestType",
4661 "clientOperationId",
4662 ]
4663 .iter()
4664 {
4665 if self._additional_params.contains_key(field) {
4666 dlg.finished(false);
4667 return Err(common::Error::FieldClash(field));
4668 }
4669 }
4670
4671 let mut params = Params::with_capacity(8 + self._additional_params.len());
4672 params.push("project", self._project);
4673 params.push("location", self._location);
4674 params.push("managedZone", self._managed_zone);
4675 params.push("dnsKeyId", self._dns_key_id);
4676 if let Some(value) = self._digest_type.as_ref() {
4677 params.push("digestType", value);
4678 }
4679 if let Some(value) = self._client_operation_id.as_ref() {
4680 params.push("clientOperationId", value);
4681 }
4682
4683 params.extend(self._additional_params.iter());
4684
4685 params.push("alt", "json");
4686 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/dnsKeys/{dnsKeyId}";
4687 if self._scopes.is_empty() {
4688 self._scopes
4689 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
4690 }
4691
4692 #[allow(clippy::single_element_loop)]
4693 for &(find_this, param_name) in [
4694 ("{project}", "project"),
4695 ("{location}", "location"),
4696 ("{managedZone}", "managedZone"),
4697 ("{dnsKeyId}", "dnsKeyId"),
4698 ]
4699 .iter()
4700 {
4701 url = params.uri_replacement(url, param_name, find_this, false);
4702 }
4703 {
4704 let to_remove = ["dnsKeyId", "managedZone", "location", "project"];
4705 params.remove_params(&to_remove);
4706 }
4707
4708 let url = params.parse_with_url(&url);
4709
4710 loop {
4711 let token = match self
4712 .hub
4713 .auth
4714 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4715 .await
4716 {
4717 Ok(token) => token,
4718 Err(e) => match dlg.token(e) {
4719 Ok(token) => token,
4720 Err(e) => {
4721 dlg.finished(false);
4722 return Err(common::Error::MissingToken(e));
4723 }
4724 },
4725 };
4726 let mut req_result = {
4727 let client = &self.hub.client;
4728 dlg.pre_request();
4729 let mut req_builder = hyper::Request::builder()
4730 .method(hyper::Method::GET)
4731 .uri(url.as_str())
4732 .header(USER_AGENT, self.hub._user_agent.clone());
4733
4734 if let Some(token) = token.as_ref() {
4735 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4736 }
4737
4738 let request = req_builder
4739 .header(CONTENT_LENGTH, 0_u64)
4740 .body(common::to_body::<String>(None));
4741
4742 client.request(request.unwrap()).await
4743 };
4744
4745 match req_result {
4746 Err(err) => {
4747 if let common::Retry::After(d) = dlg.http_error(&err) {
4748 sleep(d).await;
4749 continue;
4750 }
4751 dlg.finished(false);
4752 return Err(common::Error::HttpError(err));
4753 }
4754 Ok(res) => {
4755 let (mut parts, body) = res.into_parts();
4756 let mut body = common::Body::new(body);
4757 if !parts.status.is_success() {
4758 let bytes = common::to_bytes(body).await.unwrap_or_default();
4759 let error = serde_json::from_str(&common::to_string(&bytes));
4760 let response = common::to_response(parts, bytes.into());
4761
4762 if let common::Retry::After(d) =
4763 dlg.http_failure(&response, error.as_ref().ok())
4764 {
4765 sleep(d).await;
4766 continue;
4767 }
4768
4769 dlg.finished(false);
4770
4771 return Err(match error {
4772 Ok(value) => common::Error::BadRequest(value),
4773 _ => common::Error::Failure(response),
4774 });
4775 }
4776 let response = {
4777 let bytes = common::to_bytes(body).await.unwrap_or_default();
4778 let encoded = common::to_string(&bytes);
4779 match serde_json::from_str(&encoded) {
4780 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4781 Err(error) => {
4782 dlg.response_json_decode_error(&encoded, &error);
4783 return Err(common::Error::JsonDecodeError(
4784 encoded.to_string(),
4785 error,
4786 ));
4787 }
4788 }
4789 };
4790
4791 dlg.finished(true);
4792 return Ok(response);
4793 }
4794 }
4795 }
4796 }
4797
4798 /// Identifies the project addressed by this request.
4799 ///
4800 /// Sets the *project* path property to the given value.
4801 ///
4802 /// Even though the property as already been set when instantiating this call,
4803 /// we provide this method for API completeness.
4804 pub fn project(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4805 self._project = new_value.to_string();
4806 self
4807 }
4808 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
4809 ///
4810 /// Sets the *location* path property to the given value.
4811 ///
4812 /// Even though the property as already been set when instantiating this call,
4813 /// we provide this method for API completeness.
4814 pub fn location(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4815 self._location = new_value.to_string();
4816 self
4817 }
4818 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
4819 ///
4820 /// Sets the *managed zone* path property to the given value.
4821 ///
4822 /// Even though the property as already been set when instantiating this call,
4823 /// we provide this method for API completeness.
4824 pub fn managed_zone(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4825 self._managed_zone = new_value.to_string();
4826 self
4827 }
4828 /// The identifier of the requested DnsKey.
4829 ///
4830 /// Sets the *dns key id* path property to the given value.
4831 ///
4832 /// Even though the property as already been set when instantiating this call,
4833 /// we provide this method for API completeness.
4834 pub fn dns_key_id(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4835 self._dns_key_id = new_value.to_string();
4836 self
4837 }
4838 /// An optional comma-separated list of digest types to compute and display for key signing keys. If omitted, the recommended digest type is computed and displayed.
4839 ///
4840 /// Sets the *digest type* query property to the given value.
4841 pub fn digest_type(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4842 self._digest_type = Some(new_value.to_string());
4843 self
4844 }
4845 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
4846 ///
4847 /// Sets the *client operation id* query property to the given value.
4848 pub fn client_operation_id(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4849 self._client_operation_id = Some(new_value.to_string());
4850 self
4851 }
4852 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4853 /// while executing the actual API request.
4854 ///
4855 /// ````text
4856 /// It should be used to handle progress information, and to implement a certain level of resilience.
4857 /// ````
4858 ///
4859 /// Sets the *delegate* property to the given value.
4860 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DnsKeyGetCall<'a, C> {
4861 self._delegate = Some(new_value);
4862 self
4863 }
4864
4865 /// Set any additional parameter of the query string used in the request.
4866 /// It should be used to set parameters which are not yet available through their own
4867 /// setters.
4868 ///
4869 /// Please note that this method must not be used to set any of the known parameters
4870 /// which have their own setter method. If done anyway, the request will fail.
4871 ///
4872 /// # Additional Parameters
4873 ///
4874 /// * *$.xgafv* (query-string) - V1 error format.
4875 /// * *access_token* (query-string) - OAuth access token.
4876 /// * *alt* (query-string) - Data format for response.
4877 /// * *callback* (query-string) - JSONP
4878 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4879 /// * *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.
4880 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4881 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4882 /// * *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.
4883 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4884 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4885 pub fn param<T>(mut self, name: T, value: T) -> DnsKeyGetCall<'a, C>
4886 where
4887 T: AsRef<str>,
4888 {
4889 self._additional_params
4890 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4891 self
4892 }
4893
4894 /// Identifies the authorization scope for the method you are building.
4895 ///
4896 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4897 /// [`Scope::NdevClouddnReadonly`].
4898 ///
4899 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4900 /// tokens for more than one scope.
4901 ///
4902 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4903 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4904 /// sufficient, a read-write scope will do as well.
4905 pub fn add_scope<St>(mut self, scope: St) -> DnsKeyGetCall<'a, C>
4906 where
4907 St: AsRef<str>,
4908 {
4909 self._scopes.insert(String::from(scope.as_ref()));
4910 self
4911 }
4912 /// Identifies the authorization scope(s) for the method you are building.
4913 ///
4914 /// See [`Self::add_scope()`] for details.
4915 pub fn add_scopes<I, St>(mut self, scopes: I) -> DnsKeyGetCall<'a, C>
4916 where
4917 I: IntoIterator<Item = St>,
4918 St: AsRef<str>,
4919 {
4920 self._scopes
4921 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4922 self
4923 }
4924
4925 /// Removes all scopes, and no default scope will be used either.
4926 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4927 /// for details).
4928 pub fn clear_scopes(mut self) -> DnsKeyGetCall<'a, C> {
4929 self._scopes.clear();
4930 self
4931 }
4932}
4933
4934/// Enumerates DnsKeys to a ResourceRecordSet collection.
4935///
4936/// A builder for the *list* method supported by a *dnsKey* resource.
4937/// It is not used directly, but through a [`DnsKeyMethods`] instance.
4938///
4939/// # Example
4940///
4941/// Instantiate a resource method builder
4942///
4943/// ```test_harness,no_run
4944/// # extern crate hyper;
4945/// # extern crate hyper_rustls;
4946/// # extern crate google_dns2 as dns2;
4947/// # async fn dox() {
4948/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4949///
4950/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4951/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4952/// # .with_native_roots()
4953/// # .unwrap()
4954/// # .https_only()
4955/// # .enable_http2()
4956/// # .build();
4957///
4958/// # let executor = hyper_util::rt::TokioExecutor::new();
4959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4960/// # secret,
4961/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4962/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4963/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4964/// # ),
4965/// # ).build().await.unwrap();
4966///
4967/// # let client = hyper_util::client::legacy::Client::builder(
4968/// # hyper_util::rt::TokioExecutor::new()
4969/// # )
4970/// # .build(
4971/// # hyper_rustls::HttpsConnectorBuilder::new()
4972/// # .with_native_roots()
4973/// # .unwrap()
4974/// # .https_or_http()
4975/// # .enable_http2()
4976/// # .build()
4977/// # );
4978/// # let mut hub = Dns::new(client, auth);
4979/// // You can configure optional parameters by calling the respective setters at will, and
4980/// // execute the final call using `doit()`.
4981/// // Values shown here are possibly random and not representative !
4982/// let result = hub.dns_keys().list("project", "location", "managedZone")
4983/// .page_token("sed")
4984/// .max_results(-61)
4985/// .digest_type("Stet")
4986/// .doit().await;
4987/// # }
4988/// ```
4989pub struct DnsKeyListCall<'a, C>
4990where
4991 C: 'a,
4992{
4993 hub: &'a Dns<C>,
4994 _project: String,
4995 _location: String,
4996 _managed_zone: String,
4997 _page_token: Option<String>,
4998 _max_results: Option<i32>,
4999 _digest_type: Option<String>,
5000 _delegate: Option<&'a mut dyn common::Delegate>,
5001 _additional_params: HashMap<String, String>,
5002 _scopes: BTreeSet<String>,
5003}
5004
5005impl<'a, C> common::CallBuilder for DnsKeyListCall<'a, C> {}
5006
5007impl<'a, C> DnsKeyListCall<'a, C>
5008where
5009 C: common::Connector,
5010{
5011 /// Perform the operation you have build so far.
5012 pub async fn doit(mut self) -> common::Result<(common::Response, DnsKeysListResponse)> {
5013 use std::borrow::Cow;
5014 use std::io::{Read, Seek};
5015
5016 use common::{url::Params, ToParts};
5017 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5018
5019 let mut dd = common::DefaultDelegate;
5020 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5021 dlg.begin(common::MethodInfo {
5022 id: "dns.dnsKeys.list",
5023 http_method: hyper::Method::GET,
5024 });
5025
5026 for &field in [
5027 "alt",
5028 "project",
5029 "location",
5030 "managedZone",
5031 "pageToken",
5032 "maxResults",
5033 "digestType",
5034 ]
5035 .iter()
5036 {
5037 if self._additional_params.contains_key(field) {
5038 dlg.finished(false);
5039 return Err(common::Error::FieldClash(field));
5040 }
5041 }
5042
5043 let mut params = Params::with_capacity(8 + self._additional_params.len());
5044 params.push("project", self._project);
5045 params.push("location", self._location);
5046 params.push("managedZone", self._managed_zone);
5047 if let Some(value) = self._page_token.as_ref() {
5048 params.push("pageToken", value);
5049 }
5050 if let Some(value) = self._max_results.as_ref() {
5051 params.push("maxResults", value.to_string());
5052 }
5053 if let Some(value) = self._digest_type.as_ref() {
5054 params.push("digestType", value);
5055 }
5056
5057 params.extend(self._additional_params.iter());
5058
5059 params.push("alt", "json");
5060 let mut url = self.hub._base_url.clone()
5061 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/dnsKeys";
5062 if self._scopes.is_empty() {
5063 self._scopes
5064 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
5065 }
5066
5067 #[allow(clippy::single_element_loop)]
5068 for &(find_this, param_name) in [
5069 ("{project}", "project"),
5070 ("{location}", "location"),
5071 ("{managedZone}", "managedZone"),
5072 ]
5073 .iter()
5074 {
5075 url = params.uri_replacement(url, param_name, find_this, false);
5076 }
5077 {
5078 let to_remove = ["managedZone", "location", "project"];
5079 params.remove_params(&to_remove);
5080 }
5081
5082 let url = params.parse_with_url(&url);
5083
5084 loop {
5085 let token = match self
5086 .hub
5087 .auth
5088 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5089 .await
5090 {
5091 Ok(token) => token,
5092 Err(e) => match dlg.token(e) {
5093 Ok(token) => token,
5094 Err(e) => {
5095 dlg.finished(false);
5096 return Err(common::Error::MissingToken(e));
5097 }
5098 },
5099 };
5100 let mut req_result = {
5101 let client = &self.hub.client;
5102 dlg.pre_request();
5103 let mut req_builder = hyper::Request::builder()
5104 .method(hyper::Method::GET)
5105 .uri(url.as_str())
5106 .header(USER_AGENT, self.hub._user_agent.clone());
5107
5108 if let Some(token) = token.as_ref() {
5109 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5110 }
5111
5112 let request = req_builder
5113 .header(CONTENT_LENGTH, 0_u64)
5114 .body(common::to_body::<String>(None));
5115
5116 client.request(request.unwrap()).await
5117 };
5118
5119 match req_result {
5120 Err(err) => {
5121 if let common::Retry::After(d) = dlg.http_error(&err) {
5122 sleep(d).await;
5123 continue;
5124 }
5125 dlg.finished(false);
5126 return Err(common::Error::HttpError(err));
5127 }
5128 Ok(res) => {
5129 let (mut parts, body) = res.into_parts();
5130 let mut body = common::Body::new(body);
5131 if !parts.status.is_success() {
5132 let bytes = common::to_bytes(body).await.unwrap_or_default();
5133 let error = serde_json::from_str(&common::to_string(&bytes));
5134 let response = common::to_response(parts, bytes.into());
5135
5136 if let common::Retry::After(d) =
5137 dlg.http_failure(&response, error.as_ref().ok())
5138 {
5139 sleep(d).await;
5140 continue;
5141 }
5142
5143 dlg.finished(false);
5144
5145 return Err(match error {
5146 Ok(value) => common::Error::BadRequest(value),
5147 _ => common::Error::Failure(response),
5148 });
5149 }
5150 let response = {
5151 let bytes = common::to_bytes(body).await.unwrap_or_default();
5152 let encoded = common::to_string(&bytes);
5153 match serde_json::from_str(&encoded) {
5154 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5155 Err(error) => {
5156 dlg.response_json_decode_error(&encoded, &error);
5157 return Err(common::Error::JsonDecodeError(
5158 encoded.to_string(),
5159 error,
5160 ));
5161 }
5162 }
5163 };
5164
5165 dlg.finished(true);
5166 return Ok(response);
5167 }
5168 }
5169 }
5170 }
5171
5172 /// Identifies the project addressed by this request.
5173 ///
5174 /// Sets the *project* path property to the given value.
5175 ///
5176 /// Even though the property as already been set when instantiating this call,
5177 /// we provide this method for API completeness.
5178 pub fn project(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
5179 self._project = new_value.to_string();
5180 self
5181 }
5182 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
5183 ///
5184 /// Sets the *location* path property to the given value.
5185 ///
5186 /// Even though the property as already been set when instantiating this call,
5187 /// we provide this method for API completeness.
5188 pub fn location(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
5189 self._location = new_value.to_string();
5190 self
5191 }
5192 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
5193 ///
5194 /// Sets the *managed zone* path property to the given value.
5195 ///
5196 /// Even though the property as already been set when instantiating this call,
5197 /// we provide this method for API completeness.
5198 pub fn managed_zone(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
5199 self._managed_zone = new_value.to_string();
5200 self
5201 }
5202 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
5203 ///
5204 /// Sets the *page token* query property to the given value.
5205 pub fn page_token(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
5206 self._page_token = Some(new_value.to_string());
5207 self
5208 }
5209 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
5210 ///
5211 /// Sets the *max results* query property to the given value.
5212 pub fn max_results(mut self, new_value: i32) -> DnsKeyListCall<'a, C> {
5213 self._max_results = Some(new_value);
5214 self
5215 }
5216 /// An optional comma-separated list of digest types to compute and display for key signing keys. If omitted, the recommended digest type is computed and displayed.
5217 ///
5218 /// Sets the *digest type* query property to the given value.
5219 pub fn digest_type(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
5220 self._digest_type = Some(new_value.to_string());
5221 self
5222 }
5223 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5224 /// while executing the actual API request.
5225 ///
5226 /// ````text
5227 /// It should be used to handle progress information, and to implement a certain level of resilience.
5228 /// ````
5229 ///
5230 /// Sets the *delegate* property to the given value.
5231 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DnsKeyListCall<'a, C> {
5232 self._delegate = Some(new_value);
5233 self
5234 }
5235
5236 /// Set any additional parameter of the query string used in the request.
5237 /// It should be used to set parameters which are not yet available through their own
5238 /// setters.
5239 ///
5240 /// Please note that this method must not be used to set any of the known parameters
5241 /// which have their own setter method. If done anyway, the request will fail.
5242 ///
5243 /// # Additional Parameters
5244 ///
5245 /// * *$.xgafv* (query-string) - V1 error format.
5246 /// * *access_token* (query-string) - OAuth access token.
5247 /// * *alt* (query-string) - Data format for response.
5248 /// * *callback* (query-string) - JSONP
5249 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5250 /// * *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.
5251 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5252 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5253 /// * *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.
5254 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5255 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5256 pub fn param<T>(mut self, name: T, value: T) -> DnsKeyListCall<'a, C>
5257 where
5258 T: AsRef<str>,
5259 {
5260 self._additional_params
5261 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5262 self
5263 }
5264
5265 /// Identifies the authorization scope for the method you are building.
5266 ///
5267 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5268 /// [`Scope::NdevClouddnReadonly`].
5269 ///
5270 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5271 /// tokens for more than one scope.
5272 ///
5273 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5274 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5275 /// sufficient, a read-write scope will do as well.
5276 pub fn add_scope<St>(mut self, scope: St) -> DnsKeyListCall<'a, C>
5277 where
5278 St: AsRef<str>,
5279 {
5280 self._scopes.insert(String::from(scope.as_ref()));
5281 self
5282 }
5283 /// Identifies the authorization scope(s) for the method you are building.
5284 ///
5285 /// See [`Self::add_scope()`] for details.
5286 pub fn add_scopes<I, St>(mut self, scopes: I) -> DnsKeyListCall<'a, C>
5287 where
5288 I: IntoIterator<Item = St>,
5289 St: AsRef<str>,
5290 {
5291 self._scopes
5292 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5293 self
5294 }
5295
5296 /// Removes all scopes, and no default scope will be used either.
5297 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5298 /// for details).
5299 pub fn clear_scopes(mut self) -> DnsKeyListCall<'a, C> {
5300 self._scopes.clear();
5301 self
5302 }
5303}
5304
5305/// Fetches the representation of an existing Operation.
5306///
5307/// A builder for the *get* method supported by a *managedZoneOperation* resource.
5308/// It is not used directly, but through a [`ManagedZoneOperationMethods`] instance.
5309///
5310/// # Example
5311///
5312/// Instantiate a resource method builder
5313///
5314/// ```test_harness,no_run
5315/// # extern crate hyper;
5316/// # extern crate hyper_rustls;
5317/// # extern crate google_dns2 as dns2;
5318/// # async fn dox() {
5319/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5320///
5321/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5322/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5323/// # .with_native_roots()
5324/// # .unwrap()
5325/// # .https_only()
5326/// # .enable_http2()
5327/// # .build();
5328///
5329/// # let executor = hyper_util::rt::TokioExecutor::new();
5330/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5331/// # secret,
5332/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5333/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5334/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5335/// # ),
5336/// # ).build().await.unwrap();
5337///
5338/// # let client = hyper_util::client::legacy::Client::builder(
5339/// # hyper_util::rt::TokioExecutor::new()
5340/// # )
5341/// # .build(
5342/// # hyper_rustls::HttpsConnectorBuilder::new()
5343/// # .with_native_roots()
5344/// # .unwrap()
5345/// # .https_or_http()
5346/// # .enable_http2()
5347/// # .build()
5348/// # );
5349/// # let mut hub = Dns::new(client, auth);
5350/// // You can configure optional parameters by calling the respective setters at will, and
5351/// // execute the final call using `doit()`.
5352/// // Values shown here are possibly random and not representative !
5353/// let result = hub.managed_zone_operations().get("project", "location", "managedZone", "operation")
5354/// .client_operation_id("et")
5355/// .doit().await;
5356/// # }
5357/// ```
5358pub struct ManagedZoneOperationGetCall<'a, C>
5359where
5360 C: 'a,
5361{
5362 hub: &'a Dns<C>,
5363 _project: String,
5364 _location: String,
5365 _managed_zone: String,
5366 _operation: String,
5367 _client_operation_id: Option<String>,
5368 _delegate: Option<&'a mut dyn common::Delegate>,
5369 _additional_params: HashMap<String, String>,
5370 _scopes: BTreeSet<String>,
5371}
5372
5373impl<'a, C> common::CallBuilder for ManagedZoneOperationGetCall<'a, C> {}
5374
5375impl<'a, C> ManagedZoneOperationGetCall<'a, C>
5376where
5377 C: common::Connector,
5378{
5379 /// Perform the operation you have build so far.
5380 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5381 use std::borrow::Cow;
5382 use std::io::{Read, Seek};
5383
5384 use common::{url::Params, ToParts};
5385 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5386
5387 let mut dd = common::DefaultDelegate;
5388 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5389 dlg.begin(common::MethodInfo {
5390 id: "dns.managedZoneOperations.get",
5391 http_method: hyper::Method::GET,
5392 });
5393
5394 for &field in [
5395 "alt",
5396 "project",
5397 "location",
5398 "managedZone",
5399 "operation",
5400 "clientOperationId",
5401 ]
5402 .iter()
5403 {
5404 if self._additional_params.contains_key(field) {
5405 dlg.finished(false);
5406 return Err(common::Error::FieldClash(field));
5407 }
5408 }
5409
5410 let mut params = Params::with_capacity(7 + self._additional_params.len());
5411 params.push("project", self._project);
5412 params.push("location", self._location);
5413 params.push("managedZone", self._managed_zone);
5414 params.push("operation", self._operation);
5415 if let Some(value) = self._client_operation_id.as_ref() {
5416 params.push("clientOperationId", value);
5417 }
5418
5419 params.extend(self._additional_params.iter());
5420
5421 params.push("alt", "json");
5422 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/operations/{operation}";
5423 if self._scopes.is_empty() {
5424 self._scopes
5425 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
5426 }
5427
5428 #[allow(clippy::single_element_loop)]
5429 for &(find_this, param_name) in [
5430 ("{project}", "project"),
5431 ("{location}", "location"),
5432 ("{managedZone}", "managedZone"),
5433 ("{operation}", "operation"),
5434 ]
5435 .iter()
5436 {
5437 url = params.uri_replacement(url, param_name, find_this, false);
5438 }
5439 {
5440 let to_remove = ["operation", "managedZone", "location", "project"];
5441 params.remove_params(&to_remove);
5442 }
5443
5444 let url = params.parse_with_url(&url);
5445
5446 loop {
5447 let token = match self
5448 .hub
5449 .auth
5450 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5451 .await
5452 {
5453 Ok(token) => token,
5454 Err(e) => match dlg.token(e) {
5455 Ok(token) => token,
5456 Err(e) => {
5457 dlg.finished(false);
5458 return Err(common::Error::MissingToken(e));
5459 }
5460 },
5461 };
5462 let mut req_result = {
5463 let client = &self.hub.client;
5464 dlg.pre_request();
5465 let mut req_builder = hyper::Request::builder()
5466 .method(hyper::Method::GET)
5467 .uri(url.as_str())
5468 .header(USER_AGENT, self.hub._user_agent.clone());
5469
5470 if let Some(token) = token.as_ref() {
5471 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5472 }
5473
5474 let request = req_builder
5475 .header(CONTENT_LENGTH, 0_u64)
5476 .body(common::to_body::<String>(None));
5477
5478 client.request(request.unwrap()).await
5479 };
5480
5481 match req_result {
5482 Err(err) => {
5483 if let common::Retry::After(d) = dlg.http_error(&err) {
5484 sleep(d).await;
5485 continue;
5486 }
5487 dlg.finished(false);
5488 return Err(common::Error::HttpError(err));
5489 }
5490 Ok(res) => {
5491 let (mut parts, body) = res.into_parts();
5492 let mut body = common::Body::new(body);
5493 if !parts.status.is_success() {
5494 let bytes = common::to_bytes(body).await.unwrap_or_default();
5495 let error = serde_json::from_str(&common::to_string(&bytes));
5496 let response = common::to_response(parts, bytes.into());
5497
5498 if let common::Retry::After(d) =
5499 dlg.http_failure(&response, error.as_ref().ok())
5500 {
5501 sleep(d).await;
5502 continue;
5503 }
5504
5505 dlg.finished(false);
5506
5507 return Err(match error {
5508 Ok(value) => common::Error::BadRequest(value),
5509 _ => common::Error::Failure(response),
5510 });
5511 }
5512 let response = {
5513 let bytes = common::to_bytes(body).await.unwrap_or_default();
5514 let encoded = common::to_string(&bytes);
5515 match serde_json::from_str(&encoded) {
5516 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5517 Err(error) => {
5518 dlg.response_json_decode_error(&encoded, &error);
5519 return Err(common::Error::JsonDecodeError(
5520 encoded.to_string(),
5521 error,
5522 ));
5523 }
5524 }
5525 };
5526
5527 dlg.finished(true);
5528 return Ok(response);
5529 }
5530 }
5531 }
5532 }
5533
5534 /// Identifies the project addressed by this request.
5535 ///
5536 /// Sets the *project* path property to the given value.
5537 ///
5538 /// Even though the property as already been set when instantiating this call,
5539 /// we provide this method for API completeness.
5540 pub fn project(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5541 self._project = new_value.to_string();
5542 self
5543 }
5544 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
5545 ///
5546 /// Sets the *location* path property to the given value.
5547 ///
5548 /// Even though the property as already been set when instantiating this call,
5549 /// we provide this method for API completeness.
5550 pub fn location(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5551 self._location = new_value.to_string();
5552 self
5553 }
5554 /// Identifies the managed zone addressed by this request.
5555 ///
5556 /// Sets the *managed zone* path property to the given value.
5557 ///
5558 /// Even though the property as already been set when instantiating this call,
5559 /// we provide this method for API completeness.
5560 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5561 self._managed_zone = new_value.to_string();
5562 self
5563 }
5564 /// Identifies the operation addressed by this request (ID of the operation).
5565 ///
5566 /// Sets the *operation* path property to the given value.
5567 ///
5568 /// Even though the property as already been set when instantiating this call,
5569 /// we provide this method for API completeness.
5570 pub fn operation(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5571 self._operation = new_value.to_string();
5572 self
5573 }
5574 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
5575 ///
5576 /// Sets the *client operation id* query property to the given value.
5577 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5578 self._client_operation_id = Some(new_value.to_string());
5579 self
5580 }
5581 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5582 /// while executing the actual API request.
5583 ///
5584 /// ````text
5585 /// It should be used to handle progress information, and to implement a certain level of resilience.
5586 /// ````
5587 ///
5588 /// Sets the *delegate* property to the given value.
5589 pub fn delegate(
5590 mut self,
5591 new_value: &'a mut dyn common::Delegate,
5592 ) -> ManagedZoneOperationGetCall<'a, C> {
5593 self._delegate = Some(new_value);
5594 self
5595 }
5596
5597 /// Set any additional parameter of the query string used in the request.
5598 /// It should be used to set parameters which are not yet available through their own
5599 /// setters.
5600 ///
5601 /// Please note that this method must not be used to set any of the known parameters
5602 /// which have their own setter method. If done anyway, the request will fail.
5603 ///
5604 /// # Additional Parameters
5605 ///
5606 /// * *$.xgafv* (query-string) - V1 error format.
5607 /// * *access_token* (query-string) - OAuth access token.
5608 /// * *alt* (query-string) - Data format for response.
5609 /// * *callback* (query-string) - JSONP
5610 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5611 /// * *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.
5612 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5613 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5614 /// * *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.
5615 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5616 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5617 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneOperationGetCall<'a, C>
5618 where
5619 T: AsRef<str>,
5620 {
5621 self._additional_params
5622 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5623 self
5624 }
5625
5626 /// Identifies the authorization scope for the method you are building.
5627 ///
5628 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5629 /// [`Scope::NdevClouddnReadonly`].
5630 ///
5631 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5632 /// tokens for more than one scope.
5633 ///
5634 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5635 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5636 /// sufficient, a read-write scope will do as well.
5637 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneOperationGetCall<'a, C>
5638 where
5639 St: AsRef<str>,
5640 {
5641 self._scopes.insert(String::from(scope.as_ref()));
5642 self
5643 }
5644 /// Identifies the authorization scope(s) for the method you are building.
5645 ///
5646 /// See [`Self::add_scope()`] for details.
5647 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneOperationGetCall<'a, C>
5648 where
5649 I: IntoIterator<Item = St>,
5650 St: AsRef<str>,
5651 {
5652 self._scopes
5653 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5654 self
5655 }
5656
5657 /// Removes all scopes, and no default scope will be used either.
5658 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5659 /// for details).
5660 pub fn clear_scopes(mut self) -> ManagedZoneOperationGetCall<'a, C> {
5661 self._scopes.clear();
5662 self
5663 }
5664}
5665
5666/// Enumerates Operations for the given ManagedZone.
5667///
5668/// A builder for the *list* method supported by a *managedZoneOperation* resource.
5669/// It is not used directly, but through a [`ManagedZoneOperationMethods`] instance.
5670///
5671/// # Example
5672///
5673/// Instantiate a resource method builder
5674///
5675/// ```test_harness,no_run
5676/// # extern crate hyper;
5677/// # extern crate hyper_rustls;
5678/// # extern crate google_dns2 as dns2;
5679/// # async fn dox() {
5680/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5681///
5682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5683/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5684/// # .with_native_roots()
5685/// # .unwrap()
5686/// # .https_only()
5687/// # .enable_http2()
5688/// # .build();
5689///
5690/// # let executor = hyper_util::rt::TokioExecutor::new();
5691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5692/// # secret,
5693/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5694/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5695/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5696/// # ),
5697/// # ).build().await.unwrap();
5698///
5699/// # let client = hyper_util::client::legacy::Client::builder(
5700/// # hyper_util::rt::TokioExecutor::new()
5701/// # )
5702/// # .build(
5703/// # hyper_rustls::HttpsConnectorBuilder::new()
5704/// # .with_native_roots()
5705/// # .unwrap()
5706/// # .https_or_http()
5707/// # .enable_http2()
5708/// # .build()
5709/// # );
5710/// # let mut hub = Dns::new(client, auth);
5711/// // You can configure optional parameters by calling the respective setters at will, and
5712/// // execute the final call using `doit()`.
5713/// // Values shown here are possibly random and not representative !
5714/// let result = hub.managed_zone_operations().list("project", "location", "managedZone")
5715/// .sort_by("duo")
5716/// .page_token("dolore")
5717/// .max_results(-22)
5718/// .doit().await;
5719/// # }
5720/// ```
5721pub struct ManagedZoneOperationListCall<'a, C>
5722where
5723 C: 'a,
5724{
5725 hub: &'a Dns<C>,
5726 _project: String,
5727 _location: String,
5728 _managed_zone: String,
5729 _sort_by: Option<String>,
5730 _page_token: Option<String>,
5731 _max_results: Option<i32>,
5732 _delegate: Option<&'a mut dyn common::Delegate>,
5733 _additional_params: HashMap<String, String>,
5734 _scopes: BTreeSet<String>,
5735}
5736
5737impl<'a, C> common::CallBuilder for ManagedZoneOperationListCall<'a, C> {}
5738
5739impl<'a, C> ManagedZoneOperationListCall<'a, C>
5740where
5741 C: common::Connector,
5742{
5743 /// Perform the operation you have build so far.
5744 pub async fn doit(
5745 mut self,
5746 ) -> common::Result<(common::Response, ManagedZoneOperationsListResponse)> {
5747 use std::borrow::Cow;
5748 use std::io::{Read, Seek};
5749
5750 use common::{url::Params, ToParts};
5751 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5752
5753 let mut dd = common::DefaultDelegate;
5754 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5755 dlg.begin(common::MethodInfo {
5756 id: "dns.managedZoneOperations.list",
5757 http_method: hyper::Method::GET,
5758 });
5759
5760 for &field in [
5761 "alt",
5762 "project",
5763 "location",
5764 "managedZone",
5765 "sortBy",
5766 "pageToken",
5767 "maxResults",
5768 ]
5769 .iter()
5770 {
5771 if self._additional_params.contains_key(field) {
5772 dlg.finished(false);
5773 return Err(common::Error::FieldClash(field));
5774 }
5775 }
5776
5777 let mut params = Params::with_capacity(8 + self._additional_params.len());
5778 params.push("project", self._project);
5779 params.push("location", self._location);
5780 params.push("managedZone", self._managed_zone);
5781 if let Some(value) = self._sort_by.as_ref() {
5782 params.push("sortBy", value);
5783 }
5784 if let Some(value) = self._page_token.as_ref() {
5785 params.push("pageToken", value);
5786 }
5787 if let Some(value) = self._max_results.as_ref() {
5788 params.push("maxResults", value.to_string());
5789 }
5790
5791 params.extend(self._additional_params.iter());
5792
5793 params.push("alt", "json");
5794 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/operations";
5795 if self._scopes.is_empty() {
5796 self._scopes
5797 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
5798 }
5799
5800 #[allow(clippy::single_element_loop)]
5801 for &(find_this, param_name) in [
5802 ("{project}", "project"),
5803 ("{location}", "location"),
5804 ("{managedZone}", "managedZone"),
5805 ]
5806 .iter()
5807 {
5808 url = params.uri_replacement(url, param_name, find_this, false);
5809 }
5810 {
5811 let to_remove = ["managedZone", "location", "project"];
5812 params.remove_params(&to_remove);
5813 }
5814
5815 let url = params.parse_with_url(&url);
5816
5817 loop {
5818 let token = match self
5819 .hub
5820 .auth
5821 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5822 .await
5823 {
5824 Ok(token) => token,
5825 Err(e) => match dlg.token(e) {
5826 Ok(token) => token,
5827 Err(e) => {
5828 dlg.finished(false);
5829 return Err(common::Error::MissingToken(e));
5830 }
5831 },
5832 };
5833 let mut req_result = {
5834 let client = &self.hub.client;
5835 dlg.pre_request();
5836 let mut req_builder = hyper::Request::builder()
5837 .method(hyper::Method::GET)
5838 .uri(url.as_str())
5839 .header(USER_AGENT, self.hub._user_agent.clone());
5840
5841 if let Some(token) = token.as_ref() {
5842 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5843 }
5844
5845 let request = req_builder
5846 .header(CONTENT_LENGTH, 0_u64)
5847 .body(common::to_body::<String>(None));
5848
5849 client.request(request.unwrap()).await
5850 };
5851
5852 match req_result {
5853 Err(err) => {
5854 if let common::Retry::After(d) = dlg.http_error(&err) {
5855 sleep(d).await;
5856 continue;
5857 }
5858 dlg.finished(false);
5859 return Err(common::Error::HttpError(err));
5860 }
5861 Ok(res) => {
5862 let (mut parts, body) = res.into_parts();
5863 let mut body = common::Body::new(body);
5864 if !parts.status.is_success() {
5865 let bytes = common::to_bytes(body).await.unwrap_or_default();
5866 let error = serde_json::from_str(&common::to_string(&bytes));
5867 let response = common::to_response(parts, bytes.into());
5868
5869 if let common::Retry::After(d) =
5870 dlg.http_failure(&response, error.as_ref().ok())
5871 {
5872 sleep(d).await;
5873 continue;
5874 }
5875
5876 dlg.finished(false);
5877
5878 return Err(match error {
5879 Ok(value) => common::Error::BadRequest(value),
5880 _ => common::Error::Failure(response),
5881 });
5882 }
5883 let response = {
5884 let bytes = common::to_bytes(body).await.unwrap_or_default();
5885 let encoded = common::to_string(&bytes);
5886 match serde_json::from_str(&encoded) {
5887 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5888 Err(error) => {
5889 dlg.response_json_decode_error(&encoded, &error);
5890 return Err(common::Error::JsonDecodeError(
5891 encoded.to_string(),
5892 error,
5893 ));
5894 }
5895 }
5896 };
5897
5898 dlg.finished(true);
5899 return Ok(response);
5900 }
5901 }
5902 }
5903 }
5904
5905 /// Identifies the project addressed by this request.
5906 ///
5907 /// Sets the *project* path property to the given value.
5908 ///
5909 /// Even though the property as already been set when instantiating this call,
5910 /// we provide this method for API completeness.
5911 pub fn project(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5912 self._project = new_value.to_string();
5913 self
5914 }
5915 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
5916 ///
5917 /// Sets the *location* path property to the given value.
5918 ///
5919 /// Even though the property as already been set when instantiating this call,
5920 /// we provide this method for API completeness.
5921 pub fn location(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5922 self._location = new_value.to_string();
5923 self
5924 }
5925 /// Identifies the managed zone addressed by this request.
5926 ///
5927 /// Sets the *managed zone* path property to the given value.
5928 ///
5929 /// Even though the property as already been set when instantiating this call,
5930 /// we provide this method for API completeness.
5931 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5932 self._managed_zone = new_value.to_string();
5933 self
5934 }
5935 /// Sorting criterion. The only supported values are START_TIME and ID.
5936 ///
5937 /// Sets the *sort by* query property to the given value.
5938 pub fn sort_by(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5939 self._sort_by = Some(new_value.to_string());
5940 self
5941 }
5942 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
5943 ///
5944 /// Sets the *page token* query property to the given value.
5945 pub fn page_token(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5946 self._page_token = Some(new_value.to_string());
5947 self
5948 }
5949 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
5950 ///
5951 /// Sets the *max results* query property to the given value.
5952 pub fn max_results(mut self, new_value: i32) -> ManagedZoneOperationListCall<'a, C> {
5953 self._max_results = Some(new_value);
5954 self
5955 }
5956 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5957 /// while executing the actual API request.
5958 ///
5959 /// ````text
5960 /// It should be used to handle progress information, and to implement a certain level of resilience.
5961 /// ````
5962 ///
5963 /// Sets the *delegate* property to the given value.
5964 pub fn delegate(
5965 mut self,
5966 new_value: &'a mut dyn common::Delegate,
5967 ) -> ManagedZoneOperationListCall<'a, C> {
5968 self._delegate = Some(new_value);
5969 self
5970 }
5971
5972 /// Set any additional parameter of the query string used in the request.
5973 /// It should be used to set parameters which are not yet available through their own
5974 /// setters.
5975 ///
5976 /// Please note that this method must not be used to set any of the known parameters
5977 /// which have their own setter method. If done anyway, the request will fail.
5978 ///
5979 /// # Additional Parameters
5980 ///
5981 /// * *$.xgafv* (query-string) - V1 error format.
5982 /// * *access_token* (query-string) - OAuth access token.
5983 /// * *alt* (query-string) - Data format for response.
5984 /// * *callback* (query-string) - JSONP
5985 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5986 /// * *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.
5987 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5988 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5989 /// * *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.
5990 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5991 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5992 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneOperationListCall<'a, C>
5993 where
5994 T: AsRef<str>,
5995 {
5996 self._additional_params
5997 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5998 self
5999 }
6000
6001 /// Identifies the authorization scope for the method you are building.
6002 ///
6003 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6004 /// [`Scope::NdevClouddnReadonly`].
6005 ///
6006 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6007 /// tokens for more than one scope.
6008 ///
6009 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6010 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6011 /// sufficient, a read-write scope will do as well.
6012 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneOperationListCall<'a, C>
6013 where
6014 St: AsRef<str>,
6015 {
6016 self._scopes.insert(String::from(scope.as_ref()));
6017 self
6018 }
6019 /// Identifies the authorization scope(s) for the method you are building.
6020 ///
6021 /// See [`Self::add_scope()`] for details.
6022 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneOperationListCall<'a, C>
6023 where
6024 I: IntoIterator<Item = St>,
6025 St: AsRef<str>,
6026 {
6027 self._scopes
6028 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6029 self
6030 }
6031
6032 /// Removes all scopes, and no default scope will be used either.
6033 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6034 /// for details).
6035 pub fn clear_scopes(mut self) -> ManagedZoneOperationListCall<'a, C> {
6036 self._scopes.clear();
6037 self
6038 }
6039}
6040
6041/// Creates a new ManagedZone.
6042///
6043/// A builder for the *create* method supported by a *managedZone* resource.
6044/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
6045///
6046/// # Example
6047///
6048/// Instantiate a resource method builder
6049///
6050/// ```test_harness,no_run
6051/// # extern crate hyper;
6052/// # extern crate hyper_rustls;
6053/// # extern crate google_dns2 as dns2;
6054/// use dns2::api::ManagedZone;
6055/// # async fn dox() {
6056/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6057///
6058/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6059/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6060/// # .with_native_roots()
6061/// # .unwrap()
6062/// # .https_only()
6063/// # .enable_http2()
6064/// # .build();
6065///
6066/// # let executor = hyper_util::rt::TokioExecutor::new();
6067/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6068/// # secret,
6069/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6070/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6071/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6072/// # ),
6073/// # ).build().await.unwrap();
6074///
6075/// # let client = hyper_util::client::legacy::Client::builder(
6076/// # hyper_util::rt::TokioExecutor::new()
6077/// # )
6078/// # .build(
6079/// # hyper_rustls::HttpsConnectorBuilder::new()
6080/// # .with_native_roots()
6081/// # .unwrap()
6082/// # .https_or_http()
6083/// # .enable_http2()
6084/// # .build()
6085/// # );
6086/// # let mut hub = Dns::new(client, auth);
6087/// // As the method needs a request, you would usually fill it with the desired information
6088/// // into the respective structure. Some of the parts shown here might not be applicable !
6089/// // Values shown here are possibly random and not representative !
6090/// let mut req = ManagedZone::default();
6091///
6092/// // You can configure optional parameters by calling the respective setters at will, and
6093/// // execute the final call using `doit()`.
6094/// // Values shown here are possibly random and not representative !
6095/// let result = hub.managed_zones().create(req, "project", "location")
6096/// .client_operation_id("consetetur")
6097/// .doit().await;
6098/// # }
6099/// ```
6100pub struct ManagedZoneCreateCall<'a, C>
6101where
6102 C: 'a,
6103{
6104 hub: &'a Dns<C>,
6105 _request: ManagedZone,
6106 _project: String,
6107 _location: String,
6108 _client_operation_id: Option<String>,
6109 _delegate: Option<&'a mut dyn common::Delegate>,
6110 _additional_params: HashMap<String, String>,
6111 _scopes: BTreeSet<String>,
6112}
6113
6114impl<'a, C> common::CallBuilder for ManagedZoneCreateCall<'a, C> {}
6115
6116impl<'a, C> ManagedZoneCreateCall<'a, C>
6117where
6118 C: common::Connector,
6119{
6120 /// Perform the operation you have build so far.
6121 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedZone)> {
6122 use std::borrow::Cow;
6123 use std::io::{Read, Seek};
6124
6125 use common::{url::Params, ToParts};
6126 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6127
6128 let mut dd = common::DefaultDelegate;
6129 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6130 dlg.begin(common::MethodInfo {
6131 id: "dns.managedZones.create",
6132 http_method: hyper::Method::POST,
6133 });
6134
6135 for &field in ["alt", "project", "location", "clientOperationId"].iter() {
6136 if self._additional_params.contains_key(field) {
6137 dlg.finished(false);
6138 return Err(common::Error::FieldClash(field));
6139 }
6140 }
6141
6142 let mut params = Params::with_capacity(6 + self._additional_params.len());
6143 params.push("project", self._project);
6144 params.push("location", self._location);
6145 if let Some(value) = self._client_operation_id.as_ref() {
6146 params.push("clientOperationId", value);
6147 }
6148
6149 params.extend(self._additional_params.iter());
6150
6151 params.push("alt", "json");
6152 let mut url = self.hub._base_url.clone()
6153 + "dns/v2/projects/{project}/locations/{location}/managedZones";
6154 if self._scopes.is_empty() {
6155 self._scopes
6156 .insert(Scope::CloudPlatform.as_ref().to_string());
6157 }
6158
6159 #[allow(clippy::single_element_loop)]
6160 for &(find_this, param_name) in
6161 [("{project}", "project"), ("{location}", "location")].iter()
6162 {
6163 url = params.uri_replacement(url, param_name, find_this, false);
6164 }
6165 {
6166 let to_remove = ["location", "project"];
6167 params.remove_params(&to_remove);
6168 }
6169
6170 let url = params.parse_with_url(&url);
6171
6172 let mut json_mime_type = mime::APPLICATION_JSON;
6173 let mut request_value_reader = {
6174 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6175 common::remove_json_null_values(&mut value);
6176 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6177 serde_json::to_writer(&mut dst, &value).unwrap();
6178 dst
6179 };
6180 let request_size = request_value_reader
6181 .seek(std::io::SeekFrom::End(0))
6182 .unwrap();
6183 request_value_reader
6184 .seek(std::io::SeekFrom::Start(0))
6185 .unwrap();
6186
6187 loop {
6188 let token = match self
6189 .hub
6190 .auth
6191 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6192 .await
6193 {
6194 Ok(token) => token,
6195 Err(e) => match dlg.token(e) {
6196 Ok(token) => token,
6197 Err(e) => {
6198 dlg.finished(false);
6199 return Err(common::Error::MissingToken(e));
6200 }
6201 },
6202 };
6203 request_value_reader
6204 .seek(std::io::SeekFrom::Start(0))
6205 .unwrap();
6206 let mut req_result = {
6207 let client = &self.hub.client;
6208 dlg.pre_request();
6209 let mut req_builder = hyper::Request::builder()
6210 .method(hyper::Method::POST)
6211 .uri(url.as_str())
6212 .header(USER_AGENT, self.hub._user_agent.clone());
6213
6214 if let Some(token) = token.as_ref() {
6215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6216 }
6217
6218 let request = req_builder
6219 .header(CONTENT_TYPE, json_mime_type.to_string())
6220 .header(CONTENT_LENGTH, request_size as u64)
6221 .body(common::to_body(
6222 request_value_reader.get_ref().clone().into(),
6223 ));
6224
6225 client.request(request.unwrap()).await
6226 };
6227
6228 match req_result {
6229 Err(err) => {
6230 if let common::Retry::After(d) = dlg.http_error(&err) {
6231 sleep(d).await;
6232 continue;
6233 }
6234 dlg.finished(false);
6235 return Err(common::Error::HttpError(err));
6236 }
6237 Ok(res) => {
6238 let (mut parts, body) = res.into_parts();
6239 let mut body = common::Body::new(body);
6240 if !parts.status.is_success() {
6241 let bytes = common::to_bytes(body).await.unwrap_or_default();
6242 let error = serde_json::from_str(&common::to_string(&bytes));
6243 let response = common::to_response(parts, bytes.into());
6244
6245 if let common::Retry::After(d) =
6246 dlg.http_failure(&response, error.as_ref().ok())
6247 {
6248 sleep(d).await;
6249 continue;
6250 }
6251
6252 dlg.finished(false);
6253
6254 return Err(match error {
6255 Ok(value) => common::Error::BadRequest(value),
6256 _ => common::Error::Failure(response),
6257 });
6258 }
6259 let response = {
6260 let bytes = common::to_bytes(body).await.unwrap_or_default();
6261 let encoded = common::to_string(&bytes);
6262 match serde_json::from_str(&encoded) {
6263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6264 Err(error) => {
6265 dlg.response_json_decode_error(&encoded, &error);
6266 return Err(common::Error::JsonDecodeError(
6267 encoded.to_string(),
6268 error,
6269 ));
6270 }
6271 }
6272 };
6273
6274 dlg.finished(true);
6275 return Ok(response);
6276 }
6277 }
6278 }
6279 }
6280
6281 ///
6282 /// Sets the *request* property to the given value.
6283 ///
6284 /// Even though the property as already been set when instantiating this call,
6285 /// we provide this method for API completeness.
6286 pub fn request(mut self, new_value: ManagedZone) -> ManagedZoneCreateCall<'a, C> {
6287 self._request = new_value;
6288 self
6289 }
6290 /// Identifies the project addressed by this request.
6291 ///
6292 /// Sets the *project* path property to the given value.
6293 ///
6294 /// Even though the property as already been set when instantiating this call,
6295 /// we provide this method for API completeness.
6296 pub fn project(mut self, new_value: &str) -> ManagedZoneCreateCall<'a, C> {
6297 self._project = new_value.to_string();
6298 self
6299 }
6300 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
6301 ///
6302 /// Sets the *location* path property to the given value.
6303 ///
6304 /// Even though the property as already been set when instantiating this call,
6305 /// we provide this method for API completeness.
6306 pub fn location(mut self, new_value: &str) -> ManagedZoneCreateCall<'a, C> {
6307 self._location = new_value.to_string();
6308 self
6309 }
6310 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
6311 ///
6312 /// Sets the *client operation id* query property to the given value.
6313 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneCreateCall<'a, C> {
6314 self._client_operation_id = Some(new_value.to_string());
6315 self
6316 }
6317 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6318 /// while executing the actual API request.
6319 ///
6320 /// ````text
6321 /// It should be used to handle progress information, and to implement a certain level of resilience.
6322 /// ````
6323 ///
6324 /// Sets the *delegate* property to the given value.
6325 pub fn delegate(
6326 mut self,
6327 new_value: &'a mut dyn common::Delegate,
6328 ) -> ManagedZoneCreateCall<'a, C> {
6329 self._delegate = Some(new_value);
6330 self
6331 }
6332
6333 /// Set any additional parameter of the query string used in the request.
6334 /// It should be used to set parameters which are not yet available through their own
6335 /// setters.
6336 ///
6337 /// Please note that this method must not be used to set any of the known parameters
6338 /// which have their own setter method. If done anyway, the request will fail.
6339 ///
6340 /// # Additional Parameters
6341 ///
6342 /// * *$.xgafv* (query-string) - V1 error format.
6343 /// * *access_token* (query-string) - OAuth access token.
6344 /// * *alt* (query-string) - Data format for response.
6345 /// * *callback* (query-string) - JSONP
6346 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6347 /// * *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.
6348 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6349 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6350 /// * *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.
6351 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6352 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6353 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneCreateCall<'a, C>
6354 where
6355 T: AsRef<str>,
6356 {
6357 self._additional_params
6358 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6359 self
6360 }
6361
6362 /// Identifies the authorization scope for the method you are building.
6363 ///
6364 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6365 /// [`Scope::CloudPlatform`].
6366 ///
6367 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6368 /// tokens for more than one scope.
6369 ///
6370 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6371 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6372 /// sufficient, a read-write scope will do as well.
6373 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneCreateCall<'a, C>
6374 where
6375 St: AsRef<str>,
6376 {
6377 self._scopes.insert(String::from(scope.as_ref()));
6378 self
6379 }
6380 /// Identifies the authorization scope(s) for the method you are building.
6381 ///
6382 /// See [`Self::add_scope()`] for details.
6383 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneCreateCall<'a, C>
6384 where
6385 I: IntoIterator<Item = St>,
6386 St: AsRef<str>,
6387 {
6388 self._scopes
6389 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6390 self
6391 }
6392
6393 /// Removes all scopes, and no default scope will be used either.
6394 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6395 /// for details).
6396 pub fn clear_scopes(mut self) -> ManagedZoneCreateCall<'a, C> {
6397 self._scopes.clear();
6398 self
6399 }
6400}
6401
6402/// Deletes a previously created ManagedZone.
6403///
6404/// A builder for the *delete* method supported by a *managedZone* resource.
6405/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
6406///
6407/// # Example
6408///
6409/// Instantiate a resource method builder
6410///
6411/// ```test_harness,no_run
6412/// # extern crate hyper;
6413/// # extern crate hyper_rustls;
6414/// # extern crate google_dns2 as dns2;
6415/// # async fn dox() {
6416/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6417///
6418/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6419/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6420/// # .with_native_roots()
6421/// # .unwrap()
6422/// # .https_only()
6423/// # .enable_http2()
6424/// # .build();
6425///
6426/// # let executor = hyper_util::rt::TokioExecutor::new();
6427/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6428/// # secret,
6429/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6430/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6431/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6432/// # ),
6433/// # ).build().await.unwrap();
6434///
6435/// # let client = hyper_util::client::legacy::Client::builder(
6436/// # hyper_util::rt::TokioExecutor::new()
6437/// # )
6438/// # .build(
6439/// # hyper_rustls::HttpsConnectorBuilder::new()
6440/// # .with_native_roots()
6441/// # .unwrap()
6442/// # .https_or_http()
6443/// # .enable_http2()
6444/// # .build()
6445/// # );
6446/// # let mut hub = Dns::new(client, auth);
6447/// // You can configure optional parameters by calling the respective setters at will, and
6448/// // execute the final call using `doit()`.
6449/// // Values shown here are possibly random and not representative !
6450/// let result = hub.managed_zones().delete("project", "location", "managedZone")
6451/// .client_operation_id("et")
6452/// .doit().await;
6453/// # }
6454/// ```
6455pub struct ManagedZoneDeleteCall<'a, C>
6456where
6457 C: 'a,
6458{
6459 hub: &'a Dns<C>,
6460 _project: String,
6461 _location: String,
6462 _managed_zone: String,
6463 _client_operation_id: Option<String>,
6464 _delegate: Option<&'a mut dyn common::Delegate>,
6465 _additional_params: HashMap<String, String>,
6466 _scopes: BTreeSet<String>,
6467}
6468
6469impl<'a, C> common::CallBuilder for ManagedZoneDeleteCall<'a, C> {}
6470
6471impl<'a, C> ManagedZoneDeleteCall<'a, C>
6472where
6473 C: common::Connector,
6474{
6475 /// Perform the operation you have build so far.
6476 pub async fn doit(mut self) -> common::Result<common::Response> {
6477 use std::borrow::Cow;
6478 use std::io::{Read, Seek};
6479
6480 use common::{url::Params, ToParts};
6481 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6482
6483 let mut dd = common::DefaultDelegate;
6484 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6485 dlg.begin(common::MethodInfo {
6486 id: "dns.managedZones.delete",
6487 http_method: hyper::Method::DELETE,
6488 });
6489
6490 for &field in ["project", "location", "managedZone", "clientOperationId"].iter() {
6491 if self._additional_params.contains_key(field) {
6492 dlg.finished(false);
6493 return Err(common::Error::FieldClash(field));
6494 }
6495 }
6496
6497 let mut params = Params::with_capacity(5 + self._additional_params.len());
6498 params.push("project", self._project);
6499 params.push("location", self._location);
6500 params.push("managedZone", self._managed_zone);
6501 if let Some(value) = self._client_operation_id.as_ref() {
6502 params.push("clientOperationId", value);
6503 }
6504
6505 params.extend(self._additional_params.iter());
6506
6507 let mut url = self.hub._base_url.clone()
6508 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}";
6509 if self._scopes.is_empty() {
6510 self._scopes
6511 .insert(Scope::CloudPlatform.as_ref().to_string());
6512 }
6513
6514 #[allow(clippy::single_element_loop)]
6515 for &(find_this, param_name) in [
6516 ("{project}", "project"),
6517 ("{location}", "location"),
6518 ("{managedZone}", "managedZone"),
6519 ]
6520 .iter()
6521 {
6522 url = params.uri_replacement(url, param_name, find_this, false);
6523 }
6524 {
6525 let to_remove = ["managedZone", "location", "project"];
6526 params.remove_params(&to_remove);
6527 }
6528
6529 let url = params.parse_with_url(&url);
6530
6531 loop {
6532 let token = match self
6533 .hub
6534 .auth
6535 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6536 .await
6537 {
6538 Ok(token) => token,
6539 Err(e) => match dlg.token(e) {
6540 Ok(token) => token,
6541 Err(e) => {
6542 dlg.finished(false);
6543 return Err(common::Error::MissingToken(e));
6544 }
6545 },
6546 };
6547 let mut req_result = {
6548 let client = &self.hub.client;
6549 dlg.pre_request();
6550 let mut req_builder = hyper::Request::builder()
6551 .method(hyper::Method::DELETE)
6552 .uri(url.as_str())
6553 .header(USER_AGENT, self.hub._user_agent.clone());
6554
6555 if let Some(token) = token.as_ref() {
6556 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6557 }
6558
6559 let request = req_builder
6560 .header(CONTENT_LENGTH, 0_u64)
6561 .body(common::to_body::<String>(None));
6562
6563 client.request(request.unwrap()).await
6564 };
6565
6566 match req_result {
6567 Err(err) => {
6568 if let common::Retry::After(d) = dlg.http_error(&err) {
6569 sleep(d).await;
6570 continue;
6571 }
6572 dlg.finished(false);
6573 return Err(common::Error::HttpError(err));
6574 }
6575 Ok(res) => {
6576 let (mut parts, body) = res.into_parts();
6577 let mut body = common::Body::new(body);
6578 if !parts.status.is_success() {
6579 let bytes = common::to_bytes(body).await.unwrap_or_default();
6580 let error = serde_json::from_str(&common::to_string(&bytes));
6581 let response = common::to_response(parts, bytes.into());
6582
6583 if let common::Retry::After(d) =
6584 dlg.http_failure(&response, error.as_ref().ok())
6585 {
6586 sleep(d).await;
6587 continue;
6588 }
6589
6590 dlg.finished(false);
6591
6592 return Err(match error {
6593 Ok(value) => common::Error::BadRequest(value),
6594 _ => common::Error::Failure(response),
6595 });
6596 }
6597 let response = common::Response::from_parts(parts, body);
6598
6599 dlg.finished(true);
6600 return Ok(response);
6601 }
6602 }
6603 }
6604 }
6605
6606 /// Identifies the project addressed by this request.
6607 ///
6608 /// Sets the *project* path property to the given value.
6609 ///
6610 /// Even though the property as already been set when instantiating this call,
6611 /// we provide this method for API completeness.
6612 pub fn project(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6613 self._project = new_value.to_string();
6614 self
6615 }
6616 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
6617 ///
6618 /// Sets the *location* path property to the given value.
6619 ///
6620 /// Even though the property as already been set when instantiating this call,
6621 /// we provide this method for API completeness.
6622 pub fn location(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6623 self._location = new_value.to_string();
6624 self
6625 }
6626 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
6627 ///
6628 /// Sets the *managed zone* path property to the given value.
6629 ///
6630 /// Even though the property as already been set when instantiating this call,
6631 /// we provide this method for API completeness.
6632 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6633 self._managed_zone = new_value.to_string();
6634 self
6635 }
6636 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
6637 ///
6638 /// Sets the *client operation id* query property to the given value.
6639 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6640 self._client_operation_id = Some(new_value.to_string());
6641 self
6642 }
6643 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6644 /// while executing the actual API request.
6645 ///
6646 /// ````text
6647 /// It should be used to handle progress information, and to implement a certain level of resilience.
6648 /// ````
6649 ///
6650 /// Sets the *delegate* property to the given value.
6651 pub fn delegate(
6652 mut self,
6653 new_value: &'a mut dyn common::Delegate,
6654 ) -> ManagedZoneDeleteCall<'a, C> {
6655 self._delegate = Some(new_value);
6656 self
6657 }
6658
6659 /// Set any additional parameter of the query string used in the request.
6660 /// It should be used to set parameters which are not yet available through their own
6661 /// setters.
6662 ///
6663 /// Please note that this method must not be used to set any of the known parameters
6664 /// which have their own setter method. If done anyway, the request will fail.
6665 ///
6666 /// # Additional Parameters
6667 ///
6668 /// * *$.xgafv* (query-string) - V1 error format.
6669 /// * *access_token* (query-string) - OAuth access token.
6670 /// * *alt* (query-string) - Data format for response.
6671 /// * *callback* (query-string) - JSONP
6672 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6673 /// * *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.
6674 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6675 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6676 /// * *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.
6677 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6678 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6679 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneDeleteCall<'a, C>
6680 where
6681 T: AsRef<str>,
6682 {
6683 self._additional_params
6684 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6685 self
6686 }
6687
6688 /// Identifies the authorization scope for the method you are building.
6689 ///
6690 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6691 /// [`Scope::CloudPlatform`].
6692 ///
6693 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6694 /// tokens for more than one scope.
6695 ///
6696 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6697 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6698 /// sufficient, a read-write scope will do as well.
6699 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneDeleteCall<'a, C>
6700 where
6701 St: AsRef<str>,
6702 {
6703 self._scopes.insert(String::from(scope.as_ref()));
6704 self
6705 }
6706 /// Identifies the authorization scope(s) for the method you are building.
6707 ///
6708 /// See [`Self::add_scope()`] for details.
6709 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneDeleteCall<'a, C>
6710 where
6711 I: IntoIterator<Item = St>,
6712 St: AsRef<str>,
6713 {
6714 self._scopes
6715 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6716 self
6717 }
6718
6719 /// Removes all scopes, and no default scope will be used either.
6720 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6721 /// for details).
6722 pub fn clear_scopes(mut self) -> ManagedZoneDeleteCall<'a, C> {
6723 self._scopes.clear();
6724 self
6725 }
6726}
6727
6728/// Fetches the representation of an existing ManagedZone.
6729///
6730/// A builder for the *get* method supported by a *managedZone* resource.
6731/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
6732///
6733/// # Example
6734///
6735/// Instantiate a resource method builder
6736///
6737/// ```test_harness,no_run
6738/// # extern crate hyper;
6739/// # extern crate hyper_rustls;
6740/// # extern crate google_dns2 as dns2;
6741/// # async fn dox() {
6742/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6743///
6744/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6745/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6746/// # .with_native_roots()
6747/// # .unwrap()
6748/// # .https_only()
6749/// # .enable_http2()
6750/// # .build();
6751///
6752/// # let executor = hyper_util::rt::TokioExecutor::new();
6753/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6754/// # secret,
6755/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6756/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6757/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6758/// # ),
6759/// # ).build().await.unwrap();
6760///
6761/// # let client = hyper_util::client::legacy::Client::builder(
6762/// # hyper_util::rt::TokioExecutor::new()
6763/// # )
6764/// # .build(
6765/// # hyper_rustls::HttpsConnectorBuilder::new()
6766/// # .with_native_roots()
6767/// # .unwrap()
6768/// # .https_or_http()
6769/// # .enable_http2()
6770/// # .build()
6771/// # );
6772/// # let mut hub = Dns::new(client, auth);
6773/// // You can configure optional parameters by calling the respective setters at will, and
6774/// // execute the final call using `doit()`.
6775/// // Values shown here are possibly random and not representative !
6776/// let result = hub.managed_zones().get("project", "location", "managedZone")
6777/// .client_operation_id("duo")
6778/// .doit().await;
6779/// # }
6780/// ```
6781pub struct ManagedZoneGetCall<'a, C>
6782where
6783 C: 'a,
6784{
6785 hub: &'a Dns<C>,
6786 _project: String,
6787 _location: String,
6788 _managed_zone: String,
6789 _client_operation_id: Option<String>,
6790 _delegate: Option<&'a mut dyn common::Delegate>,
6791 _additional_params: HashMap<String, String>,
6792 _scopes: BTreeSet<String>,
6793}
6794
6795impl<'a, C> common::CallBuilder for ManagedZoneGetCall<'a, C> {}
6796
6797impl<'a, C> ManagedZoneGetCall<'a, C>
6798where
6799 C: common::Connector,
6800{
6801 /// Perform the operation you have build so far.
6802 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedZone)> {
6803 use std::borrow::Cow;
6804 use std::io::{Read, Seek};
6805
6806 use common::{url::Params, ToParts};
6807 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6808
6809 let mut dd = common::DefaultDelegate;
6810 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6811 dlg.begin(common::MethodInfo {
6812 id: "dns.managedZones.get",
6813 http_method: hyper::Method::GET,
6814 });
6815
6816 for &field in [
6817 "alt",
6818 "project",
6819 "location",
6820 "managedZone",
6821 "clientOperationId",
6822 ]
6823 .iter()
6824 {
6825 if self._additional_params.contains_key(field) {
6826 dlg.finished(false);
6827 return Err(common::Error::FieldClash(field));
6828 }
6829 }
6830
6831 let mut params = Params::with_capacity(6 + self._additional_params.len());
6832 params.push("project", self._project);
6833 params.push("location", self._location);
6834 params.push("managedZone", self._managed_zone);
6835 if let Some(value) = self._client_operation_id.as_ref() {
6836 params.push("clientOperationId", value);
6837 }
6838
6839 params.extend(self._additional_params.iter());
6840
6841 params.push("alt", "json");
6842 let mut url = self.hub._base_url.clone()
6843 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}";
6844 if self._scopes.is_empty() {
6845 self._scopes
6846 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
6847 }
6848
6849 #[allow(clippy::single_element_loop)]
6850 for &(find_this, param_name) in [
6851 ("{project}", "project"),
6852 ("{location}", "location"),
6853 ("{managedZone}", "managedZone"),
6854 ]
6855 .iter()
6856 {
6857 url = params.uri_replacement(url, param_name, find_this, false);
6858 }
6859 {
6860 let to_remove = ["managedZone", "location", "project"];
6861 params.remove_params(&to_remove);
6862 }
6863
6864 let url = params.parse_with_url(&url);
6865
6866 loop {
6867 let token = match self
6868 .hub
6869 .auth
6870 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6871 .await
6872 {
6873 Ok(token) => token,
6874 Err(e) => match dlg.token(e) {
6875 Ok(token) => token,
6876 Err(e) => {
6877 dlg.finished(false);
6878 return Err(common::Error::MissingToken(e));
6879 }
6880 },
6881 };
6882 let mut req_result = {
6883 let client = &self.hub.client;
6884 dlg.pre_request();
6885 let mut req_builder = hyper::Request::builder()
6886 .method(hyper::Method::GET)
6887 .uri(url.as_str())
6888 .header(USER_AGENT, self.hub._user_agent.clone());
6889
6890 if let Some(token) = token.as_ref() {
6891 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6892 }
6893
6894 let request = req_builder
6895 .header(CONTENT_LENGTH, 0_u64)
6896 .body(common::to_body::<String>(None));
6897
6898 client.request(request.unwrap()).await
6899 };
6900
6901 match req_result {
6902 Err(err) => {
6903 if let common::Retry::After(d) = dlg.http_error(&err) {
6904 sleep(d).await;
6905 continue;
6906 }
6907 dlg.finished(false);
6908 return Err(common::Error::HttpError(err));
6909 }
6910 Ok(res) => {
6911 let (mut parts, body) = res.into_parts();
6912 let mut body = common::Body::new(body);
6913 if !parts.status.is_success() {
6914 let bytes = common::to_bytes(body).await.unwrap_or_default();
6915 let error = serde_json::from_str(&common::to_string(&bytes));
6916 let response = common::to_response(parts, bytes.into());
6917
6918 if let common::Retry::After(d) =
6919 dlg.http_failure(&response, error.as_ref().ok())
6920 {
6921 sleep(d).await;
6922 continue;
6923 }
6924
6925 dlg.finished(false);
6926
6927 return Err(match error {
6928 Ok(value) => common::Error::BadRequest(value),
6929 _ => common::Error::Failure(response),
6930 });
6931 }
6932 let response = {
6933 let bytes = common::to_bytes(body).await.unwrap_or_default();
6934 let encoded = common::to_string(&bytes);
6935 match serde_json::from_str(&encoded) {
6936 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6937 Err(error) => {
6938 dlg.response_json_decode_error(&encoded, &error);
6939 return Err(common::Error::JsonDecodeError(
6940 encoded.to_string(),
6941 error,
6942 ));
6943 }
6944 }
6945 };
6946
6947 dlg.finished(true);
6948 return Ok(response);
6949 }
6950 }
6951 }
6952 }
6953
6954 /// Identifies the project addressed by this request.
6955 ///
6956 /// Sets the *project* path property to the given value.
6957 ///
6958 /// Even though the property as already been set when instantiating this call,
6959 /// we provide this method for API completeness.
6960 pub fn project(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6961 self._project = new_value.to_string();
6962 self
6963 }
6964 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
6965 ///
6966 /// Sets the *location* path property to the given value.
6967 ///
6968 /// Even though the property as already been set when instantiating this call,
6969 /// we provide this method for API completeness.
6970 pub fn location(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6971 self._location = new_value.to_string();
6972 self
6973 }
6974 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
6975 ///
6976 /// Sets the *managed zone* path property to the given value.
6977 ///
6978 /// Even though the property as already been set when instantiating this call,
6979 /// we provide this method for API completeness.
6980 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6981 self._managed_zone = new_value.to_string();
6982 self
6983 }
6984 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
6985 ///
6986 /// Sets the *client operation id* query property to the given value.
6987 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6988 self._client_operation_id = Some(new_value.to_string());
6989 self
6990 }
6991 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6992 /// while executing the actual API request.
6993 ///
6994 /// ````text
6995 /// It should be used to handle progress information, and to implement a certain level of resilience.
6996 /// ````
6997 ///
6998 /// Sets the *delegate* property to the given value.
6999 pub fn delegate(
7000 mut self,
7001 new_value: &'a mut dyn common::Delegate,
7002 ) -> ManagedZoneGetCall<'a, C> {
7003 self._delegate = Some(new_value);
7004 self
7005 }
7006
7007 /// Set any additional parameter of the query string used in the request.
7008 /// It should be used to set parameters which are not yet available through their own
7009 /// setters.
7010 ///
7011 /// Please note that this method must not be used to set any of the known parameters
7012 /// which have their own setter method. If done anyway, the request will fail.
7013 ///
7014 /// # Additional Parameters
7015 ///
7016 /// * *$.xgafv* (query-string) - V1 error format.
7017 /// * *access_token* (query-string) - OAuth access token.
7018 /// * *alt* (query-string) - Data format for response.
7019 /// * *callback* (query-string) - JSONP
7020 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7021 /// * *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.
7022 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7023 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7024 /// * *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.
7025 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7026 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7027 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneGetCall<'a, C>
7028 where
7029 T: AsRef<str>,
7030 {
7031 self._additional_params
7032 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7033 self
7034 }
7035
7036 /// Identifies the authorization scope for the method you are building.
7037 ///
7038 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7039 /// [`Scope::NdevClouddnReadonly`].
7040 ///
7041 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7042 /// tokens for more than one scope.
7043 ///
7044 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7045 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7046 /// sufficient, a read-write scope will do as well.
7047 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneGetCall<'a, C>
7048 where
7049 St: AsRef<str>,
7050 {
7051 self._scopes.insert(String::from(scope.as_ref()));
7052 self
7053 }
7054 /// Identifies the authorization scope(s) for the method you are building.
7055 ///
7056 /// See [`Self::add_scope()`] for details.
7057 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneGetCall<'a, C>
7058 where
7059 I: IntoIterator<Item = St>,
7060 St: AsRef<str>,
7061 {
7062 self._scopes
7063 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7064 self
7065 }
7066
7067 /// Removes all scopes, and no default scope will be used either.
7068 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7069 /// for details).
7070 pub fn clear_scopes(mut self) -> ManagedZoneGetCall<'a, C> {
7071 self._scopes.clear();
7072 self
7073 }
7074}
7075
7076/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7077///
7078/// A builder for the *getIamPolicy* method supported by a *managedZone* resource.
7079/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
7080///
7081/// # Example
7082///
7083/// Instantiate a resource method builder
7084///
7085/// ```test_harness,no_run
7086/// # extern crate hyper;
7087/// # extern crate hyper_rustls;
7088/// # extern crate google_dns2 as dns2;
7089/// use dns2::api::GoogleIamV1GetIamPolicyRequest;
7090/// # async fn dox() {
7091/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7092///
7093/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7094/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7095/// # .with_native_roots()
7096/// # .unwrap()
7097/// # .https_only()
7098/// # .enable_http2()
7099/// # .build();
7100///
7101/// # let executor = hyper_util::rt::TokioExecutor::new();
7102/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7103/// # secret,
7104/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7105/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7106/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7107/// # ),
7108/// # ).build().await.unwrap();
7109///
7110/// # let client = hyper_util::client::legacy::Client::builder(
7111/// # hyper_util::rt::TokioExecutor::new()
7112/// # )
7113/// # .build(
7114/// # hyper_rustls::HttpsConnectorBuilder::new()
7115/// # .with_native_roots()
7116/// # .unwrap()
7117/// # .https_or_http()
7118/// # .enable_http2()
7119/// # .build()
7120/// # );
7121/// # let mut hub = Dns::new(client, auth);
7122/// // As the method needs a request, you would usually fill it with the desired information
7123/// // into the respective structure. Some of the parts shown here might not be applicable !
7124/// // Values shown here are possibly random and not representative !
7125/// let mut req = GoogleIamV1GetIamPolicyRequest::default();
7126///
7127/// // You can configure optional parameters by calling the respective setters at will, and
7128/// // execute the final call using `doit()`.
7129/// // Values shown here are possibly random and not representative !
7130/// let result = hub.managed_zones().get_iam_policy(req, "resource")
7131/// .doit().await;
7132/// # }
7133/// ```
7134pub struct ManagedZoneGetIamPolicyCall<'a, C>
7135where
7136 C: 'a,
7137{
7138 hub: &'a Dns<C>,
7139 _request: GoogleIamV1GetIamPolicyRequest,
7140 _resource: String,
7141 _delegate: Option<&'a mut dyn common::Delegate>,
7142 _additional_params: HashMap<String, String>,
7143 _scopes: BTreeSet<String>,
7144}
7145
7146impl<'a, C> common::CallBuilder for ManagedZoneGetIamPolicyCall<'a, C> {}
7147
7148impl<'a, C> ManagedZoneGetIamPolicyCall<'a, C>
7149where
7150 C: common::Connector,
7151{
7152 /// Perform the operation you have build so far.
7153 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
7154 use std::borrow::Cow;
7155 use std::io::{Read, Seek};
7156
7157 use common::{url::Params, ToParts};
7158 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7159
7160 let mut dd = common::DefaultDelegate;
7161 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7162 dlg.begin(common::MethodInfo {
7163 id: "dns.managedZones.getIamPolicy",
7164 http_method: hyper::Method::POST,
7165 });
7166
7167 for &field in ["alt", "resource"].iter() {
7168 if self._additional_params.contains_key(field) {
7169 dlg.finished(false);
7170 return Err(common::Error::FieldClash(field));
7171 }
7172 }
7173
7174 let mut params = Params::with_capacity(4 + self._additional_params.len());
7175 params.push("resource", self._resource);
7176
7177 params.extend(self._additional_params.iter());
7178
7179 params.push("alt", "json");
7180 let mut url = self.hub._base_url.clone() + "dns/v2/{+resource}:getIamPolicy";
7181 if self._scopes.is_empty() {
7182 self._scopes
7183 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
7184 }
7185
7186 #[allow(clippy::single_element_loop)]
7187 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7188 url = params.uri_replacement(url, param_name, find_this, true);
7189 }
7190 {
7191 let to_remove = ["resource"];
7192 params.remove_params(&to_remove);
7193 }
7194
7195 let url = params.parse_with_url(&url);
7196
7197 let mut json_mime_type = mime::APPLICATION_JSON;
7198 let mut request_value_reader = {
7199 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7200 common::remove_json_null_values(&mut value);
7201 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7202 serde_json::to_writer(&mut dst, &value).unwrap();
7203 dst
7204 };
7205 let request_size = request_value_reader
7206 .seek(std::io::SeekFrom::End(0))
7207 .unwrap();
7208 request_value_reader
7209 .seek(std::io::SeekFrom::Start(0))
7210 .unwrap();
7211
7212 loop {
7213 let token = match self
7214 .hub
7215 .auth
7216 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7217 .await
7218 {
7219 Ok(token) => token,
7220 Err(e) => match dlg.token(e) {
7221 Ok(token) => token,
7222 Err(e) => {
7223 dlg.finished(false);
7224 return Err(common::Error::MissingToken(e));
7225 }
7226 },
7227 };
7228 request_value_reader
7229 .seek(std::io::SeekFrom::Start(0))
7230 .unwrap();
7231 let mut req_result = {
7232 let client = &self.hub.client;
7233 dlg.pre_request();
7234 let mut req_builder = hyper::Request::builder()
7235 .method(hyper::Method::POST)
7236 .uri(url.as_str())
7237 .header(USER_AGENT, self.hub._user_agent.clone());
7238
7239 if let Some(token) = token.as_ref() {
7240 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7241 }
7242
7243 let request = req_builder
7244 .header(CONTENT_TYPE, json_mime_type.to_string())
7245 .header(CONTENT_LENGTH, request_size as u64)
7246 .body(common::to_body(
7247 request_value_reader.get_ref().clone().into(),
7248 ));
7249
7250 client.request(request.unwrap()).await
7251 };
7252
7253 match req_result {
7254 Err(err) => {
7255 if let common::Retry::After(d) = dlg.http_error(&err) {
7256 sleep(d).await;
7257 continue;
7258 }
7259 dlg.finished(false);
7260 return Err(common::Error::HttpError(err));
7261 }
7262 Ok(res) => {
7263 let (mut parts, body) = res.into_parts();
7264 let mut body = common::Body::new(body);
7265 if !parts.status.is_success() {
7266 let bytes = common::to_bytes(body).await.unwrap_or_default();
7267 let error = serde_json::from_str(&common::to_string(&bytes));
7268 let response = common::to_response(parts, bytes.into());
7269
7270 if let common::Retry::After(d) =
7271 dlg.http_failure(&response, error.as_ref().ok())
7272 {
7273 sleep(d).await;
7274 continue;
7275 }
7276
7277 dlg.finished(false);
7278
7279 return Err(match error {
7280 Ok(value) => common::Error::BadRequest(value),
7281 _ => common::Error::Failure(response),
7282 });
7283 }
7284 let response = {
7285 let bytes = common::to_bytes(body).await.unwrap_or_default();
7286 let encoded = common::to_string(&bytes);
7287 match serde_json::from_str(&encoded) {
7288 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7289 Err(error) => {
7290 dlg.response_json_decode_error(&encoded, &error);
7291 return Err(common::Error::JsonDecodeError(
7292 encoded.to_string(),
7293 error,
7294 ));
7295 }
7296 }
7297 };
7298
7299 dlg.finished(true);
7300 return Ok(response);
7301 }
7302 }
7303 }
7304 }
7305
7306 ///
7307 /// Sets the *request* property to the given value.
7308 ///
7309 /// Even though the property as already been set when instantiating this call,
7310 /// we provide this method for API completeness.
7311 pub fn request(
7312 mut self,
7313 new_value: GoogleIamV1GetIamPolicyRequest,
7314 ) -> ManagedZoneGetIamPolicyCall<'a, C> {
7315 self._request = new_value;
7316 self
7317 }
7318 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
7319 ///
7320 /// Sets the *resource* path property to the given value.
7321 ///
7322 /// Even though the property as already been set when instantiating this call,
7323 /// we provide this method for API completeness.
7324 pub fn resource(mut self, new_value: &str) -> ManagedZoneGetIamPolicyCall<'a, C> {
7325 self._resource = new_value.to_string();
7326 self
7327 }
7328 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7329 /// while executing the actual API request.
7330 ///
7331 /// ````text
7332 /// It should be used to handle progress information, and to implement a certain level of resilience.
7333 /// ````
7334 ///
7335 /// Sets the *delegate* property to the given value.
7336 pub fn delegate(
7337 mut self,
7338 new_value: &'a mut dyn common::Delegate,
7339 ) -> ManagedZoneGetIamPolicyCall<'a, C> {
7340 self._delegate = Some(new_value);
7341 self
7342 }
7343
7344 /// Set any additional parameter of the query string used in the request.
7345 /// It should be used to set parameters which are not yet available through their own
7346 /// setters.
7347 ///
7348 /// Please note that this method must not be used to set any of the known parameters
7349 /// which have their own setter method. If done anyway, the request will fail.
7350 ///
7351 /// # Additional Parameters
7352 ///
7353 /// * *$.xgafv* (query-string) - V1 error format.
7354 /// * *access_token* (query-string) - OAuth access token.
7355 /// * *alt* (query-string) - Data format for response.
7356 /// * *callback* (query-string) - JSONP
7357 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7358 /// * *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.
7359 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7360 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7361 /// * *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.
7362 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7363 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7364 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneGetIamPolicyCall<'a, C>
7365 where
7366 T: AsRef<str>,
7367 {
7368 self._additional_params
7369 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7370 self
7371 }
7372
7373 /// Identifies the authorization scope for the method you are building.
7374 ///
7375 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7376 /// [`Scope::NdevClouddnReadonly`].
7377 ///
7378 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7379 /// tokens for more than one scope.
7380 ///
7381 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7382 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7383 /// sufficient, a read-write scope will do as well.
7384 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneGetIamPolicyCall<'a, C>
7385 where
7386 St: AsRef<str>,
7387 {
7388 self._scopes.insert(String::from(scope.as_ref()));
7389 self
7390 }
7391 /// Identifies the authorization scope(s) for the method you are building.
7392 ///
7393 /// See [`Self::add_scope()`] for details.
7394 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneGetIamPolicyCall<'a, C>
7395 where
7396 I: IntoIterator<Item = St>,
7397 St: AsRef<str>,
7398 {
7399 self._scopes
7400 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7401 self
7402 }
7403
7404 /// Removes all scopes, and no default scope will be used either.
7405 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7406 /// for details).
7407 pub fn clear_scopes(mut self) -> ManagedZoneGetIamPolicyCall<'a, C> {
7408 self._scopes.clear();
7409 self
7410 }
7411}
7412
7413/// Enumerates ManagedZones that have been created but not yet deleted.
7414///
7415/// A builder for the *list* method supported by a *managedZone* resource.
7416/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
7417///
7418/// # Example
7419///
7420/// Instantiate a resource method builder
7421///
7422/// ```test_harness,no_run
7423/// # extern crate hyper;
7424/// # extern crate hyper_rustls;
7425/// # extern crate google_dns2 as dns2;
7426/// # async fn dox() {
7427/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7428///
7429/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7430/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7431/// # .with_native_roots()
7432/// # .unwrap()
7433/// # .https_only()
7434/// # .enable_http2()
7435/// # .build();
7436///
7437/// # let executor = hyper_util::rt::TokioExecutor::new();
7438/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7439/// # secret,
7440/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7441/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7442/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7443/// # ),
7444/// # ).build().await.unwrap();
7445///
7446/// # let client = hyper_util::client::legacy::Client::builder(
7447/// # hyper_util::rt::TokioExecutor::new()
7448/// # )
7449/// # .build(
7450/// # hyper_rustls::HttpsConnectorBuilder::new()
7451/// # .with_native_roots()
7452/// # .unwrap()
7453/// # .https_or_http()
7454/// # .enable_http2()
7455/// # .build()
7456/// # );
7457/// # let mut hub = Dns::new(client, auth);
7458/// // You can configure optional parameters by calling the respective setters at will, and
7459/// // execute the final call using `doit()`.
7460/// // Values shown here are possibly random and not representative !
7461/// let result = hub.managed_zones().list("project", "location")
7462/// .page_token("Stet")
7463/// .max_results(-76)
7464/// .dns_name("elitr")
7465/// .doit().await;
7466/// # }
7467/// ```
7468pub struct ManagedZoneListCall<'a, C>
7469where
7470 C: 'a,
7471{
7472 hub: &'a Dns<C>,
7473 _project: String,
7474 _location: String,
7475 _page_token: Option<String>,
7476 _max_results: Option<i32>,
7477 _dns_name: Option<String>,
7478 _delegate: Option<&'a mut dyn common::Delegate>,
7479 _additional_params: HashMap<String, String>,
7480 _scopes: BTreeSet<String>,
7481}
7482
7483impl<'a, C> common::CallBuilder for ManagedZoneListCall<'a, C> {}
7484
7485impl<'a, C> ManagedZoneListCall<'a, C>
7486where
7487 C: common::Connector,
7488{
7489 /// Perform the operation you have build so far.
7490 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedZonesListResponse)> {
7491 use std::borrow::Cow;
7492 use std::io::{Read, Seek};
7493
7494 use common::{url::Params, ToParts};
7495 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7496
7497 let mut dd = common::DefaultDelegate;
7498 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7499 dlg.begin(common::MethodInfo {
7500 id: "dns.managedZones.list",
7501 http_method: hyper::Method::GET,
7502 });
7503
7504 for &field in [
7505 "alt",
7506 "project",
7507 "location",
7508 "pageToken",
7509 "maxResults",
7510 "dnsName",
7511 ]
7512 .iter()
7513 {
7514 if self._additional_params.contains_key(field) {
7515 dlg.finished(false);
7516 return Err(common::Error::FieldClash(field));
7517 }
7518 }
7519
7520 let mut params = Params::with_capacity(7 + self._additional_params.len());
7521 params.push("project", self._project);
7522 params.push("location", self._location);
7523 if let Some(value) = self._page_token.as_ref() {
7524 params.push("pageToken", value);
7525 }
7526 if let Some(value) = self._max_results.as_ref() {
7527 params.push("maxResults", value.to_string());
7528 }
7529 if let Some(value) = self._dns_name.as_ref() {
7530 params.push("dnsName", value);
7531 }
7532
7533 params.extend(self._additional_params.iter());
7534
7535 params.push("alt", "json");
7536 let mut url = self.hub._base_url.clone()
7537 + "dns/v2/projects/{project}/locations/{location}/managedZones";
7538 if self._scopes.is_empty() {
7539 self._scopes
7540 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
7541 }
7542
7543 #[allow(clippy::single_element_loop)]
7544 for &(find_this, param_name) in
7545 [("{project}", "project"), ("{location}", "location")].iter()
7546 {
7547 url = params.uri_replacement(url, param_name, find_this, false);
7548 }
7549 {
7550 let to_remove = ["location", "project"];
7551 params.remove_params(&to_remove);
7552 }
7553
7554 let url = params.parse_with_url(&url);
7555
7556 loop {
7557 let token = match self
7558 .hub
7559 .auth
7560 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7561 .await
7562 {
7563 Ok(token) => token,
7564 Err(e) => match dlg.token(e) {
7565 Ok(token) => token,
7566 Err(e) => {
7567 dlg.finished(false);
7568 return Err(common::Error::MissingToken(e));
7569 }
7570 },
7571 };
7572 let mut req_result = {
7573 let client = &self.hub.client;
7574 dlg.pre_request();
7575 let mut req_builder = hyper::Request::builder()
7576 .method(hyper::Method::GET)
7577 .uri(url.as_str())
7578 .header(USER_AGENT, self.hub._user_agent.clone());
7579
7580 if let Some(token) = token.as_ref() {
7581 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7582 }
7583
7584 let request = req_builder
7585 .header(CONTENT_LENGTH, 0_u64)
7586 .body(common::to_body::<String>(None));
7587
7588 client.request(request.unwrap()).await
7589 };
7590
7591 match req_result {
7592 Err(err) => {
7593 if let common::Retry::After(d) = dlg.http_error(&err) {
7594 sleep(d).await;
7595 continue;
7596 }
7597 dlg.finished(false);
7598 return Err(common::Error::HttpError(err));
7599 }
7600 Ok(res) => {
7601 let (mut parts, body) = res.into_parts();
7602 let mut body = common::Body::new(body);
7603 if !parts.status.is_success() {
7604 let bytes = common::to_bytes(body).await.unwrap_or_default();
7605 let error = serde_json::from_str(&common::to_string(&bytes));
7606 let response = common::to_response(parts, bytes.into());
7607
7608 if let common::Retry::After(d) =
7609 dlg.http_failure(&response, error.as_ref().ok())
7610 {
7611 sleep(d).await;
7612 continue;
7613 }
7614
7615 dlg.finished(false);
7616
7617 return Err(match error {
7618 Ok(value) => common::Error::BadRequest(value),
7619 _ => common::Error::Failure(response),
7620 });
7621 }
7622 let response = {
7623 let bytes = common::to_bytes(body).await.unwrap_or_default();
7624 let encoded = common::to_string(&bytes);
7625 match serde_json::from_str(&encoded) {
7626 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7627 Err(error) => {
7628 dlg.response_json_decode_error(&encoded, &error);
7629 return Err(common::Error::JsonDecodeError(
7630 encoded.to_string(),
7631 error,
7632 ));
7633 }
7634 }
7635 };
7636
7637 dlg.finished(true);
7638 return Ok(response);
7639 }
7640 }
7641 }
7642 }
7643
7644 /// Identifies the project addressed by this request.
7645 ///
7646 /// Sets the *project* path property to the given value.
7647 ///
7648 /// Even though the property as already been set when instantiating this call,
7649 /// we provide this method for API completeness.
7650 pub fn project(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7651 self._project = new_value.to_string();
7652 self
7653 }
7654 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
7655 ///
7656 /// Sets the *location* path property to the given value.
7657 ///
7658 /// Even though the property as already been set when instantiating this call,
7659 /// we provide this method for API completeness.
7660 pub fn location(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7661 self._location = new_value.to_string();
7662 self
7663 }
7664 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
7665 ///
7666 /// Sets the *page token* query property to the given value.
7667 pub fn page_token(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7668 self._page_token = Some(new_value.to_string());
7669 self
7670 }
7671 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
7672 ///
7673 /// Sets the *max results* query property to the given value.
7674 pub fn max_results(mut self, new_value: i32) -> ManagedZoneListCall<'a, C> {
7675 self._max_results = Some(new_value);
7676 self
7677 }
7678 /// Restricts the list to return only zones with this domain name.
7679 ///
7680 /// Sets the *dns name* query property to the given value.
7681 pub fn dns_name(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7682 self._dns_name = Some(new_value.to_string());
7683 self
7684 }
7685 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7686 /// while executing the actual API request.
7687 ///
7688 /// ````text
7689 /// It should be used to handle progress information, and to implement a certain level of resilience.
7690 /// ````
7691 ///
7692 /// Sets the *delegate* property to the given value.
7693 pub fn delegate(
7694 mut self,
7695 new_value: &'a mut dyn common::Delegate,
7696 ) -> ManagedZoneListCall<'a, C> {
7697 self._delegate = Some(new_value);
7698 self
7699 }
7700
7701 /// Set any additional parameter of the query string used in the request.
7702 /// It should be used to set parameters which are not yet available through their own
7703 /// setters.
7704 ///
7705 /// Please note that this method must not be used to set any of the known parameters
7706 /// which have their own setter method. If done anyway, the request will fail.
7707 ///
7708 /// # Additional Parameters
7709 ///
7710 /// * *$.xgafv* (query-string) - V1 error format.
7711 /// * *access_token* (query-string) - OAuth access token.
7712 /// * *alt* (query-string) - Data format for response.
7713 /// * *callback* (query-string) - JSONP
7714 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7715 /// * *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.
7716 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7717 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7718 /// * *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.
7719 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7720 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7721 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneListCall<'a, C>
7722 where
7723 T: AsRef<str>,
7724 {
7725 self._additional_params
7726 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7727 self
7728 }
7729
7730 /// Identifies the authorization scope for the method you are building.
7731 ///
7732 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7733 /// [`Scope::NdevClouddnReadonly`].
7734 ///
7735 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7736 /// tokens for more than one scope.
7737 ///
7738 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7739 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7740 /// sufficient, a read-write scope will do as well.
7741 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneListCall<'a, C>
7742 where
7743 St: AsRef<str>,
7744 {
7745 self._scopes.insert(String::from(scope.as_ref()));
7746 self
7747 }
7748 /// Identifies the authorization scope(s) for the method you are building.
7749 ///
7750 /// See [`Self::add_scope()`] for details.
7751 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneListCall<'a, C>
7752 where
7753 I: IntoIterator<Item = St>,
7754 St: AsRef<str>,
7755 {
7756 self._scopes
7757 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7758 self
7759 }
7760
7761 /// Removes all scopes, and no default scope will be used either.
7762 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7763 /// for details).
7764 pub fn clear_scopes(mut self) -> ManagedZoneListCall<'a, C> {
7765 self._scopes.clear();
7766 self
7767 }
7768}
7769
7770/// Applies a partial update to an existing ManagedZone.
7771///
7772/// A builder for the *patch* method supported by a *managedZone* resource.
7773/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
7774///
7775/// # Example
7776///
7777/// Instantiate a resource method builder
7778///
7779/// ```test_harness,no_run
7780/// # extern crate hyper;
7781/// # extern crate hyper_rustls;
7782/// # extern crate google_dns2 as dns2;
7783/// use dns2::api::ManagedZone;
7784/// # async fn dox() {
7785/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7786///
7787/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7788/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7789/// # .with_native_roots()
7790/// # .unwrap()
7791/// # .https_only()
7792/// # .enable_http2()
7793/// # .build();
7794///
7795/// # let executor = hyper_util::rt::TokioExecutor::new();
7796/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7797/// # secret,
7798/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7799/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7800/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7801/// # ),
7802/// # ).build().await.unwrap();
7803///
7804/// # let client = hyper_util::client::legacy::Client::builder(
7805/// # hyper_util::rt::TokioExecutor::new()
7806/// # )
7807/// # .build(
7808/// # hyper_rustls::HttpsConnectorBuilder::new()
7809/// # .with_native_roots()
7810/// # .unwrap()
7811/// # .https_or_http()
7812/// # .enable_http2()
7813/// # .build()
7814/// # );
7815/// # let mut hub = Dns::new(client, auth);
7816/// // As the method needs a request, you would usually fill it with the desired information
7817/// // into the respective structure. Some of the parts shown here might not be applicable !
7818/// // Values shown here are possibly random and not representative !
7819/// let mut req = ManagedZone::default();
7820///
7821/// // You can configure optional parameters by calling the respective setters at will, and
7822/// // execute the final call using `doit()`.
7823/// // Values shown here are possibly random and not representative !
7824/// let result = hub.managed_zones().patch(req, "project", "location", "managedZone")
7825/// .client_operation_id("ipsum")
7826/// .doit().await;
7827/// # }
7828/// ```
7829pub struct ManagedZonePatchCall<'a, C>
7830where
7831 C: 'a,
7832{
7833 hub: &'a Dns<C>,
7834 _request: ManagedZone,
7835 _project: String,
7836 _location: String,
7837 _managed_zone: String,
7838 _client_operation_id: Option<String>,
7839 _delegate: Option<&'a mut dyn common::Delegate>,
7840 _additional_params: HashMap<String, String>,
7841 _scopes: BTreeSet<String>,
7842}
7843
7844impl<'a, C> common::CallBuilder for ManagedZonePatchCall<'a, C> {}
7845
7846impl<'a, C> ManagedZonePatchCall<'a, C>
7847where
7848 C: common::Connector,
7849{
7850 /// Perform the operation you have build so far.
7851 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7852 use std::borrow::Cow;
7853 use std::io::{Read, Seek};
7854
7855 use common::{url::Params, ToParts};
7856 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7857
7858 let mut dd = common::DefaultDelegate;
7859 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7860 dlg.begin(common::MethodInfo {
7861 id: "dns.managedZones.patch",
7862 http_method: hyper::Method::PATCH,
7863 });
7864
7865 for &field in [
7866 "alt",
7867 "project",
7868 "location",
7869 "managedZone",
7870 "clientOperationId",
7871 ]
7872 .iter()
7873 {
7874 if self._additional_params.contains_key(field) {
7875 dlg.finished(false);
7876 return Err(common::Error::FieldClash(field));
7877 }
7878 }
7879
7880 let mut params = Params::with_capacity(7 + self._additional_params.len());
7881 params.push("project", self._project);
7882 params.push("location", self._location);
7883 params.push("managedZone", self._managed_zone);
7884 if let Some(value) = self._client_operation_id.as_ref() {
7885 params.push("clientOperationId", value);
7886 }
7887
7888 params.extend(self._additional_params.iter());
7889
7890 params.push("alt", "json");
7891 let mut url = self.hub._base_url.clone()
7892 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}";
7893 if self._scopes.is_empty() {
7894 self._scopes
7895 .insert(Scope::CloudPlatform.as_ref().to_string());
7896 }
7897
7898 #[allow(clippy::single_element_loop)]
7899 for &(find_this, param_name) in [
7900 ("{project}", "project"),
7901 ("{location}", "location"),
7902 ("{managedZone}", "managedZone"),
7903 ]
7904 .iter()
7905 {
7906 url = params.uri_replacement(url, param_name, find_this, false);
7907 }
7908 {
7909 let to_remove = ["managedZone", "location", "project"];
7910 params.remove_params(&to_remove);
7911 }
7912
7913 let url = params.parse_with_url(&url);
7914
7915 let mut json_mime_type = mime::APPLICATION_JSON;
7916 let mut request_value_reader = {
7917 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7918 common::remove_json_null_values(&mut value);
7919 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7920 serde_json::to_writer(&mut dst, &value).unwrap();
7921 dst
7922 };
7923 let request_size = request_value_reader
7924 .seek(std::io::SeekFrom::End(0))
7925 .unwrap();
7926 request_value_reader
7927 .seek(std::io::SeekFrom::Start(0))
7928 .unwrap();
7929
7930 loop {
7931 let token = match self
7932 .hub
7933 .auth
7934 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7935 .await
7936 {
7937 Ok(token) => token,
7938 Err(e) => match dlg.token(e) {
7939 Ok(token) => token,
7940 Err(e) => {
7941 dlg.finished(false);
7942 return Err(common::Error::MissingToken(e));
7943 }
7944 },
7945 };
7946 request_value_reader
7947 .seek(std::io::SeekFrom::Start(0))
7948 .unwrap();
7949 let mut req_result = {
7950 let client = &self.hub.client;
7951 dlg.pre_request();
7952 let mut req_builder = hyper::Request::builder()
7953 .method(hyper::Method::PATCH)
7954 .uri(url.as_str())
7955 .header(USER_AGENT, self.hub._user_agent.clone());
7956
7957 if let Some(token) = token.as_ref() {
7958 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7959 }
7960
7961 let request = req_builder
7962 .header(CONTENT_TYPE, json_mime_type.to_string())
7963 .header(CONTENT_LENGTH, request_size as u64)
7964 .body(common::to_body(
7965 request_value_reader.get_ref().clone().into(),
7966 ));
7967
7968 client.request(request.unwrap()).await
7969 };
7970
7971 match req_result {
7972 Err(err) => {
7973 if let common::Retry::After(d) = dlg.http_error(&err) {
7974 sleep(d).await;
7975 continue;
7976 }
7977 dlg.finished(false);
7978 return Err(common::Error::HttpError(err));
7979 }
7980 Ok(res) => {
7981 let (mut parts, body) = res.into_parts();
7982 let mut body = common::Body::new(body);
7983 if !parts.status.is_success() {
7984 let bytes = common::to_bytes(body).await.unwrap_or_default();
7985 let error = serde_json::from_str(&common::to_string(&bytes));
7986 let response = common::to_response(parts, bytes.into());
7987
7988 if let common::Retry::After(d) =
7989 dlg.http_failure(&response, error.as_ref().ok())
7990 {
7991 sleep(d).await;
7992 continue;
7993 }
7994
7995 dlg.finished(false);
7996
7997 return Err(match error {
7998 Ok(value) => common::Error::BadRequest(value),
7999 _ => common::Error::Failure(response),
8000 });
8001 }
8002 let response = {
8003 let bytes = common::to_bytes(body).await.unwrap_or_default();
8004 let encoded = common::to_string(&bytes);
8005 match serde_json::from_str(&encoded) {
8006 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8007 Err(error) => {
8008 dlg.response_json_decode_error(&encoded, &error);
8009 return Err(common::Error::JsonDecodeError(
8010 encoded.to_string(),
8011 error,
8012 ));
8013 }
8014 }
8015 };
8016
8017 dlg.finished(true);
8018 return Ok(response);
8019 }
8020 }
8021 }
8022 }
8023
8024 ///
8025 /// Sets the *request* property to the given value.
8026 ///
8027 /// Even though the property as already been set when instantiating this call,
8028 /// we provide this method for API completeness.
8029 pub fn request(mut self, new_value: ManagedZone) -> ManagedZonePatchCall<'a, C> {
8030 self._request = new_value;
8031 self
8032 }
8033 /// Identifies the project addressed by this request.
8034 ///
8035 /// Sets the *project* path property to the given value.
8036 ///
8037 /// Even though the property as already been set when instantiating this call,
8038 /// we provide this method for API completeness.
8039 pub fn project(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
8040 self._project = new_value.to_string();
8041 self
8042 }
8043 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
8044 ///
8045 /// Sets the *location* path property to the given value.
8046 ///
8047 /// Even though the property as already been set when instantiating this call,
8048 /// we provide this method for API completeness.
8049 pub fn location(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
8050 self._location = new_value.to_string();
8051 self
8052 }
8053 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
8054 ///
8055 /// Sets the *managed zone* path property to the given value.
8056 ///
8057 /// Even though the property as already been set when instantiating this call,
8058 /// we provide this method for API completeness.
8059 pub fn managed_zone(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
8060 self._managed_zone = new_value.to_string();
8061 self
8062 }
8063 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
8064 ///
8065 /// Sets the *client operation id* query property to the given value.
8066 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
8067 self._client_operation_id = Some(new_value.to_string());
8068 self
8069 }
8070 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8071 /// while executing the actual API request.
8072 ///
8073 /// ````text
8074 /// It should be used to handle progress information, and to implement a certain level of resilience.
8075 /// ````
8076 ///
8077 /// Sets the *delegate* property to the given value.
8078 pub fn delegate(
8079 mut self,
8080 new_value: &'a mut dyn common::Delegate,
8081 ) -> ManagedZonePatchCall<'a, C> {
8082 self._delegate = Some(new_value);
8083 self
8084 }
8085
8086 /// Set any additional parameter of the query string used in the request.
8087 /// It should be used to set parameters which are not yet available through their own
8088 /// setters.
8089 ///
8090 /// Please note that this method must not be used to set any of the known parameters
8091 /// which have their own setter method. If done anyway, the request will fail.
8092 ///
8093 /// # Additional Parameters
8094 ///
8095 /// * *$.xgafv* (query-string) - V1 error format.
8096 /// * *access_token* (query-string) - OAuth access token.
8097 /// * *alt* (query-string) - Data format for response.
8098 /// * *callback* (query-string) - JSONP
8099 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8100 /// * *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.
8101 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8102 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8103 /// * *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.
8104 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8105 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8106 pub fn param<T>(mut self, name: T, value: T) -> ManagedZonePatchCall<'a, C>
8107 where
8108 T: AsRef<str>,
8109 {
8110 self._additional_params
8111 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8112 self
8113 }
8114
8115 /// Identifies the authorization scope for the method you are building.
8116 ///
8117 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8118 /// [`Scope::CloudPlatform`].
8119 ///
8120 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8121 /// tokens for more than one scope.
8122 ///
8123 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8124 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8125 /// sufficient, a read-write scope will do as well.
8126 pub fn add_scope<St>(mut self, scope: St) -> ManagedZonePatchCall<'a, C>
8127 where
8128 St: AsRef<str>,
8129 {
8130 self._scopes.insert(String::from(scope.as_ref()));
8131 self
8132 }
8133 /// Identifies the authorization scope(s) for the method you are building.
8134 ///
8135 /// See [`Self::add_scope()`] for details.
8136 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZonePatchCall<'a, C>
8137 where
8138 I: IntoIterator<Item = St>,
8139 St: AsRef<str>,
8140 {
8141 self._scopes
8142 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8143 self
8144 }
8145
8146 /// Removes all scopes, and no default scope will be used either.
8147 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8148 /// for details).
8149 pub fn clear_scopes(mut self) -> ManagedZonePatchCall<'a, C> {
8150 self._scopes.clear();
8151 self
8152 }
8153}
8154
8155/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
8156///
8157/// A builder for the *setIamPolicy* method supported by a *managedZone* resource.
8158/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
8159///
8160/// # Example
8161///
8162/// Instantiate a resource method builder
8163///
8164/// ```test_harness,no_run
8165/// # extern crate hyper;
8166/// # extern crate hyper_rustls;
8167/// # extern crate google_dns2 as dns2;
8168/// use dns2::api::GoogleIamV1SetIamPolicyRequest;
8169/// # async fn dox() {
8170/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8171///
8172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8173/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8174/// # .with_native_roots()
8175/// # .unwrap()
8176/// # .https_only()
8177/// # .enable_http2()
8178/// # .build();
8179///
8180/// # let executor = hyper_util::rt::TokioExecutor::new();
8181/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8182/// # secret,
8183/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8184/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8185/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8186/// # ),
8187/// # ).build().await.unwrap();
8188///
8189/// # let client = hyper_util::client::legacy::Client::builder(
8190/// # hyper_util::rt::TokioExecutor::new()
8191/// # )
8192/// # .build(
8193/// # hyper_rustls::HttpsConnectorBuilder::new()
8194/// # .with_native_roots()
8195/// # .unwrap()
8196/// # .https_or_http()
8197/// # .enable_http2()
8198/// # .build()
8199/// # );
8200/// # let mut hub = Dns::new(client, auth);
8201/// // As the method needs a request, you would usually fill it with the desired information
8202/// // into the respective structure. Some of the parts shown here might not be applicable !
8203/// // Values shown here are possibly random and not representative !
8204/// let mut req = GoogleIamV1SetIamPolicyRequest::default();
8205///
8206/// // You can configure optional parameters by calling the respective setters at will, and
8207/// // execute the final call using `doit()`.
8208/// // Values shown here are possibly random and not representative !
8209/// let result = hub.managed_zones().set_iam_policy(req, "resource")
8210/// .doit().await;
8211/// # }
8212/// ```
8213pub struct ManagedZoneSetIamPolicyCall<'a, C>
8214where
8215 C: 'a,
8216{
8217 hub: &'a Dns<C>,
8218 _request: GoogleIamV1SetIamPolicyRequest,
8219 _resource: String,
8220 _delegate: Option<&'a mut dyn common::Delegate>,
8221 _additional_params: HashMap<String, String>,
8222 _scopes: BTreeSet<String>,
8223}
8224
8225impl<'a, C> common::CallBuilder for ManagedZoneSetIamPolicyCall<'a, C> {}
8226
8227impl<'a, C> ManagedZoneSetIamPolicyCall<'a, C>
8228where
8229 C: common::Connector,
8230{
8231 /// Perform the operation you have build so far.
8232 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
8233 use std::borrow::Cow;
8234 use std::io::{Read, Seek};
8235
8236 use common::{url::Params, ToParts};
8237 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8238
8239 let mut dd = common::DefaultDelegate;
8240 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8241 dlg.begin(common::MethodInfo {
8242 id: "dns.managedZones.setIamPolicy",
8243 http_method: hyper::Method::POST,
8244 });
8245
8246 for &field in ["alt", "resource"].iter() {
8247 if self._additional_params.contains_key(field) {
8248 dlg.finished(false);
8249 return Err(common::Error::FieldClash(field));
8250 }
8251 }
8252
8253 let mut params = Params::with_capacity(4 + self._additional_params.len());
8254 params.push("resource", self._resource);
8255
8256 params.extend(self._additional_params.iter());
8257
8258 params.push("alt", "json");
8259 let mut url = self.hub._base_url.clone() + "dns/v2/{+resource}:setIamPolicy";
8260 if self._scopes.is_empty() {
8261 self._scopes
8262 .insert(Scope::CloudPlatform.as_ref().to_string());
8263 }
8264
8265 #[allow(clippy::single_element_loop)]
8266 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8267 url = params.uri_replacement(url, param_name, find_this, true);
8268 }
8269 {
8270 let to_remove = ["resource"];
8271 params.remove_params(&to_remove);
8272 }
8273
8274 let url = params.parse_with_url(&url);
8275
8276 let mut json_mime_type = mime::APPLICATION_JSON;
8277 let mut request_value_reader = {
8278 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8279 common::remove_json_null_values(&mut value);
8280 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8281 serde_json::to_writer(&mut dst, &value).unwrap();
8282 dst
8283 };
8284 let request_size = request_value_reader
8285 .seek(std::io::SeekFrom::End(0))
8286 .unwrap();
8287 request_value_reader
8288 .seek(std::io::SeekFrom::Start(0))
8289 .unwrap();
8290
8291 loop {
8292 let token = match self
8293 .hub
8294 .auth
8295 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8296 .await
8297 {
8298 Ok(token) => token,
8299 Err(e) => match dlg.token(e) {
8300 Ok(token) => token,
8301 Err(e) => {
8302 dlg.finished(false);
8303 return Err(common::Error::MissingToken(e));
8304 }
8305 },
8306 };
8307 request_value_reader
8308 .seek(std::io::SeekFrom::Start(0))
8309 .unwrap();
8310 let mut req_result = {
8311 let client = &self.hub.client;
8312 dlg.pre_request();
8313 let mut req_builder = hyper::Request::builder()
8314 .method(hyper::Method::POST)
8315 .uri(url.as_str())
8316 .header(USER_AGENT, self.hub._user_agent.clone());
8317
8318 if let Some(token) = token.as_ref() {
8319 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8320 }
8321
8322 let request = req_builder
8323 .header(CONTENT_TYPE, json_mime_type.to_string())
8324 .header(CONTENT_LENGTH, request_size as u64)
8325 .body(common::to_body(
8326 request_value_reader.get_ref().clone().into(),
8327 ));
8328
8329 client.request(request.unwrap()).await
8330 };
8331
8332 match req_result {
8333 Err(err) => {
8334 if let common::Retry::After(d) = dlg.http_error(&err) {
8335 sleep(d).await;
8336 continue;
8337 }
8338 dlg.finished(false);
8339 return Err(common::Error::HttpError(err));
8340 }
8341 Ok(res) => {
8342 let (mut parts, body) = res.into_parts();
8343 let mut body = common::Body::new(body);
8344 if !parts.status.is_success() {
8345 let bytes = common::to_bytes(body).await.unwrap_or_default();
8346 let error = serde_json::from_str(&common::to_string(&bytes));
8347 let response = common::to_response(parts, bytes.into());
8348
8349 if let common::Retry::After(d) =
8350 dlg.http_failure(&response, error.as_ref().ok())
8351 {
8352 sleep(d).await;
8353 continue;
8354 }
8355
8356 dlg.finished(false);
8357
8358 return Err(match error {
8359 Ok(value) => common::Error::BadRequest(value),
8360 _ => common::Error::Failure(response),
8361 });
8362 }
8363 let response = {
8364 let bytes = common::to_bytes(body).await.unwrap_or_default();
8365 let encoded = common::to_string(&bytes);
8366 match serde_json::from_str(&encoded) {
8367 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8368 Err(error) => {
8369 dlg.response_json_decode_error(&encoded, &error);
8370 return Err(common::Error::JsonDecodeError(
8371 encoded.to_string(),
8372 error,
8373 ));
8374 }
8375 }
8376 };
8377
8378 dlg.finished(true);
8379 return Ok(response);
8380 }
8381 }
8382 }
8383 }
8384
8385 ///
8386 /// Sets the *request* property to the given value.
8387 ///
8388 /// Even though the property as already been set when instantiating this call,
8389 /// we provide this method for API completeness.
8390 pub fn request(
8391 mut self,
8392 new_value: GoogleIamV1SetIamPolicyRequest,
8393 ) -> ManagedZoneSetIamPolicyCall<'a, C> {
8394 self._request = new_value;
8395 self
8396 }
8397 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8398 ///
8399 /// Sets the *resource* path property to the given value.
8400 ///
8401 /// Even though the property as already been set when instantiating this call,
8402 /// we provide this method for API completeness.
8403 pub fn resource(mut self, new_value: &str) -> ManagedZoneSetIamPolicyCall<'a, C> {
8404 self._resource = new_value.to_string();
8405 self
8406 }
8407 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8408 /// while executing the actual API request.
8409 ///
8410 /// ````text
8411 /// It should be used to handle progress information, and to implement a certain level of resilience.
8412 /// ````
8413 ///
8414 /// Sets the *delegate* property to the given value.
8415 pub fn delegate(
8416 mut self,
8417 new_value: &'a mut dyn common::Delegate,
8418 ) -> ManagedZoneSetIamPolicyCall<'a, C> {
8419 self._delegate = Some(new_value);
8420 self
8421 }
8422
8423 /// Set any additional parameter of the query string used in the request.
8424 /// It should be used to set parameters which are not yet available through their own
8425 /// setters.
8426 ///
8427 /// Please note that this method must not be used to set any of the known parameters
8428 /// which have their own setter method. If done anyway, the request will fail.
8429 ///
8430 /// # Additional Parameters
8431 ///
8432 /// * *$.xgafv* (query-string) - V1 error format.
8433 /// * *access_token* (query-string) - OAuth access token.
8434 /// * *alt* (query-string) - Data format for response.
8435 /// * *callback* (query-string) - JSONP
8436 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8437 /// * *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.
8438 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8439 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8440 /// * *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.
8441 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8442 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8443 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneSetIamPolicyCall<'a, C>
8444 where
8445 T: AsRef<str>,
8446 {
8447 self._additional_params
8448 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8449 self
8450 }
8451
8452 /// Identifies the authorization scope for the method you are building.
8453 ///
8454 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8455 /// [`Scope::CloudPlatform`].
8456 ///
8457 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8458 /// tokens for more than one scope.
8459 ///
8460 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8461 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8462 /// sufficient, a read-write scope will do as well.
8463 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneSetIamPolicyCall<'a, C>
8464 where
8465 St: AsRef<str>,
8466 {
8467 self._scopes.insert(String::from(scope.as_ref()));
8468 self
8469 }
8470 /// Identifies the authorization scope(s) for the method you are building.
8471 ///
8472 /// See [`Self::add_scope()`] for details.
8473 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneSetIamPolicyCall<'a, C>
8474 where
8475 I: IntoIterator<Item = St>,
8476 St: AsRef<str>,
8477 {
8478 self._scopes
8479 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8480 self
8481 }
8482
8483 /// Removes all scopes, and no default scope will be used either.
8484 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8485 /// for details).
8486 pub fn clear_scopes(mut self) -> ManagedZoneSetIamPolicyCall<'a, C> {
8487 self._scopes.clear();
8488 self
8489 }
8490}
8491
8492/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this returns an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
8493///
8494/// A builder for the *testIamPermissions* method supported by a *managedZone* resource.
8495/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
8496///
8497/// # Example
8498///
8499/// Instantiate a resource method builder
8500///
8501/// ```test_harness,no_run
8502/// # extern crate hyper;
8503/// # extern crate hyper_rustls;
8504/// # extern crate google_dns2 as dns2;
8505/// use dns2::api::GoogleIamV1TestIamPermissionsRequest;
8506/// # async fn dox() {
8507/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8508///
8509/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8510/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8511/// # .with_native_roots()
8512/// # .unwrap()
8513/// # .https_only()
8514/// # .enable_http2()
8515/// # .build();
8516///
8517/// # let executor = hyper_util::rt::TokioExecutor::new();
8518/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8519/// # secret,
8520/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8521/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8522/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8523/// # ),
8524/// # ).build().await.unwrap();
8525///
8526/// # let client = hyper_util::client::legacy::Client::builder(
8527/// # hyper_util::rt::TokioExecutor::new()
8528/// # )
8529/// # .build(
8530/// # hyper_rustls::HttpsConnectorBuilder::new()
8531/// # .with_native_roots()
8532/// # .unwrap()
8533/// # .https_or_http()
8534/// # .enable_http2()
8535/// # .build()
8536/// # );
8537/// # let mut hub = Dns::new(client, auth);
8538/// // As the method needs a request, you would usually fill it with the desired information
8539/// // into the respective structure. Some of the parts shown here might not be applicable !
8540/// // Values shown here are possibly random and not representative !
8541/// let mut req = GoogleIamV1TestIamPermissionsRequest::default();
8542///
8543/// // You can configure optional parameters by calling the respective setters at will, and
8544/// // execute the final call using `doit()`.
8545/// // Values shown here are possibly random and not representative !
8546/// let result = hub.managed_zones().test_iam_permissions(req, "resource")
8547/// .doit().await;
8548/// # }
8549/// ```
8550pub struct ManagedZoneTestIamPermissionCall<'a, C>
8551where
8552 C: 'a,
8553{
8554 hub: &'a Dns<C>,
8555 _request: GoogleIamV1TestIamPermissionsRequest,
8556 _resource: String,
8557 _delegate: Option<&'a mut dyn common::Delegate>,
8558 _additional_params: HashMap<String, String>,
8559 _scopes: BTreeSet<String>,
8560}
8561
8562impl<'a, C> common::CallBuilder for ManagedZoneTestIamPermissionCall<'a, C> {}
8563
8564impl<'a, C> ManagedZoneTestIamPermissionCall<'a, C>
8565where
8566 C: common::Connector,
8567{
8568 /// Perform the operation you have build so far.
8569 pub async fn doit(
8570 mut self,
8571 ) -> common::Result<(common::Response, GoogleIamV1TestIamPermissionsResponse)> {
8572 use std::borrow::Cow;
8573 use std::io::{Read, Seek};
8574
8575 use common::{url::Params, ToParts};
8576 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8577
8578 let mut dd = common::DefaultDelegate;
8579 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8580 dlg.begin(common::MethodInfo {
8581 id: "dns.managedZones.testIamPermissions",
8582 http_method: hyper::Method::POST,
8583 });
8584
8585 for &field in ["alt", "resource"].iter() {
8586 if self._additional_params.contains_key(field) {
8587 dlg.finished(false);
8588 return Err(common::Error::FieldClash(field));
8589 }
8590 }
8591
8592 let mut params = Params::with_capacity(4 + self._additional_params.len());
8593 params.push("resource", self._resource);
8594
8595 params.extend(self._additional_params.iter());
8596
8597 params.push("alt", "json");
8598 let mut url = self.hub._base_url.clone() + "dns/v2/{+resource}:testIamPermissions";
8599 if self._scopes.is_empty() {
8600 self._scopes
8601 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
8602 }
8603
8604 #[allow(clippy::single_element_loop)]
8605 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8606 url = params.uri_replacement(url, param_name, find_this, true);
8607 }
8608 {
8609 let to_remove = ["resource"];
8610 params.remove_params(&to_remove);
8611 }
8612
8613 let url = params.parse_with_url(&url);
8614
8615 let mut json_mime_type = mime::APPLICATION_JSON;
8616 let mut request_value_reader = {
8617 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8618 common::remove_json_null_values(&mut value);
8619 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8620 serde_json::to_writer(&mut dst, &value).unwrap();
8621 dst
8622 };
8623 let request_size = request_value_reader
8624 .seek(std::io::SeekFrom::End(0))
8625 .unwrap();
8626 request_value_reader
8627 .seek(std::io::SeekFrom::Start(0))
8628 .unwrap();
8629
8630 loop {
8631 let token = match self
8632 .hub
8633 .auth
8634 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8635 .await
8636 {
8637 Ok(token) => token,
8638 Err(e) => match dlg.token(e) {
8639 Ok(token) => token,
8640 Err(e) => {
8641 dlg.finished(false);
8642 return Err(common::Error::MissingToken(e));
8643 }
8644 },
8645 };
8646 request_value_reader
8647 .seek(std::io::SeekFrom::Start(0))
8648 .unwrap();
8649 let mut req_result = {
8650 let client = &self.hub.client;
8651 dlg.pre_request();
8652 let mut req_builder = hyper::Request::builder()
8653 .method(hyper::Method::POST)
8654 .uri(url.as_str())
8655 .header(USER_AGENT, self.hub._user_agent.clone());
8656
8657 if let Some(token) = token.as_ref() {
8658 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8659 }
8660
8661 let request = req_builder
8662 .header(CONTENT_TYPE, json_mime_type.to_string())
8663 .header(CONTENT_LENGTH, request_size as u64)
8664 .body(common::to_body(
8665 request_value_reader.get_ref().clone().into(),
8666 ));
8667
8668 client.request(request.unwrap()).await
8669 };
8670
8671 match req_result {
8672 Err(err) => {
8673 if let common::Retry::After(d) = dlg.http_error(&err) {
8674 sleep(d).await;
8675 continue;
8676 }
8677 dlg.finished(false);
8678 return Err(common::Error::HttpError(err));
8679 }
8680 Ok(res) => {
8681 let (mut parts, body) = res.into_parts();
8682 let mut body = common::Body::new(body);
8683 if !parts.status.is_success() {
8684 let bytes = common::to_bytes(body).await.unwrap_or_default();
8685 let error = serde_json::from_str(&common::to_string(&bytes));
8686 let response = common::to_response(parts, bytes.into());
8687
8688 if let common::Retry::After(d) =
8689 dlg.http_failure(&response, error.as_ref().ok())
8690 {
8691 sleep(d).await;
8692 continue;
8693 }
8694
8695 dlg.finished(false);
8696
8697 return Err(match error {
8698 Ok(value) => common::Error::BadRequest(value),
8699 _ => common::Error::Failure(response),
8700 });
8701 }
8702 let response = {
8703 let bytes = common::to_bytes(body).await.unwrap_or_default();
8704 let encoded = common::to_string(&bytes);
8705 match serde_json::from_str(&encoded) {
8706 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8707 Err(error) => {
8708 dlg.response_json_decode_error(&encoded, &error);
8709 return Err(common::Error::JsonDecodeError(
8710 encoded.to_string(),
8711 error,
8712 ));
8713 }
8714 }
8715 };
8716
8717 dlg.finished(true);
8718 return Ok(response);
8719 }
8720 }
8721 }
8722 }
8723
8724 ///
8725 /// Sets the *request* property to the given value.
8726 ///
8727 /// Even though the property as already been set when instantiating this call,
8728 /// we provide this method for API completeness.
8729 pub fn request(
8730 mut self,
8731 new_value: GoogleIamV1TestIamPermissionsRequest,
8732 ) -> ManagedZoneTestIamPermissionCall<'a, C> {
8733 self._request = new_value;
8734 self
8735 }
8736 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8737 ///
8738 /// Sets the *resource* path property to the given value.
8739 ///
8740 /// Even though the property as already been set when instantiating this call,
8741 /// we provide this method for API completeness.
8742 pub fn resource(mut self, new_value: &str) -> ManagedZoneTestIamPermissionCall<'a, C> {
8743 self._resource = new_value.to_string();
8744 self
8745 }
8746 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8747 /// while executing the actual API request.
8748 ///
8749 /// ````text
8750 /// It should be used to handle progress information, and to implement a certain level of resilience.
8751 /// ````
8752 ///
8753 /// Sets the *delegate* property to the given value.
8754 pub fn delegate(
8755 mut self,
8756 new_value: &'a mut dyn common::Delegate,
8757 ) -> ManagedZoneTestIamPermissionCall<'a, C> {
8758 self._delegate = Some(new_value);
8759 self
8760 }
8761
8762 /// Set any additional parameter of the query string used in the request.
8763 /// It should be used to set parameters which are not yet available through their own
8764 /// setters.
8765 ///
8766 /// Please note that this method must not be used to set any of the known parameters
8767 /// which have their own setter method. If done anyway, the request will fail.
8768 ///
8769 /// # Additional Parameters
8770 ///
8771 /// * *$.xgafv* (query-string) - V1 error format.
8772 /// * *access_token* (query-string) - OAuth access token.
8773 /// * *alt* (query-string) - Data format for response.
8774 /// * *callback* (query-string) - JSONP
8775 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8776 /// * *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.
8777 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8778 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8779 /// * *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.
8780 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8781 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8782 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneTestIamPermissionCall<'a, C>
8783 where
8784 T: AsRef<str>,
8785 {
8786 self._additional_params
8787 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8788 self
8789 }
8790
8791 /// Identifies the authorization scope for the method you are building.
8792 ///
8793 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8794 /// [`Scope::NdevClouddnReadonly`].
8795 ///
8796 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8797 /// tokens for more than one scope.
8798 ///
8799 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8800 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8801 /// sufficient, a read-write scope will do as well.
8802 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneTestIamPermissionCall<'a, C>
8803 where
8804 St: AsRef<str>,
8805 {
8806 self._scopes.insert(String::from(scope.as_ref()));
8807 self
8808 }
8809 /// Identifies the authorization scope(s) for the method you are building.
8810 ///
8811 /// See [`Self::add_scope()`] for details.
8812 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneTestIamPermissionCall<'a, C>
8813 where
8814 I: IntoIterator<Item = St>,
8815 St: AsRef<str>,
8816 {
8817 self._scopes
8818 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8819 self
8820 }
8821
8822 /// Removes all scopes, and no default scope will be used either.
8823 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8824 /// for details).
8825 pub fn clear_scopes(mut self) -> ManagedZoneTestIamPermissionCall<'a, C> {
8826 self._scopes.clear();
8827 self
8828 }
8829}
8830
8831/// Updates an existing ManagedZone.
8832///
8833/// A builder for the *update* method supported by a *managedZone* resource.
8834/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
8835///
8836/// # Example
8837///
8838/// Instantiate a resource method builder
8839///
8840/// ```test_harness,no_run
8841/// # extern crate hyper;
8842/// # extern crate hyper_rustls;
8843/// # extern crate google_dns2 as dns2;
8844/// use dns2::api::ManagedZone;
8845/// # async fn dox() {
8846/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8847///
8848/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8849/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8850/// # .with_native_roots()
8851/// # .unwrap()
8852/// # .https_only()
8853/// # .enable_http2()
8854/// # .build();
8855///
8856/// # let executor = hyper_util::rt::TokioExecutor::new();
8857/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8858/// # secret,
8859/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8860/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8861/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8862/// # ),
8863/// # ).build().await.unwrap();
8864///
8865/// # let client = hyper_util::client::legacy::Client::builder(
8866/// # hyper_util::rt::TokioExecutor::new()
8867/// # )
8868/// # .build(
8869/// # hyper_rustls::HttpsConnectorBuilder::new()
8870/// # .with_native_roots()
8871/// # .unwrap()
8872/// # .https_or_http()
8873/// # .enable_http2()
8874/// # .build()
8875/// # );
8876/// # let mut hub = Dns::new(client, auth);
8877/// // As the method needs a request, you would usually fill it with the desired information
8878/// // into the respective structure. Some of the parts shown here might not be applicable !
8879/// // Values shown here are possibly random and not representative !
8880/// let mut req = ManagedZone::default();
8881///
8882/// // You can configure optional parameters by calling the respective setters at will, and
8883/// // execute the final call using `doit()`.
8884/// // Values shown here are possibly random and not representative !
8885/// let result = hub.managed_zones().update(req, "project", "location", "managedZone")
8886/// .client_operation_id("erat")
8887/// .doit().await;
8888/// # }
8889/// ```
8890pub struct ManagedZoneUpdateCall<'a, C>
8891where
8892 C: 'a,
8893{
8894 hub: &'a Dns<C>,
8895 _request: ManagedZone,
8896 _project: String,
8897 _location: String,
8898 _managed_zone: String,
8899 _client_operation_id: Option<String>,
8900 _delegate: Option<&'a mut dyn common::Delegate>,
8901 _additional_params: HashMap<String, String>,
8902 _scopes: BTreeSet<String>,
8903}
8904
8905impl<'a, C> common::CallBuilder for ManagedZoneUpdateCall<'a, C> {}
8906
8907impl<'a, C> ManagedZoneUpdateCall<'a, C>
8908where
8909 C: common::Connector,
8910{
8911 /// Perform the operation you have build so far.
8912 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8913 use std::borrow::Cow;
8914 use std::io::{Read, Seek};
8915
8916 use common::{url::Params, ToParts};
8917 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8918
8919 let mut dd = common::DefaultDelegate;
8920 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8921 dlg.begin(common::MethodInfo {
8922 id: "dns.managedZones.update",
8923 http_method: hyper::Method::PUT,
8924 });
8925
8926 for &field in [
8927 "alt",
8928 "project",
8929 "location",
8930 "managedZone",
8931 "clientOperationId",
8932 ]
8933 .iter()
8934 {
8935 if self._additional_params.contains_key(field) {
8936 dlg.finished(false);
8937 return Err(common::Error::FieldClash(field));
8938 }
8939 }
8940
8941 let mut params = Params::with_capacity(7 + self._additional_params.len());
8942 params.push("project", self._project);
8943 params.push("location", self._location);
8944 params.push("managedZone", self._managed_zone);
8945 if let Some(value) = self._client_operation_id.as_ref() {
8946 params.push("clientOperationId", value);
8947 }
8948
8949 params.extend(self._additional_params.iter());
8950
8951 params.push("alt", "json");
8952 let mut url = self.hub._base_url.clone()
8953 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}";
8954 if self._scopes.is_empty() {
8955 self._scopes
8956 .insert(Scope::CloudPlatform.as_ref().to_string());
8957 }
8958
8959 #[allow(clippy::single_element_loop)]
8960 for &(find_this, param_name) in [
8961 ("{project}", "project"),
8962 ("{location}", "location"),
8963 ("{managedZone}", "managedZone"),
8964 ]
8965 .iter()
8966 {
8967 url = params.uri_replacement(url, param_name, find_this, false);
8968 }
8969 {
8970 let to_remove = ["managedZone", "location", "project"];
8971 params.remove_params(&to_remove);
8972 }
8973
8974 let url = params.parse_with_url(&url);
8975
8976 let mut json_mime_type = mime::APPLICATION_JSON;
8977 let mut request_value_reader = {
8978 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8979 common::remove_json_null_values(&mut value);
8980 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8981 serde_json::to_writer(&mut dst, &value).unwrap();
8982 dst
8983 };
8984 let request_size = request_value_reader
8985 .seek(std::io::SeekFrom::End(0))
8986 .unwrap();
8987 request_value_reader
8988 .seek(std::io::SeekFrom::Start(0))
8989 .unwrap();
8990
8991 loop {
8992 let token = match self
8993 .hub
8994 .auth
8995 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8996 .await
8997 {
8998 Ok(token) => token,
8999 Err(e) => match dlg.token(e) {
9000 Ok(token) => token,
9001 Err(e) => {
9002 dlg.finished(false);
9003 return Err(common::Error::MissingToken(e));
9004 }
9005 },
9006 };
9007 request_value_reader
9008 .seek(std::io::SeekFrom::Start(0))
9009 .unwrap();
9010 let mut req_result = {
9011 let client = &self.hub.client;
9012 dlg.pre_request();
9013 let mut req_builder = hyper::Request::builder()
9014 .method(hyper::Method::PUT)
9015 .uri(url.as_str())
9016 .header(USER_AGENT, self.hub._user_agent.clone());
9017
9018 if let Some(token) = token.as_ref() {
9019 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9020 }
9021
9022 let request = req_builder
9023 .header(CONTENT_TYPE, json_mime_type.to_string())
9024 .header(CONTENT_LENGTH, request_size as u64)
9025 .body(common::to_body(
9026 request_value_reader.get_ref().clone().into(),
9027 ));
9028
9029 client.request(request.unwrap()).await
9030 };
9031
9032 match req_result {
9033 Err(err) => {
9034 if let common::Retry::After(d) = dlg.http_error(&err) {
9035 sleep(d).await;
9036 continue;
9037 }
9038 dlg.finished(false);
9039 return Err(common::Error::HttpError(err));
9040 }
9041 Ok(res) => {
9042 let (mut parts, body) = res.into_parts();
9043 let mut body = common::Body::new(body);
9044 if !parts.status.is_success() {
9045 let bytes = common::to_bytes(body).await.unwrap_or_default();
9046 let error = serde_json::from_str(&common::to_string(&bytes));
9047 let response = common::to_response(parts, bytes.into());
9048
9049 if let common::Retry::After(d) =
9050 dlg.http_failure(&response, error.as_ref().ok())
9051 {
9052 sleep(d).await;
9053 continue;
9054 }
9055
9056 dlg.finished(false);
9057
9058 return Err(match error {
9059 Ok(value) => common::Error::BadRequest(value),
9060 _ => common::Error::Failure(response),
9061 });
9062 }
9063 let response = {
9064 let bytes = common::to_bytes(body).await.unwrap_or_default();
9065 let encoded = common::to_string(&bytes);
9066 match serde_json::from_str(&encoded) {
9067 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9068 Err(error) => {
9069 dlg.response_json_decode_error(&encoded, &error);
9070 return Err(common::Error::JsonDecodeError(
9071 encoded.to_string(),
9072 error,
9073 ));
9074 }
9075 }
9076 };
9077
9078 dlg.finished(true);
9079 return Ok(response);
9080 }
9081 }
9082 }
9083 }
9084
9085 ///
9086 /// Sets the *request* property to the given value.
9087 ///
9088 /// Even though the property as already been set when instantiating this call,
9089 /// we provide this method for API completeness.
9090 pub fn request(mut self, new_value: ManagedZone) -> ManagedZoneUpdateCall<'a, C> {
9091 self._request = new_value;
9092 self
9093 }
9094 /// Identifies the project addressed by this request.
9095 ///
9096 /// Sets the *project* path property to the given value.
9097 ///
9098 /// Even though the property as already been set when instantiating this call,
9099 /// we provide this method for API completeness.
9100 pub fn project(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
9101 self._project = new_value.to_string();
9102 self
9103 }
9104 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
9105 ///
9106 /// Sets the *location* path property to the given value.
9107 ///
9108 /// Even though the property as already been set when instantiating this call,
9109 /// we provide this method for API completeness.
9110 pub fn location(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
9111 self._location = new_value.to_string();
9112 self
9113 }
9114 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
9115 ///
9116 /// Sets the *managed zone* path property to the given value.
9117 ///
9118 /// Even though the property as already been set when instantiating this call,
9119 /// we provide this method for API completeness.
9120 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
9121 self._managed_zone = new_value.to_string();
9122 self
9123 }
9124 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
9125 ///
9126 /// Sets the *client operation id* query property to the given value.
9127 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
9128 self._client_operation_id = Some(new_value.to_string());
9129 self
9130 }
9131 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9132 /// while executing the actual API request.
9133 ///
9134 /// ````text
9135 /// It should be used to handle progress information, and to implement a certain level of resilience.
9136 /// ````
9137 ///
9138 /// Sets the *delegate* property to the given value.
9139 pub fn delegate(
9140 mut self,
9141 new_value: &'a mut dyn common::Delegate,
9142 ) -> ManagedZoneUpdateCall<'a, C> {
9143 self._delegate = Some(new_value);
9144 self
9145 }
9146
9147 /// Set any additional parameter of the query string used in the request.
9148 /// It should be used to set parameters which are not yet available through their own
9149 /// setters.
9150 ///
9151 /// Please note that this method must not be used to set any of the known parameters
9152 /// which have their own setter method. If done anyway, the request will fail.
9153 ///
9154 /// # Additional Parameters
9155 ///
9156 /// * *$.xgafv* (query-string) - V1 error format.
9157 /// * *access_token* (query-string) - OAuth access token.
9158 /// * *alt* (query-string) - Data format for response.
9159 /// * *callback* (query-string) - JSONP
9160 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9161 /// * *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.
9162 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9163 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9164 /// * *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.
9165 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9166 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9167 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneUpdateCall<'a, C>
9168 where
9169 T: AsRef<str>,
9170 {
9171 self._additional_params
9172 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9173 self
9174 }
9175
9176 /// Identifies the authorization scope for the method you are building.
9177 ///
9178 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9179 /// [`Scope::CloudPlatform`].
9180 ///
9181 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9182 /// tokens for more than one scope.
9183 ///
9184 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9185 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9186 /// sufficient, a read-write scope will do as well.
9187 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneUpdateCall<'a, C>
9188 where
9189 St: AsRef<str>,
9190 {
9191 self._scopes.insert(String::from(scope.as_ref()));
9192 self
9193 }
9194 /// Identifies the authorization scope(s) for the method you are building.
9195 ///
9196 /// See [`Self::add_scope()`] for details.
9197 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneUpdateCall<'a, C>
9198 where
9199 I: IntoIterator<Item = St>,
9200 St: AsRef<str>,
9201 {
9202 self._scopes
9203 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9204 self
9205 }
9206
9207 /// Removes all scopes, and no default scope will be used either.
9208 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9209 /// for details).
9210 pub fn clear_scopes(mut self) -> ManagedZoneUpdateCall<'a, C> {
9211 self._scopes.clear();
9212 self
9213 }
9214}
9215
9216/// Creates a new policy.
9217///
9218/// A builder for the *create* method supported by a *policy* resource.
9219/// It is not used directly, but through a [`PolicyMethods`] instance.
9220///
9221/// # Example
9222///
9223/// Instantiate a resource method builder
9224///
9225/// ```test_harness,no_run
9226/// # extern crate hyper;
9227/// # extern crate hyper_rustls;
9228/// # extern crate google_dns2 as dns2;
9229/// use dns2::api::Policy;
9230/// # async fn dox() {
9231/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9232///
9233/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9234/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9235/// # .with_native_roots()
9236/// # .unwrap()
9237/// # .https_only()
9238/// # .enable_http2()
9239/// # .build();
9240///
9241/// # let executor = hyper_util::rt::TokioExecutor::new();
9242/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9243/// # secret,
9244/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9245/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9246/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9247/// # ),
9248/// # ).build().await.unwrap();
9249///
9250/// # let client = hyper_util::client::legacy::Client::builder(
9251/// # hyper_util::rt::TokioExecutor::new()
9252/// # )
9253/// # .build(
9254/// # hyper_rustls::HttpsConnectorBuilder::new()
9255/// # .with_native_roots()
9256/// # .unwrap()
9257/// # .https_or_http()
9258/// # .enable_http2()
9259/// # .build()
9260/// # );
9261/// # let mut hub = Dns::new(client, auth);
9262/// // As the method needs a request, you would usually fill it with the desired information
9263/// // into the respective structure. Some of the parts shown here might not be applicable !
9264/// // Values shown here are possibly random and not representative !
9265/// let mut req = Policy::default();
9266///
9267/// // You can configure optional parameters by calling the respective setters at will, and
9268/// // execute the final call using `doit()`.
9269/// // Values shown here are possibly random and not representative !
9270/// let result = hub.policies().create(req, "project", "location")
9271/// .client_operation_id("sed")
9272/// .doit().await;
9273/// # }
9274/// ```
9275pub struct PolicyCreateCall<'a, C>
9276where
9277 C: 'a,
9278{
9279 hub: &'a Dns<C>,
9280 _request: Policy,
9281 _project: String,
9282 _location: String,
9283 _client_operation_id: Option<String>,
9284 _delegate: Option<&'a mut dyn common::Delegate>,
9285 _additional_params: HashMap<String, String>,
9286 _scopes: BTreeSet<String>,
9287}
9288
9289impl<'a, C> common::CallBuilder for PolicyCreateCall<'a, C> {}
9290
9291impl<'a, C> PolicyCreateCall<'a, C>
9292where
9293 C: common::Connector,
9294{
9295 /// Perform the operation you have build so far.
9296 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9297 use std::borrow::Cow;
9298 use std::io::{Read, Seek};
9299
9300 use common::{url::Params, ToParts};
9301 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9302
9303 let mut dd = common::DefaultDelegate;
9304 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9305 dlg.begin(common::MethodInfo {
9306 id: "dns.policies.create",
9307 http_method: hyper::Method::POST,
9308 });
9309
9310 for &field in ["alt", "project", "location", "clientOperationId"].iter() {
9311 if self._additional_params.contains_key(field) {
9312 dlg.finished(false);
9313 return Err(common::Error::FieldClash(field));
9314 }
9315 }
9316
9317 let mut params = Params::with_capacity(6 + self._additional_params.len());
9318 params.push("project", self._project);
9319 params.push("location", self._location);
9320 if let Some(value) = self._client_operation_id.as_ref() {
9321 params.push("clientOperationId", value);
9322 }
9323
9324 params.extend(self._additional_params.iter());
9325
9326 params.push("alt", "json");
9327 let mut url =
9328 self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/policies";
9329 if self._scopes.is_empty() {
9330 self._scopes
9331 .insert(Scope::CloudPlatform.as_ref().to_string());
9332 }
9333
9334 #[allow(clippy::single_element_loop)]
9335 for &(find_this, param_name) in
9336 [("{project}", "project"), ("{location}", "location")].iter()
9337 {
9338 url = params.uri_replacement(url, param_name, find_this, false);
9339 }
9340 {
9341 let to_remove = ["location", "project"];
9342 params.remove_params(&to_remove);
9343 }
9344
9345 let url = params.parse_with_url(&url);
9346
9347 let mut json_mime_type = mime::APPLICATION_JSON;
9348 let mut request_value_reader = {
9349 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9350 common::remove_json_null_values(&mut value);
9351 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9352 serde_json::to_writer(&mut dst, &value).unwrap();
9353 dst
9354 };
9355 let request_size = request_value_reader
9356 .seek(std::io::SeekFrom::End(0))
9357 .unwrap();
9358 request_value_reader
9359 .seek(std::io::SeekFrom::Start(0))
9360 .unwrap();
9361
9362 loop {
9363 let token = match self
9364 .hub
9365 .auth
9366 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9367 .await
9368 {
9369 Ok(token) => token,
9370 Err(e) => match dlg.token(e) {
9371 Ok(token) => token,
9372 Err(e) => {
9373 dlg.finished(false);
9374 return Err(common::Error::MissingToken(e));
9375 }
9376 },
9377 };
9378 request_value_reader
9379 .seek(std::io::SeekFrom::Start(0))
9380 .unwrap();
9381 let mut req_result = {
9382 let client = &self.hub.client;
9383 dlg.pre_request();
9384 let mut req_builder = hyper::Request::builder()
9385 .method(hyper::Method::POST)
9386 .uri(url.as_str())
9387 .header(USER_AGENT, self.hub._user_agent.clone());
9388
9389 if let Some(token) = token.as_ref() {
9390 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9391 }
9392
9393 let request = req_builder
9394 .header(CONTENT_TYPE, json_mime_type.to_string())
9395 .header(CONTENT_LENGTH, request_size as u64)
9396 .body(common::to_body(
9397 request_value_reader.get_ref().clone().into(),
9398 ));
9399
9400 client.request(request.unwrap()).await
9401 };
9402
9403 match req_result {
9404 Err(err) => {
9405 if let common::Retry::After(d) = dlg.http_error(&err) {
9406 sleep(d).await;
9407 continue;
9408 }
9409 dlg.finished(false);
9410 return Err(common::Error::HttpError(err));
9411 }
9412 Ok(res) => {
9413 let (mut parts, body) = res.into_parts();
9414 let mut body = common::Body::new(body);
9415 if !parts.status.is_success() {
9416 let bytes = common::to_bytes(body).await.unwrap_or_default();
9417 let error = serde_json::from_str(&common::to_string(&bytes));
9418 let response = common::to_response(parts, bytes.into());
9419
9420 if let common::Retry::After(d) =
9421 dlg.http_failure(&response, error.as_ref().ok())
9422 {
9423 sleep(d).await;
9424 continue;
9425 }
9426
9427 dlg.finished(false);
9428
9429 return Err(match error {
9430 Ok(value) => common::Error::BadRequest(value),
9431 _ => common::Error::Failure(response),
9432 });
9433 }
9434 let response = {
9435 let bytes = common::to_bytes(body).await.unwrap_or_default();
9436 let encoded = common::to_string(&bytes);
9437 match serde_json::from_str(&encoded) {
9438 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9439 Err(error) => {
9440 dlg.response_json_decode_error(&encoded, &error);
9441 return Err(common::Error::JsonDecodeError(
9442 encoded.to_string(),
9443 error,
9444 ));
9445 }
9446 }
9447 };
9448
9449 dlg.finished(true);
9450 return Ok(response);
9451 }
9452 }
9453 }
9454 }
9455
9456 ///
9457 /// Sets the *request* property to the given value.
9458 ///
9459 /// Even though the property as already been set when instantiating this call,
9460 /// we provide this method for API completeness.
9461 pub fn request(mut self, new_value: Policy) -> PolicyCreateCall<'a, C> {
9462 self._request = new_value;
9463 self
9464 }
9465 /// Identifies the project addressed by this request.
9466 ///
9467 /// Sets the *project* path property to the given value.
9468 ///
9469 /// Even though the property as already been set when instantiating this call,
9470 /// we provide this method for API completeness.
9471 pub fn project(mut self, new_value: &str) -> PolicyCreateCall<'a, C> {
9472 self._project = new_value.to_string();
9473 self
9474 }
9475 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
9476 ///
9477 /// Sets the *location* path property to the given value.
9478 ///
9479 /// Even though the property as already been set when instantiating this call,
9480 /// we provide this method for API completeness.
9481 pub fn location(mut self, new_value: &str) -> PolicyCreateCall<'a, C> {
9482 self._location = new_value.to_string();
9483 self
9484 }
9485 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
9486 ///
9487 /// Sets the *client operation id* query property to the given value.
9488 pub fn client_operation_id(mut self, new_value: &str) -> PolicyCreateCall<'a, C> {
9489 self._client_operation_id = Some(new_value.to_string());
9490 self
9491 }
9492 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9493 /// while executing the actual API request.
9494 ///
9495 /// ````text
9496 /// It should be used to handle progress information, and to implement a certain level of resilience.
9497 /// ````
9498 ///
9499 /// Sets the *delegate* property to the given value.
9500 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyCreateCall<'a, C> {
9501 self._delegate = Some(new_value);
9502 self
9503 }
9504
9505 /// Set any additional parameter of the query string used in the request.
9506 /// It should be used to set parameters which are not yet available through their own
9507 /// setters.
9508 ///
9509 /// Please note that this method must not be used to set any of the known parameters
9510 /// which have their own setter method. If done anyway, the request will fail.
9511 ///
9512 /// # Additional Parameters
9513 ///
9514 /// * *$.xgafv* (query-string) - V1 error format.
9515 /// * *access_token* (query-string) - OAuth access token.
9516 /// * *alt* (query-string) - Data format for response.
9517 /// * *callback* (query-string) - JSONP
9518 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9519 /// * *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.
9520 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9521 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9522 /// * *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.
9523 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9524 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9525 pub fn param<T>(mut self, name: T, value: T) -> PolicyCreateCall<'a, C>
9526 where
9527 T: AsRef<str>,
9528 {
9529 self._additional_params
9530 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9531 self
9532 }
9533
9534 /// Identifies the authorization scope for the method you are building.
9535 ///
9536 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9537 /// [`Scope::CloudPlatform`].
9538 ///
9539 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9540 /// tokens for more than one scope.
9541 ///
9542 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9543 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9544 /// sufficient, a read-write scope will do as well.
9545 pub fn add_scope<St>(mut self, scope: St) -> PolicyCreateCall<'a, C>
9546 where
9547 St: AsRef<str>,
9548 {
9549 self._scopes.insert(String::from(scope.as_ref()));
9550 self
9551 }
9552 /// Identifies the authorization scope(s) for the method you are building.
9553 ///
9554 /// See [`Self::add_scope()`] for details.
9555 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyCreateCall<'a, C>
9556 where
9557 I: IntoIterator<Item = St>,
9558 St: AsRef<str>,
9559 {
9560 self._scopes
9561 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9562 self
9563 }
9564
9565 /// Removes all scopes, and no default scope will be used either.
9566 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9567 /// for details).
9568 pub fn clear_scopes(mut self) -> PolicyCreateCall<'a, C> {
9569 self._scopes.clear();
9570 self
9571 }
9572}
9573
9574/// Deletes a previously created policy. Fails if the policy is still being referenced by a network.
9575///
9576/// A builder for the *delete* method supported by a *policy* resource.
9577/// It is not used directly, but through a [`PolicyMethods`] instance.
9578///
9579/// # Example
9580///
9581/// Instantiate a resource method builder
9582///
9583/// ```test_harness,no_run
9584/// # extern crate hyper;
9585/// # extern crate hyper_rustls;
9586/// # extern crate google_dns2 as dns2;
9587/// # async fn dox() {
9588/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9589///
9590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9591/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9592/// # .with_native_roots()
9593/// # .unwrap()
9594/// # .https_only()
9595/// # .enable_http2()
9596/// # .build();
9597///
9598/// # let executor = hyper_util::rt::TokioExecutor::new();
9599/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9600/// # secret,
9601/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9602/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9603/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9604/// # ),
9605/// # ).build().await.unwrap();
9606///
9607/// # let client = hyper_util::client::legacy::Client::builder(
9608/// # hyper_util::rt::TokioExecutor::new()
9609/// # )
9610/// # .build(
9611/// # hyper_rustls::HttpsConnectorBuilder::new()
9612/// # .with_native_roots()
9613/// # .unwrap()
9614/// # .https_or_http()
9615/// # .enable_http2()
9616/// # .build()
9617/// # );
9618/// # let mut hub = Dns::new(client, auth);
9619/// // You can configure optional parameters by calling the respective setters at will, and
9620/// // execute the final call using `doit()`.
9621/// // Values shown here are possibly random and not representative !
9622/// let result = hub.policies().delete("project", "location", "policy")
9623/// .client_operation_id("et")
9624/// .doit().await;
9625/// # }
9626/// ```
9627pub struct PolicyDeleteCall<'a, C>
9628where
9629 C: 'a,
9630{
9631 hub: &'a Dns<C>,
9632 _project: String,
9633 _location: String,
9634 _policy: String,
9635 _client_operation_id: Option<String>,
9636 _delegate: Option<&'a mut dyn common::Delegate>,
9637 _additional_params: HashMap<String, String>,
9638 _scopes: BTreeSet<String>,
9639}
9640
9641impl<'a, C> common::CallBuilder for PolicyDeleteCall<'a, C> {}
9642
9643impl<'a, C> PolicyDeleteCall<'a, C>
9644where
9645 C: common::Connector,
9646{
9647 /// Perform the operation you have build so far.
9648 pub async fn doit(mut self) -> common::Result<common::Response> {
9649 use std::borrow::Cow;
9650 use std::io::{Read, Seek};
9651
9652 use common::{url::Params, ToParts};
9653 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9654
9655 let mut dd = common::DefaultDelegate;
9656 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9657 dlg.begin(common::MethodInfo {
9658 id: "dns.policies.delete",
9659 http_method: hyper::Method::DELETE,
9660 });
9661
9662 for &field in ["project", "location", "policy", "clientOperationId"].iter() {
9663 if self._additional_params.contains_key(field) {
9664 dlg.finished(false);
9665 return Err(common::Error::FieldClash(field));
9666 }
9667 }
9668
9669 let mut params = Params::with_capacity(5 + self._additional_params.len());
9670 params.push("project", self._project);
9671 params.push("location", self._location);
9672 params.push("policy", self._policy);
9673 if let Some(value) = self._client_operation_id.as_ref() {
9674 params.push("clientOperationId", value);
9675 }
9676
9677 params.extend(self._additional_params.iter());
9678
9679 let mut url = self.hub._base_url.clone()
9680 + "dns/v2/projects/{project}/locations/{location}/policies/{policy}";
9681 if self._scopes.is_empty() {
9682 self._scopes
9683 .insert(Scope::CloudPlatform.as_ref().to_string());
9684 }
9685
9686 #[allow(clippy::single_element_loop)]
9687 for &(find_this, param_name) in [
9688 ("{project}", "project"),
9689 ("{location}", "location"),
9690 ("{policy}", "policy"),
9691 ]
9692 .iter()
9693 {
9694 url = params.uri_replacement(url, param_name, find_this, false);
9695 }
9696 {
9697 let to_remove = ["policy", "location", "project"];
9698 params.remove_params(&to_remove);
9699 }
9700
9701 let url = params.parse_with_url(&url);
9702
9703 loop {
9704 let token = match self
9705 .hub
9706 .auth
9707 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9708 .await
9709 {
9710 Ok(token) => token,
9711 Err(e) => match dlg.token(e) {
9712 Ok(token) => token,
9713 Err(e) => {
9714 dlg.finished(false);
9715 return Err(common::Error::MissingToken(e));
9716 }
9717 },
9718 };
9719 let mut req_result = {
9720 let client = &self.hub.client;
9721 dlg.pre_request();
9722 let mut req_builder = hyper::Request::builder()
9723 .method(hyper::Method::DELETE)
9724 .uri(url.as_str())
9725 .header(USER_AGENT, self.hub._user_agent.clone());
9726
9727 if let Some(token) = token.as_ref() {
9728 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9729 }
9730
9731 let request = req_builder
9732 .header(CONTENT_LENGTH, 0_u64)
9733 .body(common::to_body::<String>(None));
9734
9735 client.request(request.unwrap()).await
9736 };
9737
9738 match req_result {
9739 Err(err) => {
9740 if let common::Retry::After(d) = dlg.http_error(&err) {
9741 sleep(d).await;
9742 continue;
9743 }
9744 dlg.finished(false);
9745 return Err(common::Error::HttpError(err));
9746 }
9747 Ok(res) => {
9748 let (mut parts, body) = res.into_parts();
9749 let mut body = common::Body::new(body);
9750 if !parts.status.is_success() {
9751 let bytes = common::to_bytes(body).await.unwrap_or_default();
9752 let error = serde_json::from_str(&common::to_string(&bytes));
9753 let response = common::to_response(parts, bytes.into());
9754
9755 if let common::Retry::After(d) =
9756 dlg.http_failure(&response, error.as_ref().ok())
9757 {
9758 sleep(d).await;
9759 continue;
9760 }
9761
9762 dlg.finished(false);
9763
9764 return Err(match error {
9765 Ok(value) => common::Error::BadRequest(value),
9766 _ => common::Error::Failure(response),
9767 });
9768 }
9769 let response = common::Response::from_parts(parts, body);
9770
9771 dlg.finished(true);
9772 return Ok(response);
9773 }
9774 }
9775 }
9776 }
9777
9778 /// Identifies the project addressed by this request.
9779 ///
9780 /// Sets the *project* path property to the given value.
9781 ///
9782 /// Even though the property as already been set when instantiating this call,
9783 /// we provide this method for API completeness.
9784 pub fn project(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9785 self._project = new_value.to_string();
9786 self
9787 }
9788 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
9789 ///
9790 /// Sets the *location* path property to the given value.
9791 ///
9792 /// Even though the property as already been set when instantiating this call,
9793 /// we provide this method for API completeness.
9794 pub fn location(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9795 self._location = new_value.to_string();
9796 self
9797 }
9798 /// User given friendly name of the policy addressed by this request.
9799 ///
9800 /// Sets the *policy* path property to the given value.
9801 ///
9802 /// Even though the property as already been set when instantiating this call,
9803 /// we provide this method for API completeness.
9804 pub fn policy(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9805 self._policy = new_value.to_string();
9806 self
9807 }
9808 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
9809 ///
9810 /// Sets the *client operation id* query property to the given value.
9811 pub fn client_operation_id(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9812 self._client_operation_id = Some(new_value.to_string());
9813 self
9814 }
9815 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9816 /// while executing the actual API request.
9817 ///
9818 /// ````text
9819 /// It should be used to handle progress information, and to implement a certain level of resilience.
9820 /// ````
9821 ///
9822 /// Sets the *delegate* property to the given value.
9823 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyDeleteCall<'a, C> {
9824 self._delegate = Some(new_value);
9825 self
9826 }
9827
9828 /// Set any additional parameter of the query string used in the request.
9829 /// It should be used to set parameters which are not yet available through their own
9830 /// setters.
9831 ///
9832 /// Please note that this method must not be used to set any of the known parameters
9833 /// which have their own setter method. If done anyway, the request will fail.
9834 ///
9835 /// # Additional Parameters
9836 ///
9837 /// * *$.xgafv* (query-string) - V1 error format.
9838 /// * *access_token* (query-string) - OAuth access token.
9839 /// * *alt* (query-string) - Data format for response.
9840 /// * *callback* (query-string) - JSONP
9841 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9842 /// * *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.
9843 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9844 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9845 /// * *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.
9846 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9847 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9848 pub fn param<T>(mut self, name: T, value: T) -> PolicyDeleteCall<'a, C>
9849 where
9850 T: AsRef<str>,
9851 {
9852 self._additional_params
9853 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9854 self
9855 }
9856
9857 /// Identifies the authorization scope for the method you are building.
9858 ///
9859 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9860 /// [`Scope::CloudPlatform`].
9861 ///
9862 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9863 /// tokens for more than one scope.
9864 ///
9865 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9866 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9867 /// sufficient, a read-write scope will do as well.
9868 pub fn add_scope<St>(mut self, scope: St) -> PolicyDeleteCall<'a, C>
9869 where
9870 St: AsRef<str>,
9871 {
9872 self._scopes.insert(String::from(scope.as_ref()));
9873 self
9874 }
9875 /// Identifies the authorization scope(s) for the method you are building.
9876 ///
9877 /// See [`Self::add_scope()`] for details.
9878 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyDeleteCall<'a, C>
9879 where
9880 I: IntoIterator<Item = St>,
9881 St: AsRef<str>,
9882 {
9883 self._scopes
9884 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9885 self
9886 }
9887
9888 /// Removes all scopes, and no default scope will be used either.
9889 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9890 /// for details).
9891 pub fn clear_scopes(mut self) -> PolicyDeleteCall<'a, C> {
9892 self._scopes.clear();
9893 self
9894 }
9895}
9896
9897/// Fetches the representation of an existing policy.
9898///
9899/// A builder for the *get* method supported by a *policy* resource.
9900/// It is not used directly, but through a [`PolicyMethods`] instance.
9901///
9902/// # Example
9903///
9904/// Instantiate a resource method builder
9905///
9906/// ```test_harness,no_run
9907/// # extern crate hyper;
9908/// # extern crate hyper_rustls;
9909/// # extern crate google_dns2 as dns2;
9910/// # async fn dox() {
9911/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9912///
9913/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9914/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9915/// # .with_native_roots()
9916/// # .unwrap()
9917/// # .https_only()
9918/// # .enable_http2()
9919/// # .build();
9920///
9921/// # let executor = hyper_util::rt::TokioExecutor::new();
9922/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9923/// # secret,
9924/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9925/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9926/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9927/// # ),
9928/// # ).build().await.unwrap();
9929///
9930/// # let client = hyper_util::client::legacy::Client::builder(
9931/// # hyper_util::rt::TokioExecutor::new()
9932/// # )
9933/// # .build(
9934/// # hyper_rustls::HttpsConnectorBuilder::new()
9935/// # .with_native_roots()
9936/// # .unwrap()
9937/// # .https_or_http()
9938/// # .enable_http2()
9939/// # .build()
9940/// # );
9941/// # let mut hub = Dns::new(client, auth);
9942/// // You can configure optional parameters by calling the respective setters at will, and
9943/// // execute the final call using `doit()`.
9944/// // Values shown here are possibly random and not representative !
9945/// let result = hub.policies().get("project", "location", "policy")
9946/// .client_operation_id("dolore")
9947/// .doit().await;
9948/// # }
9949/// ```
9950pub struct PolicyGetCall<'a, C>
9951where
9952 C: 'a,
9953{
9954 hub: &'a Dns<C>,
9955 _project: String,
9956 _location: String,
9957 _policy: String,
9958 _client_operation_id: Option<String>,
9959 _delegate: Option<&'a mut dyn common::Delegate>,
9960 _additional_params: HashMap<String, String>,
9961 _scopes: BTreeSet<String>,
9962}
9963
9964impl<'a, C> common::CallBuilder for PolicyGetCall<'a, C> {}
9965
9966impl<'a, C> PolicyGetCall<'a, C>
9967where
9968 C: common::Connector,
9969{
9970 /// Perform the operation you have build so far.
9971 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9972 use std::borrow::Cow;
9973 use std::io::{Read, Seek};
9974
9975 use common::{url::Params, ToParts};
9976 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9977
9978 let mut dd = common::DefaultDelegate;
9979 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9980 dlg.begin(common::MethodInfo {
9981 id: "dns.policies.get",
9982 http_method: hyper::Method::GET,
9983 });
9984
9985 for &field in ["alt", "project", "location", "policy", "clientOperationId"].iter() {
9986 if self._additional_params.contains_key(field) {
9987 dlg.finished(false);
9988 return Err(common::Error::FieldClash(field));
9989 }
9990 }
9991
9992 let mut params = Params::with_capacity(6 + self._additional_params.len());
9993 params.push("project", self._project);
9994 params.push("location", self._location);
9995 params.push("policy", self._policy);
9996 if let Some(value) = self._client_operation_id.as_ref() {
9997 params.push("clientOperationId", value);
9998 }
9999
10000 params.extend(self._additional_params.iter());
10001
10002 params.push("alt", "json");
10003 let mut url = self.hub._base_url.clone()
10004 + "dns/v2/projects/{project}/locations/{location}/policies/{policy}";
10005 if self._scopes.is_empty() {
10006 self._scopes
10007 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
10008 }
10009
10010 #[allow(clippy::single_element_loop)]
10011 for &(find_this, param_name) in [
10012 ("{project}", "project"),
10013 ("{location}", "location"),
10014 ("{policy}", "policy"),
10015 ]
10016 .iter()
10017 {
10018 url = params.uri_replacement(url, param_name, find_this, false);
10019 }
10020 {
10021 let to_remove = ["policy", "location", "project"];
10022 params.remove_params(&to_remove);
10023 }
10024
10025 let url = params.parse_with_url(&url);
10026
10027 loop {
10028 let token = match self
10029 .hub
10030 .auth
10031 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10032 .await
10033 {
10034 Ok(token) => token,
10035 Err(e) => match dlg.token(e) {
10036 Ok(token) => token,
10037 Err(e) => {
10038 dlg.finished(false);
10039 return Err(common::Error::MissingToken(e));
10040 }
10041 },
10042 };
10043 let mut req_result = {
10044 let client = &self.hub.client;
10045 dlg.pre_request();
10046 let mut req_builder = hyper::Request::builder()
10047 .method(hyper::Method::GET)
10048 .uri(url.as_str())
10049 .header(USER_AGENT, self.hub._user_agent.clone());
10050
10051 if let Some(token) = token.as_ref() {
10052 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10053 }
10054
10055 let request = req_builder
10056 .header(CONTENT_LENGTH, 0_u64)
10057 .body(common::to_body::<String>(None));
10058
10059 client.request(request.unwrap()).await
10060 };
10061
10062 match req_result {
10063 Err(err) => {
10064 if let common::Retry::After(d) = dlg.http_error(&err) {
10065 sleep(d).await;
10066 continue;
10067 }
10068 dlg.finished(false);
10069 return Err(common::Error::HttpError(err));
10070 }
10071 Ok(res) => {
10072 let (mut parts, body) = res.into_parts();
10073 let mut body = common::Body::new(body);
10074 if !parts.status.is_success() {
10075 let bytes = common::to_bytes(body).await.unwrap_or_default();
10076 let error = serde_json::from_str(&common::to_string(&bytes));
10077 let response = common::to_response(parts, bytes.into());
10078
10079 if let common::Retry::After(d) =
10080 dlg.http_failure(&response, error.as_ref().ok())
10081 {
10082 sleep(d).await;
10083 continue;
10084 }
10085
10086 dlg.finished(false);
10087
10088 return Err(match error {
10089 Ok(value) => common::Error::BadRequest(value),
10090 _ => common::Error::Failure(response),
10091 });
10092 }
10093 let response = {
10094 let bytes = common::to_bytes(body).await.unwrap_or_default();
10095 let encoded = common::to_string(&bytes);
10096 match serde_json::from_str(&encoded) {
10097 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10098 Err(error) => {
10099 dlg.response_json_decode_error(&encoded, &error);
10100 return Err(common::Error::JsonDecodeError(
10101 encoded.to_string(),
10102 error,
10103 ));
10104 }
10105 }
10106 };
10107
10108 dlg.finished(true);
10109 return Ok(response);
10110 }
10111 }
10112 }
10113 }
10114
10115 /// Identifies the project addressed by this request.
10116 ///
10117 /// Sets the *project* path property to the given value.
10118 ///
10119 /// Even though the property as already been set when instantiating this call,
10120 /// we provide this method for API completeness.
10121 pub fn project(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
10122 self._project = new_value.to_string();
10123 self
10124 }
10125 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
10126 ///
10127 /// Sets the *location* path property to the given value.
10128 ///
10129 /// Even though the property as already been set when instantiating this call,
10130 /// we provide this method for API completeness.
10131 pub fn location(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
10132 self._location = new_value.to_string();
10133 self
10134 }
10135 /// User given friendly name of the policy addressed by this request.
10136 ///
10137 /// Sets the *policy* path property to the given value.
10138 ///
10139 /// Even though the property as already been set when instantiating this call,
10140 /// we provide this method for API completeness.
10141 pub fn policy(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
10142 self._policy = new_value.to_string();
10143 self
10144 }
10145 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
10146 ///
10147 /// Sets the *client operation id* query property to the given value.
10148 pub fn client_operation_id(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
10149 self._client_operation_id = Some(new_value.to_string());
10150 self
10151 }
10152 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10153 /// while executing the actual API request.
10154 ///
10155 /// ````text
10156 /// It should be used to handle progress information, and to implement a certain level of resilience.
10157 /// ````
10158 ///
10159 /// Sets the *delegate* property to the given value.
10160 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyGetCall<'a, C> {
10161 self._delegate = Some(new_value);
10162 self
10163 }
10164
10165 /// Set any additional parameter of the query string used in the request.
10166 /// It should be used to set parameters which are not yet available through their own
10167 /// setters.
10168 ///
10169 /// Please note that this method must not be used to set any of the known parameters
10170 /// which have their own setter method. If done anyway, the request will fail.
10171 ///
10172 /// # Additional Parameters
10173 ///
10174 /// * *$.xgafv* (query-string) - V1 error format.
10175 /// * *access_token* (query-string) - OAuth access token.
10176 /// * *alt* (query-string) - Data format for response.
10177 /// * *callback* (query-string) - JSONP
10178 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10179 /// * *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.
10180 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10181 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10182 /// * *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.
10183 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10184 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10185 pub fn param<T>(mut self, name: T, value: T) -> PolicyGetCall<'a, C>
10186 where
10187 T: AsRef<str>,
10188 {
10189 self._additional_params
10190 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10191 self
10192 }
10193
10194 /// Identifies the authorization scope for the method you are building.
10195 ///
10196 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10197 /// [`Scope::NdevClouddnReadonly`].
10198 ///
10199 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10200 /// tokens for more than one scope.
10201 ///
10202 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10203 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10204 /// sufficient, a read-write scope will do as well.
10205 pub fn add_scope<St>(mut self, scope: St) -> PolicyGetCall<'a, C>
10206 where
10207 St: AsRef<str>,
10208 {
10209 self._scopes.insert(String::from(scope.as_ref()));
10210 self
10211 }
10212 /// Identifies the authorization scope(s) for the method you are building.
10213 ///
10214 /// See [`Self::add_scope()`] for details.
10215 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyGetCall<'a, C>
10216 where
10217 I: IntoIterator<Item = St>,
10218 St: AsRef<str>,
10219 {
10220 self._scopes
10221 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10222 self
10223 }
10224
10225 /// Removes all scopes, and no default scope will be used either.
10226 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10227 /// for details).
10228 pub fn clear_scopes(mut self) -> PolicyGetCall<'a, C> {
10229 self._scopes.clear();
10230 self
10231 }
10232}
10233
10234/// Enumerates all policies associated with a project.
10235///
10236/// A builder for the *list* method supported by a *policy* resource.
10237/// It is not used directly, but through a [`PolicyMethods`] instance.
10238///
10239/// # Example
10240///
10241/// Instantiate a resource method builder
10242///
10243/// ```test_harness,no_run
10244/// # extern crate hyper;
10245/// # extern crate hyper_rustls;
10246/// # extern crate google_dns2 as dns2;
10247/// # async fn dox() {
10248/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10249///
10250/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10251/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10252/// # .with_native_roots()
10253/// # .unwrap()
10254/// # .https_only()
10255/// # .enable_http2()
10256/// # .build();
10257///
10258/// # let executor = hyper_util::rt::TokioExecutor::new();
10259/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10260/// # secret,
10261/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10262/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10263/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10264/// # ),
10265/// # ).build().await.unwrap();
10266///
10267/// # let client = hyper_util::client::legacy::Client::builder(
10268/// # hyper_util::rt::TokioExecutor::new()
10269/// # )
10270/// # .build(
10271/// # hyper_rustls::HttpsConnectorBuilder::new()
10272/// # .with_native_roots()
10273/// # .unwrap()
10274/// # .https_or_http()
10275/// # .enable_http2()
10276/// # .build()
10277/// # );
10278/// # let mut hub = Dns::new(client, auth);
10279/// // You can configure optional parameters by calling the respective setters at will, and
10280/// // execute the final call using `doit()`.
10281/// // Values shown here are possibly random and not representative !
10282/// let result = hub.policies().list("project", "location")
10283/// .page_token("amet.")
10284/// .max_results(-17)
10285/// .doit().await;
10286/// # }
10287/// ```
10288pub struct PolicyListCall<'a, C>
10289where
10290 C: 'a,
10291{
10292 hub: &'a Dns<C>,
10293 _project: String,
10294 _location: String,
10295 _page_token: Option<String>,
10296 _max_results: Option<i32>,
10297 _delegate: Option<&'a mut dyn common::Delegate>,
10298 _additional_params: HashMap<String, String>,
10299 _scopes: BTreeSet<String>,
10300}
10301
10302impl<'a, C> common::CallBuilder for PolicyListCall<'a, C> {}
10303
10304impl<'a, C> PolicyListCall<'a, C>
10305where
10306 C: common::Connector,
10307{
10308 /// Perform the operation you have build so far.
10309 pub async fn doit(mut self) -> common::Result<(common::Response, PoliciesListResponse)> {
10310 use std::borrow::Cow;
10311 use std::io::{Read, Seek};
10312
10313 use common::{url::Params, ToParts};
10314 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10315
10316 let mut dd = common::DefaultDelegate;
10317 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10318 dlg.begin(common::MethodInfo {
10319 id: "dns.policies.list",
10320 http_method: hyper::Method::GET,
10321 });
10322
10323 for &field in ["alt", "project", "location", "pageToken", "maxResults"].iter() {
10324 if self._additional_params.contains_key(field) {
10325 dlg.finished(false);
10326 return Err(common::Error::FieldClash(field));
10327 }
10328 }
10329
10330 let mut params = Params::with_capacity(6 + self._additional_params.len());
10331 params.push("project", self._project);
10332 params.push("location", self._location);
10333 if let Some(value) = self._page_token.as_ref() {
10334 params.push("pageToken", value);
10335 }
10336 if let Some(value) = self._max_results.as_ref() {
10337 params.push("maxResults", value.to_string());
10338 }
10339
10340 params.extend(self._additional_params.iter());
10341
10342 params.push("alt", "json");
10343 let mut url =
10344 self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/policies";
10345 if self._scopes.is_empty() {
10346 self._scopes
10347 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
10348 }
10349
10350 #[allow(clippy::single_element_loop)]
10351 for &(find_this, param_name) in
10352 [("{project}", "project"), ("{location}", "location")].iter()
10353 {
10354 url = params.uri_replacement(url, param_name, find_this, false);
10355 }
10356 {
10357 let to_remove = ["location", "project"];
10358 params.remove_params(&to_remove);
10359 }
10360
10361 let url = params.parse_with_url(&url);
10362
10363 loop {
10364 let token = match self
10365 .hub
10366 .auth
10367 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10368 .await
10369 {
10370 Ok(token) => token,
10371 Err(e) => match dlg.token(e) {
10372 Ok(token) => token,
10373 Err(e) => {
10374 dlg.finished(false);
10375 return Err(common::Error::MissingToken(e));
10376 }
10377 },
10378 };
10379 let mut req_result = {
10380 let client = &self.hub.client;
10381 dlg.pre_request();
10382 let mut req_builder = hyper::Request::builder()
10383 .method(hyper::Method::GET)
10384 .uri(url.as_str())
10385 .header(USER_AGENT, self.hub._user_agent.clone());
10386
10387 if let Some(token) = token.as_ref() {
10388 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10389 }
10390
10391 let request = req_builder
10392 .header(CONTENT_LENGTH, 0_u64)
10393 .body(common::to_body::<String>(None));
10394
10395 client.request(request.unwrap()).await
10396 };
10397
10398 match req_result {
10399 Err(err) => {
10400 if let common::Retry::After(d) = dlg.http_error(&err) {
10401 sleep(d).await;
10402 continue;
10403 }
10404 dlg.finished(false);
10405 return Err(common::Error::HttpError(err));
10406 }
10407 Ok(res) => {
10408 let (mut parts, body) = res.into_parts();
10409 let mut body = common::Body::new(body);
10410 if !parts.status.is_success() {
10411 let bytes = common::to_bytes(body).await.unwrap_or_default();
10412 let error = serde_json::from_str(&common::to_string(&bytes));
10413 let response = common::to_response(parts, bytes.into());
10414
10415 if let common::Retry::After(d) =
10416 dlg.http_failure(&response, error.as_ref().ok())
10417 {
10418 sleep(d).await;
10419 continue;
10420 }
10421
10422 dlg.finished(false);
10423
10424 return Err(match error {
10425 Ok(value) => common::Error::BadRequest(value),
10426 _ => common::Error::Failure(response),
10427 });
10428 }
10429 let response = {
10430 let bytes = common::to_bytes(body).await.unwrap_or_default();
10431 let encoded = common::to_string(&bytes);
10432 match serde_json::from_str(&encoded) {
10433 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10434 Err(error) => {
10435 dlg.response_json_decode_error(&encoded, &error);
10436 return Err(common::Error::JsonDecodeError(
10437 encoded.to_string(),
10438 error,
10439 ));
10440 }
10441 }
10442 };
10443
10444 dlg.finished(true);
10445 return Ok(response);
10446 }
10447 }
10448 }
10449 }
10450
10451 /// Identifies the project addressed by this request.
10452 ///
10453 /// Sets the *project* path property to the given value.
10454 ///
10455 /// Even though the property as already been set when instantiating this call,
10456 /// we provide this method for API completeness.
10457 pub fn project(mut self, new_value: &str) -> PolicyListCall<'a, C> {
10458 self._project = new_value.to_string();
10459 self
10460 }
10461 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
10462 ///
10463 /// Sets the *location* path property to the given value.
10464 ///
10465 /// Even though the property as already been set when instantiating this call,
10466 /// we provide this method for API completeness.
10467 pub fn location(mut self, new_value: &str) -> PolicyListCall<'a, C> {
10468 self._location = new_value.to_string();
10469 self
10470 }
10471 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
10472 ///
10473 /// Sets the *page token* query property to the given value.
10474 pub fn page_token(mut self, new_value: &str) -> PolicyListCall<'a, C> {
10475 self._page_token = Some(new_value.to_string());
10476 self
10477 }
10478 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
10479 ///
10480 /// Sets the *max results* query property to the given value.
10481 pub fn max_results(mut self, new_value: i32) -> PolicyListCall<'a, C> {
10482 self._max_results = Some(new_value);
10483 self
10484 }
10485 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10486 /// while executing the actual API request.
10487 ///
10488 /// ````text
10489 /// It should be used to handle progress information, and to implement a certain level of resilience.
10490 /// ````
10491 ///
10492 /// Sets the *delegate* property to the given value.
10493 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyListCall<'a, C> {
10494 self._delegate = Some(new_value);
10495 self
10496 }
10497
10498 /// Set any additional parameter of the query string used in the request.
10499 /// It should be used to set parameters which are not yet available through their own
10500 /// setters.
10501 ///
10502 /// Please note that this method must not be used to set any of the known parameters
10503 /// which have their own setter method. If done anyway, the request will fail.
10504 ///
10505 /// # Additional Parameters
10506 ///
10507 /// * *$.xgafv* (query-string) - V1 error format.
10508 /// * *access_token* (query-string) - OAuth access token.
10509 /// * *alt* (query-string) - Data format for response.
10510 /// * *callback* (query-string) - JSONP
10511 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10512 /// * *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.
10513 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10514 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10515 /// * *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.
10516 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10517 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10518 pub fn param<T>(mut self, name: T, value: T) -> PolicyListCall<'a, C>
10519 where
10520 T: AsRef<str>,
10521 {
10522 self._additional_params
10523 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10524 self
10525 }
10526
10527 /// Identifies the authorization scope for the method you are building.
10528 ///
10529 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10530 /// [`Scope::NdevClouddnReadonly`].
10531 ///
10532 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10533 /// tokens for more than one scope.
10534 ///
10535 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10536 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10537 /// sufficient, a read-write scope will do as well.
10538 pub fn add_scope<St>(mut self, scope: St) -> PolicyListCall<'a, C>
10539 where
10540 St: AsRef<str>,
10541 {
10542 self._scopes.insert(String::from(scope.as_ref()));
10543 self
10544 }
10545 /// Identifies the authorization scope(s) for the method you are building.
10546 ///
10547 /// See [`Self::add_scope()`] for details.
10548 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyListCall<'a, C>
10549 where
10550 I: IntoIterator<Item = St>,
10551 St: AsRef<str>,
10552 {
10553 self._scopes
10554 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10555 self
10556 }
10557
10558 /// Removes all scopes, and no default scope will be used either.
10559 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10560 /// for details).
10561 pub fn clear_scopes(mut self) -> PolicyListCall<'a, C> {
10562 self._scopes.clear();
10563 self
10564 }
10565}
10566
10567/// Applies a partial update to an existing policy.
10568///
10569/// A builder for the *patch* method supported by a *policy* resource.
10570/// It is not used directly, but through a [`PolicyMethods`] instance.
10571///
10572/// # Example
10573///
10574/// Instantiate a resource method builder
10575///
10576/// ```test_harness,no_run
10577/// # extern crate hyper;
10578/// # extern crate hyper_rustls;
10579/// # extern crate google_dns2 as dns2;
10580/// use dns2::api::Policy;
10581/// # async fn dox() {
10582/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10583///
10584/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10585/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10586/// # .with_native_roots()
10587/// # .unwrap()
10588/// # .https_only()
10589/// # .enable_http2()
10590/// # .build();
10591///
10592/// # let executor = hyper_util::rt::TokioExecutor::new();
10593/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10594/// # secret,
10595/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10596/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10597/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10598/// # ),
10599/// # ).build().await.unwrap();
10600///
10601/// # let client = hyper_util::client::legacy::Client::builder(
10602/// # hyper_util::rt::TokioExecutor::new()
10603/// # )
10604/// # .build(
10605/// # hyper_rustls::HttpsConnectorBuilder::new()
10606/// # .with_native_roots()
10607/// # .unwrap()
10608/// # .https_or_http()
10609/// # .enable_http2()
10610/// # .build()
10611/// # );
10612/// # let mut hub = Dns::new(client, auth);
10613/// // As the method needs a request, you would usually fill it with the desired information
10614/// // into the respective structure. Some of the parts shown here might not be applicable !
10615/// // Values shown here are possibly random and not representative !
10616/// let mut req = Policy::default();
10617///
10618/// // You can configure optional parameters by calling the respective setters at will, and
10619/// // execute the final call using `doit()`.
10620/// // Values shown here are possibly random and not representative !
10621/// let result = hub.policies().patch(req, "project", "location", "policy")
10622/// .client_operation_id("no")
10623/// .doit().await;
10624/// # }
10625/// ```
10626pub struct PolicyPatchCall<'a, C>
10627where
10628 C: 'a,
10629{
10630 hub: &'a Dns<C>,
10631 _request: Policy,
10632 _project: String,
10633 _location: String,
10634 _policy: String,
10635 _client_operation_id: Option<String>,
10636 _delegate: Option<&'a mut dyn common::Delegate>,
10637 _additional_params: HashMap<String, String>,
10638 _scopes: BTreeSet<String>,
10639}
10640
10641impl<'a, C> common::CallBuilder for PolicyPatchCall<'a, C> {}
10642
10643impl<'a, C> PolicyPatchCall<'a, C>
10644where
10645 C: common::Connector,
10646{
10647 /// Perform the operation you have build so far.
10648 pub async fn doit(mut self) -> common::Result<(common::Response, PoliciesPatchResponse)> {
10649 use std::borrow::Cow;
10650 use std::io::{Read, Seek};
10651
10652 use common::{url::Params, ToParts};
10653 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10654
10655 let mut dd = common::DefaultDelegate;
10656 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10657 dlg.begin(common::MethodInfo {
10658 id: "dns.policies.patch",
10659 http_method: hyper::Method::PATCH,
10660 });
10661
10662 for &field in ["alt", "project", "location", "policy", "clientOperationId"].iter() {
10663 if self._additional_params.contains_key(field) {
10664 dlg.finished(false);
10665 return Err(common::Error::FieldClash(field));
10666 }
10667 }
10668
10669 let mut params = Params::with_capacity(7 + self._additional_params.len());
10670 params.push("project", self._project);
10671 params.push("location", self._location);
10672 params.push("policy", self._policy);
10673 if let Some(value) = self._client_operation_id.as_ref() {
10674 params.push("clientOperationId", value);
10675 }
10676
10677 params.extend(self._additional_params.iter());
10678
10679 params.push("alt", "json");
10680 let mut url = self.hub._base_url.clone()
10681 + "dns/v2/projects/{project}/locations/{location}/policies/{policy}";
10682 if self._scopes.is_empty() {
10683 self._scopes
10684 .insert(Scope::CloudPlatform.as_ref().to_string());
10685 }
10686
10687 #[allow(clippy::single_element_loop)]
10688 for &(find_this, param_name) in [
10689 ("{project}", "project"),
10690 ("{location}", "location"),
10691 ("{policy}", "policy"),
10692 ]
10693 .iter()
10694 {
10695 url = params.uri_replacement(url, param_name, find_this, false);
10696 }
10697 {
10698 let to_remove = ["policy", "location", "project"];
10699 params.remove_params(&to_remove);
10700 }
10701
10702 let url = params.parse_with_url(&url);
10703
10704 let mut json_mime_type = mime::APPLICATION_JSON;
10705 let mut request_value_reader = {
10706 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10707 common::remove_json_null_values(&mut value);
10708 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10709 serde_json::to_writer(&mut dst, &value).unwrap();
10710 dst
10711 };
10712 let request_size = request_value_reader
10713 .seek(std::io::SeekFrom::End(0))
10714 .unwrap();
10715 request_value_reader
10716 .seek(std::io::SeekFrom::Start(0))
10717 .unwrap();
10718
10719 loop {
10720 let token = match self
10721 .hub
10722 .auth
10723 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10724 .await
10725 {
10726 Ok(token) => token,
10727 Err(e) => match dlg.token(e) {
10728 Ok(token) => token,
10729 Err(e) => {
10730 dlg.finished(false);
10731 return Err(common::Error::MissingToken(e));
10732 }
10733 },
10734 };
10735 request_value_reader
10736 .seek(std::io::SeekFrom::Start(0))
10737 .unwrap();
10738 let mut req_result = {
10739 let client = &self.hub.client;
10740 dlg.pre_request();
10741 let mut req_builder = hyper::Request::builder()
10742 .method(hyper::Method::PATCH)
10743 .uri(url.as_str())
10744 .header(USER_AGENT, self.hub._user_agent.clone());
10745
10746 if let Some(token) = token.as_ref() {
10747 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10748 }
10749
10750 let request = req_builder
10751 .header(CONTENT_TYPE, json_mime_type.to_string())
10752 .header(CONTENT_LENGTH, request_size as u64)
10753 .body(common::to_body(
10754 request_value_reader.get_ref().clone().into(),
10755 ));
10756
10757 client.request(request.unwrap()).await
10758 };
10759
10760 match req_result {
10761 Err(err) => {
10762 if let common::Retry::After(d) = dlg.http_error(&err) {
10763 sleep(d).await;
10764 continue;
10765 }
10766 dlg.finished(false);
10767 return Err(common::Error::HttpError(err));
10768 }
10769 Ok(res) => {
10770 let (mut parts, body) = res.into_parts();
10771 let mut body = common::Body::new(body);
10772 if !parts.status.is_success() {
10773 let bytes = common::to_bytes(body).await.unwrap_or_default();
10774 let error = serde_json::from_str(&common::to_string(&bytes));
10775 let response = common::to_response(parts, bytes.into());
10776
10777 if let common::Retry::After(d) =
10778 dlg.http_failure(&response, error.as_ref().ok())
10779 {
10780 sleep(d).await;
10781 continue;
10782 }
10783
10784 dlg.finished(false);
10785
10786 return Err(match error {
10787 Ok(value) => common::Error::BadRequest(value),
10788 _ => common::Error::Failure(response),
10789 });
10790 }
10791 let response = {
10792 let bytes = common::to_bytes(body).await.unwrap_or_default();
10793 let encoded = common::to_string(&bytes);
10794 match serde_json::from_str(&encoded) {
10795 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10796 Err(error) => {
10797 dlg.response_json_decode_error(&encoded, &error);
10798 return Err(common::Error::JsonDecodeError(
10799 encoded.to_string(),
10800 error,
10801 ));
10802 }
10803 }
10804 };
10805
10806 dlg.finished(true);
10807 return Ok(response);
10808 }
10809 }
10810 }
10811 }
10812
10813 ///
10814 /// Sets the *request* property to the given value.
10815 ///
10816 /// Even though the property as already been set when instantiating this call,
10817 /// we provide this method for API completeness.
10818 pub fn request(mut self, new_value: Policy) -> PolicyPatchCall<'a, C> {
10819 self._request = new_value;
10820 self
10821 }
10822 /// Identifies the project addressed by this request.
10823 ///
10824 /// Sets the *project* path property to the given value.
10825 ///
10826 /// Even though the property as already been set when instantiating this call,
10827 /// we provide this method for API completeness.
10828 pub fn project(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10829 self._project = new_value.to_string();
10830 self
10831 }
10832 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
10833 ///
10834 /// Sets the *location* path property to the given value.
10835 ///
10836 /// Even though the property as already been set when instantiating this call,
10837 /// we provide this method for API completeness.
10838 pub fn location(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10839 self._location = new_value.to_string();
10840 self
10841 }
10842 /// User given friendly name of the policy addressed by this request.
10843 ///
10844 /// Sets the *policy* path property to the given value.
10845 ///
10846 /// Even though the property as already been set when instantiating this call,
10847 /// we provide this method for API completeness.
10848 pub fn policy(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10849 self._policy = new_value.to_string();
10850 self
10851 }
10852 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
10853 ///
10854 /// Sets the *client operation id* query property to the given value.
10855 pub fn client_operation_id(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10856 self._client_operation_id = Some(new_value.to_string());
10857 self
10858 }
10859 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10860 /// while executing the actual API request.
10861 ///
10862 /// ````text
10863 /// It should be used to handle progress information, and to implement a certain level of resilience.
10864 /// ````
10865 ///
10866 /// Sets the *delegate* property to the given value.
10867 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyPatchCall<'a, C> {
10868 self._delegate = Some(new_value);
10869 self
10870 }
10871
10872 /// Set any additional parameter of the query string used in the request.
10873 /// It should be used to set parameters which are not yet available through their own
10874 /// setters.
10875 ///
10876 /// Please note that this method must not be used to set any of the known parameters
10877 /// which have their own setter method. If done anyway, the request will fail.
10878 ///
10879 /// # Additional Parameters
10880 ///
10881 /// * *$.xgafv* (query-string) - V1 error format.
10882 /// * *access_token* (query-string) - OAuth access token.
10883 /// * *alt* (query-string) - Data format for response.
10884 /// * *callback* (query-string) - JSONP
10885 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10886 /// * *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.
10887 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10888 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10889 /// * *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.
10890 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10891 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10892 pub fn param<T>(mut self, name: T, value: T) -> PolicyPatchCall<'a, C>
10893 where
10894 T: AsRef<str>,
10895 {
10896 self._additional_params
10897 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10898 self
10899 }
10900
10901 /// Identifies the authorization scope for the method you are building.
10902 ///
10903 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10904 /// [`Scope::CloudPlatform`].
10905 ///
10906 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10907 /// tokens for more than one scope.
10908 ///
10909 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10910 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10911 /// sufficient, a read-write scope will do as well.
10912 pub fn add_scope<St>(mut self, scope: St) -> PolicyPatchCall<'a, C>
10913 where
10914 St: AsRef<str>,
10915 {
10916 self._scopes.insert(String::from(scope.as_ref()));
10917 self
10918 }
10919 /// Identifies the authorization scope(s) for the method you are building.
10920 ///
10921 /// See [`Self::add_scope()`] for details.
10922 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyPatchCall<'a, C>
10923 where
10924 I: IntoIterator<Item = St>,
10925 St: AsRef<str>,
10926 {
10927 self._scopes
10928 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10929 self
10930 }
10931
10932 /// Removes all scopes, and no default scope will be used either.
10933 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10934 /// for details).
10935 pub fn clear_scopes(mut self) -> PolicyPatchCall<'a, C> {
10936 self._scopes.clear();
10937 self
10938 }
10939}
10940
10941/// Updates an existing policy.
10942///
10943/// A builder for the *update* method supported by a *policy* resource.
10944/// It is not used directly, but through a [`PolicyMethods`] instance.
10945///
10946/// # Example
10947///
10948/// Instantiate a resource method builder
10949///
10950/// ```test_harness,no_run
10951/// # extern crate hyper;
10952/// # extern crate hyper_rustls;
10953/// # extern crate google_dns2 as dns2;
10954/// use dns2::api::Policy;
10955/// # async fn dox() {
10956/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10957///
10958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10959/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10960/// # .with_native_roots()
10961/// # .unwrap()
10962/// # .https_only()
10963/// # .enable_http2()
10964/// # .build();
10965///
10966/// # let executor = hyper_util::rt::TokioExecutor::new();
10967/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10968/// # secret,
10969/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10970/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10971/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10972/// # ),
10973/// # ).build().await.unwrap();
10974///
10975/// # let client = hyper_util::client::legacy::Client::builder(
10976/// # hyper_util::rt::TokioExecutor::new()
10977/// # )
10978/// # .build(
10979/// # hyper_rustls::HttpsConnectorBuilder::new()
10980/// # .with_native_roots()
10981/// # .unwrap()
10982/// # .https_or_http()
10983/// # .enable_http2()
10984/// # .build()
10985/// # );
10986/// # let mut hub = Dns::new(client, auth);
10987/// // As the method needs a request, you would usually fill it with the desired information
10988/// // into the respective structure. Some of the parts shown here might not be applicable !
10989/// // Values shown here are possibly random and not representative !
10990/// let mut req = Policy::default();
10991///
10992/// // You can configure optional parameters by calling the respective setters at will, and
10993/// // execute the final call using `doit()`.
10994/// // Values shown here are possibly random and not representative !
10995/// let result = hub.policies().update(req, "project", "location", "policy")
10996/// .client_operation_id("sit")
10997/// .doit().await;
10998/// # }
10999/// ```
11000pub struct PolicyUpdateCall<'a, C>
11001where
11002 C: 'a,
11003{
11004 hub: &'a Dns<C>,
11005 _request: Policy,
11006 _project: String,
11007 _location: String,
11008 _policy: String,
11009 _client_operation_id: Option<String>,
11010 _delegate: Option<&'a mut dyn common::Delegate>,
11011 _additional_params: HashMap<String, String>,
11012 _scopes: BTreeSet<String>,
11013}
11014
11015impl<'a, C> common::CallBuilder for PolicyUpdateCall<'a, C> {}
11016
11017impl<'a, C> PolicyUpdateCall<'a, C>
11018where
11019 C: common::Connector,
11020{
11021 /// Perform the operation you have build so far.
11022 pub async fn doit(mut self) -> common::Result<(common::Response, PoliciesUpdateResponse)> {
11023 use std::borrow::Cow;
11024 use std::io::{Read, Seek};
11025
11026 use common::{url::Params, ToParts};
11027 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11028
11029 let mut dd = common::DefaultDelegate;
11030 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11031 dlg.begin(common::MethodInfo {
11032 id: "dns.policies.update",
11033 http_method: hyper::Method::PUT,
11034 });
11035
11036 for &field in ["alt", "project", "location", "policy", "clientOperationId"].iter() {
11037 if self._additional_params.contains_key(field) {
11038 dlg.finished(false);
11039 return Err(common::Error::FieldClash(field));
11040 }
11041 }
11042
11043 let mut params = Params::with_capacity(7 + self._additional_params.len());
11044 params.push("project", self._project);
11045 params.push("location", self._location);
11046 params.push("policy", self._policy);
11047 if let Some(value) = self._client_operation_id.as_ref() {
11048 params.push("clientOperationId", value);
11049 }
11050
11051 params.extend(self._additional_params.iter());
11052
11053 params.push("alt", "json");
11054 let mut url = self.hub._base_url.clone()
11055 + "dns/v2/projects/{project}/locations/{location}/policies/{policy}";
11056 if self._scopes.is_empty() {
11057 self._scopes
11058 .insert(Scope::CloudPlatform.as_ref().to_string());
11059 }
11060
11061 #[allow(clippy::single_element_loop)]
11062 for &(find_this, param_name) in [
11063 ("{project}", "project"),
11064 ("{location}", "location"),
11065 ("{policy}", "policy"),
11066 ]
11067 .iter()
11068 {
11069 url = params.uri_replacement(url, param_name, find_this, false);
11070 }
11071 {
11072 let to_remove = ["policy", "location", "project"];
11073 params.remove_params(&to_remove);
11074 }
11075
11076 let url = params.parse_with_url(&url);
11077
11078 let mut json_mime_type = mime::APPLICATION_JSON;
11079 let mut request_value_reader = {
11080 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11081 common::remove_json_null_values(&mut value);
11082 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11083 serde_json::to_writer(&mut dst, &value).unwrap();
11084 dst
11085 };
11086 let request_size = request_value_reader
11087 .seek(std::io::SeekFrom::End(0))
11088 .unwrap();
11089 request_value_reader
11090 .seek(std::io::SeekFrom::Start(0))
11091 .unwrap();
11092
11093 loop {
11094 let token = match self
11095 .hub
11096 .auth
11097 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11098 .await
11099 {
11100 Ok(token) => token,
11101 Err(e) => match dlg.token(e) {
11102 Ok(token) => token,
11103 Err(e) => {
11104 dlg.finished(false);
11105 return Err(common::Error::MissingToken(e));
11106 }
11107 },
11108 };
11109 request_value_reader
11110 .seek(std::io::SeekFrom::Start(0))
11111 .unwrap();
11112 let mut req_result = {
11113 let client = &self.hub.client;
11114 dlg.pre_request();
11115 let mut req_builder = hyper::Request::builder()
11116 .method(hyper::Method::PUT)
11117 .uri(url.as_str())
11118 .header(USER_AGENT, self.hub._user_agent.clone());
11119
11120 if let Some(token) = token.as_ref() {
11121 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11122 }
11123
11124 let request = req_builder
11125 .header(CONTENT_TYPE, json_mime_type.to_string())
11126 .header(CONTENT_LENGTH, request_size as u64)
11127 .body(common::to_body(
11128 request_value_reader.get_ref().clone().into(),
11129 ));
11130
11131 client.request(request.unwrap()).await
11132 };
11133
11134 match req_result {
11135 Err(err) => {
11136 if let common::Retry::After(d) = dlg.http_error(&err) {
11137 sleep(d).await;
11138 continue;
11139 }
11140 dlg.finished(false);
11141 return Err(common::Error::HttpError(err));
11142 }
11143 Ok(res) => {
11144 let (mut parts, body) = res.into_parts();
11145 let mut body = common::Body::new(body);
11146 if !parts.status.is_success() {
11147 let bytes = common::to_bytes(body).await.unwrap_or_default();
11148 let error = serde_json::from_str(&common::to_string(&bytes));
11149 let response = common::to_response(parts, bytes.into());
11150
11151 if let common::Retry::After(d) =
11152 dlg.http_failure(&response, error.as_ref().ok())
11153 {
11154 sleep(d).await;
11155 continue;
11156 }
11157
11158 dlg.finished(false);
11159
11160 return Err(match error {
11161 Ok(value) => common::Error::BadRequest(value),
11162 _ => common::Error::Failure(response),
11163 });
11164 }
11165 let response = {
11166 let bytes = common::to_bytes(body).await.unwrap_or_default();
11167 let encoded = common::to_string(&bytes);
11168 match serde_json::from_str(&encoded) {
11169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11170 Err(error) => {
11171 dlg.response_json_decode_error(&encoded, &error);
11172 return Err(common::Error::JsonDecodeError(
11173 encoded.to_string(),
11174 error,
11175 ));
11176 }
11177 }
11178 };
11179
11180 dlg.finished(true);
11181 return Ok(response);
11182 }
11183 }
11184 }
11185 }
11186
11187 ///
11188 /// Sets the *request* property to the given value.
11189 ///
11190 /// Even though the property as already been set when instantiating this call,
11191 /// we provide this method for API completeness.
11192 pub fn request(mut self, new_value: Policy) -> PolicyUpdateCall<'a, C> {
11193 self._request = new_value;
11194 self
11195 }
11196 /// Identifies the project addressed by this request.
11197 ///
11198 /// Sets the *project* path property to the given value.
11199 ///
11200 /// Even though the property as already been set when instantiating this call,
11201 /// we provide this method for API completeness.
11202 pub fn project(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
11203 self._project = new_value.to_string();
11204 self
11205 }
11206 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
11207 ///
11208 /// Sets the *location* path property to the given value.
11209 ///
11210 /// Even though the property as already been set when instantiating this call,
11211 /// we provide this method for API completeness.
11212 pub fn location(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
11213 self._location = new_value.to_string();
11214 self
11215 }
11216 /// User given friendly name of the policy addressed by this request.
11217 ///
11218 /// Sets the *policy* path property to the given value.
11219 ///
11220 /// Even though the property as already been set when instantiating this call,
11221 /// we provide this method for API completeness.
11222 pub fn policy(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
11223 self._policy = new_value.to_string();
11224 self
11225 }
11226 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
11227 ///
11228 /// Sets the *client operation id* query property to the given value.
11229 pub fn client_operation_id(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
11230 self._client_operation_id = Some(new_value.to_string());
11231 self
11232 }
11233 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11234 /// while executing the actual API request.
11235 ///
11236 /// ````text
11237 /// It should be used to handle progress information, and to implement a certain level of resilience.
11238 /// ````
11239 ///
11240 /// Sets the *delegate* property to the given value.
11241 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyUpdateCall<'a, C> {
11242 self._delegate = Some(new_value);
11243 self
11244 }
11245
11246 /// Set any additional parameter of the query string used in the request.
11247 /// It should be used to set parameters which are not yet available through their own
11248 /// setters.
11249 ///
11250 /// Please note that this method must not be used to set any of the known parameters
11251 /// which have their own setter method. If done anyway, the request will fail.
11252 ///
11253 /// # Additional Parameters
11254 ///
11255 /// * *$.xgafv* (query-string) - V1 error format.
11256 /// * *access_token* (query-string) - OAuth access token.
11257 /// * *alt* (query-string) - Data format for response.
11258 /// * *callback* (query-string) - JSONP
11259 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11260 /// * *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.
11261 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11262 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11263 /// * *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.
11264 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11265 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11266 pub fn param<T>(mut self, name: T, value: T) -> PolicyUpdateCall<'a, C>
11267 where
11268 T: AsRef<str>,
11269 {
11270 self._additional_params
11271 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11272 self
11273 }
11274
11275 /// Identifies the authorization scope for the method you are building.
11276 ///
11277 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11278 /// [`Scope::CloudPlatform`].
11279 ///
11280 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11281 /// tokens for more than one scope.
11282 ///
11283 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11284 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11285 /// sufficient, a read-write scope will do as well.
11286 pub fn add_scope<St>(mut self, scope: St) -> PolicyUpdateCall<'a, C>
11287 where
11288 St: AsRef<str>,
11289 {
11290 self._scopes.insert(String::from(scope.as_ref()));
11291 self
11292 }
11293 /// Identifies the authorization scope(s) for the method you are building.
11294 ///
11295 /// See [`Self::add_scope()`] for details.
11296 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyUpdateCall<'a, C>
11297 where
11298 I: IntoIterator<Item = St>,
11299 St: AsRef<str>,
11300 {
11301 self._scopes
11302 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11303 self
11304 }
11305
11306 /// Removes all scopes, and no default scope will be used either.
11307 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11308 /// for details).
11309 pub fn clear_scopes(mut self) -> PolicyUpdateCall<'a, C> {
11310 self._scopes.clear();
11311 self
11312 }
11313}
11314
11315/// Fetches the representation of an existing Project.
11316///
11317/// A builder for the *get* method supported by a *project* resource.
11318/// It is not used directly, but through a [`ProjectMethods`] instance.
11319///
11320/// # Example
11321///
11322/// Instantiate a resource method builder
11323///
11324/// ```test_harness,no_run
11325/// # extern crate hyper;
11326/// # extern crate hyper_rustls;
11327/// # extern crate google_dns2 as dns2;
11328/// # async fn dox() {
11329/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11330///
11331/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11332/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11333/// # .with_native_roots()
11334/// # .unwrap()
11335/// # .https_only()
11336/// # .enable_http2()
11337/// # .build();
11338///
11339/// # let executor = hyper_util::rt::TokioExecutor::new();
11340/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11341/// # secret,
11342/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11343/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11344/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11345/// # ),
11346/// # ).build().await.unwrap();
11347///
11348/// # let client = hyper_util::client::legacy::Client::builder(
11349/// # hyper_util::rt::TokioExecutor::new()
11350/// # )
11351/// # .build(
11352/// # hyper_rustls::HttpsConnectorBuilder::new()
11353/// # .with_native_roots()
11354/// # .unwrap()
11355/// # .https_or_http()
11356/// # .enable_http2()
11357/// # .build()
11358/// # );
11359/// # let mut hub = Dns::new(client, auth);
11360/// // You can configure optional parameters by calling the respective setters at will, and
11361/// // execute the final call using `doit()`.
11362/// // Values shown here are possibly random and not representative !
11363/// let result = hub.projects().get("project", "location")
11364/// .client_operation_id("aliquyam")
11365/// .doit().await;
11366/// # }
11367/// ```
11368pub struct ProjectGetCall<'a, C>
11369where
11370 C: 'a,
11371{
11372 hub: &'a Dns<C>,
11373 _project: String,
11374 _location: String,
11375 _client_operation_id: Option<String>,
11376 _delegate: Option<&'a mut dyn common::Delegate>,
11377 _additional_params: HashMap<String, String>,
11378 _scopes: BTreeSet<String>,
11379}
11380
11381impl<'a, C> common::CallBuilder for ProjectGetCall<'a, C> {}
11382
11383impl<'a, C> ProjectGetCall<'a, C>
11384where
11385 C: common::Connector,
11386{
11387 /// Perform the operation you have build so far.
11388 pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
11389 use std::borrow::Cow;
11390 use std::io::{Read, Seek};
11391
11392 use common::{url::Params, ToParts};
11393 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11394
11395 let mut dd = common::DefaultDelegate;
11396 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11397 dlg.begin(common::MethodInfo {
11398 id: "dns.projects.get",
11399 http_method: hyper::Method::GET,
11400 });
11401
11402 for &field in ["alt", "project", "location", "clientOperationId"].iter() {
11403 if self._additional_params.contains_key(field) {
11404 dlg.finished(false);
11405 return Err(common::Error::FieldClash(field));
11406 }
11407 }
11408
11409 let mut params = Params::with_capacity(5 + self._additional_params.len());
11410 params.push("project", self._project);
11411 params.push("location", self._location);
11412 if let Some(value) = self._client_operation_id.as_ref() {
11413 params.push("clientOperationId", value);
11414 }
11415
11416 params.extend(self._additional_params.iter());
11417
11418 params.push("alt", "json");
11419 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}";
11420 if self._scopes.is_empty() {
11421 self._scopes
11422 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
11423 }
11424
11425 #[allow(clippy::single_element_loop)]
11426 for &(find_this, param_name) in
11427 [("{project}", "project"), ("{location}", "location")].iter()
11428 {
11429 url = params.uri_replacement(url, param_name, find_this, false);
11430 }
11431 {
11432 let to_remove = ["location", "project"];
11433 params.remove_params(&to_remove);
11434 }
11435
11436 let url = params.parse_with_url(&url);
11437
11438 loop {
11439 let token = match self
11440 .hub
11441 .auth
11442 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11443 .await
11444 {
11445 Ok(token) => token,
11446 Err(e) => match dlg.token(e) {
11447 Ok(token) => token,
11448 Err(e) => {
11449 dlg.finished(false);
11450 return Err(common::Error::MissingToken(e));
11451 }
11452 },
11453 };
11454 let mut req_result = {
11455 let client = &self.hub.client;
11456 dlg.pre_request();
11457 let mut req_builder = hyper::Request::builder()
11458 .method(hyper::Method::GET)
11459 .uri(url.as_str())
11460 .header(USER_AGENT, self.hub._user_agent.clone());
11461
11462 if let Some(token) = token.as_ref() {
11463 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11464 }
11465
11466 let request = req_builder
11467 .header(CONTENT_LENGTH, 0_u64)
11468 .body(common::to_body::<String>(None));
11469
11470 client.request(request.unwrap()).await
11471 };
11472
11473 match req_result {
11474 Err(err) => {
11475 if let common::Retry::After(d) = dlg.http_error(&err) {
11476 sleep(d).await;
11477 continue;
11478 }
11479 dlg.finished(false);
11480 return Err(common::Error::HttpError(err));
11481 }
11482 Ok(res) => {
11483 let (mut parts, body) = res.into_parts();
11484 let mut body = common::Body::new(body);
11485 if !parts.status.is_success() {
11486 let bytes = common::to_bytes(body).await.unwrap_or_default();
11487 let error = serde_json::from_str(&common::to_string(&bytes));
11488 let response = common::to_response(parts, bytes.into());
11489
11490 if let common::Retry::After(d) =
11491 dlg.http_failure(&response, error.as_ref().ok())
11492 {
11493 sleep(d).await;
11494 continue;
11495 }
11496
11497 dlg.finished(false);
11498
11499 return Err(match error {
11500 Ok(value) => common::Error::BadRequest(value),
11501 _ => common::Error::Failure(response),
11502 });
11503 }
11504 let response = {
11505 let bytes = common::to_bytes(body).await.unwrap_or_default();
11506 let encoded = common::to_string(&bytes);
11507 match serde_json::from_str(&encoded) {
11508 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11509 Err(error) => {
11510 dlg.response_json_decode_error(&encoded, &error);
11511 return Err(common::Error::JsonDecodeError(
11512 encoded.to_string(),
11513 error,
11514 ));
11515 }
11516 }
11517 };
11518
11519 dlg.finished(true);
11520 return Ok(response);
11521 }
11522 }
11523 }
11524 }
11525
11526 /// Identifies the project addressed by this request.
11527 ///
11528 /// Sets the *project* path property to the given value.
11529 ///
11530 /// Even though the property as already been set when instantiating this call,
11531 /// we provide this method for API completeness.
11532 pub fn project(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
11533 self._project = new_value.to_string();
11534 self
11535 }
11536 ///
11537 /// Sets the *location* path property to the given value.
11538 ///
11539 /// Even though the property as already been set when instantiating this call,
11540 /// we provide this method for API completeness.
11541 pub fn location(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
11542 self._location = new_value.to_string();
11543 self
11544 }
11545 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
11546 ///
11547 /// Sets the *client operation id* query property to the given value.
11548 pub fn client_operation_id(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
11549 self._client_operation_id = Some(new_value.to_string());
11550 self
11551 }
11552 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11553 /// while executing the actual API request.
11554 ///
11555 /// ````text
11556 /// It should be used to handle progress information, and to implement a certain level of resilience.
11557 /// ````
11558 ///
11559 /// Sets the *delegate* property to the given value.
11560 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectGetCall<'a, C> {
11561 self._delegate = Some(new_value);
11562 self
11563 }
11564
11565 /// Set any additional parameter of the query string used in the request.
11566 /// It should be used to set parameters which are not yet available through their own
11567 /// setters.
11568 ///
11569 /// Please note that this method must not be used to set any of the known parameters
11570 /// which have their own setter method. If done anyway, the request will fail.
11571 ///
11572 /// # Additional Parameters
11573 ///
11574 /// * *$.xgafv* (query-string) - V1 error format.
11575 /// * *access_token* (query-string) - OAuth access token.
11576 /// * *alt* (query-string) - Data format for response.
11577 /// * *callback* (query-string) - JSONP
11578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11579 /// * *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.
11580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11582 /// * *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.
11583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11585 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetCall<'a, C>
11586 where
11587 T: AsRef<str>,
11588 {
11589 self._additional_params
11590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11591 self
11592 }
11593
11594 /// Identifies the authorization scope for the method you are building.
11595 ///
11596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11597 /// [`Scope::NdevClouddnReadonly`].
11598 ///
11599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11600 /// tokens for more than one scope.
11601 ///
11602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11604 /// sufficient, a read-write scope will do as well.
11605 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetCall<'a, C>
11606 where
11607 St: AsRef<str>,
11608 {
11609 self._scopes.insert(String::from(scope.as_ref()));
11610 self
11611 }
11612 /// Identifies the authorization scope(s) for the method you are building.
11613 ///
11614 /// See [`Self::add_scope()`] for details.
11615 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetCall<'a, C>
11616 where
11617 I: IntoIterator<Item = St>,
11618 St: AsRef<str>,
11619 {
11620 self._scopes
11621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11622 self
11623 }
11624
11625 /// Removes all scopes, and no default scope will be used either.
11626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11627 /// for details).
11628 pub fn clear_scopes(mut self) -> ProjectGetCall<'a, C> {
11629 self._scopes.clear();
11630 self
11631 }
11632}
11633
11634/// Creates a new ResourceRecordSet.
11635///
11636/// A builder for the *create* method supported by a *resourceRecordSet* resource.
11637/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
11638///
11639/// # Example
11640///
11641/// Instantiate a resource method builder
11642///
11643/// ```test_harness,no_run
11644/// # extern crate hyper;
11645/// # extern crate hyper_rustls;
11646/// # extern crate google_dns2 as dns2;
11647/// use dns2::api::ResourceRecordSet;
11648/// # async fn dox() {
11649/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11650///
11651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11653/// # .with_native_roots()
11654/// # .unwrap()
11655/// # .https_only()
11656/// # .enable_http2()
11657/// # .build();
11658///
11659/// # let executor = hyper_util::rt::TokioExecutor::new();
11660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11661/// # secret,
11662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11663/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11664/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11665/// # ),
11666/// # ).build().await.unwrap();
11667///
11668/// # let client = hyper_util::client::legacy::Client::builder(
11669/// # hyper_util::rt::TokioExecutor::new()
11670/// # )
11671/// # .build(
11672/// # hyper_rustls::HttpsConnectorBuilder::new()
11673/// # .with_native_roots()
11674/// # .unwrap()
11675/// # .https_or_http()
11676/// # .enable_http2()
11677/// # .build()
11678/// # );
11679/// # let mut hub = Dns::new(client, auth);
11680/// // As the method needs a request, you would usually fill it with the desired information
11681/// // into the respective structure. Some of the parts shown here might not be applicable !
11682/// // Values shown here are possibly random and not representative !
11683/// let mut req = ResourceRecordSet::default();
11684///
11685/// // You can configure optional parameters by calling the respective setters at will, and
11686/// // execute the final call using `doit()`.
11687/// // Values shown here are possibly random and not representative !
11688/// let result = hub.resource_record_sets().create(req, "project", "location", "managedZone")
11689/// .client_operation_id("Lorem")
11690/// .doit().await;
11691/// # }
11692/// ```
11693pub struct ResourceRecordSetCreateCall<'a, C>
11694where
11695 C: 'a,
11696{
11697 hub: &'a Dns<C>,
11698 _request: ResourceRecordSet,
11699 _project: String,
11700 _location: String,
11701 _managed_zone: String,
11702 _client_operation_id: Option<String>,
11703 _delegate: Option<&'a mut dyn common::Delegate>,
11704 _additional_params: HashMap<String, String>,
11705 _scopes: BTreeSet<String>,
11706}
11707
11708impl<'a, C> common::CallBuilder for ResourceRecordSetCreateCall<'a, C> {}
11709
11710impl<'a, C> ResourceRecordSetCreateCall<'a, C>
11711where
11712 C: common::Connector,
11713{
11714 /// Perform the operation you have build so far.
11715 pub async fn doit(mut self) -> common::Result<(common::Response, ResourceRecordSet)> {
11716 use std::borrow::Cow;
11717 use std::io::{Read, Seek};
11718
11719 use common::{url::Params, ToParts};
11720 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11721
11722 let mut dd = common::DefaultDelegate;
11723 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11724 dlg.begin(common::MethodInfo {
11725 id: "dns.resourceRecordSets.create",
11726 http_method: hyper::Method::POST,
11727 });
11728
11729 for &field in [
11730 "alt",
11731 "project",
11732 "location",
11733 "managedZone",
11734 "clientOperationId",
11735 ]
11736 .iter()
11737 {
11738 if self._additional_params.contains_key(field) {
11739 dlg.finished(false);
11740 return Err(common::Error::FieldClash(field));
11741 }
11742 }
11743
11744 let mut params = Params::with_capacity(7 + self._additional_params.len());
11745 params.push("project", self._project);
11746 params.push("location", self._location);
11747 params.push("managedZone", self._managed_zone);
11748 if let Some(value) = self._client_operation_id.as_ref() {
11749 params.push("clientOperationId", value);
11750 }
11751
11752 params.extend(self._additional_params.iter());
11753
11754 params.push("alt", "json");
11755 let mut url = self.hub._base_url.clone()
11756 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/rrsets";
11757 if self._scopes.is_empty() {
11758 self._scopes
11759 .insert(Scope::CloudPlatform.as_ref().to_string());
11760 }
11761
11762 #[allow(clippy::single_element_loop)]
11763 for &(find_this, param_name) in [
11764 ("{project}", "project"),
11765 ("{location}", "location"),
11766 ("{managedZone}", "managedZone"),
11767 ]
11768 .iter()
11769 {
11770 url = params.uri_replacement(url, param_name, find_this, false);
11771 }
11772 {
11773 let to_remove = ["managedZone", "location", "project"];
11774 params.remove_params(&to_remove);
11775 }
11776
11777 let url = params.parse_with_url(&url);
11778
11779 let mut json_mime_type = mime::APPLICATION_JSON;
11780 let mut request_value_reader = {
11781 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11782 common::remove_json_null_values(&mut value);
11783 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11784 serde_json::to_writer(&mut dst, &value).unwrap();
11785 dst
11786 };
11787 let request_size = request_value_reader
11788 .seek(std::io::SeekFrom::End(0))
11789 .unwrap();
11790 request_value_reader
11791 .seek(std::io::SeekFrom::Start(0))
11792 .unwrap();
11793
11794 loop {
11795 let token = match self
11796 .hub
11797 .auth
11798 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11799 .await
11800 {
11801 Ok(token) => token,
11802 Err(e) => match dlg.token(e) {
11803 Ok(token) => token,
11804 Err(e) => {
11805 dlg.finished(false);
11806 return Err(common::Error::MissingToken(e));
11807 }
11808 },
11809 };
11810 request_value_reader
11811 .seek(std::io::SeekFrom::Start(0))
11812 .unwrap();
11813 let mut req_result = {
11814 let client = &self.hub.client;
11815 dlg.pre_request();
11816 let mut req_builder = hyper::Request::builder()
11817 .method(hyper::Method::POST)
11818 .uri(url.as_str())
11819 .header(USER_AGENT, self.hub._user_agent.clone());
11820
11821 if let Some(token) = token.as_ref() {
11822 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11823 }
11824
11825 let request = req_builder
11826 .header(CONTENT_TYPE, json_mime_type.to_string())
11827 .header(CONTENT_LENGTH, request_size as u64)
11828 .body(common::to_body(
11829 request_value_reader.get_ref().clone().into(),
11830 ));
11831
11832 client.request(request.unwrap()).await
11833 };
11834
11835 match req_result {
11836 Err(err) => {
11837 if let common::Retry::After(d) = dlg.http_error(&err) {
11838 sleep(d).await;
11839 continue;
11840 }
11841 dlg.finished(false);
11842 return Err(common::Error::HttpError(err));
11843 }
11844 Ok(res) => {
11845 let (mut parts, body) = res.into_parts();
11846 let mut body = common::Body::new(body);
11847 if !parts.status.is_success() {
11848 let bytes = common::to_bytes(body).await.unwrap_or_default();
11849 let error = serde_json::from_str(&common::to_string(&bytes));
11850 let response = common::to_response(parts, bytes.into());
11851
11852 if let common::Retry::After(d) =
11853 dlg.http_failure(&response, error.as_ref().ok())
11854 {
11855 sleep(d).await;
11856 continue;
11857 }
11858
11859 dlg.finished(false);
11860
11861 return Err(match error {
11862 Ok(value) => common::Error::BadRequest(value),
11863 _ => common::Error::Failure(response),
11864 });
11865 }
11866 let response = {
11867 let bytes = common::to_bytes(body).await.unwrap_or_default();
11868 let encoded = common::to_string(&bytes);
11869 match serde_json::from_str(&encoded) {
11870 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11871 Err(error) => {
11872 dlg.response_json_decode_error(&encoded, &error);
11873 return Err(common::Error::JsonDecodeError(
11874 encoded.to_string(),
11875 error,
11876 ));
11877 }
11878 }
11879 };
11880
11881 dlg.finished(true);
11882 return Ok(response);
11883 }
11884 }
11885 }
11886 }
11887
11888 ///
11889 /// Sets the *request* property to the given value.
11890 ///
11891 /// Even though the property as already been set when instantiating this call,
11892 /// we provide this method for API completeness.
11893 pub fn request(mut self, new_value: ResourceRecordSet) -> ResourceRecordSetCreateCall<'a, C> {
11894 self._request = new_value;
11895 self
11896 }
11897 /// Identifies the project addressed by this request.
11898 ///
11899 /// Sets the *project* path property to the given value.
11900 ///
11901 /// Even though the property as already been set when instantiating this call,
11902 /// we provide this method for API completeness.
11903 pub fn project(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11904 self._project = new_value.to_string();
11905 self
11906 }
11907 /// Specifies the location of the resource. This information is used for routing and is part of the resource name.
11908 ///
11909 /// Sets the *location* path property to the given value.
11910 ///
11911 /// Even though the property as already been set when instantiating this call,
11912 /// we provide this method for API completeness.
11913 pub fn location(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11914 self._location = new_value.to_string();
11915 self
11916 }
11917 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
11918 ///
11919 /// Sets the *managed zone* path property to the given value.
11920 ///
11921 /// Even though the property as already been set when instantiating this call,
11922 /// we provide this method for API completeness.
11923 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11924 self._managed_zone = new_value.to_string();
11925 self
11926 }
11927 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
11928 ///
11929 /// Sets the *client operation id* query property to the given value.
11930 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11931 self._client_operation_id = Some(new_value.to_string());
11932 self
11933 }
11934 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11935 /// while executing the actual API request.
11936 ///
11937 /// ````text
11938 /// It should be used to handle progress information, and to implement a certain level of resilience.
11939 /// ````
11940 ///
11941 /// Sets the *delegate* property to the given value.
11942 pub fn delegate(
11943 mut self,
11944 new_value: &'a mut dyn common::Delegate,
11945 ) -> ResourceRecordSetCreateCall<'a, C> {
11946 self._delegate = Some(new_value);
11947 self
11948 }
11949
11950 /// Set any additional parameter of the query string used in the request.
11951 /// It should be used to set parameters which are not yet available through their own
11952 /// setters.
11953 ///
11954 /// Please note that this method must not be used to set any of the known parameters
11955 /// which have their own setter method. If done anyway, the request will fail.
11956 ///
11957 /// # Additional Parameters
11958 ///
11959 /// * *$.xgafv* (query-string) - V1 error format.
11960 /// * *access_token* (query-string) - OAuth access token.
11961 /// * *alt* (query-string) - Data format for response.
11962 /// * *callback* (query-string) - JSONP
11963 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11964 /// * *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.
11965 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11966 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11967 /// * *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.
11968 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11969 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11970 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetCreateCall<'a, C>
11971 where
11972 T: AsRef<str>,
11973 {
11974 self._additional_params
11975 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11976 self
11977 }
11978
11979 /// Identifies the authorization scope for the method you are building.
11980 ///
11981 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11982 /// [`Scope::CloudPlatform`].
11983 ///
11984 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11985 /// tokens for more than one scope.
11986 ///
11987 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11988 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11989 /// sufficient, a read-write scope will do as well.
11990 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetCreateCall<'a, C>
11991 where
11992 St: AsRef<str>,
11993 {
11994 self._scopes.insert(String::from(scope.as_ref()));
11995 self
11996 }
11997 /// Identifies the authorization scope(s) for the method you are building.
11998 ///
11999 /// See [`Self::add_scope()`] for details.
12000 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetCreateCall<'a, C>
12001 where
12002 I: IntoIterator<Item = St>,
12003 St: AsRef<str>,
12004 {
12005 self._scopes
12006 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12007 self
12008 }
12009
12010 /// Removes all scopes, and no default scope will be used either.
12011 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12012 /// for details).
12013 pub fn clear_scopes(mut self) -> ResourceRecordSetCreateCall<'a, C> {
12014 self._scopes.clear();
12015 self
12016 }
12017}
12018
12019/// Deletes a previously created ResourceRecordSet.
12020///
12021/// A builder for the *delete* method supported by a *resourceRecordSet* resource.
12022/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
12023///
12024/// # Example
12025///
12026/// Instantiate a resource method builder
12027///
12028/// ```test_harness,no_run
12029/// # extern crate hyper;
12030/// # extern crate hyper_rustls;
12031/// # extern crate google_dns2 as dns2;
12032/// # async fn dox() {
12033/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12034///
12035/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12036/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12037/// # .with_native_roots()
12038/// # .unwrap()
12039/// # .https_only()
12040/// # .enable_http2()
12041/// # .build();
12042///
12043/// # let executor = hyper_util::rt::TokioExecutor::new();
12044/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12045/// # secret,
12046/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12047/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12048/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12049/// # ),
12050/// # ).build().await.unwrap();
12051///
12052/// # let client = hyper_util::client::legacy::Client::builder(
12053/// # hyper_util::rt::TokioExecutor::new()
12054/// # )
12055/// # .build(
12056/// # hyper_rustls::HttpsConnectorBuilder::new()
12057/// # .with_native_roots()
12058/// # .unwrap()
12059/// # .https_or_http()
12060/// # .enable_http2()
12061/// # .build()
12062/// # );
12063/// # let mut hub = Dns::new(client, auth);
12064/// // You can configure optional parameters by calling the respective setters at will, and
12065/// // execute the final call using `doit()`.
12066/// // Values shown here are possibly random and not representative !
12067/// let result = hub.resource_record_sets().delete("project", "location", "managedZone", "name", "type")
12068/// .client_operation_id("et")
12069/// .doit().await;
12070/// # }
12071/// ```
12072pub struct ResourceRecordSetDeleteCall<'a, C>
12073where
12074 C: 'a,
12075{
12076 hub: &'a Dns<C>,
12077 _project: String,
12078 _location: String,
12079 _managed_zone: String,
12080 _name: String,
12081 _type_: String,
12082 _client_operation_id: Option<String>,
12083 _delegate: Option<&'a mut dyn common::Delegate>,
12084 _additional_params: HashMap<String, String>,
12085 _scopes: BTreeSet<String>,
12086}
12087
12088impl<'a, C> common::CallBuilder for ResourceRecordSetDeleteCall<'a, C> {}
12089
12090impl<'a, C> ResourceRecordSetDeleteCall<'a, C>
12091where
12092 C: common::Connector,
12093{
12094 /// Perform the operation you have build so far.
12095 pub async fn doit(mut self) -> common::Result<common::Response> {
12096 use std::borrow::Cow;
12097 use std::io::{Read, Seek};
12098
12099 use common::{url::Params, ToParts};
12100 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12101
12102 let mut dd = common::DefaultDelegate;
12103 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12104 dlg.begin(common::MethodInfo {
12105 id: "dns.resourceRecordSets.delete",
12106 http_method: hyper::Method::DELETE,
12107 });
12108
12109 for &field in [
12110 "project",
12111 "location",
12112 "managedZone",
12113 "name",
12114 "type",
12115 "clientOperationId",
12116 ]
12117 .iter()
12118 {
12119 if self._additional_params.contains_key(field) {
12120 dlg.finished(false);
12121 return Err(common::Error::FieldClash(field));
12122 }
12123 }
12124
12125 let mut params = Params::with_capacity(7 + self._additional_params.len());
12126 params.push("project", self._project);
12127 params.push("location", self._location);
12128 params.push("managedZone", self._managed_zone);
12129 params.push("name", self._name);
12130 params.push("type", self._type_);
12131 if let Some(value) = self._client_operation_id.as_ref() {
12132 params.push("clientOperationId", value);
12133 }
12134
12135 params.extend(self._additional_params.iter());
12136
12137 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/rrsets/{name}/{type}";
12138 if self._scopes.is_empty() {
12139 self._scopes
12140 .insert(Scope::CloudPlatform.as_ref().to_string());
12141 }
12142
12143 #[allow(clippy::single_element_loop)]
12144 for &(find_this, param_name) in [
12145 ("{project}", "project"),
12146 ("{location}", "location"),
12147 ("{managedZone}", "managedZone"),
12148 ("{name}", "name"),
12149 ("{type}", "type"),
12150 ]
12151 .iter()
12152 {
12153 url = params.uri_replacement(url, param_name, find_this, false);
12154 }
12155 {
12156 let to_remove = ["type", "name", "managedZone", "location", "project"];
12157 params.remove_params(&to_remove);
12158 }
12159
12160 let url = params.parse_with_url(&url);
12161
12162 loop {
12163 let token = match self
12164 .hub
12165 .auth
12166 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12167 .await
12168 {
12169 Ok(token) => token,
12170 Err(e) => match dlg.token(e) {
12171 Ok(token) => token,
12172 Err(e) => {
12173 dlg.finished(false);
12174 return Err(common::Error::MissingToken(e));
12175 }
12176 },
12177 };
12178 let mut req_result = {
12179 let client = &self.hub.client;
12180 dlg.pre_request();
12181 let mut req_builder = hyper::Request::builder()
12182 .method(hyper::Method::DELETE)
12183 .uri(url.as_str())
12184 .header(USER_AGENT, self.hub._user_agent.clone());
12185
12186 if let Some(token) = token.as_ref() {
12187 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12188 }
12189
12190 let request = req_builder
12191 .header(CONTENT_LENGTH, 0_u64)
12192 .body(common::to_body::<String>(None));
12193
12194 client.request(request.unwrap()).await
12195 };
12196
12197 match req_result {
12198 Err(err) => {
12199 if let common::Retry::After(d) = dlg.http_error(&err) {
12200 sleep(d).await;
12201 continue;
12202 }
12203 dlg.finished(false);
12204 return Err(common::Error::HttpError(err));
12205 }
12206 Ok(res) => {
12207 let (mut parts, body) = res.into_parts();
12208 let mut body = common::Body::new(body);
12209 if !parts.status.is_success() {
12210 let bytes = common::to_bytes(body).await.unwrap_or_default();
12211 let error = serde_json::from_str(&common::to_string(&bytes));
12212 let response = common::to_response(parts, bytes.into());
12213
12214 if let common::Retry::After(d) =
12215 dlg.http_failure(&response, error.as_ref().ok())
12216 {
12217 sleep(d).await;
12218 continue;
12219 }
12220
12221 dlg.finished(false);
12222
12223 return Err(match error {
12224 Ok(value) => common::Error::BadRequest(value),
12225 _ => common::Error::Failure(response),
12226 });
12227 }
12228 let response = common::Response::from_parts(parts, body);
12229
12230 dlg.finished(true);
12231 return Ok(response);
12232 }
12233 }
12234 }
12235 }
12236
12237 /// Identifies the project addressed by this request.
12238 ///
12239 /// Sets the *project* path property to the given value.
12240 ///
12241 /// Even though the property as already been set when instantiating this call,
12242 /// we provide this method for API completeness.
12243 pub fn project(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
12244 self._project = new_value.to_string();
12245 self
12246 }
12247 /// Specifies the location of the resource. This information is used for routing and is part of the resource name.
12248 ///
12249 /// Sets the *location* path property to the given value.
12250 ///
12251 /// Even though the property as already been set when instantiating this call,
12252 /// we provide this method for API completeness.
12253 pub fn location(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
12254 self._location = new_value.to_string();
12255 self
12256 }
12257 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
12258 ///
12259 /// Sets the *managed zone* path property to the given value.
12260 ///
12261 /// Even though the property as already been set when instantiating this call,
12262 /// we provide this method for API completeness.
12263 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
12264 self._managed_zone = new_value.to_string();
12265 self
12266 }
12267 /// Fully qualified domain name.
12268 ///
12269 /// Sets the *name* path property to the given value.
12270 ///
12271 /// Even though the property as already been set when instantiating this call,
12272 /// we provide this method for API completeness.
12273 pub fn name(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
12274 self._name = new_value.to_string();
12275 self
12276 }
12277 /// RRSet type.
12278 ///
12279 /// Sets the *type* path property to the given value.
12280 ///
12281 /// Even though the property as already been set when instantiating this call,
12282 /// we provide this method for API completeness.
12283 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
12284 self._type_ = new_value.to_string();
12285 self
12286 }
12287 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
12288 ///
12289 /// Sets the *client operation id* query property to the given value.
12290 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
12291 self._client_operation_id = Some(new_value.to_string());
12292 self
12293 }
12294 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12295 /// while executing the actual API request.
12296 ///
12297 /// ````text
12298 /// It should be used to handle progress information, and to implement a certain level of resilience.
12299 /// ````
12300 ///
12301 /// Sets the *delegate* property to the given value.
12302 pub fn delegate(
12303 mut self,
12304 new_value: &'a mut dyn common::Delegate,
12305 ) -> ResourceRecordSetDeleteCall<'a, C> {
12306 self._delegate = Some(new_value);
12307 self
12308 }
12309
12310 /// Set any additional parameter of the query string used in the request.
12311 /// It should be used to set parameters which are not yet available through their own
12312 /// setters.
12313 ///
12314 /// Please note that this method must not be used to set any of the known parameters
12315 /// which have their own setter method. If done anyway, the request will fail.
12316 ///
12317 /// # Additional Parameters
12318 ///
12319 /// * *$.xgafv* (query-string) - V1 error format.
12320 /// * *access_token* (query-string) - OAuth access token.
12321 /// * *alt* (query-string) - Data format for response.
12322 /// * *callback* (query-string) - JSONP
12323 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12324 /// * *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.
12325 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12326 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12327 /// * *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.
12328 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12329 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12330 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetDeleteCall<'a, C>
12331 where
12332 T: AsRef<str>,
12333 {
12334 self._additional_params
12335 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12336 self
12337 }
12338
12339 /// Identifies the authorization scope for the method you are building.
12340 ///
12341 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12342 /// [`Scope::CloudPlatform`].
12343 ///
12344 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12345 /// tokens for more than one scope.
12346 ///
12347 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12348 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12349 /// sufficient, a read-write scope will do as well.
12350 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetDeleteCall<'a, C>
12351 where
12352 St: AsRef<str>,
12353 {
12354 self._scopes.insert(String::from(scope.as_ref()));
12355 self
12356 }
12357 /// Identifies the authorization scope(s) for the method you are building.
12358 ///
12359 /// See [`Self::add_scope()`] for details.
12360 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetDeleteCall<'a, C>
12361 where
12362 I: IntoIterator<Item = St>,
12363 St: AsRef<str>,
12364 {
12365 self._scopes
12366 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12367 self
12368 }
12369
12370 /// Removes all scopes, and no default scope will be used either.
12371 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12372 /// for details).
12373 pub fn clear_scopes(mut self) -> ResourceRecordSetDeleteCall<'a, C> {
12374 self._scopes.clear();
12375 self
12376 }
12377}
12378
12379/// Fetches the representation of an existing ResourceRecordSet.
12380///
12381/// A builder for the *get* method supported by a *resourceRecordSet* resource.
12382/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
12383///
12384/// # Example
12385///
12386/// Instantiate a resource method builder
12387///
12388/// ```test_harness,no_run
12389/// # extern crate hyper;
12390/// # extern crate hyper_rustls;
12391/// # extern crate google_dns2 as dns2;
12392/// # async fn dox() {
12393/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12394///
12395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12396/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12397/// # .with_native_roots()
12398/// # .unwrap()
12399/// # .https_only()
12400/// # .enable_http2()
12401/// # .build();
12402///
12403/// # let executor = hyper_util::rt::TokioExecutor::new();
12404/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12405/// # secret,
12406/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12407/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12408/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12409/// # ),
12410/// # ).build().await.unwrap();
12411///
12412/// # let client = hyper_util::client::legacy::Client::builder(
12413/// # hyper_util::rt::TokioExecutor::new()
12414/// # )
12415/// # .build(
12416/// # hyper_rustls::HttpsConnectorBuilder::new()
12417/// # .with_native_roots()
12418/// # .unwrap()
12419/// # .https_or_http()
12420/// # .enable_http2()
12421/// # .build()
12422/// # );
12423/// # let mut hub = Dns::new(client, auth);
12424/// // You can configure optional parameters by calling the respective setters at will, and
12425/// // execute the final call using `doit()`.
12426/// // Values shown here are possibly random and not representative !
12427/// let result = hub.resource_record_sets().get("project", "location", "managedZone", "name", "type")
12428/// .client_operation_id("no")
12429/// .doit().await;
12430/// # }
12431/// ```
12432pub struct ResourceRecordSetGetCall<'a, C>
12433where
12434 C: 'a,
12435{
12436 hub: &'a Dns<C>,
12437 _project: String,
12438 _location: String,
12439 _managed_zone: String,
12440 _name: String,
12441 _type_: String,
12442 _client_operation_id: Option<String>,
12443 _delegate: Option<&'a mut dyn common::Delegate>,
12444 _additional_params: HashMap<String, String>,
12445 _scopes: BTreeSet<String>,
12446}
12447
12448impl<'a, C> common::CallBuilder for ResourceRecordSetGetCall<'a, C> {}
12449
12450impl<'a, C> ResourceRecordSetGetCall<'a, C>
12451where
12452 C: common::Connector,
12453{
12454 /// Perform the operation you have build so far.
12455 pub async fn doit(mut self) -> common::Result<(common::Response, ResourceRecordSet)> {
12456 use std::borrow::Cow;
12457 use std::io::{Read, Seek};
12458
12459 use common::{url::Params, ToParts};
12460 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12461
12462 let mut dd = common::DefaultDelegate;
12463 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12464 dlg.begin(common::MethodInfo {
12465 id: "dns.resourceRecordSets.get",
12466 http_method: hyper::Method::GET,
12467 });
12468
12469 for &field in [
12470 "alt",
12471 "project",
12472 "location",
12473 "managedZone",
12474 "name",
12475 "type",
12476 "clientOperationId",
12477 ]
12478 .iter()
12479 {
12480 if self._additional_params.contains_key(field) {
12481 dlg.finished(false);
12482 return Err(common::Error::FieldClash(field));
12483 }
12484 }
12485
12486 let mut params = Params::with_capacity(8 + self._additional_params.len());
12487 params.push("project", self._project);
12488 params.push("location", self._location);
12489 params.push("managedZone", self._managed_zone);
12490 params.push("name", self._name);
12491 params.push("type", self._type_);
12492 if let Some(value) = self._client_operation_id.as_ref() {
12493 params.push("clientOperationId", value);
12494 }
12495
12496 params.extend(self._additional_params.iter());
12497
12498 params.push("alt", "json");
12499 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/rrsets/{name}/{type}";
12500 if self._scopes.is_empty() {
12501 self._scopes
12502 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
12503 }
12504
12505 #[allow(clippy::single_element_loop)]
12506 for &(find_this, param_name) in [
12507 ("{project}", "project"),
12508 ("{location}", "location"),
12509 ("{managedZone}", "managedZone"),
12510 ("{name}", "name"),
12511 ("{type}", "type"),
12512 ]
12513 .iter()
12514 {
12515 url = params.uri_replacement(url, param_name, find_this, false);
12516 }
12517 {
12518 let to_remove = ["type", "name", "managedZone", "location", "project"];
12519 params.remove_params(&to_remove);
12520 }
12521
12522 let url = params.parse_with_url(&url);
12523
12524 loop {
12525 let token = match self
12526 .hub
12527 .auth
12528 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12529 .await
12530 {
12531 Ok(token) => token,
12532 Err(e) => match dlg.token(e) {
12533 Ok(token) => token,
12534 Err(e) => {
12535 dlg.finished(false);
12536 return Err(common::Error::MissingToken(e));
12537 }
12538 },
12539 };
12540 let mut req_result = {
12541 let client = &self.hub.client;
12542 dlg.pre_request();
12543 let mut req_builder = hyper::Request::builder()
12544 .method(hyper::Method::GET)
12545 .uri(url.as_str())
12546 .header(USER_AGENT, self.hub._user_agent.clone());
12547
12548 if let Some(token) = token.as_ref() {
12549 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12550 }
12551
12552 let request = req_builder
12553 .header(CONTENT_LENGTH, 0_u64)
12554 .body(common::to_body::<String>(None));
12555
12556 client.request(request.unwrap()).await
12557 };
12558
12559 match req_result {
12560 Err(err) => {
12561 if let common::Retry::After(d) = dlg.http_error(&err) {
12562 sleep(d).await;
12563 continue;
12564 }
12565 dlg.finished(false);
12566 return Err(common::Error::HttpError(err));
12567 }
12568 Ok(res) => {
12569 let (mut parts, body) = res.into_parts();
12570 let mut body = common::Body::new(body);
12571 if !parts.status.is_success() {
12572 let bytes = common::to_bytes(body).await.unwrap_or_default();
12573 let error = serde_json::from_str(&common::to_string(&bytes));
12574 let response = common::to_response(parts, bytes.into());
12575
12576 if let common::Retry::After(d) =
12577 dlg.http_failure(&response, error.as_ref().ok())
12578 {
12579 sleep(d).await;
12580 continue;
12581 }
12582
12583 dlg.finished(false);
12584
12585 return Err(match error {
12586 Ok(value) => common::Error::BadRequest(value),
12587 _ => common::Error::Failure(response),
12588 });
12589 }
12590 let response = {
12591 let bytes = common::to_bytes(body).await.unwrap_or_default();
12592 let encoded = common::to_string(&bytes);
12593 match serde_json::from_str(&encoded) {
12594 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12595 Err(error) => {
12596 dlg.response_json_decode_error(&encoded, &error);
12597 return Err(common::Error::JsonDecodeError(
12598 encoded.to_string(),
12599 error,
12600 ));
12601 }
12602 }
12603 };
12604
12605 dlg.finished(true);
12606 return Ok(response);
12607 }
12608 }
12609 }
12610 }
12611
12612 /// Identifies the project addressed by this request.
12613 ///
12614 /// Sets the *project* path property to the given value.
12615 ///
12616 /// Even though the property as already been set when instantiating this call,
12617 /// we provide this method for API completeness.
12618 pub fn project(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12619 self._project = new_value.to_string();
12620 self
12621 }
12622 /// Specifies the location of the resource. This information is used for routing and is part of the resource name.
12623 ///
12624 /// Sets the *location* path property to the given value.
12625 ///
12626 /// Even though the property as already been set when instantiating this call,
12627 /// we provide this method for API completeness.
12628 pub fn location(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12629 self._location = new_value.to_string();
12630 self
12631 }
12632 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
12633 ///
12634 /// Sets the *managed zone* path property to the given value.
12635 ///
12636 /// Even though the property as already been set when instantiating this call,
12637 /// we provide this method for API completeness.
12638 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12639 self._managed_zone = new_value.to_string();
12640 self
12641 }
12642 /// Fully qualified domain name.
12643 ///
12644 /// Sets the *name* path property to the given value.
12645 ///
12646 /// Even though the property as already been set when instantiating this call,
12647 /// we provide this method for API completeness.
12648 pub fn name(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12649 self._name = new_value.to_string();
12650 self
12651 }
12652 /// RRSet type.
12653 ///
12654 /// Sets the *type* path property to the given value.
12655 ///
12656 /// Even though the property as already been set when instantiating this call,
12657 /// we provide this method for API completeness.
12658 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12659 self._type_ = new_value.to_string();
12660 self
12661 }
12662 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
12663 ///
12664 /// Sets the *client operation id* query property to the given value.
12665 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12666 self._client_operation_id = Some(new_value.to_string());
12667 self
12668 }
12669 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12670 /// while executing the actual API request.
12671 ///
12672 /// ````text
12673 /// It should be used to handle progress information, and to implement a certain level of resilience.
12674 /// ````
12675 ///
12676 /// Sets the *delegate* property to the given value.
12677 pub fn delegate(
12678 mut self,
12679 new_value: &'a mut dyn common::Delegate,
12680 ) -> ResourceRecordSetGetCall<'a, C> {
12681 self._delegate = Some(new_value);
12682 self
12683 }
12684
12685 /// Set any additional parameter of the query string used in the request.
12686 /// It should be used to set parameters which are not yet available through their own
12687 /// setters.
12688 ///
12689 /// Please note that this method must not be used to set any of the known parameters
12690 /// which have their own setter method. If done anyway, the request will fail.
12691 ///
12692 /// # Additional Parameters
12693 ///
12694 /// * *$.xgafv* (query-string) - V1 error format.
12695 /// * *access_token* (query-string) - OAuth access token.
12696 /// * *alt* (query-string) - Data format for response.
12697 /// * *callback* (query-string) - JSONP
12698 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12699 /// * *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.
12700 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12701 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12702 /// * *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.
12703 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12704 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12705 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetGetCall<'a, C>
12706 where
12707 T: AsRef<str>,
12708 {
12709 self._additional_params
12710 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12711 self
12712 }
12713
12714 /// Identifies the authorization scope for the method you are building.
12715 ///
12716 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12717 /// [`Scope::NdevClouddnReadonly`].
12718 ///
12719 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12720 /// tokens for more than one scope.
12721 ///
12722 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12723 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12724 /// sufficient, a read-write scope will do as well.
12725 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetGetCall<'a, C>
12726 where
12727 St: AsRef<str>,
12728 {
12729 self._scopes.insert(String::from(scope.as_ref()));
12730 self
12731 }
12732 /// Identifies the authorization scope(s) for the method you are building.
12733 ///
12734 /// See [`Self::add_scope()`] for details.
12735 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetGetCall<'a, C>
12736 where
12737 I: IntoIterator<Item = St>,
12738 St: AsRef<str>,
12739 {
12740 self._scopes
12741 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12742 self
12743 }
12744
12745 /// Removes all scopes, and no default scope will be used either.
12746 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12747 /// for details).
12748 pub fn clear_scopes(mut self) -> ResourceRecordSetGetCall<'a, C> {
12749 self._scopes.clear();
12750 self
12751 }
12752}
12753
12754/// Enumerates ResourceRecordSets that you have created but not yet deleted.
12755///
12756/// A builder for the *list* method supported by a *resourceRecordSet* resource.
12757/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
12758///
12759/// # Example
12760///
12761/// Instantiate a resource method builder
12762///
12763/// ```test_harness,no_run
12764/// # extern crate hyper;
12765/// # extern crate hyper_rustls;
12766/// # extern crate google_dns2 as dns2;
12767/// # async fn dox() {
12768/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12769///
12770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12771/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12772/// # .with_native_roots()
12773/// # .unwrap()
12774/// # .https_only()
12775/// # .enable_http2()
12776/// # .build();
12777///
12778/// # let executor = hyper_util::rt::TokioExecutor::new();
12779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12780/// # secret,
12781/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12782/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12783/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12784/// # ),
12785/// # ).build().await.unwrap();
12786///
12787/// # let client = hyper_util::client::legacy::Client::builder(
12788/// # hyper_util::rt::TokioExecutor::new()
12789/// # )
12790/// # .build(
12791/// # hyper_rustls::HttpsConnectorBuilder::new()
12792/// # .with_native_roots()
12793/// # .unwrap()
12794/// # .https_or_http()
12795/// # .enable_http2()
12796/// # .build()
12797/// # );
12798/// # let mut hub = Dns::new(client, auth);
12799/// // You can configure optional parameters by calling the respective setters at will, and
12800/// // execute the final call using `doit()`.
12801/// // Values shown here are possibly random and not representative !
12802/// let result = hub.resource_record_sets().list("project", "location", "managedZone")
12803/// .type_("aliquyam")
12804/// .page_token("dolores")
12805/// .name("sadipscing")
12806/// .max_results(-31)
12807/// .doit().await;
12808/// # }
12809/// ```
12810pub struct ResourceRecordSetListCall<'a, C>
12811where
12812 C: 'a,
12813{
12814 hub: &'a Dns<C>,
12815 _project: String,
12816 _location: String,
12817 _managed_zone: String,
12818 _type_: Option<String>,
12819 _page_token: Option<String>,
12820 _name: Option<String>,
12821 _max_results: Option<i32>,
12822 _delegate: Option<&'a mut dyn common::Delegate>,
12823 _additional_params: HashMap<String, String>,
12824 _scopes: BTreeSet<String>,
12825}
12826
12827impl<'a, C> common::CallBuilder for ResourceRecordSetListCall<'a, C> {}
12828
12829impl<'a, C> ResourceRecordSetListCall<'a, C>
12830where
12831 C: common::Connector,
12832{
12833 /// Perform the operation you have build so far.
12834 pub async fn doit(
12835 mut self,
12836 ) -> common::Result<(common::Response, ResourceRecordSetsListResponse)> {
12837 use std::borrow::Cow;
12838 use std::io::{Read, Seek};
12839
12840 use common::{url::Params, ToParts};
12841 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12842
12843 let mut dd = common::DefaultDelegate;
12844 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12845 dlg.begin(common::MethodInfo {
12846 id: "dns.resourceRecordSets.list",
12847 http_method: hyper::Method::GET,
12848 });
12849
12850 for &field in [
12851 "alt",
12852 "project",
12853 "location",
12854 "managedZone",
12855 "type",
12856 "pageToken",
12857 "name",
12858 "maxResults",
12859 ]
12860 .iter()
12861 {
12862 if self._additional_params.contains_key(field) {
12863 dlg.finished(false);
12864 return Err(common::Error::FieldClash(field));
12865 }
12866 }
12867
12868 let mut params = Params::with_capacity(9 + self._additional_params.len());
12869 params.push("project", self._project);
12870 params.push("location", self._location);
12871 params.push("managedZone", self._managed_zone);
12872 if let Some(value) = self._type_.as_ref() {
12873 params.push("type", value);
12874 }
12875 if let Some(value) = self._page_token.as_ref() {
12876 params.push("pageToken", value);
12877 }
12878 if let Some(value) = self._name.as_ref() {
12879 params.push("name", value);
12880 }
12881 if let Some(value) = self._max_results.as_ref() {
12882 params.push("maxResults", value.to_string());
12883 }
12884
12885 params.extend(self._additional_params.iter());
12886
12887 params.push("alt", "json");
12888 let mut url = self.hub._base_url.clone()
12889 + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/rrsets";
12890 if self._scopes.is_empty() {
12891 self._scopes
12892 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
12893 }
12894
12895 #[allow(clippy::single_element_loop)]
12896 for &(find_this, param_name) in [
12897 ("{project}", "project"),
12898 ("{location}", "location"),
12899 ("{managedZone}", "managedZone"),
12900 ]
12901 .iter()
12902 {
12903 url = params.uri_replacement(url, param_name, find_this, false);
12904 }
12905 {
12906 let to_remove = ["managedZone", "location", "project"];
12907 params.remove_params(&to_remove);
12908 }
12909
12910 let url = params.parse_with_url(&url);
12911
12912 loop {
12913 let token = match self
12914 .hub
12915 .auth
12916 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12917 .await
12918 {
12919 Ok(token) => token,
12920 Err(e) => match dlg.token(e) {
12921 Ok(token) => token,
12922 Err(e) => {
12923 dlg.finished(false);
12924 return Err(common::Error::MissingToken(e));
12925 }
12926 },
12927 };
12928 let mut req_result = {
12929 let client = &self.hub.client;
12930 dlg.pre_request();
12931 let mut req_builder = hyper::Request::builder()
12932 .method(hyper::Method::GET)
12933 .uri(url.as_str())
12934 .header(USER_AGENT, self.hub._user_agent.clone());
12935
12936 if let Some(token) = token.as_ref() {
12937 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12938 }
12939
12940 let request = req_builder
12941 .header(CONTENT_LENGTH, 0_u64)
12942 .body(common::to_body::<String>(None));
12943
12944 client.request(request.unwrap()).await
12945 };
12946
12947 match req_result {
12948 Err(err) => {
12949 if let common::Retry::After(d) = dlg.http_error(&err) {
12950 sleep(d).await;
12951 continue;
12952 }
12953 dlg.finished(false);
12954 return Err(common::Error::HttpError(err));
12955 }
12956 Ok(res) => {
12957 let (mut parts, body) = res.into_parts();
12958 let mut body = common::Body::new(body);
12959 if !parts.status.is_success() {
12960 let bytes = common::to_bytes(body).await.unwrap_or_default();
12961 let error = serde_json::from_str(&common::to_string(&bytes));
12962 let response = common::to_response(parts, bytes.into());
12963
12964 if let common::Retry::After(d) =
12965 dlg.http_failure(&response, error.as_ref().ok())
12966 {
12967 sleep(d).await;
12968 continue;
12969 }
12970
12971 dlg.finished(false);
12972
12973 return Err(match error {
12974 Ok(value) => common::Error::BadRequest(value),
12975 _ => common::Error::Failure(response),
12976 });
12977 }
12978 let response = {
12979 let bytes = common::to_bytes(body).await.unwrap_or_default();
12980 let encoded = common::to_string(&bytes);
12981 match serde_json::from_str(&encoded) {
12982 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12983 Err(error) => {
12984 dlg.response_json_decode_error(&encoded, &error);
12985 return Err(common::Error::JsonDecodeError(
12986 encoded.to_string(),
12987 error,
12988 ));
12989 }
12990 }
12991 };
12992
12993 dlg.finished(true);
12994 return Ok(response);
12995 }
12996 }
12997 }
12998 }
12999
13000 /// Identifies the project addressed by this request.
13001 ///
13002 /// Sets the *project* path property to the given value.
13003 ///
13004 /// Even though the property as already been set when instantiating this call,
13005 /// we provide this method for API completeness.
13006 pub fn project(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
13007 self._project = new_value.to_string();
13008 self
13009 }
13010 /// Specifies the location of the resource. This information is used for routing and is part of the resource name.
13011 ///
13012 /// Sets the *location* path property to the given value.
13013 ///
13014 /// Even though the property as already been set when instantiating this call,
13015 /// we provide this method for API completeness.
13016 pub fn location(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
13017 self._location = new_value.to_string();
13018 self
13019 }
13020 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
13021 ///
13022 /// Sets the *managed zone* path property to the given value.
13023 ///
13024 /// Even though the property as already been set when instantiating this call,
13025 /// we provide this method for API completeness.
13026 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
13027 self._managed_zone = new_value.to_string();
13028 self
13029 }
13030 /// Restricts the list to return only records of this type. If present, the "name" parameter must also be present. Mutually exclusive with the {@code filter} field.
13031 ///
13032 /// Sets the *type* query property to the given value.
13033 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
13034 self._type_ = Some(new_value.to_string());
13035 self
13036 }
13037 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
13038 ///
13039 /// Sets the *page token* query property to the given value.
13040 pub fn page_token(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
13041 self._page_token = Some(new_value.to_string());
13042 self
13043 }
13044 /// Restricts the list to return only records with this fully qualified domain name. Mutually exclusive with the {@code filter} field.
13045 ///
13046 /// Sets the *name* query property to the given value.
13047 pub fn name(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
13048 self._name = Some(new_value.to_string());
13049 self
13050 }
13051 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
13052 ///
13053 /// Sets the *max results* query property to the given value.
13054 pub fn max_results(mut self, new_value: i32) -> ResourceRecordSetListCall<'a, C> {
13055 self._max_results = Some(new_value);
13056 self
13057 }
13058 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13059 /// while executing the actual API request.
13060 ///
13061 /// ````text
13062 /// It should be used to handle progress information, and to implement a certain level of resilience.
13063 /// ````
13064 ///
13065 /// Sets the *delegate* property to the given value.
13066 pub fn delegate(
13067 mut self,
13068 new_value: &'a mut dyn common::Delegate,
13069 ) -> ResourceRecordSetListCall<'a, C> {
13070 self._delegate = Some(new_value);
13071 self
13072 }
13073
13074 /// Set any additional parameter of the query string used in the request.
13075 /// It should be used to set parameters which are not yet available through their own
13076 /// setters.
13077 ///
13078 /// Please note that this method must not be used to set any of the known parameters
13079 /// which have their own setter method. If done anyway, the request will fail.
13080 ///
13081 /// # Additional Parameters
13082 ///
13083 /// * *$.xgafv* (query-string) - V1 error format.
13084 /// * *access_token* (query-string) - OAuth access token.
13085 /// * *alt* (query-string) - Data format for response.
13086 /// * *callback* (query-string) - JSONP
13087 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13088 /// * *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.
13089 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13090 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13091 /// * *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.
13092 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13093 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13094 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetListCall<'a, C>
13095 where
13096 T: AsRef<str>,
13097 {
13098 self._additional_params
13099 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13100 self
13101 }
13102
13103 /// Identifies the authorization scope for the method you are building.
13104 ///
13105 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13106 /// [`Scope::NdevClouddnReadonly`].
13107 ///
13108 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13109 /// tokens for more than one scope.
13110 ///
13111 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13112 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13113 /// sufficient, a read-write scope will do as well.
13114 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetListCall<'a, C>
13115 where
13116 St: AsRef<str>,
13117 {
13118 self._scopes.insert(String::from(scope.as_ref()));
13119 self
13120 }
13121 /// Identifies the authorization scope(s) for the method you are building.
13122 ///
13123 /// See [`Self::add_scope()`] for details.
13124 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetListCall<'a, C>
13125 where
13126 I: IntoIterator<Item = St>,
13127 St: AsRef<str>,
13128 {
13129 self._scopes
13130 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13131 self
13132 }
13133
13134 /// Removes all scopes, and no default scope will be used either.
13135 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13136 /// for details).
13137 pub fn clear_scopes(mut self) -> ResourceRecordSetListCall<'a, C> {
13138 self._scopes.clear();
13139 self
13140 }
13141}
13142
13143/// Applies a partial update to an existing ResourceRecordSet.
13144///
13145/// A builder for the *patch* method supported by a *resourceRecordSet* resource.
13146/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
13147///
13148/// # Example
13149///
13150/// Instantiate a resource method builder
13151///
13152/// ```test_harness,no_run
13153/// # extern crate hyper;
13154/// # extern crate hyper_rustls;
13155/// # extern crate google_dns2 as dns2;
13156/// use dns2::api::ResourceRecordSet;
13157/// # async fn dox() {
13158/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13159///
13160/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13161/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13162/// # .with_native_roots()
13163/// # .unwrap()
13164/// # .https_only()
13165/// # .enable_http2()
13166/// # .build();
13167///
13168/// # let executor = hyper_util::rt::TokioExecutor::new();
13169/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13170/// # secret,
13171/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13172/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13173/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13174/// # ),
13175/// # ).build().await.unwrap();
13176///
13177/// # let client = hyper_util::client::legacy::Client::builder(
13178/// # hyper_util::rt::TokioExecutor::new()
13179/// # )
13180/// # .build(
13181/// # hyper_rustls::HttpsConnectorBuilder::new()
13182/// # .with_native_roots()
13183/// # .unwrap()
13184/// # .https_or_http()
13185/// # .enable_http2()
13186/// # .build()
13187/// # );
13188/// # let mut hub = Dns::new(client, auth);
13189/// // As the method needs a request, you would usually fill it with the desired information
13190/// // into the respective structure. Some of the parts shown here might not be applicable !
13191/// // Values shown here are possibly random and not representative !
13192/// let mut req = ResourceRecordSet::default();
13193///
13194/// // You can configure optional parameters by calling the respective setters at will, and
13195/// // execute the final call using `doit()`.
13196/// // Values shown here are possibly random and not representative !
13197/// let result = hub.resource_record_sets().patch(req, "project", "location", "managedZone", "name", "type")
13198/// .client_operation_id("consetetur")
13199/// .doit().await;
13200/// # }
13201/// ```
13202pub struct ResourceRecordSetPatchCall<'a, C>
13203where
13204 C: 'a,
13205{
13206 hub: &'a Dns<C>,
13207 _request: ResourceRecordSet,
13208 _project: String,
13209 _location: String,
13210 _managed_zone: String,
13211 _name: String,
13212 _type_: String,
13213 _client_operation_id: Option<String>,
13214 _delegate: Option<&'a mut dyn common::Delegate>,
13215 _additional_params: HashMap<String, String>,
13216 _scopes: BTreeSet<String>,
13217}
13218
13219impl<'a, C> common::CallBuilder for ResourceRecordSetPatchCall<'a, C> {}
13220
13221impl<'a, C> ResourceRecordSetPatchCall<'a, C>
13222where
13223 C: common::Connector,
13224{
13225 /// Perform the operation you have build so far.
13226 pub async fn doit(mut self) -> common::Result<(common::Response, ResourceRecordSet)> {
13227 use std::borrow::Cow;
13228 use std::io::{Read, Seek};
13229
13230 use common::{url::Params, ToParts};
13231 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13232
13233 let mut dd = common::DefaultDelegate;
13234 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13235 dlg.begin(common::MethodInfo {
13236 id: "dns.resourceRecordSets.patch",
13237 http_method: hyper::Method::PATCH,
13238 });
13239
13240 for &field in [
13241 "alt",
13242 "project",
13243 "location",
13244 "managedZone",
13245 "name",
13246 "type",
13247 "clientOperationId",
13248 ]
13249 .iter()
13250 {
13251 if self._additional_params.contains_key(field) {
13252 dlg.finished(false);
13253 return Err(common::Error::FieldClash(field));
13254 }
13255 }
13256
13257 let mut params = Params::with_capacity(9 + self._additional_params.len());
13258 params.push("project", self._project);
13259 params.push("location", self._location);
13260 params.push("managedZone", self._managed_zone);
13261 params.push("name", self._name);
13262 params.push("type", self._type_);
13263 if let Some(value) = self._client_operation_id.as_ref() {
13264 params.push("clientOperationId", value);
13265 }
13266
13267 params.extend(self._additional_params.iter());
13268
13269 params.push("alt", "json");
13270 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/managedZones/{managedZone}/rrsets/{name}/{type}";
13271 if self._scopes.is_empty() {
13272 self._scopes
13273 .insert(Scope::CloudPlatform.as_ref().to_string());
13274 }
13275
13276 #[allow(clippy::single_element_loop)]
13277 for &(find_this, param_name) in [
13278 ("{project}", "project"),
13279 ("{location}", "location"),
13280 ("{managedZone}", "managedZone"),
13281 ("{name}", "name"),
13282 ("{type}", "type"),
13283 ]
13284 .iter()
13285 {
13286 url = params.uri_replacement(url, param_name, find_this, false);
13287 }
13288 {
13289 let to_remove = ["type", "name", "managedZone", "location", "project"];
13290 params.remove_params(&to_remove);
13291 }
13292
13293 let url = params.parse_with_url(&url);
13294
13295 let mut json_mime_type = mime::APPLICATION_JSON;
13296 let mut request_value_reader = {
13297 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13298 common::remove_json_null_values(&mut value);
13299 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13300 serde_json::to_writer(&mut dst, &value).unwrap();
13301 dst
13302 };
13303 let request_size = request_value_reader
13304 .seek(std::io::SeekFrom::End(0))
13305 .unwrap();
13306 request_value_reader
13307 .seek(std::io::SeekFrom::Start(0))
13308 .unwrap();
13309
13310 loop {
13311 let token = match self
13312 .hub
13313 .auth
13314 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13315 .await
13316 {
13317 Ok(token) => token,
13318 Err(e) => match dlg.token(e) {
13319 Ok(token) => token,
13320 Err(e) => {
13321 dlg.finished(false);
13322 return Err(common::Error::MissingToken(e));
13323 }
13324 },
13325 };
13326 request_value_reader
13327 .seek(std::io::SeekFrom::Start(0))
13328 .unwrap();
13329 let mut req_result = {
13330 let client = &self.hub.client;
13331 dlg.pre_request();
13332 let mut req_builder = hyper::Request::builder()
13333 .method(hyper::Method::PATCH)
13334 .uri(url.as_str())
13335 .header(USER_AGENT, self.hub._user_agent.clone());
13336
13337 if let Some(token) = token.as_ref() {
13338 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13339 }
13340
13341 let request = req_builder
13342 .header(CONTENT_TYPE, json_mime_type.to_string())
13343 .header(CONTENT_LENGTH, request_size as u64)
13344 .body(common::to_body(
13345 request_value_reader.get_ref().clone().into(),
13346 ));
13347
13348 client.request(request.unwrap()).await
13349 };
13350
13351 match req_result {
13352 Err(err) => {
13353 if let common::Retry::After(d) = dlg.http_error(&err) {
13354 sleep(d).await;
13355 continue;
13356 }
13357 dlg.finished(false);
13358 return Err(common::Error::HttpError(err));
13359 }
13360 Ok(res) => {
13361 let (mut parts, body) = res.into_parts();
13362 let mut body = common::Body::new(body);
13363 if !parts.status.is_success() {
13364 let bytes = common::to_bytes(body).await.unwrap_or_default();
13365 let error = serde_json::from_str(&common::to_string(&bytes));
13366 let response = common::to_response(parts, bytes.into());
13367
13368 if let common::Retry::After(d) =
13369 dlg.http_failure(&response, error.as_ref().ok())
13370 {
13371 sleep(d).await;
13372 continue;
13373 }
13374
13375 dlg.finished(false);
13376
13377 return Err(match error {
13378 Ok(value) => common::Error::BadRequest(value),
13379 _ => common::Error::Failure(response),
13380 });
13381 }
13382 let response = {
13383 let bytes = common::to_bytes(body).await.unwrap_or_default();
13384 let encoded = common::to_string(&bytes);
13385 match serde_json::from_str(&encoded) {
13386 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13387 Err(error) => {
13388 dlg.response_json_decode_error(&encoded, &error);
13389 return Err(common::Error::JsonDecodeError(
13390 encoded.to_string(),
13391 error,
13392 ));
13393 }
13394 }
13395 };
13396
13397 dlg.finished(true);
13398 return Ok(response);
13399 }
13400 }
13401 }
13402 }
13403
13404 ///
13405 /// Sets the *request* property to the given value.
13406 ///
13407 /// Even though the property as already been set when instantiating this call,
13408 /// we provide this method for API completeness.
13409 pub fn request(mut self, new_value: ResourceRecordSet) -> ResourceRecordSetPatchCall<'a, C> {
13410 self._request = new_value;
13411 self
13412 }
13413 /// Identifies the project addressed by this request.
13414 ///
13415 /// Sets the *project* path property to the given value.
13416 ///
13417 /// Even though the property as already been set when instantiating this call,
13418 /// we provide this method for API completeness.
13419 pub fn project(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
13420 self._project = new_value.to_string();
13421 self
13422 }
13423 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
13424 ///
13425 /// Sets the *location* path property to the given value.
13426 ///
13427 /// Even though the property as already been set when instantiating this call,
13428 /// we provide this method for API completeness.
13429 pub fn location(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
13430 self._location = new_value.to_string();
13431 self
13432 }
13433 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
13434 ///
13435 /// Sets the *managed zone* path property to the given value.
13436 ///
13437 /// Even though the property as already been set when instantiating this call,
13438 /// we provide this method for API completeness.
13439 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
13440 self._managed_zone = new_value.to_string();
13441 self
13442 }
13443 /// Fully qualified domain name.
13444 ///
13445 /// Sets the *name* path property to the given value.
13446 ///
13447 /// Even though the property as already been set when instantiating this call,
13448 /// we provide this method for API completeness.
13449 pub fn name(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
13450 self._name = new_value.to_string();
13451 self
13452 }
13453 /// RRSet type.
13454 ///
13455 /// Sets the *type* path property to the given value.
13456 ///
13457 /// Even though the property as already been set when instantiating this call,
13458 /// we provide this method for API completeness.
13459 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
13460 self._type_ = new_value.to_string();
13461 self
13462 }
13463 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
13464 ///
13465 /// Sets the *client operation id* query property to the given value.
13466 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
13467 self._client_operation_id = Some(new_value.to_string());
13468 self
13469 }
13470 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13471 /// while executing the actual API request.
13472 ///
13473 /// ````text
13474 /// It should be used to handle progress information, and to implement a certain level of resilience.
13475 /// ````
13476 ///
13477 /// Sets the *delegate* property to the given value.
13478 pub fn delegate(
13479 mut self,
13480 new_value: &'a mut dyn common::Delegate,
13481 ) -> ResourceRecordSetPatchCall<'a, C> {
13482 self._delegate = Some(new_value);
13483 self
13484 }
13485
13486 /// Set any additional parameter of the query string used in the request.
13487 /// It should be used to set parameters which are not yet available through their own
13488 /// setters.
13489 ///
13490 /// Please note that this method must not be used to set any of the known parameters
13491 /// which have their own setter method. If done anyway, the request will fail.
13492 ///
13493 /// # Additional Parameters
13494 ///
13495 /// * *$.xgafv* (query-string) - V1 error format.
13496 /// * *access_token* (query-string) - OAuth access token.
13497 /// * *alt* (query-string) - Data format for response.
13498 /// * *callback* (query-string) - JSONP
13499 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13500 /// * *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.
13501 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13502 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13503 /// * *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.
13504 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13505 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13506 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetPatchCall<'a, C>
13507 where
13508 T: AsRef<str>,
13509 {
13510 self._additional_params
13511 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13512 self
13513 }
13514
13515 /// Identifies the authorization scope for the method you are building.
13516 ///
13517 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13518 /// [`Scope::CloudPlatform`].
13519 ///
13520 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13521 /// tokens for more than one scope.
13522 ///
13523 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13524 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13525 /// sufficient, a read-write scope will do as well.
13526 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetPatchCall<'a, C>
13527 where
13528 St: AsRef<str>,
13529 {
13530 self._scopes.insert(String::from(scope.as_ref()));
13531 self
13532 }
13533 /// Identifies the authorization scope(s) for the method you are building.
13534 ///
13535 /// See [`Self::add_scope()`] for details.
13536 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetPatchCall<'a, C>
13537 where
13538 I: IntoIterator<Item = St>,
13539 St: AsRef<str>,
13540 {
13541 self._scopes
13542 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13543 self
13544 }
13545
13546 /// Removes all scopes, and no default scope will be used either.
13547 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13548 /// for details).
13549 pub fn clear_scopes(mut self) -> ResourceRecordSetPatchCall<'a, C> {
13550 self._scopes.clear();
13551 self
13552 }
13553}
13554
13555/// Creates a new Response Policy
13556///
13557/// A builder for the *create* method supported by a *responsePolicy* resource.
13558/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
13559///
13560/// # Example
13561///
13562/// Instantiate a resource method builder
13563///
13564/// ```test_harness,no_run
13565/// # extern crate hyper;
13566/// # extern crate hyper_rustls;
13567/// # extern crate google_dns2 as dns2;
13568/// use dns2::api::ResponsePolicy;
13569/// # async fn dox() {
13570/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13571///
13572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13574/// # .with_native_roots()
13575/// # .unwrap()
13576/// # .https_only()
13577/// # .enable_http2()
13578/// # .build();
13579///
13580/// # let executor = hyper_util::rt::TokioExecutor::new();
13581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13582/// # secret,
13583/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13584/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13585/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13586/// # ),
13587/// # ).build().await.unwrap();
13588///
13589/// # let client = hyper_util::client::legacy::Client::builder(
13590/// # hyper_util::rt::TokioExecutor::new()
13591/// # )
13592/// # .build(
13593/// # hyper_rustls::HttpsConnectorBuilder::new()
13594/// # .with_native_roots()
13595/// # .unwrap()
13596/// # .https_or_http()
13597/// # .enable_http2()
13598/// # .build()
13599/// # );
13600/// # let mut hub = Dns::new(client, auth);
13601/// // As the method needs a request, you would usually fill it with the desired information
13602/// // into the respective structure. Some of the parts shown here might not be applicable !
13603/// // Values shown here are possibly random and not representative !
13604/// let mut req = ResponsePolicy::default();
13605///
13606/// // You can configure optional parameters by calling the respective setters at will, and
13607/// // execute the final call using `doit()`.
13608/// // Values shown here are possibly random and not representative !
13609/// let result = hub.response_policies().create(req, "project", "location")
13610/// .client_operation_id("est")
13611/// .doit().await;
13612/// # }
13613/// ```
13614pub struct ResponsePolicyCreateCall<'a, C>
13615where
13616 C: 'a,
13617{
13618 hub: &'a Dns<C>,
13619 _request: ResponsePolicy,
13620 _project: String,
13621 _location: String,
13622 _client_operation_id: Option<String>,
13623 _delegate: Option<&'a mut dyn common::Delegate>,
13624 _additional_params: HashMap<String, String>,
13625 _scopes: BTreeSet<String>,
13626}
13627
13628impl<'a, C> common::CallBuilder for ResponsePolicyCreateCall<'a, C> {}
13629
13630impl<'a, C> ResponsePolicyCreateCall<'a, C>
13631where
13632 C: common::Connector,
13633{
13634 /// Perform the operation you have build so far.
13635 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicy)> {
13636 use std::borrow::Cow;
13637 use std::io::{Read, Seek};
13638
13639 use common::{url::Params, ToParts};
13640 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13641
13642 let mut dd = common::DefaultDelegate;
13643 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13644 dlg.begin(common::MethodInfo {
13645 id: "dns.responsePolicies.create",
13646 http_method: hyper::Method::POST,
13647 });
13648
13649 for &field in ["alt", "project", "location", "clientOperationId"].iter() {
13650 if self._additional_params.contains_key(field) {
13651 dlg.finished(false);
13652 return Err(common::Error::FieldClash(field));
13653 }
13654 }
13655
13656 let mut params = Params::with_capacity(6 + self._additional_params.len());
13657 params.push("project", self._project);
13658 params.push("location", self._location);
13659 if let Some(value) = self._client_operation_id.as_ref() {
13660 params.push("clientOperationId", value);
13661 }
13662
13663 params.extend(self._additional_params.iter());
13664
13665 params.push("alt", "json");
13666 let mut url = self.hub._base_url.clone()
13667 + "dns/v2/projects/{project}/locations/{location}/responsePolicies";
13668 if self._scopes.is_empty() {
13669 self._scopes
13670 .insert(Scope::CloudPlatform.as_ref().to_string());
13671 }
13672
13673 #[allow(clippy::single_element_loop)]
13674 for &(find_this, param_name) in
13675 [("{project}", "project"), ("{location}", "location")].iter()
13676 {
13677 url = params.uri_replacement(url, param_name, find_this, false);
13678 }
13679 {
13680 let to_remove = ["location", "project"];
13681 params.remove_params(&to_remove);
13682 }
13683
13684 let url = params.parse_with_url(&url);
13685
13686 let mut json_mime_type = mime::APPLICATION_JSON;
13687 let mut request_value_reader = {
13688 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13689 common::remove_json_null_values(&mut value);
13690 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13691 serde_json::to_writer(&mut dst, &value).unwrap();
13692 dst
13693 };
13694 let request_size = request_value_reader
13695 .seek(std::io::SeekFrom::End(0))
13696 .unwrap();
13697 request_value_reader
13698 .seek(std::io::SeekFrom::Start(0))
13699 .unwrap();
13700
13701 loop {
13702 let token = match self
13703 .hub
13704 .auth
13705 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13706 .await
13707 {
13708 Ok(token) => token,
13709 Err(e) => match dlg.token(e) {
13710 Ok(token) => token,
13711 Err(e) => {
13712 dlg.finished(false);
13713 return Err(common::Error::MissingToken(e));
13714 }
13715 },
13716 };
13717 request_value_reader
13718 .seek(std::io::SeekFrom::Start(0))
13719 .unwrap();
13720 let mut req_result = {
13721 let client = &self.hub.client;
13722 dlg.pre_request();
13723 let mut req_builder = hyper::Request::builder()
13724 .method(hyper::Method::POST)
13725 .uri(url.as_str())
13726 .header(USER_AGENT, self.hub._user_agent.clone());
13727
13728 if let Some(token) = token.as_ref() {
13729 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13730 }
13731
13732 let request = req_builder
13733 .header(CONTENT_TYPE, json_mime_type.to_string())
13734 .header(CONTENT_LENGTH, request_size as u64)
13735 .body(common::to_body(
13736 request_value_reader.get_ref().clone().into(),
13737 ));
13738
13739 client.request(request.unwrap()).await
13740 };
13741
13742 match req_result {
13743 Err(err) => {
13744 if let common::Retry::After(d) = dlg.http_error(&err) {
13745 sleep(d).await;
13746 continue;
13747 }
13748 dlg.finished(false);
13749 return Err(common::Error::HttpError(err));
13750 }
13751 Ok(res) => {
13752 let (mut parts, body) = res.into_parts();
13753 let mut body = common::Body::new(body);
13754 if !parts.status.is_success() {
13755 let bytes = common::to_bytes(body).await.unwrap_or_default();
13756 let error = serde_json::from_str(&common::to_string(&bytes));
13757 let response = common::to_response(parts, bytes.into());
13758
13759 if let common::Retry::After(d) =
13760 dlg.http_failure(&response, error.as_ref().ok())
13761 {
13762 sleep(d).await;
13763 continue;
13764 }
13765
13766 dlg.finished(false);
13767
13768 return Err(match error {
13769 Ok(value) => common::Error::BadRequest(value),
13770 _ => common::Error::Failure(response),
13771 });
13772 }
13773 let response = {
13774 let bytes = common::to_bytes(body).await.unwrap_or_default();
13775 let encoded = common::to_string(&bytes);
13776 match serde_json::from_str(&encoded) {
13777 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13778 Err(error) => {
13779 dlg.response_json_decode_error(&encoded, &error);
13780 return Err(common::Error::JsonDecodeError(
13781 encoded.to_string(),
13782 error,
13783 ));
13784 }
13785 }
13786 };
13787
13788 dlg.finished(true);
13789 return Ok(response);
13790 }
13791 }
13792 }
13793 }
13794
13795 ///
13796 /// Sets the *request* property to the given value.
13797 ///
13798 /// Even though the property as already been set when instantiating this call,
13799 /// we provide this method for API completeness.
13800 pub fn request(mut self, new_value: ResponsePolicy) -> ResponsePolicyCreateCall<'a, C> {
13801 self._request = new_value;
13802 self
13803 }
13804 /// Identifies the project addressed by this request.
13805 ///
13806 /// Sets the *project* path property to the given value.
13807 ///
13808 /// Even though the property as already been set when instantiating this call,
13809 /// we provide this method for API completeness.
13810 pub fn project(mut self, new_value: &str) -> ResponsePolicyCreateCall<'a, C> {
13811 self._project = new_value.to_string();
13812 self
13813 }
13814 /// Specifies the location of the resource, only applicable in the v APIs. This information will be used for routing and will be part of the resource name.
13815 ///
13816 /// Sets the *location* path property to the given value.
13817 ///
13818 /// Even though the property as already been set when instantiating this call,
13819 /// we provide this method for API completeness.
13820 pub fn location(mut self, new_value: &str) -> ResponsePolicyCreateCall<'a, C> {
13821 self._location = new_value.to_string();
13822 self
13823 }
13824 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
13825 ///
13826 /// Sets the *client operation id* query property to the given value.
13827 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyCreateCall<'a, C> {
13828 self._client_operation_id = Some(new_value.to_string());
13829 self
13830 }
13831 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13832 /// while executing the actual API request.
13833 ///
13834 /// ````text
13835 /// It should be used to handle progress information, and to implement a certain level of resilience.
13836 /// ````
13837 ///
13838 /// Sets the *delegate* property to the given value.
13839 pub fn delegate(
13840 mut self,
13841 new_value: &'a mut dyn common::Delegate,
13842 ) -> ResponsePolicyCreateCall<'a, C> {
13843 self._delegate = Some(new_value);
13844 self
13845 }
13846
13847 /// Set any additional parameter of the query string used in the request.
13848 /// It should be used to set parameters which are not yet available through their own
13849 /// setters.
13850 ///
13851 /// Please note that this method must not be used to set any of the known parameters
13852 /// which have their own setter method. If done anyway, the request will fail.
13853 ///
13854 /// # Additional Parameters
13855 ///
13856 /// * *$.xgafv* (query-string) - V1 error format.
13857 /// * *access_token* (query-string) - OAuth access token.
13858 /// * *alt* (query-string) - Data format for response.
13859 /// * *callback* (query-string) - JSONP
13860 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13861 /// * *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.
13862 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13863 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13864 /// * *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.
13865 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13866 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13867 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyCreateCall<'a, C>
13868 where
13869 T: AsRef<str>,
13870 {
13871 self._additional_params
13872 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13873 self
13874 }
13875
13876 /// Identifies the authorization scope for the method you are building.
13877 ///
13878 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13879 /// [`Scope::CloudPlatform`].
13880 ///
13881 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13882 /// tokens for more than one scope.
13883 ///
13884 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13885 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13886 /// sufficient, a read-write scope will do as well.
13887 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyCreateCall<'a, C>
13888 where
13889 St: AsRef<str>,
13890 {
13891 self._scopes.insert(String::from(scope.as_ref()));
13892 self
13893 }
13894 /// Identifies the authorization scope(s) for the method you are building.
13895 ///
13896 /// See [`Self::add_scope()`] for details.
13897 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyCreateCall<'a, C>
13898 where
13899 I: IntoIterator<Item = St>,
13900 St: AsRef<str>,
13901 {
13902 self._scopes
13903 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13904 self
13905 }
13906
13907 /// Removes all scopes, and no default scope will be used either.
13908 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13909 /// for details).
13910 pub fn clear_scopes(mut self) -> ResponsePolicyCreateCall<'a, C> {
13911 self._scopes.clear();
13912 self
13913 }
13914}
13915
13916/// Deletes a previously created Response Policy. Fails if the response policy is non-empty or still being referenced by a network.
13917///
13918/// A builder for the *delete* method supported by a *responsePolicy* resource.
13919/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
13920///
13921/// # Example
13922///
13923/// Instantiate a resource method builder
13924///
13925/// ```test_harness,no_run
13926/// # extern crate hyper;
13927/// # extern crate hyper_rustls;
13928/// # extern crate google_dns2 as dns2;
13929/// # async fn dox() {
13930/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13931///
13932/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13933/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13934/// # .with_native_roots()
13935/// # .unwrap()
13936/// # .https_only()
13937/// # .enable_http2()
13938/// # .build();
13939///
13940/// # let executor = hyper_util::rt::TokioExecutor::new();
13941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13942/// # secret,
13943/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13944/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13945/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13946/// # ),
13947/// # ).build().await.unwrap();
13948///
13949/// # let client = hyper_util::client::legacy::Client::builder(
13950/// # hyper_util::rt::TokioExecutor::new()
13951/// # )
13952/// # .build(
13953/// # hyper_rustls::HttpsConnectorBuilder::new()
13954/// # .with_native_roots()
13955/// # .unwrap()
13956/// # .https_or_http()
13957/// # .enable_http2()
13958/// # .build()
13959/// # );
13960/// # let mut hub = Dns::new(client, auth);
13961/// // You can configure optional parameters by calling the respective setters at will, and
13962/// // execute the final call using `doit()`.
13963/// // Values shown here are possibly random and not representative !
13964/// let result = hub.response_policies().delete("project", "location", "responsePolicy")
13965/// .client_operation_id("diam")
13966/// .doit().await;
13967/// # }
13968/// ```
13969pub struct ResponsePolicyDeleteCall<'a, C>
13970where
13971 C: 'a,
13972{
13973 hub: &'a Dns<C>,
13974 _project: String,
13975 _location: String,
13976 _response_policy: String,
13977 _client_operation_id: Option<String>,
13978 _delegate: Option<&'a mut dyn common::Delegate>,
13979 _additional_params: HashMap<String, String>,
13980 _scopes: BTreeSet<String>,
13981}
13982
13983impl<'a, C> common::CallBuilder for ResponsePolicyDeleteCall<'a, C> {}
13984
13985impl<'a, C> ResponsePolicyDeleteCall<'a, C>
13986where
13987 C: common::Connector,
13988{
13989 /// Perform the operation you have build so far.
13990 pub async fn doit(mut self) -> common::Result<common::Response> {
13991 use std::borrow::Cow;
13992 use std::io::{Read, Seek};
13993
13994 use common::{url::Params, ToParts};
13995 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13996
13997 let mut dd = common::DefaultDelegate;
13998 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13999 dlg.begin(common::MethodInfo {
14000 id: "dns.responsePolicies.delete",
14001 http_method: hyper::Method::DELETE,
14002 });
14003
14004 for &field in ["project", "location", "responsePolicy", "clientOperationId"].iter() {
14005 if self._additional_params.contains_key(field) {
14006 dlg.finished(false);
14007 return Err(common::Error::FieldClash(field));
14008 }
14009 }
14010
14011 let mut params = Params::with_capacity(5 + self._additional_params.len());
14012 params.push("project", self._project);
14013 params.push("location", self._location);
14014 params.push("responsePolicy", self._response_policy);
14015 if let Some(value) = self._client_operation_id.as_ref() {
14016 params.push("clientOperationId", value);
14017 }
14018
14019 params.extend(self._additional_params.iter());
14020
14021 let mut url = self.hub._base_url.clone()
14022 + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}";
14023 if self._scopes.is_empty() {
14024 self._scopes
14025 .insert(Scope::CloudPlatform.as_ref().to_string());
14026 }
14027
14028 #[allow(clippy::single_element_loop)]
14029 for &(find_this, param_name) in [
14030 ("{project}", "project"),
14031 ("{location}", "location"),
14032 ("{responsePolicy}", "responsePolicy"),
14033 ]
14034 .iter()
14035 {
14036 url = params.uri_replacement(url, param_name, find_this, false);
14037 }
14038 {
14039 let to_remove = ["responsePolicy", "location", "project"];
14040 params.remove_params(&to_remove);
14041 }
14042
14043 let url = params.parse_with_url(&url);
14044
14045 loop {
14046 let token = match self
14047 .hub
14048 .auth
14049 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14050 .await
14051 {
14052 Ok(token) => token,
14053 Err(e) => match dlg.token(e) {
14054 Ok(token) => token,
14055 Err(e) => {
14056 dlg.finished(false);
14057 return Err(common::Error::MissingToken(e));
14058 }
14059 },
14060 };
14061 let mut req_result = {
14062 let client = &self.hub.client;
14063 dlg.pre_request();
14064 let mut req_builder = hyper::Request::builder()
14065 .method(hyper::Method::DELETE)
14066 .uri(url.as_str())
14067 .header(USER_AGENT, self.hub._user_agent.clone());
14068
14069 if let Some(token) = token.as_ref() {
14070 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14071 }
14072
14073 let request = req_builder
14074 .header(CONTENT_LENGTH, 0_u64)
14075 .body(common::to_body::<String>(None));
14076
14077 client.request(request.unwrap()).await
14078 };
14079
14080 match req_result {
14081 Err(err) => {
14082 if let common::Retry::After(d) = dlg.http_error(&err) {
14083 sleep(d).await;
14084 continue;
14085 }
14086 dlg.finished(false);
14087 return Err(common::Error::HttpError(err));
14088 }
14089 Ok(res) => {
14090 let (mut parts, body) = res.into_parts();
14091 let mut body = common::Body::new(body);
14092 if !parts.status.is_success() {
14093 let bytes = common::to_bytes(body).await.unwrap_or_default();
14094 let error = serde_json::from_str(&common::to_string(&bytes));
14095 let response = common::to_response(parts, bytes.into());
14096
14097 if let common::Retry::After(d) =
14098 dlg.http_failure(&response, error.as_ref().ok())
14099 {
14100 sleep(d).await;
14101 continue;
14102 }
14103
14104 dlg.finished(false);
14105
14106 return Err(match error {
14107 Ok(value) => common::Error::BadRequest(value),
14108 _ => common::Error::Failure(response),
14109 });
14110 }
14111 let response = common::Response::from_parts(parts, body);
14112
14113 dlg.finished(true);
14114 return Ok(response);
14115 }
14116 }
14117 }
14118 }
14119
14120 /// Identifies the project addressed by this request.
14121 ///
14122 /// Sets the *project* path property to the given value.
14123 ///
14124 /// Even though the property as already been set when instantiating this call,
14125 /// we provide this method for API completeness.
14126 pub fn project(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
14127 self._project = new_value.to_string();
14128 self
14129 }
14130 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
14131 ///
14132 /// Sets the *location* path property to the given value.
14133 ///
14134 /// Even though the property as already been set when instantiating this call,
14135 /// we provide this method for API completeness.
14136 pub fn location(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
14137 self._location = new_value.to_string();
14138 self
14139 }
14140 /// User assigned name of the Response Policy addressed by this request.
14141 ///
14142 /// Sets the *response policy* path property to the given value.
14143 ///
14144 /// Even though the property as already been set when instantiating this call,
14145 /// we provide this method for API completeness.
14146 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
14147 self._response_policy = new_value.to_string();
14148 self
14149 }
14150 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
14151 ///
14152 /// Sets the *client operation id* query property to the given value.
14153 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
14154 self._client_operation_id = Some(new_value.to_string());
14155 self
14156 }
14157 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14158 /// while executing the actual API request.
14159 ///
14160 /// ````text
14161 /// It should be used to handle progress information, and to implement a certain level of resilience.
14162 /// ````
14163 ///
14164 /// Sets the *delegate* property to the given value.
14165 pub fn delegate(
14166 mut self,
14167 new_value: &'a mut dyn common::Delegate,
14168 ) -> ResponsePolicyDeleteCall<'a, C> {
14169 self._delegate = Some(new_value);
14170 self
14171 }
14172
14173 /// Set any additional parameter of the query string used in the request.
14174 /// It should be used to set parameters which are not yet available through their own
14175 /// setters.
14176 ///
14177 /// Please note that this method must not be used to set any of the known parameters
14178 /// which have their own setter method. If done anyway, the request will fail.
14179 ///
14180 /// # Additional Parameters
14181 ///
14182 /// * *$.xgafv* (query-string) - V1 error format.
14183 /// * *access_token* (query-string) - OAuth access token.
14184 /// * *alt* (query-string) - Data format for response.
14185 /// * *callback* (query-string) - JSONP
14186 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14187 /// * *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.
14188 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14189 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14190 /// * *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.
14191 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14192 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14193 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyDeleteCall<'a, C>
14194 where
14195 T: AsRef<str>,
14196 {
14197 self._additional_params
14198 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14199 self
14200 }
14201
14202 /// Identifies the authorization scope for the method you are building.
14203 ///
14204 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14205 /// [`Scope::CloudPlatform`].
14206 ///
14207 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14208 /// tokens for more than one scope.
14209 ///
14210 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14211 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14212 /// sufficient, a read-write scope will do as well.
14213 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyDeleteCall<'a, C>
14214 where
14215 St: AsRef<str>,
14216 {
14217 self._scopes.insert(String::from(scope.as_ref()));
14218 self
14219 }
14220 /// Identifies the authorization scope(s) for the method you are building.
14221 ///
14222 /// See [`Self::add_scope()`] for details.
14223 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyDeleteCall<'a, C>
14224 where
14225 I: IntoIterator<Item = St>,
14226 St: AsRef<str>,
14227 {
14228 self._scopes
14229 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14230 self
14231 }
14232
14233 /// Removes all scopes, and no default scope will be used either.
14234 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14235 /// for details).
14236 pub fn clear_scopes(mut self) -> ResponsePolicyDeleteCall<'a, C> {
14237 self._scopes.clear();
14238 self
14239 }
14240}
14241
14242/// Fetches the representation of an existing Response Policy.
14243///
14244/// A builder for the *get* method supported by a *responsePolicy* resource.
14245/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
14246///
14247/// # Example
14248///
14249/// Instantiate a resource method builder
14250///
14251/// ```test_harness,no_run
14252/// # extern crate hyper;
14253/// # extern crate hyper_rustls;
14254/// # extern crate google_dns2 as dns2;
14255/// # async fn dox() {
14256/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14257///
14258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14260/// # .with_native_roots()
14261/// # .unwrap()
14262/// # .https_only()
14263/// # .enable_http2()
14264/// # .build();
14265///
14266/// # let executor = hyper_util::rt::TokioExecutor::new();
14267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14268/// # secret,
14269/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14270/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14271/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14272/// # ),
14273/// # ).build().await.unwrap();
14274///
14275/// # let client = hyper_util::client::legacy::Client::builder(
14276/// # hyper_util::rt::TokioExecutor::new()
14277/// # )
14278/// # .build(
14279/// # hyper_rustls::HttpsConnectorBuilder::new()
14280/// # .with_native_roots()
14281/// # .unwrap()
14282/// # .https_or_http()
14283/// # .enable_http2()
14284/// # .build()
14285/// # );
14286/// # let mut hub = Dns::new(client, auth);
14287/// // You can configure optional parameters by calling the respective setters at will, and
14288/// // execute the final call using `doit()`.
14289/// // Values shown here are possibly random and not representative !
14290/// let result = hub.response_policies().get("project", "location", "responsePolicy")
14291/// .client_operation_id("eos")
14292/// .doit().await;
14293/// # }
14294/// ```
14295pub struct ResponsePolicyGetCall<'a, C>
14296where
14297 C: 'a,
14298{
14299 hub: &'a Dns<C>,
14300 _project: String,
14301 _location: String,
14302 _response_policy: String,
14303 _client_operation_id: Option<String>,
14304 _delegate: Option<&'a mut dyn common::Delegate>,
14305 _additional_params: HashMap<String, String>,
14306 _scopes: BTreeSet<String>,
14307}
14308
14309impl<'a, C> common::CallBuilder for ResponsePolicyGetCall<'a, C> {}
14310
14311impl<'a, C> ResponsePolicyGetCall<'a, C>
14312where
14313 C: common::Connector,
14314{
14315 /// Perform the operation you have build so far.
14316 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicy)> {
14317 use std::borrow::Cow;
14318 use std::io::{Read, Seek};
14319
14320 use common::{url::Params, ToParts};
14321 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14322
14323 let mut dd = common::DefaultDelegate;
14324 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14325 dlg.begin(common::MethodInfo {
14326 id: "dns.responsePolicies.get",
14327 http_method: hyper::Method::GET,
14328 });
14329
14330 for &field in [
14331 "alt",
14332 "project",
14333 "location",
14334 "responsePolicy",
14335 "clientOperationId",
14336 ]
14337 .iter()
14338 {
14339 if self._additional_params.contains_key(field) {
14340 dlg.finished(false);
14341 return Err(common::Error::FieldClash(field));
14342 }
14343 }
14344
14345 let mut params = Params::with_capacity(6 + self._additional_params.len());
14346 params.push("project", self._project);
14347 params.push("location", self._location);
14348 params.push("responsePolicy", self._response_policy);
14349 if let Some(value) = self._client_operation_id.as_ref() {
14350 params.push("clientOperationId", value);
14351 }
14352
14353 params.extend(self._additional_params.iter());
14354
14355 params.push("alt", "json");
14356 let mut url = self.hub._base_url.clone()
14357 + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}";
14358 if self._scopes.is_empty() {
14359 self._scopes
14360 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
14361 }
14362
14363 #[allow(clippy::single_element_loop)]
14364 for &(find_this, param_name) in [
14365 ("{project}", "project"),
14366 ("{location}", "location"),
14367 ("{responsePolicy}", "responsePolicy"),
14368 ]
14369 .iter()
14370 {
14371 url = params.uri_replacement(url, param_name, find_this, false);
14372 }
14373 {
14374 let to_remove = ["responsePolicy", "location", "project"];
14375 params.remove_params(&to_remove);
14376 }
14377
14378 let url = params.parse_with_url(&url);
14379
14380 loop {
14381 let token = match self
14382 .hub
14383 .auth
14384 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14385 .await
14386 {
14387 Ok(token) => token,
14388 Err(e) => match dlg.token(e) {
14389 Ok(token) => token,
14390 Err(e) => {
14391 dlg.finished(false);
14392 return Err(common::Error::MissingToken(e));
14393 }
14394 },
14395 };
14396 let mut req_result = {
14397 let client = &self.hub.client;
14398 dlg.pre_request();
14399 let mut req_builder = hyper::Request::builder()
14400 .method(hyper::Method::GET)
14401 .uri(url.as_str())
14402 .header(USER_AGENT, self.hub._user_agent.clone());
14403
14404 if let Some(token) = token.as_ref() {
14405 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14406 }
14407
14408 let request = req_builder
14409 .header(CONTENT_LENGTH, 0_u64)
14410 .body(common::to_body::<String>(None));
14411
14412 client.request(request.unwrap()).await
14413 };
14414
14415 match req_result {
14416 Err(err) => {
14417 if let common::Retry::After(d) = dlg.http_error(&err) {
14418 sleep(d).await;
14419 continue;
14420 }
14421 dlg.finished(false);
14422 return Err(common::Error::HttpError(err));
14423 }
14424 Ok(res) => {
14425 let (mut parts, body) = res.into_parts();
14426 let mut body = common::Body::new(body);
14427 if !parts.status.is_success() {
14428 let bytes = common::to_bytes(body).await.unwrap_or_default();
14429 let error = serde_json::from_str(&common::to_string(&bytes));
14430 let response = common::to_response(parts, bytes.into());
14431
14432 if let common::Retry::After(d) =
14433 dlg.http_failure(&response, error.as_ref().ok())
14434 {
14435 sleep(d).await;
14436 continue;
14437 }
14438
14439 dlg.finished(false);
14440
14441 return Err(match error {
14442 Ok(value) => common::Error::BadRequest(value),
14443 _ => common::Error::Failure(response),
14444 });
14445 }
14446 let response = {
14447 let bytes = common::to_bytes(body).await.unwrap_or_default();
14448 let encoded = common::to_string(&bytes);
14449 match serde_json::from_str(&encoded) {
14450 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14451 Err(error) => {
14452 dlg.response_json_decode_error(&encoded, &error);
14453 return Err(common::Error::JsonDecodeError(
14454 encoded.to_string(),
14455 error,
14456 ));
14457 }
14458 }
14459 };
14460
14461 dlg.finished(true);
14462 return Ok(response);
14463 }
14464 }
14465 }
14466 }
14467
14468 /// Identifies the project addressed by this request.
14469 ///
14470 /// Sets the *project* path property to the given value.
14471 ///
14472 /// Even though the property as already been set when instantiating this call,
14473 /// we provide this method for API completeness.
14474 pub fn project(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
14475 self._project = new_value.to_string();
14476 self
14477 }
14478 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
14479 ///
14480 /// Sets the *location* path property to the given value.
14481 ///
14482 /// Even though the property as already been set when instantiating this call,
14483 /// we provide this method for API completeness.
14484 pub fn location(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
14485 self._location = new_value.to_string();
14486 self
14487 }
14488 /// User assigned name of the Response Policy addressed by this request.
14489 ///
14490 /// Sets the *response policy* path property to the given value.
14491 ///
14492 /// Even though the property as already been set when instantiating this call,
14493 /// we provide this method for API completeness.
14494 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
14495 self._response_policy = new_value.to_string();
14496 self
14497 }
14498 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
14499 ///
14500 /// Sets the *client operation id* query property to the given value.
14501 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
14502 self._client_operation_id = Some(new_value.to_string());
14503 self
14504 }
14505 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14506 /// while executing the actual API request.
14507 ///
14508 /// ````text
14509 /// It should be used to handle progress information, and to implement a certain level of resilience.
14510 /// ````
14511 ///
14512 /// Sets the *delegate* property to the given value.
14513 pub fn delegate(
14514 mut self,
14515 new_value: &'a mut dyn common::Delegate,
14516 ) -> ResponsePolicyGetCall<'a, C> {
14517 self._delegate = Some(new_value);
14518 self
14519 }
14520
14521 /// Set any additional parameter of the query string used in the request.
14522 /// It should be used to set parameters which are not yet available through their own
14523 /// setters.
14524 ///
14525 /// Please note that this method must not be used to set any of the known parameters
14526 /// which have their own setter method. If done anyway, the request will fail.
14527 ///
14528 /// # Additional Parameters
14529 ///
14530 /// * *$.xgafv* (query-string) - V1 error format.
14531 /// * *access_token* (query-string) - OAuth access token.
14532 /// * *alt* (query-string) - Data format for response.
14533 /// * *callback* (query-string) - JSONP
14534 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14535 /// * *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.
14536 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14537 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14538 /// * *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.
14539 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14540 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14541 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyGetCall<'a, C>
14542 where
14543 T: AsRef<str>,
14544 {
14545 self._additional_params
14546 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14547 self
14548 }
14549
14550 /// Identifies the authorization scope for the method you are building.
14551 ///
14552 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14553 /// [`Scope::NdevClouddnReadonly`].
14554 ///
14555 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14556 /// tokens for more than one scope.
14557 ///
14558 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14559 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14560 /// sufficient, a read-write scope will do as well.
14561 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyGetCall<'a, C>
14562 where
14563 St: AsRef<str>,
14564 {
14565 self._scopes.insert(String::from(scope.as_ref()));
14566 self
14567 }
14568 /// Identifies the authorization scope(s) for the method you are building.
14569 ///
14570 /// See [`Self::add_scope()`] for details.
14571 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyGetCall<'a, C>
14572 where
14573 I: IntoIterator<Item = St>,
14574 St: AsRef<str>,
14575 {
14576 self._scopes
14577 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14578 self
14579 }
14580
14581 /// Removes all scopes, and no default scope will be used either.
14582 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14583 /// for details).
14584 pub fn clear_scopes(mut self) -> ResponsePolicyGetCall<'a, C> {
14585 self._scopes.clear();
14586 self
14587 }
14588}
14589
14590/// Enumerates all Response Policies associated with a project.
14591///
14592/// A builder for the *list* method supported by a *responsePolicy* resource.
14593/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
14594///
14595/// # Example
14596///
14597/// Instantiate a resource method builder
14598///
14599/// ```test_harness,no_run
14600/// # extern crate hyper;
14601/// # extern crate hyper_rustls;
14602/// # extern crate google_dns2 as dns2;
14603/// # async fn dox() {
14604/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14605///
14606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14607/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14608/// # .with_native_roots()
14609/// # .unwrap()
14610/// # .https_only()
14611/// # .enable_http2()
14612/// # .build();
14613///
14614/// # let executor = hyper_util::rt::TokioExecutor::new();
14615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14616/// # secret,
14617/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14618/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14619/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14620/// # ),
14621/// # ).build().await.unwrap();
14622///
14623/// # let client = hyper_util::client::legacy::Client::builder(
14624/// # hyper_util::rt::TokioExecutor::new()
14625/// # )
14626/// # .build(
14627/// # hyper_rustls::HttpsConnectorBuilder::new()
14628/// # .with_native_roots()
14629/// # .unwrap()
14630/// # .https_or_http()
14631/// # .enable_http2()
14632/// # .build()
14633/// # );
14634/// # let mut hub = Dns::new(client, auth);
14635/// // You can configure optional parameters by calling the respective setters at will, and
14636/// // execute the final call using `doit()`.
14637/// // Values shown here are possibly random and not representative !
14638/// let result = hub.response_policies().list("project", "location")
14639/// .page_token("Stet")
14640/// .max_results(-19)
14641/// .doit().await;
14642/// # }
14643/// ```
14644pub struct ResponsePolicyListCall<'a, C>
14645where
14646 C: 'a,
14647{
14648 hub: &'a Dns<C>,
14649 _project: String,
14650 _location: String,
14651 _page_token: Option<String>,
14652 _max_results: Option<i32>,
14653 _delegate: Option<&'a mut dyn common::Delegate>,
14654 _additional_params: HashMap<String, String>,
14655 _scopes: BTreeSet<String>,
14656}
14657
14658impl<'a, C> common::CallBuilder for ResponsePolicyListCall<'a, C> {}
14659
14660impl<'a, C> ResponsePolicyListCall<'a, C>
14661where
14662 C: common::Connector,
14663{
14664 /// Perform the operation you have build so far.
14665 pub async fn doit(
14666 mut self,
14667 ) -> common::Result<(common::Response, ResponsePoliciesListResponse)> {
14668 use std::borrow::Cow;
14669 use std::io::{Read, Seek};
14670
14671 use common::{url::Params, ToParts};
14672 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14673
14674 let mut dd = common::DefaultDelegate;
14675 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14676 dlg.begin(common::MethodInfo {
14677 id: "dns.responsePolicies.list",
14678 http_method: hyper::Method::GET,
14679 });
14680
14681 for &field in ["alt", "project", "location", "pageToken", "maxResults"].iter() {
14682 if self._additional_params.contains_key(field) {
14683 dlg.finished(false);
14684 return Err(common::Error::FieldClash(field));
14685 }
14686 }
14687
14688 let mut params = Params::with_capacity(6 + self._additional_params.len());
14689 params.push("project", self._project);
14690 params.push("location", self._location);
14691 if let Some(value) = self._page_token.as_ref() {
14692 params.push("pageToken", value);
14693 }
14694 if let Some(value) = self._max_results.as_ref() {
14695 params.push("maxResults", value.to_string());
14696 }
14697
14698 params.extend(self._additional_params.iter());
14699
14700 params.push("alt", "json");
14701 let mut url = self.hub._base_url.clone()
14702 + "dns/v2/projects/{project}/locations/{location}/responsePolicies";
14703 if self._scopes.is_empty() {
14704 self._scopes
14705 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
14706 }
14707
14708 #[allow(clippy::single_element_loop)]
14709 for &(find_this, param_name) in
14710 [("{project}", "project"), ("{location}", "location")].iter()
14711 {
14712 url = params.uri_replacement(url, param_name, find_this, false);
14713 }
14714 {
14715 let to_remove = ["location", "project"];
14716 params.remove_params(&to_remove);
14717 }
14718
14719 let url = params.parse_with_url(&url);
14720
14721 loop {
14722 let token = match self
14723 .hub
14724 .auth
14725 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14726 .await
14727 {
14728 Ok(token) => token,
14729 Err(e) => match dlg.token(e) {
14730 Ok(token) => token,
14731 Err(e) => {
14732 dlg.finished(false);
14733 return Err(common::Error::MissingToken(e));
14734 }
14735 },
14736 };
14737 let mut req_result = {
14738 let client = &self.hub.client;
14739 dlg.pre_request();
14740 let mut req_builder = hyper::Request::builder()
14741 .method(hyper::Method::GET)
14742 .uri(url.as_str())
14743 .header(USER_AGENT, self.hub._user_agent.clone());
14744
14745 if let Some(token) = token.as_ref() {
14746 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14747 }
14748
14749 let request = req_builder
14750 .header(CONTENT_LENGTH, 0_u64)
14751 .body(common::to_body::<String>(None));
14752
14753 client.request(request.unwrap()).await
14754 };
14755
14756 match req_result {
14757 Err(err) => {
14758 if let common::Retry::After(d) = dlg.http_error(&err) {
14759 sleep(d).await;
14760 continue;
14761 }
14762 dlg.finished(false);
14763 return Err(common::Error::HttpError(err));
14764 }
14765 Ok(res) => {
14766 let (mut parts, body) = res.into_parts();
14767 let mut body = common::Body::new(body);
14768 if !parts.status.is_success() {
14769 let bytes = common::to_bytes(body).await.unwrap_or_default();
14770 let error = serde_json::from_str(&common::to_string(&bytes));
14771 let response = common::to_response(parts, bytes.into());
14772
14773 if let common::Retry::After(d) =
14774 dlg.http_failure(&response, error.as_ref().ok())
14775 {
14776 sleep(d).await;
14777 continue;
14778 }
14779
14780 dlg.finished(false);
14781
14782 return Err(match error {
14783 Ok(value) => common::Error::BadRequest(value),
14784 _ => common::Error::Failure(response),
14785 });
14786 }
14787 let response = {
14788 let bytes = common::to_bytes(body).await.unwrap_or_default();
14789 let encoded = common::to_string(&bytes);
14790 match serde_json::from_str(&encoded) {
14791 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14792 Err(error) => {
14793 dlg.response_json_decode_error(&encoded, &error);
14794 return Err(common::Error::JsonDecodeError(
14795 encoded.to_string(),
14796 error,
14797 ));
14798 }
14799 }
14800 };
14801
14802 dlg.finished(true);
14803 return Ok(response);
14804 }
14805 }
14806 }
14807 }
14808
14809 /// Identifies the project addressed by this request.
14810 ///
14811 /// Sets the *project* path property to the given value.
14812 ///
14813 /// Even though the property as already been set when instantiating this call,
14814 /// we provide this method for API completeness.
14815 pub fn project(mut self, new_value: &str) -> ResponsePolicyListCall<'a, C> {
14816 self._project = new_value.to_string();
14817 self
14818 }
14819 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
14820 ///
14821 /// Sets the *location* path property to the given value.
14822 ///
14823 /// Even though the property as already been set when instantiating this call,
14824 /// we provide this method for API completeness.
14825 pub fn location(mut self, new_value: &str) -> ResponsePolicyListCall<'a, C> {
14826 self._location = new_value.to_string();
14827 self
14828 }
14829 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
14830 ///
14831 /// Sets the *page token* query property to the given value.
14832 pub fn page_token(mut self, new_value: &str) -> ResponsePolicyListCall<'a, C> {
14833 self._page_token = Some(new_value.to_string());
14834 self
14835 }
14836 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
14837 ///
14838 /// Sets the *max results* query property to the given value.
14839 pub fn max_results(mut self, new_value: i32) -> ResponsePolicyListCall<'a, C> {
14840 self._max_results = Some(new_value);
14841 self
14842 }
14843 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14844 /// while executing the actual API request.
14845 ///
14846 /// ````text
14847 /// It should be used to handle progress information, and to implement a certain level of resilience.
14848 /// ````
14849 ///
14850 /// Sets the *delegate* property to the given value.
14851 pub fn delegate(
14852 mut self,
14853 new_value: &'a mut dyn common::Delegate,
14854 ) -> ResponsePolicyListCall<'a, C> {
14855 self._delegate = Some(new_value);
14856 self
14857 }
14858
14859 /// Set any additional parameter of the query string used in the request.
14860 /// It should be used to set parameters which are not yet available through their own
14861 /// setters.
14862 ///
14863 /// Please note that this method must not be used to set any of the known parameters
14864 /// which have their own setter method. If done anyway, the request will fail.
14865 ///
14866 /// # Additional Parameters
14867 ///
14868 /// * *$.xgafv* (query-string) - V1 error format.
14869 /// * *access_token* (query-string) - OAuth access token.
14870 /// * *alt* (query-string) - Data format for response.
14871 /// * *callback* (query-string) - JSONP
14872 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14873 /// * *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.
14874 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14875 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14876 /// * *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.
14877 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14878 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14879 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyListCall<'a, C>
14880 where
14881 T: AsRef<str>,
14882 {
14883 self._additional_params
14884 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14885 self
14886 }
14887
14888 /// Identifies the authorization scope for the method you are building.
14889 ///
14890 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14891 /// [`Scope::NdevClouddnReadonly`].
14892 ///
14893 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14894 /// tokens for more than one scope.
14895 ///
14896 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14897 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14898 /// sufficient, a read-write scope will do as well.
14899 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyListCall<'a, C>
14900 where
14901 St: AsRef<str>,
14902 {
14903 self._scopes.insert(String::from(scope.as_ref()));
14904 self
14905 }
14906 /// Identifies the authorization scope(s) for the method you are building.
14907 ///
14908 /// See [`Self::add_scope()`] for details.
14909 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyListCall<'a, C>
14910 where
14911 I: IntoIterator<Item = St>,
14912 St: AsRef<str>,
14913 {
14914 self._scopes
14915 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14916 self
14917 }
14918
14919 /// Removes all scopes, and no default scope will be used either.
14920 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14921 /// for details).
14922 pub fn clear_scopes(mut self) -> ResponsePolicyListCall<'a, C> {
14923 self._scopes.clear();
14924 self
14925 }
14926}
14927
14928/// Applies a partial update to an existing Response Policy.
14929///
14930/// A builder for the *patch* method supported by a *responsePolicy* resource.
14931/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
14932///
14933/// # Example
14934///
14935/// Instantiate a resource method builder
14936///
14937/// ```test_harness,no_run
14938/// # extern crate hyper;
14939/// # extern crate hyper_rustls;
14940/// # extern crate google_dns2 as dns2;
14941/// use dns2::api::ResponsePolicy;
14942/// # async fn dox() {
14943/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14944///
14945/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14946/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14947/// # .with_native_roots()
14948/// # .unwrap()
14949/// # .https_only()
14950/// # .enable_http2()
14951/// # .build();
14952///
14953/// # let executor = hyper_util::rt::TokioExecutor::new();
14954/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14955/// # secret,
14956/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14957/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14958/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14959/// # ),
14960/// # ).build().await.unwrap();
14961///
14962/// # let client = hyper_util::client::legacy::Client::builder(
14963/// # hyper_util::rt::TokioExecutor::new()
14964/// # )
14965/// # .build(
14966/// # hyper_rustls::HttpsConnectorBuilder::new()
14967/// # .with_native_roots()
14968/// # .unwrap()
14969/// # .https_or_http()
14970/// # .enable_http2()
14971/// # .build()
14972/// # );
14973/// # let mut hub = Dns::new(client, auth);
14974/// // As the method needs a request, you would usually fill it with the desired information
14975/// // into the respective structure. Some of the parts shown here might not be applicable !
14976/// // Values shown here are possibly random and not representative !
14977/// let mut req = ResponsePolicy::default();
14978///
14979/// // You can configure optional parameters by calling the respective setters at will, and
14980/// // execute the final call using `doit()`.
14981/// // Values shown here are possibly random and not representative !
14982/// let result = hub.response_policies().patch(req, "project", "location", "responsePolicy")
14983/// .client_operation_id("et")
14984/// .doit().await;
14985/// # }
14986/// ```
14987pub struct ResponsePolicyPatchCall<'a, C>
14988where
14989 C: 'a,
14990{
14991 hub: &'a Dns<C>,
14992 _request: ResponsePolicy,
14993 _project: String,
14994 _location: String,
14995 _response_policy: String,
14996 _client_operation_id: Option<String>,
14997 _delegate: Option<&'a mut dyn common::Delegate>,
14998 _additional_params: HashMap<String, String>,
14999 _scopes: BTreeSet<String>,
15000}
15001
15002impl<'a, C> common::CallBuilder for ResponsePolicyPatchCall<'a, C> {}
15003
15004impl<'a, C> ResponsePolicyPatchCall<'a, C>
15005where
15006 C: common::Connector,
15007{
15008 /// Perform the operation you have build so far.
15009 pub async fn doit(
15010 mut self,
15011 ) -> common::Result<(common::Response, ResponsePoliciesPatchResponse)> {
15012 use std::borrow::Cow;
15013 use std::io::{Read, Seek};
15014
15015 use common::{url::Params, ToParts};
15016 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15017
15018 let mut dd = common::DefaultDelegate;
15019 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15020 dlg.begin(common::MethodInfo {
15021 id: "dns.responsePolicies.patch",
15022 http_method: hyper::Method::PATCH,
15023 });
15024
15025 for &field in [
15026 "alt",
15027 "project",
15028 "location",
15029 "responsePolicy",
15030 "clientOperationId",
15031 ]
15032 .iter()
15033 {
15034 if self._additional_params.contains_key(field) {
15035 dlg.finished(false);
15036 return Err(common::Error::FieldClash(field));
15037 }
15038 }
15039
15040 let mut params = Params::with_capacity(7 + self._additional_params.len());
15041 params.push("project", self._project);
15042 params.push("location", self._location);
15043 params.push("responsePolicy", self._response_policy);
15044 if let Some(value) = self._client_operation_id.as_ref() {
15045 params.push("clientOperationId", value);
15046 }
15047
15048 params.extend(self._additional_params.iter());
15049
15050 params.push("alt", "json");
15051 let mut url = self.hub._base_url.clone()
15052 + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}";
15053 if self._scopes.is_empty() {
15054 self._scopes
15055 .insert(Scope::CloudPlatform.as_ref().to_string());
15056 }
15057
15058 #[allow(clippy::single_element_loop)]
15059 for &(find_this, param_name) in [
15060 ("{project}", "project"),
15061 ("{location}", "location"),
15062 ("{responsePolicy}", "responsePolicy"),
15063 ]
15064 .iter()
15065 {
15066 url = params.uri_replacement(url, param_name, find_this, false);
15067 }
15068 {
15069 let to_remove = ["responsePolicy", "location", "project"];
15070 params.remove_params(&to_remove);
15071 }
15072
15073 let url = params.parse_with_url(&url);
15074
15075 let mut json_mime_type = mime::APPLICATION_JSON;
15076 let mut request_value_reader = {
15077 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15078 common::remove_json_null_values(&mut value);
15079 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15080 serde_json::to_writer(&mut dst, &value).unwrap();
15081 dst
15082 };
15083 let request_size = request_value_reader
15084 .seek(std::io::SeekFrom::End(0))
15085 .unwrap();
15086 request_value_reader
15087 .seek(std::io::SeekFrom::Start(0))
15088 .unwrap();
15089
15090 loop {
15091 let token = match self
15092 .hub
15093 .auth
15094 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15095 .await
15096 {
15097 Ok(token) => token,
15098 Err(e) => match dlg.token(e) {
15099 Ok(token) => token,
15100 Err(e) => {
15101 dlg.finished(false);
15102 return Err(common::Error::MissingToken(e));
15103 }
15104 },
15105 };
15106 request_value_reader
15107 .seek(std::io::SeekFrom::Start(0))
15108 .unwrap();
15109 let mut req_result = {
15110 let client = &self.hub.client;
15111 dlg.pre_request();
15112 let mut req_builder = hyper::Request::builder()
15113 .method(hyper::Method::PATCH)
15114 .uri(url.as_str())
15115 .header(USER_AGENT, self.hub._user_agent.clone());
15116
15117 if let Some(token) = token.as_ref() {
15118 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15119 }
15120
15121 let request = req_builder
15122 .header(CONTENT_TYPE, json_mime_type.to_string())
15123 .header(CONTENT_LENGTH, request_size as u64)
15124 .body(common::to_body(
15125 request_value_reader.get_ref().clone().into(),
15126 ));
15127
15128 client.request(request.unwrap()).await
15129 };
15130
15131 match req_result {
15132 Err(err) => {
15133 if let common::Retry::After(d) = dlg.http_error(&err) {
15134 sleep(d).await;
15135 continue;
15136 }
15137 dlg.finished(false);
15138 return Err(common::Error::HttpError(err));
15139 }
15140 Ok(res) => {
15141 let (mut parts, body) = res.into_parts();
15142 let mut body = common::Body::new(body);
15143 if !parts.status.is_success() {
15144 let bytes = common::to_bytes(body).await.unwrap_or_default();
15145 let error = serde_json::from_str(&common::to_string(&bytes));
15146 let response = common::to_response(parts, bytes.into());
15147
15148 if let common::Retry::After(d) =
15149 dlg.http_failure(&response, error.as_ref().ok())
15150 {
15151 sleep(d).await;
15152 continue;
15153 }
15154
15155 dlg.finished(false);
15156
15157 return Err(match error {
15158 Ok(value) => common::Error::BadRequest(value),
15159 _ => common::Error::Failure(response),
15160 });
15161 }
15162 let response = {
15163 let bytes = common::to_bytes(body).await.unwrap_or_default();
15164 let encoded = common::to_string(&bytes);
15165 match serde_json::from_str(&encoded) {
15166 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15167 Err(error) => {
15168 dlg.response_json_decode_error(&encoded, &error);
15169 return Err(common::Error::JsonDecodeError(
15170 encoded.to_string(),
15171 error,
15172 ));
15173 }
15174 }
15175 };
15176
15177 dlg.finished(true);
15178 return Ok(response);
15179 }
15180 }
15181 }
15182 }
15183
15184 ///
15185 /// Sets the *request* property to the given value.
15186 ///
15187 /// Even though the property as already been set when instantiating this call,
15188 /// we provide this method for API completeness.
15189 pub fn request(mut self, new_value: ResponsePolicy) -> ResponsePolicyPatchCall<'a, C> {
15190 self._request = new_value;
15191 self
15192 }
15193 /// Identifies the project addressed by this request.
15194 ///
15195 /// Sets the *project* path property to the given value.
15196 ///
15197 /// Even though the property as already been set when instantiating this call,
15198 /// we provide this method for API completeness.
15199 pub fn project(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
15200 self._project = new_value.to_string();
15201 self
15202 }
15203 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
15204 ///
15205 /// Sets the *location* path property to the given value.
15206 ///
15207 /// Even though the property as already been set when instantiating this call,
15208 /// we provide this method for API completeness.
15209 pub fn location(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
15210 self._location = new_value.to_string();
15211 self
15212 }
15213 /// User assigned name of the response policy addressed by this request.
15214 ///
15215 /// Sets the *response policy* path property to the given value.
15216 ///
15217 /// Even though the property as already been set when instantiating this call,
15218 /// we provide this method for API completeness.
15219 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
15220 self._response_policy = new_value.to_string();
15221 self
15222 }
15223 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
15224 ///
15225 /// Sets the *client operation id* query property to the given value.
15226 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
15227 self._client_operation_id = Some(new_value.to_string());
15228 self
15229 }
15230 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15231 /// while executing the actual API request.
15232 ///
15233 /// ````text
15234 /// It should be used to handle progress information, and to implement a certain level of resilience.
15235 /// ````
15236 ///
15237 /// Sets the *delegate* property to the given value.
15238 pub fn delegate(
15239 mut self,
15240 new_value: &'a mut dyn common::Delegate,
15241 ) -> ResponsePolicyPatchCall<'a, C> {
15242 self._delegate = Some(new_value);
15243 self
15244 }
15245
15246 /// Set any additional parameter of the query string used in the request.
15247 /// It should be used to set parameters which are not yet available through their own
15248 /// setters.
15249 ///
15250 /// Please note that this method must not be used to set any of the known parameters
15251 /// which have their own setter method. If done anyway, the request will fail.
15252 ///
15253 /// # Additional Parameters
15254 ///
15255 /// * *$.xgafv* (query-string) - V1 error format.
15256 /// * *access_token* (query-string) - OAuth access token.
15257 /// * *alt* (query-string) - Data format for response.
15258 /// * *callback* (query-string) - JSONP
15259 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15260 /// * *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.
15261 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15262 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15263 /// * *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.
15264 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15265 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15266 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyPatchCall<'a, C>
15267 where
15268 T: AsRef<str>,
15269 {
15270 self._additional_params
15271 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15272 self
15273 }
15274
15275 /// Identifies the authorization scope for the method you are building.
15276 ///
15277 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15278 /// [`Scope::CloudPlatform`].
15279 ///
15280 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15281 /// tokens for more than one scope.
15282 ///
15283 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15284 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15285 /// sufficient, a read-write scope will do as well.
15286 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyPatchCall<'a, C>
15287 where
15288 St: AsRef<str>,
15289 {
15290 self._scopes.insert(String::from(scope.as_ref()));
15291 self
15292 }
15293 /// Identifies the authorization scope(s) for the method you are building.
15294 ///
15295 /// See [`Self::add_scope()`] for details.
15296 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyPatchCall<'a, C>
15297 where
15298 I: IntoIterator<Item = St>,
15299 St: AsRef<str>,
15300 {
15301 self._scopes
15302 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15303 self
15304 }
15305
15306 /// Removes all scopes, and no default scope will be used either.
15307 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15308 /// for details).
15309 pub fn clear_scopes(mut self) -> ResponsePolicyPatchCall<'a, C> {
15310 self._scopes.clear();
15311 self
15312 }
15313}
15314
15315/// Updates an existing Response Policy.
15316///
15317/// A builder for the *update* method supported by a *responsePolicy* resource.
15318/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
15319///
15320/// # Example
15321///
15322/// Instantiate a resource method builder
15323///
15324/// ```test_harness,no_run
15325/// # extern crate hyper;
15326/// # extern crate hyper_rustls;
15327/// # extern crate google_dns2 as dns2;
15328/// use dns2::api::ResponsePolicy;
15329/// # async fn dox() {
15330/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15331///
15332/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15333/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15334/// # .with_native_roots()
15335/// # .unwrap()
15336/// # .https_only()
15337/// # .enable_http2()
15338/// # .build();
15339///
15340/// # let executor = hyper_util::rt::TokioExecutor::new();
15341/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15342/// # secret,
15343/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15344/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15345/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15346/// # ),
15347/// # ).build().await.unwrap();
15348///
15349/// # let client = hyper_util::client::legacy::Client::builder(
15350/// # hyper_util::rt::TokioExecutor::new()
15351/// # )
15352/// # .build(
15353/// # hyper_rustls::HttpsConnectorBuilder::new()
15354/// # .with_native_roots()
15355/// # .unwrap()
15356/// # .https_or_http()
15357/// # .enable_http2()
15358/// # .build()
15359/// # );
15360/// # let mut hub = Dns::new(client, auth);
15361/// // As the method needs a request, you would usually fill it with the desired information
15362/// // into the respective structure. Some of the parts shown here might not be applicable !
15363/// // Values shown here are possibly random and not representative !
15364/// let mut req = ResponsePolicy::default();
15365///
15366/// // You can configure optional parameters by calling the respective setters at will, and
15367/// // execute the final call using `doit()`.
15368/// // Values shown here are possibly random and not representative !
15369/// let result = hub.response_policies().update(req, "project", "location", "responsePolicy")
15370/// .client_operation_id("Lorem")
15371/// .doit().await;
15372/// # }
15373/// ```
15374pub struct ResponsePolicyUpdateCall<'a, C>
15375where
15376 C: 'a,
15377{
15378 hub: &'a Dns<C>,
15379 _request: ResponsePolicy,
15380 _project: String,
15381 _location: String,
15382 _response_policy: String,
15383 _client_operation_id: Option<String>,
15384 _delegate: Option<&'a mut dyn common::Delegate>,
15385 _additional_params: HashMap<String, String>,
15386 _scopes: BTreeSet<String>,
15387}
15388
15389impl<'a, C> common::CallBuilder for ResponsePolicyUpdateCall<'a, C> {}
15390
15391impl<'a, C> ResponsePolicyUpdateCall<'a, C>
15392where
15393 C: common::Connector,
15394{
15395 /// Perform the operation you have build so far.
15396 pub async fn doit(
15397 mut self,
15398 ) -> common::Result<(common::Response, ResponsePoliciesUpdateResponse)> {
15399 use std::borrow::Cow;
15400 use std::io::{Read, Seek};
15401
15402 use common::{url::Params, ToParts};
15403 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15404
15405 let mut dd = common::DefaultDelegate;
15406 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15407 dlg.begin(common::MethodInfo {
15408 id: "dns.responsePolicies.update",
15409 http_method: hyper::Method::PUT,
15410 });
15411
15412 for &field in [
15413 "alt",
15414 "project",
15415 "location",
15416 "responsePolicy",
15417 "clientOperationId",
15418 ]
15419 .iter()
15420 {
15421 if self._additional_params.contains_key(field) {
15422 dlg.finished(false);
15423 return Err(common::Error::FieldClash(field));
15424 }
15425 }
15426
15427 let mut params = Params::with_capacity(7 + self._additional_params.len());
15428 params.push("project", self._project);
15429 params.push("location", self._location);
15430 params.push("responsePolicy", self._response_policy);
15431 if let Some(value) = self._client_operation_id.as_ref() {
15432 params.push("clientOperationId", value);
15433 }
15434
15435 params.extend(self._additional_params.iter());
15436
15437 params.push("alt", "json");
15438 let mut url = self.hub._base_url.clone()
15439 + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}";
15440 if self._scopes.is_empty() {
15441 self._scopes
15442 .insert(Scope::CloudPlatform.as_ref().to_string());
15443 }
15444
15445 #[allow(clippy::single_element_loop)]
15446 for &(find_this, param_name) in [
15447 ("{project}", "project"),
15448 ("{location}", "location"),
15449 ("{responsePolicy}", "responsePolicy"),
15450 ]
15451 .iter()
15452 {
15453 url = params.uri_replacement(url, param_name, find_this, false);
15454 }
15455 {
15456 let to_remove = ["responsePolicy", "location", "project"];
15457 params.remove_params(&to_remove);
15458 }
15459
15460 let url = params.parse_with_url(&url);
15461
15462 let mut json_mime_type = mime::APPLICATION_JSON;
15463 let mut request_value_reader = {
15464 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15465 common::remove_json_null_values(&mut value);
15466 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15467 serde_json::to_writer(&mut dst, &value).unwrap();
15468 dst
15469 };
15470 let request_size = request_value_reader
15471 .seek(std::io::SeekFrom::End(0))
15472 .unwrap();
15473 request_value_reader
15474 .seek(std::io::SeekFrom::Start(0))
15475 .unwrap();
15476
15477 loop {
15478 let token = match self
15479 .hub
15480 .auth
15481 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15482 .await
15483 {
15484 Ok(token) => token,
15485 Err(e) => match dlg.token(e) {
15486 Ok(token) => token,
15487 Err(e) => {
15488 dlg.finished(false);
15489 return Err(common::Error::MissingToken(e));
15490 }
15491 },
15492 };
15493 request_value_reader
15494 .seek(std::io::SeekFrom::Start(0))
15495 .unwrap();
15496 let mut req_result = {
15497 let client = &self.hub.client;
15498 dlg.pre_request();
15499 let mut req_builder = hyper::Request::builder()
15500 .method(hyper::Method::PUT)
15501 .uri(url.as_str())
15502 .header(USER_AGENT, self.hub._user_agent.clone());
15503
15504 if let Some(token) = token.as_ref() {
15505 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15506 }
15507
15508 let request = req_builder
15509 .header(CONTENT_TYPE, json_mime_type.to_string())
15510 .header(CONTENT_LENGTH, request_size as u64)
15511 .body(common::to_body(
15512 request_value_reader.get_ref().clone().into(),
15513 ));
15514
15515 client.request(request.unwrap()).await
15516 };
15517
15518 match req_result {
15519 Err(err) => {
15520 if let common::Retry::After(d) = dlg.http_error(&err) {
15521 sleep(d).await;
15522 continue;
15523 }
15524 dlg.finished(false);
15525 return Err(common::Error::HttpError(err));
15526 }
15527 Ok(res) => {
15528 let (mut parts, body) = res.into_parts();
15529 let mut body = common::Body::new(body);
15530 if !parts.status.is_success() {
15531 let bytes = common::to_bytes(body).await.unwrap_or_default();
15532 let error = serde_json::from_str(&common::to_string(&bytes));
15533 let response = common::to_response(parts, bytes.into());
15534
15535 if let common::Retry::After(d) =
15536 dlg.http_failure(&response, error.as_ref().ok())
15537 {
15538 sleep(d).await;
15539 continue;
15540 }
15541
15542 dlg.finished(false);
15543
15544 return Err(match error {
15545 Ok(value) => common::Error::BadRequest(value),
15546 _ => common::Error::Failure(response),
15547 });
15548 }
15549 let response = {
15550 let bytes = common::to_bytes(body).await.unwrap_or_default();
15551 let encoded = common::to_string(&bytes);
15552 match serde_json::from_str(&encoded) {
15553 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15554 Err(error) => {
15555 dlg.response_json_decode_error(&encoded, &error);
15556 return Err(common::Error::JsonDecodeError(
15557 encoded.to_string(),
15558 error,
15559 ));
15560 }
15561 }
15562 };
15563
15564 dlg.finished(true);
15565 return Ok(response);
15566 }
15567 }
15568 }
15569 }
15570
15571 ///
15572 /// Sets the *request* property to the given value.
15573 ///
15574 /// Even though the property as already been set when instantiating this call,
15575 /// we provide this method for API completeness.
15576 pub fn request(mut self, new_value: ResponsePolicy) -> ResponsePolicyUpdateCall<'a, C> {
15577 self._request = new_value;
15578 self
15579 }
15580 /// Identifies the project addressed by this request.
15581 ///
15582 /// Sets the *project* path property to the given value.
15583 ///
15584 /// Even though the property as already been set when instantiating this call,
15585 /// we provide this method for API completeness.
15586 pub fn project(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
15587 self._project = new_value.to_string();
15588 self
15589 }
15590 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
15591 ///
15592 /// Sets the *location* path property to the given value.
15593 ///
15594 /// Even though the property as already been set when instantiating this call,
15595 /// we provide this method for API completeness.
15596 pub fn location(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
15597 self._location = new_value.to_string();
15598 self
15599 }
15600 /// User assigned name of the Response Policy addressed by this request.
15601 ///
15602 /// Sets the *response policy* path property to the given value.
15603 ///
15604 /// Even though the property as already been set when instantiating this call,
15605 /// we provide this method for API completeness.
15606 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
15607 self._response_policy = new_value.to_string();
15608 self
15609 }
15610 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
15611 ///
15612 /// Sets the *client operation id* query property to the given value.
15613 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
15614 self._client_operation_id = Some(new_value.to_string());
15615 self
15616 }
15617 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15618 /// while executing the actual API request.
15619 ///
15620 /// ````text
15621 /// It should be used to handle progress information, and to implement a certain level of resilience.
15622 /// ````
15623 ///
15624 /// Sets the *delegate* property to the given value.
15625 pub fn delegate(
15626 mut self,
15627 new_value: &'a mut dyn common::Delegate,
15628 ) -> ResponsePolicyUpdateCall<'a, C> {
15629 self._delegate = Some(new_value);
15630 self
15631 }
15632
15633 /// Set any additional parameter of the query string used in the request.
15634 /// It should be used to set parameters which are not yet available through their own
15635 /// setters.
15636 ///
15637 /// Please note that this method must not be used to set any of the known parameters
15638 /// which have their own setter method. If done anyway, the request will fail.
15639 ///
15640 /// # Additional Parameters
15641 ///
15642 /// * *$.xgafv* (query-string) - V1 error format.
15643 /// * *access_token* (query-string) - OAuth access token.
15644 /// * *alt* (query-string) - Data format for response.
15645 /// * *callback* (query-string) - JSONP
15646 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15647 /// * *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.
15648 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15649 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15650 /// * *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.
15651 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15652 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15653 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyUpdateCall<'a, C>
15654 where
15655 T: AsRef<str>,
15656 {
15657 self._additional_params
15658 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15659 self
15660 }
15661
15662 /// Identifies the authorization scope for the method you are building.
15663 ///
15664 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15665 /// [`Scope::CloudPlatform`].
15666 ///
15667 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15668 /// tokens for more than one scope.
15669 ///
15670 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15671 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15672 /// sufficient, a read-write scope will do as well.
15673 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyUpdateCall<'a, C>
15674 where
15675 St: AsRef<str>,
15676 {
15677 self._scopes.insert(String::from(scope.as_ref()));
15678 self
15679 }
15680 /// Identifies the authorization scope(s) for the method you are building.
15681 ///
15682 /// See [`Self::add_scope()`] for details.
15683 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyUpdateCall<'a, C>
15684 where
15685 I: IntoIterator<Item = St>,
15686 St: AsRef<str>,
15687 {
15688 self._scopes
15689 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15690 self
15691 }
15692
15693 /// Removes all scopes, and no default scope will be used either.
15694 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15695 /// for details).
15696 pub fn clear_scopes(mut self) -> ResponsePolicyUpdateCall<'a, C> {
15697 self._scopes.clear();
15698 self
15699 }
15700}
15701
15702/// Creates a new Response Policy Rule.
15703///
15704/// A builder for the *create* method supported by a *responsePolicyRule* resource.
15705/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
15706///
15707/// # Example
15708///
15709/// Instantiate a resource method builder
15710///
15711/// ```test_harness,no_run
15712/// # extern crate hyper;
15713/// # extern crate hyper_rustls;
15714/// # extern crate google_dns2 as dns2;
15715/// use dns2::api::ResponsePolicyRule;
15716/// # async fn dox() {
15717/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15718///
15719/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15720/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15721/// # .with_native_roots()
15722/// # .unwrap()
15723/// # .https_only()
15724/// # .enable_http2()
15725/// # .build();
15726///
15727/// # let executor = hyper_util::rt::TokioExecutor::new();
15728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15729/// # secret,
15730/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15731/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15732/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15733/// # ),
15734/// # ).build().await.unwrap();
15735///
15736/// # let client = hyper_util::client::legacy::Client::builder(
15737/// # hyper_util::rt::TokioExecutor::new()
15738/// # )
15739/// # .build(
15740/// # hyper_rustls::HttpsConnectorBuilder::new()
15741/// # .with_native_roots()
15742/// # .unwrap()
15743/// # .https_or_http()
15744/// # .enable_http2()
15745/// # .build()
15746/// # );
15747/// # let mut hub = Dns::new(client, auth);
15748/// // As the method needs a request, you would usually fill it with the desired information
15749/// // into the respective structure. Some of the parts shown here might not be applicable !
15750/// // Values shown here are possibly random and not representative !
15751/// let mut req = ResponsePolicyRule::default();
15752///
15753/// // You can configure optional parameters by calling the respective setters at will, and
15754/// // execute the final call using `doit()`.
15755/// // Values shown here are possibly random and not representative !
15756/// let result = hub.response_policy_rules().create(req, "project", "location", "responsePolicy")
15757/// .client_operation_id("dolores")
15758/// .doit().await;
15759/// # }
15760/// ```
15761pub struct ResponsePolicyRuleCreateCall<'a, C>
15762where
15763 C: 'a,
15764{
15765 hub: &'a Dns<C>,
15766 _request: ResponsePolicyRule,
15767 _project: String,
15768 _location: String,
15769 _response_policy: String,
15770 _client_operation_id: Option<String>,
15771 _delegate: Option<&'a mut dyn common::Delegate>,
15772 _additional_params: HashMap<String, String>,
15773 _scopes: BTreeSet<String>,
15774}
15775
15776impl<'a, C> common::CallBuilder for ResponsePolicyRuleCreateCall<'a, C> {}
15777
15778impl<'a, C> ResponsePolicyRuleCreateCall<'a, C>
15779where
15780 C: common::Connector,
15781{
15782 /// Perform the operation you have build so far.
15783 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicyRule)> {
15784 use std::borrow::Cow;
15785 use std::io::{Read, Seek};
15786
15787 use common::{url::Params, ToParts};
15788 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15789
15790 let mut dd = common::DefaultDelegate;
15791 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15792 dlg.begin(common::MethodInfo {
15793 id: "dns.responsePolicyRules.create",
15794 http_method: hyper::Method::POST,
15795 });
15796
15797 for &field in [
15798 "alt",
15799 "project",
15800 "location",
15801 "responsePolicy",
15802 "clientOperationId",
15803 ]
15804 .iter()
15805 {
15806 if self._additional_params.contains_key(field) {
15807 dlg.finished(false);
15808 return Err(common::Error::FieldClash(field));
15809 }
15810 }
15811
15812 let mut params = Params::with_capacity(7 + self._additional_params.len());
15813 params.push("project", self._project);
15814 params.push("location", self._location);
15815 params.push("responsePolicy", self._response_policy);
15816 if let Some(value) = self._client_operation_id.as_ref() {
15817 params.push("clientOperationId", value);
15818 }
15819
15820 params.extend(self._additional_params.iter());
15821
15822 params.push("alt", "json");
15823 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}/rules";
15824 if self._scopes.is_empty() {
15825 self._scopes
15826 .insert(Scope::CloudPlatform.as_ref().to_string());
15827 }
15828
15829 #[allow(clippy::single_element_loop)]
15830 for &(find_this, param_name) in [
15831 ("{project}", "project"),
15832 ("{location}", "location"),
15833 ("{responsePolicy}", "responsePolicy"),
15834 ]
15835 .iter()
15836 {
15837 url = params.uri_replacement(url, param_name, find_this, false);
15838 }
15839 {
15840 let to_remove = ["responsePolicy", "location", "project"];
15841 params.remove_params(&to_remove);
15842 }
15843
15844 let url = params.parse_with_url(&url);
15845
15846 let mut json_mime_type = mime::APPLICATION_JSON;
15847 let mut request_value_reader = {
15848 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15849 common::remove_json_null_values(&mut value);
15850 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15851 serde_json::to_writer(&mut dst, &value).unwrap();
15852 dst
15853 };
15854 let request_size = request_value_reader
15855 .seek(std::io::SeekFrom::End(0))
15856 .unwrap();
15857 request_value_reader
15858 .seek(std::io::SeekFrom::Start(0))
15859 .unwrap();
15860
15861 loop {
15862 let token = match self
15863 .hub
15864 .auth
15865 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15866 .await
15867 {
15868 Ok(token) => token,
15869 Err(e) => match dlg.token(e) {
15870 Ok(token) => token,
15871 Err(e) => {
15872 dlg.finished(false);
15873 return Err(common::Error::MissingToken(e));
15874 }
15875 },
15876 };
15877 request_value_reader
15878 .seek(std::io::SeekFrom::Start(0))
15879 .unwrap();
15880 let mut req_result = {
15881 let client = &self.hub.client;
15882 dlg.pre_request();
15883 let mut req_builder = hyper::Request::builder()
15884 .method(hyper::Method::POST)
15885 .uri(url.as_str())
15886 .header(USER_AGENT, self.hub._user_agent.clone());
15887
15888 if let Some(token) = token.as_ref() {
15889 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15890 }
15891
15892 let request = req_builder
15893 .header(CONTENT_TYPE, json_mime_type.to_string())
15894 .header(CONTENT_LENGTH, request_size as u64)
15895 .body(common::to_body(
15896 request_value_reader.get_ref().clone().into(),
15897 ));
15898
15899 client.request(request.unwrap()).await
15900 };
15901
15902 match req_result {
15903 Err(err) => {
15904 if let common::Retry::After(d) = dlg.http_error(&err) {
15905 sleep(d).await;
15906 continue;
15907 }
15908 dlg.finished(false);
15909 return Err(common::Error::HttpError(err));
15910 }
15911 Ok(res) => {
15912 let (mut parts, body) = res.into_parts();
15913 let mut body = common::Body::new(body);
15914 if !parts.status.is_success() {
15915 let bytes = common::to_bytes(body).await.unwrap_or_default();
15916 let error = serde_json::from_str(&common::to_string(&bytes));
15917 let response = common::to_response(parts, bytes.into());
15918
15919 if let common::Retry::After(d) =
15920 dlg.http_failure(&response, error.as_ref().ok())
15921 {
15922 sleep(d).await;
15923 continue;
15924 }
15925
15926 dlg.finished(false);
15927
15928 return Err(match error {
15929 Ok(value) => common::Error::BadRequest(value),
15930 _ => common::Error::Failure(response),
15931 });
15932 }
15933 let response = {
15934 let bytes = common::to_bytes(body).await.unwrap_or_default();
15935 let encoded = common::to_string(&bytes);
15936 match serde_json::from_str(&encoded) {
15937 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15938 Err(error) => {
15939 dlg.response_json_decode_error(&encoded, &error);
15940 return Err(common::Error::JsonDecodeError(
15941 encoded.to_string(),
15942 error,
15943 ));
15944 }
15945 }
15946 };
15947
15948 dlg.finished(true);
15949 return Ok(response);
15950 }
15951 }
15952 }
15953 }
15954
15955 ///
15956 /// Sets the *request* property to the given value.
15957 ///
15958 /// Even though the property as already been set when instantiating this call,
15959 /// we provide this method for API completeness.
15960 pub fn request(mut self, new_value: ResponsePolicyRule) -> ResponsePolicyRuleCreateCall<'a, C> {
15961 self._request = new_value;
15962 self
15963 }
15964 /// Identifies the project addressed by this request.
15965 ///
15966 /// Sets the *project* path property to the given value.
15967 ///
15968 /// Even though the property as already been set when instantiating this call,
15969 /// we provide this method for API completeness.
15970 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15971 self._project = new_value.to_string();
15972 self
15973 }
15974 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
15975 ///
15976 /// Sets the *location* path property to the given value.
15977 ///
15978 /// Even though the property as already been set when instantiating this call,
15979 /// we provide this method for API completeness.
15980 pub fn location(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15981 self._location = new_value.to_string();
15982 self
15983 }
15984 /// User assigned name of the Response Policy containing the Response Policy Rule.
15985 ///
15986 /// Sets the *response policy* path property to the given value.
15987 ///
15988 /// Even though the property as already been set when instantiating this call,
15989 /// we provide this method for API completeness.
15990 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15991 self._response_policy = new_value.to_string();
15992 self
15993 }
15994 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
15995 ///
15996 /// Sets the *client operation id* query property to the given value.
15997 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15998 self._client_operation_id = Some(new_value.to_string());
15999 self
16000 }
16001 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16002 /// while executing the actual API request.
16003 ///
16004 /// ````text
16005 /// It should be used to handle progress information, and to implement a certain level of resilience.
16006 /// ````
16007 ///
16008 /// Sets the *delegate* property to the given value.
16009 pub fn delegate(
16010 mut self,
16011 new_value: &'a mut dyn common::Delegate,
16012 ) -> ResponsePolicyRuleCreateCall<'a, C> {
16013 self._delegate = Some(new_value);
16014 self
16015 }
16016
16017 /// Set any additional parameter of the query string used in the request.
16018 /// It should be used to set parameters which are not yet available through their own
16019 /// setters.
16020 ///
16021 /// Please note that this method must not be used to set any of the known parameters
16022 /// which have their own setter method. If done anyway, the request will fail.
16023 ///
16024 /// # Additional Parameters
16025 ///
16026 /// * *$.xgafv* (query-string) - V1 error format.
16027 /// * *access_token* (query-string) - OAuth access token.
16028 /// * *alt* (query-string) - Data format for response.
16029 /// * *callback* (query-string) - JSONP
16030 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16031 /// * *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.
16032 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16033 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16034 /// * *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.
16035 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16036 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16037 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleCreateCall<'a, C>
16038 where
16039 T: AsRef<str>,
16040 {
16041 self._additional_params
16042 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16043 self
16044 }
16045
16046 /// Identifies the authorization scope for the method you are building.
16047 ///
16048 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16049 /// [`Scope::CloudPlatform`].
16050 ///
16051 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16052 /// tokens for more than one scope.
16053 ///
16054 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16055 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16056 /// sufficient, a read-write scope will do as well.
16057 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleCreateCall<'a, C>
16058 where
16059 St: AsRef<str>,
16060 {
16061 self._scopes.insert(String::from(scope.as_ref()));
16062 self
16063 }
16064 /// Identifies the authorization scope(s) for the method you are building.
16065 ///
16066 /// See [`Self::add_scope()`] for details.
16067 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleCreateCall<'a, C>
16068 where
16069 I: IntoIterator<Item = St>,
16070 St: AsRef<str>,
16071 {
16072 self._scopes
16073 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16074 self
16075 }
16076
16077 /// Removes all scopes, and no default scope will be used either.
16078 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16079 /// for details).
16080 pub fn clear_scopes(mut self) -> ResponsePolicyRuleCreateCall<'a, C> {
16081 self._scopes.clear();
16082 self
16083 }
16084}
16085
16086/// Deletes a previously created Response Policy Rule.
16087///
16088/// A builder for the *delete* method supported by a *responsePolicyRule* resource.
16089/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
16090///
16091/// # Example
16092///
16093/// Instantiate a resource method builder
16094///
16095/// ```test_harness,no_run
16096/// # extern crate hyper;
16097/// # extern crate hyper_rustls;
16098/// # extern crate google_dns2 as dns2;
16099/// # async fn dox() {
16100/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16101///
16102/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16103/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16104/// # .with_native_roots()
16105/// # .unwrap()
16106/// # .https_only()
16107/// # .enable_http2()
16108/// # .build();
16109///
16110/// # let executor = hyper_util::rt::TokioExecutor::new();
16111/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16112/// # secret,
16113/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16114/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16115/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16116/// # ),
16117/// # ).build().await.unwrap();
16118///
16119/// # let client = hyper_util::client::legacy::Client::builder(
16120/// # hyper_util::rt::TokioExecutor::new()
16121/// # )
16122/// # .build(
16123/// # hyper_rustls::HttpsConnectorBuilder::new()
16124/// # .with_native_roots()
16125/// # .unwrap()
16126/// # .https_or_http()
16127/// # .enable_http2()
16128/// # .build()
16129/// # );
16130/// # let mut hub = Dns::new(client, auth);
16131/// // You can configure optional parameters by calling the respective setters at will, and
16132/// // execute the final call using `doit()`.
16133/// // Values shown here are possibly random and not representative !
16134/// let result = hub.response_policy_rules().delete("project", "location", "responsePolicy", "responsePolicyRule")
16135/// .client_operation_id("Lorem")
16136/// .doit().await;
16137/// # }
16138/// ```
16139pub struct ResponsePolicyRuleDeleteCall<'a, C>
16140where
16141 C: 'a,
16142{
16143 hub: &'a Dns<C>,
16144 _project: String,
16145 _location: String,
16146 _response_policy: String,
16147 _response_policy_rule: String,
16148 _client_operation_id: Option<String>,
16149 _delegate: Option<&'a mut dyn common::Delegate>,
16150 _additional_params: HashMap<String, String>,
16151 _scopes: BTreeSet<String>,
16152}
16153
16154impl<'a, C> common::CallBuilder for ResponsePolicyRuleDeleteCall<'a, C> {}
16155
16156impl<'a, C> ResponsePolicyRuleDeleteCall<'a, C>
16157where
16158 C: common::Connector,
16159{
16160 /// Perform the operation you have build so far.
16161 pub async fn doit(mut self) -> common::Result<common::Response> {
16162 use std::borrow::Cow;
16163 use std::io::{Read, Seek};
16164
16165 use common::{url::Params, ToParts};
16166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16167
16168 let mut dd = common::DefaultDelegate;
16169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16170 dlg.begin(common::MethodInfo {
16171 id: "dns.responsePolicyRules.delete",
16172 http_method: hyper::Method::DELETE,
16173 });
16174
16175 for &field in [
16176 "project",
16177 "location",
16178 "responsePolicy",
16179 "responsePolicyRule",
16180 "clientOperationId",
16181 ]
16182 .iter()
16183 {
16184 if self._additional_params.contains_key(field) {
16185 dlg.finished(false);
16186 return Err(common::Error::FieldClash(field));
16187 }
16188 }
16189
16190 let mut params = Params::with_capacity(6 + self._additional_params.len());
16191 params.push("project", self._project);
16192 params.push("location", self._location);
16193 params.push("responsePolicy", self._response_policy);
16194 params.push("responsePolicyRule", self._response_policy_rule);
16195 if let Some(value) = self._client_operation_id.as_ref() {
16196 params.push("clientOperationId", value);
16197 }
16198
16199 params.extend(self._additional_params.iter());
16200
16201 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
16202 if self._scopes.is_empty() {
16203 self._scopes
16204 .insert(Scope::CloudPlatform.as_ref().to_string());
16205 }
16206
16207 #[allow(clippy::single_element_loop)]
16208 for &(find_this, param_name) in [
16209 ("{project}", "project"),
16210 ("{location}", "location"),
16211 ("{responsePolicy}", "responsePolicy"),
16212 ("{responsePolicyRule}", "responsePolicyRule"),
16213 ]
16214 .iter()
16215 {
16216 url = params.uri_replacement(url, param_name, find_this, false);
16217 }
16218 {
16219 let to_remove = [
16220 "responsePolicyRule",
16221 "responsePolicy",
16222 "location",
16223 "project",
16224 ];
16225 params.remove_params(&to_remove);
16226 }
16227
16228 let url = params.parse_with_url(&url);
16229
16230 loop {
16231 let token = match self
16232 .hub
16233 .auth
16234 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16235 .await
16236 {
16237 Ok(token) => token,
16238 Err(e) => match dlg.token(e) {
16239 Ok(token) => token,
16240 Err(e) => {
16241 dlg.finished(false);
16242 return Err(common::Error::MissingToken(e));
16243 }
16244 },
16245 };
16246 let mut req_result = {
16247 let client = &self.hub.client;
16248 dlg.pre_request();
16249 let mut req_builder = hyper::Request::builder()
16250 .method(hyper::Method::DELETE)
16251 .uri(url.as_str())
16252 .header(USER_AGENT, self.hub._user_agent.clone());
16253
16254 if let Some(token) = token.as_ref() {
16255 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16256 }
16257
16258 let request = req_builder
16259 .header(CONTENT_LENGTH, 0_u64)
16260 .body(common::to_body::<String>(None));
16261
16262 client.request(request.unwrap()).await
16263 };
16264
16265 match req_result {
16266 Err(err) => {
16267 if let common::Retry::After(d) = dlg.http_error(&err) {
16268 sleep(d).await;
16269 continue;
16270 }
16271 dlg.finished(false);
16272 return Err(common::Error::HttpError(err));
16273 }
16274 Ok(res) => {
16275 let (mut parts, body) = res.into_parts();
16276 let mut body = common::Body::new(body);
16277 if !parts.status.is_success() {
16278 let bytes = common::to_bytes(body).await.unwrap_or_default();
16279 let error = serde_json::from_str(&common::to_string(&bytes));
16280 let response = common::to_response(parts, bytes.into());
16281
16282 if let common::Retry::After(d) =
16283 dlg.http_failure(&response, error.as_ref().ok())
16284 {
16285 sleep(d).await;
16286 continue;
16287 }
16288
16289 dlg.finished(false);
16290
16291 return Err(match error {
16292 Ok(value) => common::Error::BadRequest(value),
16293 _ => common::Error::Failure(response),
16294 });
16295 }
16296 let response = common::Response::from_parts(parts, body);
16297
16298 dlg.finished(true);
16299 return Ok(response);
16300 }
16301 }
16302 }
16303 }
16304
16305 /// Identifies the project addressed by this request.
16306 ///
16307 /// Sets the *project* path property to the given value.
16308 ///
16309 /// Even though the property as already been set when instantiating this call,
16310 /// we provide this method for API completeness.
16311 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
16312 self._project = new_value.to_string();
16313 self
16314 }
16315 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
16316 ///
16317 /// Sets the *location* path property to the given value.
16318 ///
16319 /// Even though the property as already been set when instantiating this call,
16320 /// we provide this method for API completeness.
16321 pub fn location(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
16322 self._location = new_value.to_string();
16323 self
16324 }
16325 /// User assigned name of the Response Policy containing the Response Policy Rule.
16326 ///
16327 /// Sets the *response policy* path property to the given value.
16328 ///
16329 /// Even though the property as already been set when instantiating this call,
16330 /// we provide this method for API completeness.
16331 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
16332 self._response_policy = new_value.to_string();
16333 self
16334 }
16335 /// User assigned name of the Response Policy Rule addressed by this request.
16336 ///
16337 /// Sets the *response policy rule* path property to the given value.
16338 ///
16339 /// Even though the property as already been set when instantiating this call,
16340 /// we provide this method for API completeness.
16341 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
16342 self._response_policy_rule = new_value.to_string();
16343 self
16344 }
16345 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
16346 ///
16347 /// Sets the *client operation id* query property to the given value.
16348 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
16349 self._client_operation_id = Some(new_value.to_string());
16350 self
16351 }
16352 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16353 /// while executing the actual API request.
16354 ///
16355 /// ````text
16356 /// It should be used to handle progress information, and to implement a certain level of resilience.
16357 /// ````
16358 ///
16359 /// Sets the *delegate* property to the given value.
16360 pub fn delegate(
16361 mut self,
16362 new_value: &'a mut dyn common::Delegate,
16363 ) -> ResponsePolicyRuleDeleteCall<'a, C> {
16364 self._delegate = Some(new_value);
16365 self
16366 }
16367
16368 /// Set any additional parameter of the query string used in the request.
16369 /// It should be used to set parameters which are not yet available through their own
16370 /// setters.
16371 ///
16372 /// Please note that this method must not be used to set any of the known parameters
16373 /// which have their own setter method. If done anyway, the request will fail.
16374 ///
16375 /// # Additional Parameters
16376 ///
16377 /// * *$.xgafv* (query-string) - V1 error format.
16378 /// * *access_token* (query-string) - OAuth access token.
16379 /// * *alt* (query-string) - Data format for response.
16380 /// * *callback* (query-string) - JSONP
16381 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16382 /// * *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.
16383 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16384 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16385 /// * *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.
16386 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16387 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16388 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleDeleteCall<'a, C>
16389 where
16390 T: AsRef<str>,
16391 {
16392 self._additional_params
16393 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16394 self
16395 }
16396
16397 /// Identifies the authorization scope for the method you are building.
16398 ///
16399 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16400 /// [`Scope::CloudPlatform`].
16401 ///
16402 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16403 /// tokens for more than one scope.
16404 ///
16405 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16406 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16407 /// sufficient, a read-write scope will do as well.
16408 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleDeleteCall<'a, C>
16409 where
16410 St: AsRef<str>,
16411 {
16412 self._scopes.insert(String::from(scope.as_ref()));
16413 self
16414 }
16415 /// Identifies the authorization scope(s) for the method you are building.
16416 ///
16417 /// See [`Self::add_scope()`] for details.
16418 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleDeleteCall<'a, C>
16419 where
16420 I: IntoIterator<Item = St>,
16421 St: AsRef<str>,
16422 {
16423 self._scopes
16424 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16425 self
16426 }
16427
16428 /// Removes all scopes, and no default scope will be used either.
16429 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16430 /// for details).
16431 pub fn clear_scopes(mut self) -> ResponsePolicyRuleDeleteCall<'a, C> {
16432 self._scopes.clear();
16433 self
16434 }
16435}
16436
16437/// Fetches the representation of an existing Response Policy Rule.
16438///
16439/// A builder for the *get* method supported by a *responsePolicyRule* resource.
16440/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
16441///
16442/// # Example
16443///
16444/// Instantiate a resource method builder
16445///
16446/// ```test_harness,no_run
16447/// # extern crate hyper;
16448/// # extern crate hyper_rustls;
16449/// # extern crate google_dns2 as dns2;
16450/// # async fn dox() {
16451/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16452///
16453/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16454/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16455/// # .with_native_roots()
16456/// # .unwrap()
16457/// # .https_only()
16458/// # .enable_http2()
16459/// # .build();
16460///
16461/// # let executor = hyper_util::rt::TokioExecutor::new();
16462/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16463/// # secret,
16464/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16465/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16466/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16467/// # ),
16468/// # ).build().await.unwrap();
16469///
16470/// # let client = hyper_util::client::legacy::Client::builder(
16471/// # hyper_util::rt::TokioExecutor::new()
16472/// # )
16473/// # .build(
16474/// # hyper_rustls::HttpsConnectorBuilder::new()
16475/// # .with_native_roots()
16476/// # .unwrap()
16477/// # .https_or_http()
16478/// # .enable_http2()
16479/// # .build()
16480/// # );
16481/// # let mut hub = Dns::new(client, auth);
16482/// // You can configure optional parameters by calling the respective setters at will, and
16483/// // execute the final call using `doit()`.
16484/// // Values shown here are possibly random and not representative !
16485/// let result = hub.response_policy_rules().get("project", "location", "responsePolicy", "responsePolicyRule")
16486/// .client_operation_id("sit")
16487/// .doit().await;
16488/// # }
16489/// ```
16490pub struct ResponsePolicyRuleGetCall<'a, C>
16491where
16492 C: 'a,
16493{
16494 hub: &'a Dns<C>,
16495 _project: String,
16496 _location: String,
16497 _response_policy: String,
16498 _response_policy_rule: String,
16499 _client_operation_id: Option<String>,
16500 _delegate: Option<&'a mut dyn common::Delegate>,
16501 _additional_params: HashMap<String, String>,
16502 _scopes: BTreeSet<String>,
16503}
16504
16505impl<'a, C> common::CallBuilder for ResponsePolicyRuleGetCall<'a, C> {}
16506
16507impl<'a, C> ResponsePolicyRuleGetCall<'a, C>
16508where
16509 C: common::Connector,
16510{
16511 /// Perform the operation you have build so far.
16512 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicyRule)> {
16513 use std::borrow::Cow;
16514 use std::io::{Read, Seek};
16515
16516 use common::{url::Params, ToParts};
16517 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16518
16519 let mut dd = common::DefaultDelegate;
16520 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16521 dlg.begin(common::MethodInfo {
16522 id: "dns.responsePolicyRules.get",
16523 http_method: hyper::Method::GET,
16524 });
16525
16526 for &field in [
16527 "alt",
16528 "project",
16529 "location",
16530 "responsePolicy",
16531 "responsePolicyRule",
16532 "clientOperationId",
16533 ]
16534 .iter()
16535 {
16536 if self._additional_params.contains_key(field) {
16537 dlg.finished(false);
16538 return Err(common::Error::FieldClash(field));
16539 }
16540 }
16541
16542 let mut params = Params::with_capacity(7 + self._additional_params.len());
16543 params.push("project", self._project);
16544 params.push("location", self._location);
16545 params.push("responsePolicy", self._response_policy);
16546 params.push("responsePolicyRule", self._response_policy_rule);
16547 if let Some(value) = self._client_operation_id.as_ref() {
16548 params.push("clientOperationId", value);
16549 }
16550
16551 params.extend(self._additional_params.iter());
16552
16553 params.push("alt", "json");
16554 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
16555 if self._scopes.is_empty() {
16556 self._scopes
16557 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
16558 }
16559
16560 #[allow(clippy::single_element_loop)]
16561 for &(find_this, param_name) in [
16562 ("{project}", "project"),
16563 ("{location}", "location"),
16564 ("{responsePolicy}", "responsePolicy"),
16565 ("{responsePolicyRule}", "responsePolicyRule"),
16566 ]
16567 .iter()
16568 {
16569 url = params.uri_replacement(url, param_name, find_this, false);
16570 }
16571 {
16572 let to_remove = [
16573 "responsePolicyRule",
16574 "responsePolicy",
16575 "location",
16576 "project",
16577 ];
16578 params.remove_params(&to_remove);
16579 }
16580
16581 let url = params.parse_with_url(&url);
16582
16583 loop {
16584 let token = match self
16585 .hub
16586 .auth
16587 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16588 .await
16589 {
16590 Ok(token) => token,
16591 Err(e) => match dlg.token(e) {
16592 Ok(token) => token,
16593 Err(e) => {
16594 dlg.finished(false);
16595 return Err(common::Error::MissingToken(e));
16596 }
16597 },
16598 };
16599 let mut req_result = {
16600 let client = &self.hub.client;
16601 dlg.pre_request();
16602 let mut req_builder = hyper::Request::builder()
16603 .method(hyper::Method::GET)
16604 .uri(url.as_str())
16605 .header(USER_AGENT, self.hub._user_agent.clone());
16606
16607 if let Some(token) = token.as_ref() {
16608 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16609 }
16610
16611 let request = req_builder
16612 .header(CONTENT_LENGTH, 0_u64)
16613 .body(common::to_body::<String>(None));
16614
16615 client.request(request.unwrap()).await
16616 };
16617
16618 match req_result {
16619 Err(err) => {
16620 if let common::Retry::After(d) = dlg.http_error(&err) {
16621 sleep(d).await;
16622 continue;
16623 }
16624 dlg.finished(false);
16625 return Err(common::Error::HttpError(err));
16626 }
16627 Ok(res) => {
16628 let (mut parts, body) = res.into_parts();
16629 let mut body = common::Body::new(body);
16630 if !parts.status.is_success() {
16631 let bytes = common::to_bytes(body).await.unwrap_or_default();
16632 let error = serde_json::from_str(&common::to_string(&bytes));
16633 let response = common::to_response(parts, bytes.into());
16634
16635 if let common::Retry::After(d) =
16636 dlg.http_failure(&response, error.as_ref().ok())
16637 {
16638 sleep(d).await;
16639 continue;
16640 }
16641
16642 dlg.finished(false);
16643
16644 return Err(match error {
16645 Ok(value) => common::Error::BadRequest(value),
16646 _ => common::Error::Failure(response),
16647 });
16648 }
16649 let response = {
16650 let bytes = common::to_bytes(body).await.unwrap_or_default();
16651 let encoded = common::to_string(&bytes);
16652 match serde_json::from_str(&encoded) {
16653 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16654 Err(error) => {
16655 dlg.response_json_decode_error(&encoded, &error);
16656 return Err(common::Error::JsonDecodeError(
16657 encoded.to_string(),
16658 error,
16659 ));
16660 }
16661 }
16662 };
16663
16664 dlg.finished(true);
16665 return Ok(response);
16666 }
16667 }
16668 }
16669 }
16670
16671 /// Identifies the project addressed by this request.
16672 ///
16673 /// Sets the *project* path property to the given value.
16674 ///
16675 /// Even though the property as already been set when instantiating this call,
16676 /// we provide this method for API completeness.
16677 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
16678 self._project = new_value.to_string();
16679 self
16680 }
16681 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
16682 ///
16683 /// Sets the *location* path property to the given value.
16684 ///
16685 /// Even though the property as already been set when instantiating this call,
16686 /// we provide this method for API completeness.
16687 pub fn location(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
16688 self._location = new_value.to_string();
16689 self
16690 }
16691 /// User assigned name of the Response Policy containing the Response Policy Rule.
16692 ///
16693 /// Sets the *response policy* path property to the given value.
16694 ///
16695 /// Even though the property as already been set when instantiating this call,
16696 /// we provide this method for API completeness.
16697 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
16698 self._response_policy = new_value.to_string();
16699 self
16700 }
16701 /// User assigned name of the Response Policy Rule addressed by this request.
16702 ///
16703 /// Sets the *response policy rule* path property to the given value.
16704 ///
16705 /// Even though the property as already been set when instantiating this call,
16706 /// we provide this method for API completeness.
16707 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
16708 self._response_policy_rule = new_value.to_string();
16709 self
16710 }
16711 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
16712 ///
16713 /// Sets the *client operation id* query property to the given value.
16714 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
16715 self._client_operation_id = Some(new_value.to_string());
16716 self
16717 }
16718 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16719 /// while executing the actual API request.
16720 ///
16721 /// ````text
16722 /// It should be used to handle progress information, and to implement a certain level of resilience.
16723 /// ````
16724 ///
16725 /// Sets the *delegate* property to the given value.
16726 pub fn delegate(
16727 mut self,
16728 new_value: &'a mut dyn common::Delegate,
16729 ) -> ResponsePolicyRuleGetCall<'a, C> {
16730 self._delegate = Some(new_value);
16731 self
16732 }
16733
16734 /// Set any additional parameter of the query string used in the request.
16735 /// It should be used to set parameters which are not yet available through their own
16736 /// setters.
16737 ///
16738 /// Please note that this method must not be used to set any of the known parameters
16739 /// which have their own setter method. If done anyway, the request will fail.
16740 ///
16741 /// # Additional Parameters
16742 ///
16743 /// * *$.xgafv* (query-string) - V1 error format.
16744 /// * *access_token* (query-string) - OAuth access token.
16745 /// * *alt* (query-string) - Data format for response.
16746 /// * *callback* (query-string) - JSONP
16747 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16748 /// * *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.
16749 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16750 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16751 /// * *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.
16752 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16753 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16754 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleGetCall<'a, C>
16755 where
16756 T: AsRef<str>,
16757 {
16758 self._additional_params
16759 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16760 self
16761 }
16762
16763 /// Identifies the authorization scope for the method you are building.
16764 ///
16765 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16766 /// [`Scope::NdevClouddnReadonly`].
16767 ///
16768 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16769 /// tokens for more than one scope.
16770 ///
16771 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16772 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16773 /// sufficient, a read-write scope will do as well.
16774 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleGetCall<'a, C>
16775 where
16776 St: AsRef<str>,
16777 {
16778 self._scopes.insert(String::from(scope.as_ref()));
16779 self
16780 }
16781 /// Identifies the authorization scope(s) for the method you are building.
16782 ///
16783 /// See [`Self::add_scope()`] for details.
16784 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleGetCall<'a, C>
16785 where
16786 I: IntoIterator<Item = St>,
16787 St: AsRef<str>,
16788 {
16789 self._scopes
16790 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16791 self
16792 }
16793
16794 /// Removes all scopes, and no default scope will be used either.
16795 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16796 /// for details).
16797 pub fn clear_scopes(mut self) -> ResponsePolicyRuleGetCall<'a, C> {
16798 self._scopes.clear();
16799 self
16800 }
16801}
16802
16803/// Enumerates all Response Policy Rules associated with a project.
16804///
16805/// A builder for the *list* method supported by a *responsePolicyRule* resource.
16806/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
16807///
16808/// # Example
16809///
16810/// Instantiate a resource method builder
16811///
16812/// ```test_harness,no_run
16813/// # extern crate hyper;
16814/// # extern crate hyper_rustls;
16815/// # extern crate google_dns2 as dns2;
16816/// # async fn dox() {
16817/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16818///
16819/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16820/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16821/// # .with_native_roots()
16822/// # .unwrap()
16823/// # .https_only()
16824/// # .enable_http2()
16825/// # .build();
16826///
16827/// # let executor = hyper_util::rt::TokioExecutor::new();
16828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16829/// # secret,
16830/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16831/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16832/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16833/// # ),
16834/// # ).build().await.unwrap();
16835///
16836/// # let client = hyper_util::client::legacy::Client::builder(
16837/// # hyper_util::rt::TokioExecutor::new()
16838/// # )
16839/// # .build(
16840/// # hyper_rustls::HttpsConnectorBuilder::new()
16841/// # .with_native_roots()
16842/// # .unwrap()
16843/// # .https_or_http()
16844/// # .enable_http2()
16845/// # .build()
16846/// # );
16847/// # let mut hub = Dns::new(client, auth);
16848/// // You can configure optional parameters by calling the respective setters at will, and
16849/// // execute the final call using `doit()`.
16850/// // Values shown here are possibly random and not representative !
16851/// let result = hub.response_policy_rules().list("project", "location", "responsePolicy")
16852/// .page_token("et")
16853/// .max_results(-12)
16854/// .doit().await;
16855/// # }
16856/// ```
16857pub struct ResponsePolicyRuleListCall<'a, C>
16858where
16859 C: 'a,
16860{
16861 hub: &'a Dns<C>,
16862 _project: String,
16863 _location: String,
16864 _response_policy: String,
16865 _page_token: Option<String>,
16866 _max_results: Option<i32>,
16867 _delegate: Option<&'a mut dyn common::Delegate>,
16868 _additional_params: HashMap<String, String>,
16869 _scopes: BTreeSet<String>,
16870}
16871
16872impl<'a, C> common::CallBuilder for ResponsePolicyRuleListCall<'a, C> {}
16873
16874impl<'a, C> ResponsePolicyRuleListCall<'a, C>
16875where
16876 C: common::Connector,
16877{
16878 /// Perform the operation you have build so far.
16879 pub async fn doit(
16880 mut self,
16881 ) -> common::Result<(common::Response, ResponsePolicyRulesListResponse)> {
16882 use std::borrow::Cow;
16883 use std::io::{Read, Seek};
16884
16885 use common::{url::Params, ToParts};
16886 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16887
16888 let mut dd = common::DefaultDelegate;
16889 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16890 dlg.begin(common::MethodInfo {
16891 id: "dns.responsePolicyRules.list",
16892 http_method: hyper::Method::GET,
16893 });
16894
16895 for &field in [
16896 "alt",
16897 "project",
16898 "location",
16899 "responsePolicy",
16900 "pageToken",
16901 "maxResults",
16902 ]
16903 .iter()
16904 {
16905 if self._additional_params.contains_key(field) {
16906 dlg.finished(false);
16907 return Err(common::Error::FieldClash(field));
16908 }
16909 }
16910
16911 let mut params = Params::with_capacity(7 + self._additional_params.len());
16912 params.push("project", self._project);
16913 params.push("location", self._location);
16914 params.push("responsePolicy", self._response_policy);
16915 if let Some(value) = self._page_token.as_ref() {
16916 params.push("pageToken", value);
16917 }
16918 if let Some(value) = self._max_results.as_ref() {
16919 params.push("maxResults", value.to_string());
16920 }
16921
16922 params.extend(self._additional_params.iter());
16923
16924 params.push("alt", "json");
16925 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}/rules";
16926 if self._scopes.is_empty() {
16927 self._scopes
16928 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
16929 }
16930
16931 #[allow(clippy::single_element_loop)]
16932 for &(find_this, param_name) in [
16933 ("{project}", "project"),
16934 ("{location}", "location"),
16935 ("{responsePolicy}", "responsePolicy"),
16936 ]
16937 .iter()
16938 {
16939 url = params.uri_replacement(url, param_name, find_this, false);
16940 }
16941 {
16942 let to_remove = ["responsePolicy", "location", "project"];
16943 params.remove_params(&to_remove);
16944 }
16945
16946 let url = params.parse_with_url(&url);
16947
16948 loop {
16949 let token = match self
16950 .hub
16951 .auth
16952 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16953 .await
16954 {
16955 Ok(token) => token,
16956 Err(e) => match dlg.token(e) {
16957 Ok(token) => token,
16958 Err(e) => {
16959 dlg.finished(false);
16960 return Err(common::Error::MissingToken(e));
16961 }
16962 },
16963 };
16964 let mut req_result = {
16965 let client = &self.hub.client;
16966 dlg.pre_request();
16967 let mut req_builder = hyper::Request::builder()
16968 .method(hyper::Method::GET)
16969 .uri(url.as_str())
16970 .header(USER_AGENT, self.hub._user_agent.clone());
16971
16972 if let Some(token) = token.as_ref() {
16973 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16974 }
16975
16976 let request = req_builder
16977 .header(CONTENT_LENGTH, 0_u64)
16978 .body(common::to_body::<String>(None));
16979
16980 client.request(request.unwrap()).await
16981 };
16982
16983 match req_result {
16984 Err(err) => {
16985 if let common::Retry::After(d) = dlg.http_error(&err) {
16986 sleep(d).await;
16987 continue;
16988 }
16989 dlg.finished(false);
16990 return Err(common::Error::HttpError(err));
16991 }
16992 Ok(res) => {
16993 let (mut parts, body) = res.into_parts();
16994 let mut body = common::Body::new(body);
16995 if !parts.status.is_success() {
16996 let bytes = common::to_bytes(body).await.unwrap_or_default();
16997 let error = serde_json::from_str(&common::to_string(&bytes));
16998 let response = common::to_response(parts, bytes.into());
16999
17000 if let common::Retry::After(d) =
17001 dlg.http_failure(&response, error.as_ref().ok())
17002 {
17003 sleep(d).await;
17004 continue;
17005 }
17006
17007 dlg.finished(false);
17008
17009 return Err(match error {
17010 Ok(value) => common::Error::BadRequest(value),
17011 _ => common::Error::Failure(response),
17012 });
17013 }
17014 let response = {
17015 let bytes = common::to_bytes(body).await.unwrap_or_default();
17016 let encoded = common::to_string(&bytes);
17017 match serde_json::from_str(&encoded) {
17018 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17019 Err(error) => {
17020 dlg.response_json_decode_error(&encoded, &error);
17021 return Err(common::Error::JsonDecodeError(
17022 encoded.to_string(),
17023 error,
17024 ));
17025 }
17026 }
17027 };
17028
17029 dlg.finished(true);
17030 return Ok(response);
17031 }
17032 }
17033 }
17034 }
17035
17036 /// Identifies the project addressed by this request.
17037 ///
17038 /// Sets the *project* path property to the given value.
17039 ///
17040 /// Even though the property as already been set when instantiating this call,
17041 /// we provide this method for API completeness.
17042 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
17043 self._project = new_value.to_string();
17044 self
17045 }
17046 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
17047 ///
17048 /// Sets the *location* path property to the given value.
17049 ///
17050 /// Even though the property as already been set when instantiating this call,
17051 /// we provide this method for API completeness.
17052 pub fn location(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
17053 self._location = new_value.to_string();
17054 self
17055 }
17056 /// User assigned name of the Response Policy to list.
17057 ///
17058 /// Sets the *response policy* path property to the given value.
17059 ///
17060 /// Even though the property as already been set when instantiating this call,
17061 /// we provide this method for API completeness.
17062 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
17063 self._response_policy = new_value.to_string();
17064 self
17065 }
17066 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
17067 ///
17068 /// Sets the *page token* query property to the given value.
17069 pub fn page_token(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
17070 self._page_token = Some(new_value.to_string());
17071 self
17072 }
17073 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
17074 ///
17075 /// Sets the *max results* query property to the given value.
17076 pub fn max_results(mut self, new_value: i32) -> ResponsePolicyRuleListCall<'a, C> {
17077 self._max_results = Some(new_value);
17078 self
17079 }
17080 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17081 /// while executing the actual API request.
17082 ///
17083 /// ````text
17084 /// It should be used to handle progress information, and to implement a certain level of resilience.
17085 /// ````
17086 ///
17087 /// Sets the *delegate* property to the given value.
17088 pub fn delegate(
17089 mut self,
17090 new_value: &'a mut dyn common::Delegate,
17091 ) -> ResponsePolicyRuleListCall<'a, C> {
17092 self._delegate = Some(new_value);
17093 self
17094 }
17095
17096 /// Set any additional parameter of the query string used in the request.
17097 /// It should be used to set parameters which are not yet available through their own
17098 /// setters.
17099 ///
17100 /// Please note that this method must not be used to set any of the known parameters
17101 /// which have their own setter method. If done anyway, the request will fail.
17102 ///
17103 /// # Additional Parameters
17104 ///
17105 /// * *$.xgafv* (query-string) - V1 error format.
17106 /// * *access_token* (query-string) - OAuth access token.
17107 /// * *alt* (query-string) - Data format for response.
17108 /// * *callback* (query-string) - JSONP
17109 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17110 /// * *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.
17111 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17112 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17113 /// * *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.
17114 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17115 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17116 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleListCall<'a, C>
17117 where
17118 T: AsRef<str>,
17119 {
17120 self._additional_params
17121 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17122 self
17123 }
17124
17125 /// Identifies the authorization scope for the method you are building.
17126 ///
17127 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17128 /// [`Scope::NdevClouddnReadonly`].
17129 ///
17130 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17131 /// tokens for more than one scope.
17132 ///
17133 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17134 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17135 /// sufficient, a read-write scope will do as well.
17136 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleListCall<'a, C>
17137 where
17138 St: AsRef<str>,
17139 {
17140 self._scopes.insert(String::from(scope.as_ref()));
17141 self
17142 }
17143 /// Identifies the authorization scope(s) for the method you are building.
17144 ///
17145 /// See [`Self::add_scope()`] for details.
17146 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleListCall<'a, C>
17147 where
17148 I: IntoIterator<Item = St>,
17149 St: AsRef<str>,
17150 {
17151 self._scopes
17152 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17153 self
17154 }
17155
17156 /// Removes all scopes, and no default scope will be used either.
17157 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17158 /// for details).
17159 pub fn clear_scopes(mut self) -> ResponsePolicyRuleListCall<'a, C> {
17160 self._scopes.clear();
17161 self
17162 }
17163}
17164
17165/// Applies a partial update to an existing Response Policy Rule.
17166///
17167/// A builder for the *patch* method supported by a *responsePolicyRule* resource.
17168/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
17169///
17170/// # Example
17171///
17172/// Instantiate a resource method builder
17173///
17174/// ```test_harness,no_run
17175/// # extern crate hyper;
17176/// # extern crate hyper_rustls;
17177/// # extern crate google_dns2 as dns2;
17178/// use dns2::api::ResponsePolicyRule;
17179/// # async fn dox() {
17180/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17181///
17182/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17183/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17184/// # .with_native_roots()
17185/// # .unwrap()
17186/// # .https_only()
17187/// # .enable_http2()
17188/// # .build();
17189///
17190/// # let executor = hyper_util::rt::TokioExecutor::new();
17191/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17192/// # secret,
17193/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17194/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17195/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17196/// # ),
17197/// # ).build().await.unwrap();
17198///
17199/// # let client = hyper_util::client::legacy::Client::builder(
17200/// # hyper_util::rt::TokioExecutor::new()
17201/// # )
17202/// # .build(
17203/// # hyper_rustls::HttpsConnectorBuilder::new()
17204/// # .with_native_roots()
17205/// # .unwrap()
17206/// # .https_or_http()
17207/// # .enable_http2()
17208/// # .build()
17209/// # );
17210/// # let mut hub = Dns::new(client, auth);
17211/// // As the method needs a request, you would usually fill it with the desired information
17212/// // into the respective structure. Some of the parts shown here might not be applicable !
17213/// // Values shown here are possibly random and not representative !
17214/// let mut req = ResponsePolicyRule::default();
17215///
17216/// // You can configure optional parameters by calling the respective setters at will, and
17217/// // execute the final call using `doit()`.
17218/// // Values shown here are possibly random and not representative !
17219/// let result = hub.response_policy_rules().patch(req, "project", "location", "responsePolicy", "responsePolicyRule")
17220/// .client_operation_id("aliquyam")
17221/// .doit().await;
17222/// # }
17223/// ```
17224pub struct ResponsePolicyRulePatchCall<'a, C>
17225where
17226 C: 'a,
17227{
17228 hub: &'a Dns<C>,
17229 _request: ResponsePolicyRule,
17230 _project: String,
17231 _location: String,
17232 _response_policy: String,
17233 _response_policy_rule: String,
17234 _client_operation_id: Option<String>,
17235 _delegate: Option<&'a mut dyn common::Delegate>,
17236 _additional_params: HashMap<String, String>,
17237 _scopes: BTreeSet<String>,
17238}
17239
17240impl<'a, C> common::CallBuilder for ResponsePolicyRulePatchCall<'a, C> {}
17241
17242impl<'a, C> ResponsePolicyRulePatchCall<'a, C>
17243where
17244 C: common::Connector,
17245{
17246 /// Perform the operation you have build so far.
17247 pub async fn doit(
17248 mut self,
17249 ) -> common::Result<(common::Response, ResponsePolicyRulesPatchResponse)> {
17250 use std::borrow::Cow;
17251 use std::io::{Read, Seek};
17252
17253 use common::{url::Params, ToParts};
17254 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17255
17256 let mut dd = common::DefaultDelegate;
17257 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17258 dlg.begin(common::MethodInfo {
17259 id: "dns.responsePolicyRules.patch",
17260 http_method: hyper::Method::PATCH,
17261 });
17262
17263 for &field in [
17264 "alt",
17265 "project",
17266 "location",
17267 "responsePolicy",
17268 "responsePolicyRule",
17269 "clientOperationId",
17270 ]
17271 .iter()
17272 {
17273 if self._additional_params.contains_key(field) {
17274 dlg.finished(false);
17275 return Err(common::Error::FieldClash(field));
17276 }
17277 }
17278
17279 let mut params = Params::with_capacity(8 + self._additional_params.len());
17280 params.push("project", self._project);
17281 params.push("location", self._location);
17282 params.push("responsePolicy", self._response_policy);
17283 params.push("responsePolicyRule", self._response_policy_rule);
17284 if let Some(value) = self._client_operation_id.as_ref() {
17285 params.push("clientOperationId", value);
17286 }
17287
17288 params.extend(self._additional_params.iter());
17289
17290 params.push("alt", "json");
17291 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
17292 if self._scopes.is_empty() {
17293 self._scopes
17294 .insert(Scope::CloudPlatform.as_ref().to_string());
17295 }
17296
17297 #[allow(clippy::single_element_loop)]
17298 for &(find_this, param_name) in [
17299 ("{project}", "project"),
17300 ("{location}", "location"),
17301 ("{responsePolicy}", "responsePolicy"),
17302 ("{responsePolicyRule}", "responsePolicyRule"),
17303 ]
17304 .iter()
17305 {
17306 url = params.uri_replacement(url, param_name, find_this, false);
17307 }
17308 {
17309 let to_remove = [
17310 "responsePolicyRule",
17311 "responsePolicy",
17312 "location",
17313 "project",
17314 ];
17315 params.remove_params(&to_remove);
17316 }
17317
17318 let url = params.parse_with_url(&url);
17319
17320 let mut json_mime_type = mime::APPLICATION_JSON;
17321 let mut request_value_reader = {
17322 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17323 common::remove_json_null_values(&mut value);
17324 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17325 serde_json::to_writer(&mut dst, &value).unwrap();
17326 dst
17327 };
17328 let request_size = request_value_reader
17329 .seek(std::io::SeekFrom::End(0))
17330 .unwrap();
17331 request_value_reader
17332 .seek(std::io::SeekFrom::Start(0))
17333 .unwrap();
17334
17335 loop {
17336 let token = match self
17337 .hub
17338 .auth
17339 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17340 .await
17341 {
17342 Ok(token) => token,
17343 Err(e) => match dlg.token(e) {
17344 Ok(token) => token,
17345 Err(e) => {
17346 dlg.finished(false);
17347 return Err(common::Error::MissingToken(e));
17348 }
17349 },
17350 };
17351 request_value_reader
17352 .seek(std::io::SeekFrom::Start(0))
17353 .unwrap();
17354 let mut req_result = {
17355 let client = &self.hub.client;
17356 dlg.pre_request();
17357 let mut req_builder = hyper::Request::builder()
17358 .method(hyper::Method::PATCH)
17359 .uri(url.as_str())
17360 .header(USER_AGENT, self.hub._user_agent.clone());
17361
17362 if let Some(token) = token.as_ref() {
17363 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17364 }
17365
17366 let request = req_builder
17367 .header(CONTENT_TYPE, json_mime_type.to_string())
17368 .header(CONTENT_LENGTH, request_size as u64)
17369 .body(common::to_body(
17370 request_value_reader.get_ref().clone().into(),
17371 ));
17372
17373 client.request(request.unwrap()).await
17374 };
17375
17376 match req_result {
17377 Err(err) => {
17378 if let common::Retry::After(d) = dlg.http_error(&err) {
17379 sleep(d).await;
17380 continue;
17381 }
17382 dlg.finished(false);
17383 return Err(common::Error::HttpError(err));
17384 }
17385 Ok(res) => {
17386 let (mut parts, body) = res.into_parts();
17387 let mut body = common::Body::new(body);
17388 if !parts.status.is_success() {
17389 let bytes = common::to_bytes(body).await.unwrap_or_default();
17390 let error = serde_json::from_str(&common::to_string(&bytes));
17391 let response = common::to_response(parts, bytes.into());
17392
17393 if let common::Retry::After(d) =
17394 dlg.http_failure(&response, error.as_ref().ok())
17395 {
17396 sleep(d).await;
17397 continue;
17398 }
17399
17400 dlg.finished(false);
17401
17402 return Err(match error {
17403 Ok(value) => common::Error::BadRequest(value),
17404 _ => common::Error::Failure(response),
17405 });
17406 }
17407 let response = {
17408 let bytes = common::to_bytes(body).await.unwrap_or_default();
17409 let encoded = common::to_string(&bytes);
17410 match serde_json::from_str(&encoded) {
17411 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17412 Err(error) => {
17413 dlg.response_json_decode_error(&encoded, &error);
17414 return Err(common::Error::JsonDecodeError(
17415 encoded.to_string(),
17416 error,
17417 ));
17418 }
17419 }
17420 };
17421
17422 dlg.finished(true);
17423 return Ok(response);
17424 }
17425 }
17426 }
17427 }
17428
17429 ///
17430 /// Sets the *request* property to the given value.
17431 ///
17432 /// Even though the property as already been set when instantiating this call,
17433 /// we provide this method for API completeness.
17434 pub fn request(mut self, new_value: ResponsePolicyRule) -> ResponsePolicyRulePatchCall<'a, C> {
17435 self._request = new_value;
17436 self
17437 }
17438 /// Identifies the project addressed by this request.
17439 ///
17440 /// Sets the *project* path property to the given value.
17441 ///
17442 /// Even though the property as already been set when instantiating this call,
17443 /// we provide this method for API completeness.
17444 pub fn project(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
17445 self._project = new_value.to_string();
17446 self
17447 }
17448 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
17449 ///
17450 /// Sets the *location* path property to the given value.
17451 ///
17452 /// Even though the property as already been set when instantiating this call,
17453 /// we provide this method for API completeness.
17454 pub fn location(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
17455 self._location = new_value.to_string();
17456 self
17457 }
17458 /// User assigned name of the Response Policy containing the Response Policy Rule.
17459 ///
17460 /// Sets the *response policy* path property to the given value.
17461 ///
17462 /// Even though the property as already been set when instantiating this call,
17463 /// we provide this method for API completeness.
17464 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
17465 self._response_policy = new_value.to_string();
17466 self
17467 }
17468 /// User assigned name of the Response Policy Rule addressed by this request.
17469 ///
17470 /// Sets the *response policy rule* path property to the given value.
17471 ///
17472 /// Even though the property as already been set when instantiating this call,
17473 /// we provide this method for API completeness.
17474 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
17475 self._response_policy_rule = new_value.to_string();
17476 self
17477 }
17478 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
17479 ///
17480 /// Sets the *client operation id* query property to the given value.
17481 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
17482 self._client_operation_id = Some(new_value.to_string());
17483 self
17484 }
17485 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17486 /// while executing the actual API request.
17487 ///
17488 /// ````text
17489 /// It should be used to handle progress information, and to implement a certain level of resilience.
17490 /// ````
17491 ///
17492 /// Sets the *delegate* property to the given value.
17493 pub fn delegate(
17494 mut self,
17495 new_value: &'a mut dyn common::Delegate,
17496 ) -> ResponsePolicyRulePatchCall<'a, C> {
17497 self._delegate = Some(new_value);
17498 self
17499 }
17500
17501 /// Set any additional parameter of the query string used in the request.
17502 /// It should be used to set parameters which are not yet available through their own
17503 /// setters.
17504 ///
17505 /// Please note that this method must not be used to set any of the known parameters
17506 /// which have their own setter method. If done anyway, the request will fail.
17507 ///
17508 /// # Additional Parameters
17509 ///
17510 /// * *$.xgafv* (query-string) - V1 error format.
17511 /// * *access_token* (query-string) - OAuth access token.
17512 /// * *alt* (query-string) - Data format for response.
17513 /// * *callback* (query-string) - JSONP
17514 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17515 /// * *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.
17516 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17517 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17518 /// * *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.
17519 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17520 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17521 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRulePatchCall<'a, C>
17522 where
17523 T: AsRef<str>,
17524 {
17525 self._additional_params
17526 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17527 self
17528 }
17529
17530 /// Identifies the authorization scope for the method you are building.
17531 ///
17532 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17533 /// [`Scope::CloudPlatform`].
17534 ///
17535 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17536 /// tokens for more than one scope.
17537 ///
17538 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17539 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17540 /// sufficient, a read-write scope will do as well.
17541 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRulePatchCall<'a, C>
17542 where
17543 St: AsRef<str>,
17544 {
17545 self._scopes.insert(String::from(scope.as_ref()));
17546 self
17547 }
17548 /// Identifies the authorization scope(s) for the method you are building.
17549 ///
17550 /// See [`Self::add_scope()`] for details.
17551 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRulePatchCall<'a, C>
17552 where
17553 I: IntoIterator<Item = St>,
17554 St: AsRef<str>,
17555 {
17556 self._scopes
17557 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17558 self
17559 }
17560
17561 /// Removes all scopes, and no default scope will be used either.
17562 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17563 /// for details).
17564 pub fn clear_scopes(mut self) -> ResponsePolicyRulePatchCall<'a, C> {
17565 self._scopes.clear();
17566 self
17567 }
17568}
17569
17570/// Updates an existing Response Policy Rule.
17571///
17572/// A builder for the *update* method supported by a *responsePolicyRule* resource.
17573/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
17574///
17575/// # Example
17576///
17577/// Instantiate a resource method builder
17578///
17579/// ```test_harness,no_run
17580/// # extern crate hyper;
17581/// # extern crate hyper_rustls;
17582/// # extern crate google_dns2 as dns2;
17583/// use dns2::api::ResponsePolicyRule;
17584/// # async fn dox() {
17585/// # use dns2::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17586///
17587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17588/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17589/// # .with_native_roots()
17590/// # .unwrap()
17591/// # .https_only()
17592/// # .enable_http2()
17593/// # .build();
17594///
17595/// # let executor = hyper_util::rt::TokioExecutor::new();
17596/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17597/// # secret,
17598/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17599/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17600/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17601/// # ),
17602/// # ).build().await.unwrap();
17603///
17604/// # let client = hyper_util::client::legacy::Client::builder(
17605/// # hyper_util::rt::TokioExecutor::new()
17606/// # )
17607/// # .build(
17608/// # hyper_rustls::HttpsConnectorBuilder::new()
17609/// # .with_native_roots()
17610/// # .unwrap()
17611/// # .https_or_http()
17612/// # .enable_http2()
17613/// # .build()
17614/// # );
17615/// # let mut hub = Dns::new(client, auth);
17616/// // As the method needs a request, you would usually fill it with the desired information
17617/// // into the respective structure. Some of the parts shown here might not be applicable !
17618/// // Values shown here are possibly random and not representative !
17619/// let mut req = ResponsePolicyRule::default();
17620///
17621/// // You can configure optional parameters by calling the respective setters at will, and
17622/// // execute the final call using `doit()`.
17623/// // Values shown here are possibly random and not representative !
17624/// let result = hub.response_policy_rules().update(req, "project", "location", "responsePolicy", "responsePolicyRule")
17625/// .client_operation_id("gubergren")
17626/// .doit().await;
17627/// # }
17628/// ```
17629pub struct ResponsePolicyRuleUpdateCall<'a, C>
17630where
17631 C: 'a,
17632{
17633 hub: &'a Dns<C>,
17634 _request: ResponsePolicyRule,
17635 _project: String,
17636 _location: String,
17637 _response_policy: String,
17638 _response_policy_rule: String,
17639 _client_operation_id: Option<String>,
17640 _delegate: Option<&'a mut dyn common::Delegate>,
17641 _additional_params: HashMap<String, String>,
17642 _scopes: BTreeSet<String>,
17643}
17644
17645impl<'a, C> common::CallBuilder for ResponsePolicyRuleUpdateCall<'a, C> {}
17646
17647impl<'a, C> ResponsePolicyRuleUpdateCall<'a, C>
17648where
17649 C: common::Connector,
17650{
17651 /// Perform the operation you have build so far.
17652 pub async fn doit(
17653 mut self,
17654 ) -> common::Result<(common::Response, ResponsePolicyRulesUpdateResponse)> {
17655 use std::borrow::Cow;
17656 use std::io::{Read, Seek};
17657
17658 use common::{url::Params, ToParts};
17659 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17660
17661 let mut dd = common::DefaultDelegate;
17662 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17663 dlg.begin(common::MethodInfo {
17664 id: "dns.responsePolicyRules.update",
17665 http_method: hyper::Method::PUT,
17666 });
17667
17668 for &field in [
17669 "alt",
17670 "project",
17671 "location",
17672 "responsePolicy",
17673 "responsePolicyRule",
17674 "clientOperationId",
17675 ]
17676 .iter()
17677 {
17678 if self._additional_params.contains_key(field) {
17679 dlg.finished(false);
17680 return Err(common::Error::FieldClash(field));
17681 }
17682 }
17683
17684 let mut params = Params::with_capacity(8 + self._additional_params.len());
17685 params.push("project", self._project);
17686 params.push("location", self._location);
17687 params.push("responsePolicy", self._response_policy);
17688 params.push("responsePolicyRule", self._response_policy_rule);
17689 if let Some(value) = self._client_operation_id.as_ref() {
17690 params.push("clientOperationId", value);
17691 }
17692
17693 params.extend(self._additional_params.iter());
17694
17695 params.push("alt", "json");
17696 let mut url = self.hub._base_url.clone() + "dns/v2/projects/{project}/locations/{location}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
17697 if self._scopes.is_empty() {
17698 self._scopes
17699 .insert(Scope::CloudPlatform.as_ref().to_string());
17700 }
17701
17702 #[allow(clippy::single_element_loop)]
17703 for &(find_this, param_name) in [
17704 ("{project}", "project"),
17705 ("{location}", "location"),
17706 ("{responsePolicy}", "responsePolicy"),
17707 ("{responsePolicyRule}", "responsePolicyRule"),
17708 ]
17709 .iter()
17710 {
17711 url = params.uri_replacement(url, param_name, find_this, false);
17712 }
17713 {
17714 let to_remove = [
17715 "responsePolicyRule",
17716 "responsePolicy",
17717 "location",
17718 "project",
17719 ];
17720 params.remove_params(&to_remove);
17721 }
17722
17723 let url = params.parse_with_url(&url);
17724
17725 let mut json_mime_type = mime::APPLICATION_JSON;
17726 let mut request_value_reader = {
17727 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17728 common::remove_json_null_values(&mut value);
17729 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17730 serde_json::to_writer(&mut dst, &value).unwrap();
17731 dst
17732 };
17733 let request_size = request_value_reader
17734 .seek(std::io::SeekFrom::End(0))
17735 .unwrap();
17736 request_value_reader
17737 .seek(std::io::SeekFrom::Start(0))
17738 .unwrap();
17739
17740 loop {
17741 let token = match self
17742 .hub
17743 .auth
17744 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17745 .await
17746 {
17747 Ok(token) => token,
17748 Err(e) => match dlg.token(e) {
17749 Ok(token) => token,
17750 Err(e) => {
17751 dlg.finished(false);
17752 return Err(common::Error::MissingToken(e));
17753 }
17754 },
17755 };
17756 request_value_reader
17757 .seek(std::io::SeekFrom::Start(0))
17758 .unwrap();
17759 let mut req_result = {
17760 let client = &self.hub.client;
17761 dlg.pre_request();
17762 let mut req_builder = hyper::Request::builder()
17763 .method(hyper::Method::PUT)
17764 .uri(url.as_str())
17765 .header(USER_AGENT, self.hub._user_agent.clone());
17766
17767 if let Some(token) = token.as_ref() {
17768 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17769 }
17770
17771 let request = req_builder
17772 .header(CONTENT_TYPE, json_mime_type.to_string())
17773 .header(CONTENT_LENGTH, request_size as u64)
17774 .body(common::to_body(
17775 request_value_reader.get_ref().clone().into(),
17776 ));
17777
17778 client.request(request.unwrap()).await
17779 };
17780
17781 match req_result {
17782 Err(err) => {
17783 if let common::Retry::After(d) = dlg.http_error(&err) {
17784 sleep(d).await;
17785 continue;
17786 }
17787 dlg.finished(false);
17788 return Err(common::Error::HttpError(err));
17789 }
17790 Ok(res) => {
17791 let (mut parts, body) = res.into_parts();
17792 let mut body = common::Body::new(body);
17793 if !parts.status.is_success() {
17794 let bytes = common::to_bytes(body).await.unwrap_or_default();
17795 let error = serde_json::from_str(&common::to_string(&bytes));
17796 let response = common::to_response(parts, bytes.into());
17797
17798 if let common::Retry::After(d) =
17799 dlg.http_failure(&response, error.as_ref().ok())
17800 {
17801 sleep(d).await;
17802 continue;
17803 }
17804
17805 dlg.finished(false);
17806
17807 return Err(match error {
17808 Ok(value) => common::Error::BadRequest(value),
17809 _ => common::Error::Failure(response),
17810 });
17811 }
17812 let response = {
17813 let bytes = common::to_bytes(body).await.unwrap_or_default();
17814 let encoded = common::to_string(&bytes);
17815 match serde_json::from_str(&encoded) {
17816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17817 Err(error) => {
17818 dlg.response_json_decode_error(&encoded, &error);
17819 return Err(common::Error::JsonDecodeError(
17820 encoded.to_string(),
17821 error,
17822 ));
17823 }
17824 }
17825 };
17826
17827 dlg.finished(true);
17828 return Ok(response);
17829 }
17830 }
17831 }
17832 }
17833
17834 ///
17835 /// Sets the *request* property to the given value.
17836 ///
17837 /// Even though the property as already been set when instantiating this call,
17838 /// we provide this method for API completeness.
17839 pub fn request(mut self, new_value: ResponsePolicyRule) -> ResponsePolicyRuleUpdateCall<'a, C> {
17840 self._request = new_value;
17841 self
17842 }
17843 /// Identifies the project addressed by this request.
17844 ///
17845 /// Sets the *project* path property to the given value.
17846 ///
17847 /// Even though the property as already been set when instantiating this call,
17848 /// we provide this method for API completeness.
17849 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17850 self._project = new_value.to_string();
17851 self
17852 }
17853 /// Specifies the location of the resource. This information will be used for routing and will be part of the resource name.
17854 ///
17855 /// Sets the *location* path property to the given value.
17856 ///
17857 /// Even though the property as already been set when instantiating this call,
17858 /// we provide this method for API completeness.
17859 pub fn location(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17860 self._location = new_value.to_string();
17861 self
17862 }
17863 /// User assigned name of the Response Policy containing the Response Policy Rule.
17864 ///
17865 /// Sets the *response policy* path property to the given value.
17866 ///
17867 /// Even though the property as already been set when instantiating this call,
17868 /// we provide this method for API completeness.
17869 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17870 self._response_policy = new_value.to_string();
17871 self
17872 }
17873 /// User assigned name of the Response Policy Rule addressed by this request.
17874 ///
17875 /// Sets the *response policy rule* path property to the given value.
17876 ///
17877 /// Even though the property as already been set when instantiating this call,
17878 /// we provide this method for API completeness.
17879 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17880 self._response_policy_rule = new_value.to_string();
17881 self
17882 }
17883 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
17884 ///
17885 /// Sets the *client operation id* query property to the given value.
17886 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17887 self._client_operation_id = Some(new_value.to_string());
17888 self
17889 }
17890 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17891 /// while executing the actual API request.
17892 ///
17893 /// ````text
17894 /// It should be used to handle progress information, and to implement a certain level of resilience.
17895 /// ````
17896 ///
17897 /// Sets the *delegate* property to the given value.
17898 pub fn delegate(
17899 mut self,
17900 new_value: &'a mut dyn common::Delegate,
17901 ) -> ResponsePolicyRuleUpdateCall<'a, C> {
17902 self._delegate = Some(new_value);
17903 self
17904 }
17905
17906 /// Set any additional parameter of the query string used in the request.
17907 /// It should be used to set parameters which are not yet available through their own
17908 /// setters.
17909 ///
17910 /// Please note that this method must not be used to set any of the known parameters
17911 /// which have their own setter method. If done anyway, the request will fail.
17912 ///
17913 /// # Additional Parameters
17914 ///
17915 /// * *$.xgafv* (query-string) - V1 error format.
17916 /// * *access_token* (query-string) - OAuth access token.
17917 /// * *alt* (query-string) - Data format for response.
17918 /// * *callback* (query-string) - JSONP
17919 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17920 /// * *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.
17921 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17922 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17923 /// * *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.
17924 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17925 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17926 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleUpdateCall<'a, C>
17927 where
17928 T: AsRef<str>,
17929 {
17930 self._additional_params
17931 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17932 self
17933 }
17934
17935 /// Identifies the authorization scope for the method you are building.
17936 ///
17937 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17938 /// [`Scope::CloudPlatform`].
17939 ///
17940 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17941 /// tokens for more than one scope.
17942 ///
17943 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17944 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17945 /// sufficient, a read-write scope will do as well.
17946 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleUpdateCall<'a, C>
17947 where
17948 St: AsRef<str>,
17949 {
17950 self._scopes.insert(String::from(scope.as_ref()));
17951 self
17952 }
17953 /// Identifies the authorization scope(s) for the method you are building.
17954 ///
17955 /// See [`Self::add_scope()`] for details.
17956 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleUpdateCall<'a, C>
17957 where
17958 I: IntoIterator<Item = St>,
17959 St: AsRef<str>,
17960 {
17961 self._scopes
17962 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17963 self
17964 }
17965
17966 /// Removes all scopes, and no default scope will be used either.
17967 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17968 /// for details).
17969 pub fn clear_scopes(mut self) -> ResponsePolicyRuleUpdateCall<'a, C> {
17970 self._scopes.clear();
17971 self
17972 }
17973}