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