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