google_dns1/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_dns1 as dns1;
65/// use dns1::{Result, Error};
66/// # async fn dox() {
67/// use dns1::{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")
109/// .page_token("takimata")
110/// .max_results(-52)
111/// .dns_name("duo")
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 /// Type of resource.
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/// * [delete resource record sets](ResourceRecordSetDeleteCall) (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 ResourceRecordSetsDeleteResponse {
1521 _never_set: Option<bool>,
1522}
1523
1524impl common::ResponseResult for ResourceRecordSetsDeleteResponse {}
1525
1526/// There is no detailed description.
1527///
1528/// # Activities
1529///
1530/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1531/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1532///
1533/// * [list resource record sets](ResourceRecordSetListCall) (response)
1534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1535#[serde_with::serde_as]
1536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1537pub struct ResourceRecordSetsListResponse {
1538 /// Type of resource.
1539 pub kind: Option<String>,
1540 /// 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.
1541 #[serde(rename = "nextPageToken")]
1542 pub next_page_token: Option<String>,
1543 /// The resource record set resources.
1544 pub rrsets: Option<Vec<ResourceRecordSet>>,
1545}
1546
1547impl common::ResponseResult for ResourceRecordSetsListResponse {}
1548
1549/// There is no detailed description.
1550///
1551/// # Activities
1552///
1553/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1554/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1555///
1556/// * [list response policies](ResponsePolicyListCall) (response)
1557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1558#[serde_with::serde_as]
1559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1560pub struct ResponsePoliciesListResponse {
1561 /// 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.
1562 #[serde(rename = "nextPageToken")]
1563 pub next_page_token: Option<String>,
1564 /// The Response Policy resources.
1565 #[serde(rename = "responsePolicies")]
1566 pub response_policies: Option<Vec<ResponsePolicy>>,
1567}
1568
1569impl common::ResponseResult for ResponsePoliciesListResponse {}
1570
1571/// There is no detailed description.
1572///
1573/// # Activities
1574///
1575/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1576/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1577///
1578/// * [patch response policies](ResponsePolicyPatchCall) (response)
1579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1580#[serde_with::serde_as]
1581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1582pub struct ResponsePoliciesPatchResponse {
1583 /// no description provided
1584 #[serde(rename = "responsePolicy")]
1585 pub response_policy: Option<ResponsePolicy>,
1586}
1587
1588impl common::ResponseResult for ResponsePoliciesPatchResponse {}
1589
1590/// There is no detailed description.
1591///
1592/// # Activities
1593///
1594/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1595/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1596///
1597/// * [update response policies](ResponsePolicyUpdateCall) (response)
1598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1599#[serde_with::serde_as]
1600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1601pub struct ResponsePoliciesUpdateResponse {
1602 /// no description provided
1603 #[serde(rename = "responsePolicy")]
1604 pub response_policy: Option<ResponsePolicy>,
1605}
1606
1607impl common::ResponseResult for ResponsePoliciesUpdateResponse {}
1608
1609/// A Response Policy is a collection of selectors that apply to queries made against one or more Virtual Private Cloud networks.
1610///
1611/// # Activities
1612///
1613/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1614/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1615///
1616/// * [create response policies](ResponsePolicyCreateCall) (request|response)
1617/// * [get response policies](ResponsePolicyGetCall) (response)
1618/// * [patch response policies](ResponsePolicyPatchCall) (request)
1619/// * [update response policies](ResponsePolicyUpdateCall) (request)
1620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1621#[serde_with::serde_as]
1622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1623pub struct ResponsePolicy {
1624 /// User-provided description for this Response Policy.
1625 pub description: Option<String>,
1626 /// The list of Google Kubernetes Engine clusters to which this response policy is applied.
1627 #[serde(rename = "gkeClusters")]
1628 pub gke_clusters: Option<Vec<ResponsePolicyGKECluster>>,
1629 /// Unique identifier for the resource; defined by the server (output only).
1630 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1631 pub id: Option<i64>,
1632 /// no description provided
1633 pub kind: Option<String>,
1634 /// User labels.
1635 pub labels: Option<HashMap<String, String>>,
1636 /// List of network names specifying networks to which this policy is applied.
1637 pub networks: Option<Vec<ResponsePolicyNetwork>>,
1638 /// User assigned name for this Response Policy.
1639 #[serde(rename = "responsePolicyName")]
1640 pub response_policy_name: Option<String>,
1641}
1642
1643impl common::RequestValue for ResponsePolicy {}
1644impl common::ResponseResult for ResponsePolicy {}
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 ResponsePolicyGKECluster {
1654 /// 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
1655 #[serde(rename = "gkeClusterName")]
1656 pub gke_cluster_name: Option<String>,
1657 /// no description provided
1658 pub kind: Option<String>,
1659}
1660
1661impl common::Part for ResponsePolicyGKECluster {}
1662
1663/// There is no detailed description.
1664///
1665/// This type is not used in any activity, and only used as *part* of another schema.
1666///
1667#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1668#[serde_with::serde_as]
1669#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1670pub struct ResponsePolicyNetwork {
1671 /// no description provided
1672 pub kind: Option<String>,
1673 /// 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}`
1674 #[serde(rename = "networkUrl")]
1675 pub network_url: Option<String>,
1676}
1677
1678impl common::Part for ResponsePolicyNetwork {}
1679
1680/// 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.
1681///
1682/// # Activities
1683///
1684/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1685/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1686///
1687/// * [create response policy rules](ResponsePolicyRuleCreateCall) (request|response)
1688/// * [delete response policy rules](ResponsePolicyRuleDeleteCall) (none)
1689/// * [get response policy rules](ResponsePolicyRuleGetCall) (response)
1690/// * [list response policy rules](ResponsePolicyRuleListCall) (none)
1691/// * [patch response policy rules](ResponsePolicyRulePatchCall) (request)
1692/// * [update response policy rules](ResponsePolicyRuleUpdateCall) (request)
1693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1694#[serde_with::serde_as]
1695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1696pub struct ResponsePolicyRule {
1697 /// Answer this query with a behavior rather than DNS data.
1698 pub behavior: Option<String>,
1699 /// The DNS name (wildcard or exact) to apply this rule to. Must be unique within the Response Policy Rule.
1700 #[serde(rename = "dnsName")]
1701 pub dns_name: Option<String>,
1702 /// no description provided
1703 pub kind: Option<String>,
1704 /// 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.
1705 #[serde(rename = "localData")]
1706 pub local_data: Option<ResponsePolicyRuleLocalData>,
1707 /// An identifier for this rule. Must be unique with the ResponsePolicy.
1708 #[serde(rename = "ruleName")]
1709 pub rule_name: Option<String>,
1710}
1711
1712impl common::RequestValue for ResponsePolicyRule {}
1713impl common::Resource for ResponsePolicyRule {}
1714impl common::ResponseResult for ResponsePolicyRule {}
1715
1716/// There is no detailed description.
1717///
1718/// This type is not used in any activity, and only used as *part* of another schema.
1719///
1720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1721#[serde_with::serde_as]
1722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1723pub struct ResponsePolicyRuleLocalData {
1724 /// All resource record sets for this selector, one per resource record type. The name must match the dns_name.
1725 #[serde(rename = "localDatas")]
1726 pub local_datas: Option<Vec<ResourceRecordSet>>,
1727}
1728
1729impl common::Part for ResponsePolicyRuleLocalData {}
1730
1731/// There is no detailed description.
1732///
1733/// # Activities
1734///
1735/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1736/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1737///
1738/// * [list response policy rules](ResponsePolicyRuleListCall) (response)
1739#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1740#[serde_with::serde_as]
1741#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1742pub struct ResponsePolicyRulesListResponse {
1743 /// 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.
1744 #[serde(rename = "nextPageToken")]
1745 pub next_page_token: Option<String>,
1746 /// The Response Policy Rule resources.
1747 #[serde(rename = "responsePolicyRules")]
1748 pub response_policy_rules: Option<Vec<ResponsePolicyRule>>,
1749}
1750
1751impl common::ResponseResult for ResponsePolicyRulesListResponse {}
1752
1753/// There is no detailed description.
1754///
1755/// # Activities
1756///
1757/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1758/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1759///
1760/// * [patch response policy rules](ResponsePolicyRulePatchCall) (response)
1761#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1762#[serde_with::serde_as]
1763#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1764pub struct ResponsePolicyRulesPatchResponse {
1765 /// no description provided
1766 #[serde(rename = "responsePolicyRule")]
1767 pub response_policy_rule: Option<ResponsePolicyRule>,
1768}
1769
1770impl common::ResponseResult for ResponsePolicyRulesPatchResponse {}
1771
1772/// There is no detailed description.
1773///
1774/// # Activities
1775///
1776/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1777/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1778///
1779/// * [update response policy rules](ResponsePolicyRuleUpdateCall) (response)
1780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1781#[serde_with::serde_as]
1782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1783pub struct ResponsePolicyRulesUpdateResponse {
1784 /// no description provided
1785 #[serde(rename = "responsePolicyRule")]
1786 pub response_policy_rule: Option<ResponsePolicyRule>,
1787}
1788
1789impl common::ResponseResult for ResponsePolicyRulesUpdateResponse {}
1790
1791// ###################
1792// MethodBuilders ###
1793// #################
1794
1795/// A builder providing access to all methods supported on *change* resources.
1796/// It is not used directly, but through the [`Dns`] hub.
1797///
1798/// # Example
1799///
1800/// Instantiate a resource builder
1801///
1802/// ```test_harness,no_run
1803/// extern crate hyper;
1804/// extern crate hyper_rustls;
1805/// extern crate google_dns1 as dns1;
1806///
1807/// # async fn dox() {
1808/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1809///
1810/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1811/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1812/// .with_native_roots()
1813/// .unwrap()
1814/// .https_only()
1815/// .enable_http2()
1816/// .build();
1817///
1818/// let executor = hyper_util::rt::TokioExecutor::new();
1819/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1820/// secret,
1821/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1822/// yup_oauth2::client::CustomHyperClientBuilder::from(
1823/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1824/// ),
1825/// ).build().await.unwrap();
1826///
1827/// let client = hyper_util::client::legacy::Client::builder(
1828/// hyper_util::rt::TokioExecutor::new()
1829/// )
1830/// .build(
1831/// hyper_rustls::HttpsConnectorBuilder::new()
1832/// .with_native_roots()
1833/// .unwrap()
1834/// .https_or_http()
1835/// .enable_http2()
1836/// .build()
1837/// );
1838/// let mut hub = Dns::new(client, auth);
1839/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1840/// // like `create(...)`, `get(...)` and `list(...)`
1841/// // to build up your call.
1842/// let rb = hub.changes();
1843/// # }
1844/// ```
1845pub struct ChangeMethods<'a, C>
1846where
1847 C: 'a,
1848{
1849 hub: &'a Dns<C>,
1850}
1851
1852impl<'a, C> common::MethodsBuilder for ChangeMethods<'a, C> {}
1853
1854impl<'a, C> ChangeMethods<'a, C> {
1855 /// Create a builder to help you perform the following task:
1856 ///
1857 /// Atomically updates the ResourceRecordSet collection.
1858 ///
1859 /// # Arguments
1860 ///
1861 /// * `request` - No description provided.
1862 /// * `project` - Identifies the project addressed by this request.
1863 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1864 pub fn create(
1865 &self,
1866 request: Change,
1867 project: &str,
1868 managed_zone: &str,
1869 ) -> ChangeCreateCall<'a, C> {
1870 ChangeCreateCall {
1871 hub: self.hub,
1872 _request: request,
1873 _project: project.to_string(),
1874 _managed_zone: managed_zone.to_string(),
1875 _client_operation_id: Default::default(),
1876 _delegate: Default::default(),
1877 _additional_params: Default::default(),
1878 _scopes: Default::default(),
1879 }
1880 }
1881
1882 /// Create a builder to help you perform the following task:
1883 ///
1884 /// Fetches the representation of an existing Change.
1885 ///
1886 /// # Arguments
1887 ///
1888 /// * `project` - Identifies the project addressed by this request.
1889 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1890 /// * `changeId` - The identifier of the requested change, from a previous ResourceRecordSetsChangeResponse.
1891 pub fn get(&self, project: &str, managed_zone: &str, change_id: &str) -> ChangeGetCall<'a, C> {
1892 ChangeGetCall {
1893 hub: self.hub,
1894 _project: project.to_string(),
1895 _managed_zone: managed_zone.to_string(),
1896 _change_id: change_id.to_string(),
1897 _client_operation_id: Default::default(),
1898 _delegate: Default::default(),
1899 _additional_params: Default::default(),
1900 _scopes: Default::default(),
1901 }
1902 }
1903
1904 /// Create a builder to help you perform the following task:
1905 ///
1906 /// Enumerates Changes to a ResourceRecordSet collection.
1907 ///
1908 /// # Arguments
1909 ///
1910 /// * `project` - Identifies the project addressed by this request.
1911 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1912 pub fn list(&self, project: &str, managed_zone: &str) -> ChangeListCall<'a, C> {
1913 ChangeListCall {
1914 hub: self.hub,
1915 _project: project.to_string(),
1916 _managed_zone: managed_zone.to_string(),
1917 _sort_order: Default::default(),
1918 _sort_by: Default::default(),
1919 _page_token: Default::default(),
1920 _max_results: Default::default(),
1921 _delegate: Default::default(),
1922 _additional_params: Default::default(),
1923 _scopes: Default::default(),
1924 }
1925 }
1926}
1927
1928/// A builder providing access to all methods supported on *dnsKey* resources.
1929/// It is not used directly, but through the [`Dns`] hub.
1930///
1931/// # Example
1932///
1933/// Instantiate a resource builder
1934///
1935/// ```test_harness,no_run
1936/// extern crate hyper;
1937/// extern crate hyper_rustls;
1938/// extern crate google_dns1 as dns1;
1939///
1940/// # async fn dox() {
1941/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1942///
1943/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1944/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1945/// .with_native_roots()
1946/// .unwrap()
1947/// .https_only()
1948/// .enable_http2()
1949/// .build();
1950///
1951/// let executor = hyper_util::rt::TokioExecutor::new();
1952/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1953/// secret,
1954/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1955/// yup_oauth2::client::CustomHyperClientBuilder::from(
1956/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1957/// ),
1958/// ).build().await.unwrap();
1959///
1960/// let client = hyper_util::client::legacy::Client::builder(
1961/// hyper_util::rt::TokioExecutor::new()
1962/// )
1963/// .build(
1964/// hyper_rustls::HttpsConnectorBuilder::new()
1965/// .with_native_roots()
1966/// .unwrap()
1967/// .https_or_http()
1968/// .enable_http2()
1969/// .build()
1970/// );
1971/// let mut hub = Dns::new(client, auth);
1972/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1973/// // like `get(...)` and `list(...)`
1974/// // to build up your call.
1975/// let rb = hub.dns_keys();
1976/// # }
1977/// ```
1978pub struct DnsKeyMethods<'a, C>
1979where
1980 C: 'a,
1981{
1982 hub: &'a Dns<C>,
1983}
1984
1985impl<'a, C> common::MethodsBuilder for DnsKeyMethods<'a, C> {}
1986
1987impl<'a, C> DnsKeyMethods<'a, C> {
1988 /// Create a builder to help you perform the following task:
1989 ///
1990 /// Fetches the representation of an existing DnsKey.
1991 ///
1992 /// # Arguments
1993 ///
1994 /// * `project` - Identifies the project addressed by this request.
1995 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
1996 /// * `dnsKeyId` - The identifier of the requested DnsKey.
1997 pub fn get(&self, project: &str, managed_zone: &str, dns_key_id: &str) -> DnsKeyGetCall<'a, C> {
1998 DnsKeyGetCall {
1999 hub: self.hub,
2000 _project: project.to_string(),
2001 _managed_zone: managed_zone.to_string(),
2002 _dns_key_id: dns_key_id.to_string(),
2003 _digest_type: Default::default(),
2004 _client_operation_id: Default::default(),
2005 _delegate: Default::default(),
2006 _additional_params: Default::default(),
2007 _scopes: Default::default(),
2008 }
2009 }
2010
2011 /// Create a builder to help you perform the following task:
2012 ///
2013 /// Enumerates DnsKeys to a ResourceRecordSet collection.
2014 ///
2015 /// # Arguments
2016 ///
2017 /// * `project` - Identifies the project addressed by this request.
2018 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2019 pub fn list(&self, project: &str, managed_zone: &str) -> DnsKeyListCall<'a, C> {
2020 DnsKeyListCall {
2021 hub: self.hub,
2022 _project: project.to_string(),
2023 _managed_zone: managed_zone.to_string(),
2024 _page_token: Default::default(),
2025 _max_results: Default::default(),
2026 _digest_type: Default::default(),
2027 _delegate: Default::default(),
2028 _additional_params: Default::default(),
2029 _scopes: Default::default(),
2030 }
2031 }
2032}
2033
2034/// A builder providing access to all methods supported on *managedZoneOperation* resources.
2035/// It is not used directly, but through the [`Dns`] hub.
2036///
2037/// # Example
2038///
2039/// Instantiate a resource builder
2040///
2041/// ```test_harness,no_run
2042/// extern crate hyper;
2043/// extern crate hyper_rustls;
2044/// extern crate google_dns1 as dns1;
2045///
2046/// # async fn dox() {
2047/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2048///
2049/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2050/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2051/// .with_native_roots()
2052/// .unwrap()
2053/// .https_only()
2054/// .enable_http2()
2055/// .build();
2056///
2057/// let executor = hyper_util::rt::TokioExecutor::new();
2058/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2059/// secret,
2060/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2061/// yup_oauth2::client::CustomHyperClientBuilder::from(
2062/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2063/// ),
2064/// ).build().await.unwrap();
2065///
2066/// let client = hyper_util::client::legacy::Client::builder(
2067/// hyper_util::rt::TokioExecutor::new()
2068/// )
2069/// .build(
2070/// hyper_rustls::HttpsConnectorBuilder::new()
2071/// .with_native_roots()
2072/// .unwrap()
2073/// .https_or_http()
2074/// .enable_http2()
2075/// .build()
2076/// );
2077/// let mut hub = Dns::new(client, auth);
2078/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2079/// // like `get(...)` and `list(...)`
2080/// // to build up your call.
2081/// let rb = hub.managed_zone_operations();
2082/// # }
2083/// ```
2084pub struct ManagedZoneOperationMethods<'a, C>
2085where
2086 C: 'a,
2087{
2088 hub: &'a Dns<C>,
2089}
2090
2091impl<'a, C> common::MethodsBuilder for ManagedZoneOperationMethods<'a, C> {}
2092
2093impl<'a, C> ManagedZoneOperationMethods<'a, C> {
2094 /// Create a builder to help you perform the following task:
2095 ///
2096 /// Fetches the representation of an existing Operation.
2097 ///
2098 /// # Arguments
2099 ///
2100 /// * `project` - Identifies the project addressed by this request.
2101 /// * `managedZone` - Identifies the managed zone addressed by this request.
2102 /// * `operation` - Identifies the operation addressed by this request (ID of the operation).
2103 pub fn get(
2104 &self,
2105 project: &str,
2106 managed_zone: &str,
2107 operation: &str,
2108 ) -> ManagedZoneOperationGetCall<'a, C> {
2109 ManagedZoneOperationGetCall {
2110 hub: self.hub,
2111 _project: project.to_string(),
2112 _managed_zone: managed_zone.to_string(),
2113 _operation: operation.to_string(),
2114 _client_operation_id: Default::default(),
2115 _delegate: Default::default(),
2116 _additional_params: Default::default(),
2117 _scopes: Default::default(),
2118 }
2119 }
2120
2121 /// Create a builder to help you perform the following task:
2122 ///
2123 /// Enumerates Operations for the given ManagedZone.
2124 ///
2125 /// # Arguments
2126 ///
2127 /// * `project` - Identifies the project addressed by this request.
2128 /// * `managedZone` - Identifies the managed zone addressed by this request.
2129 pub fn list(&self, project: &str, managed_zone: &str) -> ManagedZoneOperationListCall<'a, C> {
2130 ManagedZoneOperationListCall {
2131 hub: self.hub,
2132 _project: project.to_string(),
2133 _managed_zone: managed_zone.to_string(),
2134 _sort_by: Default::default(),
2135 _page_token: Default::default(),
2136 _max_results: Default::default(),
2137 _delegate: Default::default(),
2138 _additional_params: Default::default(),
2139 _scopes: Default::default(),
2140 }
2141 }
2142}
2143
2144/// A builder providing access to all methods supported on *managedZone* resources.
2145/// It is not used directly, but through the [`Dns`] hub.
2146///
2147/// # Example
2148///
2149/// Instantiate a resource builder
2150///
2151/// ```test_harness,no_run
2152/// extern crate hyper;
2153/// extern crate hyper_rustls;
2154/// extern crate google_dns1 as dns1;
2155///
2156/// # async fn dox() {
2157/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2158///
2159/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2160/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2161/// .with_native_roots()
2162/// .unwrap()
2163/// .https_only()
2164/// .enable_http2()
2165/// .build();
2166///
2167/// let executor = hyper_util::rt::TokioExecutor::new();
2168/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2169/// secret,
2170/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2171/// yup_oauth2::client::CustomHyperClientBuilder::from(
2172/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2173/// ),
2174/// ).build().await.unwrap();
2175///
2176/// let client = hyper_util::client::legacy::Client::builder(
2177/// hyper_util::rt::TokioExecutor::new()
2178/// )
2179/// .build(
2180/// hyper_rustls::HttpsConnectorBuilder::new()
2181/// .with_native_roots()
2182/// .unwrap()
2183/// .https_or_http()
2184/// .enable_http2()
2185/// .build()
2186/// );
2187/// let mut hub = Dns::new(client, auth);
2188/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2189/// // like `create(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `patch(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)` and `update(...)`
2190/// // to build up your call.
2191/// let rb = hub.managed_zones();
2192/// # }
2193/// ```
2194pub struct ManagedZoneMethods<'a, C>
2195where
2196 C: 'a,
2197{
2198 hub: &'a Dns<C>,
2199}
2200
2201impl<'a, C> common::MethodsBuilder for ManagedZoneMethods<'a, C> {}
2202
2203impl<'a, C> ManagedZoneMethods<'a, C> {
2204 /// Create a builder to help you perform the following task:
2205 ///
2206 /// Creates a new ManagedZone.
2207 ///
2208 /// # Arguments
2209 ///
2210 /// * `request` - No description provided.
2211 /// * `project` - Identifies the project addressed by this request.
2212 pub fn create(&self, request: ManagedZone, project: &str) -> ManagedZoneCreateCall<'a, C> {
2213 ManagedZoneCreateCall {
2214 hub: self.hub,
2215 _request: request,
2216 _project: project.to_string(),
2217 _client_operation_id: Default::default(),
2218 _delegate: Default::default(),
2219 _additional_params: Default::default(),
2220 _scopes: Default::default(),
2221 }
2222 }
2223
2224 /// Create a builder to help you perform the following task:
2225 ///
2226 /// Deletes a previously created ManagedZone.
2227 ///
2228 /// # Arguments
2229 ///
2230 /// * `project` - Identifies the project addressed by this request.
2231 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2232 pub fn delete(&self, project: &str, managed_zone: &str) -> ManagedZoneDeleteCall<'a, C> {
2233 ManagedZoneDeleteCall {
2234 hub: self.hub,
2235 _project: project.to_string(),
2236 _managed_zone: managed_zone.to_string(),
2237 _client_operation_id: Default::default(),
2238 _delegate: Default::default(),
2239 _additional_params: Default::default(),
2240 _scopes: Default::default(),
2241 }
2242 }
2243
2244 /// Create a builder to help you perform the following task:
2245 ///
2246 /// Fetches the representation of an existing ManagedZone.
2247 ///
2248 /// # Arguments
2249 ///
2250 /// * `project` - Identifies the project addressed by this request.
2251 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2252 pub fn get(&self, project: &str, managed_zone: &str) -> ManagedZoneGetCall<'a, C> {
2253 ManagedZoneGetCall {
2254 hub: self.hub,
2255 _project: project.to_string(),
2256 _managed_zone: managed_zone.to_string(),
2257 _client_operation_id: Default::default(),
2258 _delegate: Default::default(),
2259 _additional_params: Default::default(),
2260 _scopes: Default::default(),
2261 }
2262 }
2263
2264 /// Create a builder to help you perform the following task:
2265 ///
2266 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2267 ///
2268 /// # Arguments
2269 ///
2270 /// * `request` - No description provided.
2271 /// * `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.
2272 pub fn get_iam_policy(
2273 &self,
2274 request: GoogleIamV1GetIamPolicyRequest,
2275 resource: &str,
2276 ) -> ManagedZoneGetIamPolicyCall<'a, C> {
2277 ManagedZoneGetIamPolicyCall {
2278 hub: self.hub,
2279 _request: request,
2280 _resource: resource.to_string(),
2281 _delegate: Default::default(),
2282 _additional_params: Default::default(),
2283 _scopes: Default::default(),
2284 }
2285 }
2286
2287 /// Create a builder to help you perform the following task:
2288 ///
2289 /// Enumerates ManagedZones that have been created but not yet deleted.
2290 ///
2291 /// # Arguments
2292 ///
2293 /// * `project` - Identifies the project addressed by this request.
2294 pub fn list(&self, project: &str) -> ManagedZoneListCall<'a, C> {
2295 ManagedZoneListCall {
2296 hub: self.hub,
2297 _project: project.to_string(),
2298 _page_token: Default::default(),
2299 _max_results: Default::default(),
2300 _dns_name: Default::default(),
2301 _delegate: Default::default(),
2302 _additional_params: Default::default(),
2303 _scopes: Default::default(),
2304 }
2305 }
2306
2307 /// Create a builder to help you perform the following task:
2308 ///
2309 /// Applies a partial update to an existing ManagedZone.
2310 ///
2311 /// # Arguments
2312 ///
2313 /// * `request` - No description provided.
2314 /// * `project` - Identifies the project addressed by this request.
2315 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2316 pub fn patch(
2317 &self,
2318 request: ManagedZone,
2319 project: &str,
2320 managed_zone: &str,
2321 ) -> ManagedZonePatchCall<'a, C> {
2322 ManagedZonePatchCall {
2323 hub: self.hub,
2324 _request: request,
2325 _project: project.to_string(),
2326 _managed_zone: managed_zone.to_string(),
2327 _client_operation_id: Default::default(),
2328 _delegate: Default::default(),
2329 _additional_params: Default::default(),
2330 _scopes: Default::default(),
2331 }
2332 }
2333
2334 /// Create a builder to help you perform the following task:
2335 ///
2336 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2337 ///
2338 /// # Arguments
2339 ///
2340 /// * `request` - No description provided.
2341 /// * `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.
2342 pub fn set_iam_policy(
2343 &self,
2344 request: GoogleIamV1SetIamPolicyRequest,
2345 resource: &str,
2346 ) -> ManagedZoneSetIamPolicyCall<'a, C> {
2347 ManagedZoneSetIamPolicyCall {
2348 hub: self.hub,
2349 _request: request,
2350 _resource: resource.to_string(),
2351 _delegate: Default::default(),
2352 _additional_params: Default::default(),
2353 _scopes: Default::default(),
2354 }
2355 }
2356
2357 /// Create a builder to help you perform the following task:
2358 ///
2359 /// 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.
2360 ///
2361 /// # Arguments
2362 ///
2363 /// * `request` - No description provided.
2364 /// * `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.
2365 pub fn test_iam_permissions(
2366 &self,
2367 request: GoogleIamV1TestIamPermissionsRequest,
2368 resource: &str,
2369 ) -> ManagedZoneTestIamPermissionCall<'a, C> {
2370 ManagedZoneTestIamPermissionCall {
2371 hub: self.hub,
2372 _request: request,
2373 _resource: resource.to_string(),
2374 _delegate: Default::default(),
2375 _additional_params: Default::default(),
2376 _scopes: Default::default(),
2377 }
2378 }
2379
2380 /// Create a builder to help you perform the following task:
2381 ///
2382 /// Updates an existing ManagedZone.
2383 ///
2384 /// # Arguments
2385 ///
2386 /// * `request` - No description provided.
2387 /// * `project` - Identifies the project addressed by this request.
2388 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2389 pub fn update(
2390 &self,
2391 request: ManagedZone,
2392 project: &str,
2393 managed_zone: &str,
2394 ) -> ManagedZoneUpdateCall<'a, C> {
2395 ManagedZoneUpdateCall {
2396 hub: self.hub,
2397 _request: request,
2398 _project: project.to_string(),
2399 _managed_zone: managed_zone.to_string(),
2400 _client_operation_id: Default::default(),
2401 _delegate: Default::default(),
2402 _additional_params: Default::default(),
2403 _scopes: Default::default(),
2404 }
2405 }
2406}
2407
2408/// A builder providing access to all methods supported on *policy* resources.
2409/// It is not used directly, but through the [`Dns`] hub.
2410///
2411/// # Example
2412///
2413/// Instantiate a resource builder
2414///
2415/// ```test_harness,no_run
2416/// extern crate hyper;
2417/// extern crate hyper_rustls;
2418/// extern crate google_dns1 as dns1;
2419///
2420/// # async fn dox() {
2421/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2422///
2423/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2424/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2425/// .with_native_roots()
2426/// .unwrap()
2427/// .https_only()
2428/// .enable_http2()
2429/// .build();
2430///
2431/// let executor = hyper_util::rt::TokioExecutor::new();
2432/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2433/// secret,
2434/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2435/// yup_oauth2::client::CustomHyperClientBuilder::from(
2436/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2437/// ),
2438/// ).build().await.unwrap();
2439///
2440/// let client = hyper_util::client::legacy::Client::builder(
2441/// hyper_util::rt::TokioExecutor::new()
2442/// )
2443/// .build(
2444/// hyper_rustls::HttpsConnectorBuilder::new()
2445/// .with_native_roots()
2446/// .unwrap()
2447/// .https_or_http()
2448/// .enable_http2()
2449/// .build()
2450/// );
2451/// let mut hub = Dns::new(client, auth);
2452/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2453/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
2454/// // to build up your call.
2455/// let rb = hub.policies();
2456/// # }
2457/// ```
2458pub struct PolicyMethods<'a, C>
2459where
2460 C: 'a,
2461{
2462 hub: &'a Dns<C>,
2463}
2464
2465impl<'a, C> common::MethodsBuilder for PolicyMethods<'a, C> {}
2466
2467impl<'a, C> PolicyMethods<'a, C> {
2468 /// Create a builder to help you perform the following task:
2469 ///
2470 /// Creates a new policy.
2471 ///
2472 /// # Arguments
2473 ///
2474 /// * `request` - No description provided.
2475 /// * `project` - Identifies the project addressed by this request.
2476 pub fn create(&self, request: Policy, project: &str) -> PolicyCreateCall<'a, C> {
2477 PolicyCreateCall {
2478 hub: self.hub,
2479 _request: request,
2480 _project: project.to_string(),
2481 _client_operation_id: Default::default(),
2482 _delegate: Default::default(),
2483 _additional_params: Default::default(),
2484 _scopes: Default::default(),
2485 }
2486 }
2487
2488 /// Create a builder to help you perform the following task:
2489 ///
2490 /// Deletes a previously created policy. Fails if the policy is still being referenced by a network.
2491 ///
2492 /// # Arguments
2493 ///
2494 /// * `project` - Identifies the project addressed by this request.
2495 /// * `policy` - User given friendly name of the policy addressed by this request.
2496 pub fn delete(&self, project: &str, policy: &str) -> PolicyDeleteCall<'a, C> {
2497 PolicyDeleteCall {
2498 hub: self.hub,
2499 _project: project.to_string(),
2500 _policy: policy.to_string(),
2501 _client_operation_id: Default::default(),
2502 _delegate: Default::default(),
2503 _additional_params: Default::default(),
2504 _scopes: Default::default(),
2505 }
2506 }
2507
2508 /// Create a builder to help you perform the following task:
2509 ///
2510 /// Fetches the representation of an existing policy.
2511 ///
2512 /// # Arguments
2513 ///
2514 /// * `project` - Identifies the project addressed by this request.
2515 /// * `policy` - User given friendly name of the policy addressed by this request.
2516 pub fn get(&self, project: &str, policy: &str) -> PolicyGetCall<'a, C> {
2517 PolicyGetCall {
2518 hub: self.hub,
2519 _project: project.to_string(),
2520 _policy: policy.to_string(),
2521 _client_operation_id: Default::default(),
2522 _delegate: Default::default(),
2523 _additional_params: Default::default(),
2524 _scopes: Default::default(),
2525 }
2526 }
2527
2528 /// Create a builder to help you perform the following task:
2529 ///
2530 /// Enumerates all policies associated with a project.
2531 ///
2532 /// # Arguments
2533 ///
2534 /// * `project` - Identifies the project addressed by this request.
2535 pub fn list(&self, project: &str) -> PolicyListCall<'a, C> {
2536 PolicyListCall {
2537 hub: self.hub,
2538 _project: project.to_string(),
2539 _page_token: Default::default(),
2540 _max_results: Default::default(),
2541 _delegate: Default::default(),
2542 _additional_params: Default::default(),
2543 _scopes: Default::default(),
2544 }
2545 }
2546
2547 /// Create a builder to help you perform the following task:
2548 ///
2549 /// Applies a partial update to an existing policy.
2550 ///
2551 /// # Arguments
2552 ///
2553 /// * `request` - No description provided.
2554 /// * `project` - Identifies the project addressed by this request.
2555 /// * `policy` - User given friendly name of the policy addressed by this request.
2556 pub fn patch(&self, request: Policy, project: &str, policy: &str) -> PolicyPatchCall<'a, C> {
2557 PolicyPatchCall {
2558 hub: self.hub,
2559 _request: request,
2560 _project: project.to_string(),
2561 _policy: policy.to_string(),
2562 _client_operation_id: Default::default(),
2563 _delegate: Default::default(),
2564 _additional_params: Default::default(),
2565 _scopes: Default::default(),
2566 }
2567 }
2568
2569 /// Create a builder to help you perform the following task:
2570 ///
2571 /// Updates an existing policy.
2572 ///
2573 /// # Arguments
2574 ///
2575 /// * `request` - No description provided.
2576 /// * `project` - Identifies the project addressed by this request.
2577 /// * `policy` - User given friendly name of the policy addressed by this request.
2578 pub fn update(&self, request: Policy, project: &str, policy: &str) -> PolicyUpdateCall<'a, C> {
2579 PolicyUpdateCall {
2580 hub: self.hub,
2581 _request: request,
2582 _project: project.to_string(),
2583 _policy: policy.to_string(),
2584 _client_operation_id: Default::default(),
2585 _delegate: Default::default(),
2586 _additional_params: Default::default(),
2587 _scopes: Default::default(),
2588 }
2589 }
2590}
2591
2592/// A builder providing access to all methods supported on *project* resources.
2593/// It is not used directly, but through the [`Dns`] hub.
2594///
2595/// # Example
2596///
2597/// Instantiate a resource builder
2598///
2599/// ```test_harness,no_run
2600/// extern crate hyper;
2601/// extern crate hyper_rustls;
2602/// extern crate google_dns1 as dns1;
2603///
2604/// # async fn dox() {
2605/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2606///
2607/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2608/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2609/// .with_native_roots()
2610/// .unwrap()
2611/// .https_only()
2612/// .enable_http2()
2613/// .build();
2614///
2615/// let executor = hyper_util::rt::TokioExecutor::new();
2616/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2617/// secret,
2618/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2619/// yup_oauth2::client::CustomHyperClientBuilder::from(
2620/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2621/// ),
2622/// ).build().await.unwrap();
2623///
2624/// let client = hyper_util::client::legacy::Client::builder(
2625/// hyper_util::rt::TokioExecutor::new()
2626/// )
2627/// .build(
2628/// hyper_rustls::HttpsConnectorBuilder::new()
2629/// .with_native_roots()
2630/// .unwrap()
2631/// .https_or_http()
2632/// .enable_http2()
2633/// .build()
2634/// );
2635/// let mut hub = Dns::new(client, auth);
2636/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2637/// // like `get(...)`
2638/// // to build up your call.
2639/// let rb = hub.projects();
2640/// # }
2641/// ```
2642pub struct ProjectMethods<'a, C>
2643where
2644 C: 'a,
2645{
2646 hub: &'a Dns<C>,
2647}
2648
2649impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2650
2651impl<'a, C> ProjectMethods<'a, C> {
2652 /// Create a builder to help you perform the following task:
2653 ///
2654 /// Fetches the representation of an existing Project.
2655 ///
2656 /// # Arguments
2657 ///
2658 /// * `project` - Identifies the project addressed by this request.
2659 pub fn get(&self, project: &str) -> ProjectGetCall<'a, C> {
2660 ProjectGetCall {
2661 hub: self.hub,
2662 _project: project.to_string(),
2663 _client_operation_id: Default::default(),
2664 _delegate: Default::default(),
2665 _additional_params: Default::default(),
2666 _scopes: Default::default(),
2667 }
2668 }
2669}
2670
2671/// A builder providing access to all methods supported on *resourceRecordSet* resources.
2672/// It is not used directly, but through the [`Dns`] hub.
2673///
2674/// # Example
2675///
2676/// Instantiate a resource builder
2677///
2678/// ```test_harness,no_run
2679/// extern crate hyper;
2680/// extern crate hyper_rustls;
2681/// extern crate google_dns1 as dns1;
2682///
2683/// # async fn dox() {
2684/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2685///
2686/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2687/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2688/// .with_native_roots()
2689/// .unwrap()
2690/// .https_only()
2691/// .enable_http2()
2692/// .build();
2693///
2694/// let executor = hyper_util::rt::TokioExecutor::new();
2695/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2696/// secret,
2697/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2698/// yup_oauth2::client::CustomHyperClientBuilder::from(
2699/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2700/// ),
2701/// ).build().await.unwrap();
2702///
2703/// let client = hyper_util::client::legacy::Client::builder(
2704/// hyper_util::rt::TokioExecutor::new()
2705/// )
2706/// .build(
2707/// hyper_rustls::HttpsConnectorBuilder::new()
2708/// .with_native_roots()
2709/// .unwrap()
2710/// .https_or_http()
2711/// .enable_http2()
2712/// .build()
2713/// );
2714/// let mut hub = Dns::new(client, auth);
2715/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2716/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `patch(...)`
2717/// // to build up your call.
2718/// let rb = hub.resource_record_sets();
2719/// # }
2720/// ```
2721pub struct ResourceRecordSetMethods<'a, C>
2722where
2723 C: 'a,
2724{
2725 hub: &'a Dns<C>,
2726}
2727
2728impl<'a, C> common::MethodsBuilder for ResourceRecordSetMethods<'a, C> {}
2729
2730impl<'a, C> ResourceRecordSetMethods<'a, C> {
2731 /// Create a builder to help you perform the following task:
2732 ///
2733 /// Creates a new ResourceRecordSet.
2734 ///
2735 /// # Arguments
2736 ///
2737 /// * `request` - No description provided.
2738 /// * `project` - Identifies the project addressed by this request.
2739 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2740 pub fn create(
2741 &self,
2742 request: ResourceRecordSet,
2743 project: &str,
2744 managed_zone: &str,
2745 ) -> ResourceRecordSetCreateCall<'a, C> {
2746 ResourceRecordSetCreateCall {
2747 hub: self.hub,
2748 _request: request,
2749 _project: project.to_string(),
2750 _managed_zone: managed_zone.to_string(),
2751 _client_operation_id: Default::default(),
2752 _delegate: Default::default(),
2753 _additional_params: Default::default(),
2754 _scopes: Default::default(),
2755 }
2756 }
2757
2758 /// Create a builder to help you perform the following task:
2759 ///
2760 /// Deletes a previously created ResourceRecordSet.
2761 ///
2762 /// # Arguments
2763 ///
2764 /// * `project` - Identifies the project addressed by this request.
2765 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2766 /// * `name` - Fully qualified domain name.
2767 /// * `type` - RRSet type.
2768 pub fn delete(
2769 &self,
2770 project: &str,
2771 managed_zone: &str,
2772 name: &str,
2773 type_: &str,
2774 ) -> ResourceRecordSetDeleteCall<'a, C> {
2775 ResourceRecordSetDeleteCall {
2776 hub: self.hub,
2777 _project: project.to_string(),
2778 _managed_zone: managed_zone.to_string(),
2779 _name: name.to_string(),
2780 _type_: type_.to_string(),
2781 _client_operation_id: Default::default(),
2782 _delegate: Default::default(),
2783 _additional_params: Default::default(),
2784 _scopes: Default::default(),
2785 }
2786 }
2787
2788 /// Create a builder to help you perform the following task:
2789 ///
2790 /// Fetches the representation of an existing ResourceRecordSet.
2791 ///
2792 /// # Arguments
2793 ///
2794 /// * `project` - Identifies the project addressed by this request.
2795 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2796 /// * `name` - Fully qualified domain name.
2797 /// * `type` - RRSet type.
2798 pub fn get(
2799 &self,
2800 project: &str,
2801 managed_zone: &str,
2802 name: &str,
2803 type_: &str,
2804 ) -> ResourceRecordSetGetCall<'a, C> {
2805 ResourceRecordSetGetCall {
2806 hub: self.hub,
2807 _project: project.to_string(),
2808 _managed_zone: managed_zone.to_string(),
2809 _name: name.to_string(),
2810 _type_: type_.to_string(),
2811 _client_operation_id: Default::default(),
2812 _delegate: Default::default(),
2813 _additional_params: Default::default(),
2814 _scopes: Default::default(),
2815 }
2816 }
2817
2818 /// Create a builder to help you perform the following task:
2819 ///
2820 /// Enumerates ResourceRecordSets that you have created but not yet deleted.
2821 ///
2822 /// # Arguments
2823 ///
2824 /// * `project` - Identifies the project addressed by this request.
2825 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2826 pub fn list(&self, project: &str, managed_zone: &str) -> ResourceRecordSetListCall<'a, C> {
2827 ResourceRecordSetListCall {
2828 hub: self.hub,
2829 _project: project.to_string(),
2830 _managed_zone: managed_zone.to_string(),
2831 _type_: Default::default(),
2832 _page_token: Default::default(),
2833 _name: Default::default(),
2834 _max_results: Default::default(),
2835 _delegate: Default::default(),
2836 _additional_params: Default::default(),
2837 _scopes: Default::default(),
2838 }
2839 }
2840
2841 /// Create a builder to help you perform the following task:
2842 ///
2843 /// Applies a partial update to an existing ResourceRecordSet.
2844 ///
2845 /// # Arguments
2846 ///
2847 /// * `request` - No description provided.
2848 /// * `project` - Identifies the project addressed by this request.
2849 /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
2850 /// * `name` - Fully qualified domain name.
2851 /// * `type` - RRSet type.
2852 pub fn patch(
2853 &self,
2854 request: ResourceRecordSet,
2855 project: &str,
2856 managed_zone: &str,
2857 name: &str,
2858 type_: &str,
2859 ) -> ResourceRecordSetPatchCall<'a, C> {
2860 ResourceRecordSetPatchCall {
2861 hub: self.hub,
2862 _request: request,
2863 _project: project.to_string(),
2864 _managed_zone: managed_zone.to_string(),
2865 _name: name.to_string(),
2866 _type_: type_.to_string(),
2867 _client_operation_id: Default::default(),
2868 _delegate: Default::default(),
2869 _additional_params: Default::default(),
2870 _scopes: Default::default(),
2871 }
2872 }
2873}
2874
2875/// A builder providing access to all methods supported on *responsePolicy* resources.
2876/// It is not used directly, but through the [`Dns`] hub.
2877///
2878/// # Example
2879///
2880/// Instantiate a resource builder
2881///
2882/// ```test_harness,no_run
2883/// extern crate hyper;
2884/// extern crate hyper_rustls;
2885/// extern crate google_dns1 as dns1;
2886///
2887/// # async fn dox() {
2888/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2889///
2890/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2891/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2892/// .with_native_roots()
2893/// .unwrap()
2894/// .https_only()
2895/// .enable_http2()
2896/// .build();
2897///
2898/// let executor = hyper_util::rt::TokioExecutor::new();
2899/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2900/// secret,
2901/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2902/// yup_oauth2::client::CustomHyperClientBuilder::from(
2903/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2904/// ),
2905/// ).build().await.unwrap();
2906///
2907/// let client = hyper_util::client::legacy::Client::builder(
2908/// hyper_util::rt::TokioExecutor::new()
2909/// )
2910/// .build(
2911/// hyper_rustls::HttpsConnectorBuilder::new()
2912/// .with_native_roots()
2913/// .unwrap()
2914/// .https_or_http()
2915/// .enable_http2()
2916/// .build()
2917/// );
2918/// let mut hub = Dns::new(client, auth);
2919/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2920/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
2921/// // to build up your call.
2922/// let rb = hub.response_policies();
2923/// # }
2924/// ```
2925pub struct ResponsePolicyMethods<'a, C>
2926where
2927 C: 'a,
2928{
2929 hub: &'a Dns<C>,
2930}
2931
2932impl<'a, C> common::MethodsBuilder for ResponsePolicyMethods<'a, C> {}
2933
2934impl<'a, C> ResponsePolicyMethods<'a, C> {
2935 /// Create a builder to help you perform the following task:
2936 ///
2937 /// Creates a new Response Policy
2938 ///
2939 /// # Arguments
2940 ///
2941 /// * `request` - No description provided.
2942 /// * `project` - Identifies the project addressed by this request.
2943 pub fn create(
2944 &self,
2945 request: ResponsePolicy,
2946 project: &str,
2947 ) -> ResponsePolicyCreateCall<'a, C> {
2948 ResponsePolicyCreateCall {
2949 hub: self.hub,
2950 _request: request,
2951 _project: project.to_string(),
2952 _client_operation_id: Default::default(),
2953 _delegate: Default::default(),
2954 _additional_params: Default::default(),
2955 _scopes: Default::default(),
2956 }
2957 }
2958
2959 /// Create a builder to help you perform the following task:
2960 ///
2961 /// Deletes a previously created Response Policy. Fails if the response policy is non-empty or still being referenced by a network.
2962 ///
2963 /// # Arguments
2964 ///
2965 /// * `project` - Identifies the project addressed by this request.
2966 /// * `responsePolicy` - User assigned name of the Response Policy addressed by this request.
2967 pub fn delete(&self, project: &str, response_policy: &str) -> ResponsePolicyDeleteCall<'a, C> {
2968 ResponsePolicyDeleteCall {
2969 hub: self.hub,
2970 _project: project.to_string(),
2971 _response_policy: response_policy.to_string(),
2972 _client_operation_id: Default::default(),
2973 _delegate: Default::default(),
2974 _additional_params: Default::default(),
2975 _scopes: Default::default(),
2976 }
2977 }
2978
2979 /// Create a builder to help you perform the following task:
2980 ///
2981 /// Fetches the representation of an existing Response Policy.
2982 ///
2983 /// # Arguments
2984 ///
2985 /// * `project` - Identifies the project addressed by this request.
2986 /// * `responsePolicy` - User assigned name of the Response Policy addressed by this request.
2987 pub fn get(&self, project: &str, response_policy: &str) -> ResponsePolicyGetCall<'a, C> {
2988 ResponsePolicyGetCall {
2989 hub: self.hub,
2990 _project: project.to_string(),
2991 _response_policy: response_policy.to_string(),
2992 _client_operation_id: Default::default(),
2993 _delegate: Default::default(),
2994 _additional_params: Default::default(),
2995 _scopes: Default::default(),
2996 }
2997 }
2998
2999 /// Create a builder to help you perform the following task:
3000 ///
3001 /// Enumerates all Response Policies associated with a project.
3002 ///
3003 /// # Arguments
3004 ///
3005 /// * `project` - Identifies the project addressed by this request.
3006 pub fn list(&self, project: &str) -> ResponsePolicyListCall<'a, C> {
3007 ResponsePolicyListCall {
3008 hub: self.hub,
3009 _project: project.to_string(),
3010 _page_token: Default::default(),
3011 _max_results: Default::default(),
3012 _delegate: Default::default(),
3013 _additional_params: Default::default(),
3014 _scopes: Default::default(),
3015 }
3016 }
3017
3018 /// Create a builder to help you perform the following task:
3019 ///
3020 /// Applies a partial update to an existing Response Policy.
3021 ///
3022 /// # Arguments
3023 ///
3024 /// * `request` - No description provided.
3025 /// * `project` - Identifies the project addressed by this request.
3026 /// * `responsePolicy` - User assigned name of the response policy addressed by this request.
3027 pub fn patch(
3028 &self,
3029 request: ResponsePolicy,
3030 project: &str,
3031 response_policy: &str,
3032 ) -> ResponsePolicyPatchCall<'a, C> {
3033 ResponsePolicyPatchCall {
3034 hub: self.hub,
3035 _request: request,
3036 _project: project.to_string(),
3037 _response_policy: response_policy.to_string(),
3038 _client_operation_id: Default::default(),
3039 _delegate: Default::default(),
3040 _additional_params: Default::default(),
3041 _scopes: Default::default(),
3042 }
3043 }
3044
3045 /// Create a builder to help you perform the following task:
3046 ///
3047 /// Updates an existing Response Policy.
3048 ///
3049 /// # Arguments
3050 ///
3051 /// * `request` - No description provided.
3052 /// * `project` - Identifies the project addressed by this request.
3053 /// * `responsePolicy` - User assigned name of the Response Policy addressed by this request.
3054 pub fn update(
3055 &self,
3056 request: ResponsePolicy,
3057 project: &str,
3058 response_policy: &str,
3059 ) -> ResponsePolicyUpdateCall<'a, C> {
3060 ResponsePolicyUpdateCall {
3061 hub: self.hub,
3062 _request: request,
3063 _project: project.to_string(),
3064 _response_policy: response_policy.to_string(),
3065 _client_operation_id: Default::default(),
3066 _delegate: Default::default(),
3067 _additional_params: Default::default(),
3068 _scopes: Default::default(),
3069 }
3070 }
3071}
3072
3073/// A builder providing access to all methods supported on *responsePolicyRule* resources.
3074/// It is not used directly, but through the [`Dns`] hub.
3075///
3076/// # Example
3077///
3078/// Instantiate a resource builder
3079///
3080/// ```test_harness,no_run
3081/// extern crate hyper;
3082/// extern crate hyper_rustls;
3083/// extern crate google_dns1 as dns1;
3084///
3085/// # async fn dox() {
3086/// use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3087///
3088/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3089/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3090/// .with_native_roots()
3091/// .unwrap()
3092/// .https_only()
3093/// .enable_http2()
3094/// .build();
3095///
3096/// let executor = hyper_util::rt::TokioExecutor::new();
3097/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3098/// secret,
3099/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3100/// yup_oauth2::client::CustomHyperClientBuilder::from(
3101/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3102/// ),
3103/// ).build().await.unwrap();
3104///
3105/// let client = hyper_util::client::legacy::Client::builder(
3106/// hyper_util::rt::TokioExecutor::new()
3107/// )
3108/// .build(
3109/// hyper_rustls::HttpsConnectorBuilder::new()
3110/// .with_native_roots()
3111/// .unwrap()
3112/// .https_or_http()
3113/// .enable_http2()
3114/// .build()
3115/// );
3116/// let mut hub = Dns::new(client, auth);
3117/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3118/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)`
3119/// // to build up your call.
3120/// let rb = hub.response_policy_rules();
3121/// # }
3122/// ```
3123pub struct ResponsePolicyRuleMethods<'a, C>
3124where
3125 C: 'a,
3126{
3127 hub: &'a Dns<C>,
3128}
3129
3130impl<'a, C> common::MethodsBuilder for ResponsePolicyRuleMethods<'a, C> {}
3131
3132impl<'a, C> ResponsePolicyRuleMethods<'a, C> {
3133 /// Create a builder to help you perform the following task:
3134 ///
3135 /// Creates a new Response Policy Rule.
3136 ///
3137 /// # Arguments
3138 ///
3139 /// * `request` - No description provided.
3140 /// * `project` - Identifies the project addressed by this request.
3141 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3142 pub fn create(
3143 &self,
3144 request: ResponsePolicyRule,
3145 project: &str,
3146 response_policy: &str,
3147 ) -> ResponsePolicyRuleCreateCall<'a, C> {
3148 ResponsePolicyRuleCreateCall {
3149 hub: self.hub,
3150 _request: request,
3151 _project: project.to_string(),
3152 _response_policy: response_policy.to_string(),
3153 _client_operation_id: Default::default(),
3154 _delegate: Default::default(),
3155 _additional_params: Default::default(),
3156 _scopes: Default::default(),
3157 }
3158 }
3159
3160 /// Create a builder to help you perform the following task:
3161 ///
3162 /// Deletes a previously created Response Policy Rule.
3163 ///
3164 /// # Arguments
3165 ///
3166 /// * `project` - Identifies the project addressed by this request.
3167 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3168 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3169 pub fn delete(
3170 &self,
3171 project: &str,
3172 response_policy: &str,
3173 response_policy_rule: &str,
3174 ) -> ResponsePolicyRuleDeleteCall<'a, C> {
3175 ResponsePolicyRuleDeleteCall {
3176 hub: self.hub,
3177 _project: project.to_string(),
3178 _response_policy: response_policy.to_string(),
3179 _response_policy_rule: response_policy_rule.to_string(),
3180 _client_operation_id: Default::default(),
3181 _delegate: Default::default(),
3182 _additional_params: Default::default(),
3183 _scopes: Default::default(),
3184 }
3185 }
3186
3187 /// Create a builder to help you perform the following task:
3188 ///
3189 /// Fetches the representation of an existing Response Policy Rule.
3190 ///
3191 /// # Arguments
3192 ///
3193 /// * `project` - Identifies the project addressed by this request.
3194 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3195 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3196 pub fn get(
3197 &self,
3198 project: &str,
3199 response_policy: &str,
3200 response_policy_rule: &str,
3201 ) -> ResponsePolicyRuleGetCall<'a, C> {
3202 ResponsePolicyRuleGetCall {
3203 hub: self.hub,
3204 _project: project.to_string(),
3205 _response_policy: response_policy.to_string(),
3206 _response_policy_rule: response_policy_rule.to_string(),
3207 _client_operation_id: Default::default(),
3208 _delegate: Default::default(),
3209 _additional_params: Default::default(),
3210 _scopes: Default::default(),
3211 }
3212 }
3213
3214 /// Create a builder to help you perform the following task:
3215 ///
3216 /// Enumerates all Response Policy Rules associated with a project.
3217 ///
3218 /// # Arguments
3219 ///
3220 /// * `project` - Identifies the project addressed by this request.
3221 /// * `responsePolicy` - User assigned name of the Response Policy to list.
3222 pub fn list(&self, project: &str, response_policy: &str) -> ResponsePolicyRuleListCall<'a, C> {
3223 ResponsePolicyRuleListCall {
3224 hub: self.hub,
3225 _project: project.to_string(),
3226 _response_policy: response_policy.to_string(),
3227 _page_token: Default::default(),
3228 _max_results: Default::default(),
3229 _delegate: Default::default(),
3230 _additional_params: Default::default(),
3231 _scopes: Default::default(),
3232 }
3233 }
3234
3235 /// Create a builder to help you perform the following task:
3236 ///
3237 /// Applies a partial update to an existing Response Policy Rule.
3238 ///
3239 /// # Arguments
3240 ///
3241 /// * `request` - No description provided.
3242 /// * `project` - Identifies the project addressed by this request.
3243 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3244 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3245 pub fn patch(
3246 &self,
3247 request: ResponsePolicyRule,
3248 project: &str,
3249 response_policy: &str,
3250 response_policy_rule: &str,
3251 ) -> ResponsePolicyRulePatchCall<'a, C> {
3252 ResponsePolicyRulePatchCall {
3253 hub: self.hub,
3254 _request: request,
3255 _project: project.to_string(),
3256 _response_policy: response_policy.to_string(),
3257 _response_policy_rule: response_policy_rule.to_string(),
3258 _client_operation_id: Default::default(),
3259 _delegate: Default::default(),
3260 _additional_params: Default::default(),
3261 _scopes: Default::default(),
3262 }
3263 }
3264
3265 /// Create a builder to help you perform the following task:
3266 ///
3267 /// Updates an existing Response Policy Rule.
3268 ///
3269 /// # Arguments
3270 ///
3271 /// * `request` - No description provided.
3272 /// * `project` - Identifies the project addressed by this request.
3273 /// * `responsePolicy` - User assigned name of the Response Policy containing the Response Policy Rule.
3274 /// * `responsePolicyRule` - User assigned name of the Response Policy Rule addressed by this request.
3275 pub fn update(
3276 &self,
3277 request: ResponsePolicyRule,
3278 project: &str,
3279 response_policy: &str,
3280 response_policy_rule: &str,
3281 ) -> ResponsePolicyRuleUpdateCall<'a, C> {
3282 ResponsePolicyRuleUpdateCall {
3283 hub: self.hub,
3284 _request: request,
3285 _project: project.to_string(),
3286 _response_policy: response_policy.to_string(),
3287 _response_policy_rule: response_policy_rule.to_string(),
3288 _client_operation_id: Default::default(),
3289 _delegate: Default::default(),
3290 _additional_params: Default::default(),
3291 _scopes: Default::default(),
3292 }
3293 }
3294}
3295
3296// ###################
3297// CallBuilders ###
3298// #################
3299
3300/// Atomically updates the ResourceRecordSet collection.
3301///
3302/// A builder for the *create* method supported by a *change* resource.
3303/// It is not used directly, but through a [`ChangeMethods`] instance.
3304///
3305/// # Example
3306///
3307/// Instantiate a resource method builder
3308///
3309/// ```test_harness,no_run
3310/// # extern crate hyper;
3311/// # extern crate hyper_rustls;
3312/// # extern crate google_dns1 as dns1;
3313/// use dns1::api::Change;
3314/// # async fn dox() {
3315/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3316///
3317/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3318/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3319/// # .with_native_roots()
3320/// # .unwrap()
3321/// # .https_only()
3322/// # .enable_http2()
3323/// # .build();
3324///
3325/// # let executor = hyper_util::rt::TokioExecutor::new();
3326/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3327/// # secret,
3328/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3329/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3330/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3331/// # ),
3332/// # ).build().await.unwrap();
3333///
3334/// # let client = hyper_util::client::legacy::Client::builder(
3335/// # hyper_util::rt::TokioExecutor::new()
3336/// # )
3337/// # .build(
3338/// # hyper_rustls::HttpsConnectorBuilder::new()
3339/// # .with_native_roots()
3340/// # .unwrap()
3341/// # .https_or_http()
3342/// # .enable_http2()
3343/// # .build()
3344/// # );
3345/// # let mut hub = Dns::new(client, auth);
3346/// // As the method needs a request, you would usually fill it with the desired information
3347/// // into the respective structure. Some of the parts shown here might not be applicable !
3348/// // Values shown here are possibly random and not representative !
3349/// let mut req = Change::default();
3350///
3351/// // You can configure optional parameters by calling the respective setters at will, and
3352/// // execute the final call using `doit()`.
3353/// // Values shown here are possibly random and not representative !
3354/// let result = hub.changes().create(req, "project", "managedZone")
3355/// .client_operation_id("Lorem")
3356/// .doit().await;
3357/// # }
3358/// ```
3359pub struct ChangeCreateCall<'a, C>
3360where
3361 C: 'a,
3362{
3363 hub: &'a Dns<C>,
3364 _request: Change,
3365 _project: String,
3366 _managed_zone: String,
3367 _client_operation_id: Option<String>,
3368 _delegate: Option<&'a mut dyn common::Delegate>,
3369 _additional_params: HashMap<String, String>,
3370 _scopes: BTreeSet<String>,
3371}
3372
3373impl<'a, C> common::CallBuilder for ChangeCreateCall<'a, C> {}
3374
3375impl<'a, C> ChangeCreateCall<'a, C>
3376where
3377 C: common::Connector,
3378{
3379 /// Perform the operation you have build so far.
3380 pub async fn doit(mut self) -> common::Result<(common::Response, Change)> {
3381 use std::borrow::Cow;
3382 use std::io::{Read, Seek};
3383
3384 use common::{url::Params, ToParts};
3385 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3386
3387 let mut dd = common::DefaultDelegate;
3388 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3389 dlg.begin(common::MethodInfo {
3390 id: "dns.changes.create",
3391 http_method: hyper::Method::POST,
3392 });
3393
3394 for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() {
3395 if self._additional_params.contains_key(field) {
3396 dlg.finished(false);
3397 return Err(common::Error::FieldClash(field));
3398 }
3399 }
3400
3401 let mut params = Params::with_capacity(6 + self._additional_params.len());
3402 params.push("project", self._project);
3403 params.push("managedZone", self._managed_zone);
3404 if let Some(value) = self._client_operation_id.as_ref() {
3405 params.push("clientOperationId", value);
3406 }
3407
3408 params.extend(self._additional_params.iter());
3409
3410 params.push("alt", "json");
3411 let mut url = self.hub._base_url.clone()
3412 + "dns/v1/projects/{project}/managedZones/{managedZone}/changes";
3413 if self._scopes.is_empty() {
3414 self._scopes
3415 .insert(Scope::CloudPlatform.as_ref().to_string());
3416 }
3417
3418 #[allow(clippy::single_element_loop)]
3419 for &(find_this, param_name) in
3420 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
3421 {
3422 url = params.uri_replacement(url, param_name, find_this, false);
3423 }
3424 {
3425 let to_remove = ["managedZone", "project"];
3426 params.remove_params(&to_remove);
3427 }
3428
3429 let url = params.parse_with_url(&url);
3430
3431 let mut json_mime_type = mime::APPLICATION_JSON;
3432 let mut request_value_reader = {
3433 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3434 common::remove_json_null_values(&mut value);
3435 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3436 serde_json::to_writer(&mut dst, &value).unwrap();
3437 dst
3438 };
3439 let request_size = request_value_reader
3440 .seek(std::io::SeekFrom::End(0))
3441 .unwrap();
3442 request_value_reader
3443 .seek(std::io::SeekFrom::Start(0))
3444 .unwrap();
3445
3446 loop {
3447 let token = match self
3448 .hub
3449 .auth
3450 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3451 .await
3452 {
3453 Ok(token) => token,
3454 Err(e) => match dlg.token(e) {
3455 Ok(token) => token,
3456 Err(e) => {
3457 dlg.finished(false);
3458 return Err(common::Error::MissingToken(e));
3459 }
3460 },
3461 };
3462 request_value_reader
3463 .seek(std::io::SeekFrom::Start(0))
3464 .unwrap();
3465 let mut req_result = {
3466 let client = &self.hub.client;
3467 dlg.pre_request();
3468 let mut req_builder = hyper::Request::builder()
3469 .method(hyper::Method::POST)
3470 .uri(url.as_str())
3471 .header(USER_AGENT, self.hub._user_agent.clone());
3472
3473 if let Some(token) = token.as_ref() {
3474 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3475 }
3476
3477 let request = req_builder
3478 .header(CONTENT_TYPE, json_mime_type.to_string())
3479 .header(CONTENT_LENGTH, request_size as u64)
3480 .body(common::to_body(
3481 request_value_reader.get_ref().clone().into(),
3482 ));
3483
3484 client.request(request.unwrap()).await
3485 };
3486
3487 match req_result {
3488 Err(err) => {
3489 if let common::Retry::After(d) = dlg.http_error(&err) {
3490 sleep(d).await;
3491 continue;
3492 }
3493 dlg.finished(false);
3494 return Err(common::Error::HttpError(err));
3495 }
3496 Ok(res) => {
3497 let (mut parts, body) = res.into_parts();
3498 let mut body = common::Body::new(body);
3499 if !parts.status.is_success() {
3500 let bytes = common::to_bytes(body).await.unwrap_or_default();
3501 let error = serde_json::from_str(&common::to_string(&bytes));
3502 let response = common::to_response(parts, bytes.into());
3503
3504 if let common::Retry::After(d) =
3505 dlg.http_failure(&response, error.as_ref().ok())
3506 {
3507 sleep(d).await;
3508 continue;
3509 }
3510
3511 dlg.finished(false);
3512
3513 return Err(match error {
3514 Ok(value) => common::Error::BadRequest(value),
3515 _ => common::Error::Failure(response),
3516 });
3517 }
3518 let response = {
3519 let bytes = common::to_bytes(body).await.unwrap_or_default();
3520 let encoded = common::to_string(&bytes);
3521 match serde_json::from_str(&encoded) {
3522 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3523 Err(error) => {
3524 dlg.response_json_decode_error(&encoded, &error);
3525 return Err(common::Error::JsonDecodeError(
3526 encoded.to_string(),
3527 error,
3528 ));
3529 }
3530 }
3531 };
3532
3533 dlg.finished(true);
3534 return Ok(response);
3535 }
3536 }
3537 }
3538 }
3539
3540 ///
3541 /// Sets the *request* property to the given value.
3542 ///
3543 /// Even though the property as already been set when instantiating this call,
3544 /// we provide this method for API completeness.
3545 pub fn request(mut self, new_value: Change) -> ChangeCreateCall<'a, C> {
3546 self._request = new_value;
3547 self
3548 }
3549 /// Identifies the project addressed by this request.
3550 ///
3551 /// Sets the *project* path property to the given value.
3552 ///
3553 /// Even though the property as already been set when instantiating this call,
3554 /// we provide this method for API completeness.
3555 pub fn project(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3556 self._project = new_value.to_string();
3557 self
3558 }
3559 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
3560 ///
3561 /// Sets the *managed zone* path property to the given value.
3562 ///
3563 /// Even though the property as already been set when instantiating this call,
3564 /// we provide this method for API completeness.
3565 pub fn managed_zone(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3566 self._managed_zone = new_value.to_string();
3567 self
3568 }
3569 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
3570 ///
3571 /// Sets the *client operation id* query property to the given value.
3572 pub fn client_operation_id(mut self, new_value: &str) -> ChangeCreateCall<'a, C> {
3573 self._client_operation_id = Some(new_value.to_string());
3574 self
3575 }
3576 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3577 /// while executing the actual API request.
3578 ///
3579 /// ````text
3580 /// It should be used to handle progress information, and to implement a certain level of resilience.
3581 /// ````
3582 ///
3583 /// Sets the *delegate* property to the given value.
3584 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeCreateCall<'a, C> {
3585 self._delegate = Some(new_value);
3586 self
3587 }
3588
3589 /// Set any additional parameter of the query string used in the request.
3590 /// It should be used to set parameters which are not yet available through their own
3591 /// setters.
3592 ///
3593 /// Please note that this method must not be used to set any of the known parameters
3594 /// which have their own setter method. If done anyway, the request will fail.
3595 ///
3596 /// # Additional Parameters
3597 ///
3598 /// * *$.xgafv* (query-string) - V1 error format.
3599 /// * *access_token* (query-string) - OAuth access token.
3600 /// * *alt* (query-string) - Data format for response.
3601 /// * *callback* (query-string) - JSONP
3602 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3603 /// * *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.
3604 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3605 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3606 /// * *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.
3607 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3608 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3609 pub fn param<T>(mut self, name: T, value: T) -> ChangeCreateCall<'a, C>
3610 where
3611 T: AsRef<str>,
3612 {
3613 self._additional_params
3614 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3615 self
3616 }
3617
3618 /// Identifies the authorization scope for the method you are building.
3619 ///
3620 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3621 /// [`Scope::CloudPlatform`].
3622 ///
3623 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3624 /// tokens for more than one scope.
3625 ///
3626 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3627 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3628 /// sufficient, a read-write scope will do as well.
3629 pub fn add_scope<St>(mut self, scope: St) -> ChangeCreateCall<'a, C>
3630 where
3631 St: AsRef<str>,
3632 {
3633 self._scopes.insert(String::from(scope.as_ref()));
3634 self
3635 }
3636 /// Identifies the authorization scope(s) for the method you are building.
3637 ///
3638 /// See [`Self::add_scope()`] for details.
3639 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeCreateCall<'a, C>
3640 where
3641 I: IntoIterator<Item = St>,
3642 St: AsRef<str>,
3643 {
3644 self._scopes
3645 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3646 self
3647 }
3648
3649 /// Removes all scopes, and no default scope will be used either.
3650 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3651 /// for details).
3652 pub fn clear_scopes(mut self) -> ChangeCreateCall<'a, C> {
3653 self._scopes.clear();
3654 self
3655 }
3656}
3657
3658/// Fetches the representation of an existing Change.
3659///
3660/// A builder for the *get* method supported by a *change* resource.
3661/// It is not used directly, but through a [`ChangeMethods`] instance.
3662///
3663/// # Example
3664///
3665/// Instantiate a resource method builder
3666///
3667/// ```test_harness,no_run
3668/// # extern crate hyper;
3669/// # extern crate hyper_rustls;
3670/// # extern crate google_dns1 as dns1;
3671/// # async fn dox() {
3672/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3673///
3674/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3675/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3676/// # .with_native_roots()
3677/// # .unwrap()
3678/// # .https_only()
3679/// # .enable_http2()
3680/// # .build();
3681///
3682/// # let executor = hyper_util::rt::TokioExecutor::new();
3683/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3684/// # secret,
3685/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3686/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3687/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3688/// # ),
3689/// # ).build().await.unwrap();
3690///
3691/// # let client = hyper_util::client::legacy::Client::builder(
3692/// # hyper_util::rt::TokioExecutor::new()
3693/// # )
3694/// # .build(
3695/// # hyper_rustls::HttpsConnectorBuilder::new()
3696/// # .with_native_roots()
3697/// # .unwrap()
3698/// # .https_or_http()
3699/// # .enable_http2()
3700/// # .build()
3701/// # );
3702/// # let mut hub = Dns::new(client, auth);
3703/// // You can configure optional parameters by calling the respective setters at will, and
3704/// // execute the final call using `doit()`.
3705/// // Values shown here are possibly random and not representative !
3706/// let result = hub.changes().get("project", "managedZone", "changeId")
3707/// .client_operation_id("ea")
3708/// .doit().await;
3709/// # }
3710/// ```
3711pub struct ChangeGetCall<'a, C>
3712where
3713 C: 'a,
3714{
3715 hub: &'a Dns<C>,
3716 _project: String,
3717 _managed_zone: String,
3718 _change_id: String,
3719 _client_operation_id: Option<String>,
3720 _delegate: Option<&'a mut dyn common::Delegate>,
3721 _additional_params: HashMap<String, String>,
3722 _scopes: BTreeSet<String>,
3723}
3724
3725impl<'a, C> common::CallBuilder for ChangeGetCall<'a, C> {}
3726
3727impl<'a, C> ChangeGetCall<'a, C>
3728where
3729 C: common::Connector,
3730{
3731 /// Perform the operation you have build so far.
3732 pub async fn doit(mut self) -> common::Result<(common::Response, Change)> {
3733 use std::borrow::Cow;
3734 use std::io::{Read, Seek};
3735
3736 use common::{url::Params, ToParts};
3737 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3738
3739 let mut dd = common::DefaultDelegate;
3740 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3741 dlg.begin(common::MethodInfo {
3742 id: "dns.changes.get",
3743 http_method: hyper::Method::GET,
3744 });
3745
3746 for &field in [
3747 "alt",
3748 "project",
3749 "managedZone",
3750 "changeId",
3751 "clientOperationId",
3752 ]
3753 .iter()
3754 {
3755 if self._additional_params.contains_key(field) {
3756 dlg.finished(false);
3757 return Err(common::Error::FieldClash(field));
3758 }
3759 }
3760
3761 let mut params = Params::with_capacity(6 + self._additional_params.len());
3762 params.push("project", self._project);
3763 params.push("managedZone", self._managed_zone);
3764 params.push("changeId", self._change_id);
3765 if let Some(value) = self._client_operation_id.as_ref() {
3766 params.push("clientOperationId", value);
3767 }
3768
3769 params.extend(self._additional_params.iter());
3770
3771 params.push("alt", "json");
3772 let mut url = self.hub._base_url.clone()
3773 + "dns/v1/projects/{project}/managedZones/{managedZone}/changes/{changeId}";
3774 if self._scopes.is_empty() {
3775 self._scopes
3776 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
3777 }
3778
3779 #[allow(clippy::single_element_loop)]
3780 for &(find_this, param_name) in [
3781 ("{project}", "project"),
3782 ("{managedZone}", "managedZone"),
3783 ("{changeId}", "changeId"),
3784 ]
3785 .iter()
3786 {
3787 url = params.uri_replacement(url, param_name, find_this, false);
3788 }
3789 {
3790 let to_remove = ["changeId", "managedZone", "project"];
3791 params.remove_params(&to_remove);
3792 }
3793
3794 let url = params.parse_with_url(&url);
3795
3796 loop {
3797 let token = match self
3798 .hub
3799 .auth
3800 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3801 .await
3802 {
3803 Ok(token) => token,
3804 Err(e) => match dlg.token(e) {
3805 Ok(token) => token,
3806 Err(e) => {
3807 dlg.finished(false);
3808 return Err(common::Error::MissingToken(e));
3809 }
3810 },
3811 };
3812 let mut req_result = {
3813 let client = &self.hub.client;
3814 dlg.pre_request();
3815 let mut req_builder = hyper::Request::builder()
3816 .method(hyper::Method::GET)
3817 .uri(url.as_str())
3818 .header(USER_AGENT, self.hub._user_agent.clone());
3819
3820 if let Some(token) = token.as_ref() {
3821 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3822 }
3823
3824 let request = req_builder
3825 .header(CONTENT_LENGTH, 0_u64)
3826 .body(common::to_body::<String>(None));
3827
3828 client.request(request.unwrap()).await
3829 };
3830
3831 match req_result {
3832 Err(err) => {
3833 if let common::Retry::After(d) = dlg.http_error(&err) {
3834 sleep(d).await;
3835 continue;
3836 }
3837 dlg.finished(false);
3838 return Err(common::Error::HttpError(err));
3839 }
3840 Ok(res) => {
3841 let (mut parts, body) = res.into_parts();
3842 let mut body = common::Body::new(body);
3843 if !parts.status.is_success() {
3844 let bytes = common::to_bytes(body).await.unwrap_or_default();
3845 let error = serde_json::from_str(&common::to_string(&bytes));
3846 let response = common::to_response(parts, bytes.into());
3847
3848 if let common::Retry::After(d) =
3849 dlg.http_failure(&response, error.as_ref().ok())
3850 {
3851 sleep(d).await;
3852 continue;
3853 }
3854
3855 dlg.finished(false);
3856
3857 return Err(match error {
3858 Ok(value) => common::Error::BadRequest(value),
3859 _ => common::Error::Failure(response),
3860 });
3861 }
3862 let response = {
3863 let bytes = common::to_bytes(body).await.unwrap_or_default();
3864 let encoded = common::to_string(&bytes);
3865 match serde_json::from_str(&encoded) {
3866 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3867 Err(error) => {
3868 dlg.response_json_decode_error(&encoded, &error);
3869 return Err(common::Error::JsonDecodeError(
3870 encoded.to_string(),
3871 error,
3872 ));
3873 }
3874 }
3875 };
3876
3877 dlg.finished(true);
3878 return Ok(response);
3879 }
3880 }
3881 }
3882 }
3883
3884 /// Identifies the project addressed by this request.
3885 ///
3886 /// Sets the *project* path property to the given value.
3887 ///
3888 /// Even though the property as already been set when instantiating this call,
3889 /// we provide this method for API completeness.
3890 pub fn project(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
3891 self._project = new_value.to_string();
3892 self
3893 }
3894 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
3895 ///
3896 /// Sets the *managed zone* path property to the given value.
3897 ///
3898 /// Even though the property as already been set when instantiating this call,
3899 /// we provide this method for API completeness.
3900 pub fn managed_zone(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
3901 self._managed_zone = new_value.to_string();
3902 self
3903 }
3904 /// The identifier of the requested change, from a previous ResourceRecordSetsChangeResponse.
3905 ///
3906 /// Sets the *change id* path property to the given value.
3907 ///
3908 /// Even though the property as already been set when instantiating this call,
3909 /// we provide this method for API completeness.
3910 pub fn change_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
3911 self._change_id = new_value.to_string();
3912 self
3913 }
3914 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
3915 ///
3916 /// Sets the *client operation id* query property to the given value.
3917 pub fn client_operation_id(mut self, new_value: &str) -> ChangeGetCall<'a, C> {
3918 self._client_operation_id = Some(new_value.to_string());
3919 self
3920 }
3921 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3922 /// while executing the actual API request.
3923 ///
3924 /// ````text
3925 /// It should be used to handle progress information, and to implement a certain level of resilience.
3926 /// ````
3927 ///
3928 /// Sets the *delegate* property to the given value.
3929 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeGetCall<'a, C> {
3930 self._delegate = Some(new_value);
3931 self
3932 }
3933
3934 /// Set any additional parameter of the query string used in the request.
3935 /// It should be used to set parameters which are not yet available through their own
3936 /// setters.
3937 ///
3938 /// Please note that this method must not be used to set any of the known parameters
3939 /// which have their own setter method. If done anyway, the request will fail.
3940 ///
3941 /// # Additional Parameters
3942 ///
3943 /// * *$.xgafv* (query-string) - V1 error format.
3944 /// * *access_token* (query-string) - OAuth access token.
3945 /// * *alt* (query-string) - Data format for response.
3946 /// * *callback* (query-string) - JSONP
3947 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3948 /// * *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.
3949 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3950 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3951 /// * *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.
3952 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3953 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3954 pub fn param<T>(mut self, name: T, value: T) -> ChangeGetCall<'a, C>
3955 where
3956 T: AsRef<str>,
3957 {
3958 self._additional_params
3959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3960 self
3961 }
3962
3963 /// Identifies the authorization scope for the method you are building.
3964 ///
3965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3966 /// [`Scope::NdevClouddnReadonly`].
3967 ///
3968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3969 /// tokens for more than one scope.
3970 ///
3971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3973 /// sufficient, a read-write scope will do as well.
3974 pub fn add_scope<St>(mut self, scope: St) -> ChangeGetCall<'a, C>
3975 where
3976 St: AsRef<str>,
3977 {
3978 self._scopes.insert(String::from(scope.as_ref()));
3979 self
3980 }
3981 /// Identifies the authorization scope(s) for the method you are building.
3982 ///
3983 /// See [`Self::add_scope()`] for details.
3984 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeGetCall<'a, C>
3985 where
3986 I: IntoIterator<Item = St>,
3987 St: AsRef<str>,
3988 {
3989 self._scopes
3990 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3991 self
3992 }
3993
3994 /// Removes all scopes, and no default scope will be used either.
3995 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3996 /// for details).
3997 pub fn clear_scopes(mut self) -> ChangeGetCall<'a, C> {
3998 self._scopes.clear();
3999 self
4000 }
4001}
4002
4003/// Enumerates Changes to a ResourceRecordSet collection.
4004///
4005/// A builder for the *list* method supported by a *change* resource.
4006/// It is not used directly, but through a [`ChangeMethods`] instance.
4007///
4008/// # Example
4009///
4010/// Instantiate a resource method builder
4011///
4012/// ```test_harness,no_run
4013/// # extern crate hyper;
4014/// # extern crate hyper_rustls;
4015/// # extern crate google_dns1 as dns1;
4016/// # async fn dox() {
4017/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4018///
4019/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4020/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4021/// # .with_native_roots()
4022/// # .unwrap()
4023/// # .https_only()
4024/// # .enable_http2()
4025/// # .build();
4026///
4027/// # let executor = hyper_util::rt::TokioExecutor::new();
4028/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4029/// # secret,
4030/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4031/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4032/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4033/// # ),
4034/// # ).build().await.unwrap();
4035///
4036/// # let client = hyper_util::client::legacy::Client::builder(
4037/// # hyper_util::rt::TokioExecutor::new()
4038/// # )
4039/// # .build(
4040/// # hyper_rustls::HttpsConnectorBuilder::new()
4041/// # .with_native_roots()
4042/// # .unwrap()
4043/// # .https_or_http()
4044/// # .enable_http2()
4045/// # .build()
4046/// # );
4047/// # let mut hub = Dns::new(client, auth);
4048/// // You can configure optional parameters by calling the respective setters at will, and
4049/// // execute the final call using `doit()`.
4050/// // Values shown here are possibly random and not representative !
4051/// let result = hub.changes().list("project", "managedZone")
4052/// .sort_order("amet")
4053/// .sort_by("duo")
4054/// .page_token("ipsum")
4055/// .max_results(-93)
4056/// .doit().await;
4057/// # }
4058/// ```
4059pub struct ChangeListCall<'a, C>
4060where
4061 C: 'a,
4062{
4063 hub: &'a Dns<C>,
4064 _project: String,
4065 _managed_zone: String,
4066 _sort_order: Option<String>,
4067 _sort_by: Option<String>,
4068 _page_token: Option<String>,
4069 _max_results: Option<i32>,
4070 _delegate: Option<&'a mut dyn common::Delegate>,
4071 _additional_params: HashMap<String, String>,
4072 _scopes: BTreeSet<String>,
4073}
4074
4075impl<'a, C> common::CallBuilder for ChangeListCall<'a, C> {}
4076
4077impl<'a, C> ChangeListCall<'a, C>
4078where
4079 C: common::Connector,
4080{
4081 /// Perform the operation you have build so far.
4082 pub async fn doit(mut self) -> common::Result<(common::Response, ChangesListResponse)> {
4083 use std::borrow::Cow;
4084 use std::io::{Read, Seek};
4085
4086 use common::{url::Params, ToParts};
4087 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4088
4089 let mut dd = common::DefaultDelegate;
4090 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4091 dlg.begin(common::MethodInfo {
4092 id: "dns.changes.list",
4093 http_method: hyper::Method::GET,
4094 });
4095
4096 for &field in [
4097 "alt",
4098 "project",
4099 "managedZone",
4100 "sortOrder",
4101 "sortBy",
4102 "pageToken",
4103 "maxResults",
4104 ]
4105 .iter()
4106 {
4107 if self._additional_params.contains_key(field) {
4108 dlg.finished(false);
4109 return Err(common::Error::FieldClash(field));
4110 }
4111 }
4112
4113 let mut params = Params::with_capacity(8 + self._additional_params.len());
4114 params.push("project", self._project);
4115 params.push("managedZone", self._managed_zone);
4116 if let Some(value) = self._sort_order.as_ref() {
4117 params.push("sortOrder", value);
4118 }
4119 if let Some(value) = self._sort_by.as_ref() {
4120 params.push("sortBy", value);
4121 }
4122 if let Some(value) = self._page_token.as_ref() {
4123 params.push("pageToken", value);
4124 }
4125 if let Some(value) = self._max_results.as_ref() {
4126 params.push("maxResults", value.to_string());
4127 }
4128
4129 params.extend(self._additional_params.iter());
4130
4131 params.push("alt", "json");
4132 let mut url = self.hub._base_url.clone()
4133 + "dns/v1/projects/{project}/managedZones/{managedZone}/changes";
4134 if self._scopes.is_empty() {
4135 self._scopes
4136 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
4137 }
4138
4139 #[allow(clippy::single_element_loop)]
4140 for &(find_this, param_name) in
4141 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
4142 {
4143 url = params.uri_replacement(url, param_name, find_this, false);
4144 }
4145 {
4146 let to_remove = ["managedZone", "project"];
4147 params.remove_params(&to_remove);
4148 }
4149
4150 let url = params.parse_with_url(&url);
4151
4152 loop {
4153 let token = match self
4154 .hub
4155 .auth
4156 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4157 .await
4158 {
4159 Ok(token) => token,
4160 Err(e) => match dlg.token(e) {
4161 Ok(token) => token,
4162 Err(e) => {
4163 dlg.finished(false);
4164 return Err(common::Error::MissingToken(e));
4165 }
4166 },
4167 };
4168 let mut req_result = {
4169 let client = &self.hub.client;
4170 dlg.pre_request();
4171 let mut req_builder = hyper::Request::builder()
4172 .method(hyper::Method::GET)
4173 .uri(url.as_str())
4174 .header(USER_AGENT, self.hub._user_agent.clone());
4175
4176 if let Some(token) = token.as_ref() {
4177 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4178 }
4179
4180 let request = req_builder
4181 .header(CONTENT_LENGTH, 0_u64)
4182 .body(common::to_body::<String>(None));
4183
4184 client.request(request.unwrap()).await
4185 };
4186
4187 match req_result {
4188 Err(err) => {
4189 if let common::Retry::After(d) = dlg.http_error(&err) {
4190 sleep(d).await;
4191 continue;
4192 }
4193 dlg.finished(false);
4194 return Err(common::Error::HttpError(err));
4195 }
4196 Ok(res) => {
4197 let (mut parts, body) = res.into_parts();
4198 let mut body = common::Body::new(body);
4199 if !parts.status.is_success() {
4200 let bytes = common::to_bytes(body).await.unwrap_or_default();
4201 let error = serde_json::from_str(&common::to_string(&bytes));
4202 let response = common::to_response(parts, bytes.into());
4203
4204 if let common::Retry::After(d) =
4205 dlg.http_failure(&response, error.as_ref().ok())
4206 {
4207 sleep(d).await;
4208 continue;
4209 }
4210
4211 dlg.finished(false);
4212
4213 return Err(match error {
4214 Ok(value) => common::Error::BadRequest(value),
4215 _ => common::Error::Failure(response),
4216 });
4217 }
4218 let response = {
4219 let bytes = common::to_bytes(body).await.unwrap_or_default();
4220 let encoded = common::to_string(&bytes);
4221 match serde_json::from_str(&encoded) {
4222 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4223 Err(error) => {
4224 dlg.response_json_decode_error(&encoded, &error);
4225 return Err(common::Error::JsonDecodeError(
4226 encoded.to_string(),
4227 error,
4228 ));
4229 }
4230 }
4231 };
4232
4233 dlg.finished(true);
4234 return Ok(response);
4235 }
4236 }
4237 }
4238 }
4239
4240 /// Identifies the project addressed by this request.
4241 ///
4242 /// Sets the *project* path property to the given value.
4243 ///
4244 /// Even though the property as already been set when instantiating this call,
4245 /// we provide this method for API completeness.
4246 pub fn project(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4247 self._project = new_value.to_string();
4248 self
4249 }
4250 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
4251 ///
4252 /// Sets the *managed zone* path property to the given value.
4253 ///
4254 /// Even though the property as already been set when instantiating this call,
4255 /// we provide this method for API completeness.
4256 pub fn managed_zone(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4257 self._managed_zone = new_value.to_string();
4258 self
4259 }
4260 /// Sorting order direction: 'ascending' or 'descending'.
4261 ///
4262 /// Sets the *sort order* query property to the given value.
4263 pub fn sort_order(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4264 self._sort_order = Some(new_value.to_string());
4265 self
4266 }
4267 /// Sorting criterion. The only supported value is change sequence.
4268 ///
4269 /// Sets the *sort by* query property to the given value.
4270 pub fn sort_by(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4271 self._sort_by = Some(new_value.to_string());
4272 self
4273 }
4274 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
4275 ///
4276 /// Sets the *page token* query property to the given value.
4277 pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a, C> {
4278 self._page_token = Some(new_value.to_string());
4279 self
4280 }
4281 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
4282 ///
4283 /// Sets the *max results* query property to the given value.
4284 pub fn max_results(mut self, new_value: i32) -> ChangeListCall<'a, C> {
4285 self._max_results = Some(new_value);
4286 self
4287 }
4288 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4289 /// while executing the actual API request.
4290 ///
4291 /// ````text
4292 /// It should be used to handle progress information, and to implement a certain level of resilience.
4293 /// ````
4294 ///
4295 /// Sets the *delegate* property to the given value.
4296 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeListCall<'a, C> {
4297 self._delegate = Some(new_value);
4298 self
4299 }
4300
4301 /// Set any additional parameter of the query string used in the request.
4302 /// It should be used to set parameters which are not yet available through their own
4303 /// setters.
4304 ///
4305 /// Please note that this method must not be used to set any of the known parameters
4306 /// which have their own setter method. If done anyway, the request will fail.
4307 ///
4308 /// # Additional Parameters
4309 ///
4310 /// * *$.xgafv* (query-string) - V1 error format.
4311 /// * *access_token* (query-string) - OAuth access token.
4312 /// * *alt* (query-string) - Data format for response.
4313 /// * *callback* (query-string) - JSONP
4314 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4315 /// * *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.
4316 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4317 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4318 /// * *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.
4319 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4320 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4321 pub fn param<T>(mut self, name: T, value: T) -> ChangeListCall<'a, C>
4322 where
4323 T: AsRef<str>,
4324 {
4325 self._additional_params
4326 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4327 self
4328 }
4329
4330 /// Identifies the authorization scope for the method you are building.
4331 ///
4332 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4333 /// [`Scope::NdevClouddnReadonly`].
4334 ///
4335 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4336 /// tokens for more than one scope.
4337 ///
4338 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4339 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4340 /// sufficient, a read-write scope will do as well.
4341 pub fn add_scope<St>(mut self, scope: St) -> ChangeListCall<'a, C>
4342 where
4343 St: AsRef<str>,
4344 {
4345 self._scopes.insert(String::from(scope.as_ref()));
4346 self
4347 }
4348 /// Identifies the authorization scope(s) for the method you are building.
4349 ///
4350 /// See [`Self::add_scope()`] for details.
4351 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeListCall<'a, C>
4352 where
4353 I: IntoIterator<Item = St>,
4354 St: AsRef<str>,
4355 {
4356 self._scopes
4357 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4358 self
4359 }
4360
4361 /// Removes all scopes, and no default scope will be used either.
4362 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4363 /// for details).
4364 pub fn clear_scopes(mut self) -> ChangeListCall<'a, C> {
4365 self._scopes.clear();
4366 self
4367 }
4368}
4369
4370/// Fetches the representation of an existing DnsKey.
4371///
4372/// A builder for the *get* method supported by a *dnsKey* resource.
4373/// It is not used directly, but through a [`DnsKeyMethods`] instance.
4374///
4375/// # Example
4376///
4377/// Instantiate a resource method builder
4378///
4379/// ```test_harness,no_run
4380/// # extern crate hyper;
4381/// # extern crate hyper_rustls;
4382/// # extern crate google_dns1 as dns1;
4383/// # async fn dox() {
4384/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4385///
4386/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4387/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4388/// # .with_native_roots()
4389/// # .unwrap()
4390/// # .https_only()
4391/// # .enable_http2()
4392/// # .build();
4393///
4394/// # let executor = hyper_util::rt::TokioExecutor::new();
4395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4396/// # secret,
4397/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4398/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4399/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4400/// # ),
4401/// # ).build().await.unwrap();
4402///
4403/// # let client = hyper_util::client::legacy::Client::builder(
4404/// # hyper_util::rt::TokioExecutor::new()
4405/// # )
4406/// # .build(
4407/// # hyper_rustls::HttpsConnectorBuilder::new()
4408/// # .with_native_roots()
4409/// # .unwrap()
4410/// # .https_or_http()
4411/// # .enable_http2()
4412/// # .build()
4413/// # );
4414/// # let mut hub = Dns::new(client, auth);
4415/// // You can configure optional parameters by calling the respective setters at will, and
4416/// // execute the final call using `doit()`.
4417/// // Values shown here are possibly random and not representative !
4418/// let result = hub.dns_keys().get("project", "managedZone", "dnsKeyId")
4419/// .digest_type("est")
4420/// .client_operation_id("ipsum")
4421/// .doit().await;
4422/// # }
4423/// ```
4424pub struct DnsKeyGetCall<'a, C>
4425where
4426 C: 'a,
4427{
4428 hub: &'a Dns<C>,
4429 _project: String,
4430 _managed_zone: String,
4431 _dns_key_id: String,
4432 _digest_type: Option<String>,
4433 _client_operation_id: Option<String>,
4434 _delegate: Option<&'a mut dyn common::Delegate>,
4435 _additional_params: HashMap<String, String>,
4436 _scopes: BTreeSet<String>,
4437}
4438
4439impl<'a, C> common::CallBuilder for DnsKeyGetCall<'a, C> {}
4440
4441impl<'a, C> DnsKeyGetCall<'a, C>
4442where
4443 C: common::Connector,
4444{
4445 /// Perform the operation you have build so far.
4446 pub async fn doit(mut self) -> common::Result<(common::Response, DnsKey)> {
4447 use std::borrow::Cow;
4448 use std::io::{Read, Seek};
4449
4450 use common::{url::Params, ToParts};
4451 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4452
4453 let mut dd = common::DefaultDelegate;
4454 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4455 dlg.begin(common::MethodInfo {
4456 id: "dns.dnsKeys.get",
4457 http_method: hyper::Method::GET,
4458 });
4459
4460 for &field in [
4461 "alt",
4462 "project",
4463 "managedZone",
4464 "dnsKeyId",
4465 "digestType",
4466 "clientOperationId",
4467 ]
4468 .iter()
4469 {
4470 if self._additional_params.contains_key(field) {
4471 dlg.finished(false);
4472 return Err(common::Error::FieldClash(field));
4473 }
4474 }
4475
4476 let mut params = Params::with_capacity(7 + self._additional_params.len());
4477 params.push("project", self._project);
4478 params.push("managedZone", self._managed_zone);
4479 params.push("dnsKeyId", self._dns_key_id);
4480 if let Some(value) = self._digest_type.as_ref() {
4481 params.push("digestType", value);
4482 }
4483 if let Some(value) = self._client_operation_id.as_ref() {
4484 params.push("clientOperationId", value);
4485 }
4486
4487 params.extend(self._additional_params.iter());
4488
4489 params.push("alt", "json");
4490 let mut url = self.hub._base_url.clone()
4491 + "dns/v1/projects/{project}/managedZones/{managedZone}/dnsKeys/{dnsKeyId}";
4492 if self._scopes.is_empty() {
4493 self._scopes
4494 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
4495 }
4496
4497 #[allow(clippy::single_element_loop)]
4498 for &(find_this, param_name) in [
4499 ("{project}", "project"),
4500 ("{managedZone}", "managedZone"),
4501 ("{dnsKeyId}", "dnsKeyId"),
4502 ]
4503 .iter()
4504 {
4505 url = params.uri_replacement(url, param_name, find_this, false);
4506 }
4507 {
4508 let to_remove = ["dnsKeyId", "managedZone", "project"];
4509 params.remove_params(&to_remove);
4510 }
4511
4512 let url = params.parse_with_url(&url);
4513
4514 loop {
4515 let token = match self
4516 .hub
4517 .auth
4518 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4519 .await
4520 {
4521 Ok(token) => token,
4522 Err(e) => match dlg.token(e) {
4523 Ok(token) => token,
4524 Err(e) => {
4525 dlg.finished(false);
4526 return Err(common::Error::MissingToken(e));
4527 }
4528 },
4529 };
4530 let mut req_result = {
4531 let client = &self.hub.client;
4532 dlg.pre_request();
4533 let mut req_builder = hyper::Request::builder()
4534 .method(hyper::Method::GET)
4535 .uri(url.as_str())
4536 .header(USER_AGENT, self.hub._user_agent.clone());
4537
4538 if let Some(token) = token.as_ref() {
4539 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4540 }
4541
4542 let request = req_builder
4543 .header(CONTENT_LENGTH, 0_u64)
4544 .body(common::to_body::<String>(None));
4545
4546 client.request(request.unwrap()).await
4547 };
4548
4549 match req_result {
4550 Err(err) => {
4551 if let common::Retry::After(d) = dlg.http_error(&err) {
4552 sleep(d).await;
4553 continue;
4554 }
4555 dlg.finished(false);
4556 return Err(common::Error::HttpError(err));
4557 }
4558 Ok(res) => {
4559 let (mut parts, body) = res.into_parts();
4560 let mut body = common::Body::new(body);
4561 if !parts.status.is_success() {
4562 let bytes = common::to_bytes(body).await.unwrap_or_default();
4563 let error = serde_json::from_str(&common::to_string(&bytes));
4564 let response = common::to_response(parts, bytes.into());
4565
4566 if let common::Retry::After(d) =
4567 dlg.http_failure(&response, error.as_ref().ok())
4568 {
4569 sleep(d).await;
4570 continue;
4571 }
4572
4573 dlg.finished(false);
4574
4575 return Err(match error {
4576 Ok(value) => common::Error::BadRequest(value),
4577 _ => common::Error::Failure(response),
4578 });
4579 }
4580 let response = {
4581 let bytes = common::to_bytes(body).await.unwrap_or_default();
4582 let encoded = common::to_string(&bytes);
4583 match serde_json::from_str(&encoded) {
4584 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4585 Err(error) => {
4586 dlg.response_json_decode_error(&encoded, &error);
4587 return Err(common::Error::JsonDecodeError(
4588 encoded.to_string(),
4589 error,
4590 ));
4591 }
4592 }
4593 };
4594
4595 dlg.finished(true);
4596 return Ok(response);
4597 }
4598 }
4599 }
4600 }
4601
4602 /// Identifies the project addressed by this request.
4603 ///
4604 /// Sets the *project* path property to the given value.
4605 ///
4606 /// Even though the property as already been set when instantiating this call,
4607 /// we provide this method for API completeness.
4608 pub fn project(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4609 self._project = new_value.to_string();
4610 self
4611 }
4612 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
4613 ///
4614 /// Sets the *managed zone* path property to the given value.
4615 ///
4616 /// Even though the property as already been set when instantiating this call,
4617 /// we provide this method for API completeness.
4618 pub fn managed_zone(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4619 self._managed_zone = new_value.to_string();
4620 self
4621 }
4622 /// The identifier of the requested DnsKey.
4623 ///
4624 /// Sets the *dns key id* path property to the given value.
4625 ///
4626 /// Even though the property as already been set when instantiating this call,
4627 /// we provide this method for API completeness.
4628 pub fn dns_key_id(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4629 self._dns_key_id = new_value.to_string();
4630 self
4631 }
4632 /// 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.
4633 ///
4634 /// Sets the *digest type* query property to the given value.
4635 pub fn digest_type(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4636 self._digest_type = Some(new_value.to_string());
4637 self
4638 }
4639 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
4640 ///
4641 /// Sets the *client operation id* query property to the given value.
4642 pub fn client_operation_id(mut self, new_value: &str) -> DnsKeyGetCall<'a, C> {
4643 self._client_operation_id = Some(new_value.to_string());
4644 self
4645 }
4646 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4647 /// while executing the actual API request.
4648 ///
4649 /// ````text
4650 /// It should be used to handle progress information, and to implement a certain level of resilience.
4651 /// ````
4652 ///
4653 /// Sets the *delegate* property to the given value.
4654 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DnsKeyGetCall<'a, C> {
4655 self._delegate = Some(new_value);
4656 self
4657 }
4658
4659 /// Set any additional parameter of the query string used in the request.
4660 /// It should be used to set parameters which are not yet available through their own
4661 /// setters.
4662 ///
4663 /// Please note that this method must not be used to set any of the known parameters
4664 /// which have their own setter method. If done anyway, the request will fail.
4665 ///
4666 /// # Additional Parameters
4667 ///
4668 /// * *$.xgafv* (query-string) - V1 error format.
4669 /// * *access_token* (query-string) - OAuth access token.
4670 /// * *alt* (query-string) - Data format for response.
4671 /// * *callback* (query-string) - JSONP
4672 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4673 /// * *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.
4674 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4675 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4676 /// * *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.
4677 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4678 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4679 pub fn param<T>(mut self, name: T, value: T) -> DnsKeyGetCall<'a, C>
4680 where
4681 T: AsRef<str>,
4682 {
4683 self._additional_params
4684 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4685 self
4686 }
4687
4688 /// Identifies the authorization scope for the method you are building.
4689 ///
4690 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4691 /// [`Scope::NdevClouddnReadonly`].
4692 ///
4693 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4694 /// tokens for more than one scope.
4695 ///
4696 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4697 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4698 /// sufficient, a read-write scope will do as well.
4699 pub fn add_scope<St>(mut self, scope: St) -> DnsKeyGetCall<'a, C>
4700 where
4701 St: AsRef<str>,
4702 {
4703 self._scopes.insert(String::from(scope.as_ref()));
4704 self
4705 }
4706 /// Identifies the authorization scope(s) for the method you are building.
4707 ///
4708 /// See [`Self::add_scope()`] for details.
4709 pub fn add_scopes<I, St>(mut self, scopes: I) -> DnsKeyGetCall<'a, C>
4710 where
4711 I: IntoIterator<Item = St>,
4712 St: AsRef<str>,
4713 {
4714 self._scopes
4715 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4716 self
4717 }
4718
4719 /// Removes all scopes, and no default scope will be used either.
4720 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4721 /// for details).
4722 pub fn clear_scopes(mut self) -> DnsKeyGetCall<'a, C> {
4723 self._scopes.clear();
4724 self
4725 }
4726}
4727
4728/// Enumerates DnsKeys to a ResourceRecordSet collection.
4729///
4730/// A builder for the *list* method supported by a *dnsKey* resource.
4731/// It is not used directly, but through a [`DnsKeyMethods`] instance.
4732///
4733/// # Example
4734///
4735/// Instantiate a resource method builder
4736///
4737/// ```test_harness,no_run
4738/// # extern crate hyper;
4739/// # extern crate hyper_rustls;
4740/// # extern crate google_dns1 as dns1;
4741/// # async fn dox() {
4742/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4743///
4744/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4745/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4746/// # .with_native_roots()
4747/// # .unwrap()
4748/// # .https_only()
4749/// # .enable_http2()
4750/// # .build();
4751///
4752/// # let executor = hyper_util::rt::TokioExecutor::new();
4753/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4754/// # secret,
4755/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4756/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4757/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4758/// # ),
4759/// # ).build().await.unwrap();
4760///
4761/// # let client = hyper_util::client::legacy::Client::builder(
4762/// # hyper_util::rt::TokioExecutor::new()
4763/// # )
4764/// # .build(
4765/// # hyper_rustls::HttpsConnectorBuilder::new()
4766/// # .with_native_roots()
4767/// # .unwrap()
4768/// # .https_or_http()
4769/// # .enable_http2()
4770/// # .build()
4771/// # );
4772/// # let mut hub = Dns::new(client, auth);
4773/// // You can configure optional parameters by calling the respective setters at will, and
4774/// // execute the final call using `doit()`.
4775/// // Values shown here are possibly random and not representative !
4776/// let result = hub.dns_keys().list("project", "managedZone")
4777/// .page_token("gubergren")
4778/// .max_results(-17)
4779/// .digest_type("dolor")
4780/// .doit().await;
4781/// # }
4782/// ```
4783pub struct DnsKeyListCall<'a, C>
4784where
4785 C: 'a,
4786{
4787 hub: &'a Dns<C>,
4788 _project: String,
4789 _managed_zone: String,
4790 _page_token: Option<String>,
4791 _max_results: Option<i32>,
4792 _digest_type: Option<String>,
4793 _delegate: Option<&'a mut dyn common::Delegate>,
4794 _additional_params: HashMap<String, String>,
4795 _scopes: BTreeSet<String>,
4796}
4797
4798impl<'a, C> common::CallBuilder for DnsKeyListCall<'a, C> {}
4799
4800impl<'a, C> DnsKeyListCall<'a, C>
4801where
4802 C: common::Connector,
4803{
4804 /// Perform the operation you have build so far.
4805 pub async fn doit(mut self) -> common::Result<(common::Response, DnsKeysListResponse)> {
4806 use std::borrow::Cow;
4807 use std::io::{Read, Seek};
4808
4809 use common::{url::Params, ToParts};
4810 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4811
4812 let mut dd = common::DefaultDelegate;
4813 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4814 dlg.begin(common::MethodInfo {
4815 id: "dns.dnsKeys.list",
4816 http_method: hyper::Method::GET,
4817 });
4818
4819 for &field in [
4820 "alt",
4821 "project",
4822 "managedZone",
4823 "pageToken",
4824 "maxResults",
4825 "digestType",
4826 ]
4827 .iter()
4828 {
4829 if self._additional_params.contains_key(field) {
4830 dlg.finished(false);
4831 return Err(common::Error::FieldClash(field));
4832 }
4833 }
4834
4835 let mut params = Params::with_capacity(7 + self._additional_params.len());
4836 params.push("project", self._project);
4837 params.push("managedZone", self._managed_zone);
4838 if let Some(value) = self._page_token.as_ref() {
4839 params.push("pageToken", value);
4840 }
4841 if let Some(value) = self._max_results.as_ref() {
4842 params.push("maxResults", value.to_string());
4843 }
4844 if let Some(value) = self._digest_type.as_ref() {
4845 params.push("digestType", value);
4846 }
4847
4848 params.extend(self._additional_params.iter());
4849
4850 params.push("alt", "json");
4851 let mut url = self.hub._base_url.clone()
4852 + "dns/v1/projects/{project}/managedZones/{managedZone}/dnsKeys";
4853 if self._scopes.is_empty() {
4854 self._scopes
4855 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
4856 }
4857
4858 #[allow(clippy::single_element_loop)]
4859 for &(find_this, param_name) in
4860 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
4861 {
4862 url = params.uri_replacement(url, param_name, find_this, false);
4863 }
4864 {
4865 let to_remove = ["managedZone", "project"];
4866 params.remove_params(&to_remove);
4867 }
4868
4869 let url = params.parse_with_url(&url);
4870
4871 loop {
4872 let token = match self
4873 .hub
4874 .auth
4875 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4876 .await
4877 {
4878 Ok(token) => token,
4879 Err(e) => match dlg.token(e) {
4880 Ok(token) => token,
4881 Err(e) => {
4882 dlg.finished(false);
4883 return Err(common::Error::MissingToken(e));
4884 }
4885 },
4886 };
4887 let mut req_result = {
4888 let client = &self.hub.client;
4889 dlg.pre_request();
4890 let mut req_builder = hyper::Request::builder()
4891 .method(hyper::Method::GET)
4892 .uri(url.as_str())
4893 .header(USER_AGENT, self.hub._user_agent.clone());
4894
4895 if let Some(token) = token.as_ref() {
4896 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4897 }
4898
4899 let request = req_builder
4900 .header(CONTENT_LENGTH, 0_u64)
4901 .body(common::to_body::<String>(None));
4902
4903 client.request(request.unwrap()).await
4904 };
4905
4906 match req_result {
4907 Err(err) => {
4908 if let common::Retry::After(d) = dlg.http_error(&err) {
4909 sleep(d).await;
4910 continue;
4911 }
4912 dlg.finished(false);
4913 return Err(common::Error::HttpError(err));
4914 }
4915 Ok(res) => {
4916 let (mut parts, body) = res.into_parts();
4917 let mut body = common::Body::new(body);
4918 if !parts.status.is_success() {
4919 let bytes = common::to_bytes(body).await.unwrap_or_default();
4920 let error = serde_json::from_str(&common::to_string(&bytes));
4921 let response = common::to_response(parts, bytes.into());
4922
4923 if let common::Retry::After(d) =
4924 dlg.http_failure(&response, error.as_ref().ok())
4925 {
4926 sleep(d).await;
4927 continue;
4928 }
4929
4930 dlg.finished(false);
4931
4932 return Err(match error {
4933 Ok(value) => common::Error::BadRequest(value),
4934 _ => common::Error::Failure(response),
4935 });
4936 }
4937 let response = {
4938 let bytes = common::to_bytes(body).await.unwrap_or_default();
4939 let encoded = common::to_string(&bytes);
4940 match serde_json::from_str(&encoded) {
4941 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4942 Err(error) => {
4943 dlg.response_json_decode_error(&encoded, &error);
4944 return Err(common::Error::JsonDecodeError(
4945 encoded.to_string(),
4946 error,
4947 ));
4948 }
4949 }
4950 };
4951
4952 dlg.finished(true);
4953 return Ok(response);
4954 }
4955 }
4956 }
4957 }
4958
4959 /// Identifies the project addressed by this request.
4960 ///
4961 /// Sets the *project* path property to the given value.
4962 ///
4963 /// Even though the property as already been set when instantiating this call,
4964 /// we provide this method for API completeness.
4965 pub fn project(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
4966 self._project = new_value.to_string();
4967 self
4968 }
4969 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
4970 ///
4971 /// Sets the *managed zone* path property to the given value.
4972 ///
4973 /// Even though the property as already been set when instantiating this call,
4974 /// we provide this method for API completeness.
4975 pub fn managed_zone(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
4976 self._managed_zone = new_value.to_string();
4977 self
4978 }
4979 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
4980 ///
4981 /// Sets the *page token* query property to the given value.
4982 pub fn page_token(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
4983 self._page_token = Some(new_value.to_string());
4984 self
4985 }
4986 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
4987 ///
4988 /// Sets the *max results* query property to the given value.
4989 pub fn max_results(mut self, new_value: i32) -> DnsKeyListCall<'a, C> {
4990 self._max_results = Some(new_value);
4991 self
4992 }
4993 /// 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.
4994 ///
4995 /// Sets the *digest type* query property to the given value.
4996 pub fn digest_type(mut self, new_value: &str) -> DnsKeyListCall<'a, C> {
4997 self._digest_type = Some(new_value.to_string());
4998 self
4999 }
5000 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5001 /// while executing the actual API request.
5002 ///
5003 /// ````text
5004 /// It should be used to handle progress information, and to implement a certain level of resilience.
5005 /// ````
5006 ///
5007 /// Sets the *delegate* property to the given value.
5008 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DnsKeyListCall<'a, C> {
5009 self._delegate = Some(new_value);
5010 self
5011 }
5012
5013 /// Set any additional parameter of the query string used in the request.
5014 /// It should be used to set parameters which are not yet available through their own
5015 /// setters.
5016 ///
5017 /// Please note that this method must not be used to set any of the known parameters
5018 /// which have their own setter method. If done anyway, the request will fail.
5019 ///
5020 /// # Additional Parameters
5021 ///
5022 /// * *$.xgafv* (query-string) - V1 error format.
5023 /// * *access_token* (query-string) - OAuth access token.
5024 /// * *alt* (query-string) - Data format for response.
5025 /// * *callback* (query-string) - JSONP
5026 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5027 /// * *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.
5028 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5029 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5030 /// * *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.
5031 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5032 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5033 pub fn param<T>(mut self, name: T, value: T) -> DnsKeyListCall<'a, C>
5034 where
5035 T: AsRef<str>,
5036 {
5037 self._additional_params
5038 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5039 self
5040 }
5041
5042 /// Identifies the authorization scope for the method you are building.
5043 ///
5044 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5045 /// [`Scope::NdevClouddnReadonly`].
5046 ///
5047 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5048 /// tokens for more than one scope.
5049 ///
5050 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5051 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5052 /// sufficient, a read-write scope will do as well.
5053 pub fn add_scope<St>(mut self, scope: St) -> DnsKeyListCall<'a, C>
5054 where
5055 St: AsRef<str>,
5056 {
5057 self._scopes.insert(String::from(scope.as_ref()));
5058 self
5059 }
5060 /// Identifies the authorization scope(s) for the method you are building.
5061 ///
5062 /// See [`Self::add_scope()`] for details.
5063 pub fn add_scopes<I, St>(mut self, scopes: I) -> DnsKeyListCall<'a, C>
5064 where
5065 I: IntoIterator<Item = St>,
5066 St: AsRef<str>,
5067 {
5068 self._scopes
5069 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5070 self
5071 }
5072
5073 /// Removes all scopes, and no default scope will be used either.
5074 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5075 /// for details).
5076 pub fn clear_scopes(mut self) -> DnsKeyListCall<'a, C> {
5077 self._scopes.clear();
5078 self
5079 }
5080}
5081
5082/// Fetches the representation of an existing Operation.
5083///
5084/// A builder for the *get* method supported by a *managedZoneOperation* resource.
5085/// It is not used directly, but through a [`ManagedZoneOperationMethods`] instance.
5086///
5087/// # Example
5088///
5089/// Instantiate a resource method builder
5090///
5091/// ```test_harness,no_run
5092/// # extern crate hyper;
5093/// # extern crate hyper_rustls;
5094/// # extern crate google_dns1 as dns1;
5095/// # async fn dox() {
5096/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5097///
5098/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5099/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5100/// # .with_native_roots()
5101/// # .unwrap()
5102/// # .https_only()
5103/// # .enable_http2()
5104/// # .build();
5105///
5106/// # let executor = hyper_util::rt::TokioExecutor::new();
5107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5108/// # secret,
5109/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5110/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5111/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5112/// # ),
5113/// # ).build().await.unwrap();
5114///
5115/// # let client = hyper_util::client::legacy::Client::builder(
5116/// # hyper_util::rt::TokioExecutor::new()
5117/// # )
5118/// # .build(
5119/// # hyper_rustls::HttpsConnectorBuilder::new()
5120/// # .with_native_roots()
5121/// # .unwrap()
5122/// # .https_or_http()
5123/// # .enable_http2()
5124/// # .build()
5125/// # );
5126/// # let mut hub = Dns::new(client, auth);
5127/// // You can configure optional parameters by calling the respective setters at will, and
5128/// // execute the final call using `doit()`.
5129/// // Values shown here are possibly random and not representative !
5130/// let result = hub.managed_zone_operations().get("project", "managedZone", "operation")
5131/// .client_operation_id("sed")
5132/// .doit().await;
5133/// # }
5134/// ```
5135pub struct ManagedZoneOperationGetCall<'a, C>
5136where
5137 C: 'a,
5138{
5139 hub: &'a Dns<C>,
5140 _project: String,
5141 _managed_zone: String,
5142 _operation: String,
5143 _client_operation_id: Option<String>,
5144 _delegate: Option<&'a mut dyn common::Delegate>,
5145 _additional_params: HashMap<String, String>,
5146 _scopes: BTreeSet<String>,
5147}
5148
5149impl<'a, C> common::CallBuilder for ManagedZoneOperationGetCall<'a, C> {}
5150
5151impl<'a, C> ManagedZoneOperationGetCall<'a, C>
5152where
5153 C: common::Connector,
5154{
5155 /// Perform the operation you have build so far.
5156 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5157 use std::borrow::Cow;
5158 use std::io::{Read, Seek};
5159
5160 use common::{url::Params, ToParts};
5161 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5162
5163 let mut dd = common::DefaultDelegate;
5164 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5165 dlg.begin(common::MethodInfo {
5166 id: "dns.managedZoneOperations.get",
5167 http_method: hyper::Method::GET,
5168 });
5169
5170 for &field in [
5171 "alt",
5172 "project",
5173 "managedZone",
5174 "operation",
5175 "clientOperationId",
5176 ]
5177 .iter()
5178 {
5179 if self._additional_params.contains_key(field) {
5180 dlg.finished(false);
5181 return Err(common::Error::FieldClash(field));
5182 }
5183 }
5184
5185 let mut params = Params::with_capacity(6 + self._additional_params.len());
5186 params.push("project", self._project);
5187 params.push("managedZone", self._managed_zone);
5188 params.push("operation", self._operation);
5189 if let Some(value) = self._client_operation_id.as_ref() {
5190 params.push("clientOperationId", value);
5191 }
5192
5193 params.extend(self._additional_params.iter());
5194
5195 params.push("alt", "json");
5196 let mut url = self.hub._base_url.clone()
5197 + "dns/v1/projects/{project}/managedZones/{managedZone}/operations/{operation}";
5198 if self._scopes.is_empty() {
5199 self._scopes
5200 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
5201 }
5202
5203 #[allow(clippy::single_element_loop)]
5204 for &(find_this, param_name) in [
5205 ("{project}", "project"),
5206 ("{managedZone}", "managedZone"),
5207 ("{operation}", "operation"),
5208 ]
5209 .iter()
5210 {
5211 url = params.uri_replacement(url, param_name, find_this, false);
5212 }
5213 {
5214 let to_remove = ["operation", "managedZone", "project"];
5215 params.remove_params(&to_remove);
5216 }
5217
5218 let url = params.parse_with_url(&url);
5219
5220 loop {
5221 let token = match self
5222 .hub
5223 .auth
5224 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5225 .await
5226 {
5227 Ok(token) => token,
5228 Err(e) => match dlg.token(e) {
5229 Ok(token) => token,
5230 Err(e) => {
5231 dlg.finished(false);
5232 return Err(common::Error::MissingToken(e));
5233 }
5234 },
5235 };
5236 let mut req_result = {
5237 let client = &self.hub.client;
5238 dlg.pre_request();
5239 let mut req_builder = hyper::Request::builder()
5240 .method(hyper::Method::GET)
5241 .uri(url.as_str())
5242 .header(USER_AGENT, self.hub._user_agent.clone());
5243
5244 if let Some(token) = token.as_ref() {
5245 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5246 }
5247
5248 let request = req_builder
5249 .header(CONTENT_LENGTH, 0_u64)
5250 .body(common::to_body::<String>(None));
5251
5252 client.request(request.unwrap()).await
5253 };
5254
5255 match req_result {
5256 Err(err) => {
5257 if let common::Retry::After(d) = dlg.http_error(&err) {
5258 sleep(d).await;
5259 continue;
5260 }
5261 dlg.finished(false);
5262 return Err(common::Error::HttpError(err));
5263 }
5264 Ok(res) => {
5265 let (mut parts, body) = res.into_parts();
5266 let mut body = common::Body::new(body);
5267 if !parts.status.is_success() {
5268 let bytes = common::to_bytes(body).await.unwrap_or_default();
5269 let error = serde_json::from_str(&common::to_string(&bytes));
5270 let response = common::to_response(parts, bytes.into());
5271
5272 if let common::Retry::After(d) =
5273 dlg.http_failure(&response, error.as_ref().ok())
5274 {
5275 sleep(d).await;
5276 continue;
5277 }
5278
5279 dlg.finished(false);
5280
5281 return Err(match error {
5282 Ok(value) => common::Error::BadRequest(value),
5283 _ => common::Error::Failure(response),
5284 });
5285 }
5286 let response = {
5287 let bytes = common::to_bytes(body).await.unwrap_or_default();
5288 let encoded = common::to_string(&bytes);
5289 match serde_json::from_str(&encoded) {
5290 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5291 Err(error) => {
5292 dlg.response_json_decode_error(&encoded, &error);
5293 return Err(common::Error::JsonDecodeError(
5294 encoded.to_string(),
5295 error,
5296 ));
5297 }
5298 }
5299 };
5300
5301 dlg.finished(true);
5302 return Ok(response);
5303 }
5304 }
5305 }
5306 }
5307
5308 /// Identifies the project addressed by this request.
5309 ///
5310 /// Sets the *project* path property to the given value.
5311 ///
5312 /// Even though the property as already been set when instantiating this call,
5313 /// we provide this method for API completeness.
5314 pub fn project(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5315 self._project = new_value.to_string();
5316 self
5317 }
5318 /// Identifies the managed zone addressed by this request.
5319 ///
5320 /// Sets the *managed zone* path property to the given value.
5321 ///
5322 /// Even though the property as already been set when instantiating this call,
5323 /// we provide this method for API completeness.
5324 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5325 self._managed_zone = new_value.to_string();
5326 self
5327 }
5328 /// Identifies the operation addressed by this request (ID of the operation).
5329 ///
5330 /// Sets the *operation* path property to the given value.
5331 ///
5332 /// Even though the property as already been set when instantiating this call,
5333 /// we provide this method for API completeness.
5334 pub fn operation(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5335 self._operation = new_value.to_string();
5336 self
5337 }
5338 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
5339 ///
5340 /// Sets the *client operation id* query property to the given value.
5341 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a, C> {
5342 self._client_operation_id = Some(new_value.to_string());
5343 self
5344 }
5345 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5346 /// while executing the actual API request.
5347 ///
5348 /// ````text
5349 /// It should be used to handle progress information, and to implement a certain level of resilience.
5350 /// ````
5351 ///
5352 /// Sets the *delegate* property to the given value.
5353 pub fn delegate(
5354 mut self,
5355 new_value: &'a mut dyn common::Delegate,
5356 ) -> ManagedZoneOperationGetCall<'a, C> {
5357 self._delegate = Some(new_value);
5358 self
5359 }
5360
5361 /// Set any additional parameter of the query string used in the request.
5362 /// It should be used to set parameters which are not yet available through their own
5363 /// setters.
5364 ///
5365 /// Please note that this method must not be used to set any of the known parameters
5366 /// which have their own setter method. If done anyway, the request will fail.
5367 ///
5368 /// # Additional Parameters
5369 ///
5370 /// * *$.xgafv* (query-string) - V1 error format.
5371 /// * *access_token* (query-string) - OAuth access token.
5372 /// * *alt* (query-string) - Data format for response.
5373 /// * *callback* (query-string) - JSONP
5374 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5375 /// * *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.
5376 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5377 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5378 /// * *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.
5379 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5380 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5381 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneOperationGetCall<'a, C>
5382 where
5383 T: AsRef<str>,
5384 {
5385 self._additional_params
5386 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5387 self
5388 }
5389
5390 /// Identifies the authorization scope for the method you are building.
5391 ///
5392 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5393 /// [`Scope::NdevClouddnReadonly`].
5394 ///
5395 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5396 /// tokens for more than one scope.
5397 ///
5398 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5399 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5400 /// sufficient, a read-write scope will do as well.
5401 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneOperationGetCall<'a, C>
5402 where
5403 St: AsRef<str>,
5404 {
5405 self._scopes.insert(String::from(scope.as_ref()));
5406 self
5407 }
5408 /// Identifies the authorization scope(s) for the method you are building.
5409 ///
5410 /// See [`Self::add_scope()`] for details.
5411 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneOperationGetCall<'a, C>
5412 where
5413 I: IntoIterator<Item = St>,
5414 St: AsRef<str>,
5415 {
5416 self._scopes
5417 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5418 self
5419 }
5420
5421 /// Removes all scopes, and no default scope will be used either.
5422 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5423 /// for details).
5424 pub fn clear_scopes(mut self) -> ManagedZoneOperationGetCall<'a, C> {
5425 self._scopes.clear();
5426 self
5427 }
5428}
5429
5430/// Enumerates Operations for the given ManagedZone.
5431///
5432/// A builder for the *list* method supported by a *managedZoneOperation* resource.
5433/// It is not used directly, but through a [`ManagedZoneOperationMethods`] instance.
5434///
5435/// # Example
5436///
5437/// Instantiate a resource method builder
5438///
5439/// ```test_harness,no_run
5440/// # extern crate hyper;
5441/// # extern crate hyper_rustls;
5442/// # extern crate google_dns1 as dns1;
5443/// # async fn dox() {
5444/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5445///
5446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5447/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5448/// # .with_native_roots()
5449/// # .unwrap()
5450/// # .https_only()
5451/// # .enable_http2()
5452/// # .build();
5453///
5454/// # let executor = hyper_util::rt::TokioExecutor::new();
5455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5456/// # secret,
5457/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5458/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5459/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5460/// # ),
5461/// # ).build().await.unwrap();
5462///
5463/// # let client = hyper_util::client::legacy::Client::builder(
5464/// # hyper_util::rt::TokioExecutor::new()
5465/// # )
5466/// # .build(
5467/// # hyper_rustls::HttpsConnectorBuilder::new()
5468/// # .with_native_roots()
5469/// # .unwrap()
5470/// # .https_or_http()
5471/// # .enable_http2()
5472/// # .build()
5473/// # );
5474/// # let mut hub = Dns::new(client, auth);
5475/// // You can configure optional parameters by calling the respective setters at will, and
5476/// // execute the final call using `doit()`.
5477/// // Values shown here are possibly random and not representative !
5478/// let result = hub.managed_zone_operations().list("project", "managedZone")
5479/// .sort_by("no")
5480/// .page_token("Stet")
5481/// .max_results(-13)
5482/// .doit().await;
5483/// # }
5484/// ```
5485pub struct ManagedZoneOperationListCall<'a, C>
5486where
5487 C: 'a,
5488{
5489 hub: &'a Dns<C>,
5490 _project: String,
5491 _managed_zone: String,
5492 _sort_by: Option<String>,
5493 _page_token: Option<String>,
5494 _max_results: Option<i32>,
5495 _delegate: Option<&'a mut dyn common::Delegate>,
5496 _additional_params: HashMap<String, String>,
5497 _scopes: BTreeSet<String>,
5498}
5499
5500impl<'a, C> common::CallBuilder for ManagedZoneOperationListCall<'a, C> {}
5501
5502impl<'a, C> ManagedZoneOperationListCall<'a, C>
5503where
5504 C: common::Connector,
5505{
5506 /// Perform the operation you have build so far.
5507 pub async fn doit(
5508 mut self,
5509 ) -> common::Result<(common::Response, ManagedZoneOperationsListResponse)> {
5510 use std::borrow::Cow;
5511 use std::io::{Read, Seek};
5512
5513 use common::{url::Params, ToParts};
5514 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5515
5516 let mut dd = common::DefaultDelegate;
5517 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5518 dlg.begin(common::MethodInfo {
5519 id: "dns.managedZoneOperations.list",
5520 http_method: hyper::Method::GET,
5521 });
5522
5523 for &field in [
5524 "alt",
5525 "project",
5526 "managedZone",
5527 "sortBy",
5528 "pageToken",
5529 "maxResults",
5530 ]
5531 .iter()
5532 {
5533 if self._additional_params.contains_key(field) {
5534 dlg.finished(false);
5535 return Err(common::Error::FieldClash(field));
5536 }
5537 }
5538
5539 let mut params = Params::with_capacity(7 + self._additional_params.len());
5540 params.push("project", self._project);
5541 params.push("managedZone", self._managed_zone);
5542 if let Some(value) = self._sort_by.as_ref() {
5543 params.push("sortBy", value);
5544 }
5545 if let Some(value) = self._page_token.as_ref() {
5546 params.push("pageToken", value);
5547 }
5548 if let Some(value) = self._max_results.as_ref() {
5549 params.push("maxResults", value.to_string());
5550 }
5551
5552 params.extend(self._additional_params.iter());
5553
5554 params.push("alt", "json");
5555 let mut url = self.hub._base_url.clone()
5556 + "dns/v1/projects/{project}/managedZones/{managedZone}/operations";
5557 if self._scopes.is_empty() {
5558 self._scopes
5559 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
5560 }
5561
5562 #[allow(clippy::single_element_loop)]
5563 for &(find_this, param_name) in
5564 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
5565 {
5566 url = params.uri_replacement(url, param_name, find_this, false);
5567 }
5568 {
5569 let to_remove = ["managedZone", "project"];
5570 params.remove_params(&to_remove);
5571 }
5572
5573 let url = params.parse_with_url(&url);
5574
5575 loop {
5576 let token = match self
5577 .hub
5578 .auth
5579 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5580 .await
5581 {
5582 Ok(token) => token,
5583 Err(e) => match dlg.token(e) {
5584 Ok(token) => token,
5585 Err(e) => {
5586 dlg.finished(false);
5587 return Err(common::Error::MissingToken(e));
5588 }
5589 },
5590 };
5591 let mut req_result = {
5592 let client = &self.hub.client;
5593 dlg.pre_request();
5594 let mut req_builder = hyper::Request::builder()
5595 .method(hyper::Method::GET)
5596 .uri(url.as_str())
5597 .header(USER_AGENT, self.hub._user_agent.clone());
5598
5599 if let Some(token) = token.as_ref() {
5600 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5601 }
5602
5603 let request = req_builder
5604 .header(CONTENT_LENGTH, 0_u64)
5605 .body(common::to_body::<String>(None));
5606
5607 client.request(request.unwrap()).await
5608 };
5609
5610 match req_result {
5611 Err(err) => {
5612 if let common::Retry::After(d) = dlg.http_error(&err) {
5613 sleep(d).await;
5614 continue;
5615 }
5616 dlg.finished(false);
5617 return Err(common::Error::HttpError(err));
5618 }
5619 Ok(res) => {
5620 let (mut parts, body) = res.into_parts();
5621 let mut body = common::Body::new(body);
5622 if !parts.status.is_success() {
5623 let bytes = common::to_bytes(body).await.unwrap_or_default();
5624 let error = serde_json::from_str(&common::to_string(&bytes));
5625 let response = common::to_response(parts, bytes.into());
5626
5627 if let common::Retry::After(d) =
5628 dlg.http_failure(&response, error.as_ref().ok())
5629 {
5630 sleep(d).await;
5631 continue;
5632 }
5633
5634 dlg.finished(false);
5635
5636 return Err(match error {
5637 Ok(value) => common::Error::BadRequest(value),
5638 _ => common::Error::Failure(response),
5639 });
5640 }
5641 let response = {
5642 let bytes = common::to_bytes(body).await.unwrap_or_default();
5643 let encoded = common::to_string(&bytes);
5644 match serde_json::from_str(&encoded) {
5645 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5646 Err(error) => {
5647 dlg.response_json_decode_error(&encoded, &error);
5648 return Err(common::Error::JsonDecodeError(
5649 encoded.to_string(),
5650 error,
5651 ));
5652 }
5653 }
5654 };
5655
5656 dlg.finished(true);
5657 return Ok(response);
5658 }
5659 }
5660 }
5661 }
5662
5663 /// Identifies the project addressed by this request.
5664 ///
5665 /// Sets the *project* path property to the given value.
5666 ///
5667 /// Even though the property as already been set when instantiating this call,
5668 /// we provide this method for API completeness.
5669 pub fn project(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5670 self._project = new_value.to_string();
5671 self
5672 }
5673 /// Identifies the managed zone addressed by this request.
5674 ///
5675 /// Sets the *managed zone* path property to the given value.
5676 ///
5677 /// Even though the property as already been set when instantiating this call,
5678 /// we provide this method for API completeness.
5679 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5680 self._managed_zone = new_value.to_string();
5681 self
5682 }
5683 /// Sorting criterion. The only supported values are START_TIME and ID.
5684 ///
5685 /// Sets the *sort by* query property to the given value.
5686 pub fn sort_by(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5687 self._sort_by = Some(new_value.to_string());
5688 self
5689 }
5690 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
5691 ///
5692 /// Sets the *page token* query property to the given value.
5693 pub fn page_token(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a, C> {
5694 self._page_token = Some(new_value.to_string());
5695 self
5696 }
5697 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
5698 ///
5699 /// Sets the *max results* query property to the given value.
5700 pub fn max_results(mut self, new_value: i32) -> ManagedZoneOperationListCall<'a, C> {
5701 self._max_results = Some(new_value);
5702 self
5703 }
5704 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5705 /// while executing the actual API request.
5706 ///
5707 /// ````text
5708 /// It should be used to handle progress information, and to implement a certain level of resilience.
5709 /// ````
5710 ///
5711 /// Sets the *delegate* property to the given value.
5712 pub fn delegate(
5713 mut self,
5714 new_value: &'a mut dyn common::Delegate,
5715 ) -> ManagedZoneOperationListCall<'a, C> {
5716 self._delegate = Some(new_value);
5717 self
5718 }
5719
5720 /// Set any additional parameter of the query string used in the request.
5721 /// It should be used to set parameters which are not yet available through their own
5722 /// setters.
5723 ///
5724 /// Please note that this method must not be used to set any of the known parameters
5725 /// which have their own setter method. If done anyway, the request will fail.
5726 ///
5727 /// # Additional Parameters
5728 ///
5729 /// * *$.xgafv* (query-string) - V1 error format.
5730 /// * *access_token* (query-string) - OAuth access token.
5731 /// * *alt* (query-string) - Data format for response.
5732 /// * *callback* (query-string) - JSONP
5733 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5734 /// * *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.
5735 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5736 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5737 /// * *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.
5738 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5739 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5740 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneOperationListCall<'a, C>
5741 where
5742 T: AsRef<str>,
5743 {
5744 self._additional_params
5745 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5746 self
5747 }
5748
5749 /// Identifies the authorization scope for the method you are building.
5750 ///
5751 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5752 /// [`Scope::NdevClouddnReadonly`].
5753 ///
5754 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5755 /// tokens for more than one scope.
5756 ///
5757 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5758 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5759 /// sufficient, a read-write scope will do as well.
5760 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneOperationListCall<'a, C>
5761 where
5762 St: AsRef<str>,
5763 {
5764 self._scopes.insert(String::from(scope.as_ref()));
5765 self
5766 }
5767 /// Identifies the authorization scope(s) for the method you are building.
5768 ///
5769 /// See [`Self::add_scope()`] for details.
5770 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneOperationListCall<'a, C>
5771 where
5772 I: IntoIterator<Item = St>,
5773 St: AsRef<str>,
5774 {
5775 self._scopes
5776 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5777 self
5778 }
5779
5780 /// Removes all scopes, and no default scope will be used either.
5781 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5782 /// for details).
5783 pub fn clear_scopes(mut self) -> ManagedZoneOperationListCall<'a, C> {
5784 self._scopes.clear();
5785 self
5786 }
5787}
5788
5789/// Creates a new ManagedZone.
5790///
5791/// A builder for the *create* method supported by a *managedZone* resource.
5792/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
5793///
5794/// # Example
5795///
5796/// Instantiate a resource method builder
5797///
5798/// ```test_harness,no_run
5799/// # extern crate hyper;
5800/// # extern crate hyper_rustls;
5801/// # extern crate google_dns1 as dns1;
5802/// use dns1::api::ManagedZone;
5803/// # async fn dox() {
5804/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5805///
5806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5807/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5808/// # .with_native_roots()
5809/// # .unwrap()
5810/// # .https_only()
5811/// # .enable_http2()
5812/// # .build();
5813///
5814/// # let executor = hyper_util::rt::TokioExecutor::new();
5815/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5816/// # secret,
5817/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5818/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5819/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5820/// # ),
5821/// # ).build().await.unwrap();
5822///
5823/// # let client = hyper_util::client::legacy::Client::builder(
5824/// # hyper_util::rt::TokioExecutor::new()
5825/// # )
5826/// # .build(
5827/// # hyper_rustls::HttpsConnectorBuilder::new()
5828/// # .with_native_roots()
5829/// # .unwrap()
5830/// # .https_or_http()
5831/// # .enable_http2()
5832/// # .build()
5833/// # );
5834/// # let mut hub = Dns::new(client, auth);
5835/// // As the method needs a request, you would usually fill it with the desired information
5836/// // into the respective structure. Some of the parts shown here might not be applicable !
5837/// // Values shown here are possibly random and not representative !
5838/// let mut req = ManagedZone::default();
5839///
5840/// // You can configure optional parameters by calling the respective setters at will, and
5841/// // execute the final call using `doit()`.
5842/// // Values shown here are possibly random and not representative !
5843/// let result = hub.managed_zones().create(req, "project")
5844/// .client_operation_id("sed")
5845/// .doit().await;
5846/// # }
5847/// ```
5848pub struct ManagedZoneCreateCall<'a, C>
5849where
5850 C: 'a,
5851{
5852 hub: &'a Dns<C>,
5853 _request: ManagedZone,
5854 _project: String,
5855 _client_operation_id: Option<String>,
5856 _delegate: Option<&'a mut dyn common::Delegate>,
5857 _additional_params: HashMap<String, String>,
5858 _scopes: BTreeSet<String>,
5859}
5860
5861impl<'a, C> common::CallBuilder for ManagedZoneCreateCall<'a, C> {}
5862
5863impl<'a, C> ManagedZoneCreateCall<'a, C>
5864where
5865 C: common::Connector,
5866{
5867 /// Perform the operation you have build so far.
5868 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedZone)> {
5869 use std::borrow::Cow;
5870 use std::io::{Read, Seek};
5871
5872 use common::{url::Params, ToParts};
5873 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5874
5875 let mut dd = common::DefaultDelegate;
5876 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5877 dlg.begin(common::MethodInfo {
5878 id: "dns.managedZones.create",
5879 http_method: hyper::Method::POST,
5880 });
5881
5882 for &field in ["alt", "project", "clientOperationId"].iter() {
5883 if self._additional_params.contains_key(field) {
5884 dlg.finished(false);
5885 return Err(common::Error::FieldClash(field));
5886 }
5887 }
5888
5889 let mut params = Params::with_capacity(5 + self._additional_params.len());
5890 params.push("project", self._project);
5891 if let Some(value) = self._client_operation_id.as_ref() {
5892 params.push("clientOperationId", value);
5893 }
5894
5895 params.extend(self._additional_params.iter());
5896
5897 params.push("alt", "json");
5898 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones";
5899 if self._scopes.is_empty() {
5900 self._scopes
5901 .insert(Scope::CloudPlatform.as_ref().to_string());
5902 }
5903
5904 #[allow(clippy::single_element_loop)]
5905 for &(find_this, param_name) in [("{project}", "project")].iter() {
5906 url = params.uri_replacement(url, param_name, find_this, false);
5907 }
5908 {
5909 let to_remove = ["project"];
5910 params.remove_params(&to_remove);
5911 }
5912
5913 let url = params.parse_with_url(&url);
5914
5915 let mut json_mime_type = mime::APPLICATION_JSON;
5916 let mut request_value_reader = {
5917 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5918 common::remove_json_null_values(&mut value);
5919 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5920 serde_json::to_writer(&mut dst, &value).unwrap();
5921 dst
5922 };
5923 let request_size = request_value_reader
5924 .seek(std::io::SeekFrom::End(0))
5925 .unwrap();
5926 request_value_reader
5927 .seek(std::io::SeekFrom::Start(0))
5928 .unwrap();
5929
5930 loop {
5931 let token = match self
5932 .hub
5933 .auth
5934 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5935 .await
5936 {
5937 Ok(token) => token,
5938 Err(e) => match dlg.token(e) {
5939 Ok(token) => token,
5940 Err(e) => {
5941 dlg.finished(false);
5942 return Err(common::Error::MissingToken(e));
5943 }
5944 },
5945 };
5946 request_value_reader
5947 .seek(std::io::SeekFrom::Start(0))
5948 .unwrap();
5949 let mut req_result = {
5950 let client = &self.hub.client;
5951 dlg.pre_request();
5952 let mut req_builder = hyper::Request::builder()
5953 .method(hyper::Method::POST)
5954 .uri(url.as_str())
5955 .header(USER_AGENT, self.hub._user_agent.clone());
5956
5957 if let Some(token) = token.as_ref() {
5958 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5959 }
5960
5961 let request = req_builder
5962 .header(CONTENT_TYPE, json_mime_type.to_string())
5963 .header(CONTENT_LENGTH, request_size as u64)
5964 .body(common::to_body(
5965 request_value_reader.get_ref().clone().into(),
5966 ));
5967
5968 client.request(request.unwrap()).await
5969 };
5970
5971 match req_result {
5972 Err(err) => {
5973 if let common::Retry::After(d) = dlg.http_error(&err) {
5974 sleep(d).await;
5975 continue;
5976 }
5977 dlg.finished(false);
5978 return Err(common::Error::HttpError(err));
5979 }
5980 Ok(res) => {
5981 let (mut parts, body) = res.into_parts();
5982 let mut body = common::Body::new(body);
5983 if !parts.status.is_success() {
5984 let bytes = common::to_bytes(body).await.unwrap_or_default();
5985 let error = serde_json::from_str(&common::to_string(&bytes));
5986 let response = common::to_response(parts, bytes.into());
5987
5988 if let common::Retry::After(d) =
5989 dlg.http_failure(&response, error.as_ref().ok())
5990 {
5991 sleep(d).await;
5992 continue;
5993 }
5994
5995 dlg.finished(false);
5996
5997 return Err(match error {
5998 Ok(value) => common::Error::BadRequest(value),
5999 _ => common::Error::Failure(response),
6000 });
6001 }
6002 let response = {
6003 let bytes = common::to_bytes(body).await.unwrap_or_default();
6004 let encoded = common::to_string(&bytes);
6005 match serde_json::from_str(&encoded) {
6006 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6007 Err(error) => {
6008 dlg.response_json_decode_error(&encoded, &error);
6009 return Err(common::Error::JsonDecodeError(
6010 encoded.to_string(),
6011 error,
6012 ));
6013 }
6014 }
6015 };
6016
6017 dlg.finished(true);
6018 return Ok(response);
6019 }
6020 }
6021 }
6022 }
6023
6024 ///
6025 /// Sets the *request* property to the given value.
6026 ///
6027 /// Even though the property as already been set when instantiating this call,
6028 /// we provide this method for API completeness.
6029 pub fn request(mut self, new_value: ManagedZone) -> ManagedZoneCreateCall<'a, C> {
6030 self._request = new_value;
6031 self
6032 }
6033 /// Identifies the project addressed by this request.
6034 ///
6035 /// Sets the *project* path property to the given value.
6036 ///
6037 /// Even though the property as already been set when instantiating this call,
6038 /// we provide this method for API completeness.
6039 pub fn project(mut self, new_value: &str) -> ManagedZoneCreateCall<'a, C> {
6040 self._project = new_value.to_string();
6041 self
6042 }
6043 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
6044 ///
6045 /// Sets the *client operation id* query property to the given value.
6046 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneCreateCall<'a, C> {
6047 self._client_operation_id = Some(new_value.to_string());
6048 self
6049 }
6050 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6051 /// while executing the actual API request.
6052 ///
6053 /// ````text
6054 /// It should be used to handle progress information, and to implement a certain level of resilience.
6055 /// ````
6056 ///
6057 /// Sets the *delegate* property to the given value.
6058 pub fn delegate(
6059 mut self,
6060 new_value: &'a mut dyn common::Delegate,
6061 ) -> ManagedZoneCreateCall<'a, C> {
6062 self._delegate = Some(new_value);
6063 self
6064 }
6065
6066 /// Set any additional parameter of the query string used in the request.
6067 /// It should be used to set parameters which are not yet available through their own
6068 /// setters.
6069 ///
6070 /// Please note that this method must not be used to set any of the known parameters
6071 /// which have their own setter method. If done anyway, the request will fail.
6072 ///
6073 /// # Additional Parameters
6074 ///
6075 /// * *$.xgafv* (query-string) - V1 error format.
6076 /// * *access_token* (query-string) - OAuth access token.
6077 /// * *alt* (query-string) - Data format for response.
6078 /// * *callback* (query-string) - JSONP
6079 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6080 /// * *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.
6081 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6082 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6083 /// * *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.
6084 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6085 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6086 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneCreateCall<'a, C>
6087 where
6088 T: AsRef<str>,
6089 {
6090 self._additional_params
6091 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6092 self
6093 }
6094
6095 /// Identifies the authorization scope for the method you are building.
6096 ///
6097 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6098 /// [`Scope::CloudPlatform`].
6099 ///
6100 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6101 /// tokens for more than one scope.
6102 ///
6103 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6104 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6105 /// sufficient, a read-write scope will do as well.
6106 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneCreateCall<'a, C>
6107 where
6108 St: AsRef<str>,
6109 {
6110 self._scopes.insert(String::from(scope.as_ref()));
6111 self
6112 }
6113 /// Identifies the authorization scope(s) for the method you are building.
6114 ///
6115 /// See [`Self::add_scope()`] for details.
6116 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneCreateCall<'a, C>
6117 where
6118 I: IntoIterator<Item = St>,
6119 St: AsRef<str>,
6120 {
6121 self._scopes
6122 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6123 self
6124 }
6125
6126 /// Removes all scopes, and no default scope will be used either.
6127 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6128 /// for details).
6129 pub fn clear_scopes(mut self) -> ManagedZoneCreateCall<'a, C> {
6130 self._scopes.clear();
6131 self
6132 }
6133}
6134
6135/// Deletes a previously created ManagedZone.
6136///
6137/// A builder for the *delete* method supported by a *managedZone* resource.
6138/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
6139///
6140/// # Example
6141///
6142/// Instantiate a resource method builder
6143///
6144/// ```test_harness,no_run
6145/// # extern crate hyper;
6146/// # extern crate hyper_rustls;
6147/// # extern crate google_dns1 as dns1;
6148/// # async fn dox() {
6149/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6150///
6151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6152/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6153/// # .with_native_roots()
6154/// # .unwrap()
6155/// # .https_only()
6156/// # .enable_http2()
6157/// # .build();
6158///
6159/// # let executor = hyper_util::rt::TokioExecutor::new();
6160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6161/// # secret,
6162/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6163/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6164/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6165/// # ),
6166/// # ).build().await.unwrap();
6167///
6168/// # let client = hyper_util::client::legacy::Client::builder(
6169/// # hyper_util::rt::TokioExecutor::new()
6170/// # )
6171/// # .build(
6172/// # hyper_rustls::HttpsConnectorBuilder::new()
6173/// # .with_native_roots()
6174/// # .unwrap()
6175/// # .https_or_http()
6176/// # .enable_http2()
6177/// # .build()
6178/// # );
6179/// # let mut hub = Dns::new(client, auth);
6180/// // You can configure optional parameters by calling the respective setters at will, and
6181/// // execute the final call using `doit()`.
6182/// // Values shown here are possibly random and not representative !
6183/// let result = hub.managed_zones().delete("project", "managedZone")
6184/// .client_operation_id("vero")
6185/// .doit().await;
6186/// # }
6187/// ```
6188pub struct ManagedZoneDeleteCall<'a, C>
6189where
6190 C: 'a,
6191{
6192 hub: &'a Dns<C>,
6193 _project: String,
6194 _managed_zone: String,
6195 _client_operation_id: Option<String>,
6196 _delegate: Option<&'a mut dyn common::Delegate>,
6197 _additional_params: HashMap<String, String>,
6198 _scopes: BTreeSet<String>,
6199}
6200
6201impl<'a, C> common::CallBuilder for ManagedZoneDeleteCall<'a, C> {}
6202
6203impl<'a, C> ManagedZoneDeleteCall<'a, C>
6204where
6205 C: common::Connector,
6206{
6207 /// Perform the operation you have build so far.
6208 pub async fn doit(mut self) -> common::Result<common::Response> {
6209 use std::borrow::Cow;
6210 use std::io::{Read, Seek};
6211
6212 use common::{url::Params, ToParts};
6213 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6214
6215 let mut dd = common::DefaultDelegate;
6216 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6217 dlg.begin(common::MethodInfo {
6218 id: "dns.managedZones.delete",
6219 http_method: hyper::Method::DELETE,
6220 });
6221
6222 for &field in ["project", "managedZone", "clientOperationId"].iter() {
6223 if self._additional_params.contains_key(field) {
6224 dlg.finished(false);
6225 return Err(common::Error::FieldClash(field));
6226 }
6227 }
6228
6229 let mut params = Params::with_capacity(4 + self._additional_params.len());
6230 params.push("project", self._project);
6231 params.push("managedZone", self._managed_zone);
6232 if let Some(value) = self._client_operation_id.as_ref() {
6233 params.push("clientOperationId", value);
6234 }
6235
6236 params.extend(self._additional_params.iter());
6237
6238 let mut url =
6239 self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones/{managedZone}";
6240 if self._scopes.is_empty() {
6241 self._scopes
6242 .insert(Scope::CloudPlatform.as_ref().to_string());
6243 }
6244
6245 #[allow(clippy::single_element_loop)]
6246 for &(find_this, param_name) in
6247 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
6248 {
6249 url = params.uri_replacement(url, param_name, find_this, false);
6250 }
6251 {
6252 let to_remove = ["managedZone", "project"];
6253 params.remove_params(&to_remove);
6254 }
6255
6256 let url = params.parse_with_url(&url);
6257
6258 loop {
6259 let token = match self
6260 .hub
6261 .auth
6262 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6263 .await
6264 {
6265 Ok(token) => token,
6266 Err(e) => match dlg.token(e) {
6267 Ok(token) => token,
6268 Err(e) => {
6269 dlg.finished(false);
6270 return Err(common::Error::MissingToken(e));
6271 }
6272 },
6273 };
6274 let mut req_result = {
6275 let client = &self.hub.client;
6276 dlg.pre_request();
6277 let mut req_builder = hyper::Request::builder()
6278 .method(hyper::Method::DELETE)
6279 .uri(url.as_str())
6280 .header(USER_AGENT, self.hub._user_agent.clone());
6281
6282 if let Some(token) = token.as_ref() {
6283 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6284 }
6285
6286 let request = req_builder
6287 .header(CONTENT_LENGTH, 0_u64)
6288 .body(common::to_body::<String>(None));
6289
6290 client.request(request.unwrap()).await
6291 };
6292
6293 match req_result {
6294 Err(err) => {
6295 if let common::Retry::After(d) = dlg.http_error(&err) {
6296 sleep(d).await;
6297 continue;
6298 }
6299 dlg.finished(false);
6300 return Err(common::Error::HttpError(err));
6301 }
6302 Ok(res) => {
6303 let (mut parts, body) = res.into_parts();
6304 let mut body = common::Body::new(body);
6305 if !parts.status.is_success() {
6306 let bytes = common::to_bytes(body).await.unwrap_or_default();
6307 let error = serde_json::from_str(&common::to_string(&bytes));
6308 let response = common::to_response(parts, bytes.into());
6309
6310 if let common::Retry::After(d) =
6311 dlg.http_failure(&response, error.as_ref().ok())
6312 {
6313 sleep(d).await;
6314 continue;
6315 }
6316
6317 dlg.finished(false);
6318
6319 return Err(match error {
6320 Ok(value) => common::Error::BadRequest(value),
6321 _ => common::Error::Failure(response),
6322 });
6323 }
6324 let response = common::Response::from_parts(parts, body);
6325
6326 dlg.finished(true);
6327 return Ok(response);
6328 }
6329 }
6330 }
6331 }
6332
6333 /// Identifies the project addressed by this request.
6334 ///
6335 /// Sets the *project* path property to the given value.
6336 ///
6337 /// Even though the property as already been set when instantiating this call,
6338 /// we provide this method for API completeness.
6339 pub fn project(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6340 self._project = new_value.to_string();
6341 self
6342 }
6343 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
6344 ///
6345 /// Sets the *managed zone* path property to the given value.
6346 ///
6347 /// Even though the property as already been set when instantiating this call,
6348 /// we provide this method for API completeness.
6349 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6350 self._managed_zone = new_value.to_string();
6351 self
6352 }
6353 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
6354 ///
6355 /// Sets the *client operation id* query property to the given value.
6356 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a, C> {
6357 self._client_operation_id = Some(new_value.to_string());
6358 self
6359 }
6360 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6361 /// while executing the actual API request.
6362 ///
6363 /// ````text
6364 /// It should be used to handle progress information, and to implement a certain level of resilience.
6365 /// ````
6366 ///
6367 /// Sets the *delegate* property to the given value.
6368 pub fn delegate(
6369 mut self,
6370 new_value: &'a mut dyn common::Delegate,
6371 ) -> ManagedZoneDeleteCall<'a, C> {
6372 self._delegate = Some(new_value);
6373 self
6374 }
6375
6376 /// Set any additional parameter of the query string used in the request.
6377 /// It should be used to set parameters which are not yet available through their own
6378 /// setters.
6379 ///
6380 /// Please note that this method must not be used to set any of the known parameters
6381 /// which have their own setter method. If done anyway, the request will fail.
6382 ///
6383 /// # Additional Parameters
6384 ///
6385 /// * *$.xgafv* (query-string) - V1 error format.
6386 /// * *access_token* (query-string) - OAuth access token.
6387 /// * *alt* (query-string) - Data format for response.
6388 /// * *callback* (query-string) - JSONP
6389 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6390 /// * *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.
6391 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6392 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6393 /// * *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.
6394 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6395 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6396 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneDeleteCall<'a, C>
6397 where
6398 T: AsRef<str>,
6399 {
6400 self._additional_params
6401 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6402 self
6403 }
6404
6405 /// Identifies the authorization scope for the method you are building.
6406 ///
6407 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6408 /// [`Scope::CloudPlatform`].
6409 ///
6410 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6411 /// tokens for more than one scope.
6412 ///
6413 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6414 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6415 /// sufficient, a read-write scope will do as well.
6416 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneDeleteCall<'a, C>
6417 where
6418 St: AsRef<str>,
6419 {
6420 self._scopes.insert(String::from(scope.as_ref()));
6421 self
6422 }
6423 /// Identifies the authorization scope(s) for the method you are building.
6424 ///
6425 /// See [`Self::add_scope()`] for details.
6426 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneDeleteCall<'a, C>
6427 where
6428 I: IntoIterator<Item = St>,
6429 St: AsRef<str>,
6430 {
6431 self._scopes
6432 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6433 self
6434 }
6435
6436 /// Removes all scopes, and no default scope will be used either.
6437 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6438 /// for details).
6439 pub fn clear_scopes(mut self) -> ManagedZoneDeleteCall<'a, C> {
6440 self._scopes.clear();
6441 self
6442 }
6443}
6444
6445/// Fetches the representation of an existing ManagedZone.
6446///
6447/// A builder for the *get* method supported by a *managedZone* resource.
6448/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
6449///
6450/// # Example
6451///
6452/// Instantiate a resource method builder
6453///
6454/// ```test_harness,no_run
6455/// # extern crate hyper;
6456/// # extern crate hyper_rustls;
6457/// # extern crate google_dns1 as dns1;
6458/// # async fn dox() {
6459/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6460///
6461/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6462/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6463/// # .with_native_roots()
6464/// # .unwrap()
6465/// # .https_only()
6466/// # .enable_http2()
6467/// # .build();
6468///
6469/// # let executor = hyper_util::rt::TokioExecutor::new();
6470/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6471/// # secret,
6472/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6473/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6474/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6475/// # ),
6476/// # ).build().await.unwrap();
6477///
6478/// # let client = hyper_util::client::legacy::Client::builder(
6479/// # hyper_util::rt::TokioExecutor::new()
6480/// # )
6481/// # .build(
6482/// # hyper_rustls::HttpsConnectorBuilder::new()
6483/// # .with_native_roots()
6484/// # .unwrap()
6485/// # .https_or_http()
6486/// # .enable_http2()
6487/// # .build()
6488/// # );
6489/// # let mut hub = Dns::new(client, auth);
6490/// // You can configure optional parameters by calling the respective setters at will, and
6491/// // execute the final call using `doit()`.
6492/// // Values shown here are possibly random and not representative !
6493/// let result = hub.managed_zones().get("project", "managedZone")
6494/// .client_operation_id("duo")
6495/// .doit().await;
6496/// # }
6497/// ```
6498pub struct ManagedZoneGetCall<'a, C>
6499where
6500 C: 'a,
6501{
6502 hub: &'a Dns<C>,
6503 _project: String,
6504 _managed_zone: String,
6505 _client_operation_id: Option<String>,
6506 _delegate: Option<&'a mut dyn common::Delegate>,
6507 _additional_params: HashMap<String, String>,
6508 _scopes: BTreeSet<String>,
6509}
6510
6511impl<'a, C> common::CallBuilder for ManagedZoneGetCall<'a, C> {}
6512
6513impl<'a, C> ManagedZoneGetCall<'a, C>
6514where
6515 C: common::Connector,
6516{
6517 /// Perform the operation you have build so far.
6518 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedZone)> {
6519 use std::borrow::Cow;
6520 use std::io::{Read, Seek};
6521
6522 use common::{url::Params, ToParts};
6523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6524
6525 let mut dd = common::DefaultDelegate;
6526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6527 dlg.begin(common::MethodInfo {
6528 id: "dns.managedZones.get",
6529 http_method: hyper::Method::GET,
6530 });
6531
6532 for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() {
6533 if self._additional_params.contains_key(field) {
6534 dlg.finished(false);
6535 return Err(common::Error::FieldClash(field));
6536 }
6537 }
6538
6539 let mut params = Params::with_capacity(5 + self._additional_params.len());
6540 params.push("project", self._project);
6541 params.push("managedZone", self._managed_zone);
6542 if let Some(value) = self._client_operation_id.as_ref() {
6543 params.push("clientOperationId", value);
6544 }
6545
6546 params.extend(self._additional_params.iter());
6547
6548 params.push("alt", "json");
6549 let mut url =
6550 self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones/{managedZone}";
6551 if self._scopes.is_empty() {
6552 self._scopes
6553 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
6554 }
6555
6556 #[allow(clippy::single_element_loop)]
6557 for &(find_this, param_name) in
6558 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
6559 {
6560 url = params.uri_replacement(url, param_name, find_this, false);
6561 }
6562 {
6563 let to_remove = ["managedZone", "project"];
6564 params.remove_params(&to_remove);
6565 }
6566
6567 let url = params.parse_with_url(&url);
6568
6569 loop {
6570 let token = match self
6571 .hub
6572 .auth
6573 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6574 .await
6575 {
6576 Ok(token) => token,
6577 Err(e) => match dlg.token(e) {
6578 Ok(token) => token,
6579 Err(e) => {
6580 dlg.finished(false);
6581 return Err(common::Error::MissingToken(e));
6582 }
6583 },
6584 };
6585 let mut req_result = {
6586 let client = &self.hub.client;
6587 dlg.pre_request();
6588 let mut req_builder = hyper::Request::builder()
6589 .method(hyper::Method::GET)
6590 .uri(url.as_str())
6591 .header(USER_AGENT, self.hub._user_agent.clone());
6592
6593 if let Some(token) = token.as_ref() {
6594 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6595 }
6596
6597 let request = req_builder
6598 .header(CONTENT_LENGTH, 0_u64)
6599 .body(common::to_body::<String>(None));
6600
6601 client.request(request.unwrap()).await
6602 };
6603
6604 match req_result {
6605 Err(err) => {
6606 if let common::Retry::After(d) = dlg.http_error(&err) {
6607 sleep(d).await;
6608 continue;
6609 }
6610 dlg.finished(false);
6611 return Err(common::Error::HttpError(err));
6612 }
6613 Ok(res) => {
6614 let (mut parts, body) = res.into_parts();
6615 let mut body = common::Body::new(body);
6616 if !parts.status.is_success() {
6617 let bytes = common::to_bytes(body).await.unwrap_or_default();
6618 let error = serde_json::from_str(&common::to_string(&bytes));
6619 let response = common::to_response(parts, bytes.into());
6620
6621 if let common::Retry::After(d) =
6622 dlg.http_failure(&response, error.as_ref().ok())
6623 {
6624 sleep(d).await;
6625 continue;
6626 }
6627
6628 dlg.finished(false);
6629
6630 return Err(match error {
6631 Ok(value) => common::Error::BadRequest(value),
6632 _ => common::Error::Failure(response),
6633 });
6634 }
6635 let response = {
6636 let bytes = common::to_bytes(body).await.unwrap_or_default();
6637 let encoded = common::to_string(&bytes);
6638 match serde_json::from_str(&encoded) {
6639 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6640 Err(error) => {
6641 dlg.response_json_decode_error(&encoded, &error);
6642 return Err(common::Error::JsonDecodeError(
6643 encoded.to_string(),
6644 error,
6645 ));
6646 }
6647 }
6648 };
6649
6650 dlg.finished(true);
6651 return Ok(response);
6652 }
6653 }
6654 }
6655 }
6656
6657 /// Identifies the project addressed by this request.
6658 ///
6659 /// Sets the *project* path property to the given value.
6660 ///
6661 /// Even though the property as already been set when instantiating this call,
6662 /// we provide this method for API completeness.
6663 pub fn project(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6664 self._project = new_value.to_string();
6665 self
6666 }
6667 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
6668 ///
6669 /// Sets the *managed zone* path property to the given value.
6670 ///
6671 /// Even though the property as already been set when instantiating this call,
6672 /// we provide this method for API completeness.
6673 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6674 self._managed_zone = new_value.to_string();
6675 self
6676 }
6677 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
6678 ///
6679 /// Sets the *client operation id* query property to the given value.
6680 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneGetCall<'a, C> {
6681 self._client_operation_id = Some(new_value.to_string());
6682 self
6683 }
6684 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6685 /// while executing the actual API request.
6686 ///
6687 /// ````text
6688 /// It should be used to handle progress information, and to implement a certain level of resilience.
6689 /// ````
6690 ///
6691 /// Sets the *delegate* property to the given value.
6692 pub fn delegate(
6693 mut self,
6694 new_value: &'a mut dyn common::Delegate,
6695 ) -> ManagedZoneGetCall<'a, C> {
6696 self._delegate = Some(new_value);
6697 self
6698 }
6699
6700 /// Set any additional parameter of the query string used in the request.
6701 /// It should be used to set parameters which are not yet available through their own
6702 /// setters.
6703 ///
6704 /// Please note that this method must not be used to set any of the known parameters
6705 /// which have their own setter method. If done anyway, the request will fail.
6706 ///
6707 /// # Additional Parameters
6708 ///
6709 /// * *$.xgafv* (query-string) - V1 error format.
6710 /// * *access_token* (query-string) - OAuth access token.
6711 /// * *alt* (query-string) - Data format for response.
6712 /// * *callback* (query-string) - JSONP
6713 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6714 /// * *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.
6715 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6716 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6717 /// * *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.
6718 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6719 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6720 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneGetCall<'a, C>
6721 where
6722 T: AsRef<str>,
6723 {
6724 self._additional_params
6725 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6726 self
6727 }
6728
6729 /// Identifies the authorization scope for the method you are building.
6730 ///
6731 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6732 /// [`Scope::NdevClouddnReadonly`].
6733 ///
6734 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6735 /// tokens for more than one scope.
6736 ///
6737 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6738 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6739 /// sufficient, a read-write scope will do as well.
6740 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneGetCall<'a, C>
6741 where
6742 St: AsRef<str>,
6743 {
6744 self._scopes.insert(String::from(scope.as_ref()));
6745 self
6746 }
6747 /// Identifies the authorization scope(s) for the method you are building.
6748 ///
6749 /// See [`Self::add_scope()`] for details.
6750 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneGetCall<'a, C>
6751 where
6752 I: IntoIterator<Item = St>,
6753 St: AsRef<str>,
6754 {
6755 self._scopes
6756 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6757 self
6758 }
6759
6760 /// Removes all scopes, and no default scope will be used either.
6761 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6762 /// for details).
6763 pub fn clear_scopes(mut self) -> ManagedZoneGetCall<'a, C> {
6764 self._scopes.clear();
6765 self
6766 }
6767}
6768
6769/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
6770///
6771/// A builder for the *getIamPolicy* method supported by a *managedZone* resource.
6772/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
6773///
6774/// # Example
6775///
6776/// Instantiate a resource method builder
6777///
6778/// ```test_harness,no_run
6779/// # extern crate hyper;
6780/// # extern crate hyper_rustls;
6781/// # extern crate google_dns1 as dns1;
6782/// use dns1::api::GoogleIamV1GetIamPolicyRequest;
6783/// # async fn dox() {
6784/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6785///
6786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6787/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6788/// # .with_native_roots()
6789/// # .unwrap()
6790/// # .https_only()
6791/// # .enable_http2()
6792/// # .build();
6793///
6794/// # let executor = hyper_util::rt::TokioExecutor::new();
6795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6796/// # secret,
6797/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6798/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6799/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6800/// # ),
6801/// # ).build().await.unwrap();
6802///
6803/// # let client = hyper_util::client::legacy::Client::builder(
6804/// # hyper_util::rt::TokioExecutor::new()
6805/// # )
6806/// # .build(
6807/// # hyper_rustls::HttpsConnectorBuilder::new()
6808/// # .with_native_roots()
6809/// # .unwrap()
6810/// # .https_or_http()
6811/// # .enable_http2()
6812/// # .build()
6813/// # );
6814/// # let mut hub = Dns::new(client, auth);
6815/// // As the method needs a request, you would usually fill it with the desired information
6816/// // into the respective structure. Some of the parts shown here might not be applicable !
6817/// // Values shown here are possibly random and not representative !
6818/// let mut req = GoogleIamV1GetIamPolicyRequest::default();
6819///
6820/// // You can configure optional parameters by calling the respective setters at will, and
6821/// // execute the final call using `doit()`.
6822/// // Values shown here are possibly random and not representative !
6823/// let result = hub.managed_zones().get_iam_policy(req, "resource")
6824/// .doit().await;
6825/// # }
6826/// ```
6827pub struct ManagedZoneGetIamPolicyCall<'a, C>
6828where
6829 C: 'a,
6830{
6831 hub: &'a Dns<C>,
6832 _request: GoogleIamV1GetIamPolicyRequest,
6833 _resource: String,
6834 _delegate: Option<&'a mut dyn common::Delegate>,
6835 _additional_params: HashMap<String, String>,
6836 _scopes: BTreeSet<String>,
6837}
6838
6839impl<'a, C> common::CallBuilder for ManagedZoneGetIamPolicyCall<'a, C> {}
6840
6841impl<'a, C> ManagedZoneGetIamPolicyCall<'a, C>
6842where
6843 C: common::Connector,
6844{
6845 /// Perform the operation you have build so far.
6846 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
6847 use std::borrow::Cow;
6848 use std::io::{Read, Seek};
6849
6850 use common::{url::Params, ToParts};
6851 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6852
6853 let mut dd = common::DefaultDelegate;
6854 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6855 dlg.begin(common::MethodInfo {
6856 id: "dns.managedZones.getIamPolicy",
6857 http_method: hyper::Method::POST,
6858 });
6859
6860 for &field in ["alt", "resource"].iter() {
6861 if self._additional_params.contains_key(field) {
6862 dlg.finished(false);
6863 return Err(common::Error::FieldClash(field));
6864 }
6865 }
6866
6867 let mut params = Params::with_capacity(4 + self._additional_params.len());
6868 params.push("resource", self._resource);
6869
6870 params.extend(self._additional_params.iter());
6871
6872 params.push("alt", "json");
6873 let mut url = self.hub._base_url.clone() + "dns/v1/{+resource}:getIamPolicy";
6874 if self._scopes.is_empty() {
6875 self._scopes
6876 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
6877 }
6878
6879 #[allow(clippy::single_element_loop)]
6880 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6881 url = params.uri_replacement(url, param_name, find_this, true);
6882 }
6883 {
6884 let to_remove = ["resource"];
6885 params.remove_params(&to_remove);
6886 }
6887
6888 let url = params.parse_with_url(&url);
6889
6890 let mut json_mime_type = mime::APPLICATION_JSON;
6891 let mut request_value_reader = {
6892 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6893 common::remove_json_null_values(&mut value);
6894 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6895 serde_json::to_writer(&mut dst, &value).unwrap();
6896 dst
6897 };
6898 let request_size = request_value_reader
6899 .seek(std::io::SeekFrom::End(0))
6900 .unwrap();
6901 request_value_reader
6902 .seek(std::io::SeekFrom::Start(0))
6903 .unwrap();
6904
6905 loop {
6906 let token = match self
6907 .hub
6908 .auth
6909 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6910 .await
6911 {
6912 Ok(token) => token,
6913 Err(e) => match dlg.token(e) {
6914 Ok(token) => token,
6915 Err(e) => {
6916 dlg.finished(false);
6917 return Err(common::Error::MissingToken(e));
6918 }
6919 },
6920 };
6921 request_value_reader
6922 .seek(std::io::SeekFrom::Start(0))
6923 .unwrap();
6924 let mut req_result = {
6925 let client = &self.hub.client;
6926 dlg.pre_request();
6927 let mut req_builder = hyper::Request::builder()
6928 .method(hyper::Method::POST)
6929 .uri(url.as_str())
6930 .header(USER_AGENT, self.hub._user_agent.clone());
6931
6932 if let Some(token) = token.as_ref() {
6933 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6934 }
6935
6936 let request = req_builder
6937 .header(CONTENT_TYPE, json_mime_type.to_string())
6938 .header(CONTENT_LENGTH, request_size as u64)
6939 .body(common::to_body(
6940 request_value_reader.get_ref().clone().into(),
6941 ));
6942
6943 client.request(request.unwrap()).await
6944 };
6945
6946 match req_result {
6947 Err(err) => {
6948 if let common::Retry::After(d) = dlg.http_error(&err) {
6949 sleep(d).await;
6950 continue;
6951 }
6952 dlg.finished(false);
6953 return Err(common::Error::HttpError(err));
6954 }
6955 Ok(res) => {
6956 let (mut parts, body) = res.into_parts();
6957 let mut body = common::Body::new(body);
6958 if !parts.status.is_success() {
6959 let bytes = common::to_bytes(body).await.unwrap_or_default();
6960 let error = serde_json::from_str(&common::to_string(&bytes));
6961 let response = common::to_response(parts, bytes.into());
6962
6963 if let common::Retry::After(d) =
6964 dlg.http_failure(&response, error.as_ref().ok())
6965 {
6966 sleep(d).await;
6967 continue;
6968 }
6969
6970 dlg.finished(false);
6971
6972 return Err(match error {
6973 Ok(value) => common::Error::BadRequest(value),
6974 _ => common::Error::Failure(response),
6975 });
6976 }
6977 let response = {
6978 let bytes = common::to_bytes(body).await.unwrap_or_default();
6979 let encoded = common::to_string(&bytes);
6980 match serde_json::from_str(&encoded) {
6981 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6982 Err(error) => {
6983 dlg.response_json_decode_error(&encoded, &error);
6984 return Err(common::Error::JsonDecodeError(
6985 encoded.to_string(),
6986 error,
6987 ));
6988 }
6989 }
6990 };
6991
6992 dlg.finished(true);
6993 return Ok(response);
6994 }
6995 }
6996 }
6997 }
6998
6999 ///
7000 /// Sets the *request* property to the given value.
7001 ///
7002 /// Even though the property as already been set when instantiating this call,
7003 /// we provide this method for API completeness.
7004 pub fn request(
7005 mut self,
7006 new_value: GoogleIamV1GetIamPolicyRequest,
7007 ) -> ManagedZoneGetIamPolicyCall<'a, C> {
7008 self._request = new_value;
7009 self
7010 }
7011 /// 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.
7012 ///
7013 /// Sets the *resource* path property to the given value.
7014 ///
7015 /// Even though the property as already been set when instantiating this call,
7016 /// we provide this method for API completeness.
7017 pub fn resource(mut self, new_value: &str) -> ManagedZoneGetIamPolicyCall<'a, C> {
7018 self._resource = new_value.to_string();
7019 self
7020 }
7021 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7022 /// while executing the actual API request.
7023 ///
7024 /// ````text
7025 /// It should be used to handle progress information, and to implement a certain level of resilience.
7026 /// ````
7027 ///
7028 /// Sets the *delegate* property to the given value.
7029 pub fn delegate(
7030 mut self,
7031 new_value: &'a mut dyn common::Delegate,
7032 ) -> ManagedZoneGetIamPolicyCall<'a, C> {
7033 self._delegate = Some(new_value);
7034 self
7035 }
7036
7037 /// Set any additional parameter of the query string used in the request.
7038 /// It should be used to set parameters which are not yet available through their own
7039 /// setters.
7040 ///
7041 /// Please note that this method must not be used to set any of the known parameters
7042 /// which have their own setter method. If done anyway, the request will fail.
7043 ///
7044 /// # Additional Parameters
7045 ///
7046 /// * *$.xgafv* (query-string) - V1 error format.
7047 /// * *access_token* (query-string) - OAuth access token.
7048 /// * *alt* (query-string) - Data format for response.
7049 /// * *callback* (query-string) - JSONP
7050 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7051 /// * *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.
7052 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7053 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7054 /// * *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.
7055 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7056 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7057 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneGetIamPolicyCall<'a, C>
7058 where
7059 T: AsRef<str>,
7060 {
7061 self._additional_params
7062 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7063 self
7064 }
7065
7066 /// Identifies the authorization scope for the method you are building.
7067 ///
7068 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7069 /// [`Scope::NdevClouddnReadonly`].
7070 ///
7071 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7072 /// tokens for more than one scope.
7073 ///
7074 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7075 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7076 /// sufficient, a read-write scope will do as well.
7077 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneGetIamPolicyCall<'a, C>
7078 where
7079 St: AsRef<str>,
7080 {
7081 self._scopes.insert(String::from(scope.as_ref()));
7082 self
7083 }
7084 /// Identifies the authorization scope(s) for the method you are building.
7085 ///
7086 /// See [`Self::add_scope()`] for details.
7087 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneGetIamPolicyCall<'a, C>
7088 where
7089 I: IntoIterator<Item = St>,
7090 St: AsRef<str>,
7091 {
7092 self._scopes
7093 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7094 self
7095 }
7096
7097 /// Removes all scopes, and no default scope will be used either.
7098 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7099 /// for details).
7100 pub fn clear_scopes(mut self) -> ManagedZoneGetIamPolicyCall<'a, C> {
7101 self._scopes.clear();
7102 self
7103 }
7104}
7105
7106/// Enumerates ManagedZones that have been created but not yet deleted.
7107///
7108/// A builder for the *list* method supported by a *managedZone* resource.
7109/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
7110///
7111/// # Example
7112///
7113/// Instantiate a resource method builder
7114///
7115/// ```test_harness,no_run
7116/// # extern crate hyper;
7117/// # extern crate hyper_rustls;
7118/// # extern crate google_dns1 as dns1;
7119/// # async fn dox() {
7120/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7121///
7122/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7123/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7124/// # .with_native_roots()
7125/// # .unwrap()
7126/// # .https_only()
7127/// # .enable_http2()
7128/// # .build();
7129///
7130/// # let executor = hyper_util::rt::TokioExecutor::new();
7131/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7132/// # secret,
7133/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7134/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7135/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7136/// # ),
7137/// # ).build().await.unwrap();
7138///
7139/// # let client = hyper_util::client::legacy::Client::builder(
7140/// # hyper_util::rt::TokioExecutor::new()
7141/// # )
7142/// # .build(
7143/// # hyper_rustls::HttpsConnectorBuilder::new()
7144/// # .with_native_roots()
7145/// # .unwrap()
7146/// # .https_or_http()
7147/// # .enable_http2()
7148/// # .build()
7149/// # );
7150/// # let mut hub = Dns::new(client, auth);
7151/// // You can configure optional parameters by calling the respective setters at will, and
7152/// // execute the final call using `doit()`.
7153/// // Values shown here are possibly random and not representative !
7154/// let result = hub.managed_zones().list("project")
7155/// .page_token("voluptua.")
7156/// .max_results(-2)
7157/// .dns_name("consetetur")
7158/// .doit().await;
7159/// # }
7160/// ```
7161pub struct ManagedZoneListCall<'a, C>
7162where
7163 C: 'a,
7164{
7165 hub: &'a Dns<C>,
7166 _project: String,
7167 _page_token: Option<String>,
7168 _max_results: Option<i32>,
7169 _dns_name: Option<String>,
7170 _delegate: Option<&'a mut dyn common::Delegate>,
7171 _additional_params: HashMap<String, String>,
7172 _scopes: BTreeSet<String>,
7173}
7174
7175impl<'a, C> common::CallBuilder for ManagedZoneListCall<'a, C> {}
7176
7177impl<'a, C> ManagedZoneListCall<'a, C>
7178where
7179 C: common::Connector,
7180{
7181 /// Perform the operation you have build so far.
7182 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedZonesListResponse)> {
7183 use std::borrow::Cow;
7184 use std::io::{Read, Seek};
7185
7186 use common::{url::Params, ToParts};
7187 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7188
7189 let mut dd = common::DefaultDelegate;
7190 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7191 dlg.begin(common::MethodInfo {
7192 id: "dns.managedZones.list",
7193 http_method: hyper::Method::GET,
7194 });
7195
7196 for &field in ["alt", "project", "pageToken", "maxResults", "dnsName"].iter() {
7197 if self._additional_params.contains_key(field) {
7198 dlg.finished(false);
7199 return Err(common::Error::FieldClash(field));
7200 }
7201 }
7202
7203 let mut params = Params::with_capacity(6 + self._additional_params.len());
7204 params.push("project", self._project);
7205 if let Some(value) = self._page_token.as_ref() {
7206 params.push("pageToken", value);
7207 }
7208 if let Some(value) = self._max_results.as_ref() {
7209 params.push("maxResults", value.to_string());
7210 }
7211 if let Some(value) = self._dns_name.as_ref() {
7212 params.push("dnsName", value);
7213 }
7214
7215 params.extend(self._additional_params.iter());
7216
7217 params.push("alt", "json");
7218 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones";
7219 if self._scopes.is_empty() {
7220 self._scopes
7221 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
7222 }
7223
7224 #[allow(clippy::single_element_loop)]
7225 for &(find_this, param_name) in [("{project}", "project")].iter() {
7226 url = params.uri_replacement(url, param_name, find_this, false);
7227 }
7228 {
7229 let to_remove = ["project"];
7230 params.remove_params(&to_remove);
7231 }
7232
7233 let url = params.parse_with_url(&url);
7234
7235 loop {
7236 let token = match self
7237 .hub
7238 .auth
7239 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7240 .await
7241 {
7242 Ok(token) => token,
7243 Err(e) => match dlg.token(e) {
7244 Ok(token) => token,
7245 Err(e) => {
7246 dlg.finished(false);
7247 return Err(common::Error::MissingToken(e));
7248 }
7249 },
7250 };
7251 let mut req_result = {
7252 let client = &self.hub.client;
7253 dlg.pre_request();
7254 let mut req_builder = hyper::Request::builder()
7255 .method(hyper::Method::GET)
7256 .uri(url.as_str())
7257 .header(USER_AGENT, self.hub._user_agent.clone());
7258
7259 if let Some(token) = token.as_ref() {
7260 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7261 }
7262
7263 let request = req_builder
7264 .header(CONTENT_LENGTH, 0_u64)
7265 .body(common::to_body::<String>(None));
7266
7267 client.request(request.unwrap()).await
7268 };
7269
7270 match req_result {
7271 Err(err) => {
7272 if let common::Retry::After(d) = dlg.http_error(&err) {
7273 sleep(d).await;
7274 continue;
7275 }
7276 dlg.finished(false);
7277 return Err(common::Error::HttpError(err));
7278 }
7279 Ok(res) => {
7280 let (mut parts, body) = res.into_parts();
7281 let mut body = common::Body::new(body);
7282 if !parts.status.is_success() {
7283 let bytes = common::to_bytes(body).await.unwrap_or_default();
7284 let error = serde_json::from_str(&common::to_string(&bytes));
7285 let response = common::to_response(parts, bytes.into());
7286
7287 if let common::Retry::After(d) =
7288 dlg.http_failure(&response, error.as_ref().ok())
7289 {
7290 sleep(d).await;
7291 continue;
7292 }
7293
7294 dlg.finished(false);
7295
7296 return Err(match error {
7297 Ok(value) => common::Error::BadRequest(value),
7298 _ => common::Error::Failure(response),
7299 });
7300 }
7301 let response = {
7302 let bytes = common::to_bytes(body).await.unwrap_or_default();
7303 let encoded = common::to_string(&bytes);
7304 match serde_json::from_str(&encoded) {
7305 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7306 Err(error) => {
7307 dlg.response_json_decode_error(&encoded, &error);
7308 return Err(common::Error::JsonDecodeError(
7309 encoded.to_string(),
7310 error,
7311 ));
7312 }
7313 }
7314 };
7315
7316 dlg.finished(true);
7317 return Ok(response);
7318 }
7319 }
7320 }
7321 }
7322
7323 /// Identifies the project addressed by this request.
7324 ///
7325 /// Sets the *project* path property to the given value.
7326 ///
7327 /// Even though the property as already been set when instantiating this call,
7328 /// we provide this method for API completeness.
7329 pub fn project(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7330 self._project = new_value.to_string();
7331 self
7332 }
7333 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
7334 ///
7335 /// Sets the *page token* query property to the given value.
7336 pub fn page_token(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7337 self._page_token = Some(new_value.to_string());
7338 self
7339 }
7340 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
7341 ///
7342 /// Sets the *max results* query property to the given value.
7343 pub fn max_results(mut self, new_value: i32) -> ManagedZoneListCall<'a, C> {
7344 self._max_results = Some(new_value);
7345 self
7346 }
7347 /// Restricts the list to return only zones with this domain name.
7348 ///
7349 /// Sets the *dns name* query property to the given value.
7350 pub fn dns_name(mut self, new_value: &str) -> ManagedZoneListCall<'a, C> {
7351 self._dns_name = Some(new_value.to_string());
7352 self
7353 }
7354 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7355 /// while executing the actual API request.
7356 ///
7357 /// ````text
7358 /// It should be used to handle progress information, and to implement a certain level of resilience.
7359 /// ````
7360 ///
7361 /// Sets the *delegate* property to the given value.
7362 pub fn delegate(
7363 mut self,
7364 new_value: &'a mut dyn common::Delegate,
7365 ) -> ManagedZoneListCall<'a, C> {
7366 self._delegate = Some(new_value);
7367 self
7368 }
7369
7370 /// Set any additional parameter of the query string used in the request.
7371 /// It should be used to set parameters which are not yet available through their own
7372 /// setters.
7373 ///
7374 /// Please note that this method must not be used to set any of the known parameters
7375 /// which have their own setter method. If done anyway, the request will fail.
7376 ///
7377 /// # Additional Parameters
7378 ///
7379 /// * *$.xgafv* (query-string) - V1 error format.
7380 /// * *access_token* (query-string) - OAuth access token.
7381 /// * *alt* (query-string) - Data format for response.
7382 /// * *callback* (query-string) - JSONP
7383 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7384 /// * *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.
7385 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7386 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7387 /// * *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.
7388 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7389 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7390 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneListCall<'a, C>
7391 where
7392 T: AsRef<str>,
7393 {
7394 self._additional_params
7395 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7396 self
7397 }
7398
7399 /// Identifies the authorization scope for the method you are building.
7400 ///
7401 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7402 /// [`Scope::NdevClouddnReadonly`].
7403 ///
7404 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7405 /// tokens for more than one scope.
7406 ///
7407 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7408 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7409 /// sufficient, a read-write scope will do as well.
7410 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneListCall<'a, C>
7411 where
7412 St: AsRef<str>,
7413 {
7414 self._scopes.insert(String::from(scope.as_ref()));
7415 self
7416 }
7417 /// Identifies the authorization scope(s) for the method you are building.
7418 ///
7419 /// See [`Self::add_scope()`] for details.
7420 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneListCall<'a, C>
7421 where
7422 I: IntoIterator<Item = St>,
7423 St: AsRef<str>,
7424 {
7425 self._scopes
7426 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7427 self
7428 }
7429
7430 /// Removes all scopes, and no default scope will be used either.
7431 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7432 /// for details).
7433 pub fn clear_scopes(mut self) -> ManagedZoneListCall<'a, C> {
7434 self._scopes.clear();
7435 self
7436 }
7437}
7438
7439/// Applies a partial update to an existing ManagedZone.
7440///
7441/// A builder for the *patch* method supported by a *managedZone* resource.
7442/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
7443///
7444/// # Example
7445///
7446/// Instantiate a resource method builder
7447///
7448/// ```test_harness,no_run
7449/// # extern crate hyper;
7450/// # extern crate hyper_rustls;
7451/// # extern crate google_dns1 as dns1;
7452/// use dns1::api::ManagedZone;
7453/// # async fn dox() {
7454/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7455///
7456/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7457/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7458/// # .with_native_roots()
7459/// # .unwrap()
7460/// # .https_only()
7461/// # .enable_http2()
7462/// # .build();
7463///
7464/// # let executor = hyper_util::rt::TokioExecutor::new();
7465/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7466/// # secret,
7467/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7468/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7469/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7470/// # ),
7471/// # ).build().await.unwrap();
7472///
7473/// # let client = hyper_util::client::legacy::Client::builder(
7474/// # hyper_util::rt::TokioExecutor::new()
7475/// # )
7476/// # .build(
7477/// # hyper_rustls::HttpsConnectorBuilder::new()
7478/// # .with_native_roots()
7479/// # .unwrap()
7480/// # .https_or_http()
7481/// # .enable_http2()
7482/// # .build()
7483/// # );
7484/// # let mut hub = Dns::new(client, auth);
7485/// // As the method needs a request, you would usually fill it with the desired information
7486/// // into the respective structure. Some of the parts shown here might not be applicable !
7487/// // Values shown here are possibly random and not representative !
7488/// let mut req = ManagedZone::default();
7489///
7490/// // You can configure optional parameters by calling the respective setters at will, and
7491/// // execute the final call using `doit()`.
7492/// // Values shown here are possibly random and not representative !
7493/// let result = hub.managed_zones().patch(req, "project", "managedZone")
7494/// .client_operation_id("et")
7495/// .doit().await;
7496/// # }
7497/// ```
7498pub struct ManagedZonePatchCall<'a, C>
7499where
7500 C: 'a,
7501{
7502 hub: &'a Dns<C>,
7503 _request: ManagedZone,
7504 _project: String,
7505 _managed_zone: String,
7506 _client_operation_id: Option<String>,
7507 _delegate: Option<&'a mut dyn common::Delegate>,
7508 _additional_params: HashMap<String, String>,
7509 _scopes: BTreeSet<String>,
7510}
7511
7512impl<'a, C> common::CallBuilder for ManagedZonePatchCall<'a, C> {}
7513
7514impl<'a, C> ManagedZonePatchCall<'a, C>
7515where
7516 C: common::Connector,
7517{
7518 /// Perform the operation you have build so far.
7519 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7520 use std::borrow::Cow;
7521 use std::io::{Read, Seek};
7522
7523 use common::{url::Params, ToParts};
7524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7525
7526 let mut dd = common::DefaultDelegate;
7527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7528 dlg.begin(common::MethodInfo {
7529 id: "dns.managedZones.patch",
7530 http_method: hyper::Method::PATCH,
7531 });
7532
7533 for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() {
7534 if self._additional_params.contains_key(field) {
7535 dlg.finished(false);
7536 return Err(common::Error::FieldClash(field));
7537 }
7538 }
7539
7540 let mut params = Params::with_capacity(6 + self._additional_params.len());
7541 params.push("project", self._project);
7542 params.push("managedZone", self._managed_zone);
7543 if let Some(value) = self._client_operation_id.as_ref() {
7544 params.push("clientOperationId", value);
7545 }
7546
7547 params.extend(self._additional_params.iter());
7548
7549 params.push("alt", "json");
7550 let mut url =
7551 self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones/{managedZone}";
7552 if self._scopes.is_empty() {
7553 self._scopes
7554 .insert(Scope::CloudPlatform.as_ref().to_string());
7555 }
7556
7557 #[allow(clippy::single_element_loop)]
7558 for &(find_this, param_name) in
7559 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
7560 {
7561 url = params.uri_replacement(url, param_name, find_this, false);
7562 }
7563 {
7564 let to_remove = ["managedZone", "project"];
7565 params.remove_params(&to_remove);
7566 }
7567
7568 let url = params.parse_with_url(&url);
7569
7570 let mut json_mime_type = mime::APPLICATION_JSON;
7571 let mut request_value_reader = {
7572 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7573 common::remove_json_null_values(&mut value);
7574 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7575 serde_json::to_writer(&mut dst, &value).unwrap();
7576 dst
7577 };
7578 let request_size = request_value_reader
7579 .seek(std::io::SeekFrom::End(0))
7580 .unwrap();
7581 request_value_reader
7582 .seek(std::io::SeekFrom::Start(0))
7583 .unwrap();
7584
7585 loop {
7586 let token = match self
7587 .hub
7588 .auth
7589 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7590 .await
7591 {
7592 Ok(token) => token,
7593 Err(e) => match dlg.token(e) {
7594 Ok(token) => token,
7595 Err(e) => {
7596 dlg.finished(false);
7597 return Err(common::Error::MissingToken(e));
7598 }
7599 },
7600 };
7601 request_value_reader
7602 .seek(std::io::SeekFrom::Start(0))
7603 .unwrap();
7604 let mut req_result = {
7605 let client = &self.hub.client;
7606 dlg.pre_request();
7607 let mut req_builder = hyper::Request::builder()
7608 .method(hyper::Method::PATCH)
7609 .uri(url.as_str())
7610 .header(USER_AGENT, self.hub._user_agent.clone());
7611
7612 if let Some(token) = token.as_ref() {
7613 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7614 }
7615
7616 let request = req_builder
7617 .header(CONTENT_TYPE, json_mime_type.to_string())
7618 .header(CONTENT_LENGTH, request_size as u64)
7619 .body(common::to_body(
7620 request_value_reader.get_ref().clone().into(),
7621 ));
7622
7623 client.request(request.unwrap()).await
7624 };
7625
7626 match req_result {
7627 Err(err) => {
7628 if let common::Retry::After(d) = dlg.http_error(&err) {
7629 sleep(d).await;
7630 continue;
7631 }
7632 dlg.finished(false);
7633 return Err(common::Error::HttpError(err));
7634 }
7635 Ok(res) => {
7636 let (mut parts, body) = res.into_parts();
7637 let mut body = common::Body::new(body);
7638 if !parts.status.is_success() {
7639 let bytes = common::to_bytes(body).await.unwrap_or_default();
7640 let error = serde_json::from_str(&common::to_string(&bytes));
7641 let response = common::to_response(parts, bytes.into());
7642
7643 if let common::Retry::After(d) =
7644 dlg.http_failure(&response, error.as_ref().ok())
7645 {
7646 sleep(d).await;
7647 continue;
7648 }
7649
7650 dlg.finished(false);
7651
7652 return Err(match error {
7653 Ok(value) => common::Error::BadRequest(value),
7654 _ => common::Error::Failure(response),
7655 });
7656 }
7657 let response = {
7658 let bytes = common::to_bytes(body).await.unwrap_or_default();
7659 let encoded = common::to_string(&bytes);
7660 match serde_json::from_str(&encoded) {
7661 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7662 Err(error) => {
7663 dlg.response_json_decode_error(&encoded, &error);
7664 return Err(common::Error::JsonDecodeError(
7665 encoded.to_string(),
7666 error,
7667 ));
7668 }
7669 }
7670 };
7671
7672 dlg.finished(true);
7673 return Ok(response);
7674 }
7675 }
7676 }
7677 }
7678
7679 ///
7680 /// Sets the *request* property to the given value.
7681 ///
7682 /// Even though the property as already been set when instantiating this call,
7683 /// we provide this method for API completeness.
7684 pub fn request(mut self, new_value: ManagedZone) -> ManagedZonePatchCall<'a, C> {
7685 self._request = new_value;
7686 self
7687 }
7688 /// Identifies the project addressed by this request.
7689 ///
7690 /// Sets the *project* path property to the given value.
7691 ///
7692 /// Even though the property as already been set when instantiating this call,
7693 /// we provide this method for API completeness.
7694 pub fn project(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
7695 self._project = new_value.to_string();
7696 self
7697 }
7698 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
7699 ///
7700 /// Sets the *managed zone* path property to the given value.
7701 ///
7702 /// Even though the property as already been set when instantiating this call,
7703 /// we provide this method for API completeness.
7704 pub fn managed_zone(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
7705 self._managed_zone = new_value.to_string();
7706 self
7707 }
7708 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
7709 ///
7710 /// Sets the *client operation id* query property to the given value.
7711 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZonePatchCall<'a, C> {
7712 self._client_operation_id = Some(new_value.to_string());
7713 self
7714 }
7715 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7716 /// while executing the actual API request.
7717 ///
7718 /// ````text
7719 /// It should be used to handle progress information, and to implement a certain level of resilience.
7720 /// ````
7721 ///
7722 /// Sets the *delegate* property to the given value.
7723 pub fn delegate(
7724 mut self,
7725 new_value: &'a mut dyn common::Delegate,
7726 ) -> ManagedZonePatchCall<'a, C> {
7727 self._delegate = Some(new_value);
7728 self
7729 }
7730
7731 /// Set any additional parameter of the query string used in the request.
7732 /// It should be used to set parameters which are not yet available through their own
7733 /// setters.
7734 ///
7735 /// Please note that this method must not be used to set any of the known parameters
7736 /// which have their own setter method. If done anyway, the request will fail.
7737 ///
7738 /// # Additional Parameters
7739 ///
7740 /// * *$.xgafv* (query-string) - V1 error format.
7741 /// * *access_token* (query-string) - OAuth access token.
7742 /// * *alt* (query-string) - Data format for response.
7743 /// * *callback* (query-string) - JSONP
7744 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7745 /// * *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.
7746 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7747 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7748 /// * *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.
7749 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7750 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7751 pub fn param<T>(mut self, name: T, value: T) -> ManagedZonePatchCall<'a, C>
7752 where
7753 T: AsRef<str>,
7754 {
7755 self._additional_params
7756 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7757 self
7758 }
7759
7760 /// Identifies the authorization scope for the method you are building.
7761 ///
7762 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7763 /// [`Scope::CloudPlatform`].
7764 ///
7765 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7766 /// tokens for more than one scope.
7767 ///
7768 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7769 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7770 /// sufficient, a read-write scope will do as well.
7771 pub fn add_scope<St>(mut self, scope: St) -> ManagedZonePatchCall<'a, C>
7772 where
7773 St: AsRef<str>,
7774 {
7775 self._scopes.insert(String::from(scope.as_ref()));
7776 self
7777 }
7778 /// Identifies the authorization scope(s) for the method you are building.
7779 ///
7780 /// See [`Self::add_scope()`] for details.
7781 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZonePatchCall<'a, C>
7782 where
7783 I: IntoIterator<Item = St>,
7784 St: AsRef<str>,
7785 {
7786 self._scopes
7787 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7788 self
7789 }
7790
7791 /// Removes all scopes, and no default scope will be used either.
7792 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7793 /// for details).
7794 pub fn clear_scopes(mut self) -> ManagedZonePatchCall<'a, C> {
7795 self._scopes.clear();
7796 self
7797 }
7798}
7799
7800/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
7801///
7802/// A builder for the *setIamPolicy* method supported by a *managedZone* resource.
7803/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
7804///
7805/// # Example
7806///
7807/// Instantiate a resource method builder
7808///
7809/// ```test_harness,no_run
7810/// # extern crate hyper;
7811/// # extern crate hyper_rustls;
7812/// # extern crate google_dns1 as dns1;
7813/// use dns1::api::GoogleIamV1SetIamPolicyRequest;
7814/// # async fn dox() {
7815/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7816///
7817/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7818/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7819/// # .with_native_roots()
7820/// # .unwrap()
7821/// # .https_only()
7822/// # .enable_http2()
7823/// # .build();
7824///
7825/// # let executor = hyper_util::rt::TokioExecutor::new();
7826/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7827/// # secret,
7828/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7829/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7830/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7831/// # ),
7832/// # ).build().await.unwrap();
7833///
7834/// # let client = hyper_util::client::legacy::Client::builder(
7835/// # hyper_util::rt::TokioExecutor::new()
7836/// # )
7837/// # .build(
7838/// # hyper_rustls::HttpsConnectorBuilder::new()
7839/// # .with_native_roots()
7840/// # .unwrap()
7841/// # .https_or_http()
7842/// # .enable_http2()
7843/// # .build()
7844/// # );
7845/// # let mut hub = Dns::new(client, auth);
7846/// // As the method needs a request, you would usually fill it with the desired information
7847/// // into the respective structure. Some of the parts shown here might not be applicable !
7848/// // Values shown here are possibly random and not representative !
7849/// let mut req = GoogleIamV1SetIamPolicyRequest::default();
7850///
7851/// // You can configure optional parameters by calling the respective setters at will, and
7852/// // execute the final call using `doit()`.
7853/// // Values shown here are possibly random and not representative !
7854/// let result = hub.managed_zones().set_iam_policy(req, "resource")
7855/// .doit().await;
7856/// # }
7857/// ```
7858pub struct ManagedZoneSetIamPolicyCall<'a, C>
7859where
7860 C: 'a,
7861{
7862 hub: &'a Dns<C>,
7863 _request: GoogleIamV1SetIamPolicyRequest,
7864 _resource: String,
7865 _delegate: Option<&'a mut dyn common::Delegate>,
7866 _additional_params: HashMap<String, String>,
7867 _scopes: BTreeSet<String>,
7868}
7869
7870impl<'a, C> common::CallBuilder for ManagedZoneSetIamPolicyCall<'a, C> {}
7871
7872impl<'a, C> ManagedZoneSetIamPolicyCall<'a, C>
7873where
7874 C: common::Connector,
7875{
7876 /// Perform the operation you have build so far.
7877 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
7878 use std::borrow::Cow;
7879 use std::io::{Read, Seek};
7880
7881 use common::{url::Params, ToParts};
7882 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7883
7884 let mut dd = common::DefaultDelegate;
7885 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7886 dlg.begin(common::MethodInfo {
7887 id: "dns.managedZones.setIamPolicy",
7888 http_method: hyper::Method::POST,
7889 });
7890
7891 for &field in ["alt", "resource"].iter() {
7892 if self._additional_params.contains_key(field) {
7893 dlg.finished(false);
7894 return Err(common::Error::FieldClash(field));
7895 }
7896 }
7897
7898 let mut params = Params::with_capacity(4 + self._additional_params.len());
7899 params.push("resource", self._resource);
7900
7901 params.extend(self._additional_params.iter());
7902
7903 params.push("alt", "json");
7904 let mut url = self.hub._base_url.clone() + "dns/v1/{+resource}:setIamPolicy";
7905 if self._scopes.is_empty() {
7906 self._scopes
7907 .insert(Scope::CloudPlatform.as_ref().to_string());
7908 }
7909
7910 #[allow(clippy::single_element_loop)]
7911 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7912 url = params.uri_replacement(url, param_name, find_this, true);
7913 }
7914 {
7915 let to_remove = ["resource"];
7916 params.remove_params(&to_remove);
7917 }
7918
7919 let url = params.parse_with_url(&url);
7920
7921 let mut json_mime_type = mime::APPLICATION_JSON;
7922 let mut request_value_reader = {
7923 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7924 common::remove_json_null_values(&mut value);
7925 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7926 serde_json::to_writer(&mut dst, &value).unwrap();
7927 dst
7928 };
7929 let request_size = request_value_reader
7930 .seek(std::io::SeekFrom::End(0))
7931 .unwrap();
7932 request_value_reader
7933 .seek(std::io::SeekFrom::Start(0))
7934 .unwrap();
7935
7936 loop {
7937 let token = match self
7938 .hub
7939 .auth
7940 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7941 .await
7942 {
7943 Ok(token) => token,
7944 Err(e) => match dlg.token(e) {
7945 Ok(token) => token,
7946 Err(e) => {
7947 dlg.finished(false);
7948 return Err(common::Error::MissingToken(e));
7949 }
7950 },
7951 };
7952 request_value_reader
7953 .seek(std::io::SeekFrom::Start(0))
7954 .unwrap();
7955 let mut req_result = {
7956 let client = &self.hub.client;
7957 dlg.pre_request();
7958 let mut req_builder = hyper::Request::builder()
7959 .method(hyper::Method::POST)
7960 .uri(url.as_str())
7961 .header(USER_AGENT, self.hub._user_agent.clone());
7962
7963 if let Some(token) = token.as_ref() {
7964 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7965 }
7966
7967 let request = req_builder
7968 .header(CONTENT_TYPE, json_mime_type.to_string())
7969 .header(CONTENT_LENGTH, request_size as u64)
7970 .body(common::to_body(
7971 request_value_reader.get_ref().clone().into(),
7972 ));
7973
7974 client.request(request.unwrap()).await
7975 };
7976
7977 match req_result {
7978 Err(err) => {
7979 if let common::Retry::After(d) = dlg.http_error(&err) {
7980 sleep(d).await;
7981 continue;
7982 }
7983 dlg.finished(false);
7984 return Err(common::Error::HttpError(err));
7985 }
7986 Ok(res) => {
7987 let (mut parts, body) = res.into_parts();
7988 let mut body = common::Body::new(body);
7989 if !parts.status.is_success() {
7990 let bytes = common::to_bytes(body).await.unwrap_or_default();
7991 let error = serde_json::from_str(&common::to_string(&bytes));
7992 let response = common::to_response(parts, bytes.into());
7993
7994 if let common::Retry::After(d) =
7995 dlg.http_failure(&response, error.as_ref().ok())
7996 {
7997 sleep(d).await;
7998 continue;
7999 }
8000
8001 dlg.finished(false);
8002
8003 return Err(match error {
8004 Ok(value) => common::Error::BadRequest(value),
8005 _ => common::Error::Failure(response),
8006 });
8007 }
8008 let response = {
8009 let bytes = common::to_bytes(body).await.unwrap_or_default();
8010 let encoded = common::to_string(&bytes);
8011 match serde_json::from_str(&encoded) {
8012 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8013 Err(error) => {
8014 dlg.response_json_decode_error(&encoded, &error);
8015 return Err(common::Error::JsonDecodeError(
8016 encoded.to_string(),
8017 error,
8018 ));
8019 }
8020 }
8021 };
8022
8023 dlg.finished(true);
8024 return Ok(response);
8025 }
8026 }
8027 }
8028 }
8029
8030 ///
8031 /// Sets the *request* property to the given value.
8032 ///
8033 /// Even though the property as already been set when instantiating this call,
8034 /// we provide this method for API completeness.
8035 pub fn request(
8036 mut self,
8037 new_value: GoogleIamV1SetIamPolicyRequest,
8038 ) -> ManagedZoneSetIamPolicyCall<'a, C> {
8039 self._request = new_value;
8040 self
8041 }
8042 /// 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.
8043 ///
8044 /// Sets the *resource* path property to the given value.
8045 ///
8046 /// Even though the property as already been set when instantiating this call,
8047 /// we provide this method for API completeness.
8048 pub fn resource(mut self, new_value: &str) -> ManagedZoneSetIamPolicyCall<'a, C> {
8049 self._resource = new_value.to_string();
8050 self
8051 }
8052 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8053 /// while executing the actual API request.
8054 ///
8055 /// ````text
8056 /// It should be used to handle progress information, and to implement a certain level of resilience.
8057 /// ````
8058 ///
8059 /// Sets the *delegate* property to the given value.
8060 pub fn delegate(
8061 mut self,
8062 new_value: &'a mut dyn common::Delegate,
8063 ) -> ManagedZoneSetIamPolicyCall<'a, C> {
8064 self._delegate = Some(new_value);
8065 self
8066 }
8067
8068 /// Set any additional parameter of the query string used in the request.
8069 /// It should be used to set parameters which are not yet available through their own
8070 /// setters.
8071 ///
8072 /// Please note that this method must not be used to set any of the known parameters
8073 /// which have their own setter method. If done anyway, the request will fail.
8074 ///
8075 /// # Additional Parameters
8076 ///
8077 /// * *$.xgafv* (query-string) - V1 error format.
8078 /// * *access_token* (query-string) - OAuth access token.
8079 /// * *alt* (query-string) - Data format for response.
8080 /// * *callback* (query-string) - JSONP
8081 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8082 /// * *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.
8083 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8084 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8085 /// * *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.
8086 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8087 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8088 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneSetIamPolicyCall<'a, C>
8089 where
8090 T: AsRef<str>,
8091 {
8092 self._additional_params
8093 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8094 self
8095 }
8096
8097 /// Identifies the authorization scope for the method you are building.
8098 ///
8099 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8100 /// [`Scope::CloudPlatform`].
8101 ///
8102 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8103 /// tokens for more than one scope.
8104 ///
8105 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8106 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8107 /// sufficient, a read-write scope will do as well.
8108 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneSetIamPolicyCall<'a, C>
8109 where
8110 St: AsRef<str>,
8111 {
8112 self._scopes.insert(String::from(scope.as_ref()));
8113 self
8114 }
8115 /// Identifies the authorization scope(s) for the method you are building.
8116 ///
8117 /// See [`Self::add_scope()`] for details.
8118 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneSetIamPolicyCall<'a, C>
8119 where
8120 I: IntoIterator<Item = St>,
8121 St: AsRef<str>,
8122 {
8123 self._scopes
8124 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8125 self
8126 }
8127
8128 /// Removes all scopes, and no default scope will be used either.
8129 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8130 /// for details).
8131 pub fn clear_scopes(mut self) -> ManagedZoneSetIamPolicyCall<'a, C> {
8132 self._scopes.clear();
8133 self
8134 }
8135}
8136
8137/// 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.
8138///
8139/// A builder for the *testIamPermissions* method supported by a *managedZone* resource.
8140/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
8141///
8142/// # Example
8143///
8144/// Instantiate a resource method builder
8145///
8146/// ```test_harness,no_run
8147/// # extern crate hyper;
8148/// # extern crate hyper_rustls;
8149/// # extern crate google_dns1 as dns1;
8150/// use dns1::api::GoogleIamV1TestIamPermissionsRequest;
8151/// # async fn dox() {
8152/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8153///
8154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8155/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8156/// # .with_native_roots()
8157/// # .unwrap()
8158/// # .https_only()
8159/// # .enable_http2()
8160/// # .build();
8161///
8162/// # let executor = hyper_util::rt::TokioExecutor::new();
8163/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8164/// # secret,
8165/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8166/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8167/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8168/// # ),
8169/// # ).build().await.unwrap();
8170///
8171/// # let client = hyper_util::client::legacy::Client::builder(
8172/// # hyper_util::rt::TokioExecutor::new()
8173/// # )
8174/// # .build(
8175/// # hyper_rustls::HttpsConnectorBuilder::new()
8176/// # .with_native_roots()
8177/// # .unwrap()
8178/// # .https_or_http()
8179/// # .enable_http2()
8180/// # .build()
8181/// # );
8182/// # let mut hub = Dns::new(client, auth);
8183/// // As the method needs a request, you would usually fill it with the desired information
8184/// // into the respective structure. Some of the parts shown here might not be applicable !
8185/// // Values shown here are possibly random and not representative !
8186/// let mut req = GoogleIamV1TestIamPermissionsRequest::default();
8187///
8188/// // You can configure optional parameters by calling the respective setters at will, and
8189/// // execute the final call using `doit()`.
8190/// // Values shown here are possibly random and not representative !
8191/// let result = hub.managed_zones().test_iam_permissions(req, "resource")
8192/// .doit().await;
8193/// # }
8194/// ```
8195pub struct ManagedZoneTestIamPermissionCall<'a, C>
8196where
8197 C: 'a,
8198{
8199 hub: &'a Dns<C>,
8200 _request: GoogleIamV1TestIamPermissionsRequest,
8201 _resource: String,
8202 _delegate: Option<&'a mut dyn common::Delegate>,
8203 _additional_params: HashMap<String, String>,
8204 _scopes: BTreeSet<String>,
8205}
8206
8207impl<'a, C> common::CallBuilder for ManagedZoneTestIamPermissionCall<'a, C> {}
8208
8209impl<'a, C> ManagedZoneTestIamPermissionCall<'a, C>
8210where
8211 C: common::Connector,
8212{
8213 /// Perform the operation you have build so far.
8214 pub async fn doit(
8215 mut self,
8216 ) -> common::Result<(common::Response, GoogleIamV1TestIamPermissionsResponse)> {
8217 use std::borrow::Cow;
8218 use std::io::{Read, Seek};
8219
8220 use common::{url::Params, ToParts};
8221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8222
8223 let mut dd = common::DefaultDelegate;
8224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8225 dlg.begin(common::MethodInfo {
8226 id: "dns.managedZones.testIamPermissions",
8227 http_method: hyper::Method::POST,
8228 });
8229
8230 for &field in ["alt", "resource"].iter() {
8231 if self._additional_params.contains_key(field) {
8232 dlg.finished(false);
8233 return Err(common::Error::FieldClash(field));
8234 }
8235 }
8236
8237 let mut params = Params::with_capacity(4 + self._additional_params.len());
8238 params.push("resource", self._resource);
8239
8240 params.extend(self._additional_params.iter());
8241
8242 params.push("alt", "json");
8243 let mut url = self.hub._base_url.clone() + "dns/v1/{+resource}:testIamPermissions";
8244 if self._scopes.is_empty() {
8245 self._scopes
8246 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
8247 }
8248
8249 #[allow(clippy::single_element_loop)]
8250 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8251 url = params.uri_replacement(url, param_name, find_this, true);
8252 }
8253 {
8254 let to_remove = ["resource"];
8255 params.remove_params(&to_remove);
8256 }
8257
8258 let url = params.parse_with_url(&url);
8259
8260 let mut json_mime_type = mime::APPLICATION_JSON;
8261 let mut request_value_reader = {
8262 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8263 common::remove_json_null_values(&mut value);
8264 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8265 serde_json::to_writer(&mut dst, &value).unwrap();
8266 dst
8267 };
8268 let request_size = request_value_reader
8269 .seek(std::io::SeekFrom::End(0))
8270 .unwrap();
8271 request_value_reader
8272 .seek(std::io::SeekFrom::Start(0))
8273 .unwrap();
8274
8275 loop {
8276 let token = match self
8277 .hub
8278 .auth
8279 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8280 .await
8281 {
8282 Ok(token) => token,
8283 Err(e) => match dlg.token(e) {
8284 Ok(token) => token,
8285 Err(e) => {
8286 dlg.finished(false);
8287 return Err(common::Error::MissingToken(e));
8288 }
8289 },
8290 };
8291 request_value_reader
8292 .seek(std::io::SeekFrom::Start(0))
8293 .unwrap();
8294 let mut req_result = {
8295 let client = &self.hub.client;
8296 dlg.pre_request();
8297 let mut req_builder = hyper::Request::builder()
8298 .method(hyper::Method::POST)
8299 .uri(url.as_str())
8300 .header(USER_AGENT, self.hub._user_agent.clone());
8301
8302 if let Some(token) = token.as_ref() {
8303 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8304 }
8305
8306 let request = req_builder
8307 .header(CONTENT_TYPE, json_mime_type.to_string())
8308 .header(CONTENT_LENGTH, request_size as u64)
8309 .body(common::to_body(
8310 request_value_reader.get_ref().clone().into(),
8311 ));
8312
8313 client.request(request.unwrap()).await
8314 };
8315
8316 match req_result {
8317 Err(err) => {
8318 if let common::Retry::After(d) = dlg.http_error(&err) {
8319 sleep(d).await;
8320 continue;
8321 }
8322 dlg.finished(false);
8323 return Err(common::Error::HttpError(err));
8324 }
8325 Ok(res) => {
8326 let (mut parts, body) = res.into_parts();
8327 let mut body = common::Body::new(body);
8328 if !parts.status.is_success() {
8329 let bytes = common::to_bytes(body).await.unwrap_or_default();
8330 let error = serde_json::from_str(&common::to_string(&bytes));
8331 let response = common::to_response(parts, bytes.into());
8332
8333 if let common::Retry::After(d) =
8334 dlg.http_failure(&response, error.as_ref().ok())
8335 {
8336 sleep(d).await;
8337 continue;
8338 }
8339
8340 dlg.finished(false);
8341
8342 return Err(match error {
8343 Ok(value) => common::Error::BadRequest(value),
8344 _ => common::Error::Failure(response),
8345 });
8346 }
8347 let response = {
8348 let bytes = common::to_bytes(body).await.unwrap_or_default();
8349 let encoded = common::to_string(&bytes);
8350 match serde_json::from_str(&encoded) {
8351 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8352 Err(error) => {
8353 dlg.response_json_decode_error(&encoded, &error);
8354 return Err(common::Error::JsonDecodeError(
8355 encoded.to_string(),
8356 error,
8357 ));
8358 }
8359 }
8360 };
8361
8362 dlg.finished(true);
8363 return Ok(response);
8364 }
8365 }
8366 }
8367 }
8368
8369 ///
8370 /// Sets the *request* property to the given value.
8371 ///
8372 /// Even though the property as already been set when instantiating this call,
8373 /// we provide this method for API completeness.
8374 pub fn request(
8375 mut self,
8376 new_value: GoogleIamV1TestIamPermissionsRequest,
8377 ) -> ManagedZoneTestIamPermissionCall<'a, C> {
8378 self._request = new_value;
8379 self
8380 }
8381 /// 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.
8382 ///
8383 /// Sets the *resource* path property to the given value.
8384 ///
8385 /// Even though the property as already been set when instantiating this call,
8386 /// we provide this method for API completeness.
8387 pub fn resource(mut self, new_value: &str) -> ManagedZoneTestIamPermissionCall<'a, C> {
8388 self._resource = new_value.to_string();
8389 self
8390 }
8391 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8392 /// while executing the actual API request.
8393 ///
8394 /// ````text
8395 /// It should be used to handle progress information, and to implement a certain level of resilience.
8396 /// ````
8397 ///
8398 /// Sets the *delegate* property to the given value.
8399 pub fn delegate(
8400 mut self,
8401 new_value: &'a mut dyn common::Delegate,
8402 ) -> ManagedZoneTestIamPermissionCall<'a, C> {
8403 self._delegate = Some(new_value);
8404 self
8405 }
8406
8407 /// Set any additional parameter of the query string used in the request.
8408 /// It should be used to set parameters which are not yet available through their own
8409 /// setters.
8410 ///
8411 /// Please note that this method must not be used to set any of the known parameters
8412 /// which have their own setter method. If done anyway, the request will fail.
8413 ///
8414 /// # Additional Parameters
8415 ///
8416 /// * *$.xgafv* (query-string) - V1 error format.
8417 /// * *access_token* (query-string) - OAuth access token.
8418 /// * *alt* (query-string) - Data format for response.
8419 /// * *callback* (query-string) - JSONP
8420 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8421 /// * *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.
8422 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8423 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8424 /// * *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.
8425 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8426 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8427 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneTestIamPermissionCall<'a, C>
8428 where
8429 T: AsRef<str>,
8430 {
8431 self._additional_params
8432 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8433 self
8434 }
8435
8436 /// Identifies the authorization scope for the method you are building.
8437 ///
8438 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8439 /// [`Scope::NdevClouddnReadonly`].
8440 ///
8441 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8442 /// tokens for more than one scope.
8443 ///
8444 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8445 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8446 /// sufficient, a read-write scope will do as well.
8447 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneTestIamPermissionCall<'a, C>
8448 where
8449 St: AsRef<str>,
8450 {
8451 self._scopes.insert(String::from(scope.as_ref()));
8452 self
8453 }
8454 /// Identifies the authorization scope(s) for the method you are building.
8455 ///
8456 /// See [`Self::add_scope()`] for details.
8457 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneTestIamPermissionCall<'a, C>
8458 where
8459 I: IntoIterator<Item = St>,
8460 St: AsRef<str>,
8461 {
8462 self._scopes
8463 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8464 self
8465 }
8466
8467 /// Removes all scopes, and no default scope will be used either.
8468 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8469 /// for details).
8470 pub fn clear_scopes(mut self) -> ManagedZoneTestIamPermissionCall<'a, C> {
8471 self._scopes.clear();
8472 self
8473 }
8474}
8475
8476/// Updates an existing ManagedZone.
8477///
8478/// A builder for the *update* method supported by a *managedZone* resource.
8479/// It is not used directly, but through a [`ManagedZoneMethods`] instance.
8480///
8481/// # Example
8482///
8483/// Instantiate a resource method builder
8484///
8485/// ```test_harness,no_run
8486/// # extern crate hyper;
8487/// # extern crate hyper_rustls;
8488/// # extern crate google_dns1 as dns1;
8489/// use dns1::api::ManagedZone;
8490/// # async fn dox() {
8491/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8492///
8493/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8494/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8495/// # .with_native_roots()
8496/// # .unwrap()
8497/// # .https_only()
8498/// # .enable_http2()
8499/// # .build();
8500///
8501/// # let executor = hyper_util::rt::TokioExecutor::new();
8502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8503/// # secret,
8504/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8505/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8506/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8507/// # ),
8508/// # ).build().await.unwrap();
8509///
8510/// # let client = hyper_util::client::legacy::Client::builder(
8511/// # hyper_util::rt::TokioExecutor::new()
8512/// # )
8513/// # .build(
8514/// # hyper_rustls::HttpsConnectorBuilder::new()
8515/// # .with_native_roots()
8516/// # .unwrap()
8517/// # .https_or_http()
8518/// # .enable_http2()
8519/// # .build()
8520/// # );
8521/// # let mut hub = Dns::new(client, auth);
8522/// // As the method needs a request, you would usually fill it with the desired information
8523/// // into the respective structure. Some of the parts shown here might not be applicable !
8524/// // Values shown here are possibly random and not representative !
8525/// let mut req = ManagedZone::default();
8526///
8527/// // You can configure optional parameters by calling the respective setters at will, and
8528/// // execute the final call using `doit()`.
8529/// // Values shown here are possibly random and not representative !
8530/// let result = hub.managed_zones().update(req, "project", "managedZone")
8531/// .client_operation_id("duo")
8532/// .doit().await;
8533/// # }
8534/// ```
8535pub struct ManagedZoneUpdateCall<'a, C>
8536where
8537 C: 'a,
8538{
8539 hub: &'a Dns<C>,
8540 _request: ManagedZone,
8541 _project: String,
8542 _managed_zone: String,
8543 _client_operation_id: Option<String>,
8544 _delegate: Option<&'a mut dyn common::Delegate>,
8545 _additional_params: HashMap<String, String>,
8546 _scopes: BTreeSet<String>,
8547}
8548
8549impl<'a, C> common::CallBuilder for ManagedZoneUpdateCall<'a, C> {}
8550
8551impl<'a, C> ManagedZoneUpdateCall<'a, C>
8552where
8553 C: common::Connector,
8554{
8555 /// Perform the operation you have build so far.
8556 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8557 use std::borrow::Cow;
8558 use std::io::{Read, Seek};
8559
8560 use common::{url::Params, ToParts};
8561 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8562
8563 let mut dd = common::DefaultDelegate;
8564 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8565 dlg.begin(common::MethodInfo {
8566 id: "dns.managedZones.update",
8567 http_method: hyper::Method::PUT,
8568 });
8569
8570 for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() {
8571 if self._additional_params.contains_key(field) {
8572 dlg.finished(false);
8573 return Err(common::Error::FieldClash(field));
8574 }
8575 }
8576
8577 let mut params = Params::with_capacity(6 + self._additional_params.len());
8578 params.push("project", self._project);
8579 params.push("managedZone", self._managed_zone);
8580 if let Some(value) = self._client_operation_id.as_ref() {
8581 params.push("clientOperationId", value);
8582 }
8583
8584 params.extend(self._additional_params.iter());
8585
8586 params.push("alt", "json");
8587 let mut url =
8588 self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones/{managedZone}";
8589 if self._scopes.is_empty() {
8590 self._scopes
8591 .insert(Scope::CloudPlatform.as_ref().to_string());
8592 }
8593
8594 #[allow(clippy::single_element_loop)]
8595 for &(find_this, param_name) in
8596 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
8597 {
8598 url = params.uri_replacement(url, param_name, find_this, false);
8599 }
8600 {
8601 let to_remove = ["managedZone", "project"];
8602 params.remove_params(&to_remove);
8603 }
8604
8605 let url = params.parse_with_url(&url);
8606
8607 let mut json_mime_type = mime::APPLICATION_JSON;
8608 let mut request_value_reader = {
8609 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8610 common::remove_json_null_values(&mut value);
8611 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8612 serde_json::to_writer(&mut dst, &value).unwrap();
8613 dst
8614 };
8615 let request_size = request_value_reader
8616 .seek(std::io::SeekFrom::End(0))
8617 .unwrap();
8618 request_value_reader
8619 .seek(std::io::SeekFrom::Start(0))
8620 .unwrap();
8621
8622 loop {
8623 let token = match self
8624 .hub
8625 .auth
8626 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8627 .await
8628 {
8629 Ok(token) => token,
8630 Err(e) => match dlg.token(e) {
8631 Ok(token) => token,
8632 Err(e) => {
8633 dlg.finished(false);
8634 return Err(common::Error::MissingToken(e));
8635 }
8636 },
8637 };
8638 request_value_reader
8639 .seek(std::io::SeekFrom::Start(0))
8640 .unwrap();
8641 let mut req_result = {
8642 let client = &self.hub.client;
8643 dlg.pre_request();
8644 let mut req_builder = hyper::Request::builder()
8645 .method(hyper::Method::PUT)
8646 .uri(url.as_str())
8647 .header(USER_AGENT, self.hub._user_agent.clone());
8648
8649 if let Some(token) = token.as_ref() {
8650 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8651 }
8652
8653 let request = req_builder
8654 .header(CONTENT_TYPE, json_mime_type.to_string())
8655 .header(CONTENT_LENGTH, request_size as u64)
8656 .body(common::to_body(
8657 request_value_reader.get_ref().clone().into(),
8658 ));
8659
8660 client.request(request.unwrap()).await
8661 };
8662
8663 match req_result {
8664 Err(err) => {
8665 if let common::Retry::After(d) = dlg.http_error(&err) {
8666 sleep(d).await;
8667 continue;
8668 }
8669 dlg.finished(false);
8670 return Err(common::Error::HttpError(err));
8671 }
8672 Ok(res) => {
8673 let (mut parts, body) = res.into_parts();
8674 let mut body = common::Body::new(body);
8675 if !parts.status.is_success() {
8676 let bytes = common::to_bytes(body).await.unwrap_or_default();
8677 let error = serde_json::from_str(&common::to_string(&bytes));
8678 let response = common::to_response(parts, bytes.into());
8679
8680 if let common::Retry::After(d) =
8681 dlg.http_failure(&response, error.as_ref().ok())
8682 {
8683 sleep(d).await;
8684 continue;
8685 }
8686
8687 dlg.finished(false);
8688
8689 return Err(match error {
8690 Ok(value) => common::Error::BadRequest(value),
8691 _ => common::Error::Failure(response),
8692 });
8693 }
8694 let response = {
8695 let bytes = common::to_bytes(body).await.unwrap_or_default();
8696 let encoded = common::to_string(&bytes);
8697 match serde_json::from_str(&encoded) {
8698 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8699 Err(error) => {
8700 dlg.response_json_decode_error(&encoded, &error);
8701 return Err(common::Error::JsonDecodeError(
8702 encoded.to_string(),
8703 error,
8704 ));
8705 }
8706 }
8707 };
8708
8709 dlg.finished(true);
8710 return Ok(response);
8711 }
8712 }
8713 }
8714 }
8715
8716 ///
8717 /// Sets the *request* property to the given value.
8718 ///
8719 /// Even though the property as already been set when instantiating this call,
8720 /// we provide this method for API completeness.
8721 pub fn request(mut self, new_value: ManagedZone) -> ManagedZoneUpdateCall<'a, C> {
8722 self._request = new_value;
8723 self
8724 }
8725 /// Identifies the project addressed by this request.
8726 ///
8727 /// Sets the *project* path property to the given value.
8728 ///
8729 /// Even though the property as already been set when instantiating this call,
8730 /// we provide this method for API completeness.
8731 pub fn project(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
8732 self._project = new_value.to_string();
8733 self
8734 }
8735 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
8736 ///
8737 /// Sets the *managed zone* path property to the given value.
8738 ///
8739 /// Even though the property as already been set when instantiating this call,
8740 /// we provide this method for API completeness.
8741 pub fn managed_zone(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
8742 self._managed_zone = new_value.to_string();
8743 self
8744 }
8745 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
8746 ///
8747 /// Sets the *client operation id* query property to the given value.
8748 pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a, C> {
8749 self._client_operation_id = Some(new_value.to_string());
8750 self
8751 }
8752 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8753 /// while executing the actual API request.
8754 ///
8755 /// ````text
8756 /// It should be used to handle progress information, and to implement a certain level of resilience.
8757 /// ````
8758 ///
8759 /// Sets the *delegate* property to the given value.
8760 pub fn delegate(
8761 mut self,
8762 new_value: &'a mut dyn common::Delegate,
8763 ) -> ManagedZoneUpdateCall<'a, C> {
8764 self._delegate = Some(new_value);
8765 self
8766 }
8767
8768 /// Set any additional parameter of the query string used in the request.
8769 /// It should be used to set parameters which are not yet available through their own
8770 /// setters.
8771 ///
8772 /// Please note that this method must not be used to set any of the known parameters
8773 /// which have their own setter method. If done anyway, the request will fail.
8774 ///
8775 /// # Additional Parameters
8776 ///
8777 /// * *$.xgafv* (query-string) - V1 error format.
8778 /// * *access_token* (query-string) - OAuth access token.
8779 /// * *alt* (query-string) - Data format for response.
8780 /// * *callback* (query-string) - JSONP
8781 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8782 /// * *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.
8783 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8784 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8785 /// * *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.
8786 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8787 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8788 pub fn param<T>(mut self, name: T, value: T) -> ManagedZoneUpdateCall<'a, C>
8789 where
8790 T: AsRef<str>,
8791 {
8792 self._additional_params
8793 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8794 self
8795 }
8796
8797 /// Identifies the authorization scope for the method you are building.
8798 ///
8799 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8800 /// [`Scope::CloudPlatform`].
8801 ///
8802 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8803 /// tokens for more than one scope.
8804 ///
8805 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8806 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8807 /// sufficient, a read-write scope will do as well.
8808 pub fn add_scope<St>(mut self, scope: St) -> ManagedZoneUpdateCall<'a, C>
8809 where
8810 St: AsRef<str>,
8811 {
8812 self._scopes.insert(String::from(scope.as_ref()));
8813 self
8814 }
8815 /// Identifies the authorization scope(s) for the method you are building.
8816 ///
8817 /// See [`Self::add_scope()`] for details.
8818 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedZoneUpdateCall<'a, C>
8819 where
8820 I: IntoIterator<Item = St>,
8821 St: AsRef<str>,
8822 {
8823 self._scopes
8824 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8825 self
8826 }
8827
8828 /// Removes all scopes, and no default scope will be used either.
8829 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8830 /// for details).
8831 pub fn clear_scopes(mut self) -> ManagedZoneUpdateCall<'a, C> {
8832 self._scopes.clear();
8833 self
8834 }
8835}
8836
8837/// Creates a new policy.
8838///
8839/// A builder for the *create* method supported by a *policy* resource.
8840/// It is not used directly, but through a [`PolicyMethods`] instance.
8841///
8842/// # Example
8843///
8844/// Instantiate a resource method builder
8845///
8846/// ```test_harness,no_run
8847/// # extern crate hyper;
8848/// # extern crate hyper_rustls;
8849/// # extern crate google_dns1 as dns1;
8850/// use dns1::api::Policy;
8851/// # async fn dox() {
8852/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8853///
8854/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8855/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8856/// # .with_native_roots()
8857/// # .unwrap()
8858/// # .https_only()
8859/// # .enable_http2()
8860/// # .build();
8861///
8862/// # let executor = hyper_util::rt::TokioExecutor::new();
8863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8864/// # secret,
8865/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8866/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8867/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8868/// # ),
8869/// # ).build().await.unwrap();
8870///
8871/// # let client = hyper_util::client::legacy::Client::builder(
8872/// # hyper_util::rt::TokioExecutor::new()
8873/// # )
8874/// # .build(
8875/// # hyper_rustls::HttpsConnectorBuilder::new()
8876/// # .with_native_roots()
8877/// # .unwrap()
8878/// # .https_or_http()
8879/// # .enable_http2()
8880/// # .build()
8881/// # );
8882/// # let mut hub = Dns::new(client, auth);
8883/// // As the method needs a request, you would usually fill it with the desired information
8884/// // into the respective structure. Some of the parts shown here might not be applicable !
8885/// // Values shown here are possibly random and not representative !
8886/// let mut req = Policy::default();
8887///
8888/// // You can configure optional parameters by calling the respective setters at will, and
8889/// // execute the final call using `doit()`.
8890/// // Values shown here are possibly random and not representative !
8891/// let result = hub.policies().create(req, "project")
8892/// .client_operation_id("vero")
8893/// .doit().await;
8894/// # }
8895/// ```
8896pub struct PolicyCreateCall<'a, C>
8897where
8898 C: 'a,
8899{
8900 hub: &'a Dns<C>,
8901 _request: Policy,
8902 _project: String,
8903 _client_operation_id: Option<String>,
8904 _delegate: Option<&'a mut dyn common::Delegate>,
8905 _additional_params: HashMap<String, String>,
8906 _scopes: BTreeSet<String>,
8907}
8908
8909impl<'a, C> common::CallBuilder for PolicyCreateCall<'a, C> {}
8910
8911impl<'a, C> PolicyCreateCall<'a, C>
8912where
8913 C: common::Connector,
8914{
8915 /// Perform the operation you have build so far.
8916 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8917 use std::borrow::Cow;
8918 use std::io::{Read, Seek};
8919
8920 use common::{url::Params, ToParts};
8921 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8922
8923 let mut dd = common::DefaultDelegate;
8924 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8925 dlg.begin(common::MethodInfo {
8926 id: "dns.policies.create",
8927 http_method: hyper::Method::POST,
8928 });
8929
8930 for &field in ["alt", "project", "clientOperationId"].iter() {
8931 if self._additional_params.contains_key(field) {
8932 dlg.finished(false);
8933 return Err(common::Error::FieldClash(field));
8934 }
8935 }
8936
8937 let mut params = Params::with_capacity(5 + self._additional_params.len());
8938 params.push("project", self._project);
8939 if let Some(value) = self._client_operation_id.as_ref() {
8940 params.push("clientOperationId", value);
8941 }
8942
8943 params.extend(self._additional_params.iter());
8944
8945 params.push("alt", "json");
8946 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies";
8947 if self._scopes.is_empty() {
8948 self._scopes
8949 .insert(Scope::CloudPlatform.as_ref().to_string());
8950 }
8951
8952 #[allow(clippy::single_element_loop)]
8953 for &(find_this, param_name) in [("{project}", "project")].iter() {
8954 url = params.uri_replacement(url, param_name, find_this, false);
8955 }
8956 {
8957 let to_remove = ["project"];
8958 params.remove_params(&to_remove);
8959 }
8960
8961 let url = params.parse_with_url(&url);
8962
8963 let mut json_mime_type = mime::APPLICATION_JSON;
8964 let mut request_value_reader = {
8965 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8966 common::remove_json_null_values(&mut value);
8967 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8968 serde_json::to_writer(&mut dst, &value).unwrap();
8969 dst
8970 };
8971 let request_size = request_value_reader
8972 .seek(std::io::SeekFrom::End(0))
8973 .unwrap();
8974 request_value_reader
8975 .seek(std::io::SeekFrom::Start(0))
8976 .unwrap();
8977
8978 loop {
8979 let token = match self
8980 .hub
8981 .auth
8982 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8983 .await
8984 {
8985 Ok(token) => token,
8986 Err(e) => match dlg.token(e) {
8987 Ok(token) => token,
8988 Err(e) => {
8989 dlg.finished(false);
8990 return Err(common::Error::MissingToken(e));
8991 }
8992 },
8993 };
8994 request_value_reader
8995 .seek(std::io::SeekFrom::Start(0))
8996 .unwrap();
8997 let mut req_result = {
8998 let client = &self.hub.client;
8999 dlg.pre_request();
9000 let mut req_builder = hyper::Request::builder()
9001 .method(hyper::Method::POST)
9002 .uri(url.as_str())
9003 .header(USER_AGENT, self.hub._user_agent.clone());
9004
9005 if let Some(token) = token.as_ref() {
9006 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9007 }
9008
9009 let request = req_builder
9010 .header(CONTENT_TYPE, json_mime_type.to_string())
9011 .header(CONTENT_LENGTH, request_size as u64)
9012 .body(common::to_body(
9013 request_value_reader.get_ref().clone().into(),
9014 ));
9015
9016 client.request(request.unwrap()).await
9017 };
9018
9019 match req_result {
9020 Err(err) => {
9021 if let common::Retry::After(d) = dlg.http_error(&err) {
9022 sleep(d).await;
9023 continue;
9024 }
9025 dlg.finished(false);
9026 return Err(common::Error::HttpError(err));
9027 }
9028 Ok(res) => {
9029 let (mut parts, body) = res.into_parts();
9030 let mut body = common::Body::new(body);
9031 if !parts.status.is_success() {
9032 let bytes = common::to_bytes(body).await.unwrap_or_default();
9033 let error = serde_json::from_str(&common::to_string(&bytes));
9034 let response = common::to_response(parts, bytes.into());
9035
9036 if let common::Retry::After(d) =
9037 dlg.http_failure(&response, error.as_ref().ok())
9038 {
9039 sleep(d).await;
9040 continue;
9041 }
9042
9043 dlg.finished(false);
9044
9045 return Err(match error {
9046 Ok(value) => common::Error::BadRequest(value),
9047 _ => common::Error::Failure(response),
9048 });
9049 }
9050 let response = {
9051 let bytes = common::to_bytes(body).await.unwrap_or_default();
9052 let encoded = common::to_string(&bytes);
9053 match serde_json::from_str(&encoded) {
9054 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9055 Err(error) => {
9056 dlg.response_json_decode_error(&encoded, &error);
9057 return Err(common::Error::JsonDecodeError(
9058 encoded.to_string(),
9059 error,
9060 ));
9061 }
9062 }
9063 };
9064
9065 dlg.finished(true);
9066 return Ok(response);
9067 }
9068 }
9069 }
9070 }
9071
9072 ///
9073 /// Sets the *request* property to the given value.
9074 ///
9075 /// Even though the property as already been set when instantiating this call,
9076 /// we provide this method for API completeness.
9077 pub fn request(mut self, new_value: Policy) -> PolicyCreateCall<'a, C> {
9078 self._request = new_value;
9079 self
9080 }
9081 /// Identifies the project addressed by this request.
9082 ///
9083 /// Sets the *project* path property to the given value.
9084 ///
9085 /// Even though the property as already been set when instantiating this call,
9086 /// we provide this method for API completeness.
9087 pub fn project(mut self, new_value: &str) -> PolicyCreateCall<'a, C> {
9088 self._project = new_value.to_string();
9089 self
9090 }
9091 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
9092 ///
9093 /// Sets the *client operation id* query property to the given value.
9094 pub fn client_operation_id(mut self, new_value: &str) -> PolicyCreateCall<'a, C> {
9095 self._client_operation_id = Some(new_value.to_string());
9096 self
9097 }
9098 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9099 /// while executing the actual API request.
9100 ///
9101 /// ````text
9102 /// It should be used to handle progress information, and to implement a certain level of resilience.
9103 /// ````
9104 ///
9105 /// Sets the *delegate* property to the given value.
9106 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyCreateCall<'a, C> {
9107 self._delegate = Some(new_value);
9108 self
9109 }
9110
9111 /// Set any additional parameter of the query string used in the request.
9112 /// It should be used to set parameters which are not yet available through their own
9113 /// setters.
9114 ///
9115 /// Please note that this method must not be used to set any of the known parameters
9116 /// which have their own setter method. If done anyway, the request will fail.
9117 ///
9118 /// # Additional Parameters
9119 ///
9120 /// * *$.xgafv* (query-string) - V1 error format.
9121 /// * *access_token* (query-string) - OAuth access token.
9122 /// * *alt* (query-string) - Data format for response.
9123 /// * *callback* (query-string) - JSONP
9124 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9125 /// * *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.
9126 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9127 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9128 /// * *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.
9129 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9130 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9131 pub fn param<T>(mut self, name: T, value: T) -> PolicyCreateCall<'a, C>
9132 where
9133 T: AsRef<str>,
9134 {
9135 self._additional_params
9136 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9137 self
9138 }
9139
9140 /// Identifies the authorization scope for the method you are building.
9141 ///
9142 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9143 /// [`Scope::CloudPlatform`].
9144 ///
9145 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9146 /// tokens for more than one scope.
9147 ///
9148 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9149 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9150 /// sufficient, a read-write scope will do as well.
9151 pub fn add_scope<St>(mut self, scope: St) -> PolicyCreateCall<'a, C>
9152 where
9153 St: AsRef<str>,
9154 {
9155 self._scopes.insert(String::from(scope.as_ref()));
9156 self
9157 }
9158 /// Identifies the authorization scope(s) for the method you are building.
9159 ///
9160 /// See [`Self::add_scope()`] for details.
9161 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyCreateCall<'a, C>
9162 where
9163 I: IntoIterator<Item = St>,
9164 St: AsRef<str>,
9165 {
9166 self._scopes
9167 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9168 self
9169 }
9170
9171 /// Removes all scopes, and no default scope will be used either.
9172 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9173 /// for details).
9174 pub fn clear_scopes(mut self) -> PolicyCreateCall<'a, C> {
9175 self._scopes.clear();
9176 self
9177 }
9178}
9179
9180/// Deletes a previously created policy. Fails if the policy is still being referenced by a network.
9181///
9182/// A builder for the *delete* method supported by a *policy* resource.
9183/// It is not used directly, but through a [`PolicyMethods`] instance.
9184///
9185/// # Example
9186///
9187/// Instantiate a resource method builder
9188///
9189/// ```test_harness,no_run
9190/// # extern crate hyper;
9191/// # extern crate hyper_rustls;
9192/// # extern crate google_dns1 as dns1;
9193/// # async fn dox() {
9194/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9195///
9196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9197/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9198/// # .with_native_roots()
9199/// # .unwrap()
9200/// # .https_only()
9201/// # .enable_http2()
9202/// # .build();
9203///
9204/// # let executor = hyper_util::rt::TokioExecutor::new();
9205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9206/// # secret,
9207/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9208/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9209/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9210/// # ),
9211/// # ).build().await.unwrap();
9212///
9213/// # let client = hyper_util::client::legacy::Client::builder(
9214/// # hyper_util::rt::TokioExecutor::new()
9215/// # )
9216/// # .build(
9217/// # hyper_rustls::HttpsConnectorBuilder::new()
9218/// # .with_native_roots()
9219/// # .unwrap()
9220/// # .https_or_http()
9221/// # .enable_http2()
9222/// # .build()
9223/// # );
9224/// # let mut hub = Dns::new(client, auth);
9225/// // You can configure optional parameters by calling the respective setters at will, and
9226/// // execute the final call using `doit()`.
9227/// // Values shown here are possibly random and not representative !
9228/// let result = hub.policies().delete("project", "policy")
9229/// .client_operation_id("vero")
9230/// .doit().await;
9231/// # }
9232/// ```
9233pub struct PolicyDeleteCall<'a, C>
9234where
9235 C: 'a,
9236{
9237 hub: &'a Dns<C>,
9238 _project: String,
9239 _policy: String,
9240 _client_operation_id: Option<String>,
9241 _delegate: Option<&'a mut dyn common::Delegate>,
9242 _additional_params: HashMap<String, String>,
9243 _scopes: BTreeSet<String>,
9244}
9245
9246impl<'a, C> common::CallBuilder for PolicyDeleteCall<'a, C> {}
9247
9248impl<'a, C> PolicyDeleteCall<'a, C>
9249where
9250 C: common::Connector,
9251{
9252 /// Perform the operation you have build so far.
9253 pub async fn doit(mut self) -> common::Result<common::Response> {
9254 use std::borrow::Cow;
9255 use std::io::{Read, Seek};
9256
9257 use common::{url::Params, ToParts};
9258 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9259
9260 let mut dd = common::DefaultDelegate;
9261 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9262 dlg.begin(common::MethodInfo {
9263 id: "dns.policies.delete",
9264 http_method: hyper::Method::DELETE,
9265 });
9266
9267 for &field in ["project", "policy", "clientOperationId"].iter() {
9268 if self._additional_params.contains_key(field) {
9269 dlg.finished(false);
9270 return Err(common::Error::FieldClash(field));
9271 }
9272 }
9273
9274 let mut params = Params::with_capacity(4 + self._additional_params.len());
9275 params.push("project", self._project);
9276 params.push("policy", self._policy);
9277 if let Some(value) = self._client_operation_id.as_ref() {
9278 params.push("clientOperationId", value);
9279 }
9280
9281 params.extend(self._additional_params.iter());
9282
9283 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies/{policy}";
9284 if self._scopes.is_empty() {
9285 self._scopes
9286 .insert(Scope::CloudPlatform.as_ref().to_string());
9287 }
9288
9289 #[allow(clippy::single_element_loop)]
9290 for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() {
9291 url = params.uri_replacement(url, param_name, find_this, false);
9292 }
9293 {
9294 let to_remove = ["policy", "project"];
9295 params.remove_params(&to_remove);
9296 }
9297
9298 let url = params.parse_with_url(&url);
9299
9300 loop {
9301 let token = match self
9302 .hub
9303 .auth
9304 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9305 .await
9306 {
9307 Ok(token) => token,
9308 Err(e) => match dlg.token(e) {
9309 Ok(token) => token,
9310 Err(e) => {
9311 dlg.finished(false);
9312 return Err(common::Error::MissingToken(e));
9313 }
9314 },
9315 };
9316 let mut req_result = {
9317 let client = &self.hub.client;
9318 dlg.pre_request();
9319 let mut req_builder = hyper::Request::builder()
9320 .method(hyper::Method::DELETE)
9321 .uri(url.as_str())
9322 .header(USER_AGENT, self.hub._user_agent.clone());
9323
9324 if let Some(token) = token.as_ref() {
9325 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9326 }
9327
9328 let request = req_builder
9329 .header(CONTENT_LENGTH, 0_u64)
9330 .body(common::to_body::<String>(None));
9331
9332 client.request(request.unwrap()).await
9333 };
9334
9335 match req_result {
9336 Err(err) => {
9337 if let common::Retry::After(d) = dlg.http_error(&err) {
9338 sleep(d).await;
9339 continue;
9340 }
9341 dlg.finished(false);
9342 return Err(common::Error::HttpError(err));
9343 }
9344 Ok(res) => {
9345 let (mut parts, body) = res.into_parts();
9346 let mut body = common::Body::new(body);
9347 if !parts.status.is_success() {
9348 let bytes = common::to_bytes(body).await.unwrap_or_default();
9349 let error = serde_json::from_str(&common::to_string(&bytes));
9350 let response = common::to_response(parts, bytes.into());
9351
9352 if let common::Retry::After(d) =
9353 dlg.http_failure(&response, error.as_ref().ok())
9354 {
9355 sleep(d).await;
9356 continue;
9357 }
9358
9359 dlg.finished(false);
9360
9361 return Err(match error {
9362 Ok(value) => common::Error::BadRequest(value),
9363 _ => common::Error::Failure(response),
9364 });
9365 }
9366 let response = common::Response::from_parts(parts, body);
9367
9368 dlg.finished(true);
9369 return Ok(response);
9370 }
9371 }
9372 }
9373 }
9374
9375 /// Identifies the project addressed by this request.
9376 ///
9377 /// Sets the *project* path property to the given value.
9378 ///
9379 /// Even though the property as already been set when instantiating this call,
9380 /// we provide this method for API completeness.
9381 pub fn project(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9382 self._project = new_value.to_string();
9383 self
9384 }
9385 /// User given friendly name of the policy addressed by this request.
9386 ///
9387 /// Sets the *policy* path property to the given value.
9388 ///
9389 /// Even though the property as already been set when instantiating this call,
9390 /// we provide this method for API completeness.
9391 pub fn policy(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9392 self._policy = new_value.to_string();
9393 self
9394 }
9395 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
9396 ///
9397 /// Sets the *client operation id* query property to the given value.
9398 pub fn client_operation_id(mut self, new_value: &str) -> PolicyDeleteCall<'a, C> {
9399 self._client_operation_id = Some(new_value.to_string());
9400 self
9401 }
9402 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9403 /// while executing the actual API request.
9404 ///
9405 /// ````text
9406 /// It should be used to handle progress information, and to implement a certain level of resilience.
9407 /// ````
9408 ///
9409 /// Sets the *delegate* property to the given value.
9410 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyDeleteCall<'a, C> {
9411 self._delegate = Some(new_value);
9412 self
9413 }
9414
9415 /// Set any additional parameter of the query string used in the request.
9416 /// It should be used to set parameters which are not yet available through their own
9417 /// setters.
9418 ///
9419 /// Please note that this method must not be used to set any of the known parameters
9420 /// which have their own setter method. If done anyway, the request will fail.
9421 ///
9422 /// # Additional Parameters
9423 ///
9424 /// * *$.xgafv* (query-string) - V1 error format.
9425 /// * *access_token* (query-string) - OAuth access token.
9426 /// * *alt* (query-string) - Data format for response.
9427 /// * *callback* (query-string) - JSONP
9428 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9429 /// * *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.
9430 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9431 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9432 /// * *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.
9433 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9434 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9435 pub fn param<T>(mut self, name: T, value: T) -> PolicyDeleteCall<'a, C>
9436 where
9437 T: AsRef<str>,
9438 {
9439 self._additional_params
9440 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9441 self
9442 }
9443
9444 /// Identifies the authorization scope for the method you are building.
9445 ///
9446 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9447 /// [`Scope::CloudPlatform`].
9448 ///
9449 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9450 /// tokens for more than one scope.
9451 ///
9452 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9453 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9454 /// sufficient, a read-write scope will do as well.
9455 pub fn add_scope<St>(mut self, scope: St) -> PolicyDeleteCall<'a, C>
9456 where
9457 St: AsRef<str>,
9458 {
9459 self._scopes.insert(String::from(scope.as_ref()));
9460 self
9461 }
9462 /// Identifies the authorization scope(s) for the method you are building.
9463 ///
9464 /// See [`Self::add_scope()`] for details.
9465 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyDeleteCall<'a, C>
9466 where
9467 I: IntoIterator<Item = St>,
9468 St: AsRef<str>,
9469 {
9470 self._scopes
9471 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9472 self
9473 }
9474
9475 /// Removes all scopes, and no default scope will be used either.
9476 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9477 /// for details).
9478 pub fn clear_scopes(mut self) -> PolicyDeleteCall<'a, C> {
9479 self._scopes.clear();
9480 self
9481 }
9482}
9483
9484/// Fetches the representation of an existing policy.
9485///
9486/// A builder for the *get* method supported by a *policy* resource.
9487/// It is not used directly, but through a [`PolicyMethods`] instance.
9488///
9489/// # Example
9490///
9491/// Instantiate a resource method builder
9492///
9493/// ```test_harness,no_run
9494/// # extern crate hyper;
9495/// # extern crate hyper_rustls;
9496/// # extern crate google_dns1 as dns1;
9497/// # async fn dox() {
9498/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9499///
9500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9502/// # .with_native_roots()
9503/// # .unwrap()
9504/// # .https_only()
9505/// # .enable_http2()
9506/// # .build();
9507///
9508/// # let executor = hyper_util::rt::TokioExecutor::new();
9509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9510/// # secret,
9511/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9512/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9513/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9514/// # ),
9515/// # ).build().await.unwrap();
9516///
9517/// # let client = hyper_util::client::legacy::Client::builder(
9518/// # hyper_util::rt::TokioExecutor::new()
9519/// # )
9520/// # .build(
9521/// # hyper_rustls::HttpsConnectorBuilder::new()
9522/// # .with_native_roots()
9523/// # .unwrap()
9524/// # .https_or_http()
9525/// # .enable_http2()
9526/// # .build()
9527/// # );
9528/// # let mut hub = Dns::new(client, auth);
9529/// // You can configure optional parameters by calling the respective setters at will, and
9530/// // execute the final call using `doit()`.
9531/// // Values shown here are possibly random and not representative !
9532/// let result = hub.policies().get("project", "policy")
9533/// .client_operation_id("diam")
9534/// .doit().await;
9535/// # }
9536/// ```
9537pub struct PolicyGetCall<'a, C>
9538where
9539 C: 'a,
9540{
9541 hub: &'a Dns<C>,
9542 _project: String,
9543 _policy: String,
9544 _client_operation_id: Option<String>,
9545 _delegate: Option<&'a mut dyn common::Delegate>,
9546 _additional_params: HashMap<String, String>,
9547 _scopes: BTreeSet<String>,
9548}
9549
9550impl<'a, C> common::CallBuilder for PolicyGetCall<'a, C> {}
9551
9552impl<'a, C> PolicyGetCall<'a, C>
9553where
9554 C: common::Connector,
9555{
9556 /// Perform the operation you have build so far.
9557 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9558 use std::borrow::Cow;
9559 use std::io::{Read, Seek};
9560
9561 use common::{url::Params, ToParts};
9562 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9563
9564 let mut dd = common::DefaultDelegate;
9565 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9566 dlg.begin(common::MethodInfo {
9567 id: "dns.policies.get",
9568 http_method: hyper::Method::GET,
9569 });
9570
9571 for &field in ["alt", "project", "policy", "clientOperationId"].iter() {
9572 if self._additional_params.contains_key(field) {
9573 dlg.finished(false);
9574 return Err(common::Error::FieldClash(field));
9575 }
9576 }
9577
9578 let mut params = Params::with_capacity(5 + self._additional_params.len());
9579 params.push("project", self._project);
9580 params.push("policy", self._policy);
9581 if let Some(value) = self._client_operation_id.as_ref() {
9582 params.push("clientOperationId", value);
9583 }
9584
9585 params.extend(self._additional_params.iter());
9586
9587 params.push("alt", "json");
9588 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies/{policy}";
9589 if self._scopes.is_empty() {
9590 self._scopes
9591 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
9592 }
9593
9594 #[allow(clippy::single_element_loop)]
9595 for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() {
9596 url = params.uri_replacement(url, param_name, find_this, false);
9597 }
9598 {
9599 let to_remove = ["policy", "project"];
9600 params.remove_params(&to_remove);
9601 }
9602
9603 let url = params.parse_with_url(&url);
9604
9605 loop {
9606 let token = match self
9607 .hub
9608 .auth
9609 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9610 .await
9611 {
9612 Ok(token) => token,
9613 Err(e) => match dlg.token(e) {
9614 Ok(token) => token,
9615 Err(e) => {
9616 dlg.finished(false);
9617 return Err(common::Error::MissingToken(e));
9618 }
9619 },
9620 };
9621 let mut req_result = {
9622 let client = &self.hub.client;
9623 dlg.pre_request();
9624 let mut req_builder = hyper::Request::builder()
9625 .method(hyper::Method::GET)
9626 .uri(url.as_str())
9627 .header(USER_AGENT, self.hub._user_agent.clone());
9628
9629 if let Some(token) = token.as_ref() {
9630 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9631 }
9632
9633 let request = req_builder
9634 .header(CONTENT_LENGTH, 0_u64)
9635 .body(common::to_body::<String>(None));
9636
9637 client.request(request.unwrap()).await
9638 };
9639
9640 match req_result {
9641 Err(err) => {
9642 if let common::Retry::After(d) = dlg.http_error(&err) {
9643 sleep(d).await;
9644 continue;
9645 }
9646 dlg.finished(false);
9647 return Err(common::Error::HttpError(err));
9648 }
9649 Ok(res) => {
9650 let (mut parts, body) = res.into_parts();
9651 let mut body = common::Body::new(body);
9652 if !parts.status.is_success() {
9653 let bytes = common::to_bytes(body).await.unwrap_or_default();
9654 let error = serde_json::from_str(&common::to_string(&bytes));
9655 let response = common::to_response(parts, bytes.into());
9656
9657 if let common::Retry::After(d) =
9658 dlg.http_failure(&response, error.as_ref().ok())
9659 {
9660 sleep(d).await;
9661 continue;
9662 }
9663
9664 dlg.finished(false);
9665
9666 return Err(match error {
9667 Ok(value) => common::Error::BadRequest(value),
9668 _ => common::Error::Failure(response),
9669 });
9670 }
9671 let response = {
9672 let bytes = common::to_bytes(body).await.unwrap_or_default();
9673 let encoded = common::to_string(&bytes);
9674 match serde_json::from_str(&encoded) {
9675 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9676 Err(error) => {
9677 dlg.response_json_decode_error(&encoded, &error);
9678 return Err(common::Error::JsonDecodeError(
9679 encoded.to_string(),
9680 error,
9681 ));
9682 }
9683 }
9684 };
9685
9686 dlg.finished(true);
9687 return Ok(response);
9688 }
9689 }
9690 }
9691 }
9692
9693 /// Identifies the project addressed by this request.
9694 ///
9695 /// Sets the *project* path property to the given value.
9696 ///
9697 /// Even though the property as already been set when instantiating this call,
9698 /// we provide this method for API completeness.
9699 pub fn project(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
9700 self._project = new_value.to_string();
9701 self
9702 }
9703 /// User given friendly name of the policy addressed by this request.
9704 ///
9705 /// Sets the *policy* path property to the given value.
9706 ///
9707 /// Even though the property as already been set when instantiating this call,
9708 /// we provide this method for API completeness.
9709 pub fn policy(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
9710 self._policy = new_value.to_string();
9711 self
9712 }
9713 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
9714 ///
9715 /// Sets the *client operation id* query property to the given value.
9716 pub fn client_operation_id(mut self, new_value: &str) -> PolicyGetCall<'a, C> {
9717 self._client_operation_id = Some(new_value.to_string());
9718 self
9719 }
9720 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9721 /// while executing the actual API request.
9722 ///
9723 /// ````text
9724 /// It should be used to handle progress information, and to implement a certain level of resilience.
9725 /// ````
9726 ///
9727 /// Sets the *delegate* property to the given value.
9728 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyGetCall<'a, C> {
9729 self._delegate = Some(new_value);
9730 self
9731 }
9732
9733 /// Set any additional parameter of the query string used in the request.
9734 /// It should be used to set parameters which are not yet available through their own
9735 /// setters.
9736 ///
9737 /// Please note that this method must not be used to set any of the known parameters
9738 /// which have their own setter method. If done anyway, the request will fail.
9739 ///
9740 /// # Additional Parameters
9741 ///
9742 /// * *$.xgafv* (query-string) - V1 error format.
9743 /// * *access_token* (query-string) - OAuth access token.
9744 /// * *alt* (query-string) - Data format for response.
9745 /// * *callback* (query-string) - JSONP
9746 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9747 /// * *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.
9748 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9749 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9750 /// * *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.
9751 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9752 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9753 pub fn param<T>(mut self, name: T, value: T) -> PolicyGetCall<'a, C>
9754 where
9755 T: AsRef<str>,
9756 {
9757 self._additional_params
9758 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9759 self
9760 }
9761
9762 /// Identifies the authorization scope for the method you are building.
9763 ///
9764 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9765 /// [`Scope::NdevClouddnReadonly`].
9766 ///
9767 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9768 /// tokens for more than one scope.
9769 ///
9770 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9771 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9772 /// sufficient, a read-write scope will do as well.
9773 pub fn add_scope<St>(mut self, scope: St) -> PolicyGetCall<'a, C>
9774 where
9775 St: AsRef<str>,
9776 {
9777 self._scopes.insert(String::from(scope.as_ref()));
9778 self
9779 }
9780 /// Identifies the authorization scope(s) for the method you are building.
9781 ///
9782 /// See [`Self::add_scope()`] for details.
9783 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyGetCall<'a, C>
9784 where
9785 I: IntoIterator<Item = St>,
9786 St: AsRef<str>,
9787 {
9788 self._scopes
9789 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9790 self
9791 }
9792
9793 /// Removes all scopes, and no default scope will be used either.
9794 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9795 /// for details).
9796 pub fn clear_scopes(mut self) -> PolicyGetCall<'a, C> {
9797 self._scopes.clear();
9798 self
9799 }
9800}
9801
9802/// Enumerates all policies associated with a project.
9803///
9804/// A builder for the *list* method supported by a *policy* resource.
9805/// It is not used directly, but through a [`PolicyMethods`] instance.
9806///
9807/// # Example
9808///
9809/// Instantiate a resource method builder
9810///
9811/// ```test_harness,no_run
9812/// # extern crate hyper;
9813/// # extern crate hyper_rustls;
9814/// # extern crate google_dns1 as dns1;
9815/// # async fn dox() {
9816/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9817///
9818/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9819/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9820/// # .with_native_roots()
9821/// # .unwrap()
9822/// # .https_only()
9823/// # .enable_http2()
9824/// # .build();
9825///
9826/// # let executor = hyper_util::rt::TokioExecutor::new();
9827/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9828/// # secret,
9829/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9830/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9831/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9832/// # ),
9833/// # ).build().await.unwrap();
9834///
9835/// # let client = hyper_util::client::legacy::Client::builder(
9836/// # hyper_util::rt::TokioExecutor::new()
9837/// # )
9838/// # .build(
9839/// # hyper_rustls::HttpsConnectorBuilder::new()
9840/// # .with_native_roots()
9841/// # .unwrap()
9842/// # .https_or_http()
9843/// # .enable_http2()
9844/// # .build()
9845/// # );
9846/// # let mut hub = Dns::new(client, auth);
9847/// // You can configure optional parameters by calling the respective setters at will, and
9848/// // execute the final call using `doit()`.
9849/// // Values shown here are possibly random and not representative !
9850/// let result = hub.policies().list("project")
9851/// .page_token("ipsum")
9852/// .max_results(-23)
9853/// .doit().await;
9854/// # }
9855/// ```
9856pub struct PolicyListCall<'a, C>
9857where
9858 C: 'a,
9859{
9860 hub: &'a Dns<C>,
9861 _project: String,
9862 _page_token: Option<String>,
9863 _max_results: Option<i32>,
9864 _delegate: Option<&'a mut dyn common::Delegate>,
9865 _additional_params: HashMap<String, String>,
9866 _scopes: BTreeSet<String>,
9867}
9868
9869impl<'a, C> common::CallBuilder for PolicyListCall<'a, C> {}
9870
9871impl<'a, C> PolicyListCall<'a, C>
9872where
9873 C: common::Connector,
9874{
9875 /// Perform the operation you have build so far.
9876 pub async fn doit(mut self) -> common::Result<(common::Response, PoliciesListResponse)> {
9877 use std::borrow::Cow;
9878 use std::io::{Read, Seek};
9879
9880 use common::{url::Params, ToParts};
9881 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9882
9883 let mut dd = common::DefaultDelegate;
9884 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9885 dlg.begin(common::MethodInfo {
9886 id: "dns.policies.list",
9887 http_method: hyper::Method::GET,
9888 });
9889
9890 for &field in ["alt", "project", "pageToken", "maxResults"].iter() {
9891 if self._additional_params.contains_key(field) {
9892 dlg.finished(false);
9893 return Err(common::Error::FieldClash(field));
9894 }
9895 }
9896
9897 let mut params = Params::with_capacity(5 + self._additional_params.len());
9898 params.push("project", self._project);
9899 if let Some(value) = self._page_token.as_ref() {
9900 params.push("pageToken", value);
9901 }
9902 if let Some(value) = self._max_results.as_ref() {
9903 params.push("maxResults", value.to_string());
9904 }
9905
9906 params.extend(self._additional_params.iter());
9907
9908 params.push("alt", "json");
9909 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies";
9910 if self._scopes.is_empty() {
9911 self._scopes
9912 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
9913 }
9914
9915 #[allow(clippy::single_element_loop)]
9916 for &(find_this, param_name) in [("{project}", "project")].iter() {
9917 url = params.uri_replacement(url, param_name, find_this, false);
9918 }
9919 {
9920 let to_remove = ["project"];
9921 params.remove_params(&to_remove);
9922 }
9923
9924 let url = params.parse_with_url(&url);
9925
9926 loop {
9927 let token = match self
9928 .hub
9929 .auth
9930 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9931 .await
9932 {
9933 Ok(token) => token,
9934 Err(e) => match dlg.token(e) {
9935 Ok(token) => token,
9936 Err(e) => {
9937 dlg.finished(false);
9938 return Err(common::Error::MissingToken(e));
9939 }
9940 },
9941 };
9942 let mut req_result = {
9943 let client = &self.hub.client;
9944 dlg.pre_request();
9945 let mut req_builder = hyper::Request::builder()
9946 .method(hyper::Method::GET)
9947 .uri(url.as_str())
9948 .header(USER_AGENT, self.hub._user_agent.clone());
9949
9950 if let Some(token) = token.as_ref() {
9951 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9952 }
9953
9954 let request = req_builder
9955 .header(CONTENT_LENGTH, 0_u64)
9956 .body(common::to_body::<String>(None));
9957
9958 client.request(request.unwrap()).await
9959 };
9960
9961 match req_result {
9962 Err(err) => {
9963 if let common::Retry::After(d) = dlg.http_error(&err) {
9964 sleep(d).await;
9965 continue;
9966 }
9967 dlg.finished(false);
9968 return Err(common::Error::HttpError(err));
9969 }
9970 Ok(res) => {
9971 let (mut parts, body) = res.into_parts();
9972 let mut body = common::Body::new(body);
9973 if !parts.status.is_success() {
9974 let bytes = common::to_bytes(body).await.unwrap_or_default();
9975 let error = serde_json::from_str(&common::to_string(&bytes));
9976 let response = common::to_response(parts, bytes.into());
9977
9978 if let common::Retry::After(d) =
9979 dlg.http_failure(&response, error.as_ref().ok())
9980 {
9981 sleep(d).await;
9982 continue;
9983 }
9984
9985 dlg.finished(false);
9986
9987 return Err(match error {
9988 Ok(value) => common::Error::BadRequest(value),
9989 _ => common::Error::Failure(response),
9990 });
9991 }
9992 let response = {
9993 let bytes = common::to_bytes(body).await.unwrap_or_default();
9994 let encoded = common::to_string(&bytes);
9995 match serde_json::from_str(&encoded) {
9996 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9997 Err(error) => {
9998 dlg.response_json_decode_error(&encoded, &error);
9999 return Err(common::Error::JsonDecodeError(
10000 encoded.to_string(),
10001 error,
10002 ));
10003 }
10004 }
10005 };
10006
10007 dlg.finished(true);
10008 return Ok(response);
10009 }
10010 }
10011 }
10012 }
10013
10014 /// Identifies the project addressed by this request.
10015 ///
10016 /// Sets the *project* path property to the given value.
10017 ///
10018 /// Even though the property as already been set when instantiating this call,
10019 /// we provide this method for API completeness.
10020 pub fn project(mut self, new_value: &str) -> PolicyListCall<'a, C> {
10021 self._project = new_value.to_string();
10022 self
10023 }
10024 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
10025 ///
10026 /// Sets the *page token* query property to the given value.
10027 pub fn page_token(mut self, new_value: &str) -> PolicyListCall<'a, C> {
10028 self._page_token = Some(new_value.to_string());
10029 self
10030 }
10031 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
10032 ///
10033 /// Sets the *max results* query property to the given value.
10034 pub fn max_results(mut self, new_value: i32) -> PolicyListCall<'a, C> {
10035 self._max_results = Some(new_value);
10036 self
10037 }
10038 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10039 /// while executing the actual API request.
10040 ///
10041 /// ````text
10042 /// It should be used to handle progress information, and to implement a certain level of resilience.
10043 /// ````
10044 ///
10045 /// Sets the *delegate* property to the given value.
10046 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyListCall<'a, C> {
10047 self._delegate = Some(new_value);
10048 self
10049 }
10050
10051 /// Set any additional parameter of the query string used in the request.
10052 /// It should be used to set parameters which are not yet available through their own
10053 /// setters.
10054 ///
10055 /// Please note that this method must not be used to set any of the known parameters
10056 /// which have their own setter method. If done anyway, the request will fail.
10057 ///
10058 /// # Additional Parameters
10059 ///
10060 /// * *$.xgafv* (query-string) - V1 error format.
10061 /// * *access_token* (query-string) - OAuth access token.
10062 /// * *alt* (query-string) - Data format for response.
10063 /// * *callback* (query-string) - JSONP
10064 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10065 /// * *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.
10066 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10067 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10068 /// * *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.
10069 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10070 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10071 pub fn param<T>(mut self, name: T, value: T) -> PolicyListCall<'a, C>
10072 where
10073 T: AsRef<str>,
10074 {
10075 self._additional_params
10076 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10077 self
10078 }
10079
10080 /// Identifies the authorization scope for the method you are building.
10081 ///
10082 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10083 /// [`Scope::NdevClouddnReadonly`].
10084 ///
10085 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10086 /// tokens for more than one scope.
10087 ///
10088 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10089 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10090 /// sufficient, a read-write scope will do as well.
10091 pub fn add_scope<St>(mut self, scope: St) -> PolicyListCall<'a, C>
10092 where
10093 St: AsRef<str>,
10094 {
10095 self._scopes.insert(String::from(scope.as_ref()));
10096 self
10097 }
10098 /// Identifies the authorization scope(s) for the method you are building.
10099 ///
10100 /// See [`Self::add_scope()`] for details.
10101 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyListCall<'a, C>
10102 where
10103 I: IntoIterator<Item = St>,
10104 St: AsRef<str>,
10105 {
10106 self._scopes
10107 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10108 self
10109 }
10110
10111 /// Removes all scopes, and no default scope will be used either.
10112 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10113 /// for details).
10114 pub fn clear_scopes(mut self) -> PolicyListCall<'a, C> {
10115 self._scopes.clear();
10116 self
10117 }
10118}
10119
10120/// Applies a partial update to an existing policy.
10121///
10122/// A builder for the *patch* method supported by a *policy* resource.
10123/// It is not used directly, but through a [`PolicyMethods`] instance.
10124///
10125/// # Example
10126///
10127/// Instantiate a resource method builder
10128///
10129/// ```test_harness,no_run
10130/// # extern crate hyper;
10131/// # extern crate hyper_rustls;
10132/// # extern crate google_dns1 as dns1;
10133/// use dns1::api::Policy;
10134/// # async fn dox() {
10135/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10136///
10137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10139/// # .with_native_roots()
10140/// # .unwrap()
10141/// # .https_only()
10142/// # .enable_http2()
10143/// # .build();
10144///
10145/// # let executor = hyper_util::rt::TokioExecutor::new();
10146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10147/// # secret,
10148/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10149/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10150/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10151/// # ),
10152/// # ).build().await.unwrap();
10153///
10154/// # let client = hyper_util::client::legacy::Client::builder(
10155/// # hyper_util::rt::TokioExecutor::new()
10156/// # )
10157/// # .build(
10158/// # hyper_rustls::HttpsConnectorBuilder::new()
10159/// # .with_native_roots()
10160/// # .unwrap()
10161/// # .https_or_http()
10162/// # .enable_http2()
10163/// # .build()
10164/// # );
10165/// # let mut hub = Dns::new(client, auth);
10166/// // As the method needs a request, you would usually fill it with the desired information
10167/// // into the respective structure. Some of the parts shown here might not be applicable !
10168/// // Values shown here are possibly random and not representative !
10169/// let mut req = Policy::default();
10170///
10171/// // You can configure optional parameters by calling the respective setters at will, and
10172/// // execute the final call using `doit()`.
10173/// // Values shown here are possibly random and not representative !
10174/// let result = hub.policies().patch(req, "project", "policy")
10175/// .client_operation_id("voluptua.")
10176/// .doit().await;
10177/// # }
10178/// ```
10179pub struct PolicyPatchCall<'a, C>
10180where
10181 C: 'a,
10182{
10183 hub: &'a Dns<C>,
10184 _request: Policy,
10185 _project: String,
10186 _policy: String,
10187 _client_operation_id: Option<String>,
10188 _delegate: Option<&'a mut dyn common::Delegate>,
10189 _additional_params: HashMap<String, String>,
10190 _scopes: BTreeSet<String>,
10191}
10192
10193impl<'a, C> common::CallBuilder for PolicyPatchCall<'a, C> {}
10194
10195impl<'a, C> PolicyPatchCall<'a, C>
10196where
10197 C: common::Connector,
10198{
10199 /// Perform the operation you have build so far.
10200 pub async fn doit(mut self) -> common::Result<(common::Response, PoliciesPatchResponse)> {
10201 use std::borrow::Cow;
10202 use std::io::{Read, Seek};
10203
10204 use common::{url::Params, ToParts};
10205 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10206
10207 let mut dd = common::DefaultDelegate;
10208 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10209 dlg.begin(common::MethodInfo {
10210 id: "dns.policies.patch",
10211 http_method: hyper::Method::PATCH,
10212 });
10213
10214 for &field in ["alt", "project", "policy", "clientOperationId"].iter() {
10215 if self._additional_params.contains_key(field) {
10216 dlg.finished(false);
10217 return Err(common::Error::FieldClash(field));
10218 }
10219 }
10220
10221 let mut params = Params::with_capacity(6 + self._additional_params.len());
10222 params.push("project", self._project);
10223 params.push("policy", self._policy);
10224 if let Some(value) = self._client_operation_id.as_ref() {
10225 params.push("clientOperationId", value);
10226 }
10227
10228 params.extend(self._additional_params.iter());
10229
10230 params.push("alt", "json");
10231 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies/{policy}";
10232 if self._scopes.is_empty() {
10233 self._scopes
10234 .insert(Scope::CloudPlatform.as_ref().to_string());
10235 }
10236
10237 #[allow(clippy::single_element_loop)]
10238 for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() {
10239 url = params.uri_replacement(url, param_name, find_this, false);
10240 }
10241 {
10242 let to_remove = ["policy", "project"];
10243 params.remove_params(&to_remove);
10244 }
10245
10246 let url = params.parse_with_url(&url);
10247
10248 let mut json_mime_type = mime::APPLICATION_JSON;
10249 let mut request_value_reader = {
10250 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10251 common::remove_json_null_values(&mut value);
10252 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10253 serde_json::to_writer(&mut dst, &value).unwrap();
10254 dst
10255 };
10256 let request_size = request_value_reader
10257 .seek(std::io::SeekFrom::End(0))
10258 .unwrap();
10259 request_value_reader
10260 .seek(std::io::SeekFrom::Start(0))
10261 .unwrap();
10262
10263 loop {
10264 let token = match self
10265 .hub
10266 .auth
10267 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10268 .await
10269 {
10270 Ok(token) => token,
10271 Err(e) => match dlg.token(e) {
10272 Ok(token) => token,
10273 Err(e) => {
10274 dlg.finished(false);
10275 return Err(common::Error::MissingToken(e));
10276 }
10277 },
10278 };
10279 request_value_reader
10280 .seek(std::io::SeekFrom::Start(0))
10281 .unwrap();
10282 let mut req_result = {
10283 let client = &self.hub.client;
10284 dlg.pre_request();
10285 let mut req_builder = hyper::Request::builder()
10286 .method(hyper::Method::PATCH)
10287 .uri(url.as_str())
10288 .header(USER_AGENT, self.hub._user_agent.clone());
10289
10290 if let Some(token) = token.as_ref() {
10291 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10292 }
10293
10294 let request = req_builder
10295 .header(CONTENT_TYPE, json_mime_type.to_string())
10296 .header(CONTENT_LENGTH, request_size as u64)
10297 .body(common::to_body(
10298 request_value_reader.get_ref().clone().into(),
10299 ));
10300
10301 client.request(request.unwrap()).await
10302 };
10303
10304 match req_result {
10305 Err(err) => {
10306 if let common::Retry::After(d) = dlg.http_error(&err) {
10307 sleep(d).await;
10308 continue;
10309 }
10310 dlg.finished(false);
10311 return Err(common::Error::HttpError(err));
10312 }
10313 Ok(res) => {
10314 let (mut parts, body) = res.into_parts();
10315 let mut body = common::Body::new(body);
10316 if !parts.status.is_success() {
10317 let bytes = common::to_bytes(body).await.unwrap_or_default();
10318 let error = serde_json::from_str(&common::to_string(&bytes));
10319 let response = common::to_response(parts, bytes.into());
10320
10321 if let common::Retry::After(d) =
10322 dlg.http_failure(&response, error.as_ref().ok())
10323 {
10324 sleep(d).await;
10325 continue;
10326 }
10327
10328 dlg.finished(false);
10329
10330 return Err(match error {
10331 Ok(value) => common::Error::BadRequest(value),
10332 _ => common::Error::Failure(response),
10333 });
10334 }
10335 let response = {
10336 let bytes = common::to_bytes(body).await.unwrap_or_default();
10337 let encoded = common::to_string(&bytes);
10338 match serde_json::from_str(&encoded) {
10339 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10340 Err(error) => {
10341 dlg.response_json_decode_error(&encoded, &error);
10342 return Err(common::Error::JsonDecodeError(
10343 encoded.to_string(),
10344 error,
10345 ));
10346 }
10347 }
10348 };
10349
10350 dlg.finished(true);
10351 return Ok(response);
10352 }
10353 }
10354 }
10355 }
10356
10357 ///
10358 /// Sets the *request* property to the given value.
10359 ///
10360 /// Even though the property as already been set when instantiating this call,
10361 /// we provide this method for API completeness.
10362 pub fn request(mut self, new_value: Policy) -> PolicyPatchCall<'a, C> {
10363 self._request = new_value;
10364 self
10365 }
10366 /// Identifies the project addressed by this request.
10367 ///
10368 /// Sets the *project* path property to the given value.
10369 ///
10370 /// Even though the property as already been set when instantiating this call,
10371 /// we provide this method for API completeness.
10372 pub fn project(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10373 self._project = new_value.to_string();
10374 self
10375 }
10376 /// User given friendly name of the policy addressed by this request.
10377 ///
10378 /// Sets the *policy* path property to the given value.
10379 ///
10380 /// Even though the property as already been set when instantiating this call,
10381 /// we provide this method for API completeness.
10382 pub fn policy(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10383 self._policy = new_value.to_string();
10384 self
10385 }
10386 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
10387 ///
10388 /// Sets the *client operation id* query property to the given value.
10389 pub fn client_operation_id(mut self, new_value: &str) -> PolicyPatchCall<'a, C> {
10390 self._client_operation_id = Some(new_value.to_string());
10391 self
10392 }
10393 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10394 /// while executing the actual API request.
10395 ///
10396 /// ````text
10397 /// It should be used to handle progress information, and to implement a certain level of resilience.
10398 /// ````
10399 ///
10400 /// Sets the *delegate* property to the given value.
10401 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyPatchCall<'a, C> {
10402 self._delegate = Some(new_value);
10403 self
10404 }
10405
10406 /// Set any additional parameter of the query string used in the request.
10407 /// It should be used to set parameters which are not yet available through their own
10408 /// setters.
10409 ///
10410 /// Please note that this method must not be used to set any of the known parameters
10411 /// which have their own setter method. If done anyway, the request will fail.
10412 ///
10413 /// # Additional Parameters
10414 ///
10415 /// * *$.xgafv* (query-string) - V1 error format.
10416 /// * *access_token* (query-string) - OAuth access token.
10417 /// * *alt* (query-string) - Data format for response.
10418 /// * *callback* (query-string) - JSONP
10419 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10420 /// * *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.
10421 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10422 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10423 /// * *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.
10424 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10425 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10426 pub fn param<T>(mut self, name: T, value: T) -> PolicyPatchCall<'a, C>
10427 where
10428 T: AsRef<str>,
10429 {
10430 self._additional_params
10431 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10432 self
10433 }
10434
10435 /// Identifies the authorization scope for the method you are building.
10436 ///
10437 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10438 /// [`Scope::CloudPlatform`].
10439 ///
10440 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10441 /// tokens for more than one scope.
10442 ///
10443 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10444 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10445 /// sufficient, a read-write scope will do as well.
10446 pub fn add_scope<St>(mut self, scope: St) -> PolicyPatchCall<'a, C>
10447 where
10448 St: AsRef<str>,
10449 {
10450 self._scopes.insert(String::from(scope.as_ref()));
10451 self
10452 }
10453 /// Identifies the authorization scope(s) for the method you are building.
10454 ///
10455 /// See [`Self::add_scope()`] for details.
10456 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyPatchCall<'a, C>
10457 where
10458 I: IntoIterator<Item = St>,
10459 St: AsRef<str>,
10460 {
10461 self._scopes
10462 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10463 self
10464 }
10465
10466 /// Removes all scopes, and no default scope will be used either.
10467 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10468 /// for details).
10469 pub fn clear_scopes(mut self) -> PolicyPatchCall<'a, C> {
10470 self._scopes.clear();
10471 self
10472 }
10473}
10474
10475/// Updates an existing policy.
10476///
10477/// A builder for the *update* method supported by a *policy* resource.
10478/// It is not used directly, but through a [`PolicyMethods`] instance.
10479///
10480/// # Example
10481///
10482/// Instantiate a resource method builder
10483///
10484/// ```test_harness,no_run
10485/// # extern crate hyper;
10486/// # extern crate hyper_rustls;
10487/// # extern crate google_dns1 as dns1;
10488/// use dns1::api::Policy;
10489/// # async fn dox() {
10490/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10491///
10492/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10493/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10494/// # .with_native_roots()
10495/// # .unwrap()
10496/// # .https_only()
10497/// # .enable_http2()
10498/// # .build();
10499///
10500/// # let executor = hyper_util::rt::TokioExecutor::new();
10501/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10502/// # secret,
10503/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10504/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10505/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10506/// # ),
10507/// # ).build().await.unwrap();
10508///
10509/// # let client = hyper_util::client::legacy::Client::builder(
10510/// # hyper_util::rt::TokioExecutor::new()
10511/// # )
10512/// # .build(
10513/// # hyper_rustls::HttpsConnectorBuilder::new()
10514/// # .with_native_roots()
10515/// # .unwrap()
10516/// # .https_or_http()
10517/// # .enable_http2()
10518/// # .build()
10519/// # );
10520/// # let mut hub = Dns::new(client, auth);
10521/// // As the method needs a request, you would usually fill it with the desired information
10522/// // into the respective structure. Some of the parts shown here might not be applicable !
10523/// // Values shown here are possibly random and not representative !
10524/// let mut req = Policy::default();
10525///
10526/// // You can configure optional parameters by calling the respective setters at will, and
10527/// // execute the final call using `doit()`.
10528/// // Values shown here are possibly random and not representative !
10529/// let result = hub.policies().update(req, "project", "policy")
10530/// .client_operation_id("consetetur")
10531/// .doit().await;
10532/// # }
10533/// ```
10534pub struct PolicyUpdateCall<'a, C>
10535where
10536 C: 'a,
10537{
10538 hub: &'a Dns<C>,
10539 _request: Policy,
10540 _project: String,
10541 _policy: String,
10542 _client_operation_id: Option<String>,
10543 _delegate: Option<&'a mut dyn common::Delegate>,
10544 _additional_params: HashMap<String, String>,
10545 _scopes: BTreeSet<String>,
10546}
10547
10548impl<'a, C> common::CallBuilder for PolicyUpdateCall<'a, C> {}
10549
10550impl<'a, C> PolicyUpdateCall<'a, C>
10551where
10552 C: common::Connector,
10553{
10554 /// Perform the operation you have build so far.
10555 pub async fn doit(mut self) -> common::Result<(common::Response, PoliciesUpdateResponse)> {
10556 use std::borrow::Cow;
10557 use std::io::{Read, Seek};
10558
10559 use common::{url::Params, ToParts};
10560 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10561
10562 let mut dd = common::DefaultDelegate;
10563 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10564 dlg.begin(common::MethodInfo {
10565 id: "dns.policies.update",
10566 http_method: hyper::Method::PUT,
10567 });
10568
10569 for &field in ["alt", "project", "policy", "clientOperationId"].iter() {
10570 if self._additional_params.contains_key(field) {
10571 dlg.finished(false);
10572 return Err(common::Error::FieldClash(field));
10573 }
10574 }
10575
10576 let mut params = Params::with_capacity(6 + self._additional_params.len());
10577 params.push("project", self._project);
10578 params.push("policy", self._policy);
10579 if let Some(value) = self._client_operation_id.as_ref() {
10580 params.push("clientOperationId", value);
10581 }
10582
10583 params.extend(self._additional_params.iter());
10584
10585 params.push("alt", "json");
10586 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies/{policy}";
10587 if self._scopes.is_empty() {
10588 self._scopes
10589 .insert(Scope::CloudPlatform.as_ref().to_string());
10590 }
10591
10592 #[allow(clippy::single_element_loop)]
10593 for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() {
10594 url = params.uri_replacement(url, param_name, find_this, false);
10595 }
10596 {
10597 let to_remove = ["policy", "project"];
10598 params.remove_params(&to_remove);
10599 }
10600
10601 let url = params.parse_with_url(&url);
10602
10603 let mut json_mime_type = mime::APPLICATION_JSON;
10604 let mut request_value_reader = {
10605 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10606 common::remove_json_null_values(&mut value);
10607 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10608 serde_json::to_writer(&mut dst, &value).unwrap();
10609 dst
10610 };
10611 let request_size = request_value_reader
10612 .seek(std::io::SeekFrom::End(0))
10613 .unwrap();
10614 request_value_reader
10615 .seek(std::io::SeekFrom::Start(0))
10616 .unwrap();
10617
10618 loop {
10619 let token = match self
10620 .hub
10621 .auth
10622 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10623 .await
10624 {
10625 Ok(token) => token,
10626 Err(e) => match dlg.token(e) {
10627 Ok(token) => token,
10628 Err(e) => {
10629 dlg.finished(false);
10630 return Err(common::Error::MissingToken(e));
10631 }
10632 },
10633 };
10634 request_value_reader
10635 .seek(std::io::SeekFrom::Start(0))
10636 .unwrap();
10637 let mut req_result = {
10638 let client = &self.hub.client;
10639 dlg.pre_request();
10640 let mut req_builder = hyper::Request::builder()
10641 .method(hyper::Method::PUT)
10642 .uri(url.as_str())
10643 .header(USER_AGENT, self.hub._user_agent.clone());
10644
10645 if let Some(token) = token.as_ref() {
10646 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10647 }
10648
10649 let request = req_builder
10650 .header(CONTENT_TYPE, json_mime_type.to_string())
10651 .header(CONTENT_LENGTH, request_size as u64)
10652 .body(common::to_body(
10653 request_value_reader.get_ref().clone().into(),
10654 ));
10655
10656 client.request(request.unwrap()).await
10657 };
10658
10659 match req_result {
10660 Err(err) => {
10661 if let common::Retry::After(d) = dlg.http_error(&err) {
10662 sleep(d).await;
10663 continue;
10664 }
10665 dlg.finished(false);
10666 return Err(common::Error::HttpError(err));
10667 }
10668 Ok(res) => {
10669 let (mut parts, body) = res.into_parts();
10670 let mut body = common::Body::new(body);
10671 if !parts.status.is_success() {
10672 let bytes = common::to_bytes(body).await.unwrap_or_default();
10673 let error = serde_json::from_str(&common::to_string(&bytes));
10674 let response = common::to_response(parts, bytes.into());
10675
10676 if let common::Retry::After(d) =
10677 dlg.http_failure(&response, error.as_ref().ok())
10678 {
10679 sleep(d).await;
10680 continue;
10681 }
10682
10683 dlg.finished(false);
10684
10685 return Err(match error {
10686 Ok(value) => common::Error::BadRequest(value),
10687 _ => common::Error::Failure(response),
10688 });
10689 }
10690 let response = {
10691 let bytes = common::to_bytes(body).await.unwrap_or_default();
10692 let encoded = common::to_string(&bytes);
10693 match serde_json::from_str(&encoded) {
10694 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10695 Err(error) => {
10696 dlg.response_json_decode_error(&encoded, &error);
10697 return Err(common::Error::JsonDecodeError(
10698 encoded.to_string(),
10699 error,
10700 ));
10701 }
10702 }
10703 };
10704
10705 dlg.finished(true);
10706 return Ok(response);
10707 }
10708 }
10709 }
10710 }
10711
10712 ///
10713 /// Sets the *request* property to the given value.
10714 ///
10715 /// Even though the property as already been set when instantiating this call,
10716 /// we provide this method for API completeness.
10717 pub fn request(mut self, new_value: Policy) -> PolicyUpdateCall<'a, C> {
10718 self._request = new_value;
10719 self
10720 }
10721 /// Identifies the project addressed by this request.
10722 ///
10723 /// Sets the *project* path property to the given value.
10724 ///
10725 /// Even though the property as already been set when instantiating this call,
10726 /// we provide this method for API completeness.
10727 pub fn project(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
10728 self._project = new_value.to_string();
10729 self
10730 }
10731 /// User given friendly name of the policy addressed by this request.
10732 ///
10733 /// Sets the *policy* path property to the given value.
10734 ///
10735 /// Even though the property as already been set when instantiating this call,
10736 /// we provide this method for API completeness.
10737 pub fn policy(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
10738 self._policy = new_value.to_string();
10739 self
10740 }
10741 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
10742 ///
10743 /// Sets the *client operation id* query property to the given value.
10744 pub fn client_operation_id(mut self, new_value: &str) -> PolicyUpdateCall<'a, C> {
10745 self._client_operation_id = Some(new_value.to_string());
10746 self
10747 }
10748 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10749 /// while executing the actual API request.
10750 ///
10751 /// ````text
10752 /// It should be used to handle progress information, and to implement a certain level of resilience.
10753 /// ````
10754 ///
10755 /// Sets the *delegate* property to the given value.
10756 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PolicyUpdateCall<'a, C> {
10757 self._delegate = Some(new_value);
10758 self
10759 }
10760
10761 /// Set any additional parameter of the query string used in the request.
10762 /// It should be used to set parameters which are not yet available through their own
10763 /// setters.
10764 ///
10765 /// Please note that this method must not be used to set any of the known parameters
10766 /// which have their own setter method. If done anyway, the request will fail.
10767 ///
10768 /// # Additional Parameters
10769 ///
10770 /// * *$.xgafv* (query-string) - V1 error format.
10771 /// * *access_token* (query-string) - OAuth access token.
10772 /// * *alt* (query-string) - Data format for response.
10773 /// * *callback* (query-string) - JSONP
10774 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10775 /// * *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.
10776 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10777 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10778 /// * *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.
10779 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10780 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10781 pub fn param<T>(mut self, name: T, value: T) -> PolicyUpdateCall<'a, C>
10782 where
10783 T: AsRef<str>,
10784 {
10785 self._additional_params
10786 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10787 self
10788 }
10789
10790 /// Identifies the authorization scope for the method you are building.
10791 ///
10792 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10793 /// [`Scope::CloudPlatform`].
10794 ///
10795 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10796 /// tokens for more than one scope.
10797 ///
10798 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10799 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10800 /// sufficient, a read-write scope will do as well.
10801 pub fn add_scope<St>(mut self, scope: St) -> PolicyUpdateCall<'a, C>
10802 where
10803 St: AsRef<str>,
10804 {
10805 self._scopes.insert(String::from(scope.as_ref()));
10806 self
10807 }
10808 /// Identifies the authorization scope(s) for the method you are building.
10809 ///
10810 /// See [`Self::add_scope()`] for details.
10811 pub fn add_scopes<I, St>(mut self, scopes: I) -> PolicyUpdateCall<'a, C>
10812 where
10813 I: IntoIterator<Item = St>,
10814 St: AsRef<str>,
10815 {
10816 self._scopes
10817 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10818 self
10819 }
10820
10821 /// Removes all scopes, and no default scope will be used either.
10822 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10823 /// for details).
10824 pub fn clear_scopes(mut self) -> PolicyUpdateCall<'a, C> {
10825 self._scopes.clear();
10826 self
10827 }
10828}
10829
10830/// Fetches the representation of an existing Project.
10831///
10832/// A builder for the *get* method supported by a *project* resource.
10833/// It is not used directly, but through a [`ProjectMethods`] instance.
10834///
10835/// # Example
10836///
10837/// Instantiate a resource method builder
10838///
10839/// ```test_harness,no_run
10840/// # extern crate hyper;
10841/// # extern crate hyper_rustls;
10842/// # extern crate google_dns1 as dns1;
10843/// # async fn dox() {
10844/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10845///
10846/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10847/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10848/// # .with_native_roots()
10849/// # .unwrap()
10850/// # .https_only()
10851/// # .enable_http2()
10852/// # .build();
10853///
10854/// # let executor = hyper_util::rt::TokioExecutor::new();
10855/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10856/// # secret,
10857/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10858/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10859/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10860/// # ),
10861/// # ).build().await.unwrap();
10862///
10863/// # let client = hyper_util::client::legacy::Client::builder(
10864/// # hyper_util::rt::TokioExecutor::new()
10865/// # )
10866/// # .build(
10867/// # hyper_rustls::HttpsConnectorBuilder::new()
10868/// # .with_native_roots()
10869/// # .unwrap()
10870/// # .https_or_http()
10871/// # .enable_http2()
10872/// # .build()
10873/// # );
10874/// # let mut hub = Dns::new(client, auth);
10875/// // You can configure optional parameters by calling the respective setters at will, and
10876/// // execute the final call using `doit()`.
10877/// // Values shown here are possibly random and not representative !
10878/// let result = hub.projects().get("project")
10879/// .client_operation_id("sed")
10880/// .doit().await;
10881/// # }
10882/// ```
10883pub struct ProjectGetCall<'a, C>
10884where
10885 C: 'a,
10886{
10887 hub: &'a Dns<C>,
10888 _project: String,
10889 _client_operation_id: Option<String>,
10890 _delegate: Option<&'a mut dyn common::Delegate>,
10891 _additional_params: HashMap<String, String>,
10892 _scopes: BTreeSet<String>,
10893}
10894
10895impl<'a, C> common::CallBuilder for ProjectGetCall<'a, C> {}
10896
10897impl<'a, C> ProjectGetCall<'a, C>
10898where
10899 C: common::Connector,
10900{
10901 /// Perform the operation you have build so far.
10902 pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
10903 use std::borrow::Cow;
10904 use std::io::{Read, Seek};
10905
10906 use common::{url::Params, ToParts};
10907 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10908
10909 let mut dd = common::DefaultDelegate;
10910 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10911 dlg.begin(common::MethodInfo {
10912 id: "dns.projects.get",
10913 http_method: hyper::Method::GET,
10914 });
10915
10916 for &field in ["alt", "project", "clientOperationId"].iter() {
10917 if self._additional_params.contains_key(field) {
10918 dlg.finished(false);
10919 return Err(common::Error::FieldClash(field));
10920 }
10921 }
10922
10923 let mut params = Params::with_capacity(4 + self._additional_params.len());
10924 params.push("project", self._project);
10925 if let Some(value) = self._client_operation_id.as_ref() {
10926 params.push("clientOperationId", value);
10927 }
10928
10929 params.extend(self._additional_params.iter());
10930
10931 params.push("alt", "json");
10932 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}";
10933 if self._scopes.is_empty() {
10934 self._scopes
10935 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
10936 }
10937
10938 #[allow(clippy::single_element_loop)]
10939 for &(find_this, param_name) in [("{project}", "project")].iter() {
10940 url = params.uri_replacement(url, param_name, find_this, false);
10941 }
10942 {
10943 let to_remove = ["project"];
10944 params.remove_params(&to_remove);
10945 }
10946
10947 let url = params.parse_with_url(&url);
10948
10949 loop {
10950 let token = match self
10951 .hub
10952 .auth
10953 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10954 .await
10955 {
10956 Ok(token) => token,
10957 Err(e) => match dlg.token(e) {
10958 Ok(token) => token,
10959 Err(e) => {
10960 dlg.finished(false);
10961 return Err(common::Error::MissingToken(e));
10962 }
10963 },
10964 };
10965 let mut req_result = {
10966 let client = &self.hub.client;
10967 dlg.pre_request();
10968 let mut req_builder = hyper::Request::builder()
10969 .method(hyper::Method::GET)
10970 .uri(url.as_str())
10971 .header(USER_AGENT, self.hub._user_agent.clone());
10972
10973 if let Some(token) = token.as_ref() {
10974 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10975 }
10976
10977 let request = req_builder
10978 .header(CONTENT_LENGTH, 0_u64)
10979 .body(common::to_body::<String>(None));
10980
10981 client.request(request.unwrap()).await
10982 };
10983
10984 match req_result {
10985 Err(err) => {
10986 if let common::Retry::After(d) = dlg.http_error(&err) {
10987 sleep(d).await;
10988 continue;
10989 }
10990 dlg.finished(false);
10991 return Err(common::Error::HttpError(err));
10992 }
10993 Ok(res) => {
10994 let (mut parts, body) = res.into_parts();
10995 let mut body = common::Body::new(body);
10996 if !parts.status.is_success() {
10997 let bytes = common::to_bytes(body).await.unwrap_or_default();
10998 let error = serde_json::from_str(&common::to_string(&bytes));
10999 let response = common::to_response(parts, bytes.into());
11000
11001 if let common::Retry::After(d) =
11002 dlg.http_failure(&response, error.as_ref().ok())
11003 {
11004 sleep(d).await;
11005 continue;
11006 }
11007
11008 dlg.finished(false);
11009
11010 return Err(match error {
11011 Ok(value) => common::Error::BadRequest(value),
11012 _ => common::Error::Failure(response),
11013 });
11014 }
11015 let response = {
11016 let bytes = common::to_bytes(body).await.unwrap_or_default();
11017 let encoded = common::to_string(&bytes);
11018 match serde_json::from_str(&encoded) {
11019 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11020 Err(error) => {
11021 dlg.response_json_decode_error(&encoded, &error);
11022 return Err(common::Error::JsonDecodeError(
11023 encoded.to_string(),
11024 error,
11025 ));
11026 }
11027 }
11028 };
11029
11030 dlg.finished(true);
11031 return Ok(response);
11032 }
11033 }
11034 }
11035 }
11036
11037 /// Identifies the project addressed by this request.
11038 ///
11039 /// Sets the *project* path property to the given value.
11040 ///
11041 /// Even though the property as already been set when instantiating this call,
11042 /// we provide this method for API completeness.
11043 pub fn project(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
11044 self._project = new_value.to_string();
11045 self
11046 }
11047 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
11048 ///
11049 /// Sets the *client operation id* query property to the given value.
11050 pub fn client_operation_id(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
11051 self._client_operation_id = Some(new_value.to_string());
11052 self
11053 }
11054 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11055 /// while executing the actual API request.
11056 ///
11057 /// ````text
11058 /// It should be used to handle progress information, and to implement a certain level of resilience.
11059 /// ````
11060 ///
11061 /// Sets the *delegate* property to the given value.
11062 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectGetCall<'a, C> {
11063 self._delegate = Some(new_value);
11064 self
11065 }
11066
11067 /// Set any additional parameter of the query string used in the request.
11068 /// It should be used to set parameters which are not yet available through their own
11069 /// setters.
11070 ///
11071 /// Please note that this method must not be used to set any of the known parameters
11072 /// which have their own setter method. If done anyway, the request will fail.
11073 ///
11074 /// # Additional Parameters
11075 ///
11076 /// * *$.xgafv* (query-string) - V1 error format.
11077 /// * *access_token* (query-string) - OAuth access token.
11078 /// * *alt* (query-string) - Data format for response.
11079 /// * *callback* (query-string) - JSONP
11080 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11081 /// * *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.
11082 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11083 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11084 /// * *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.
11085 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11086 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11087 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetCall<'a, C>
11088 where
11089 T: AsRef<str>,
11090 {
11091 self._additional_params
11092 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11093 self
11094 }
11095
11096 /// Identifies the authorization scope for the method you are building.
11097 ///
11098 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11099 /// [`Scope::NdevClouddnReadonly`].
11100 ///
11101 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11102 /// tokens for more than one scope.
11103 ///
11104 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11105 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11106 /// sufficient, a read-write scope will do as well.
11107 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetCall<'a, C>
11108 where
11109 St: AsRef<str>,
11110 {
11111 self._scopes.insert(String::from(scope.as_ref()));
11112 self
11113 }
11114 /// Identifies the authorization scope(s) for the method you are building.
11115 ///
11116 /// See [`Self::add_scope()`] for details.
11117 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetCall<'a, C>
11118 where
11119 I: IntoIterator<Item = St>,
11120 St: AsRef<str>,
11121 {
11122 self._scopes
11123 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11124 self
11125 }
11126
11127 /// Removes all scopes, and no default scope will be used either.
11128 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11129 /// for details).
11130 pub fn clear_scopes(mut self) -> ProjectGetCall<'a, C> {
11131 self._scopes.clear();
11132 self
11133 }
11134}
11135
11136/// Creates a new ResourceRecordSet.
11137///
11138/// A builder for the *create* method supported by a *resourceRecordSet* resource.
11139/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
11140///
11141/// # Example
11142///
11143/// Instantiate a resource method builder
11144///
11145/// ```test_harness,no_run
11146/// # extern crate hyper;
11147/// # extern crate hyper_rustls;
11148/// # extern crate google_dns1 as dns1;
11149/// use dns1::api::ResourceRecordSet;
11150/// # async fn dox() {
11151/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11152///
11153/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11154/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11155/// # .with_native_roots()
11156/// # .unwrap()
11157/// # .https_only()
11158/// # .enable_http2()
11159/// # .build();
11160///
11161/// # let executor = hyper_util::rt::TokioExecutor::new();
11162/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11163/// # secret,
11164/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11165/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11166/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11167/// # ),
11168/// # ).build().await.unwrap();
11169///
11170/// # let client = hyper_util::client::legacy::Client::builder(
11171/// # hyper_util::rt::TokioExecutor::new()
11172/// # )
11173/// # .build(
11174/// # hyper_rustls::HttpsConnectorBuilder::new()
11175/// # .with_native_roots()
11176/// # .unwrap()
11177/// # .https_or_http()
11178/// # .enable_http2()
11179/// # .build()
11180/// # );
11181/// # let mut hub = Dns::new(client, auth);
11182/// // As the method needs a request, you would usually fill it with the desired information
11183/// // into the respective structure. Some of the parts shown here might not be applicable !
11184/// // Values shown here are possibly random and not representative !
11185/// let mut req = ResourceRecordSet::default();
11186///
11187/// // You can configure optional parameters by calling the respective setters at will, and
11188/// // execute the final call using `doit()`.
11189/// // Values shown here are possibly random and not representative !
11190/// let result = hub.resource_record_sets().create(req, "project", "managedZone")
11191/// .client_operation_id("gubergren")
11192/// .doit().await;
11193/// # }
11194/// ```
11195pub struct ResourceRecordSetCreateCall<'a, C>
11196where
11197 C: 'a,
11198{
11199 hub: &'a Dns<C>,
11200 _request: ResourceRecordSet,
11201 _project: String,
11202 _managed_zone: String,
11203 _client_operation_id: Option<String>,
11204 _delegate: Option<&'a mut dyn common::Delegate>,
11205 _additional_params: HashMap<String, String>,
11206 _scopes: BTreeSet<String>,
11207}
11208
11209impl<'a, C> common::CallBuilder for ResourceRecordSetCreateCall<'a, C> {}
11210
11211impl<'a, C> ResourceRecordSetCreateCall<'a, C>
11212where
11213 C: common::Connector,
11214{
11215 /// Perform the operation you have build so far.
11216 pub async fn doit(mut self) -> common::Result<(common::Response, ResourceRecordSet)> {
11217 use std::borrow::Cow;
11218 use std::io::{Read, Seek};
11219
11220 use common::{url::Params, ToParts};
11221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11222
11223 let mut dd = common::DefaultDelegate;
11224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11225 dlg.begin(common::MethodInfo {
11226 id: "dns.resourceRecordSets.create",
11227 http_method: hyper::Method::POST,
11228 });
11229
11230 for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() {
11231 if self._additional_params.contains_key(field) {
11232 dlg.finished(false);
11233 return Err(common::Error::FieldClash(field));
11234 }
11235 }
11236
11237 let mut params = Params::with_capacity(6 + self._additional_params.len());
11238 params.push("project", self._project);
11239 params.push("managedZone", self._managed_zone);
11240 if let Some(value) = self._client_operation_id.as_ref() {
11241 params.push("clientOperationId", value);
11242 }
11243
11244 params.extend(self._additional_params.iter());
11245
11246 params.push("alt", "json");
11247 let mut url = self.hub._base_url.clone()
11248 + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets";
11249 if self._scopes.is_empty() {
11250 self._scopes
11251 .insert(Scope::CloudPlatform.as_ref().to_string());
11252 }
11253
11254 #[allow(clippy::single_element_loop)]
11255 for &(find_this, param_name) in
11256 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
11257 {
11258 url = params.uri_replacement(url, param_name, find_this, false);
11259 }
11260 {
11261 let to_remove = ["managedZone", "project"];
11262 params.remove_params(&to_remove);
11263 }
11264
11265 let url = params.parse_with_url(&url);
11266
11267 let mut json_mime_type = mime::APPLICATION_JSON;
11268 let mut request_value_reader = {
11269 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11270 common::remove_json_null_values(&mut value);
11271 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11272 serde_json::to_writer(&mut dst, &value).unwrap();
11273 dst
11274 };
11275 let request_size = request_value_reader
11276 .seek(std::io::SeekFrom::End(0))
11277 .unwrap();
11278 request_value_reader
11279 .seek(std::io::SeekFrom::Start(0))
11280 .unwrap();
11281
11282 loop {
11283 let token = match self
11284 .hub
11285 .auth
11286 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11287 .await
11288 {
11289 Ok(token) => token,
11290 Err(e) => match dlg.token(e) {
11291 Ok(token) => token,
11292 Err(e) => {
11293 dlg.finished(false);
11294 return Err(common::Error::MissingToken(e));
11295 }
11296 },
11297 };
11298 request_value_reader
11299 .seek(std::io::SeekFrom::Start(0))
11300 .unwrap();
11301 let mut req_result = {
11302 let client = &self.hub.client;
11303 dlg.pre_request();
11304 let mut req_builder = hyper::Request::builder()
11305 .method(hyper::Method::POST)
11306 .uri(url.as_str())
11307 .header(USER_AGENT, self.hub._user_agent.clone());
11308
11309 if let Some(token) = token.as_ref() {
11310 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11311 }
11312
11313 let request = req_builder
11314 .header(CONTENT_TYPE, json_mime_type.to_string())
11315 .header(CONTENT_LENGTH, request_size as u64)
11316 .body(common::to_body(
11317 request_value_reader.get_ref().clone().into(),
11318 ));
11319
11320 client.request(request.unwrap()).await
11321 };
11322
11323 match req_result {
11324 Err(err) => {
11325 if let common::Retry::After(d) = dlg.http_error(&err) {
11326 sleep(d).await;
11327 continue;
11328 }
11329 dlg.finished(false);
11330 return Err(common::Error::HttpError(err));
11331 }
11332 Ok(res) => {
11333 let (mut parts, body) = res.into_parts();
11334 let mut body = common::Body::new(body);
11335 if !parts.status.is_success() {
11336 let bytes = common::to_bytes(body).await.unwrap_or_default();
11337 let error = serde_json::from_str(&common::to_string(&bytes));
11338 let response = common::to_response(parts, bytes.into());
11339
11340 if let common::Retry::After(d) =
11341 dlg.http_failure(&response, error.as_ref().ok())
11342 {
11343 sleep(d).await;
11344 continue;
11345 }
11346
11347 dlg.finished(false);
11348
11349 return Err(match error {
11350 Ok(value) => common::Error::BadRequest(value),
11351 _ => common::Error::Failure(response),
11352 });
11353 }
11354 let response = {
11355 let bytes = common::to_bytes(body).await.unwrap_or_default();
11356 let encoded = common::to_string(&bytes);
11357 match serde_json::from_str(&encoded) {
11358 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11359 Err(error) => {
11360 dlg.response_json_decode_error(&encoded, &error);
11361 return Err(common::Error::JsonDecodeError(
11362 encoded.to_string(),
11363 error,
11364 ));
11365 }
11366 }
11367 };
11368
11369 dlg.finished(true);
11370 return Ok(response);
11371 }
11372 }
11373 }
11374 }
11375
11376 ///
11377 /// Sets the *request* property to the given value.
11378 ///
11379 /// Even though the property as already been set when instantiating this call,
11380 /// we provide this method for API completeness.
11381 pub fn request(mut self, new_value: ResourceRecordSet) -> ResourceRecordSetCreateCall<'a, C> {
11382 self._request = new_value;
11383 self
11384 }
11385 /// Identifies the project addressed by this request.
11386 ///
11387 /// Sets the *project* path property to the given value.
11388 ///
11389 /// Even though the property as already been set when instantiating this call,
11390 /// we provide this method for API completeness.
11391 pub fn project(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11392 self._project = new_value.to_string();
11393 self
11394 }
11395 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
11396 ///
11397 /// Sets the *managed zone* path property to the given value.
11398 ///
11399 /// Even though the property as already been set when instantiating this call,
11400 /// we provide this method for API completeness.
11401 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11402 self._managed_zone = new_value.to_string();
11403 self
11404 }
11405 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
11406 ///
11407 /// Sets the *client operation id* query property to the given value.
11408 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetCreateCall<'a, C> {
11409 self._client_operation_id = Some(new_value.to_string());
11410 self
11411 }
11412 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11413 /// while executing the actual API request.
11414 ///
11415 /// ````text
11416 /// It should be used to handle progress information, and to implement a certain level of resilience.
11417 /// ````
11418 ///
11419 /// Sets the *delegate* property to the given value.
11420 pub fn delegate(
11421 mut self,
11422 new_value: &'a mut dyn common::Delegate,
11423 ) -> ResourceRecordSetCreateCall<'a, C> {
11424 self._delegate = Some(new_value);
11425 self
11426 }
11427
11428 /// Set any additional parameter of the query string used in the request.
11429 /// It should be used to set parameters which are not yet available through their own
11430 /// setters.
11431 ///
11432 /// Please note that this method must not be used to set any of the known parameters
11433 /// which have their own setter method. If done anyway, the request will fail.
11434 ///
11435 /// # Additional Parameters
11436 ///
11437 /// * *$.xgafv* (query-string) - V1 error format.
11438 /// * *access_token* (query-string) - OAuth access token.
11439 /// * *alt* (query-string) - Data format for response.
11440 /// * *callback* (query-string) - JSONP
11441 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11442 /// * *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.
11443 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11444 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11445 /// * *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.
11446 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11447 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11448 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetCreateCall<'a, C>
11449 where
11450 T: AsRef<str>,
11451 {
11452 self._additional_params
11453 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11454 self
11455 }
11456
11457 /// Identifies the authorization scope for the method you are building.
11458 ///
11459 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11460 /// [`Scope::CloudPlatform`].
11461 ///
11462 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11463 /// tokens for more than one scope.
11464 ///
11465 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11466 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11467 /// sufficient, a read-write scope will do as well.
11468 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetCreateCall<'a, C>
11469 where
11470 St: AsRef<str>,
11471 {
11472 self._scopes.insert(String::from(scope.as_ref()));
11473 self
11474 }
11475 /// Identifies the authorization scope(s) for the method you are building.
11476 ///
11477 /// See [`Self::add_scope()`] for details.
11478 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetCreateCall<'a, C>
11479 where
11480 I: IntoIterator<Item = St>,
11481 St: AsRef<str>,
11482 {
11483 self._scopes
11484 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11485 self
11486 }
11487
11488 /// Removes all scopes, and no default scope will be used either.
11489 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11490 /// for details).
11491 pub fn clear_scopes(mut self) -> ResourceRecordSetCreateCall<'a, C> {
11492 self._scopes.clear();
11493 self
11494 }
11495}
11496
11497/// Deletes a previously created ResourceRecordSet.
11498///
11499/// A builder for the *delete* method supported by a *resourceRecordSet* resource.
11500/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
11501///
11502/// # Example
11503///
11504/// Instantiate a resource method builder
11505///
11506/// ```test_harness,no_run
11507/// # extern crate hyper;
11508/// # extern crate hyper_rustls;
11509/// # extern crate google_dns1 as dns1;
11510/// # async fn dox() {
11511/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11512///
11513/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11514/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11515/// # .with_native_roots()
11516/// # .unwrap()
11517/// # .https_only()
11518/// # .enable_http2()
11519/// # .build();
11520///
11521/// # let executor = hyper_util::rt::TokioExecutor::new();
11522/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11523/// # secret,
11524/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11525/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11526/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11527/// # ),
11528/// # ).build().await.unwrap();
11529///
11530/// # let client = hyper_util::client::legacy::Client::builder(
11531/// # hyper_util::rt::TokioExecutor::new()
11532/// # )
11533/// # .build(
11534/// # hyper_rustls::HttpsConnectorBuilder::new()
11535/// # .with_native_roots()
11536/// # .unwrap()
11537/// # .https_or_http()
11538/// # .enable_http2()
11539/// # .build()
11540/// # );
11541/// # let mut hub = Dns::new(client, auth);
11542/// // You can configure optional parameters by calling the respective setters at will, and
11543/// // execute the final call using `doit()`.
11544/// // Values shown here are possibly random and not representative !
11545/// let result = hub.resource_record_sets().delete("project", "managedZone", "name", "type")
11546/// .client_operation_id("dolore")
11547/// .doit().await;
11548/// # }
11549/// ```
11550pub struct ResourceRecordSetDeleteCall<'a, C>
11551where
11552 C: 'a,
11553{
11554 hub: &'a Dns<C>,
11555 _project: String,
11556 _managed_zone: String,
11557 _name: String,
11558 _type_: String,
11559 _client_operation_id: Option<String>,
11560 _delegate: Option<&'a mut dyn common::Delegate>,
11561 _additional_params: HashMap<String, String>,
11562 _scopes: BTreeSet<String>,
11563}
11564
11565impl<'a, C> common::CallBuilder for ResourceRecordSetDeleteCall<'a, C> {}
11566
11567impl<'a, C> ResourceRecordSetDeleteCall<'a, C>
11568where
11569 C: common::Connector,
11570{
11571 /// Perform the operation you have build so far.
11572 pub async fn doit(
11573 mut self,
11574 ) -> common::Result<(common::Response, ResourceRecordSetsDeleteResponse)> {
11575 use std::borrow::Cow;
11576 use std::io::{Read, Seek};
11577
11578 use common::{url::Params, ToParts};
11579 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11580
11581 let mut dd = common::DefaultDelegate;
11582 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11583 dlg.begin(common::MethodInfo {
11584 id: "dns.resourceRecordSets.delete",
11585 http_method: hyper::Method::DELETE,
11586 });
11587
11588 for &field in [
11589 "alt",
11590 "project",
11591 "managedZone",
11592 "name",
11593 "type",
11594 "clientOperationId",
11595 ]
11596 .iter()
11597 {
11598 if self._additional_params.contains_key(field) {
11599 dlg.finished(false);
11600 return Err(common::Error::FieldClash(field));
11601 }
11602 }
11603
11604 let mut params = Params::with_capacity(7 + self._additional_params.len());
11605 params.push("project", self._project);
11606 params.push("managedZone", self._managed_zone);
11607 params.push("name", self._name);
11608 params.push("type", self._type_);
11609 if let Some(value) = self._client_operation_id.as_ref() {
11610 params.push("clientOperationId", value);
11611 }
11612
11613 params.extend(self._additional_params.iter());
11614
11615 params.push("alt", "json");
11616 let mut url = self.hub._base_url.clone()
11617 + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets/{name}/{type}";
11618 if self._scopes.is_empty() {
11619 self._scopes
11620 .insert(Scope::CloudPlatform.as_ref().to_string());
11621 }
11622
11623 #[allow(clippy::single_element_loop)]
11624 for &(find_this, param_name) in [
11625 ("{project}", "project"),
11626 ("{managedZone}", "managedZone"),
11627 ("{name}", "name"),
11628 ("{type}", "type"),
11629 ]
11630 .iter()
11631 {
11632 url = params.uri_replacement(url, param_name, find_this, false);
11633 }
11634 {
11635 let to_remove = ["type", "name", "managedZone", "project"];
11636 params.remove_params(&to_remove);
11637 }
11638
11639 let url = params.parse_with_url(&url);
11640
11641 loop {
11642 let token = match self
11643 .hub
11644 .auth
11645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11646 .await
11647 {
11648 Ok(token) => token,
11649 Err(e) => match dlg.token(e) {
11650 Ok(token) => token,
11651 Err(e) => {
11652 dlg.finished(false);
11653 return Err(common::Error::MissingToken(e));
11654 }
11655 },
11656 };
11657 let mut req_result = {
11658 let client = &self.hub.client;
11659 dlg.pre_request();
11660 let mut req_builder = hyper::Request::builder()
11661 .method(hyper::Method::DELETE)
11662 .uri(url.as_str())
11663 .header(USER_AGENT, self.hub._user_agent.clone());
11664
11665 if let Some(token) = token.as_ref() {
11666 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11667 }
11668
11669 let request = req_builder
11670 .header(CONTENT_LENGTH, 0_u64)
11671 .body(common::to_body::<String>(None));
11672
11673 client.request(request.unwrap()).await
11674 };
11675
11676 match req_result {
11677 Err(err) => {
11678 if let common::Retry::After(d) = dlg.http_error(&err) {
11679 sleep(d).await;
11680 continue;
11681 }
11682 dlg.finished(false);
11683 return Err(common::Error::HttpError(err));
11684 }
11685 Ok(res) => {
11686 let (mut parts, body) = res.into_parts();
11687 let mut body = common::Body::new(body);
11688 if !parts.status.is_success() {
11689 let bytes = common::to_bytes(body).await.unwrap_or_default();
11690 let error = serde_json::from_str(&common::to_string(&bytes));
11691 let response = common::to_response(parts, bytes.into());
11692
11693 if let common::Retry::After(d) =
11694 dlg.http_failure(&response, error.as_ref().ok())
11695 {
11696 sleep(d).await;
11697 continue;
11698 }
11699
11700 dlg.finished(false);
11701
11702 return Err(match error {
11703 Ok(value) => common::Error::BadRequest(value),
11704 _ => common::Error::Failure(response),
11705 });
11706 }
11707 let response = {
11708 let bytes = common::to_bytes(body).await.unwrap_or_default();
11709 let encoded = common::to_string(&bytes);
11710 match serde_json::from_str(&encoded) {
11711 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11712 Err(error) => {
11713 dlg.response_json_decode_error(&encoded, &error);
11714 return Err(common::Error::JsonDecodeError(
11715 encoded.to_string(),
11716 error,
11717 ));
11718 }
11719 }
11720 };
11721
11722 dlg.finished(true);
11723 return Ok(response);
11724 }
11725 }
11726 }
11727 }
11728
11729 /// Identifies the project addressed by this request.
11730 ///
11731 /// Sets the *project* path property to the given value.
11732 ///
11733 /// Even though the property as already been set when instantiating this call,
11734 /// we provide this method for API completeness.
11735 pub fn project(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
11736 self._project = new_value.to_string();
11737 self
11738 }
11739 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
11740 ///
11741 /// Sets the *managed zone* path property to the given value.
11742 ///
11743 /// Even though the property as already been set when instantiating this call,
11744 /// we provide this method for API completeness.
11745 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
11746 self._managed_zone = new_value.to_string();
11747 self
11748 }
11749 /// Fully qualified domain name.
11750 ///
11751 /// Sets the *name* path property to the given value.
11752 ///
11753 /// Even though the property as already been set when instantiating this call,
11754 /// we provide this method for API completeness.
11755 pub fn name(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
11756 self._name = new_value.to_string();
11757 self
11758 }
11759 /// RRSet type.
11760 ///
11761 /// Sets the *type* path property to the given value.
11762 ///
11763 /// Even though the property as already been set when instantiating this call,
11764 /// we provide this method for API completeness.
11765 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
11766 self._type_ = new_value.to_string();
11767 self
11768 }
11769 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
11770 ///
11771 /// Sets the *client operation id* query property to the given value.
11772 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetDeleteCall<'a, C> {
11773 self._client_operation_id = Some(new_value.to_string());
11774 self
11775 }
11776 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11777 /// while executing the actual API request.
11778 ///
11779 /// ````text
11780 /// It should be used to handle progress information, and to implement a certain level of resilience.
11781 /// ````
11782 ///
11783 /// Sets the *delegate* property to the given value.
11784 pub fn delegate(
11785 mut self,
11786 new_value: &'a mut dyn common::Delegate,
11787 ) -> ResourceRecordSetDeleteCall<'a, C> {
11788 self._delegate = Some(new_value);
11789 self
11790 }
11791
11792 /// Set any additional parameter of the query string used in the request.
11793 /// It should be used to set parameters which are not yet available through their own
11794 /// setters.
11795 ///
11796 /// Please note that this method must not be used to set any of the known parameters
11797 /// which have their own setter method. If done anyway, the request will fail.
11798 ///
11799 /// # Additional Parameters
11800 ///
11801 /// * *$.xgafv* (query-string) - V1 error format.
11802 /// * *access_token* (query-string) - OAuth access token.
11803 /// * *alt* (query-string) - Data format for response.
11804 /// * *callback* (query-string) - JSONP
11805 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11806 /// * *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.
11807 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11808 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11809 /// * *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.
11810 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11811 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11812 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetDeleteCall<'a, C>
11813 where
11814 T: AsRef<str>,
11815 {
11816 self._additional_params
11817 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11818 self
11819 }
11820
11821 /// Identifies the authorization scope for the method you are building.
11822 ///
11823 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11824 /// [`Scope::CloudPlatform`].
11825 ///
11826 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11827 /// tokens for more than one scope.
11828 ///
11829 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11830 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11831 /// sufficient, a read-write scope will do as well.
11832 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetDeleteCall<'a, C>
11833 where
11834 St: AsRef<str>,
11835 {
11836 self._scopes.insert(String::from(scope.as_ref()));
11837 self
11838 }
11839 /// Identifies the authorization scope(s) for the method you are building.
11840 ///
11841 /// See [`Self::add_scope()`] for details.
11842 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetDeleteCall<'a, C>
11843 where
11844 I: IntoIterator<Item = St>,
11845 St: AsRef<str>,
11846 {
11847 self._scopes
11848 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11849 self
11850 }
11851
11852 /// Removes all scopes, and no default scope will be used either.
11853 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11854 /// for details).
11855 pub fn clear_scopes(mut self) -> ResourceRecordSetDeleteCall<'a, C> {
11856 self._scopes.clear();
11857 self
11858 }
11859}
11860
11861/// Fetches the representation of an existing ResourceRecordSet.
11862///
11863/// A builder for the *get* method supported by a *resourceRecordSet* resource.
11864/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
11865///
11866/// # Example
11867///
11868/// Instantiate a resource method builder
11869///
11870/// ```test_harness,no_run
11871/// # extern crate hyper;
11872/// # extern crate hyper_rustls;
11873/// # extern crate google_dns1 as dns1;
11874/// # async fn dox() {
11875/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11876///
11877/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11878/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11879/// # .with_native_roots()
11880/// # .unwrap()
11881/// # .https_only()
11882/// # .enable_http2()
11883/// # .build();
11884///
11885/// # let executor = hyper_util::rt::TokioExecutor::new();
11886/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11887/// # secret,
11888/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11889/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11890/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11891/// # ),
11892/// # ).build().await.unwrap();
11893///
11894/// # let client = hyper_util::client::legacy::Client::builder(
11895/// # hyper_util::rt::TokioExecutor::new()
11896/// # )
11897/// # .build(
11898/// # hyper_rustls::HttpsConnectorBuilder::new()
11899/// # .with_native_roots()
11900/// # .unwrap()
11901/// # .https_or_http()
11902/// # .enable_http2()
11903/// # .build()
11904/// # );
11905/// # let mut hub = Dns::new(client, auth);
11906/// // You can configure optional parameters by calling the respective setters at will, and
11907/// // execute the final call using `doit()`.
11908/// // Values shown here are possibly random and not representative !
11909/// let result = hub.resource_record_sets().get("project", "managedZone", "name", "type")
11910/// .client_operation_id("sadipscing")
11911/// .doit().await;
11912/// # }
11913/// ```
11914pub struct ResourceRecordSetGetCall<'a, C>
11915where
11916 C: 'a,
11917{
11918 hub: &'a Dns<C>,
11919 _project: String,
11920 _managed_zone: String,
11921 _name: String,
11922 _type_: String,
11923 _client_operation_id: Option<String>,
11924 _delegate: Option<&'a mut dyn common::Delegate>,
11925 _additional_params: HashMap<String, String>,
11926 _scopes: BTreeSet<String>,
11927}
11928
11929impl<'a, C> common::CallBuilder for ResourceRecordSetGetCall<'a, C> {}
11930
11931impl<'a, C> ResourceRecordSetGetCall<'a, C>
11932where
11933 C: common::Connector,
11934{
11935 /// Perform the operation you have build so far.
11936 pub async fn doit(mut self) -> common::Result<(common::Response, ResourceRecordSet)> {
11937 use std::borrow::Cow;
11938 use std::io::{Read, Seek};
11939
11940 use common::{url::Params, ToParts};
11941 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11942
11943 let mut dd = common::DefaultDelegate;
11944 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11945 dlg.begin(common::MethodInfo {
11946 id: "dns.resourceRecordSets.get",
11947 http_method: hyper::Method::GET,
11948 });
11949
11950 for &field in [
11951 "alt",
11952 "project",
11953 "managedZone",
11954 "name",
11955 "type",
11956 "clientOperationId",
11957 ]
11958 .iter()
11959 {
11960 if self._additional_params.contains_key(field) {
11961 dlg.finished(false);
11962 return Err(common::Error::FieldClash(field));
11963 }
11964 }
11965
11966 let mut params = Params::with_capacity(7 + self._additional_params.len());
11967 params.push("project", self._project);
11968 params.push("managedZone", self._managed_zone);
11969 params.push("name", self._name);
11970 params.push("type", self._type_);
11971 if let Some(value) = self._client_operation_id.as_ref() {
11972 params.push("clientOperationId", value);
11973 }
11974
11975 params.extend(self._additional_params.iter());
11976
11977 params.push("alt", "json");
11978 let mut url = self.hub._base_url.clone()
11979 + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets/{name}/{type}";
11980 if self._scopes.is_empty() {
11981 self._scopes
11982 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
11983 }
11984
11985 #[allow(clippy::single_element_loop)]
11986 for &(find_this, param_name) in [
11987 ("{project}", "project"),
11988 ("{managedZone}", "managedZone"),
11989 ("{name}", "name"),
11990 ("{type}", "type"),
11991 ]
11992 .iter()
11993 {
11994 url = params.uri_replacement(url, param_name, find_this, false);
11995 }
11996 {
11997 let to_remove = ["type", "name", "managedZone", "project"];
11998 params.remove_params(&to_remove);
11999 }
12000
12001 let url = params.parse_with_url(&url);
12002
12003 loop {
12004 let token = match self
12005 .hub
12006 .auth
12007 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12008 .await
12009 {
12010 Ok(token) => token,
12011 Err(e) => match dlg.token(e) {
12012 Ok(token) => token,
12013 Err(e) => {
12014 dlg.finished(false);
12015 return Err(common::Error::MissingToken(e));
12016 }
12017 },
12018 };
12019 let mut req_result = {
12020 let client = &self.hub.client;
12021 dlg.pre_request();
12022 let mut req_builder = hyper::Request::builder()
12023 .method(hyper::Method::GET)
12024 .uri(url.as_str())
12025 .header(USER_AGENT, self.hub._user_agent.clone());
12026
12027 if let Some(token) = token.as_ref() {
12028 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12029 }
12030
12031 let request = req_builder
12032 .header(CONTENT_LENGTH, 0_u64)
12033 .body(common::to_body::<String>(None));
12034
12035 client.request(request.unwrap()).await
12036 };
12037
12038 match req_result {
12039 Err(err) => {
12040 if let common::Retry::After(d) = dlg.http_error(&err) {
12041 sleep(d).await;
12042 continue;
12043 }
12044 dlg.finished(false);
12045 return Err(common::Error::HttpError(err));
12046 }
12047 Ok(res) => {
12048 let (mut parts, body) = res.into_parts();
12049 let mut body = common::Body::new(body);
12050 if !parts.status.is_success() {
12051 let bytes = common::to_bytes(body).await.unwrap_or_default();
12052 let error = serde_json::from_str(&common::to_string(&bytes));
12053 let response = common::to_response(parts, bytes.into());
12054
12055 if let common::Retry::After(d) =
12056 dlg.http_failure(&response, error.as_ref().ok())
12057 {
12058 sleep(d).await;
12059 continue;
12060 }
12061
12062 dlg.finished(false);
12063
12064 return Err(match error {
12065 Ok(value) => common::Error::BadRequest(value),
12066 _ => common::Error::Failure(response),
12067 });
12068 }
12069 let response = {
12070 let bytes = common::to_bytes(body).await.unwrap_or_default();
12071 let encoded = common::to_string(&bytes);
12072 match serde_json::from_str(&encoded) {
12073 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12074 Err(error) => {
12075 dlg.response_json_decode_error(&encoded, &error);
12076 return Err(common::Error::JsonDecodeError(
12077 encoded.to_string(),
12078 error,
12079 ));
12080 }
12081 }
12082 };
12083
12084 dlg.finished(true);
12085 return Ok(response);
12086 }
12087 }
12088 }
12089 }
12090
12091 /// Identifies the project addressed by this request.
12092 ///
12093 /// Sets the *project* path property to the given value.
12094 ///
12095 /// Even though the property as already been set when instantiating this call,
12096 /// we provide this method for API completeness.
12097 pub fn project(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12098 self._project = new_value.to_string();
12099 self
12100 }
12101 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
12102 ///
12103 /// Sets the *managed zone* path property to the given value.
12104 ///
12105 /// Even though the property as already been set when instantiating this call,
12106 /// we provide this method for API completeness.
12107 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12108 self._managed_zone = new_value.to_string();
12109 self
12110 }
12111 /// Fully qualified domain name.
12112 ///
12113 /// Sets the *name* path property to the given value.
12114 ///
12115 /// Even though the property as already been set when instantiating this call,
12116 /// we provide this method for API completeness.
12117 pub fn name(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12118 self._name = new_value.to_string();
12119 self
12120 }
12121 /// RRSet type.
12122 ///
12123 /// Sets the *type* path property to the given value.
12124 ///
12125 /// Even though the property as already been set when instantiating this call,
12126 /// we provide this method for API completeness.
12127 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12128 self._type_ = new_value.to_string();
12129 self
12130 }
12131 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
12132 ///
12133 /// Sets the *client operation id* query property to the given value.
12134 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetGetCall<'a, C> {
12135 self._client_operation_id = Some(new_value.to_string());
12136 self
12137 }
12138 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12139 /// while executing the actual API request.
12140 ///
12141 /// ````text
12142 /// It should be used to handle progress information, and to implement a certain level of resilience.
12143 /// ````
12144 ///
12145 /// Sets the *delegate* property to the given value.
12146 pub fn delegate(
12147 mut self,
12148 new_value: &'a mut dyn common::Delegate,
12149 ) -> ResourceRecordSetGetCall<'a, C> {
12150 self._delegate = Some(new_value);
12151 self
12152 }
12153
12154 /// Set any additional parameter of the query string used in the request.
12155 /// It should be used to set parameters which are not yet available through their own
12156 /// setters.
12157 ///
12158 /// Please note that this method must not be used to set any of the known parameters
12159 /// which have their own setter method. If done anyway, the request will fail.
12160 ///
12161 /// # Additional Parameters
12162 ///
12163 /// * *$.xgafv* (query-string) - V1 error format.
12164 /// * *access_token* (query-string) - OAuth access token.
12165 /// * *alt* (query-string) - Data format for response.
12166 /// * *callback* (query-string) - JSONP
12167 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12168 /// * *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.
12169 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12170 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12171 /// * *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.
12172 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12173 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12174 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetGetCall<'a, C>
12175 where
12176 T: AsRef<str>,
12177 {
12178 self._additional_params
12179 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12180 self
12181 }
12182
12183 /// Identifies the authorization scope for the method you are building.
12184 ///
12185 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12186 /// [`Scope::NdevClouddnReadonly`].
12187 ///
12188 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12189 /// tokens for more than one scope.
12190 ///
12191 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12192 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12193 /// sufficient, a read-write scope will do as well.
12194 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetGetCall<'a, C>
12195 where
12196 St: AsRef<str>,
12197 {
12198 self._scopes.insert(String::from(scope.as_ref()));
12199 self
12200 }
12201 /// Identifies the authorization scope(s) for the method you are building.
12202 ///
12203 /// See [`Self::add_scope()`] for details.
12204 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetGetCall<'a, C>
12205 where
12206 I: IntoIterator<Item = St>,
12207 St: AsRef<str>,
12208 {
12209 self._scopes
12210 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12211 self
12212 }
12213
12214 /// Removes all scopes, and no default scope will be used either.
12215 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12216 /// for details).
12217 pub fn clear_scopes(mut self) -> ResourceRecordSetGetCall<'a, C> {
12218 self._scopes.clear();
12219 self
12220 }
12221}
12222
12223/// Enumerates ResourceRecordSets that you have created but not yet deleted.
12224///
12225/// A builder for the *list* method supported by a *resourceRecordSet* resource.
12226/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
12227///
12228/// # Example
12229///
12230/// Instantiate a resource method builder
12231///
12232/// ```test_harness,no_run
12233/// # extern crate hyper;
12234/// # extern crate hyper_rustls;
12235/// # extern crate google_dns1 as dns1;
12236/// # async fn dox() {
12237/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12238///
12239/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12240/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12241/// # .with_native_roots()
12242/// # .unwrap()
12243/// # .https_only()
12244/// # .enable_http2()
12245/// # .build();
12246///
12247/// # let executor = hyper_util::rt::TokioExecutor::new();
12248/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12249/// # secret,
12250/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12251/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12252/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12253/// # ),
12254/// # ).build().await.unwrap();
12255///
12256/// # let client = hyper_util::client::legacy::Client::builder(
12257/// # hyper_util::rt::TokioExecutor::new()
12258/// # )
12259/// # .build(
12260/// # hyper_rustls::HttpsConnectorBuilder::new()
12261/// # .with_native_roots()
12262/// # .unwrap()
12263/// # .https_or_http()
12264/// # .enable_http2()
12265/// # .build()
12266/// # );
12267/// # let mut hub = Dns::new(client, auth);
12268/// // You can configure optional parameters by calling the respective setters at will, and
12269/// // execute the final call using `doit()`.
12270/// // Values shown here are possibly random and not representative !
12271/// let result = hub.resource_record_sets().list("project", "managedZone")
12272/// .type_("no")
12273/// .page_token("est")
12274/// .name("At")
12275/// .max_results(-43)
12276/// .doit().await;
12277/// # }
12278/// ```
12279pub struct ResourceRecordSetListCall<'a, C>
12280where
12281 C: 'a,
12282{
12283 hub: &'a Dns<C>,
12284 _project: String,
12285 _managed_zone: String,
12286 _type_: Option<String>,
12287 _page_token: Option<String>,
12288 _name: Option<String>,
12289 _max_results: Option<i32>,
12290 _delegate: Option<&'a mut dyn common::Delegate>,
12291 _additional_params: HashMap<String, String>,
12292 _scopes: BTreeSet<String>,
12293}
12294
12295impl<'a, C> common::CallBuilder for ResourceRecordSetListCall<'a, C> {}
12296
12297impl<'a, C> ResourceRecordSetListCall<'a, C>
12298where
12299 C: common::Connector,
12300{
12301 /// Perform the operation you have build so far.
12302 pub async fn doit(
12303 mut self,
12304 ) -> common::Result<(common::Response, ResourceRecordSetsListResponse)> {
12305 use std::borrow::Cow;
12306 use std::io::{Read, Seek};
12307
12308 use common::{url::Params, ToParts};
12309 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12310
12311 let mut dd = common::DefaultDelegate;
12312 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12313 dlg.begin(common::MethodInfo {
12314 id: "dns.resourceRecordSets.list",
12315 http_method: hyper::Method::GET,
12316 });
12317
12318 for &field in [
12319 "alt",
12320 "project",
12321 "managedZone",
12322 "type",
12323 "pageToken",
12324 "name",
12325 "maxResults",
12326 ]
12327 .iter()
12328 {
12329 if self._additional_params.contains_key(field) {
12330 dlg.finished(false);
12331 return Err(common::Error::FieldClash(field));
12332 }
12333 }
12334
12335 let mut params = Params::with_capacity(8 + self._additional_params.len());
12336 params.push("project", self._project);
12337 params.push("managedZone", self._managed_zone);
12338 if let Some(value) = self._type_.as_ref() {
12339 params.push("type", value);
12340 }
12341 if let Some(value) = self._page_token.as_ref() {
12342 params.push("pageToken", value);
12343 }
12344 if let Some(value) = self._name.as_ref() {
12345 params.push("name", value);
12346 }
12347 if let Some(value) = self._max_results.as_ref() {
12348 params.push("maxResults", value.to_string());
12349 }
12350
12351 params.extend(self._additional_params.iter());
12352
12353 params.push("alt", "json");
12354 let mut url = self.hub._base_url.clone()
12355 + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets";
12356 if self._scopes.is_empty() {
12357 self._scopes
12358 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
12359 }
12360
12361 #[allow(clippy::single_element_loop)]
12362 for &(find_this, param_name) in
12363 [("{project}", "project"), ("{managedZone}", "managedZone")].iter()
12364 {
12365 url = params.uri_replacement(url, param_name, find_this, false);
12366 }
12367 {
12368 let to_remove = ["managedZone", "project"];
12369 params.remove_params(&to_remove);
12370 }
12371
12372 let url = params.parse_with_url(&url);
12373
12374 loop {
12375 let token = match self
12376 .hub
12377 .auth
12378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12379 .await
12380 {
12381 Ok(token) => token,
12382 Err(e) => match dlg.token(e) {
12383 Ok(token) => token,
12384 Err(e) => {
12385 dlg.finished(false);
12386 return Err(common::Error::MissingToken(e));
12387 }
12388 },
12389 };
12390 let mut req_result = {
12391 let client = &self.hub.client;
12392 dlg.pre_request();
12393 let mut req_builder = hyper::Request::builder()
12394 .method(hyper::Method::GET)
12395 .uri(url.as_str())
12396 .header(USER_AGENT, self.hub._user_agent.clone());
12397
12398 if let Some(token) = token.as_ref() {
12399 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12400 }
12401
12402 let request = req_builder
12403 .header(CONTENT_LENGTH, 0_u64)
12404 .body(common::to_body::<String>(None));
12405
12406 client.request(request.unwrap()).await
12407 };
12408
12409 match req_result {
12410 Err(err) => {
12411 if let common::Retry::After(d) = dlg.http_error(&err) {
12412 sleep(d).await;
12413 continue;
12414 }
12415 dlg.finished(false);
12416 return Err(common::Error::HttpError(err));
12417 }
12418 Ok(res) => {
12419 let (mut parts, body) = res.into_parts();
12420 let mut body = common::Body::new(body);
12421 if !parts.status.is_success() {
12422 let bytes = common::to_bytes(body).await.unwrap_or_default();
12423 let error = serde_json::from_str(&common::to_string(&bytes));
12424 let response = common::to_response(parts, bytes.into());
12425
12426 if let common::Retry::After(d) =
12427 dlg.http_failure(&response, error.as_ref().ok())
12428 {
12429 sleep(d).await;
12430 continue;
12431 }
12432
12433 dlg.finished(false);
12434
12435 return Err(match error {
12436 Ok(value) => common::Error::BadRequest(value),
12437 _ => common::Error::Failure(response),
12438 });
12439 }
12440 let response = {
12441 let bytes = common::to_bytes(body).await.unwrap_or_default();
12442 let encoded = common::to_string(&bytes);
12443 match serde_json::from_str(&encoded) {
12444 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12445 Err(error) => {
12446 dlg.response_json_decode_error(&encoded, &error);
12447 return Err(common::Error::JsonDecodeError(
12448 encoded.to_string(),
12449 error,
12450 ));
12451 }
12452 }
12453 };
12454
12455 dlg.finished(true);
12456 return Ok(response);
12457 }
12458 }
12459 }
12460 }
12461
12462 /// Identifies the project addressed by this request.
12463 ///
12464 /// Sets the *project* path property to the given value.
12465 ///
12466 /// Even though the property as already been set when instantiating this call,
12467 /// we provide this method for API completeness.
12468 pub fn project(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
12469 self._project = new_value.to_string();
12470 self
12471 }
12472 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
12473 ///
12474 /// Sets the *managed zone* path property to the given value.
12475 ///
12476 /// Even though the property as already been set when instantiating this call,
12477 /// we provide this method for API completeness.
12478 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
12479 self._managed_zone = new_value.to_string();
12480 self
12481 }
12482 /// 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.
12483 ///
12484 /// Sets the *type* query property to the given value.
12485 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
12486 self._type_ = Some(new_value.to_string());
12487 self
12488 }
12489 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
12490 ///
12491 /// Sets the *page token* query property to the given value.
12492 pub fn page_token(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
12493 self._page_token = Some(new_value.to_string());
12494 self
12495 }
12496 /// Restricts the list to return only records with this fully qualified domain name. Mutually exclusive with the {@code filter} field.
12497 ///
12498 /// Sets the *name* query property to the given value.
12499 pub fn name(mut self, new_value: &str) -> ResourceRecordSetListCall<'a, C> {
12500 self._name = Some(new_value.to_string());
12501 self
12502 }
12503 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
12504 ///
12505 /// Sets the *max results* query property to the given value.
12506 pub fn max_results(mut self, new_value: i32) -> ResourceRecordSetListCall<'a, C> {
12507 self._max_results = Some(new_value);
12508 self
12509 }
12510 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12511 /// while executing the actual API request.
12512 ///
12513 /// ````text
12514 /// It should be used to handle progress information, and to implement a certain level of resilience.
12515 /// ````
12516 ///
12517 /// Sets the *delegate* property to the given value.
12518 pub fn delegate(
12519 mut self,
12520 new_value: &'a mut dyn common::Delegate,
12521 ) -> ResourceRecordSetListCall<'a, C> {
12522 self._delegate = Some(new_value);
12523 self
12524 }
12525
12526 /// Set any additional parameter of the query string used in the request.
12527 /// It should be used to set parameters which are not yet available through their own
12528 /// setters.
12529 ///
12530 /// Please note that this method must not be used to set any of the known parameters
12531 /// which have their own setter method. If done anyway, the request will fail.
12532 ///
12533 /// # Additional Parameters
12534 ///
12535 /// * *$.xgafv* (query-string) - V1 error format.
12536 /// * *access_token* (query-string) - OAuth access token.
12537 /// * *alt* (query-string) - Data format for response.
12538 /// * *callback* (query-string) - JSONP
12539 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12540 /// * *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.
12541 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12542 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12543 /// * *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.
12544 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12545 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12546 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetListCall<'a, C>
12547 where
12548 T: AsRef<str>,
12549 {
12550 self._additional_params
12551 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12552 self
12553 }
12554
12555 /// Identifies the authorization scope for the method you are building.
12556 ///
12557 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12558 /// [`Scope::NdevClouddnReadonly`].
12559 ///
12560 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12561 /// tokens for more than one scope.
12562 ///
12563 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12564 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12565 /// sufficient, a read-write scope will do as well.
12566 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetListCall<'a, C>
12567 where
12568 St: AsRef<str>,
12569 {
12570 self._scopes.insert(String::from(scope.as_ref()));
12571 self
12572 }
12573 /// Identifies the authorization scope(s) for the method you are building.
12574 ///
12575 /// See [`Self::add_scope()`] for details.
12576 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetListCall<'a, C>
12577 where
12578 I: IntoIterator<Item = St>,
12579 St: AsRef<str>,
12580 {
12581 self._scopes
12582 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12583 self
12584 }
12585
12586 /// Removes all scopes, and no default scope will be used either.
12587 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12588 /// for details).
12589 pub fn clear_scopes(mut self) -> ResourceRecordSetListCall<'a, C> {
12590 self._scopes.clear();
12591 self
12592 }
12593}
12594
12595/// Applies a partial update to an existing ResourceRecordSet.
12596///
12597/// A builder for the *patch* method supported by a *resourceRecordSet* resource.
12598/// It is not used directly, but through a [`ResourceRecordSetMethods`] instance.
12599///
12600/// # Example
12601///
12602/// Instantiate a resource method builder
12603///
12604/// ```test_harness,no_run
12605/// # extern crate hyper;
12606/// # extern crate hyper_rustls;
12607/// # extern crate google_dns1 as dns1;
12608/// use dns1::api::ResourceRecordSet;
12609/// # async fn dox() {
12610/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12611///
12612/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12613/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12614/// # .with_native_roots()
12615/// # .unwrap()
12616/// # .https_only()
12617/// # .enable_http2()
12618/// # .build();
12619///
12620/// # let executor = hyper_util::rt::TokioExecutor::new();
12621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12622/// # secret,
12623/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12624/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12625/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12626/// # ),
12627/// # ).build().await.unwrap();
12628///
12629/// # let client = hyper_util::client::legacy::Client::builder(
12630/// # hyper_util::rt::TokioExecutor::new()
12631/// # )
12632/// # .build(
12633/// # hyper_rustls::HttpsConnectorBuilder::new()
12634/// # .with_native_roots()
12635/// # .unwrap()
12636/// # .https_or_http()
12637/// # .enable_http2()
12638/// # .build()
12639/// # );
12640/// # let mut hub = Dns::new(client, auth);
12641/// // As the method needs a request, you would usually fill it with the desired information
12642/// // into the respective structure. Some of the parts shown here might not be applicable !
12643/// // Values shown here are possibly random and not representative !
12644/// let mut req = ResourceRecordSet::default();
12645///
12646/// // You can configure optional parameters by calling the respective setters at will, and
12647/// // execute the final call using `doit()`.
12648/// // Values shown here are possibly random and not representative !
12649/// let result = hub.resource_record_sets().patch(req, "project", "managedZone", "name", "type")
12650/// .client_operation_id("ipsum")
12651/// .doit().await;
12652/// # }
12653/// ```
12654pub struct ResourceRecordSetPatchCall<'a, C>
12655where
12656 C: 'a,
12657{
12658 hub: &'a Dns<C>,
12659 _request: ResourceRecordSet,
12660 _project: String,
12661 _managed_zone: String,
12662 _name: String,
12663 _type_: String,
12664 _client_operation_id: Option<String>,
12665 _delegate: Option<&'a mut dyn common::Delegate>,
12666 _additional_params: HashMap<String, String>,
12667 _scopes: BTreeSet<String>,
12668}
12669
12670impl<'a, C> common::CallBuilder for ResourceRecordSetPatchCall<'a, C> {}
12671
12672impl<'a, C> ResourceRecordSetPatchCall<'a, C>
12673where
12674 C: common::Connector,
12675{
12676 /// Perform the operation you have build so far.
12677 pub async fn doit(mut self) -> common::Result<(common::Response, ResourceRecordSet)> {
12678 use std::borrow::Cow;
12679 use std::io::{Read, Seek};
12680
12681 use common::{url::Params, ToParts};
12682 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12683
12684 let mut dd = common::DefaultDelegate;
12685 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12686 dlg.begin(common::MethodInfo {
12687 id: "dns.resourceRecordSets.patch",
12688 http_method: hyper::Method::PATCH,
12689 });
12690
12691 for &field in [
12692 "alt",
12693 "project",
12694 "managedZone",
12695 "name",
12696 "type",
12697 "clientOperationId",
12698 ]
12699 .iter()
12700 {
12701 if self._additional_params.contains_key(field) {
12702 dlg.finished(false);
12703 return Err(common::Error::FieldClash(field));
12704 }
12705 }
12706
12707 let mut params = Params::with_capacity(8 + self._additional_params.len());
12708 params.push("project", self._project);
12709 params.push("managedZone", self._managed_zone);
12710 params.push("name", self._name);
12711 params.push("type", self._type_);
12712 if let Some(value) = self._client_operation_id.as_ref() {
12713 params.push("clientOperationId", value);
12714 }
12715
12716 params.extend(self._additional_params.iter());
12717
12718 params.push("alt", "json");
12719 let mut url = self.hub._base_url.clone()
12720 + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets/{name}/{type}";
12721 if self._scopes.is_empty() {
12722 self._scopes
12723 .insert(Scope::CloudPlatform.as_ref().to_string());
12724 }
12725
12726 #[allow(clippy::single_element_loop)]
12727 for &(find_this, param_name) in [
12728 ("{project}", "project"),
12729 ("{managedZone}", "managedZone"),
12730 ("{name}", "name"),
12731 ("{type}", "type"),
12732 ]
12733 .iter()
12734 {
12735 url = params.uri_replacement(url, param_name, find_this, false);
12736 }
12737 {
12738 let to_remove = ["type", "name", "managedZone", "project"];
12739 params.remove_params(&to_remove);
12740 }
12741
12742 let url = params.parse_with_url(&url);
12743
12744 let mut json_mime_type = mime::APPLICATION_JSON;
12745 let mut request_value_reader = {
12746 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12747 common::remove_json_null_values(&mut value);
12748 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12749 serde_json::to_writer(&mut dst, &value).unwrap();
12750 dst
12751 };
12752 let request_size = request_value_reader
12753 .seek(std::io::SeekFrom::End(0))
12754 .unwrap();
12755 request_value_reader
12756 .seek(std::io::SeekFrom::Start(0))
12757 .unwrap();
12758
12759 loop {
12760 let token = match self
12761 .hub
12762 .auth
12763 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12764 .await
12765 {
12766 Ok(token) => token,
12767 Err(e) => match dlg.token(e) {
12768 Ok(token) => token,
12769 Err(e) => {
12770 dlg.finished(false);
12771 return Err(common::Error::MissingToken(e));
12772 }
12773 },
12774 };
12775 request_value_reader
12776 .seek(std::io::SeekFrom::Start(0))
12777 .unwrap();
12778 let mut req_result = {
12779 let client = &self.hub.client;
12780 dlg.pre_request();
12781 let mut req_builder = hyper::Request::builder()
12782 .method(hyper::Method::PATCH)
12783 .uri(url.as_str())
12784 .header(USER_AGENT, self.hub._user_agent.clone());
12785
12786 if let Some(token) = token.as_ref() {
12787 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12788 }
12789
12790 let request = req_builder
12791 .header(CONTENT_TYPE, json_mime_type.to_string())
12792 .header(CONTENT_LENGTH, request_size as u64)
12793 .body(common::to_body(
12794 request_value_reader.get_ref().clone().into(),
12795 ));
12796
12797 client.request(request.unwrap()).await
12798 };
12799
12800 match req_result {
12801 Err(err) => {
12802 if let common::Retry::After(d) = dlg.http_error(&err) {
12803 sleep(d).await;
12804 continue;
12805 }
12806 dlg.finished(false);
12807 return Err(common::Error::HttpError(err));
12808 }
12809 Ok(res) => {
12810 let (mut parts, body) = res.into_parts();
12811 let mut body = common::Body::new(body);
12812 if !parts.status.is_success() {
12813 let bytes = common::to_bytes(body).await.unwrap_or_default();
12814 let error = serde_json::from_str(&common::to_string(&bytes));
12815 let response = common::to_response(parts, bytes.into());
12816
12817 if let common::Retry::After(d) =
12818 dlg.http_failure(&response, error.as_ref().ok())
12819 {
12820 sleep(d).await;
12821 continue;
12822 }
12823
12824 dlg.finished(false);
12825
12826 return Err(match error {
12827 Ok(value) => common::Error::BadRequest(value),
12828 _ => common::Error::Failure(response),
12829 });
12830 }
12831 let response = {
12832 let bytes = common::to_bytes(body).await.unwrap_or_default();
12833 let encoded = common::to_string(&bytes);
12834 match serde_json::from_str(&encoded) {
12835 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12836 Err(error) => {
12837 dlg.response_json_decode_error(&encoded, &error);
12838 return Err(common::Error::JsonDecodeError(
12839 encoded.to_string(),
12840 error,
12841 ));
12842 }
12843 }
12844 };
12845
12846 dlg.finished(true);
12847 return Ok(response);
12848 }
12849 }
12850 }
12851 }
12852
12853 ///
12854 /// Sets the *request* property to the given value.
12855 ///
12856 /// Even though the property as already been set when instantiating this call,
12857 /// we provide this method for API completeness.
12858 pub fn request(mut self, new_value: ResourceRecordSet) -> ResourceRecordSetPatchCall<'a, C> {
12859 self._request = new_value;
12860 self
12861 }
12862 /// Identifies the project addressed by this request.
12863 ///
12864 /// Sets the *project* path property to the given value.
12865 ///
12866 /// Even though the property as already been set when instantiating this call,
12867 /// we provide this method for API completeness.
12868 pub fn project(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
12869 self._project = new_value.to_string();
12870 self
12871 }
12872 /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID.
12873 ///
12874 /// Sets the *managed zone* path property to the given value.
12875 ///
12876 /// Even though the property as already been set when instantiating this call,
12877 /// we provide this method for API completeness.
12878 pub fn managed_zone(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
12879 self._managed_zone = new_value.to_string();
12880 self
12881 }
12882 /// Fully qualified domain name.
12883 ///
12884 /// Sets the *name* path property to the given value.
12885 ///
12886 /// Even though the property as already been set when instantiating this call,
12887 /// we provide this method for API completeness.
12888 pub fn name(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
12889 self._name = new_value.to_string();
12890 self
12891 }
12892 /// RRSet type.
12893 ///
12894 /// Sets the *type* path property to the given value.
12895 ///
12896 /// Even though the property as already been set when instantiating this call,
12897 /// we provide this method for API completeness.
12898 pub fn type_(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
12899 self._type_ = new_value.to_string();
12900 self
12901 }
12902 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
12903 ///
12904 /// Sets the *client operation id* query property to the given value.
12905 pub fn client_operation_id(mut self, new_value: &str) -> ResourceRecordSetPatchCall<'a, C> {
12906 self._client_operation_id = Some(new_value.to_string());
12907 self
12908 }
12909 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12910 /// while executing the actual API request.
12911 ///
12912 /// ````text
12913 /// It should be used to handle progress information, and to implement a certain level of resilience.
12914 /// ````
12915 ///
12916 /// Sets the *delegate* property to the given value.
12917 pub fn delegate(
12918 mut self,
12919 new_value: &'a mut dyn common::Delegate,
12920 ) -> ResourceRecordSetPatchCall<'a, C> {
12921 self._delegate = Some(new_value);
12922 self
12923 }
12924
12925 /// Set any additional parameter of the query string used in the request.
12926 /// It should be used to set parameters which are not yet available through their own
12927 /// setters.
12928 ///
12929 /// Please note that this method must not be used to set any of the known parameters
12930 /// which have their own setter method. If done anyway, the request will fail.
12931 ///
12932 /// # Additional Parameters
12933 ///
12934 /// * *$.xgafv* (query-string) - V1 error format.
12935 /// * *access_token* (query-string) - OAuth access token.
12936 /// * *alt* (query-string) - Data format for response.
12937 /// * *callback* (query-string) - JSONP
12938 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12939 /// * *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.
12940 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12941 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12942 /// * *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.
12943 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12944 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12945 pub fn param<T>(mut self, name: T, value: T) -> ResourceRecordSetPatchCall<'a, C>
12946 where
12947 T: AsRef<str>,
12948 {
12949 self._additional_params
12950 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12951 self
12952 }
12953
12954 /// Identifies the authorization scope for the method you are building.
12955 ///
12956 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12957 /// [`Scope::CloudPlatform`].
12958 ///
12959 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12960 /// tokens for more than one scope.
12961 ///
12962 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12963 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12964 /// sufficient, a read-write scope will do as well.
12965 pub fn add_scope<St>(mut self, scope: St) -> ResourceRecordSetPatchCall<'a, C>
12966 where
12967 St: AsRef<str>,
12968 {
12969 self._scopes.insert(String::from(scope.as_ref()));
12970 self
12971 }
12972 /// Identifies the authorization scope(s) for the method you are building.
12973 ///
12974 /// See [`Self::add_scope()`] for details.
12975 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResourceRecordSetPatchCall<'a, C>
12976 where
12977 I: IntoIterator<Item = St>,
12978 St: AsRef<str>,
12979 {
12980 self._scopes
12981 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12982 self
12983 }
12984
12985 /// Removes all scopes, and no default scope will be used either.
12986 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12987 /// for details).
12988 pub fn clear_scopes(mut self) -> ResourceRecordSetPatchCall<'a, C> {
12989 self._scopes.clear();
12990 self
12991 }
12992}
12993
12994/// Creates a new Response Policy
12995///
12996/// A builder for the *create* method supported by a *responsePolicy* resource.
12997/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
12998///
12999/// # Example
13000///
13001/// Instantiate a resource method builder
13002///
13003/// ```test_harness,no_run
13004/// # extern crate hyper;
13005/// # extern crate hyper_rustls;
13006/// # extern crate google_dns1 as dns1;
13007/// use dns1::api::ResponsePolicy;
13008/// # async fn dox() {
13009/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13010///
13011/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13012/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13013/// # .with_native_roots()
13014/// # .unwrap()
13015/// # .https_only()
13016/// # .enable_http2()
13017/// # .build();
13018///
13019/// # let executor = hyper_util::rt::TokioExecutor::new();
13020/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13021/// # secret,
13022/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13023/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13024/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13025/// # ),
13026/// # ).build().await.unwrap();
13027///
13028/// # let client = hyper_util::client::legacy::Client::builder(
13029/// # hyper_util::rt::TokioExecutor::new()
13030/// # )
13031/// # .build(
13032/// # hyper_rustls::HttpsConnectorBuilder::new()
13033/// # .with_native_roots()
13034/// # .unwrap()
13035/// # .https_or_http()
13036/// # .enable_http2()
13037/// # .build()
13038/// # );
13039/// # let mut hub = Dns::new(client, auth);
13040/// // As the method needs a request, you would usually fill it with the desired information
13041/// // into the respective structure. Some of the parts shown here might not be applicable !
13042/// // Values shown here are possibly random and not representative !
13043/// let mut req = ResponsePolicy::default();
13044///
13045/// // You can configure optional parameters by calling the respective setters at will, and
13046/// // execute the final call using `doit()`.
13047/// // Values shown here are possibly random and not representative !
13048/// let result = hub.response_policies().create(req, "project")
13049/// .client_operation_id("sanctus")
13050/// .doit().await;
13051/// # }
13052/// ```
13053pub struct ResponsePolicyCreateCall<'a, C>
13054where
13055 C: 'a,
13056{
13057 hub: &'a Dns<C>,
13058 _request: ResponsePolicy,
13059 _project: String,
13060 _client_operation_id: Option<String>,
13061 _delegate: Option<&'a mut dyn common::Delegate>,
13062 _additional_params: HashMap<String, String>,
13063 _scopes: BTreeSet<String>,
13064}
13065
13066impl<'a, C> common::CallBuilder for ResponsePolicyCreateCall<'a, C> {}
13067
13068impl<'a, C> ResponsePolicyCreateCall<'a, C>
13069where
13070 C: common::Connector,
13071{
13072 /// Perform the operation you have build so far.
13073 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicy)> {
13074 use std::borrow::Cow;
13075 use std::io::{Read, Seek};
13076
13077 use common::{url::Params, ToParts};
13078 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13079
13080 let mut dd = common::DefaultDelegate;
13081 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13082 dlg.begin(common::MethodInfo {
13083 id: "dns.responsePolicies.create",
13084 http_method: hyper::Method::POST,
13085 });
13086
13087 for &field in ["alt", "project", "clientOperationId"].iter() {
13088 if self._additional_params.contains_key(field) {
13089 dlg.finished(false);
13090 return Err(common::Error::FieldClash(field));
13091 }
13092 }
13093
13094 let mut params = Params::with_capacity(5 + self._additional_params.len());
13095 params.push("project", self._project);
13096 if let Some(value) = self._client_operation_id.as_ref() {
13097 params.push("clientOperationId", value);
13098 }
13099
13100 params.extend(self._additional_params.iter());
13101
13102 params.push("alt", "json");
13103 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/responsePolicies";
13104 if self._scopes.is_empty() {
13105 self._scopes
13106 .insert(Scope::CloudPlatform.as_ref().to_string());
13107 }
13108
13109 #[allow(clippy::single_element_loop)]
13110 for &(find_this, param_name) in [("{project}", "project")].iter() {
13111 url = params.uri_replacement(url, param_name, find_this, false);
13112 }
13113 {
13114 let to_remove = ["project"];
13115 params.remove_params(&to_remove);
13116 }
13117
13118 let url = params.parse_with_url(&url);
13119
13120 let mut json_mime_type = mime::APPLICATION_JSON;
13121 let mut request_value_reader = {
13122 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13123 common::remove_json_null_values(&mut value);
13124 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13125 serde_json::to_writer(&mut dst, &value).unwrap();
13126 dst
13127 };
13128 let request_size = request_value_reader
13129 .seek(std::io::SeekFrom::End(0))
13130 .unwrap();
13131 request_value_reader
13132 .seek(std::io::SeekFrom::Start(0))
13133 .unwrap();
13134
13135 loop {
13136 let token = match self
13137 .hub
13138 .auth
13139 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13140 .await
13141 {
13142 Ok(token) => token,
13143 Err(e) => match dlg.token(e) {
13144 Ok(token) => token,
13145 Err(e) => {
13146 dlg.finished(false);
13147 return Err(common::Error::MissingToken(e));
13148 }
13149 },
13150 };
13151 request_value_reader
13152 .seek(std::io::SeekFrom::Start(0))
13153 .unwrap();
13154 let mut req_result = {
13155 let client = &self.hub.client;
13156 dlg.pre_request();
13157 let mut req_builder = hyper::Request::builder()
13158 .method(hyper::Method::POST)
13159 .uri(url.as_str())
13160 .header(USER_AGENT, self.hub._user_agent.clone());
13161
13162 if let Some(token) = token.as_ref() {
13163 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13164 }
13165
13166 let request = req_builder
13167 .header(CONTENT_TYPE, json_mime_type.to_string())
13168 .header(CONTENT_LENGTH, request_size as u64)
13169 .body(common::to_body(
13170 request_value_reader.get_ref().clone().into(),
13171 ));
13172
13173 client.request(request.unwrap()).await
13174 };
13175
13176 match req_result {
13177 Err(err) => {
13178 if let common::Retry::After(d) = dlg.http_error(&err) {
13179 sleep(d).await;
13180 continue;
13181 }
13182 dlg.finished(false);
13183 return Err(common::Error::HttpError(err));
13184 }
13185 Ok(res) => {
13186 let (mut parts, body) = res.into_parts();
13187 let mut body = common::Body::new(body);
13188 if !parts.status.is_success() {
13189 let bytes = common::to_bytes(body).await.unwrap_or_default();
13190 let error = serde_json::from_str(&common::to_string(&bytes));
13191 let response = common::to_response(parts, bytes.into());
13192
13193 if let common::Retry::After(d) =
13194 dlg.http_failure(&response, error.as_ref().ok())
13195 {
13196 sleep(d).await;
13197 continue;
13198 }
13199
13200 dlg.finished(false);
13201
13202 return Err(match error {
13203 Ok(value) => common::Error::BadRequest(value),
13204 _ => common::Error::Failure(response),
13205 });
13206 }
13207 let response = {
13208 let bytes = common::to_bytes(body).await.unwrap_or_default();
13209 let encoded = common::to_string(&bytes);
13210 match serde_json::from_str(&encoded) {
13211 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13212 Err(error) => {
13213 dlg.response_json_decode_error(&encoded, &error);
13214 return Err(common::Error::JsonDecodeError(
13215 encoded.to_string(),
13216 error,
13217 ));
13218 }
13219 }
13220 };
13221
13222 dlg.finished(true);
13223 return Ok(response);
13224 }
13225 }
13226 }
13227 }
13228
13229 ///
13230 /// Sets the *request* property to the given value.
13231 ///
13232 /// Even though the property as already been set when instantiating this call,
13233 /// we provide this method for API completeness.
13234 pub fn request(mut self, new_value: ResponsePolicy) -> ResponsePolicyCreateCall<'a, C> {
13235 self._request = new_value;
13236 self
13237 }
13238 /// Identifies the project addressed by this request.
13239 ///
13240 /// Sets the *project* path property to the given value.
13241 ///
13242 /// Even though the property as already been set when instantiating this call,
13243 /// we provide this method for API completeness.
13244 pub fn project(mut self, new_value: &str) -> ResponsePolicyCreateCall<'a, C> {
13245 self._project = new_value.to_string();
13246 self
13247 }
13248 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
13249 ///
13250 /// Sets the *client operation id* query property to the given value.
13251 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyCreateCall<'a, C> {
13252 self._client_operation_id = Some(new_value.to_string());
13253 self
13254 }
13255 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13256 /// while executing the actual API request.
13257 ///
13258 /// ````text
13259 /// It should be used to handle progress information, and to implement a certain level of resilience.
13260 /// ````
13261 ///
13262 /// Sets the *delegate* property to the given value.
13263 pub fn delegate(
13264 mut self,
13265 new_value: &'a mut dyn common::Delegate,
13266 ) -> ResponsePolicyCreateCall<'a, C> {
13267 self._delegate = Some(new_value);
13268 self
13269 }
13270
13271 /// Set any additional parameter of the query string used in the request.
13272 /// It should be used to set parameters which are not yet available through their own
13273 /// setters.
13274 ///
13275 /// Please note that this method must not be used to set any of the known parameters
13276 /// which have their own setter method. If done anyway, the request will fail.
13277 ///
13278 /// # Additional Parameters
13279 ///
13280 /// * *$.xgafv* (query-string) - V1 error format.
13281 /// * *access_token* (query-string) - OAuth access token.
13282 /// * *alt* (query-string) - Data format for response.
13283 /// * *callback* (query-string) - JSONP
13284 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13285 /// * *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.
13286 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13287 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13288 /// * *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.
13289 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13290 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13291 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyCreateCall<'a, C>
13292 where
13293 T: AsRef<str>,
13294 {
13295 self._additional_params
13296 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13297 self
13298 }
13299
13300 /// Identifies the authorization scope for the method you are building.
13301 ///
13302 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13303 /// [`Scope::CloudPlatform`].
13304 ///
13305 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13306 /// tokens for more than one scope.
13307 ///
13308 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13309 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13310 /// sufficient, a read-write scope will do as well.
13311 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyCreateCall<'a, C>
13312 where
13313 St: AsRef<str>,
13314 {
13315 self._scopes.insert(String::from(scope.as_ref()));
13316 self
13317 }
13318 /// Identifies the authorization scope(s) for the method you are building.
13319 ///
13320 /// See [`Self::add_scope()`] for details.
13321 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyCreateCall<'a, C>
13322 where
13323 I: IntoIterator<Item = St>,
13324 St: AsRef<str>,
13325 {
13326 self._scopes
13327 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13328 self
13329 }
13330
13331 /// Removes all scopes, and no default scope will be used either.
13332 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13333 /// for details).
13334 pub fn clear_scopes(mut self) -> ResponsePolicyCreateCall<'a, C> {
13335 self._scopes.clear();
13336 self
13337 }
13338}
13339
13340/// Deletes a previously created Response Policy. Fails if the response policy is non-empty or still being referenced by a network.
13341///
13342/// A builder for the *delete* method supported by a *responsePolicy* resource.
13343/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
13344///
13345/// # Example
13346///
13347/// Instantiate a resource method builder
13348///
13349/// ```test_harness,no_run
13350/// # extern crate hyper;
13351/// # extern crate hyper_rustls;
13352/// # extern crate google_dns1 as dns1;
13353/// # async fn dox() {
13354/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13355///
13356/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13357/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13358/// # .with_native_roots()
13359/// # .unwrap()
13360/// # .https_only()
13361/// # .enable_http2()
13362/// # .build();
13363///
13364/// # let executor = hyper_util::rt::TokioExecutor::new();
13365/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13366/// # secret,
13367/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13368/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13369/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13370/// # ),
13371/// # ).build().await.unwrap();
13372///
13373/// # let client = hyper_util::client::legacy::Client::builder(
13374/// # hyper_util::rt::TokioExecutor::new()
13375/// # )
13376/// # .build(
13377/// # hyper_rustls::HttpsConnectorBuilder::new()
13378/// # .with_native_roots()
13379/// # .unwrap()
13380/// # .https_or_http()
13381/// # .enable_http2()
13382/// # .build()
13383/// # );
13384/// # let mut hub = Dns::new(client, auth);
13385/// // You can configure optional parameters by calling the respective setters at will, and
13386/// // execute the final call using `doit()`.
13387/// // Values shown here are possibly random and not representative !
13388/// let result = hub.response_policies().delete("project", "responsePolicy")
13389/// .client_operation_id("sed")
13390/// .doit().await;
13391/// # }
13392/// ```
13393pub struct ResponsePolicyDeleteCall<'a, C>
13394where
13395 C: 'a,
13396{
13397 hub: &'a Dns<C>,
13398 _project: String,
13399 _response_policy: String,
13400 _client_operation_id: Option<String>,
13401 _delegate: Option<&'a mut dyn common::Delegate>,
13402 _additional_params: HashMap<String, String>,
13403 _scopes: BTreeSet<String>,
13404}
13405
13406impl<'a, C> common::CallBuilder for ResponsePolicyDeleteCall<'a, C> {}
13407
13408impl<'a, C> ResponsePolicyDeleteCall<'a, C>
13409where
13410 C: common::Connector,
13411{
13412 /// Perform the operation you have build so far.
13413 pub async fn doit(mut self) -> common::Result<common::Response> {
13414 use std::borrow::Cow;
13415 use std::io::{Read, Seek};
13416
13417 use common::{url::Params, ToParts};
13418 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13419
13420 let mut dd = common::DefaultDelegate;
13421 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13422 dlg.begin(common::MethodInfo {
13423 id: "dns.responsePolicies.delete",
13424 http_method: hyper::Method::DELETE,
13425 });
13426
13427 for &field in ["project", "responsePolicy", "clientOperationId"].iter() {
13428 if self._additional_params.contains_key(field) {
13429 dlg.finished(false);
13430 return Err(common::Error::FieldClash(field));
13431 }
13432 }
13433
13434 let mut params = Params::with_capacity(4 + self._additional_params.len());
13435 params.push("project", self._project);
13436 params.push("responsePolicy", self._response_policy);
13437 if let Some(value) = self._client_operation_id.as_ref() {
13438 params.push("clientOperationId", value);
13439 }
13440
13441 params.extend(self._additional_params.iter());
13442
13443 let mut url = self.hub._base_url.clone()
13444 + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}";
13445 if self._scopes.is_empty() {
13446 self._scopes
13447 .insert(Scope::CloudPlatform.as_ref().to_string());
13448 }
13449
13450 #[allow(clippy::single_element_loop)]
13451 for &(find_this, param_name) in [
13452 ("{project}", "project"),
13453 ("{responsePolicy}", "responsePolicy"),
13454 ]
13455 .iter()
13456 {
13457 url = params.uri_replacement(url, param_name, find_this, false);
13458 }
13459 {
13460 let to_remove = ["responsePolicy", "project"];
13461 params.remove_params(&to_remove);
13462 }
13463
13464 let url = params.parse_with_url(&url);
13465
13466 loop {
13467 let token = match self
13468 .hub
13469 .auth
13470 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13471 .await
13472 {
13473 Ok(token) => token,
13474 Err(e) => match dlg.token(e) {
13475 Ok(token) => token,
13476 Err(e) => {
13477 dlg.finished(false);
13478 return Err(common::Error::MissingToken(e));
13479 }
13480 },
13481 };
13482 let mut req_result = {
13483 let client = &self.hub.client;
13484 dlg.pre_request();
13485 let mut req_builder = hyper::Request::builder()
13486 .method(hyper::Method::DELETE)
13487 .uri(url.as_str())
13488 .header(USER_AGENT, self.hub._user_agent.clone());
13489
13490 if let Some(token) = token.as_ref() {
13491 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13492 }
13493
13494 let request = req_builder
13495 .header(CONTENT_LENGTH, 0_u64)
13496 .body(common::to_body::<String>(None));
13497
13498 client.request(request.unwrap()).await
13499 };
13500
13501 match req_result {
13502 Err(err) => {
13503 if let common::Retry::After(d) = dlg.http_error(&err) {
13504 sleep(d).await;
13505 continue;
13506 }
13507 dlg.finished(false);
13508 return Err(common::Error::HttpError(err));
13509 }
13510 Ok(res) => {
13511 let (mut parts, body) = res.into_parts();
13512 let mut body = common::Body::new(body);
13513 if !parts.status.is_success() {
13514 let bytes = common::to_bytes(body).await.unwrap_or_default();
13515 let error = serde_json::from_str(&common::to_string(&bytes));
13516 let response = common::to_response(parts, bytes.into());
13517
13518 if let common::Retry::After(d) =
13519 dlg.http_failure(&response, error.as_ref().ok())
13520 {
13521 sleep(d).await;
13522 continue;
13523 }
13524
13525 dlg.finished(false);
13526
13527 return Err(match error {
13528 Ok(value) => common::Error::BadRequest(value),
13529 _ => common::Error::Failure(response),
13530 });
13531 }
13532 let response = common::Response::from_parts(parts, body);
13533
13534 dlg.finished(true);
13535 return Ok(response);
13536 }
13537 }
13538 }
13539 }
13540
13541 /// Identifies the project addressed by this request.
13542 ///
13543 /// Sets the *project* path property to the given value.
13544 ///
13545 /// Even though the property as already been set when instantiating this call,
13546 /// we provide this method for API completeness.
13547 pub fn project(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
13548 self._project = new_value.to_string();
13549 self
13550 }
13551 /// User assigned name of the Response Policy addressed by this request.
13552 ///
13553 /// Sets the *response policy* path property to the given value.
13554 ///
13555 /// Even though the property as already been set when instantiating this call,
13556 /// we provide this method for API completeness.
13557 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
13558 self._response_policy = new_value.to_string();
13559 self
13560 }
13561 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
13562 ///
13563 /// Sets the *client operation id* query property to the given value.
13564 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyDeleteCall<'a, C> {
13565 self._client_operation_id = Some(new_value.to_string());
13566 self
13567 }
13568 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13569 /// while executing the actual API request.
13570 ///
13571 /// ````text
13572 /// It should be used to handle progress information, and to implement a certain level of resilience.
13573 /// ````
13574 ///
13575 /// Sets the *delegate* property to the given value.
13576 pub fn delegate(
13577 mut self,
13578 new_value: &'a mut dyn common::Delegate,
13579 ) -> ResponsePolicyDeleteCall<'a, C> {
13580 self._delegate = Some(new_value);
13581 self
13582 }
13583
13584 /// Set any additional parameter of the query string used in the request.
13585 /// It should be used to set parameters which are not yet available through their own
13586 /// setters.
13587 ///
13588 /// Please note that this method must not be used to set any of the known parameters
13589 /// which have their own setter method. If done anyway, the request will fail.
13590 ///
13591 /// # Additional Parameters
13592 ///
13593 /// * *$.xgafv* (query-string) - V1 error format.
13594 /// * *access_token* (query-string) - OAuth access token.
13595 /// * *alt* (query-string) - Data format for response.
13596 /// * *callback* (query-string) - JSONP
13597 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13598 /// * *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.
13599 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13600 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13601 /// * *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.
13602 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13603 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13604 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyDeleteCall<'a, C>
13605 where
13606 T: AsRef<str>,
13607 {
13608 self._additional_params
13609 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13610 self
13611 }
13612
13613 /// Identifies the authorization scope for the method you are building.
13614 ///
13615 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13616 /// [`Scope::CloudPlatform`].
13617 ///
13618 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13619 /// tokens for more than one scope.
13620 ///
13621 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13622 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13623 /// sufficient, a read-write scope will do as well.
13624 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyDeleteCall<'a, C>
13625 where
13626 St: AsRef<str>,
13627 {
13628 self._scopes.insert(String::from(scope.as_ref()));
13629 self
13630 }
13631 /// Identifies the authorization scope(s) for the method you are building.
13632 ///
13633 /// See [`Self::add_scope()`] for details.
13634 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyDeleteCall<'a, C>
13635 where
13636 I: IntoIterator<Item = St>,
13637 St: AsRef<str>,
13638 {
13639 self._scopes
13640 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13641 self
13642 }
13643
13644 /// Removes all scopes, and no default scope will be used either.
13645 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13646 /// for details).
13647 pub fn clear_scopes(mut self) -> ResponsePolicyDeleteCall<'a, C> {
13648 self._scopes.clear();
13649 self
13650 }
13651}
13652
13653/// Fetches the representation of an existing Response Policy.
13654///
13655/// A builder for the *get* method supported by a *responsePolicy* resource.
13656/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
13657///
13658/// # Example
13659///
13660/// Instantiate a resource method builder
13661///
13662/// ```test_harness,no_run
13663/// # extern crate hyper;
13664/// # extern crate hyper_rustls;
13665/// # extern crate google_dns1 as dns1;
13666/// # async fn dox() {
13667/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13668///
13669/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13670/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13671/// # .with_native_roots()
13672/// # .unwrap()
13673/// # .https_only()
13674/// # .enable_http2()
13675/// # .build();
13676///
13677/// # let executor = hyper_util::rt::TokioExecutor::new();
13678/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13679/// # secret,
13680/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13681/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13682/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13683/// # ),
13684/// # ).build().await.unwrap();
13685///
13686/// # let client = hyper_util::client::legacy::Client::builder(
13687/// # hyper_util::rt::TokioExecutor::new()
13688/// # )
13689/// # .build(
13690/// # hyper_rustls::HttpsConnectorBuilder::new()
13691/// # .with_native_roots()
13692/// # .unwrap()
13693/// # .https_or_http()
13694/// # .enable_http2()
13695/// # .build()
13696/// # );
13697/// # let mut hub = Dns::new(client, auth);
13698/// // You can configure optional parameters by calling the respective setters at will, and
13699/// // execute the final call using `doit()`.
13700/// // Values shown here are possibly random and not representative !
13701/// let result = hub.response_policies().get("project", "responsePolicy")
13702/// .client_operation_id("dolores")
13703/// .doit().await;
13704/// # }
13705/// ```
13706pub struct ResponsePolicyGetCall<'a, C>
13707where
13708 C: 'a,
13709{
13710 hub: &'a Dns<C>,
13711 _project: String,
13712 _response_policy: String,
13713 _client_operation_id: Option<String>,
13714 _delegate: Option<&'a mut dyn common::Delegate>,
13715 _additional_params: HashMap<String, String>,
13716 _scopes: BTreeSet<String>,
13717}
13718
13719impl<'a, C> common::CallBuilder for ResponsePolicyGetCall<'a, C> {}
13720
13721impl<'a, C> ResponsePolicyGetCall<'a, C>
13722where
13723 C: common::Connector,
13724{
13725 /// Perform the operation you have build so far.
13726 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicy)> {
13727 use std::borrow::Cow;
13728 use std::io::{Read, Seek};
13729
13730 use common::{url::Params, ToParts};
13731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13732
13733 let mut dd = common::DefaultDelegate;
13734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13735 dlg.begin(common::MethodInfo {
13736 id: "dns.responsePolicies.get",
13737 http_method: hyper::Method::GET,
13738 });
13739
13740 for &field in ["alt", "project", "responsePolicy", "clientOperationId"].iter() {
13741 if self._additional_params.contains_key(field) {
13742 dlg.finished(false);
13743 return Err(common::Error::FieldClash(field));
13744 }
13745 }
13746
13747 let mut params = Params::with_capacity(5 + self._additional_params.len());
13748 params.push("project", self._project);
13749 params.push("responsePolicy", self._response_policy);
13750 if let Some(value) = self._client_operation_id.as_ref() {
13751 params.push("clientOperationId", value);
13752 }
13753
13754 params.extend(self._additional_params.iter());
13755
13756 params.push("alt", "json");
13757 let mut url = self.hub._base_url.clone()
13758 + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}";
13759 if self._scopes.is_empty() {
13760 self._scopes
13761 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
13762 }
13763
13764 #[allow(clippy::single_element_loop)]
13765 for &(find_this, param_name) in [
13766 ("{project}", "project"),
13767 ("{responsePolicy}", "responsePolicy"),
13768 ]
13769 .iter()
13770 {
13771 url = params.uri_replacement(url, param_name, find_this, false);
13772 }
13773 {
13774 let to_remove = ["responsePolicy", "project"];
13775 params.remove_params(&to_remove);
13776 }
13777
13778 let url = params.parse_with_url(&url);
13779
13780 loop {
13781 let token = match self
13782 .hub
13783 .auth
13784 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13785 .await
13786 {
13787 Ok(token) => token,
13788 Err(e) => match dlg.token(e) {
13789 Ok(token) => token,
13790 Err(e) => {
13791 dlg.finished(false);
13792 return Err(common::Error::MissingToken(e));
13793 }
13794 },
13795 };
13796 let mut req_result = {
13797 let client = &self.hub.client;
13798 dlg.pre_request();
13799 let mut req_builder = hyper::Request::builder()
13800 .method(hyper::Method::GET)
13801 .uri(url.as_str())
13802 .header(USER_AGENT, self.hub._user_agent.clone());
13803
13804 if let Some(token) = token.as_ref() {
13805 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13806 }
13807
13808 let request = req_builder
13809 .header(CONTENT_LENGTH, 0_u64)
13810 .body(common::to_body::<String>(None));
13811
13812 client.request(request.unwrap()).await
13813 };
13814
13815 match req_result {
13816 Err(err) => {
13817 if let common::Retry::After(d) = dlg.http_error(&err) {
13818 sleep(d).await;
13819 continue;
13820 }
13821 dlg.finished(false);
13822 return Err(common::Error::HttpError(err));
13823 }
13824 Ok(res) => {
13825 let (mut parts, body) = res.into_parts();
13826 let mut body = common::Body::new(body);
13827 if !parts.status.is_success() {
13828 let bytes = common::to_bytes(body).await.unwrap_or_default();
13829 let error = serde_json::from_str(&common::to_string(&bytes));
13830 let response = common::to_response(parts, bytes.into());
13831
13832 if let common::Retry::After(d) =
13833 dlg.http_failure(&response, error.as_ref().ok())
13834 {
13835 sleep(d).await;
13836 continue;
13837 }
13838
13839 dlg.finished(false);
13840
13841 return Err(match error {
13842 Ok(value) => common::Error::BadRequest(value),
13843 _ => common::Error::Failure(response),
13844 });
13845 }
13846 let response = {
13847 let bytes = common::to_bytes(body).await.unwrap_or_default();
13848 let encoded = common::to_string(&bytes);
13849 match serde_json::from_str(&encoded) {
13850 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13851 Err(error) => {
13852 dlg.response_json_decode_error(&encoded, &error);
13853 return Err(common::Error::JsonDecodeError(
13854 encoded.to_string(),
13855 error,
13856 ));
13857 }
13858 }
13859 };
13860
13861 dlg.finished(true);
13862 return Ok(response);
13863 }
13864 }
13865 }
13866 }
13867
13868 /// Identifies the project addressed by this request.
13869 ///
13870 /// Sets the *project* path property to the given value.
13871 ///
13872 /// Even though the property as already been set when instantiating this call,
13873 /// we provide this method for API completeness.
13874 pub fn project(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
13875 self._project = new_value.to_string();
13876 self
13877 }
13878 /// User assigned name of the Response Policy addressed by this request.
13879 ///
13880 /// Sets the *response policy* path property to the given value.
13881 ///
13882 /// Even though the property as already been set when instantiating this call,
13883 /// we provide this method for API completeness.
13884 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
13885 self._response_policy = new_value.to_string();
13886 self
13887 }
13888 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
13889 ///
13890 /// Sets the *client operation id* query property to the given value.
13891 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyGetCall<'a, C> {
13892 self._client_operation_id = Some(new_value.to_string());
13893 self
13894 }
13895 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13896 /// while executing the actual API request.
13897 ///
13898 /// ````text
13899 /// It should be used to handle progress information, and to implement a certain level of resilience.
13900 /// ````
13901 ///
13902 /// Sets the *delegate* property to the given value.
13903 pub fn delegate(
13904 mut self,
13905 new_value: &'a mut dyn common::Delegate,
13906 ) -> ResponsePolicyGetCall<'a, C> {
13907 self._delegate = Some(new_value);
13908 self
13909 }
13910
13911 /// Set any additional parameter of the query string used in the request.
13912 /// It should be used to set parameters which are not yet available through their own
13913 /// setters.
13914 ///
13915 /// Please note that this method must not be used to set any of the known parameters
13916 /// which have their own setter method. If done anyway, the request will fail.
13917 ///
13918 /// # Additional Parameters
13919 ///
13920 /// * *$.xgafv* (query-string) - V1 error format.
13921 /// * *access_token* (query-string) - OAuth access token.
13922 /// * *alt* (query-string) - Data format for response.
13923 /// * *callback* (query-string) - JSONP
13924 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13925 /// * *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.
13926 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13927 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13928 /// * *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.
13929 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13930 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13931 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyGetCall<'a, C>
13932 where
13933 T: AsRef<str>,
13934 {
13935 self._additional_params
13936 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13937 self
13938 }
13939
13940 /// Identifies the authorization scope for the method you are building.
13941 ///
13942 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13943 /// [`Scope::NdevClouddnReadonly`].
13944 ///
13945 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13946 /// tokens for more than one scope.
13947 ///
13948 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13949 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13950 /// sufficient, a read-write scope will do as well.
13951 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyGetCall<'a, C>
13952 where
13953 St: AsRef<str>,
13954 {
13955 self._scopes.insert(String::from(scope.as_ref()));
13956 self
13957 }
13958 /// Identifies the authorization scope(s) for the method you are building.
13959 ///
13960 /// See [`Self::add_scope()`] for details.
13961 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyGetCall<'a, C>
13962 where
13963 I: IntoIterator<Item = St>,
13964 St: AsRef<str>,
13965 {
13966 self._scopes
13967 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13968 self
13969 }
13970
13971 /// Removes all scopes, and no default scope will be used either.
13972 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13973 /// for details).
13974 pub fn clear_scopes(mut self) -> ResponsePolicyGetCall<'a, C> {
13975 self._scopes.clear();
13976 self
13977 }
13978}
13979
13980/// Enumerates all Response Policies associated with a project.
13981///
13982/// A builder for the *list* method supported by a *responsePolicy* resource.
13983/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
13984///
13985/// # Example
13986///
13987/// Instantiate a resource method builder
13988///
13989/// ```test_harness,no_run
13990/// # extern crate hyper;
13991/// # extern crate hyper_rustls;
13992/// # extern crate google_dns1 as dns1;
13993/// # async fn dox() {
13994/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13995///
13996/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13997/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13998/// # .with_native_roots()
13999/// # .unwrap()
14000/// # .https_only()
14001/// # .enable_http2()
14002/// # .build();
14003///
14004/// # let executor = hyper_util::rt::TokioExecutor::new();
14005/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14006/// # secret,
14007/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14008/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14009/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14010/// # ),
14011/// # ).build().await.unwrap();
14012///
14013/// # let client = hyper_util::client::legacy::Client::builder(
14014/// # hyper_util::rt::TokioExecutor::new()
14015/// # )
14016/// # .build(
14017/// # hyper_rustls::HttpsConnectorBuilder::new()
14018/// # .with_native_roots()
14019/// # .unwrap()
14020/// # .https_or_http()
14021/// # .enable_http2()
14022/// # .build()
14023/// # );
14024/// # let mut hub = Dns::new(client, auth);
14025/// // You can configure optional parameters by calling the respective setters at will, and
14026/// // execute the final call using `doit()`.
14027/// // Values shown here are possibly random and not representative !
14028/// let result = hub.response_policies().list("project")
14029/// .page_token("sed")
14030/// .max_results(-11)
14031/// .doit().await;
14032/// # }
14033/// ```
14034pub struct ResponsePolicyListCall<'a, C>
14035where
14036 C: 'a,
14037{
14038 hub: &'a Dns<C>,
14039 _project: String,
14040 _page_token: Option<String>,
14041 _max_results: Option<i32>,
14042 _delegate: Option<&'a mut dyn common::Delegate>,
14043 _additional_params: HashMap<String, String>,
14044 _scopes: BTreeSet<String>,
14045}
14046
14047impl<'a, C> common::CallBuilder for ResponsePolicyListCall<'a, C> {}
14048
14049impl<'a, C> ResponsePolicyListCall<'a, C>
14050where
14051 C: common::Connector,
14052{
14053 /// Perform the operation you have build so far.
14054 pub async fn doit(
14055 mut self,
14056 ) -> common::Result<(common::Response, ResponsePoliciesListResponse)> {
14057 use std::borrow::Cow;
14058 use std::io::{Read, Seek};
14059
14060 use common::{url::Params, ToParts};
14061 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14062
14063 let mut dd = common::DefaultDelegate;
14064 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14065 dlg.begin(common::MethodInfo {
14066 id: "dns.responsePolicies.list",
14067 http_method: hyper::Method::GET,
14068 });
14069
14070 for &field in ["alt", "project", "pageToken", "maxResults"].iter() {
14071 if self._additional_params.contains_key(field) {
14072 dlg.finished(false);
14073 return Err(common::Error::FieldClash(field));
14074 }
14075 }
14076
14077 let mut params = Params::with_capacity(5 + self._additional_params.len());
14078 params.push("project", self._project);
14079 if let Some(value) = self._page_token.as_ref() {
14080 params.push("pageToken", value);
14081 }
14082 if let Some(value) = self._max_results.as_ref() {
14083 params.push("maxResults", value.to_string());
14084 }
14085
14086 params.extend(self._additional_params.iter());
14087
14088 params.push("alt", "json");
14089 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/responsePolicies";
14090 if self._scopes.is_empty() {
14091 self._scopes
14092 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
14093 }
14094
14095 #[allow(clippy::single_element_loop)]
14096 for &(find_this, param_name) in [("{project}", "project")].iter() {
14097 url = params.uri_replacement(url, param_name, find_this, false);
14098 }
14099 {
14100 let to_remove = ["project"];
14101 params.remove_params(&to_remove);
14102 }
14103
14104 let url = params.parse_with_url(&url);
14105
14106 loop {
14107 let token = match self
14108 .hub
14109 .auth
14110 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14111 .await
14112 {
14113 Ok(token) => token,
14114 Err(e) => match dlg.token(e) {
14115 Ok(token) => token,
14116 Err(e) => {
14117 dlg.finished(false);
14118 return Err(common::Error::MissingToken(e));
14119 }
14120 },
14121 };
14122 let mut req_result = {
14123 let client = &self.hub.client;
14124 dlg.pre_request();
14125 let mut req_builder = hyper::Request::builder()
14126 .method(hyper::Method::GET)
14127 .uri(url.as_str())
14128 .header(USER_AGENT, self.hub._user_agent.clone());
14129
14130 if let Some(token) = token.as_ref() {
14131 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14132 }
14133
14134 let request = req_builder
14135 .header(CONTENT_LENGTH, 0_u64)
14136 .body(common::to_body::<String>(None));
14137
14138 client.request(request.unwrap()).await
14139 };
14140
14141 match req_result {
14142 Err(err) => {
14143 if let common::Retry::After(d) = dlg.http_error(&err) {
14144 sleep(d).await;
14145 continue;
14146 }
14147 dlg.finished(false);
14148 return Err(common::Error::HttpError(err));
14149 }
14150 Ok(res) => {
14151 let (mut parts, body) = res.into_parts();
14152 let mut body = common::Body::new(body);
14153 if !parts.status.is_success() {
14154 let bytes = common::to_bytes(body).await.unwrap_or_default();
14155 let error = serde_json::from_str(&common::to_string(&bytes));
14156 let response = common::to_response(parts, bytes.into());
14157
14158 if let common::Retry::After(d) =
14159 dlg.http_failure(&response, error.as_ref().ok())
14160 {
14161 sleep(d).await;
14162 continue;
14163 }
14164
14165 dlg.finished(false);
14166
14167 return Err(match error {
14168 Ok(value) => common::Error::BadRequest(value),
14169 _ => common::Error::Failure(response),
14170 });
14171 }
14172 let response = {
14173 let bytes = common::to_bytes(body).await.unwrap_or_default();
14174 let encoded = common::to_string(&bytes);
14175 match serde_json::from_str(&encoded) {
14176 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14177 Err(error) => {
14178 dlg.response_json_decode_error(&encoded, &error);
14179 return Err(common::Error::JsonDecodeError(
14180 encoded.to_string(),
14181 error,
14182 ));
14183 }
14184 }
14185 };
14186
14187 dlg.finished(true);
14188 return Ok(response);
14189 }
14190 }
14191 }
14192 }
14193
14194 /// Identifies the project addressed by this request.
14195 ///
14196 /// Sets the *project* path property to the given value.
14197 ///
14198 /// Even though the property as already been set when instantiating this call,
14199 /// we provide this method for API completeness.
14200 pub fn project(mut self, new_value: &str) -> ResponsePolicyListCall<'a, C> {
14201 self._project = new_value.to_string();
14202 self
14203 }
14204 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
14205 ///
14206 /// Sets the *page token* query property to the given value.
14207 pub fn page_token(mut self, new_value: &str) -> ResponsePolicyListCall<'a, C> {
14208 self._page_token = Some(new_value.to_string());
14209 self
14210 }
14211 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
14212 ///
14213 /// Sets the *max results* query property to the given value.
14214 pub fn max_results(mut self, new_value: i32) -> ResponsePolicyListCall<'a, C> {
14215 self._max_results = Some(new_value);
14216 self
14217 }
14218 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14219 /// while executing the actual API request.
14220 ///
14221 /// ````text
14222 /// It should be used to handle progress information, and to implement a certain level of resilience.
14223 /// ````
14224 ///
14225 /// Sets the *delegate* property to the given value.
14226 pub fn delegate(
14227 mut self,
14228 new_value: &'a mut dyn common::Delegate,
14229 ) -> ResponsePolicyListCall<'a, C> {
14230 self._delegate = Some(new_value);
14231 self
14232 }
14233
14234 /// Set any additional parameter of the query string used in the request.
14235 /// It should be used to set parameters which are not yet available through their own
14236 /// setters.
14237 ///
14238 /// Please note that this method must not be used to set any of the known parameters
14239 /// which have their own setter method. If done anyway, the request will fail.
14240 ///
14241 /// # Additional Parameters
14242 ///
14243 /// * *$.xgafv* (query-string) - V1 error format.
14244 /// * *access_token* (query-string) - OAuth access token.
14245 /// * *alt* (query-string) - Data format for response.
14246 /// * *callback* (query-string) - JSONP
14247 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14248 /// * *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.
14249 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14250 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14251 /// * *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.
14252 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14253 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14254 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyListCall<'a, C>
14255 where
14256 T: AsRef<str>,
14257 {
14258 self._additional_params
14259 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14260 self
14261 }
14262
14263 /// Identifies the authorization scope for the method you are building.
14264 ///
14265 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14266 /// [`Scope::NdevClouddnReadonly`].
14267 ///
14268 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14269 /// tokens for more than one scope.
14270 ///
14271 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14272 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14273 /// sufficient, a read-write scope will do as well.
14274 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyListCall<'a, C>
14275 where
14276 St: AsRef<str>,
14277 {
14278 self._scopes.insert(String::from(scope.as_ref()));
14279 self
14280 }
14281 /// Identifies the authorization scope(s) for the method you are building.
14282 ///
14283 /// See [`Self::add_scope()`] for details.
14284 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyListCall<'a, C>
14285 where
14286 I: IntoIterator<Item = St>,
14287 St: AsRef<str>,
14288 {
14289 self._scopes
14290 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14291 self
14292 }
14293
14294 /// Removes all scopes, and no default scope will be used either.
14295 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14296 /// for details).
14297 pub fn clear_scopes(mut self) -> ResponsePolicyListCall<'a, C> {
14298 self._scopes.clear();
14299 self
14300 }
14301}
14302
14303/// Applies a partial update to an existing Response Policy.
14304///
14305/// A builder for the *patch* method supported by a *responsePolicy* resource.
14306/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
14307///
14308/// # Example
14309///
14310/// Instantiate a resource method builder
14311///
14312/// ```test_harness,no_run
14313/// # extern crate hyper;
14314/// # extern crate hyper_rustls;
14315/// # extern crate google_dns1 as dns1;
14316/// use dns1::api::ResponsePolicy;
14317/// # async fn dox() {
14318/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14319///
14320/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14321/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14322/// # .with_native_roots()
14323/// # .unwrap()
14324/// # .https_only()
14325/// # .enable_http2()
14326/// # .build();
14327///
14328/// # let executor = hyper_util::rt::TokioExecutor::new();
14329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14330/// # secret,
14331/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14332/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14333/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14334/// # ),
14335/// # ).build().await.unwrap();
14336///
14337/// # let client = hyper_util::client::legacy::Client::builder(
14338/// # hyper_util::rt::TokioExecutor::new()
14339/// # )
14340/// # .build(
14341/// # hyper_rustls::HttpsConnectorBuilder::new()
14342/// # .with_native_roots()
14343/// # .unwrap()
14344/// # .https_or_http()
14345/// # .enable_http2()
14346/// # .build()
14347/// # );
14348/// # let mut hub = Dns::new(client, auth);
14349/// // As the method needs a request, you would usually fill it with the desired information
14350/// // into the respective structure. Some of the parts shown here might not be applicable !
14351/// // Values shown here are possibly random and not representative !
14352/// let mut req = ResponsePolicy::default();
14353///
14354/// // You can configure optional parameters by calling the respective setters at will, and
14355/// // execute the final call using `doit()`.
14356/// // Values shown here are possibly random and not representative !
14357/// let result = hub.response_policies().patch(req, "project", "responsePolicy")
14358/// .client_operation_id("sed")
14359/// .doit().await;
14360/// # }
14361/// ```
14362pub struct ResponsePolicyPatchCall<'a, C>
14363where
14364 C: 'a,
14365{
14366 hub: &'a Dns<C>,
14367 _request: ResponsePolicy,
14368 _project: String,
14369 _response_policy: String,
14370 _client_operation_id: Option<String>,
14371 _delegate: Option<&'a mut dyn common::Delegate>,
14372 _additional_params: HashMap<String, String>,
14373 _scopes: BTreeSet<String>,
14374}
14375
14376impl<'a, C> common::CallBuilder for ResponsePolicyPatchCall<'a, C> {}
14377
14378impl<'a, C> ResponsePolicyPatchCall<'a, C>
14379where
14380 C: common::Connector,
14381{
14382 /// Perform the operation you have build so far.
14383 pub async fn doit(
14384 mut self,
14385 ) -> common::Result<(common::Response, ResponsePoliciesPatchResponse)> {
14386 use std::borrow::Cow;
14387 use std::io::{Read, Seek};
14388
14389 use common::{url::Params, ToParts};
14390 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14391
14392 let mut dd = common::DefaultDelegate;
14393 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14394 dlg.begin(common::MethodInfo {
14395 id: "dns.responsePolicies.patch",
14396 http_method: hyper::Method::PATCH,
14397 });
14398
14399 for &field in ["alt", "project", "responsePolicy", "clientOperationId"].iter() {
14400 if self._additional_params.contains_key(field) {
14401 dlg.finished(false);
14402 return Err(common::Error::FieldClash(field));
14403 }
14404 }
14405
14406 let mut params = Params::with_capacity(6 + self._additional_params.len());
14407 params.push("project", self._project);
14408 params.push("responsePolicy", self._response_policy);
14409 if let Some(value) = self._client_operation_id.as_ref() {
14410 params.push("clientOperationId", value);
14411 }
14412
14413 params.extend(self._additional_params.iter());
14414
14415 params.push("alt", "json");
14416 let mut url = self.hub._base_url.clone()
14417 + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}";
14418 if self._scopes.is_empty() {
14419 self._scopes
14420 .insert(Scope::CloudPlatform.as_ref().to_string());
14421 }
14422
14423 #[allow(clippy::single_element_loop)]
14424 for &(find_this, param_name) in [
14425 ("{project}", "project"),
14426 ("{responsePolicy}", "responsePolicy"),
14427 ]
14428 .iter()
14429 {
14430 url = params.uri_replacement(url, param_name, find_this, false);
14431 }
14432 {
14433 let to_remove = ["responsePolicy", "project"];
14434 params.remove_params(&to_remove);
14435 }
14436
14437 let url = params.parse_with_url(&url);
14438
14439 let mut json_mime_type = mime::APPLICATION_JSON;
14440 let mut request_value_reader = {
14441 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14442 common::remove_json_null_values(&mut value);
14443 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14444 serde_json::to_writer(&mut dst, &value).unwrap();
14445 dst
14446 };
14447 let request_size = request_value_reader
14448 .seek(std::io::SeekFrom::End(0))
14449 .unwrap();
14450 request_value_reader
14451 .seek(std::io::SeekFrom::Start(0))
14452 .unwrap();
14453
14454 loop {
14455 let token = match self
14456 .hub
14457 .auth
14458 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14459 .await
14460 {
14461 Ok(token) => token,
14462 Err(e) => match dlg.token(e) {
14463 Ok(token) => token,
14464 Err(e) => {
14465 dlg.finished(false);
14466 return Err(common::Error::MissingToken(e));
14467 }
14468 },
14469 };
14470 request_value_reader
14471 .seek(std::io::SeekFrom::Start(0))
14472 .unwrap();
14473 let mut req_result = {
14474 let client = &self.hub.client;
14475 dlg.pre_request();
14476 let mut req_builder = hyper::Request::builder()
14477 .method(hyper::Method::PATCH)
14478 .uri(url.as_str())
14479 .header(USER_AGENT, self.hub._user_agent.clone());
14480
14481 if let Some(token) = token.as_ref() {
14482 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14483 }
14484
14485 let request = req_builder
14486 .header(CONTENT_TYPE, json_mime_type.to_string())
14487 .header(CONTENT_LENGTH, request_size as u64)
14488 .body(common::to_body(
14489 request_value_reader.get_ref().clone().into(),
14490 ));
14491
14492 client.request(request.unwrap()).await
14493 };
14494
14495 match req_result {
14496 Err(err) => {
14497 if let common::Retry::After(d) = dlg.http_error(&err) {
14498 sleep(d).await;
14499 continue;
14500 }
14501 dlg.finished(false);
14502 return Err(common::Error::HttpError(err));
14503 }
14504 Ok(res) => {
14505 let (mut parts, body) = res.into_parts();
14506 let mut body = common::Body::new(body);
14507 if !parts.status.is_success() {
14508 let bytes = common::to_bytes(body).await.unwrap_or_default();
14509 let error = serde_json::from_str(&common::to_string(&bytes));
14510 let response = common::to_response(parts, bytes.into());
14511
14512 if let common::Retry::After(d) =
14513 dlg.http_failure(&response, error.as_ref().ok())
14514 {
14515 sleep(d).await;
14516 continue;
14517 }
14518
14519 dlg.finished(false);
14520
14521 return Err(match error {
14522 Ok(value) => common::Error::BadRequest(value),
14523 _ => common::Error::Failure(response),
14524 });
14525 }
14526 let response = {
14527 let bytes = common::to_bytes(body).await.unwrap_or_default();
14528 let encoded = common::to_string(&bytes);
14529 match serde_json::from_str(&encoded) {
14530 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14531 Err(error) => {
14532 dlg.response_json_decode_error(&encoded, &error);
14533 return Err(common::Error::JsonDecodeError(
14534 encoded.to_string(),
14535 error,
14536 ));
14537 }
14538 }
14539 };
14540
14541 dlg.finished(true);
14542 return Ok(response);
14543 }
14544 }
14545 }
14546 }
14547
14548 ///
14549 /// Sets the *request* property to the given value.
14550 ///
14551 /// Even though the property as already been set when instantiating this call,
14552 /// we provide this method for API completeness.
14553 pub fn request(mut self, new_value: ResponsePolicy) -> ResponsePolicyPatchCall<'a, C> {
14554 self._request = new_value;
14555 self
14556 }
14557 /// Identifies the project addressed by this request.
14558 ///
14559 /// Sets the *project* path property to the given value.
14560 ///
14561 /// Even though the property as already been set when instantiating this call,
14562 /// we provide this method for API completeness.
14563 pub fn project(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
14564 self._project = new_value.to_string();
14565 self
14566 }
14567 /// User assigned name of the response policy addressed by this request.
14568 ///
14569 /// Sets the *response policy* path property to the given value.
14570 ///
14571 /// Even though the property as already been set when instantiating this call,
14572 /// we provide this method for API completeness.
14573 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
14574 self._response_policy = new_value.to_string();
14575 self
14576 }
14577 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
14578 ///
14579 /// Sets the *client operation id* query property to the given value.
14580 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyPatchCall<'a, C> {
14581 self._client_operation_id = Some(new_value.to_string());
14582 self
14583 }
14584 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14585 /// while executing the actual API request.
14586 ///
14587 /// ````text
14588 /// It should be used to handle progress information, and to implement a certain level of resilience.
14589 /// ````
14590 ///
14591 /// Sets the *delegate* property to the given value.
14592 pub fn delegate(
14593 mut self,
14594 new_value: &'a mut dyn common::Delegate,
14595 ) -> ResponsePolicyPatchCall<'a, C> {
14596 self._delegate = Some(new_value);
14597 self
14598 }
14599
14600 /// Set any additional parameter of the query string used in the request.
14601 /// It should be used to set parameters which are not yet available through their own
14602 /// setters.
14603 ///
14604 /// Please note that this method must not be used to set any of the known parameters
14605 /// which have their own setter method. If done anyway, the request will fail.
14606 ///
14607 /// # Additional Parameters
14608 ///
14609 /// * *$.xgafv* (query-string) - V1 error format.
14610 /// * *access_token* (query-string) - OAuth access token.
14611 /// * *alt* (query-string) - Data format for response.
14612 /// * *callback* (query-string) - JSONP
14613 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14614 /// * *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.
14615 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14616 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14617 /// * *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.
14618 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14619 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14620 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyPatchCall<'a, C>
14621 where
14622 T: AsRef<str>,
14623 {
14624 self._additional_params
14625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14626 self
14627 }
14628
14629 /// Identifies the authorization scope for the method you are building.
14630 ///
14631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14632 /// [`Scope::CloudPlatform`].
14633 ///
14634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14635 /// tokens for more than one scope.
14636 ///
14637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14639 /// sufficient, a read-write scope will do as well.
14640 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyPatchCall<'a, C>
14641 where
14642 St: AsRef<str>,
14643 {
14644 self._scopes.insert(String::from(scope.as_ref()));
14645 self
14646 }
14647 /// Identifies the authorization scope(s) for the method you are building.
14648 ///
14649 /// See [`Self::add_scope()`] for details.
14650 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyPatchCall<'a, C>
14651 where
14652 I: IntoIterator<Item = St>,
14653 St: AsRef<str>,
14654 {
14655 self._scopes
14656 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14657 self
14658 }
14659
14660 /// Removes all scopes, and no default scope will be used either.
14661 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14662 /// for details).
14663 pub fn clear_scopes(mut self) -> ResponsePolicyPatchCall<'a, C> {
14664 self._scopes.clear();
14665 self
14666 }
14667}
14668
14669/// Updates an existing Response Policy.
14670///
14671/// A builder for the *update* method supported by a *responsePolicy* resource.
14672/// It is not used directly, but through a [`ResponsePolicyMethods`] instance.
14673///
14674/// # Example
14675///
14676/// Instantiate a resource method builder
14677///
14678/// ```test_harness,no_run
14679/// # extern crate hyper;
14680/// # extern crate hyper_rustls;
14681/// # extern crate google_dns1 as dns1;
14682/// use dns1::api::ResponsePolicy;
14683/// # async fn dox() {
14684/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14685///
14686/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14687/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14688/// # .with_native_roots()
14689/// # .unwrap()
14690/// # .https_only()
14691/// # .enable_http2()
14692/// # .build();
14693///
14694/// # let executor = hyper_util::rt::TokioExecutor::new();
14695/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14696/// # secret,
14697/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14698/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14699/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14700/// # ),
14701/// # ).build().await.unwrap();
14702///
14703/// # let client = hyper_util::client::legacy::Client::builder(
14704/// # hyper_util::rt::TokioExecutor::new()
14705/// # )
14706/// # .build(
14707/// # hyper_rustls::HttpsConnectorBuilder::new()
14708/// # .with_native_roots()
14709/// # .unwrap()
14710/// # .https_or_http()
14711/// # .enable_http2()
14712/// # .build()
14713/// # );
14714/// # let mut hub = Dns::new(client, auth);
14715/// // As the method needs a request, you would usually fill it with the desired information
14716/// // into the respective structure. Some of the parts shown here might not be applicable !
14717/// // Values shown here are possibly random and not representative !
14718/// let mut req = ResponsePolicy::default();
14719///
14720/// // You can configure optional parameters by calling the respective setters at will, and
14721/// // execute the final call using `doit()`.
14722/// // Values shown here are possibly random and not representative !
14723/// let result = hub.response_policies().update(req, "project", "responsePolicy")
14724/// .client_operation_id("At")
14725/// .doit().await;
14726/// # }
14727/// ```
14728pub struct ResponsePolicyUpdateCall<'a, C>
14729where
14730 C: 'a,
14731{
14732 hub: &'a Dns<C>,
14733 _request: ResponsePolicy,
14734 _project: String,
14735 _response_policy: String,
14736 _client_operation_id: Option<String>,
14737 _delegate: Option<&'a mut dyn common::Delegate>,
14738 _additional_params: HashMap<String, String>,
14739 _scopes: BTreeSet<String>,
14740}
14741
14742impl<'a, C> common::CallBuilder for ResponsePolicyUpdateCall<'a, C> {}
14743
14744impl<'a, C> ResponsePolicyUpdateCall<'a, C>
14745where
14746 C: common::Connector,
14747{
14748 /// Perform the operation you have build so far.
14749 pub async fn doit(
14750 mut self,
14751 ) -> common::Result<(common::Response, ResponsePoliciesUpdateResponse)> {
14752 use std::borrow::Cow;
14753 use std::io::{Read, Seek};
14754
14755 use common::{url::Params, ToParts};
14756 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14757
14758 let mut dd = common::DefaultDelegate;
14759 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14760 dlg.begin(common::MethodInfo {
14761 id: "dns.responsePolicies.update",
14762 http_method: hyper::Method::PUT,
14763 });
14764
14765 for &field in ["alt", "project", "responsePolicy", "clientOperationId"].iter() {
14766 if self._additional_params.contains_key(field) {
14767 dlg.finished(false);
14768 return Err(common::Error::FieldClash(field));
14769 }
14770 }
14771
14772 let mut params = Params::with_capacity(6 + self._additional_params.len());
14773 params.push("project", self._project);
14774 params.push("responsePolicy", self._response_policy);
14775 if let Some(value) = self._client_operation_id.as_ref() {
14776 params.push("clientOperationId", value);
14777 }
14778
14779 params.extend(self._additional_params.iter());
14780
14781 params.push("alt", "json");
14782 let mut url = self.hub._base_url.clone()
14783 + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}";
14784 if self._scopes.is_empty() {
14785 self._scopes
14786 .insert(Scope::CloudPlatform.as_ref().to_string());
14787 }
14788
14789 #[allow(clippy::single_element_loop)]
14790 for &(find_this, param_name) in [
14791 ("{project}", "project"),
14792 ("{responsePolicy}", "responsePolicy"),
14793 ]
14794 .iter()
14795 {
14796 url = params.uri_replacement(url, param_name, find_this, false);
14797 }
14798 {
14799 let to_remove = ["responsePolicy", "project"];
14800 params.remove_params(&to_remove);
14801 }
14802
14803 let url = params.parse_with_url(&url);
14804
14805 let mut json_mime_type = mime::APPLICATION_JSON;
14806 let mut request_value_reader = {
14807 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14808 common::remove_json_null_values(&mut value);
14809 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14810 serde_json::to_writer(&mut dst, &value).unwrap();
14811 dst
14812 };
14813 let request_size = request_value_reader
14814 .seek(std::io::SeekFrom::End(0))
14815 .unwrap();
14816 request_value_reader
14817 .seek(std::io::SeekFrom::Start(0))
14818 .unwrap();
14819
14820 loop {
14821 let token = match self
14822 .hub
14823 .auth
14824 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14825 .await
14826 {
14827 Ok(token) => token,
14828 Err(e) => match dlg.token(e) {
14829 Ok(token) => token,
14830 Err(e) => {
14831 dlg.finished(false);
14832 return Err(common::Error::MissingToken(e));
14833 }
14834 },
14835 };
14836 request_value_reader
14837 .seek(std::io::SeekFrom::Start(0))
14838 .unwrap();
14839 let mut req_result = {
14840 let client = &self.hub.client;
14841 dlg.pre_request();
14842 let mut req_builder = hyper::Request::builder()
14843 .method(hyper::Method::PUT)
14844 .uri(url.as_str())
14845 .header(USER_AGENT, self.hub._user_agent.clone());
14846
14847 if let Some(token) = token.as_ref() {
14848 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14849 }
14850
14851 let request = req_builder
14852 .header(CONTENT_TYPE, json_mime_type.to_string())
14853 .header(CONTENT_LENGTH, request_size as u64)
14854 .body(common::to_body(
14855 request_value_reader.get_ref().clone().into(),
14856 ));
14857
14858 client.request(request.unwrap()).await
14859 };
14860
14861 match req_result {
14862 Err(err) => {
14863 if let common::Retry::After(d) = dlg.http_error(&err) {
14864 sleep(d).await;
14865 continue;
14866 }
14867 dlg.finished(false);
14868 return Err(common::Error::HttpError(err));
14869 }
14870 Ok(res) => {
14871 let (mut parts, body) = res.into_parts();
14872 let mut body = common::Body::new(body);
14873 if !parts.status.is_success() {
14874 let bytes = common::to_bytes(body).await.unwrap_or_default();
14875 let error = serde_json::from_str(&common::to_string(&bytes));
14876 let response = common::to_response(parts, bytes.into());
14877
14878 if let common::Retry::After(d) =
14879 dlg.http_failure(&response, error.as_ref().ok())
14880 {
14881 sleep(d).await;
14882 continue;
14883 }
14884
14885 dlg.finished(false);
14886
14887 return Err(match error {
14888 Ok(value) => common::Error::BadRequest(value),
14889 _ => common::Error::Failure(response),
14890 });
14891 }
14892 let response = {
14893 let bytes = common::to_bytes(body).await.unwrap_or_default();
14894 let encoded = common::to_string(&bytes);
14895 match serde_json::from_str(&encoded) {
14896 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14897 Err(error) => {
14898 dlg.response_json_decode_error(&encoded, &error);
14899 return Err(common::Error::JsonDecodeError(
14900 encoded.to_string(),
14901 error,
14902 ));
14903 }
14904 }
14905 };
14906
14907 dlg.finished(true);
14908 return Ok(response);
14909 }
14910 }
14911 }
14912 }
14913
14914 ///
14915 /// Sets the *request* property to the given value.
14916 ///
14917 /// Even though the property as already been set when instantiating this call,
14918 /// we provide this method for API completeness.
14919 pub fn request(mut self, new_value: ResponsePolicy) -> ResponsePolicyUpdateCall<'a, C> {
14920 self._request = new_value;
14921 self
14922 }
14923 /// Identifies the project addressed by this request.
14924 ///
14925 /// Sets the *project* path property to the given value.
14926 ///
14927 /// Even though the property as already been set when instantiating this call,
14928 /// we provide this method for API completeness.
14929 pub fn project(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
14930 self._project = new_value.to_string();
14931 self
14932 }
14933 /// User assigned name of the Response Policy addressed by this request.
14934 ///
14935 /// Sets the *response policy* path property to the given value.
14936 ///
14937 /// Even though the property as already been set when instantiating this call,
14938 /// we provide this method for API completeness.
14939 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
14940 self._response_policy = new_value.to_string();
14941 self
14942 }
14943 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
14944 ///
14945 /// Sets the *client operation id* query property to the given value.
14946 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyUpdateCall<'a, C> {
14947 self._client_operation_id = Some(new_value.to_string());
14948 self
14949 }
14950 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14951 /// while executing the actual API request.
14952 ///
14953 /// ````text
14954 /// It should be used to handle progress information, and to implement a certain level of resilience.
14955 /// ````
14956 ///
14957 /// Sets the *delegate* property to the given value.
14958 pub fn delegate(
14959 mut self,
14960 new_value: &'a mut dyn common::Delegate,
14961 ) -> ResponsePolicyUpdateCall<'a, C> {
14962 self._delegate = Some(new_value);
14963 self
14964 }
14965
14966 /// Set any additional parameter of the query string used in the request.
14967 /// It should be used to set parameters which are not yet available through their own
14968 /// setters.
14969 ///
14970 /// Please note that this method must not be used to set any of the known parameters
14971 /// which have their own setter method. If done anyway, the request will fail.
14972 ///
14973 /// # Additional Parameters
14974 ///
14975 /// * *$.xgafv* (query-string) - V1 error format.
14976 /// * *access_token* (query-string) - OAuth access token.
14977 /// * *alt* (query-string) - Data format for response.
14978 /// * *callback* (query-string) - JSONP
14979 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14980 /// * *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.
14981 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14982 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14983 /// * *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.
14984 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14985 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14986 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyUpdateCall<'a, C>
14987 where
14988 T: AsRef<str>,
14989 {
14990 self._additional_params
14991 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14992 self
14993 }
14994
14995 /// Identifies the authorization scope for the method you are building.
14996 ///
14997 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14998 /// [`Scope::CloudPlatform`].
14999 ///
15000 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15001 /// tokens for more than one scope.
15002 ///
15003 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15004 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15005 /// sufficient, a read-write scope will do as well.
15006 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyUpdateCall<'a, C>
15007 where
15008 St: AsRef<str>,
15009 {
15010 self._scopes.insert(String::from(scope.as_ref()));
15011 self
15012 }
15013 /// Identifies the authorization scope(s) for the method you are building.
15014 ///
15015 /// See [`Self::add_scope()`] for details.
15016 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyUpdateCall<'a, C>
15017 where
15018 I: IntoIterator<Item = St>,
15019 St: AsRef<str>,
15020 {
15021 self._scopes
15022 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15023 self
15024 }
15025
15026 /// Removes all scopes, and no default scope will be used either.
15027 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15028 /// for details).
15029 pub fn clear_scopes(mut self) -> ResponsePolicyUpdateCall<'a, C> {
15030 self._scopes.clear();
15031 self
15032 }
15033}
15034
15035/// Creates a new Response Policy Rule.
15036///
15037/// A builder for the *create* method supported by a *responsePolicyRule* resource.
15038/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
15039///
15040/// # Example
15041///
15042/// Instantiate a resource method builder
15043///
15044/// ```test_harness,no_run
15045/// # extern crate hyper;
15046/// # extern crate hyper_rustls;
15047/// # extern crate google_dns1 as dns1;
15048/// use dns1::api::ResponsePolicyRule;
15049/// # async fn dox() {
15050/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15051///
15052/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15053/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15054/// # .with_native_roots()
15055/// # .unwrap()
15056/// # .https_only()
15057/// # .enable_http2()
15058/// # .build();
15059///
15060/// # let executor = hyper_util::rt::TokioExecutor::new();
15061/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15062/// # secret,
15063/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15064/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15065/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15066/// # ),
15067/// # ).build().await.unwrap();
15068///
15069/// # let client = hyper_util::client::legacy::Client::builder(
15070/// # hyper_util::rt::TokioExecutor::new()
15071/// # )
15072/// # .build(
15073/// # hyper_rustls::HttpsConnectorBuilder::new()
15074/// # .with_native_roots()
15075/// # .unwrap()
15076/// # .https_or_http()
15077/// # .enable_http2()
15078/// # .build()
15079/// # );
15080/// # let mut hub = Dns::new(client, auth);
15081/// // As the method needs a request, you would usually fill it with the desired information
15082/// // into the respective structure. Some of the parts shown here might not be applicable !
15083/// // Values shown here are possibly random and not representative !
15084/// let mut req = ResponsePolicyRule::default();
15085///
15086/// // You can configure optional parameters by calling the respective setters at will, and
15087/// // execute the final call using `doit()`.
15088/// // Values shown here are possibly random and not representative !
15089/// let result = hub.response_policy_rules().create(req, "project", "responsePolicy")
15090/// .client_operation_id("dolores")
15091/// .doit().await;
15092/// # }
15093/// ```
15094pub struct ResponsePolicyRuleCreateCall<'a, C>
15095where
15096 C: 'a,
15097{
15098 hub: &'a Dns<C>,
15099 _request: ResponsePolicyRule,
15100 _project: String,
15101 _response_policy: String,
15102 _client_operation_id: Option<String>,
15103 _delegate: Option<&'a mut dyn common::Delegate>,
15104 _additional_params: HashMap<String, String>,
15105 _scopes: BTreeSet<String>,
15106}
15107
15108impl<'a, C> common::CallBuilder for ResponsePolicyRuleCreateCall<'a, C> {}
15109
15110impl<'a, C> ResponsePolicyRuleCreateCall<'a, C>
15111where
15112 C: common::Connector,
15113{
15114 /// Perform the operation you have build so far.
15115 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicyRule)> {
15116 use std::borrow::Cow;
15117 use std::io::{Read, Seek};
15118
15119 use common::{url::Params, ToParts};
15120 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15121
15122 let mut dd = common::DefaultDelegate;
15123 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15124 dlg.begin(common::MethodInfo {
15125 id: "dns.responsePolicyRules.create",
15126 http_method: hyper::Method::POST,
15127 });
15128
15129 for &field in ["alt", "project", "responsePolicy", "clientOperationId"].iter() {
15130 if self._additional_params.contains_key(field) {
15131 dlg.finished(false);
15132 return Err(common::Error::FieldClash(field));
15133 }
15134 }
15135
15136 let mut params = Params::with_capacity(6 + self._additional_params.len());
15137 params.push("project", self._project);
15138 params.push("responsePolicy", self._response_policy);
15139 if let Some(value) = self._client_operation_id.as_ref() {
15140 params.push("clientOperationId", value);
15141 }
15142
15143 params.extend(self._additional_params.iter());
15144
15145 params.push("alt", "json");
15146 let mut url = self.hub._base_url.clone()
15147 + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules";
15148 if self._scopes.is_empty() {
15149 self._scopes
15150 .insert(Scope::CloudPlatform.as_ref().to_string());
15151 }
15152
15153 #[allow(clippy::single_element_loop)]
15154 for &(find_this, param_name) in [
15155 ("{project}", "project"),
15156 ("{responsePolicy}", "responsePolicy"),
15157 ]
15158 .iter()
15159 {
15160 url = params.uri_replacement(url, param_name, find_this, false);
15161 }
15162 {
15163 let to_remove = ["responsePolicy", "project"];
15164 params.remove_params(&to_remove);
15165 }
15166
15167 let url = params.parse_with_url(&url);
15168
15169 let mut json_mime_type = mime::APPLICATION_JSON;
15170 let mut request_value_reader = {
15171 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15172 common::remove_json_null_values(&mut value);
15173 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15174 serde_json::to_writer(&mut dst, &value).unwrap();
15175 dst
15176 };
15177 let request_size = request_value_reader
15178 .seek(std::io::SeekFrom::End(0))
15179 .unwrap();
15180 request_value_reader
15181 .seek(std::io::SeekFrom::Start(0))
15182 .unwrap();
15183
15184 loop {
15185 let token = match self
15186 .hub
15187 .auth
15188 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15189 .await
15190 {
15191 Ok(token) => token,
15192 Err(e) => match dlg.token(e) {
15193 Ok(token) => token,
15194 Err(e) => {
15195 dlg.finished(false);
15196 return Err(common::Error::MissingToken(e));
15197 }
15198 },
15199 };
15200 request_value_reader
15201 .seek(std::io::SeekFrom::Start(0))
15202 .unwrap();
15203 let mut req_result = {
15204 let client = &self.hub.client;
15205 dlg.pre_request();
15206 let mut req_builder = hyper::Request::builder()
15207 .method(hyper::Method::POST)
15208 .uri(url.as_str())
15209 .header(USER_AGENT, self.hub._user_agent.clone());
15210
15211 if let Some(token) = token.as_ref() {
15212 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15213 }
15214
15215 let request = req_builder
15216 .header(CONTENT_TYPE, json_mime_type.to_string())
15217 .header(CONTENT_LENGTH, request_size as u64)
15218 .body(common::to_body(
15219 request_value_reader.get_ref().clone().into(),
15220 ));
15221
15222 client.request(request.unwrap()).await
15223 };
15224
15225 match req_result {
15226 Err(err) => {
15227 if let common::Retry::After(d) = dlg.http_error(&err) {
15228 sleep(d).await;
15229 continue;
15230 }
15231 dlg.finished(false);
15232 return Err(common::Error::HttpError(err));
15233 }
15234 Ok(res) => {
15235 let (mut parts, body) = res.into_parts();
15236 let mut body = common::Body::new(body);
15237 if !parts.status.is_success() {
15238 let bytes = common::to_bytes(body).await.unwrap_or_default();
15239 let error = serde_json::from_str(&common::to_string(&bytes));
15240 let response = common::to_response(parts, bytes.into());
15241
15242 if let common::Retry::After(d) =
15243 dlg.http_failure(&response, error.as_ref().ok())
15244 {
15245 sleep(d).await;
15246 continue;
15247 }
15248
15249 dlg.finished(false);
15250
15251 return Err(match error {
15252 Ok(value) => common::Error::BadRequest(value),
15253 _ => common::Error::Failure(response),
15254 });
15255 }
15256 let response = {
15257 let bytes = common::to_bytes(body).await.unwrap_or_default();
15258 let encoded = common::to_string(&bytes);
15259 match serde_json::from_str(&encoded) {
15260 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15261 Err(error) => {
15262 dlg.response_json_decode_error(&encoded, &error);
15263 return Err(common::Error::JsonDecodeError(
15264 encoded.to_string(),
15265 error,
15266 ));
15267 }
15268 }
15269 };
15270
15271 dlg.finished(true);
15272 return Ok(response);
15273 }
15274 }
15275 }
15276 }
15277
15278 ///
15279 /// Sets the *request* property to the given value.
15280 ///
15281 /// Even though the property as already been set when instantiating this call,
15282 /// we provide this method for API completeness.
15283 pub fn request(mut self, new_value: ResponsePolicyRule) -> ResponsePolicyRuleCreateCall<'a, C> {
15284 self._request = new_value;
15285 self
15286 }
15287 /// Identifies the project addressed by this request.
15288 ///
15289 /// Sets the *project* path property to the given value.
15290 ///
15291 /// Even though the property as already been set when instantiating this call,
15292 /// we provide this method for API completeness.
15293 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15294 self._project = new_value.to_string();
15295 self
15296 }
15297 /// User assigned name of the Response Policy containing the Response Policy Rule.
15298 ///
15299 /// Sets the *response policy* path property to the given value.
15300 ///
15301 /// Even though the property as already been set when instantiating this call,
15302 /// we provide this method for API completeness.
15303 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15304 self._response_policy = new_value.to_string();
15305 self
15306 }
15307 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
15308 ///
15309 /// Sets the *client operation id* query property to the given value.
15310 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleCreateCall<'a, C> {
15311 self._client_operation_id = Some(new_value.to_string());
15312 self
15313 }
15314 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15315 /// while executing the actual API request.
15316 ///
15317 /// ````text
15318 /// It should be used to handle progress information, and to implement a certain level of resilience.
15319 /// ````
15320 ///
15321 /// Sets the *delegate* property to the given value.
15322 pub fn delegate(
15323 mut self,
15324 new_value: &'a mut dyn common::Delegate,
15325 ) -> ResponsePolicyRuleCreateCall<'a, C> {
15326 self._delegate = Some(new_value);
15327 self
15328 }
15329
15330 /// Set any additional parameter of the query string used in the request.
15331 /// It should be used to set parameters which are not yet available through their own
15332 /// setters.
15333 ///
15334 /// Please note that this method must not be used to set any of the known parameters
15335 /// which have their own setter method. If done anyway, the request will fail.
15336 ///
15337 /// # Additional Parameters
15338 ///
15339 /// * *$.xgafv* (query-string) - V1 error format.
15340 /// * *access_token* (query-string) - OAuth access token.
15341 /// * *alt* (query-string) - Data format for response.
15342 /// * *callback* (query-string) - JSONP
15343 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15344 /// * *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.
15345 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15346 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15347 /// * *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.
15348 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15349 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15350 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleCreateCall<'a, C>
15351 where
15352 T: AsRef<str>,
15353 {
15354 self._additional_params
15355 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15356 self
15357 }
15358
15359 /// Identifies the authorization scope for the method you are building.
15360 ///
15361 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15362 /// [`Scope::CloudPlatform`].
15363 ///
15364 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15365 /// tokens for more than one scope.
15366 ///
15367 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15368 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15369 /// sufficient, a read-write scope will do as well.
15370 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleCreateCall<'a, C>
15371 where
15372 St: AsRef<str>,
15373 {
15374 self._scopes.insert(String::from(scope.as_ref()));
15375 self
15376 }
15377 /// Identifies the authorization scope(s) for the method you are building.
15378 ///
15379 /// See [`Self::add_scope()`] for details.
15380 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleCreateCall<'a, C>
15381 where
15382 I: IntoIterator<Item = St>,
15383 St: AsRef<str>,
15384 {
15385 self._scopes
15386 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15387 self
15388 }
15389
15390 /// Removes all scopes, and no default scope will be used either.
15391 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15392 /// for details).
15393 pub fn clear_scopes(mut self) -> ResponsePolicyRuleCreateCall<'a, C> {
15394 self._scopes.clear();
15395 self
15396 }
15397}
15398
15399/// Deletes a previously created Response Policy Rule.
15400///
15401/// A builder for the *delete* method supported by a *responsePolicyRule* resource.
15402/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
15403///
15404/// # Example
15405///
15406/// Instantiate a resource method builder
15407///
15408/// ```test_harness,no_run
15409/// # extern crate hyper;
15410/// # extern crate hyper_rustls;
15411/// # extern crate google_dns1 as dns1;
15412/// # async fn dox() {
15413/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15414///
15415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15416/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15417/// # .with_native_roots()
15418/// # .unwrap()
15419/// # .https_only()
15420/// # .enable_http2()
15421/// # .build();
15422///
15423/// # let executor = hyper_util::rt::TokioExecutor::new();
15424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15425/// # secret,
15426/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15427/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15428/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15429/// # ),
15430/// # ).build().await.unwrap();
15431///
15432/// # let client = hyper_util::client::legacy::Client::builder(
15433/// # hyper_util::rt::TokioExecutor::new()
15434/// # )
15435/// # .build(
15436/// # hyper_rustls::HttpsConnectorBuilder::new()
15437/// # .with_native_roots()
15438/// # .unwrap()
15439/// # .https_or_http()
15440/// # .enable_http2()
15441/// # .build()
15442/// # );
15443/// # let mut hub = Dns::new(client, auth);
15444/// // You can configure optional parameters by calling the respective setters at will, and
15445/// // execute the final call using `doit()`.
15446/// // Values shown here are possibly random and not representative !
15447/// let result = hub.response_policy_rules().delete("project", "responsePolicy", "responsePolicyRule")
15448/// .client_operation_id("amet")
15449/// .doit().await;
15450/// # }
15451/// ```
15452pub struct ResponsePolicyRuleDeleteCall<'a, C>
15453where
15454 C: 'a,
15455{
15456 hub: &'a Dns<C>,
15457 _project: String,
15458 _response_policy: String,
15459 _response_policy_rule: String,
15460 _client_operation_id: Option<String>,
15461 _delegate: Option<&'a mut dyn common::Delegate>,
15462 _additional_params: HashMap<String, String>,
15463 _scopes: BTreeSet<String>,
15464}
15465
15466impl<'a, C> common::CallBuilder for ResponsePolicyRuleDeleteCall<'a, C> {}
15467
15468impl<'a, C> ResponsePolicyRuleDeleteCall<'a, C>
15469where
15470 C: common::Connector,
15471{
15472 /// Perform the operation you have build so far.
15473 pub async fn doit(mut self) -> common::Result<common::Response> {
15474 use std::borrow::Cow;
15475 use std::io::{Read, Seek};
15476
15477 use common::{url::Params, ToParts};
15478 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15479
15480 let mut dd = common::DefaultDelegate;
15481 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15482 dlg.begin(common::MethodInfo {
15483 id: "dns.responsePolicyRules.delete",
15484 http_method: hyper::Method::DELETE,
15485 });
15486
15487 for &field in [
15488 "project",
15489 "responsePolicy",
15490 "responsePolicyRule",
15491 "clientOperationId",
15492 ]
15493 .iter()
15494 {
15495 if self._additional_params.contains_key(field) {
15496 dlg.finished(false);
15497 return Err(common::Error::FieldClash(field));
15498 }
15499 }
15500
15501 let mut params = Params::with_capacity(5 + self._additional_params.len());
15502 params.push("project", self._project);
15503 params.push("responsePolicy", self._response_policy);
15504 params.push("responsePolicyRule", self._response_policy_rule);
15505 if let Some(value) = self._client_operation_id.as_ref() {
15506 params.push("clientOperationId", value);
15507 }
15508
15509 params.extend(self._additional_params.iter());
15510
15511 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
15512 if self._scopes.is_empty() {
15513 self._scopes
15514 .insert(Scope::CloudPlatform.as_ref().to_string());
15515 }
15516
15517 #[allow(clippy::single_element_loop)]
15518 for &(find_this, param_name) in [
15519 ("{project}", "project"),
15520 ("{responsePolicy}", "responsePolicy"),
15521 ("{responsePolicyRule}", "responsePolicyRule"),
15522 ]
15523 .iter()
15524 {
15525 url = params.uri_replacement(url, param_name, find_this, false);
15526 }
15527 {
15528 let to_remove = ["responsePolicyRule", "responsePolicy", "project"];
15529 params.remove_params(&to_remove);
15530 }
15531
15532 let url = params.parse_with_url(&url);
15533
15534 loop {
15535 let token = match self
15536 .hub
15537 .auth
15538 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15539 .await
15540 {
15541 Ok(token) => token,
15542 Err(e) => match dlg.token(e) {
15543 Ok(token) => token,
15544 Err(e) => {
15545 dlg.finished(false);
15546 return Err(common::Error::MissingToken(e));
15547 }
15548 },
15549 };
15550 let mut req_result = {
15551 let client = &self.hub.client;
15552 dlg.pre_request();
15553 let mut req_builder = hyper::Request::builder()
15554 .method(hyper::Method::DELETE)
15555 .uri(url.as_str())
15556 .header(USER_AGENT, self.hub._user_agent.clone());
15557
15558 if let Some(token) = token.as_ref() {
15559 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15560 }
15561
15562 let request = req_builder
15563 .header(CONTENT_LENGTH, 0_u64)
15564 .body(common::to_body::<String>(None));
15565
15566 client.request(request.unwrap()).await
15567 };
15568
15569 match req_result {
15570 Err(err) => {
15571 if let common::Retry::After(d) = dlg.http_error(&err) {
15572 sleep(d).await;
15573 continue;
15574 }
15575 dlg.finished(false);
15576 return Err(common::Error::HttpError(err));
15577 }
15578 Ok(res) => {
15579 let (mut parts, body) = res.into_parts();
15580 let mut body = common::Body::new(body);
15581 if !parts.status.is_success() {
15582 let bytes = common::to_bytes(body).await.unwrap_or_default();
15583 let error = serde_json::from_str(&common::to_string(&bytes));
15584 let response = common::to_response(parts, bytes.into());
15585
15586 if let common::Retry::After(d) =
15587 dlg.http_failure(&response, error.as_ref().ok())
15588 {
15589 sleep(d).await;
15590 continue;
15591 }
15592
15593 dlg.finished(false);
15594
15595 return Err(match error {
15596 Ok(value) => common::Error::BadRequest(value),
15597 _ => common::Error::Failure(response),
15598 });
15599 }
15600 let response = common::Response::from_parts(parts, body);
15601
15602 dlg.finished(true);
15603 return Ok(response);
15604 }
15605 }
15606 }
15607 }
15608
15609 /// Identifies the project addressed by this request.
15610 ///
15611 /// Sets the *project* path property to the given value.
15612 ///
15613 /// Even though the property as already been set when instantiating this call,
15614 /// we provide this method for API completeness.
15615 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
15616 self._project = new_value.to_string();
15617 self
15618 }
15619 /// User assigned name of the Response Policy containing the Response Policy Rule.
15620 ///
15621 /// Sets the *response policy* path property to the given value.
15622 ///
15623 /// Even though the property as already been set when instantiating this call,
15624 /// we provide this method for API completeness.
15625 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
15626 self._response_policy = new_value.to_string();
15627 self
15628 }
15629 /// User assigned name of the Response Policy Rule addressed by this request.
15630 ///
15631 /// Sets the *response policy rule* path property to the given value.
15632 ///
15633 /// Even though the property as already been set when instantiating this call,
15634 /// we provide this method for API completeness.
15635 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
15636 self._response_policy_rule = new_value.to_string();
15637 self
15638 }
15639 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
15640 ///
15641 /// Sets the *client operation id* query property to the given value.
15642 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleDeleteCall<'a, C> {
15643 self._client_operation_id = Some(new_value.to_string());
15644 self
15645 }
15646 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15647 /// while executing the actual API request.
15648 ///
15649 /// ````text
15650 /// It should be used to handle progress information, and to implement a certain level of resilience.
15651 /// ````
15652 ///
15653 /// Sets the *delegate* property to the given value.
15654 pub fn delegate(
15655 mut self,
15656 new_value: &'a mut dyn common::Delegate,
15657 ) -> ResponsePolicyRuleDeleteCall<'a, C> {
15658 self._delegate = Some(new_value);
15659 self
15660 }
15661
15662 /// Set any additional parameter of the query string used in the request.
15663 /// It should be used to set parameters which are not yet available through their own
15664 /// setters.
15665 ///
15666 /// Please note that this method must not be used to set any of the known parameters
15667 /// which have their own setter method. If done anyway, the request will fail.
15668 ///
15669 /// # Additional Parameters
15670 ///
15671 /// * *$.xgafv* (query-string) - V1 error format.
15672 /// * *access_token* (query-string) - OAuth access token.
15673 /// * *alt* (query-string) - Data format for response.
15674 /// * *callback* (query-string) - JSONP
15675 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15676 /// * *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.
15677 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15678 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15679 /// * *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.
15680 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15681 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15682 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleDeleteCall<'a, C>
15683 where
15684 T: AsRef<str>,
15685 {
15686 self._additional_params
15687 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15688 self
15689 }
15690
15691 /// Identifies the authorization scope for the method you are building.
15692 ///
15693 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15694 /// [`Scope::CloudPlatform`].
15695 ///
15696 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15697 /// tokens for more than one scope.
15698 ///
15699 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15700 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15701 /// sufficient, a read-write scope will do as well.
15702 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleDeleteCall<'a, C>
15703 where
15704 St: AsRef<str>,
15705 {
15706 self._scopes.insert(String::from(scope.as_ref()));
15707 self
15708 }
15709 /// Identifies the authorization scope(s) for the method you are building.
15710 ///
15711 /// See [`Self::add_scope()`] for details.
15712 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleDeleteCall<'a, C>
15713 where
15714 I: IntoIterator<Item = St>,
15715 St: AsRef<str>,
15716 {
15717 self._scopes
15718 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15719 self
15720 }
15721
15722 /// Removes all scopes, and no default scope will be used either.
15723 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15724 /// for details).
15725 pub fn clear_scopes(mut self) -> ResponsePolicyRuleDeleteCall<'a, C> {
15726 self._scopes.clear();
15727 self
15728 }
15729}
15730
15731/// Fetches the representation of an existing Response Policy Rule.
15732///
15733/// A builder for the *get* method supported by a *responsePolicyRule* resource.
15734/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
15735///
15736/// # Example
15737///
15738/// Instantiate a resource method builder
15739///
15740/// ```test_harness,no_run
15741/// # extern crate hyper;
15742/// # extern crate hyper_rustls;
15743/// # extern crate google_dns1 as dns1;
15744/// # async fn dox() {
15745/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15746///
15747/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15748/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15749/// # .with_native_roots()
15750/// # .unwrap()
15751/// # .https_only()
15752/// # .enable_http2()
15753/// # .build();
15754///
15755/// # let executor = hyper_util::rt::TokioExecutor::new();
15756/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15757/// # secret,
15758/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15759/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15760/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15761/// # ),
15762/// # ).build().await.unwrap();
15763///
15764/// # let client = hyper_util::client::legacy::Client::builder(
15765/// # hyper_util::rt::TokioExecutor::new()
15766/// # )
15767/// # .build(
15768/// # hyper_rustls::HttpsConnectorBuilder::new()
15769/// # .with_native_roots()
15770/// # .unwrap()
15771/// # .https_or_http()
15772/// # .enable_http2()
15773/// # .build()
15774/// # );
15775/// # let mut hub = Dns::new(client, auth);
15776/// // You can configure optional parameters by calling the respective setters at will, and
15777/// // execute the final call using `doit()`.
15778/// // Values shown here are possibly random and not representative !
15779/// let result = hub.response_policy_rules().get("project", "responsePolicy", "responsePolicyRule")
15780/// .client_operation_id("consetetur")
15781/// .doit().await;
15782/// # }
15783/// ```
15784pub struct ResponsePolicyRuleGetCall<'a, C>
15785where
15786 C: 'a,
15787{
15788 hub: &'a Dns<C>,
15789 _project: String,
15790 _response_policy: String,
15791 _response_policy_rule: String,
15792 _client_operation_id: Option<String>,
15793 _delegate: Option<&'a mut dyn common::Delegate>,
15794 _additional_params: HashMap<String, String>,
15795 _scopes: BTreeSet<String>,
15796}
15797
15798impl<'a, C> common::CallBuilder for ResponsePolicyRuleGetCall<'a, C> {}
15799
15800impl<'a, C> ResponsePolicyRuleGetCall<'a, C>
15801where
15802 C: common::Connector,
15803{
15804 /// Perform the operation you have build so far.
15805 pub async fn doit(mut self) -> common::Result<(common::Response, ResponsePolicyRule)> {
15806 use std::borrow::Cow;
15807 use std::io::{Read, Seek};
15808
15809 use common::{url::Params, ToParts};
15810 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15811
15812 let mut dd = common::DefaultDelegate;
15813 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15814 dlg.begin(common::MethodInfo {
15815 id: "dns.responsePolicyRules.get",
15816 http_method: hyper::Method::GET,
15817 });
15818
15819 for &field in [
15820 "alt",
15821 "project",
15822 "responsePolicy",
15823 "responsePolicyRule",
15824 "clientOperationId",
15825 ]
15826 .iter()
15827 {
15828 if self._additional_params.contains_key(field) {
15829 dlg.finished(false);
15830 return Err(common::Error::FieldClash(field));
15831 }
15832 }
15833
15834 let mut params = Params::with_capacity(6 + self._additional_params.len());
15835 params.push("project", self._project);
15836 params.push("responsePolicy", self._response_policy);
15837 params.push("responsePolicyRule", self._response_policy_rule);
15838 if let Some(value) = self._client_operation_id.as_ref() {
15839 params.push("clientOperationId", value);
15840 }
15841
15842 params.extend(self._additional_params.iter());
15843
15844 params.push("alt", "json");
15845 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
15846 if self._scopes.is_empty() {
15847 self._scopes
15848 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
15849 }
15850
15851 #[allow(clippy::single_element_loop)]
15852 for &(find_this, param_name) in [
15853 ("{project}", "project"),
15854 ("{responsePolicy}", "responsePolicy"),
15855 ("{responsePolicyRule}", "responsePolicyRule"),
15856 ]
15857 .iter()
15858 {
15859 url = params.uri_replacement(url, param_name, find_this, false);
15860 }
15861 {
15862 let to_remove = ["responsePolicyRule", "responsePolicy", "project"];
15863 params.remove_params(&to_remove);
15864 }
15865
15866 let url = params.parse_with_url(&url);
15867
15868 loop {
15869 let token = match self
15870 .hub
15871 .auth
15872 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15873 .await
15874 {
15875 Ok(token) => token,
15876 Err(e) => match dlg.token(e) {
15877 Ok(token) => token,
15878 Err(e) => {
15879 dlg.finished(false);
15880 return Err(common::Error::MissingToken(e));
15881 }
15882 },
15883 };
15884 let mut req_result = {
15885 let client = &self.hub.client;
15886 dlg.pre_request();
15887 let mut req_builder = hyper::Request::builder()
15888 .method(hyper::Method::GET)
15889 .uri(url.as_str())
15890 .header(USER_AGENT, self.hub._user_agent.clone());
15891
15892 if let Some(token) = token.as_ref() {
15893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15894 }
15895
15896 let request = req_builder
15897 .header(CONTENT_LENGTH, 0_u64)
15898 .body(common::to_body::<String>(None));
15899
15900 client.request(request.unwrap()).await
15901 };
15902
15903 match req_result {
15904 Err(err) => {
15905 if let common::Retry::After(d) = dlg.http_error(&err) {
15906 sleep(d).await;
15907 continue;
15908 }
15909 dlg.finished(false);
15910 return Err(common::Error::HttpError(err));
15911 }
15912 Ok(res) => {
15913 let (mut parts, body) = res.into_parts();
15914 let mut body = common::Body::new(body);
15915 if !parts.status.is_success() {
15916 let bytes = common::to_bytes(body).await.unwrap_or_default();
15917 let error = serde_json::from_str(&common::to_string(&bytes));
15918 let response = common::to_response(parts, bytes.into());
15919
15920 if let common::Retry::After(d) =
15921 dlg.http_failure(&response, error.as_ref().ok())
15922 {
15923 sleep(d).await;
15924 continue;
15925 }
15926
15927 dlg.finished(false);
15928
15929 return Err(match error {
15930 Ok(value) => common::Error::BadRequest(value),
15931 _ => common::Error::Failure(response),
15932 });
15933 }
15934 let response = {
15935 let bytes = common::to_bytes(body).await.unwrap_or_default();
15936 let encoded = common::to_string(&bytes);
15937 match serde_json::from_str(&encoded) {
15938 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15939 Err(error) => {
15940 dlg.response_json_decode_error(&encoded, &error);
15941 return Err(common::Error::JsonDecodeError(
15942 encoded.to_string(),
15943 error,
15944 ));
15945 }
15946 }
15947 };
15948
15949 dlg.finished(true);
15950 return Ok(response);
15951 }
15952 }
15953 }
15954 }
15955
15956 /// Identifies the project addressed by this request.
15957 ///
15958 /// Sets the *project* path property to the given value.
15959 ///
15960 /// Even though the property as already been set when instantiating this call,
15961 /// we provide this method for API completeness.
15962 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
15963 self._project = new_value.to_string();
15964 self
15965 }
15966 /// User assigned name of the Response Policy containing the Response Policy Rule.
15967 ///
15968 /// Sets the *response policy* path property to the given value.
15969 ///
15970 /// Even though the property as already been set when instantiating this call,
15971 /// we provide this method for API completeness.
15972 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
15973 self._response_policy = new_value.to_string();
15974 self
15975 }
15976 /// User assigned name of the Response Policy Rule addressed by this request.
15977 ///
15978 /// Sets the *response policy rule* path property to the given value.
15979 ///
15980 /// Even though the property as already been set when instantiating this call,
15981 /// we provide this method for API completeness.
15982 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
15983 self._response_policy_rule = new_value.to_string();
15984 self
15985 }
15986 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
15987 ///
15988 /// Sets the *client operation id* query property to the given value.
15989 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleGetCall<'a, C> {
15990 self._client_operation_id = Some(new_value.to_string());
15991 self
15992 }
15993 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15994 /// while executing the actual API request.
15995 ///
15996 /// ````text
15997 /// It should be used to handle progress information, and to implement a certain level of resilience.
15998 /// ````
15999 ///
16000 /// Sets the *delegate* property to the given value.
16001 pub fn delegate(
16002 mut self,
16003 new_value: &'a mut dyn common::Delegate,
16004 ) -> ResponsePolicyRuleGetCall<'a, C> {
16005 self._delegate = Some(new_value);
16006 self
16007 }
16008
16009 /// Set any additional parameter of the query string used in the request.
16010 /// It should be used to set parameters which are not yet available through their own
16011 /// setters.
16012 ///
16013 /// Please note that this method must not be used to set any of the known parameters
16014 /// which have their own setter method. If done anyway, the request will fail.
16015 ///
16016 /// # Additional Parameters
16017 ///
16018 /// * *$.xgafv* (query-string) - V1 error format.
16019 /// * *access_token* (query-string) - OAuth access token.
16020 /// * *alt* (query-string) - Data format for response.
16021 /// * *callback* (query-string) - JSONP
16022 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16023 /// * *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.
16024 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16025 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16026 /// * *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.
16027 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16028 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16029 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleGetCall<'a, C>
16030 where
16031 T: AsRef<str>,
16032 {
16033 self._additional_params
16034 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16035 self
16036 }
16037
16038 /// Identifies the authorization scope for the method you are building.
16039 ///
16040 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16041 /// [`Scope::NdevClouddnReadonly`].
16042 ///
16043 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16044 /// tokens for more than one scope.
16045 ///
16046 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16047 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16048 /// sufficient, a read-write scope will do as well.
16049 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleGetCall<'a, C>
16050 where
16051 St: AsRef<str>,
16052 {
16053 self._scopes.insert(String::from(scope.as_ref()));
16054 self
16055 }
16056 /// Identifies the authorization scope(s) for the method you are building.
16057 ///
16058 /// See [`Self::add_scope()`] for details.
16059 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleGetCall<'a, C>
16060 where
16061 I: IntoIterator<Item = St>,
16062 St: AsRef<str>,
16063 {
16064 self._scopes
16065 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16066 self
16067 }
16068
16069 /// Removes all scopes, and no default scope will be used either.
16070 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16071 /// for details).
16072 pub fn clear_scopes(mut self) -> ResponsePolicyRuleGetCall<'a, C> {
16073 self._scopes.clear();
16074 self
16075 }
16076}
16077
16078/// Enumerates all Response Policy Rules associated with a project.
16079///
16080/// A builder for the *list* method supported by a *responsePolicyRule* resource.
16081/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
16082///
16083/// # Example
16084///
16085/// Instantiate a resource method builder
16086///
16087/// ```test_harness,no_run
16088/// # extern crate hyper;
16089/// # extern crate hyper_rustls;
16090/// # extern crate google_dns1 as dns1;
16091/// # async fn dox() {
16092/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16093///
16094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16095/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16096/// # .with_native_roots()
16097/// # .unwrap()
16098/// # .https_only()
16099/// # .enable_http2()
16100/// # .build();
16101///
16102/// # let executor = hyper_util::rt::TokioExecutor::new();
16103/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16104/// # secret,
16105/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16106/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16107/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16108/// # ),
16109/// # ).build().await.unwrap();
16110///
16111/// # let client = hyper_util::client::legacy::Client::builder(
16112/// # hyper_util::rt::TokioExecutor::new()
16113/// # )
16114/// # .build(
16115/// # hyper_rustls::HttpsConnectorBuilder::new()
16116/// # .with_native_roots()
16117/// # .unwrap()
16118/// # .https_or_http()
16119/// # .enable_http2()
16120/// # .build()
16121/// # );
16122/// # let mut hub = Dns::new(client, auth);
16123/// // You can configure optional parameters by calling the respective setters at will, and
16124/// // execute the final call using `doit()`.
16125/// // Values shown here are possibly random and not representative !
16126/// let result = hub.response_policy_rules().list("project", "responsePolicy")
16127/// .page_token("est")
16128/// .max_results(-82)
16129/// .doit().await;
16130/// # }
16131/// ```
16132pub struct ResponsePolicyRuleListCall<'a, C>
16133where
16134 C: 'a,
16135{
16136 hub: &'a Dns<C>,
16137 _project: String,
16138 _response_policy: String,
16139 _page_token: Option<String>,
16140 _max_results: Option<i32>,
16141 _delegate: Option<&'a mut dyn common::Delegate>,
16142 _additional_params: HashMap<String, String>,
16143 _scopes: BTreeSet<String>,
16144}
16145
16146impl<'a, C> common::CallBuilder for ResponsePolicyRuleListCall<'a, C> {}
16147
16148impl<'a, C> ResponsePolicyRuleListCall<'a, C>
16149where
16150 C: common::Connector,
16151{
16152 /// Perform the operation you have build so far.
16153 pub async fn doit(
16154 mut self,
16155 ) -> common::Result<(common::Response, ResponsePolicyRulesListResponse)> {
16156 use std::borrow::Cow;
16157 use std::io::{Read, Seek};
16158
16159 use common::{url::Params, ToParts};
16160 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16161
16162 let mut dd = common::DefaultDelegate;
16163 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16164 dlg.begin(common::MethodInfo {
16165 id: "dns.responsePolicyRules.list",
16166 http_method: hyper::Method::GET,
16167 });
16168
16169 for &field in [
16170 "alt",
16171 "project",
16172 "responsePolicy",
16173 "pageToken",
16174 "maxResults",
16175 ]
16176 .iter()
16177 {
16178 if self._additional_params.contains_key(field) {
16179 dlg.finished(false);
16180 return Err(common::Error::FieldClash(field));
16181 }
16182 }
16183
16184 let mut params = Params::with_capacity(6 + self._additional_params.len());
16185 params.push("project", self._project);
16186 params.push("responsePolicy", self._response_policy);
16187 if let Some(value) = self._page_token.as_ref() {
16188 params.push("pageToken", value);
16189 }
16190 if let Some(value) = self._max_results.as_ref() {
16191 params.push("maxResults", value.to_string());
16192 }
16193
16194 params.extend(self._additional_params.iter());
16195
16196 params.push("alt", "json");
16197 let mut url = self.hub._base_url.clone()
16198 + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules";
16199 if self._scopes.is_empty() {
16200 self._scopes
16201 .insert(Scope::NdevClouddnReadonly.as_ref().to_string());
16202 }
16203
16204 #[allow(clippy::single_element_loop)]
16205 for &(find_this, param_name) in [
16206 ("{project}", "project"),
16207 ("{responsePolicy}", "responsePolicy"),
16208 ]
16209 .iter()
16210 {
16211 url = params.uri_replacement(url, param_name, find_this, false);
16212 }
16213 {
16214 let to_remove = ["responsePolicy", "project"];
16215 params.remove_params(&to_remove);
16216 }
16217
16218 let url = params.parse_with_url(&url);
16219
16220 loop {
16221 let token = match self
16222 .hub
16223 .auth
16224 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16225 .await
16226 {
16227 Ok(token) => token,
16228 Err(e) => match dlg.token(e) {
16229 Ok(token) => token,
16230 Err(e) => {
16231 dlg.finished(false);
16232 return Err(common::Error::MissingToken(e));
16233 }
16234 },
16235 };
16236 let mut req_result = {
16237 let client = &self.hub.client;
16238 dlg.pre_request();
16239 let mut req_builder = hyper::Request::builder()
16240 .method(hyper::Method::GET)
16241 .uri(url.as_str())
16242 .header(USER_AGENT, self.hub._user_agent.clone());
16243
16244 if let Some(token) = token.as_ref() {
16245 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16246 }
16247
16248 let request = req_builder
16249 .header(CONTENT_LENGTH, 0_u64)
16250 .body(common::to_body::<String>(None));
16251
16252 client.request(request.unwrap()).await
16253 };
16254
16255 match req_result {
16256 Err(err) => {
16257 if let common::Retry::After(d) = dlg.http_error(&err) {
16258 sleep(d).await;
16259 continue;
16260 }
16261 dlg.finished(false);
16262 return Err(common::Error::HttpError(err));
16263 }
16264 Ok(res) => {
16265 let (mut parts, body) = res.into_parts();
16266 let mut body = common::Body::new(body);
16267 if !parts.status.is_success() {
16268 let bytes = common::to_bytes(body).await.unwrap_or_default();
16269 let error = serde_json::from_str(&common::to_string(&bytes));
16270 let response = common::to_response(parts, bytes.into());
16271
16272 if let common::Retry::After(d) =
16273 dlg.http_failure(&response, error.as_ref().ok())
16274 {
16275 sleep(d).await;
16276 continue;
16277 }
16278
16279 dlg.finished(false);
16280
16281 return Err(match error {
16282 Ok(value) => common::Error::BadRequest(value),
16283 _ => common::Error::Failure(response),
16284 });
16285 }
16286 let response = {
16287 let bytes = common::to_bytes(body).await.unwrap_or_default();
16288 let encoded = common::to_string(&bytes);
16289 match serde_json::from_str(&encoded) {
16290 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16291 Err(error) => {
16292 dlg.response_json_decode_error(&encoded, &error);
16293 return Err(common::Error::JsonDecodeError(
16294 encoded.to_string(),
16295 error,
16296 ));
16297 }
16298 }
16299 };
16300
16301 dlg.finished(true);
16302 return Ok(response);
16303 }
16304 }
16305 }
16306 }
16307
16308 /// Identifies the project addressed by this request.
16309 ///
16310 /// Sets the *project* path property to the given value.
16311 ///
16312 /// Even though the property as already been set when instantiating this call,
16313 /// we provide this method for API completeness.
16314 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
16315 self._project = new_value.to_string();
16316 self
16317 }
16318 /// User assigned name of the Response Policy to list.
16319 ///
16320 /// Sets the *response policy* path property to the given value.
16321 ///
16322 /// Even though the property as already been set when instantiating this call,
16323 /// we provide this method for API completeness.
16324 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
16325 self._response_policy = new_value.to_string();
16326 self
16327 }
16328 /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request.
16329 ///
16330 /// Sets the *page token* query property to the given value.
16331 pub fn page_token(mut self, new_value: &str) -> ResponsePolicyRuleListCall<'a, C> {
16332 self._page_token = Some(new_value.to_string());
16333 self
16334 }
16335 /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return.
16336 ///
16337 /// Sets the *max results* query property to the given value.
16338 pub fn max_results(mut self, new_value: i32) -> ResponsePolicyRuleListCall<'a, C> {
16339 self._max_results = Some(new_value);
16340 self
16341 }
16342 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16343 /// while executing the actual API request.
16344 ///
16345 /// ````text
16346 /// It should be used to handle progress information, and to implement a certain level of resilience.
16347 /// ````
16348 ///
16349 /// Sets the *delegate* property to the given value.
16350 pub fn delegate(
16351 mut self,
16352 new_value: &'a mut dyn common::Delegate,
16353 ) -> ResponsePolicyRuleListCall<'a, C> {
16354 self._delegate = Some(new_value);
16355 self
16356 }
16357
16358 /// Set any additional parameter of the query string used in the request.
16359 /// It should be used to set parameters which are not yet available through their own
16360 /// setters.
16361 ///
16362 /// Please note that this method must not be used to set any of the known parameters
16363 /// which have their own setter method. If done anyway, the request will fail.
16364 ///
16365 /// # Additional Parameters
16366 ///
16367 /// * *$.xgafv* (query-string) - V1 error format.
16368 /// * *access_token* (query-string) - OAuth access token.
16369 /// * *alt* (query-string) - Data format for response.
16370 /// * *callback* (query-string) - JSONP
16371 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16372 /// * *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.
16373 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16374 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16375 /// * *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.
16376 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16377 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16378 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleListCall<'a, C>
16379 where
16380 T: AsRef<str>,
16381 {
16382 self._additional_params
16383 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16384 self
16385 }
16386
16387 /// Identifies the authorization scope for the method you are building.
16388 ///
16389 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16390 /// [`Scope::NdevClouddnReadonly`].
16391 ///
16392 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16393 /// tokens for more than one scope.
16394 ///
16395 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16396 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16397 /// sufficient, a read-write scope will do as well.
16398 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleListCall<'a, C>
16399 where
16400 St: AsRef<str>,
16401 {
16402 self._scopes.insert(String::from(scope.as_ref()));
16403 self
16404 }
16405 /// Identifies the authorization scope(s) for the method you are building.
16406 ///
16407 /// See [`Self::add_scope()`] for details.
16408 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleListCall<'a, C>
16409 where
16410 I: IntoIterator<Item = St>,
16411 St: AsRef<str>,
16412 {
16413 self._scopes
16414 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16415 self
16416 }
16417
16418 /// Removes all scopes, and no default scope will be used either.
16419 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16420 /// for details).
16421 pub fn clear_scopes(mut self) -> ResponsePolicyRuleListCall<'a, C> {
16422 self._scopes.clear();
16423 self
16424 }
16425}
16426
16427/// Applies a partial update to an existing Response Policy Rule.
16428///
16429/// A builder for the *patch* method supported by a *responsePolicyRule* resource.
16430/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
16431///
16432/// # Example
16433///
16434/// Instantiate a resource method builder
16435///
16436/// ```test_harness,no_run
16437/// # extern crate hyper;
16438/// # extern crate hyper_rustls;
16439/// # extern crate google_dns1 as dns1;
16440/// use dns1::api::ResponsePolicyRule;
16441/// # async fn dox() {
16442/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16443///
16444/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16445/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16446/// # .with_native_roots()
16447/// # .unwrap()
16448/// # .https_only()
16449/// # .enable_http2()
16450/// # .build();
16451///
16452/// # let executor = hyper_util::rt::TokioExecutor::new();
16453/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16454/// # secret,
16455/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16456/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16457/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16458/// # ),
16459/// # ).build().await.unwrap();
16460///
16461/// # let client = hyper_util::client::legacy::Client::builder(
16462/// # hyper_util::rt::TokioExecutor::new()
16463/// # )
16464/// # .build(
16465/// # hyper_rustls::HttpsConnectorBuilder::new()
16466/// # .with_native_roots()
16467/// # .unwrap()
16468/// # .https_or_http()
16469/// # .enable_http2()
16470/// # .build()
16471/// # );
16472/// # let mut hub = Dns::new(client, auth);
16473/// // As the method needs a request, you would usually fill it with the desired information
16474/// // into the respective structure. Some of the parts shown here might not be applicable !
16475/// // Values shown here are possibly random and not representative !
16476/// let mut req = ResponsePolicyRule::default();
16477///
16478/// // You can configure optional parameters by calling the respective setters at will, and
16479/// // execute the final call using `doit()`.
16480/// // Values shown here are possibly random and not representative !
16481/// let result = hub.response_policy_rules().patch(req, "project", "responsePolicy", "responsePolicyRule")
16482/// .client_operation_id("est")
16483/// .doit().await;
16484/// # }
16485/// ```
16486pub struct ResponsePolicyRulePatchCall<'a, C>
16487where
16488 C: 'a,
16489{
16490 hub: &'a Dns<C>,
16491 _request: ResponsePolicyRule,
16492 _project: String,
16493 _response_policy: String,
16494 _response_policy_rule: String,
16495 _client_operation_id: Option<String>,
16496 _delegate: Option<&'a mut dyn common::Delegate>,
16497 _additional_params: HashMap<String, String>,
16498 _scopes: BTreeSet<String>,
16499}
16500
16501impl<'a, C> common::CallBuilder for ResponsePolicyRulePatchCall<'a, C> {}
16502
16503impl<'a, C> ResponsePolicyRulePatchCall<'a, C>
16504where
16505 C: common::Connector,
16506{
16507 /// Perform the operation you have build so far.
16508 pub async fn doit(
16509 mut self,
16510 ) -> common::Result<(common::Response, ResponsePolicyRulesPatchResponse)> {
16511 use std::borrow::Cow;
16512 use std::io::{Read, Seek};
16513
16514 use common::{url::Params, ToParts};
16515 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16516
16517 let mut dd = common::DefaultDelegate;
16518 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16519 dlg.begin(common::MethodInfo {
16520 id: "dns.responsePolicyRules.patch",
16521 http_method: hyper::Method::PATCH,
16522 });
16523
16524 for &field in [
16525 "alt",
16526 "project",
16527 "responsePolicy",
16528 "responsePolicyRule",
16529 "clientOperationId",
16530 ]
16531 .iter()
16532 {
16533 if self._additional_params.contains_key(field) {
16534 dlg.finished(false);
16535 return Err(common::Error::FieldClash(field));
16536 }
16537 }
16538
16539 let mut params = Params::with_capacity(7 + self._additional_params.len());
16540 params.push("project", self._project);
16541 params.push("responsePolicy", self._response_policy);
16542 params.push("responsePolicyRule", self._response_policy_rule);
16543 if let Some(value) = self._client_operation_id.as_ref() {
16544 params.push("clientOperationId", value);
16545 }
16546
16547 params.extend(self._additional_params.iter());
16548
16549 params.push("alt", "json");
16550 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
16551 if self._scopes.is_empty() {
16552 self._scopes
16553 .insert(Scope::CloudPlatform.as_ref().to_string());
16554 }
16555
16556 #[allow(clippy::single_element_loop)]
16557 for &(find_this, param_name) in [
16558 ("{project}", "project"),
16559 ("{responsePolicy}", "responsePolicy"),
16560 ("{responsePolicyRule}", "responsePolicyRule"),
16561 ]
16562 .iter()
16563 {
16564 url = params.uri_replacement(url, param_name, find_this, false);
16565 }
16566 {
16567 let to_remove = ["responsePolicyRule", "responsePolicy", "project"];
16568 params.remove_params(&to_remove);
16569 }
16570
16571 let url = params.parse_with_url(&url);
16572
16573 let mut json_mime_type = mime::APPLICATION_JSON;
16574 let mut request_value_reader = {
16575 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16576 common::remove_json_null_values(&mut value);
16577 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16578 serde_json::to_writer(&mut dst, &value).unwrap();
16579 dst
16580 };
16581 let request_size = request_value_reader
16582 .seek(std::io::SeekFrom::End(0))
16583 .unwrap();
16584 request_value_reader
16585 .seek(std::io::SeekFrom::Start(0))
16586 .unwrap();
16587
16588 loop {
16589 let token = match self
16590 .hub
16591 .auth
16592 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16593 .await
16594 {
16595 Ok(token) => token,
16596 Err(e) => match dlg.token(e) {
16597 Ok(token) => token,
16598 Err(e) => {
16599 dlg.finished(false);
16600 return Err(common::Error::MissingToken(e));
16601 }
16602 },
16603 };
16604 request_value_reader
16605 .seek(std::io::SeekFrom::Start(0))
16606 .unwrap();
16607 let mut req_result = {
16608 let client = &self.hub.client;
16609 dlg.pre_request();
16610 let mut req_builder = hyper::Request::builder()
16611 .method(hyper::Method::PATCH)
16612 .uri(url.as_str())
16613 .header(USER_AGENT, self.hub._user_agent.clone());
16614
16615 if let Some(token) = token.as_ref() {
16616 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16617 }
16618
16619 let request = req_builder
16620 .header(CONTENT_TYPE, json_mime_type.to_string())
16621 .header(CONTENT_LENGTH, request_size as u64)
16622 .body(common::to_body(
16623 request_value_reader.get_ref().clone().into(),
16624 ));
16625
16626 client.request(request.unwrap()).await
16627 };
16628
16629 match req_result {
16630 Err(err) => {
16631 if let common::Retry::After(d) = dlg.http_error(&err) {
16632 sleep(d).await;
16633 continue;
16634 }
16635 dlg.finished(false);
16636 return Err(common::Error::HttpError(err));
16637 }
16638 Ok(res) => {
16639 let (mut parts, body) = res.into_parts();
16640 let mut body = common::Body::new(body);
16641 if !parts.status.is_success() {
16642 let bytes = common::to_bytes(body).await.unwrap_or_default();
16643 let error = serde_json::from_str(&common::to_string(&bytes));
16644 let response = common::to_response(parts, bytes.into());
16645
16646 if let common::Retry::After(d) =
16647 dlg.http_failure(&response, error.as_ref().ok())
16648 {
16649 sleep(d).await;
16650 continue;
16651 }
16652
16653 dlg.finished(false);
16654
16655 return Err(match error {
16656 Ok(value) => common::Error::BadRequest(value),
16657 _ => common::Error::Failure(response),
16658 });
16659 }
16660 let response = {
16661 let bytes = common::to_bytes(body).await.unwrap_or_default();
16662 let encoded = common::to_string(&bytes);
16663 match serde_json::from_str(&encoded) {
16664 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16665 Err(error) => {
16666 dlg.response_json_decode_error(&encoded, &error);
16667 return Err(common::Error::JsonDecodeError(
16668 encoded.to_string(),
16669 error,
16670 ));
16671 }
16672 }
16673 };
16674
16675 dlg.finished(true);
16676 return Ok(response);
16677 }
16678 }
16679 }
16680 }
16681
16682 ///
16683 /// Sets the *request* 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 request(mut self, new_value: ResponsePolicyRule) -> ResponsePolicyRulePatchCall<'a, C> {
16688 self._request = new_value;
16689 self
16690 }
16691 /// Identifies the project addressed by this request.
16692 ///
16693 /// Sets the *project* 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 project(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
16698 self._project = new_value.to_string();
16699 self
16700 }
16701 /// User assigned name of the Response Policy containing the Response Policy Rule.
16702 ///
16703 /// Sets the *response policy* 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(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
16708 self._response_policy = new_value.to_string();
16709 self
16710 }
16711 /// User assigned name of the Response Policy Rule addressed by this request.
16712 ///
16713 /// Sets the *response policy rule* path property to the given value.
16714 ///
16715 /// Even though the property as already been set when instantiating this call,
16716 /// we provide this method for API completeness.
16717 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
16718 self._response_policy_rule = new_value.to_string();
16719 self
16720 }
16721 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
16722 ///
16723 /// Sets the *client operation id* query property to the given value.
16724 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRulePatchCall<'a, C> {
16725 self._client_operation_id = Some(new_value.to_string());
16726 self
16727 }
16728 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16729 /// while executing the actual API request.
16730 ///
16731 /// ````text
16732 /// It should be used to handle progress information, and to implement a certain level of resilience.
16733 /// ````
16734 ///
16735 /// Sets the *delegate* property to the given value.
16736 pub fn delegate(
16737 mut self,
16738 new_value: &'a mut dyn common::Delegate,
16739 ) -> ResponsePolicyRulePatchCall<'a, C> {
16740 self._delegate = Some(new_value);
16741 self
16742 }
16743
16744 /// Set any additional parameter of the query string used in the request.
16745 /// It should be used to set parameters which are not yet available through their own
16746 /// setters.
16747 ///
16748 /// Please note that this method must not be used to set any of the known parameters
16749 /// which have their own setter method. If done anyway, the request will fail.
16750 ///
16751 /// # Additional Parameters
16752 ///
16753 /// * *$.xgafv* (query-string) - V1 error format.
16754 /// * *access_token* (query-string) - OAuth access token.
16755 /// * *alt* (query-string) - Data format for response.
16756 /// * *callback* (query-string) - JSONP
16757 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16758 /// * *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.
16759 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16760 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16761 /// * *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.
16762 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16763 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16764 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRulePatchCall<'a, C>
16765 where
16766 T: AsRef<str>,
16767 {
16768 self._additional_params
16769 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16770 self
16771 }
16772
16773 /// Identifies the authorization scope for the method you are building.
16774 ///
16775 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16776 /// [`Scope::CloudPlatform`].
16777 ///
16778 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16779 /// tokens for more than one scope.
16780 ///
16781 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16782 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16783 /// sufficient, a read-write scope will do as well.
16784 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRulePatchCall<'a, C>
16785 where
16786 St: AsRef<str>,
16787 {
16788 self._scopes.insert(String::from(scope.as_ref()));
16789 self
16790 }
16791 /// Identifies the authorization scope(s) for the method you are building.
16792 ///
16793 /// See [`Self::add_scope()`] for details.
16794 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRulePatchCall<'a, C>
16795 where
16796 I: IntoIterator<Item = St>,
16797 St: AsRef<str>,
16798 {
16799 self._scopes
16800 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16801 self
16802 }
16803
16804 /// Removes all scopes, and no default scope will be used either.
16805 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16806 /// for details).
16807 pub fn clear_scopes(mut self) -> ResponsePolicyRulePatchCall<'a, C> {
16808 self._scopes.clear();
16809 self
16810 }
16811}
16812
16813/// Updates an existing Response Policy Rule.
16814///
16815/// A builder for the *update* method supported by a *responsePolicyRule* resource.
16816/// It is not used directly, but through a [`ResponsePolicyRuleMethods`] instance.
16817///
16818/// # Example
16819///
16820/// Instantiate a resource method builder
16821///
16822/// ```test_harness,no_run
16823/// # extern crate hyper;
16824/// # extern crate hyper_rustls;
16825/// # extern crate google_dns1 as dns1;
16826/// use dns1::api::ResponsePolicyRule;
16827/// # async fn dox() {
16828/// # use dns1::{Dns, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16829///
16830/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16831/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16832/// # .with_native_roots()
16833/// # .unwrap()
16834/// # .https_only()
16835/// # .enable_http2()
16836/// # .build();
16837///
16838/// # let executor = hyper_util::rt::TokioExecutor::new();
16839/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16840/// # secret,
16841/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16842/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16843/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16844/// # ),
16845/// # ).build().await.unwrap();
16846///
16847/// # let client = hyper_util::client::legacy::Client::builder(
16848/// # hyper_util::rt::TokioExecutor::new()
16849/// # )
16850/// # .build(
16851/// # hyper_rustls::HttpsConnectorBuilder::new()
16852/// # .with_native_roots()
16853/// # .unwrap()
16854/// # .https_or_http()
16855/// # .enable_http2()
16856/// # .build()
16857/// # );
16858/// # let mut hub = Dns::new(client, auth);
16859/// // As the method needs a request, you would usually fill it with the desired information
16860/// // into the respective structure. Some of the parts shown here might not be applicable !
16861/// // Values shown here are possibly random and not representative !
16862/// let mut req = ResponsePolicyRule::default();
16863///
16864/// // You can configure optional parameters by calling the respective setters at will, and
16865/// // execute the final call using `doit()`.
16866/// // Values shown here are possibly random and not representative !
16867/// let result = hub.response_policy_rules().update(req, "project", "responsePolicy", "responsePolicyRule")
16868/// .client_operation_id("Lorem")
16869/// .doit().await;
16870/// # }
16871/// ```
16872pub struct ResponsePolicyRuleUpdateCall<'a, C>
16873where
16874 C: 'a,
16875{
16876 hub: &'a Dns<C>,
16877 _request: ResponsePolicyRule,
16878 _project: String,
16879 _response_policy: String,
16880 _response_policy_rule: String,
16881 _client_operation_id: Option<String>,
16882 _delegate: Option<&'a mut dyn common::Delegate>,
16883 _additional_params: HashMap<String, String>,
16884 _scopes: BTreeSet<String>,
16885}
16886
16887impl<'a, C> common::CallBuilder for ResponsePolicyRuleUpdateCall<'a, C> {}
16888
16889impl<'a, C> ResponsePolicyRuleUpdateCall<'a, C>
16890where
16891 C: common::Connector,
16892{
16893 /// Perform the operation you have build so far.
16894 pub async fn doit(
16895 mut self,
16896 ) -> common::Result<(common::Response, ResponsePolicyRulesUpdateResponse)> {
16897 use std::borrow::Cow;
16898 use std::io::{Read, Seek};
16899
16900 use common::{url::Params, ToParts};
16901 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16902
16903 let mut dd = common::DefaultDelegate;
16904 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16905 dlg.begin(common::MethodInfo {
16906 id: "dns.responsePolicyRules.update",
16907 http_method: hyper::Method::PUT,
16908 });
16909
16910 for &field in [
16911 "alt",
16912 "project",
16913 "responsePolicy",
16914 "responsePolicyRule",
16915 "clientOperationId",
16916 ]
16917 .iter()
16918 {
16919 if self._additional_params.contains_key(field) {
16920 dlg.finished(false);
16921 return Err(common::Error::FieldClash(field));
16922 }
16923 }
16924
16925 let mut params = Params::with_capacity(7 + self._additional_params.len());
16926 params.push("project", self._project);
16927 params.push("responsePolicy", self._response_policy);
16928 params.push("responsePolicyRule", self._response_policy_rule);
16929 if let Some(value) = self._client_operation_id.as_ref() {
16930 params.push("clientOperationId", value);
16931 }
16932
16933 params.extend(self._additional_params.iter());
16934
16935 params.push("alt", "json");
16936 let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules/{responsePolicyRule}";
16937 if self._scopes.is_empty() {
16938 self._scopes
16939 .insert(Scope::CloudPlatform.as_ref().to_string());
16940 }
16941
16942 #[allow(clippy::single_element_loop)]
16943 for &(find_this, param_name) in [
16944 ("{project}", "project"),
16945 ("{responsePolicy}", "responsePolicy"),
16946 ("{responsePolicyRule}", "responsePolicyRule"),
16947 ]
16948 .iter()
16949 {
16950 url = params.uri_replacement(url, param_name, find_this, false);
16951 }
16952 {
16953 let to_remove = ["responsePolicyRule", "responsePolicy", "project"];
16954 params.remove_params(&to_remove);
16955 }
16956
16957 let url = params.parse_with_url(&url);
16958
16959 let mut json_mime_type = mime::APPLICATION_JSON;
16960 let mut request_value_reader = {
16961 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16962 common::remove_json_null_values(&mut value);
16963 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16964 serde_json::to_writer(&mut dst, &value).unwrap();
16965 dst
16966 };
16967 let request_size = request_value_reader
16968 .seek(std::io::SeekFrom::End(0))
16969 .unwrap();
16970 request_value_reader
16971 .seek(std::io::SeekFrom::Start(0))
16972 .unwrap();
16973
16974 loop {
16975 let token = match self
16976 .hub
16977 .auth
16978 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16979 .await
16980 {
16981 Ok(token) => token,
16982 Err(e) => match dlg.token(e) {
16983 Ok(token) => token,
16984 Err(e) => {
16985 dlg.finished(false);
16986 return Err(common::Error::MissingToken(e));
16987 }
16988 },
16989 };
16990 request_value_reader
16991 .seek(std::io::SeekFrom::Start(0))
16992 .unwrap();
16993 let mut req_result = {
16994 let client = &self.hub.client;
16995 dlg.pre_request();
16996 let mut req_builder = hyper::Request::builder()
16997 .method(hyper::Method::PUT)
16998 .uri(url.as_str())
16999 .header(USER_AGENT, self.hub._user_agent.clone());
17000
17001 if let Some(token) = token.as_ref() {
17002 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17003 }
17004
17005 let request = req_builder
17006 .header(CONTENT_TYPE, json_mime_type.to_string())
17007 .header(CONTENT_LENGTH, request_size as u64)
17008 .body(common::to_body(
17009 request_value_reader.get_ref().clone().into(),
17010 ));
17011
17012 client.request(request.unwrap()).await
17013 };
17014
17015 match req_result {
17016 Err(err) => {
17017 if let common::Retry::After(d) = dlg.http_error(&err) {
17018 sleep(d).await;
17019 continue;
17020 }
17021 dlg.finished(false);
17022 return Err(common::Error::HttpError(err));
17023 }
17024 Ok(res) => {
17025 let (mut parts, body) = res.into_parts();
17026 let mut body = common::Body::new(body);
17027 if !parts.status.is_success() {
17028 let bytes = common::to_bytes(body).await.unwrap_or_default();
17029 let error = serde_json::from_str(&common::to_string(&bytes));
17030 let response = common::to_response(parts, bytes.into());
17031
17032 if let common::Retry::After(d) =
17033 dlg.http_failure(&response, error.as_ref().ok())
17034 {
17035 sleep(d).await;
17036 continue;
17037 }
17038
17039 dlg.finished(false);
17040
17041 return Err(match error {
17042 Ok(value) => common::Error::BadRequest(value),
17043 _ => common::Error::Failure(response),
17044 });
17045 }
17046 let response = {
17047 let bytes = common::to_bytes(body).await.unwrap_or_default();
17048 let encoded = common::to_string(&bytes);
17049 match serde_json::from_str(&encoded) {
17050 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17051 Err(error) => {
17052 dlg.response_json_decode_error(&encoded, &error);
17053 return Err(common::Error::JsonDecodeError(
17054 encoded.to_string(),
17055 error,
17056 ));
17057 }
17058 }
17059 };
17060
17061 dlg.finished(true);
17062 return Ok(response);
17063 }
17064 }
17065 }
17066 }
17067
17068 ///
17069 /// Sets the *request* property to the given value.
17070 ///
17071 /// Even though the property as already been set when instantiating this call,
17072 /// we provide this method for API completeness.
17073 pub fn request(mut self, new_value: ResponsePolicyRule) -> ResponsePolicyRuleUpdateCall<'a, C> {
17074 self._request = new_value;
17075 self
17076 }
17077 /// Identifies the project addressed by this request.
17078 ///
17079 /// Sets the *project* path property to the given value.
17080 ///
17081 /// Even though the property as already been set when instantiating this call,
17082 /// we provide this method for API completeness.
17083 pub fn project(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17084 self._project = new_value.to_string();
17085 self
17086 }
17087 /// User assigned name of the Response Policy containing the Response Policy Rule.
17088 ///
17089 /// Sets the *response policy* path property to the given value.
17090 ///
17091 /// Even though the property as already been set when instantiating this call,
17092 /// we provide this method for API completeness.
17093 pub fn response_policy(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17094 self._response_policy = new_value.to_string();
17095 self
17096 }
17097 /// User assigned name of the Response Policy Rule addressed by this request.
17098 ///
17099 /// Sets the *response policy rule* path property to the given value.
17100 ///
17101 /// Even though the property as already been set when instantiating this call,
17102 /// we provide this method for API completeness.
17103 pub fn response_policy_rule(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17104 self._response_policy_rule = new_value.to_string();
17105 self
17106 }
17107 /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.
17108 ///
17109 /// Sets the *client operation id* query property to the given value.
17110 pub fn client_operation_id(mut self, new_value: &str) -> ResponsePolicyRuleUpdateCall<'a, C> {
17111 self._client_operation_id = Some(new_value.to_string());
17112 self
17113 }
17114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17115 /// while executing the actual API request.
17116 ///
17117 /// ````text
17118 /// It should be used to handle progress information, and to implement a certain level of resilience.
17119 /// ````
17120 ///
17121 /// Sets the *delegate* property to the given value.
17122 pub fn delegate(
17123 mut self,
17124 new_value: &'a mut dyn common::Delegate,
17125 ) -> ResponsePolicyRuleUpdateCall<'a, C> {
17126 self._delegate = Some(new_value);
17127 self
17128 }
17129
17130 /// Set any additional parameter of the query string used in the request.
17131 /// It should be used to set parameters which are not yet available through their own
17132 /// setters.
17133 ///
17134 /// Please note that this method must not be used to set any of the known parameters
17135 /// which have their own setter method. If done anyway, the request will fail.
17136 ///
17137 /// # Additional Parameters
17138 ///
17139 /// * *$.xgafv* (query-string) - V1 error format.
17140 /// * *access_token* (query-string) - OAuth access token.
17141 /// * *alt* (query-string) - Data format for response.
17142 /// * *callback* (query-string) - JSONP
17143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17144 /// * *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.
17145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17147 /// * *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.
17148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17150 pub fn param<T>(mut self, name: T, value: T) -> ResponsePolicyRuleUpdateCall<'a, C>
17151 where
17152 T: AsRef<str>,
17153 {
17154 self._additional_params
17155 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17156 self
17157 }
17158
17159 /// Identifies the authorization scope for the method you are building.
17160 ///
17161 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17162 /// [`Scope::CloudPlatform`].
17163 ///
17164 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17165 /// tokens for more than one scope.
17166 ///
17167 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17168 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17169 /// sufficient, a read-write scope will do as well.
17170 pub fn add_scope<St>(mut self, scope: St) -> ResponsePolicyRuleUpdateCall<'a, C>
17171 where
17172 St: AsRef<str>,
17173 {
17174 self._scopes.insert(String::from(scope.as_ref()));
17175 self
17176 }
17177 /// Identifies the authorization scope(s) for the method you are building.
17178 ///
17179 /// See [`Self::add_scope()`] for details.
17180 pub fn add_scopes<I, St>(mut self, scopes: I) -> ResponsePolicyRuleUpdateCall<'a, C>
17181 where
17182 I: IntoIterator<Item = St>,
17183 St: AsRef<str>,
17184 {
17185 self._scopes
17186 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17187 self
17188 }
17189
17190 /// Removes all scopes, and no default scope will be used either.
17191 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17192 /// for details).
17193 pub fn clear_scopes(mut self) -> ResponsePolicyRuleUpdateCall<'a, C> {
17194 self._scopes.clear();
17195 self
17196 }
17197}